-
Notifications
You must be signed in to change notification settings - Fork 2
/
property.c
1911 lines (1684 loc) · 63.9 KB
/
property.c
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
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* National Laboratory.
* Copyright (c) 2002 Deutches Elektronen-Synchrotron in der Helmholtz-
* Gemelnschaft (DESY).
* Copyright (c) 2002 Berliner Speicherring-Gesellschaft fuer Synchrotron-
* Strahlung mbH (BESSY).
* Copyright (c) 2002 Southeastern Universities Research Association, as
* Operator of Thomas Jefferson National Accelerator Facility.
* Copyright (c) 2002 The Regents of the University of California, as
* Operator of Los Alamos National Laboratory.
* This file is distributed subject to a Software License Agreement found
* in the file LICENSE that is included with this distribution.
\*************************************************************************/
/* property.c */
/************************DESCRIPTION***********************************
routines for display of group and channel properties
**********************************************************************/
#include <stdlib.h>
#include <stdio.h>
#include <Xm/Xm.h>
#include <Xm/AtomMgr.h>
#include <Xm/DialogS.h>
#include <Xm/Form.h>
#include <Xm/Frame.h>
#include <Xm/LabelG.h>
#include <Xm/PushB.h>
#include <Xm/ToggleB.h>
#include <Xm/PanedW.h>
#include <Xm/Protocols.h>
#include <Xm/RowColumn.h>
#include <Xm/ScrolledW.h>
#include <Xm/Text.h>
#include <Xm/TextF.h>
#include <Xm/ToggleBG.h>
#include "alarm.h"
#include "axArea.h"
#include "alLib.h"
#include "ax.h"
extern Pixel bg_pixel[ALH_ALARM_NSEV];
struct propWindow {
void *area;
Widget menuButton;
Widget propDialog;
Widget nameLabelW;
Widget nameTextW;
Widget alarmMaskStringLabelW;
Widget alarmMaskToggleButtonW[ALARM_NMASK];
Widget resetMaskStringLabelW;
Widget maskFrameW;
Widget beepSeverityValueTextW;
Widget severityPVnameTextW;
Widget countFilterFrame;
Widget countFilterCountTextW;
Widget countFilterSecondsTextW;
Widget forcePVnameTextW;
Widget forcePVForceMaskStringLabelW;
Widget forceMaskToggleButtonW[ALARM_NMASK];
Widget forcePVcurrentValueTextW;
Widget forcePVforceValueTextW;
Widget forcePVresetValueTextW;
Widget forcePVCalcExpressionTextW;
Widget forcePVCalcPVTextW[NO_OF_CALC_PVS];
Widget aliasTextW;
Widget processTextW;
Widget statProcessTextW;
Widget sevrProcessTextW;
Widget guidanceTextW;
Widget guidanceUrlW;
};
extern char * alhAlarmSeverityString[];
/* forward declarations */
static void propApplyCallback(Widget widget,XtPointer calldata,XtPointer cbs);
static void propCancelCallback(Widget widget,XtPointer calldata,XtPointer cbs);
static void propDismissCallback(Widget widget,XtPointer calldata,XtPointer cbs);
static void propHelpCallback(Widget widget,XtPointer calldata,XtPointer cbs);
static void propCreateDialog(ALINK*area);
static void propUpdateDialogWidgets(struct propWindow *propWindow);
static void propMaskChangeCallback( Widget widget,XtPointer calldata,XtPointer cbs);
static void propEditableDialogWidgets(ALINK *area);
static GCLINK *propCreateClone(GCLINK *link,int linkType);
#if 0
static void propDeleteClone(GCLINK *link,int linkType);
#endif
/******************************************************
propUpdateDialog
******************************************************/
void propUpdateDialog(ALINK *area)
{
struct propWindow *propWindow;
propWindow = (struct propWindow *)area->propWindow;
if (!propWindow) return;
if (!propWindow->propDialog || !XtIsManaged(propWindow->propDialog)) return;
propUpdateDialogWidgets(propWindow);
}
/******************************************************
propShowDialog
******************************************************/
void propShowDialog(ALINK *area,Widget menuButton)
{
struct propWindow *propWindow;
propWindow = (struct propWindow *)area->propWindow;
/* dismiss Dialog */
if (propWindow && propWindow->propDialog &&
XtIsManaged(propWindow->propDialog)) {
propDismissCallback(NULL, (XtPointer)propWindow, NULL);
return;
}
/* create propWindow and Dialog Widgets if necessary */
if (!propWindow) propCreateDialog(area);
/* update propWindow link info */
propWindow = (struct propWindow *)area->propWindow;
propWindow->menuButton = menuButton;
/* update Dialog Widgets */
propUpdateDialogWidgets(propWindow);
/* show Dialog */
if (!propWindow->propDialog) return;
if (!XtIsManaged(propWindow->propDialog)) {
XtManageChild(propWindow->propDialog);
}
XMapWindow(XtDisplay(propWindow->propDialog),
XtWindow(XtParent(propWindow->propDialog)));
if (menuButton) XtVaSetValues(menuButton, XmNset, TRUE, NULL);
}
/******************************************************
propUpdateDialogWidgets
******************************************************/
static void propUpdateDialogWidgets(struct propWindow *propWindow)
{
struct gcData *pgcData;
struct chanData *pcData = 0;
GCLINK *link;
int linkType;
XmString string;
char buff[MAX_STRING_LENGTH];
char buff1[MAX_STRING_LENGTH];
char *str;
SNODE *pt;
int i=0;
struct guideLink *guideLink;
MASK mask;
Pixel textBackground;
Pixel textBackgroundNS;
size_t ii=0;
if (programId != ALH) textBackground = bg_pixel[3];
else textBackground = bg_pixel[0];
textBackgroundNS = bg_pixel[0];
link =getSelectionLinkArea(propWindow->area);
if (! propWindow || !propWindow->propDialog) return;
if (!link) {
XmTextFieldSetString(propWindow->nameTextW, "");
string = XmStringCreateSimple("-----");
XtVaSetValues(propWindow->alarmMaskStringLabelW, XmNlabelString, string, NULL);
XmStringFree(string);
if (programId == ALH) {
string = XmStringCreateSimple("-");
XtVaSetValues(propWindow->resetMaskStringLabelW, XmNlabelString, string, NULL);
XmStringFree(string);
}
if (programId != ALH) {
XmToggleButtonSetState(propWindow->alarmMaskToggleButtonW[0],FALSE,TRUE);
XmToggleButtonSetState(propWindow->alarmMaskToggleButtonW[1],FALSE,TRUE);
XmToggleButtonSetState(propWindow->alarmMaskToggleButtonW[2],FALSE,TRUE);
XmToggleButtonSetState(propWindow->alarmMaskToggleButtonW[3],FALSE,TRUE);
XmToggleButtonSetState(propWindow->alarmMaskToggleButtonW[4],FALSE,TRUE);
}
XmTextFieldSetString(propWindow->beepSeverityValueTextW,"");
XmTextFieldSetString(propWindow->severityPVnameTextW,"");
XmTextFieldSetString(propWindow->countFilterCountTextW,"");
XmTextFieldSetString(propWindow->countFilterSecondsTextW,"");
/* ForcePV data */
XmTextFieldSetString(propWindow->forcePVnameTextW,"");
string = XmStringCreateSimple("-----");
XtVaSetValues(propWindow->forcePVForceMaskStringLabelW, XmNlabelString, string, NULL);
XmStringFree(string);
/*
if (programId == ALH) {
string = XmStringCreateSimple("");
XtVaSetValues(propWindow->forcePVcurrentValueTextW, XmNlabelString, string, NULL);
XmStringFree(string);
}
*/
XmTextFieldSetString(propWindow->forcePVforceValueTextW,"");
XmTextFieldSetString(propWindow->forcePVresetValueTextW,"");
XmTextFieldSetString(propWindow->forcePVCalcExpressionTextW,"");
for (i=0;i<NO_OF_CALC_PVS;i++){
XmTextFieldSetString(propWindow->forcePVCalcPVTextW[i],"");
}
XmTextFieldSetString(propWindow->aliasTextW,"");
XmTextFieldSetString(propWindow->processTextW,"");
XmTextFieldSetString(propWindow->sevrProcessTextW,"");
XmTextFieldSetString(propWindow->statProcessTextW,"");
XmTextSetString(propWindow->guidanceTextW, "");
XmTextSetString(propWindow->guidanceUrlW, "");
return;
}
pgcData = link->pgcData;
linkType =getSelectionLinkTypeArea(propWindow->area);
if (linkType == CHANNEL) pcData = (struct chanData *)pgcData;
/* ---------------------------------
Group/Channel Name
--------------------------------- */
if (linkType == GROUP) string = XmStringCreateSimple("Group ");
else string = XmStringCreateSimple("Channel");
XtVaSetValues(propWindow->nameLabelW, XmNlabelString, string, NULL);
XmStringFree(string);
XmTextFieldSetString(propWindow->nameTextW, pgcData->name);
/*
if (strncmp(pgcData->name,"Unnamed",7))
XmTextFieldSetString(propWindow->nameTextW, pgcData->name);
else
XmTextFieldSetString(propWindow->nameTextW, "");
*/
/* ---------------------------------
Current Alarm Mask
--------------------------------- */
if (linkType == GROUP) awGetMaskString(((struct groupData *)pgcData)->mask,buff);
else alGetMaskString(pcData->curMask,buff);
string = XmStringCreateSimple(buff);
XtVaSetValues(propWindow->alarmMaskStringLabelW, XmNlabelString, string, NULL);
XmStringFree(string);
if (programId != ALH) {
if (linkType == GROUP) XtSetSensitive(propWindow->maskFrameW, FALSE);
else XtSetSensitive(propWindow->maskFrameW, TRUE);
alSetMask(buff,&mask);
if (mask.Cancel == 1 )
XmToggleButtonSetState(propWindow->alarmMaskToggleButtonW[0],TRUE,TRUE);
else XmToggleButtonSetState(propWindow->alarmMaskToggleButtonW[0],FALSE,TRUE);
if (mask.Disable == 1 )
XmToggleButtonSetState(propWindow->alarmMaskToggleButtonW[1],TRUE,TRUE);
else XmToggleButtonSetState(propWindow->alarmMaskToggleButtonW[1],FALSE,TRUE);
if (mask.Ack == 1 )
XmToggleButtonSetState(propWindow->alarmMaskToggleButtonW[2],TRUE,TRUE);
else XmToggleButtonSetState(propWindow->alarmMaskToggleButtonW[2],FALSE,TRUE);
if (mask.AckT == 1 )
XmToggleButtonSetState(propWindow->alarmMaskToggleButtonW[3],TRUE,TRUE);
else XmToggleButtonSetState(propWindow->alarmMaskToggleButtonW[3],FALSE,TRUE);
if (mask.Log == 1 )
XmToggleButtonSetState(propWindow->alarmMaskToggleButtonW[4],TRUE,TRUE);
else XmToggleButtonSetState(propWindow->alarmMaskToggleButtonW[4],FALSE,TRUE);
}
/* ---------------------------------
Reset Mask
--------------------------------- */
if (programId == ALH ) {
if ( linkType == CHANNEL) {
alGetMaskString(pcData->defaultMask,buff);
string = XmStringCreateSimple(buff);
} else {
string = XmStringCreateSimple("");
}
XtVaSetValues(propWindow->resetMaskStringLabelW, XmNlabelString, string, NULL);
XmStringFree(string);
}
/* ---------------------------------
Beep Severity
--------------------------------- */
if(pgcData->beepSevr > 1)
XmTextFieldSetString(propWindow->beepSeverityValueTextW,alhAlarmSeverityString[pgcData->beepSevr]);
else XmTextFieldSetString(propWindow->beepSeverityValueTextW,alhAlarmSeverityString[1]);
/* ---------------------------------
Severity Process Variable
--------------------------------- */
if(strcmp(pgcData->sevrPVName,"-") != 0)
XmTextFieldSetString(propWindow->severityPVnameTextW,pgcData->sevrPVName);
else XmTextFieldSetString(propWindow->severityPVnameTextW,"");
/* ---------------------------------
Alarm Count Filter
--------------------------------- */
if (linkType == GROUP) {
XmTextFieldSetString(propWindow->countFilterCountTextW,"");
XmTextFieldSetString(propWindow->countFilterSecondsTextW,"");
XtVaSetValues(propWindow->countFilterCountTextW,XmNbackground,textBackgroundNS,NULL);
XtVaSetValues(propWindow->countFilterSecondsTextW,XmNbackground,textBackgroundNS,NULL);
} else {
XtVaSetValues(propWindow->countFilterCountTextW,XmNbackground,textBackground,NULL);
XtVaSetValues(propWindow->countFilterSecondsTextW,XmNbackground,textBackground,NULL);
if(pcData->countFilter) {
sprintf(buff,"%d",pcData->countFilter->inputCount);
XmTextFieldSetString(propWindow->countFilterCountTextW,buff);
sprintf(buff,"%d",pcData->countFilter->inputSeconds);
XmTextFieldSetString(propWindow->countFilterSecondsTextW,buff);
} else {
XmTextFieldSetString(propWindow->countFilterCountTextW,"");
XmTextFieldSetString(propWindow->countFilterSecondsTextW,"");
}
}
/* ---------------------------------
Force Process Variable
--------------------------------- */
if(pgcData->pforcePV && pgcData->pforcePV->name)
XmTextFieldSetString(propWindow->forcePVnameTextW,pgcData->pforcePV->name);
else XmTextFieldSetString(propWindow->forcePVnameTextW,"");
if(pgcData->pforcePV){
XmTextFieldSetString(propWindow->forcePVnameTextW,pgcData->pforcePV->name);
alGetMaskString(pgcData->pforcePV->forceMask,buff);
string = XmStringCreateSimple(buff);
} else string = XmStringCreateSimple("-----");
XtVaSetValues(propWindow->forcePVForceMaskStringLabelW, XmNlabelString, string, NULL);
XmStringFree(string);
if (programId != ALH) {
if(pgcData->pforcePV) mask = pgcData->pforcePV->forceMask;
if (mask.Cancel == 1 )
XmToggleButtonSetState(propWindow->forceMaskToggleButtonW[0],TRUE,TRUE);
else XmToggleButtonSetState(propWindow->forceMaskToggleButtonW[0],FALSE,TRUE);
if (mask.Disable == 1 )
XmToggleButtonSetState(propWindow->forceMaskToggleButtonW[1],TRUE,TRUE);
else XmToggleButtonSetState(propWindow->forceMaskToggleButtonW[1],FALSE,TRUE);
if (mask.Ack == 1 )
XmToggleButtonSetState(propWindow->forceMaskToggleButtonW[2],TRUE,TRUE);
else XmToggleButtonSetState(propWindow->forceMaskToggleButtonW[2],FALSE,TRUE);
if (mask.AckT == 1 )
XmToggleButtonSetState(propWindow->forceMaskToggleButtonW[3],TRUE,TRUE);
else XmToggleButtonSetState(propWindow->forceMaskToggleButtonW[3],FALSE,TRUE);
if (mask.Log == 1 )
XmToggleButtonSetState(propWindow->forceMaskToggleButtonW[4],TRUE,TRUE);
else XmToggleButtonSetState(propWindow->forceMaskToggleButtonW[4],FALSE,TRUE);
}
if(pgcData->pforcePV){
sprintf(buff,"%g",pgcData->pforcePV->forceValue);
XmTextFieldSetString(propWindow->forcePVforceValueTextW,buff);
sprintf(buff1,"%g",pgcData->pforcePV->resetValue);
if (!strcmp(buff,buff1)) sprintf(buff,"%s","NE");
else strcpy(buff,buff1);
XmTextFieldSetString(propWindow->forcePVresetValueTextW,buff);
if(pgcData->pforcePV->pcalc){
if (pgcData->pforcePV->pcalc->expression)
XmTextFieldSetString(propWindow->forcePVCalcExpressionTextW,
pgcData->pforcePV->pcalc->expression);
else XmTextFieldSetString(propWindow->forcePVCalcExpressionTextW,"");
for (i=0;i<NO_OF_CALC_PVS;i++){
if (pgcData->pforcePV->pcalc->name[i])
XmTextFieldSetString(propWindow->forcePVCalcPVTextW[i],
pgcData->pforcePV->pcalc->name[i]);
else XmTextFieldSetString(propWindow->forcePVCalcPVTextW[i],"");
}
} else {
XmTextFieldSetString(propWindow->forcePVCalcExpressionTextW,"");
for (i=0;i<NO_OF_CALC_PVS;i++){
XmTextFieldSetString(propWindow->forcePVCalcPVTextW[i],"");
}
}
} else {
/* ForcePV data */
XmTextFieldSetString(propWindow->forcePVnameTextW,"");
string = XmStringCreateSimple("-----");
XtVaSetValues(propWindow->forcePVForceMaskStringLabelW, XmNlabelString, string, NULL);
XmStringFree(string);
XmTextFieldSetString(propWindow->forcePVforceValueTextW,"");
XmTextFieldSetString(propWindow->forcePVresetValueTextW,"");
XmTextFieldSetString(propWindow->forcePVCalcExpressionTextW,"");
for (i=0;i<NO_OF_CALC_PVS;i++){
XmTextFieldSetString(propWindow->forcePVCalcPVTextW[i],"");
}
}
/* ---------------------------------
Alias
--------------------------------- */
XmTextFieldSetString(propWindow->aliasTextW,pgcData->alias);
/* ---------------------------------
Related Process Command
--------------------------------- */
XmTextFieldSetString(propWindow->processTextW,pgcData->command);
/* ---------------------------------
Sevr Command
--------------------------------- */
getStringSevrCommandList(&pgcData->sevrCommandList,&str);
XmTextSetString(propWindow->sevrProcessTextW,str);
free(str);
/* ---------------------------------
Stat Command
--------------------------------- */
if (linkType == GROUP) {
XtSetSensitive(propWindow->statProcessTextW, FALSE);
XtVaSetValues(propWindow->statProcessTextW,XmNbackground,textBackgroundNS,NULL);
XmTextSetString(propWindow->statProcessTextW,"");
} else {
XtSetSensitive(propWindow->statProcessTextW, TRUE);
XtVaSetValues(propWindow->statProcessTextW,XmNbackground,textBackground,NULL);
getStringStatCommandList(&pcData->statCommandList,&str);
XmTextSetString(propWindow->statProcessTextW,str);
free(str);
}
/* ---------------------------------
Guidance URL
--------------------------------- */
XmTextFieldSetString(propWindow->guidanceUrlW,link->guidanceLocation);
/* ---------------------------------
Guidance Text
--------------------------------- */
pt = sllFirst(&(link->GuideList));
while (pt) {
guideLink = (struct guideLink *)pt;
ii += strlen(guideLink->list);
ii += 1;
pt = sllNext(pt);
}
str = (char*)calloc(ii+1,sizeof(char));
pt = sllFirst(&(link->GuideList));
while (pt) {
guideLink = (struct guideLink *)pt;
strcat(str,guideLink->list);
pt = sllNext(pt);
if (pt) strcat(str,"\n");
}
XmTextSetString(propWindow->guidanceTextW, str);
free(str);
}
/******************************************************
propCreateDialog
******************************************************/
static void propCreateDialog(ALINK *area)
{
struct propWindow *propWindow;
int n;
Arg args[10];
Widget propDialogShell, propDialog, severityPVnameTextW;
Widget beepSeverityValueTextW;
Widget rowcol, form, maskFrameW=0;
Widget nameLabelW, nameTextW;
Widget beepSeverityLabel, severityPVlabel;
Widget alarmMaskToggleButtonW[ALARM_NMASK];
Widget forceMaskToggleButtonW[ALARM_NMASK];
Widget aliasLabel, aliasTextW;
Widget processLabel, processTextW;
Widget sevrProcessLabel, sevrProcessTextW;
Widget statProcessLabel, statProcessTextW;
Widget forcePVcurrentValueTextW=0;
Widget forcePVLabel;
Widget forcePVnameLabel, forcePVnameTextW;
Widget forcePVForceMaskLabel;
Widget forcePVForceMaskStringLabelW;
Widget forcePVforceValueLabel, forcePVforceValueTextW;
Widget forcePVresetValueLabel, forcePVresetValueTextW;
Widget forcePVCalcLabel;
Widget forcePVCalcExpressionLabel, forcePVCalcExpressionTextW;
Widget forcePVCalcPVLabel[NO_OF_CALC_PVS],
forcePVCalcPVTextW[NO_OF_CALC_PVS];
Widget frame2, form2, frame3, form3;
Widget guidanceLabel, guidanceTextW,
guidanceUrlLabel, guidanceUrlW;
Widget alarmMaskLabel, alarmMaskStringLabelW;
Widget resetMaskLabel=0, resetMaskStringLabelW=0;
Widget prev;
int i;
Widget countFilterFrame, form1, countFilterLabel,
countFilterCountLabel,countFilterCountTextW,
countFilterSecondsLabel, countFilterSecondsTextW;
Pixel textBackground;
XmString string;
char letter[]={"ABCDEF"};
char pvid[]="A ";
static ActionAreaItem prop_items_act[] = {
{ "Apply", propApplyCallback, NULL },
{ "Cancel", propCancelCallback, NULL },
{ "Dismiss", propDismissCallback, NULL },
{ "Help", propHelpCallback, NULL },
};
static ActionAreaItem prop_items_alh[] = {
{ "Dismiss", propDismissCallback, NULL },
{ "Help", propHelpCallback, NULL },
};
static String maskFields[] = {
"Cancel Alarm",
"Disable Alarm",
"NoAck Alarm",
"NoAck Transient Alarm",
"NoLog Alarm"
};
if (!area) return;
propWindow = (struct propWindow *)area->propWindow;
if (propWindow && propWindow->propDialog){
if (XtIsManaged(propWindow->propDialog)) return;
else XtManageChild(propWindow->propDialog);
}
if (programId != ALH) textBackground = bg_pixel[3];
else textBackground = bg_pixel[0];
propWindow = (struct propWindow *)calloc(1,sizeof(struct propWindow));
area->propWindow = (void *)propWindow;
propWindow->area = (void *)area;
propDialogShell = XtVaCreatePopupShell("Alarm Handler Properties",
transientShellWidgetClass, area->toplevel, NULL);
/* Modify the window manager menu "close" callback */
{
Atom WM_DELETE_WINDOW;
XtVaSetValues(propDialogShell,
XmNdeleteResponse, XmDO_NOTHING, NULL);
WM_DELETE_WINDOW = XmInternAtom(XtDisplay(propDialogShell),
"WM_DELETE_WINDOW", False);
XmAddWMProtocolCallback(propDialogShell,WM_DELETE_WINDOW,
(XtCallbackProc)propDismissCallback, (XtPointer)propWindow);
}
propDialog = XtVaCreateWidget("propDialog",
xmPanedWindowWidgetClass, propDialogShell,
XmNsashWidth, 1,
XmNsashHeight, 1,
XmNuserData, area,
(XtPointer)NULL);
(void)XtVaCreateWidget("control_area", xmRowColumnWidgetClass, propDialog, NULL);
form = XtVaCreateWidget("control_area", xmFormWidgetClass, propDialog, NULL);
/* ---------------------------------
Group/Channel Name
--------------------------------- */
nameLabelW = XtVaCreateManagedWidget("nameLabelW",
xmLabelGadgetClass, form,
XmNrecomputeSize, True,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
NULL);
nameTextW = XtVaCreateManagedWidget("nameTextW",
xmTextFieldWidgetClass, form,
XmNspacing, 0,
XmNmarginHeight, 0,
XmNmaxLength, PVNAME_SIZE,
XmNbackground, textBackground,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, nameLabelW,
XmNrightAttachment, XmATTACH_FORM,
NULL);
XtAddCallback(nameTextW, XmNactivateCallback,
(XtCallbackProc)XmProcessTraversal, (XtPointer)XmTRAVERSE_NEXT_TAB_GROUP);
/* ---------------------------------
Current Alarm Mask
--------------------------------- */
if (programId != ALH) string = XmStringCreateSimple("Alarm Mask ");
else string = XmStringCreateSimple("Current Mask ");
alarmMaskLabel = XtVaCreateManagedWidget("alarmMaskLabel",
xmLabelGadgetClass, form,
XmNlabelString, string,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, nameTextW,
XmNleftAttachment, XmATTACH_FORM,
NULL);
XmStringFree(string);
prev = alarmMaskLabel;
string = XmStringCreateSimple("-----");
alarmMaskStringLabelW = XtVaCreateManagedWidget("alarmMaskStringLabelW",
xmLabelGadgetClass, form,
XmNlabelString, string,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, nameTextW,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, alarmMaskLabel,
NULL);
XmStringFree(string);
/* ---------------------------------
Reset Mask
--------------------------------- */
if (programId == ALH ) {
string = XmStringCreateSimple("Reset Mask ");
resetMaskLabel = XtVaCreateManagedWidget("resetMaskLabel",
xmLabelGadgetClass, form,
XmNlabelString, string,
XmNleftAttachment, XmATTACH_FORM,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, alarmMaskLabel,
NULL);
XmStringFree(string);
prev = resetMaskLabel;
string = XmStringCreateSimple(" ");
resetMaskStringLabelW = XtVaCreateManagedWidget("resetMaskStringLabelW",
xmLabelGadgetClass, form,
XmNlabelString, string,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, alarmMaskLabel,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, resetMaskLabel,
NULL);
XmStringFree(string);
}
if (programId != ALH) {
maskFrameW = XtVaCreateManagedWidget("maskFrameW",
xmFrameWidgetClass, form,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, prev,
XmNleftAttachment, XmATTACH_FORM,
NULL);
prev=maskFrameW;
rowcol = XtVaCreateWidget("rowcol",
xmRowColumnWidgetClass, maskFrameW,
XmNspacing, 0,
XmNmarginHeight, 0,
NULL);
for (i = 0; i < ALARM_NMASK; i++){
long ilong=i;
alarmMaskToggleButtonW[i] = XtVaCreateManagedWidget(maskFields[i],
xmToggleButtonGadgetClass, rowcol,
XmNmarginHeight, 0,
XmNuserData, (XtPointer)alarmMaskStringLabelW,
NULL);
XtAddCallback(alarmMaskToggleButtonW[i], XmNvalueChangedCallback,
(XtCallbackProc)propMaskChangeCallback, (XtPointer)ilong);
}
XtManageChild(rowcol);
}
/* ---------------------------------
Alarm Count Filter
--------------------------------- */
countFilterFrame = XtVaCreateManagedWidget("countFilterFrame",
xmFrameWidgetClass, form,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, nameTextW,
XmNrightAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_POSITION,
XmNleftPosition, 50,
NULL);
form1 = XtVaCreateWidget("form1",
xmFormWidgetClass, countFilterFrame,
XmNspacing, 0,
XmNmarginHeight, 0,
NULL);
string = XmStringCreateSimple("Alarm Count Filter ");
countFilterLabel = XtVaCreateManagedWidget("countFilterLabel",
xmLabelGadgetClass, form1,
XmNlabelString, string,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
NULL);
XmStringFree(string);
string = XmStringCreateSimple("Count ");
countFilterCountLabel = XtVaCreateManagedWidget("countFilterCountLabel",
xmLabelGadgetClass, form1,
XmNlabelString, string,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, countFilterLabel,
XmNleftAttachment, XmATTACH_FORM,
NULL);
XmStringFree(string);
countFilterCountTextW = XtVaCreateManagedWidget("countFilterCountTextW",
xmTextFieldWidgetClass, form1,
XmNspacing, 0,
XmNmarginHeight, 0,
XmNcolumns, 3,
XmNmaxLength, 3,
XmNbackground, textBackground,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, countFilterLabel,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, countFilterCountLabel,
NULL);
XtAddCallback(countFilterCountTextW, XmNactivateCallback,
(XtCallbackProc)XmProcessTraversal, (XtPointer)XmTRAVERSE_NEXT_TAB_GROUP);
string = XmStringCreateSimple("Seconds ");
countFilterSecondsLabel = XtVaCreateManagedWidget("countFilterSecondsLabel",
xmLabelGadgetClass, form1,
XmNlabelString, string,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, countFilterLabel,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, countFilterCountTextW,
NULL);
XmStringFree(string);
countFilterSecondsTextW = XtVaCreateManagedWidget("countFilterSecondsTextW",
xmTextFieldWidgetClass, form1,
XmNspacing, 0,
XmNmarginHeight, 0,
XmNcolumns, 3,
XmNmaxLength, 3,
XmNbackground, textBackground,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, countFilterLabel,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, countFilterSecondsLabel,
NULL);
XtAddCallback(countFilterSecondsTextW, XmNactivateCallback,
(XtCallbackProc)XmProcessTraversal, (XtPointer)XmTRAVERSE_NEXT_TAB_GROUP);
/* Form is full -- now manage */
XtManageChild(form1);
/* ---------------------------------
Force Process Variable
--------------------------------- */
frame2 = XtVaCreateManagedWidget("frame2",
xmFrameWidgetClass, form,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, form1,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
NULL);
form2 = XtVaCreateWidget("form2",
xmFormWidgetClass, frame2,
XmNspacing, 0,
XmNmarginHeight, 0,
NULL);
string = XmStringCreateSimple("Force Process Variable");
forcePVLabel = XtVaCreateManagedWidget("forcePVLabel",
xmLabelGadgetClass, form2,
XmNlabelString, string,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
NULL);
XmStringFree(string);
string = XmStringCreateSimple("PV Name ");
forcePVnameLabel = XtVaCreateManagedWidget("forcePVnameLabel",
xmLabelGadgetClass, form2,
XmNlabelString, string,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, forcePVLabel,
XmNleftAttachment, XmATTACH_FORM,
NULL);
XmStringFree(string);
forcePVnameTextW = XtVaCreateManagedWidget("forcePVnameTextW",
xmTextFieldWidgetClass, form2,
XmNspacing, 0,
XmNmarginHeight, 0,
/*
XmNmaxLength, PVNAME_SIZE,
*/
XmNbackground, textBackground,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, forcePVLabel,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, forcePVnameLabel,
XmNrightAttachment, XmATTACH_FORM,
NULL);
XtAddCallback(forcePVnameTextW, XmNactivateCallback,
(XtCallbackProc)XmProcessTraversal, (XtPointer)XmTRAVERSE_NEXT_TAB_GROUP);
string = XmStringCreateSimple("Force Mask ");
forcePVForceMaskLabel = XtVaCreateManagedWidget("forcePVForceMaskLabel",
xmLabelGadgetClass, form2,
XmNlabelString, string,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, forcePVnameTextW,
XmNleftAttachment, XmATTACH_FORM,
NULL);
XmStringFree(string);
prev = forcePVForceMaskLabel;
/*
string = XmStringCreateSimple("-----");
*/
forcePVForceMaskStringLabelW = XtVaCreateManagedWidget("forcePVmaskStringLabelW",
xmLabelGadgetClass, form2,
XmNlabelString, string,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, forcePVnameTextW,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, forcePVForceMaskLabel,
NULL);
/*
XmStringFree(string);
*/
string = XmStringCreateSimple(" Force Value ");
forcePVforceValueLabel = XtVaCreateManagedWidget("forcePVvalue",
xmLabelGadgetClass, form2,
XmNlabelString, string,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, forcePVnameTextW,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, forcePVForceMaskStringLabelW,
NULL);
XmStringFree(string);
forcePVforceValueTextW = XtVaCreateManagedWidget("forcePVforceValueTextW",
xmTextFieldWidgetClass, form2,
XmNspacing, 0,
XmNmarginHeight, 0,
XmNcolumns, 8,
XmNbackground, textBackground,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, forcePVnameTextW,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, forcePVforceValueLabel,
NULL);
XtAddCallback(forcePVforceValueTextW, XmNactivateCallback,
(XtCallbackProc)XmProcessTraversal, (XtPointer)XmTRAVERSE_NEXT_TAB_GROUP);
string = XmStringCreateSimple(" Reset Value ");
forcePVresetValueLabel = XtVaCreateManagedWidget("forcePVresetValueLabel",
xmLabelGadgetClass, form2,
XmNlabelString, string,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, forcePVnameTextW,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, forcePVforceValueTextW,
NULL);
XmStringFree(string);
forcePVresetValueTextW = XtVaCreateManagedWidget("forcePVresetValueTextW",
xmTextFieldWidgetClass, form2,
XmNspacing, 0,
XmNmarginHeight, 0,
XmNcolumns, 8,
XmNbackground, textBackground,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, forcePVnameTextW,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, forcePVresetValueLabel,
NULL);
XtAddCallback(forcePVresetValueTextW, XmNactivateCallback,
(XtCallbackProc)XmProcessTraversal, (XtPointer)XmTRAVERSE_NEXT_TAB_GROUP);
frame3 = XtVaCreateManagedWidget("frame3",
xmFrameWidgetClass, form,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, forcePVforceValueTextW,
XmNleftAttachment, XmATTACH_FORM,
XmNrightAttachment, XmATTACH_FORM,
NULL);
form3 = XtVaCreateWidget("form3",
xmFormWidgetClass, frame3,
XmNspacing, 0,
XmNmarginHeight, 0,
NULL);
string = XmStringCreateSimple("Force CALC");
forcePVCalcLabel = XtVaCreateManagedWidget("forcePVCalcLabel",
xmLabelGadgetClass, form3,
XmNlabelString, string,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_FORM,
NULL);
XmStringFree(string);
string = XmStringCreateSimple(" Expression ");
forcePVCalcExpressionLabel = XtVaCreateManagedWidget("forcePVCalcExpression",
xmLabelGadgetClass, form3,
XmNlabelString, string,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, forcePVCalcLabel,
NULL);
XmStringFree(string);
forcePVCalcExpressionTextW = XtVaCreateManagedWidget("forcePVCalcExpressionTextW",
xmTextFieldWidgetClass, form3,
XmNspacing, 0,
XmNmarginHeight, 0,
XmNbackground, textBackground,
XmNtopAttachment, XmATTACH_FORM,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, forcePVCalcExpressionLabel,
XmNrightAttachment, XmATTACH_FORM,
NULL);
XtAddCallback(forcePVforceValueTextW, XmNactivateCallback,
(XtCallbackProc)XmProcessTraversal, (XtPointer)XmTRAVERSE_NEXT_TAB_GROUP);
prev = forcePVCalcExpressionTextW;
for (i=0;i<NO_OF_CALC_PVS/2;i++) {
pvid[0]=letter[i];
string = XmStringCreateSimple(pvid);
forcePVCalcPVLabel[i] = XtVaCreateManagedWidget("forcePVCalcPVLabel",
xmLabelGadgetClass, form3,
XmNlabelString, string,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, prev,
XmNleftAttachment, XmATTACH_FORM,
NULL);
XmStringFree(string);
forcePVCalcPVTextW[i] = XtVaCreateManagedWidget("forcePVCalcPVTextW",
xmTextFieldWidgetClass, form3,
XmNspacing, 0,
XmNmarginHeight, 0,
XmNcolumns, 30,
XmNmaxLength, PVNAME_SIZE,
XmNbackground, textBackground,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, prev,
XmNleftAttachment, XmATTACH_WIDGET,
XmNleftWidget, forcePVCalcPVLabel[i],
XmNrightAttachment, XmATTACH_POSITION,
XmNrightPosition, 50,
NULL);
prev = forcePVCalcPVTextW[i];
XtAddCallback(forcePVCalcPVTextW[i], XmNactivateCallback,
(XtCallbackProc)XmProcessTraversal, (XtPointer)XmTRAVERSE_NEXT_TAB_GROUP);
}
prev = forcePVCalcExpressionTextW;
for (i=NO_OF_CALC_PVS/2;i<NO_OF_CALC_PVS;i++) {
pvid[0]=letter[i];
string = XmStringCreateSimple(pvid);
forcePVCalcPVLabel[i] = XtVaCreateManagedWidget("forcePVCalcPVLabel",
xmLabelGadgetClass, form3,
XmNlabelString, string,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, prev,
XmNleftAttachment, XmATTACH_POSITION,
XmNleftPosition, 50,
NULL);
XmStringFree(string);
forcePVCalcPVTextW[i] = XtVaCreateManagedWidget("forcePVCalcPVTextW",
xmTextFieldWidgetClass, form3,
XmNspacing, 0,
XmNmarginHeight, 0,
XmNbackground, textBackground,
XmNtopAttachment, XmATTACH_WIDGET,
XmNtopWidget, prev,
XmNleftAttachment, XmATTACH_WIDGET,