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