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