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