author | Claus Gittinger <cg@exept.de> |
Tue, 14 Dec 1999 21:15:32 +0100 | |
changeset 2488 | 65689c6d5bd6 |
parent 2410 | 292d61292ac8 |
child 2699 | dcb83b594b14 |
permissions | -rw-r--r-- |
981 | 1 |
SimpleView subclass:#SystemStatusMonitor |
2 |
instanceVariableNames:'listView listUpdateDelay updateDelay updateBlock listUpdateBlock |
|
3 |
updateProcess' |
|
4 |
classVariableNames:'' |
|
5 |
poolDictionaries:'' |
|
1053 | 6 |
category:'Monitors-ST/X' |
981 | 7 |
! |
8 |
||
9 |
||
10 |
!SystemStatusMonitor class methodsFor:'defaults'! |
|
11 |
||
12 |
defaultIcon |
|
13 |
^ StandardSystemView defaultIcon |
|
14 |
||
15 |
"Created: 23.1.1997 / 02:52:25 / cg" |
|
16 |
! |
|
17 |
||
18 |
defaultLabel |
|
19 |
^ 'Status Monitor' |
|
20 |
||
21 |
"Created: 23.1.1997 / 02:52:43 / cg" |
|
22 |
! ! |
|
23 |
||
24 |
!SystemStatusMonitor class methodsFor:'startup'! |
|
25 |
||
1823 | 26 |
isVisualStartable |
27 |
^ self ~~ SystemStatusMonitor |
|
28 |
||
29 |
"Created: / 10.8.1998 / 16:02:23 / cg" |
|
30 |
"Modified: / 10.8.1998 / 16:02:41 / cg" |
|
31 |
! |
|
32 |
||
981 | 33 |
open |
34 |
|top monitor| |
|
35 |
||
36 |
top := StandardSystemView new. |
|
37 |
monitor := self origin:0.0@0.0 corner:1.0@1.0 in:top. |
|
38 |
top extent:monitor preferredExtent. |
|
39 |
top label:self defaultLabel. |
|
40 |
top icon:self defaultIcon. |
|
2410 | 41 |
top open. |
42 |
||
43 |
^ monitor |
|
981 | 44 |
|
45 |
" |
|
46 |
ProcessMonitor open |
|
47 |
" |
|
48 |
||
49 |
"Created: 23.1.1997 / 02:53:42 / cg" |
|
50 |
! ! |
|
51 |
||
52 |
!SystemStatusMonitor methodsFor:'destroying'! |
|
53 |
||
54 |
destroy |
|
55 |
updateBlock notNil ifTrue:[ |
|
56 |
Processor removeTimedBlock:updateBlock. |
|
57 |
Processor removeTimedBlock:listUpdateBlock. |
|
58 |
] ifFalse:[ |
|
59 |
updateProcess notNil ifTrue:[updateProcess terminate] |
|
60 |
]. |
|
61 |
super destroy |
|
62 |
||
63 |
"Created: 23.1.1997 / 02:26:50 / cg" |
|
64 |
! ! |
|
65 |
||
66 |
!SystemStatusMonitor methodsFor:'drawing'! |
|
67 |
||
68 |
updateView |
|
69 |
self updateList. |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
70 |
self updateStatus:nil |
981 | 71 |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
72 |
"Created: / 23.1.1997 / 02:27:05 / cg" |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
73 |
"Modified: / 14.12.1999 / 20:47:37 / cg" |
981 | 74 |
! ! |
75 |
||
76 |
!SystemStatusMonitor methodsFor:'events'! |
|
77 |
||
78 |
canHandle:key |
|
79 |
^ key == #InspectIt |
|
80 |
||
81 |
"Created: 23.1.1997 / 02:27:15 / cg" |
|
82 |
! |
|
83 |
||
84 |
keyPress:key x:x y:y |
|
85 |
<resource: #keyboard ( #InspectIt ) > |
|
86 |
||
87 |
key == #InspectIt ifTrue:[ |
|
1897 | 88 |
^ self inspectSelection. |
981 | 89 |
]. |
90 |
^ super keyPress:key x:x y:y |
|
91 |
||
92 |
"Modified: 23.1.1997 / 02:27:27 / cg" |
|
93 |
"Created: 23.1.1997 / 02:27:45 / cg" |
|
94 |
! ! |
|
95 |
||
96 |
!SystemStatusMonitor methodsFor:'initialization'! |
|
97 |
||
98 |
initialize |
|
99 |
|v| |
|
100 |
||
101 |
super initialize. |
|
102 |
||
103 |
v := HVScrollableView for:SelectionInListView miniScrollerH:true in:self. |
|
104 |
v origin:0.0@0.0 corner:1.0@1.0. |
|
105 |
||
106 |
listView := v scrolledView. |
|
1273
3a8a91e6c5fa
give my listView a fixed font.
Claus Gittinger <cg@exept.de>
parents:
1053
diff
changeset
|
107 |
listView font:(EditTextView defaultFont). |
981 | 108 |
listView menuHolder:self; menuPerformer:self; menuMessage:#statusMenu. |
109 |
||
110 |
listView multipleSelectOk:true. |
|
1897 | 111 |
"/ listView toggleSelect:true. |
981 | 112 |
listView delegate:(KeyboardForwarder toView:self). |
113 |
listView doubleClickAction:[:line | self doubleClicked]. |
|
114 |
||
115 |
updateDelay := 0.5. |
|
116 |
listUpdateDelay := 5. |
|
117 |
||
118 |
"/ event mode is no longer used; |
|
119 |
"/ this event support may vanish |
|
120 |
Processor isPureEventDriven ifTrue:[ |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
121 |
updateBlock := [self updateStatus:nil]. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
122 |
listUpdateBlock := [self updateList]. |
981 | 123 |
]. |
124 |
||
125 |
" |
|
126 |
ProcessMonitor open |
|
127 |
" |
|
128 |
||
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
129 |
"Modified: / 14.12.1999 / 20:47:57 / cg" |
981 | 130 |
! |
131 |
||
132 |
mapped |
|
133 |
super mapped. |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
134 |
self updateStatus:nil. |
981 | 135 |
self updateList. |
136 |
||
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
137 |
"Created: / 23.1.1997 / 02:30:05 / cg" |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
138 |
"Modified: / 14.12.1999 / 20:47:54 / cg" |
981 | 139 |
! |
140 |
||
141 |
realize |
|
142 |
super realize. |
|
143 |
||
144 |
self startUpdateProcess. |
|
145 |
||
146 |
"Created: 23.1.1997 / 02:30:28 / cg" |
|
147 |
! |
|
148 |
||
149 |
reinitialize |
|
150 |
updateProcess := nil. |
|
151 |
super reinitialize. |
|
152 |
self startUpdateProcess. |
|
153 |
||
154 |
"Modified: 22.12.1995 / 22:51:14 / cg" |
|
155 |
"Created: 23.1.1997 / 02:30:43 / cg" |
|
156 |
! |
|
157 |
||
158 |
startUpdateProcess |
|
159 |
updateBlock notNil ifTrue:[ |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
160 |
Processor addTimedBlock:updateBlock afterSeconds:updateDelay. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
161 |
Processor addTimedBlock:listUpdateBlock afterSeconds:listUpdateDelay. |
981 | 162 |
] ifFalse:[ |
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
163 |
updateProcess := [ |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
164 |
[ |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
165 |
|id cnt myDelay| |
992 | 166 |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
167 |
myDelay := Delay forSeconds:0.5. |
981 | 168 |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
169 |
" |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
170 |
every 20ms, we look which process runs; |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
171 |
every half second, the status is updated. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
172 |
every 5 seconds, the list of processes is |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
173 |
built up again |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
174 |
" |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
175 |
[true] whileTrue:[ |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
176 |
1 to:9 do:[:i | |
981 | 177 |
"/ cpuUsages := IdentityDictionary new. |
178 |
"/ 1 to:25 do:[:i | |
|
179 |
"/ (Delay forSeconds:0.02) wait. |
|
180 |
"/ id := Processor interruptedProcess id. |
|
181 |
"/ cnt := cpuUsages at:id ifAbsent:[0]. |
|
182 |
"/ cpuUsages at:id put:cnt + 1. |
|
183 |
"/ ]. |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
184 |
myDelay wait. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
185 |
self updateStatus:nil. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
186 |
]. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
187 |
myDelay wait. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
188 |
self updateList. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
189 |
] |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
190 |
] valueOnUnwindDo:[ |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
191 |
updateProcess := nil |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
192 |
] |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
193 |
] forkAt:(Processor userSchedulingPriority + 1). |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
194 |
updateProcess name:'monitor [' , |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
195 |
Processor activeProcess id printString , |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
196 |
'] update'. |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
197 |
" |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
198 |
raise my own priority |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
199 |
" |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
200 |
Processor activeProcess priority:(Processor userSchedulingPriority + 2) |
981 | 201 |
]. |
202 |
||
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
203 |
"Created: / 23.1.1997 / 02:30:58 / cg" |
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
204 |
"Modified: / 14.12.1999 / 20:47:50 / cg" |
981 | 205 |
! ! |
206 |
||
207 |
!SystemStatusMonitor methodsFor:'queries'! |
|
208 |
||
209 |
preferredExtent |
|
210 |
"return my preferred extent" |
|
211 |
||
212 |
^ (font widthOf:self titleLine) + 40 @ 100 |
|
213 |
||
214 |
"Modified: 23.1.1997 / 02:35:01 / cg" |
|
215 |
"Created: 23.1.1997 / 02:51:24 / cg" |
|
216 |
! ! |
|
217 |
||
218 |
!SystemStatusMonitor class methodsFor:'documentation'! |
|
219 |
||
220 |
version |
|
2488
65689c6d5bd6
changes to avoid loosing the selection when the list is updated
Claus Gittinger <cg@exept.de>
parents:
2410
diff
changeset
|
221 |
^ '$Header: /cvs/stx/stx/libtool/SystemStatusMonitor.st,v 1.10 1999-12-14 20:15:32 cg Exp $' |
981 | 222 |
! ! |