-
Notifications
You must be signed in to change notification settings - Fork 0
/
fwFsmAtlasWidget.ctl
295 lines (259 loc) · 9.37 KB
/
fwFsmAtlasWidget.ctl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
//#uses "fwAtlasAlarmHandling/fwAtlasAlarmHandlingScreen.ctl"
fwFsmAtlasWidget_initializeWidgetValue(string dpe, string format="[4.1f,,, FALSE,]")
{
if (!dpExists(dpe)) {
this.backCol = "_dpdoesnotexist";
this.toolTipText = "DPE does not exist!";
}
else {
_fwFsmAtlasWidget_initializeWidgetValue(dpe, format);
}
}
_fwFsmAtlasWidget_initializeWidgetValue(string dpe, string format="[4.1f,,, FALSE,]")
{
this.format = format;
dpConnect("_fwFsmAtlasWidget_updateValue", true, dpe);
}
fwFsmAtlasWidget_initializeWidgetColor(string dpe, string qualityEl="")
{
if (!dpExists(dpe)) {
this.backCol = "_dpdoesnotexist";
this.toolTipText = "DPE does not exist!";
}
else {
_fwFsmAtlasWidget_initializeWidgetColor(dpe, qualityEl);
}
}
_fwFsmAtlasWidget_initializeWidgetColor(string dpe, string qualityEl="")
{
if(qualityEl == "") {
qualityEl = dpSubStr(dpe, DPSUB_SYS_DP) + ".quality";
}
bool quality = dpExists(qualityEl);
int alertType;
dpGet(dpe + ":_alert_hdl.._type", alertType);
if (alertType && quality) {
dpConnect("_fwFsmAtlasWidget_updateAllCallback", true,
dpe+":_online.._bad",
dpe+":_online.._invalid",
qualityEl+".bad",
qualityEl+".uncertain",
dpe+":_alert_hdl.._act_state",
dpe+":_alert_hdl.._act_text",
dpe+":_alert_hdl.._active");
}
else if (alertType){
dpConnect("_fwFsmAtlasWidget_updateDpeAlertCallback", true,
dpe+":_online.._bad",
dpe+":_online.._invalid",
dpe+":_alert_hdl.._act_state",
dpe+":_alert_hdl.._act_text",
dpe+":_alert_hdl.._active");
}
else if (quality){
dpConnect("_fwFsmAtlasWidget_updateDpeQualityCallback", true,
dpe+":_online.._bad",
dpe+":_online.._invalid",
qualityEl+".bad",
qualityEl+".uncertain");
}
else {
dpConnect("_fwFsmAtlasWidget_updateDpeCallback", true,
dpe+":_online.._bad",
dpe+":_online.._invalid");
}
}
_fwFsmAtlasWidget_updateAllCallback(string badAttr, bool bad,
string invalidAttr, bool invalid,
string qualityBadEl, bool qualityBad,
string qualityUncertainEl, bool qualityUncertain,
string alertStateAttr, string alertState,
string alertTextAttr, string alertText,
string alertActive, string active)
{
if (invalid || bad) _fwFsmAtlasWidget_updateDpe(badAttr, bad,
invalidAttr, invalid);
else if (qualityBad || qualityUncertain) _fwFsmAtlasWidget_updateQuality(qualityBadEl, qualityBad,
qualityUncertainEl, qualityUncertain);
else _fwFsmAtlasWidget_updateAlert(alertStateAttr, alertState,
alertTextAttr, alertText,
alertActive, active);
}
_fwFsmAtlasWidget_updateDpeAlertCallback(string badAttr, bool bad,
string invalidAttr, bool invalid,
string alertStateAttr, string alertState,
string alertTextAttr, string alertText,
string alertActive, string active)
{
if (invalid || bad) _fwFsmAtlasWidget_updateDpe(badAttr, bad,
invalidAttr, invalid);
else _fwFsmAtlasWidget_updateAlert(alertStateAttr, alertState,
alertTextAttr, alertText,
alertActive, active);
}
_fwFsmAtlasWidget_updateDpeQualityCallback(string badAttr, bool bad,
string invalidAttr, bool invalid,
string qualityBadEl, bool qualityBad,
string qualityUncertainEl, bool qualityUncertain)
{
this.backCol = "FwNoAlarmOKPhysics";
fwFsmAtlasWidget_setDescriptionAsTooltip();
if (invalid || bad) _fwFsmAtlasWidget_updateDpe(badAttr, bad,
invalidAttr, invalid);
else _fwFsmAtlasWidget_updateQuality(qualityBadEl, qualityBad,
qualityUncertainEl, qualityUncertain);
}
_fwFsmAtlasWidget_updateDpeCallback(string badAttr, bool bad,
string invalidAttr, bool invalid)
{
this.backCol = "FwNoAlarmOKPhysics";
fwFsmAtlasWidget_setDescriptionAsTooltip();
_fwFsmAtlasWidget_updateDpe(badAttr, bad,
invalidAttr, invalid);
}
_fwFsmAtlasWidget_updateAlert(string alertStateAttr, string alertState,
string alertTextAttr, string alertText,
string alertActive, string active)
{
string color = alertText;
string sTemp = dpSubStr(alertStateAttr, DPSUB_SYS_DP_EL);
int error = dpGet(sTemp + ":_alert_hdl.._act_state_color", color);
if (active && !error) {
if (color=="") color = "FwStateOKPhysics";
this.backCol = color;
this.toolTipText = alertText;
}
else if (!active) {
this.backCol = "FwAlarmDeactivated";
this.toolTipText = "Alert deactivated";
}
else {
error("Error in dpGet("+sTemp+":_alert_hdl.._act_state_color)");
}
}
_fwFsmAtlasWidget_updateQuality(string qualityBadEl, bool qualityBad,
string qualityUncertainEl, bool qualityUncertain)
{
if (qualityBad || qualityUncertain) {
this.backCol = "FwNoAlarmOKPhysics";
if(qualityBad){ this.toolTipText = "QUALITY BAD"; }
else if(qualityUncertain){ this.toolTipText = "QUALITY UNCERTAIN"; }
}
}
_fwFsmAtlasWidget_updateDpe(string badAttr, bool bad,
string invalidAttr, bool invalid)
{
if (invalid || bad) {
this.backCol = "FwNoAlarmOKPhysics";
if(bad){ this.toolTipText = "BAD DATA"; }
else if(invalid){ this.toolTipText = "INVALID DATA"; }
}
}
_fwFsmAtlasWidget_updateValue(string dpeName, string value)
{
this.text = value;
}
fwFsmAtlasWidget_setDescriptionAsTooltip()
{
string tooltip = dpGetComment($dpe);
if (tooltip=="") tooltip = $dpe;
this.toolTipText = tooltip;
}
fwFsmAtlasWidget_scaleWidth(float originalX)
{
int width = $width;
float scale = width/originalX;
this.scale(scale, 1);
int xV, yV, xU, yU;
getValue("","position",xV,yV);
if (shapeExists("Unit")) {
getValue("Unit","position",xU,yU);
int newStart = xV+width + 2; // adjust to your taste
Unit.position(newStart, yU);
}
}
fwFsmAtlasWidget_rightMousePressed(string dpe, int width=60)
{
string plotName = dpGetComment(dpe);
if (plotName=="") plotName = dpe;
strreplace(plotName, "/", "_");
strreplace(plotName, ".", "_");
dyn_string ex;
// fwTrending_createPlot(plotName, ex);
if (dynlen(ex)) DebugTN(ex);
int x, y;
int width;
getValue("", "position", x, y);
x += width+40;
//ChildPanelOn("objects/fsmAtlas/quick_trend.pnl", plotName, makeDynString("$plotName:"+plotName, "$dpe:"+$dpe), x, y);
ModuleOnWithPanel(plotName+"Module", x, y, 0, 0, 1, 1, "",
"objects/fsmAtlas/quick_trend.pnl", plotName, makeDynString("$plotName:"+plotName, "$dpe:"+dpe));
// fwTrending_openPlotDisplay(plotName, fwTrending_PANEL_PLOT_FACEPLATE, false, true, "", plotName, x, y);
}
fwFsmAtlasWidget_rightMousePressedOnParameter(string dpe)
{
// DebugTN("fwFsmAtlasWidget_rightMousePressedOnParameter "+dpe);
string subdet = fwAtlas_getSubdetectorId(dpSubStr(dpe, DPSUB_SYS));
if (subdet=="EXT" || subdet=="SAF") subdet = "GCS";
dyn_string ex;
int granted;
fwAccessControl_isGranted(subdet+":Expert", granted, ex);
if (dynlen(ex)) fwAccessControl_displayException(ex);
if (!granted) {
return;
}
dynClear(ex);
int admin;
fwAccessControl_isGranted(subdet+":Administration", admin, ex);
if (dynlen(ex)) fwAccessControl_displayException(ex);
// DebugTN("fwFsmAtlasWidget_rightMousePressedOnParameter admin "+admin);
// fill menu
//
dyn_string menu = makeDynString(
"PUSH_BUTTON, Expert Options, 1, 0", // title
"SEPARATOR",
"PUSH_BUTTON, Description, 2, 1"
);
int alertType, archiveType;
dpGet(dpe+":_alert_hdl.._type", alertType, dpe+":_archive.._type", archiveType);
if (alertType>0 || admin==1) dynAppend(menu, "PUSH_BUTTON, Alert Settings, 3, 1");
else dynAppend(menu, "PUSH_BUTTON, Alert Settings, 3, 0");
if ( (archiveType>0 || admin==1 ) && dpExists(dpSubStr(dpe, DPSUB_DP)) ) dynAppend(menu, "PUSH_BUTTON, Archive Settings, 4, 1"); // must be local DP
else dynAppend(menu, "PUSH_BUTTON, Archive Settings, 4, 0");
if (alertType>0) {
dynAppend(menu, "SEPARATOR");
if (fwInstallation_checkInstalledComponent("fwAlarmAtlas")==-1) dynAppend(menu, "PUSH_BUTTON, Alarm Help, 5, 0");
else dynAppend(menu, "PUSH_BUTTON, Alarm Help, 5, 1");
}
DebugTN("Menu: ", menu);
int answer = 0;
popupMenu(menu, answer);
// DebugTN("Menu answer = "+answer);
if (answer == 0) {
DebugTN("No answer selected, abort");
return;
}
string description = dpGetComment(dpe);
switch (answer) {
case 2:
DebugTN("Description");
ChildPanelOnCentralModal("objects/fwAtlas/fwAtlas_setDescription.pnl", "Set New Description for "+dpe, makeDynString("$dpid:"+dpe));
break;
case 3:
DebugTN("Alert");
ChildPanelOnCentralModal("objects/fwAtlas/fwAtlas_alertSettings.pnl", "Alert Settings for "+description,
makeDynString("$sDpe:"+dpe, "$fromFsm:1", "$alertExists:"+alertType, "$admin:"+admin));
break;
case 4:
DebugTN("Archive");
ChildPanelOnCentralModal("objects/fwAtlas/fwAtlas_archiveSettings.pnl", "Archive Settings for "+description, makeDynString("$sDpe:"+dpe,"$fromFsm:1"));
break;
case 5:
DebugTN("Alarm help");
fwAlarmScreenUser_showHelp(dpe, "", 0, ex);
break;
default:
DebugTN("No answer selected, abort");
break;
}
}