981
|
1 |
SimpleView subclass:#SystemStatusMonitor
|
|
2 |
instanceVariableNames:'listView listUpdateDelay updateDelay updateBlock listUpdateBlock
|
|
3 |
updateProcess'
|
|
4 |
classVariableNames:''
|
|
5 |
poolDictionaries:''
|
|
6 |
category:'Interface-Tools'
|
|
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.
|
|
97 |
listView font:font.
|
|
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 |
|
|
118 |
"Modified: 23.1.1997 / 03:21:14 / cg"
|
|
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 |
[
|
|
153 |
|id cnt|
|
|
154 |
|
|
155 |
"
|
|
156 |
every 20ms, we look which process runs;
|
|
157 |
every half second, the status is updated.
|
|
158 |
every 5 seconds, the list of processes is
|
|
159 |
built up again
|
|
160 |
"
|
|
161 |
[true] whileTrue:[
|
|
162 |
1 to:9 do:[:i |
|
|
163 |
"/ cpuUsages := IdentityDictionary new.
|
|
164 |
"/ 1 to:25 do:[:i |
|
|
165 |
"/ (Delay forSeconds:0.02) wait.
|
|
166 |
"/ id := Processor interruptedProcess id.
|
|
167 |
"/ cnt := cpuUsages at:id ifAbsent:[0].
|
|
168 |
"/ cpuUsages at:id put:cnt + 1.
|
|
169 |
"/ ].
|
|
170 |
Delay waitForSeconds:0.5.
|
|
171 |
self updateStatus.
|
|
172 |
].
|
|
173 |
Delay waitForSeconds:0.5.
|
|
174 |
self updateList.
|
|
175 |
]
|
|
176 |
] valueOnUnwindDo:[
|
|
177 |
updateProcess := nil
|
|
178 |
]
|
|
179 |
] forkAt:(Processor userSchedulingPriority + 1).
|
|
180 |
updateProcess name:'monitor [' ,
|
|
181 |
Processor activeProcess id printString ,
|
|
182 |
'] update'.
|
|
183 |
"
|
|
184 |
raise my own priority
|
|
185 |
"
|
|
186 |
Processor activeProcess priority:(Processor userSchedulingPriority + 2)
|
|
187 |
].
|
|
188 |
|
|
189 |
"Modified: 12.6.1996 / 19:53:13 / cg"
|
|
190 |
"Created: 23.1.1997 / 02:30:58 / cg"
|
|
191 |
! !
|
|
192 |
|
|
193 |
!SystemStatusMonitor methodsFor:'queries'!
|
|
194 |
|
|
195 |
preferredExtent
|
|
196 |
"return my preferred extent"
|
|
197 |
|
|
198 |
^ (font widthOf:self titleLine) + 40 @ 100
|
|
199 |
|
|
200 |
"Modified: 23.1.1997 / 02:35:01 / cg"
|
|
201 |
"Created: 23.1.1997 / 02:51:24 / cg"
|
|
202 |
! !
|
|
203 |
|
|
204 |
!SystemStatusMonitor class methodsFor:'documentation'!
|
|
205 |
|
|
206 |
version
|
|
207 |
^ '$Header: /cvs/stx/stx/libtool/SystemStatusMonitor.st,v 1.1 1997-01-23 02:28:30 cg Exp $'
|
|
208 |
! !
|