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