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