-
Notifications
You must be signed in to change notification settings - Fork 0
/
probeUpdate.c
212 lines (199 loc) · 5.33 KB
/
probeUpdate.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
/*************************************************************************\
* Copyright (c) 2002 The University of Chicago, as Operator of Argonne
* National Laboratory.
* 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.
\*************************************************************************/
#define DEBUG_WINSOCK 0
#include <stdarg.h>
#include <stdio.h>
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>
#include <Xm/Xm.h>
#include <Xm/Label.h>
#include <Xm/RowColumn.h>
#include <Xm/PushB.h>
#include <Xm/ToggleB.h>
#include <Xm/Text.h>
#include <Xm/MessageB.h>
#ifdef EXCEED
#include <X11/XlibXtra.h>
#endif
/*
* System includes for CA
*/
#include <caerr.h>
#include <cadef.h>
#include <db_access.h>
#include <stdio.h>
#include <string.h>
#include <alarm.h>
#include "probe.h"
char *alarmSeverityStrs[] = {
"NO ALARM",
"MINOR",
"MAJOR",
"INVALID",
"alarm no severtiy",
};
char *alarmStatusStrs[] = {
"NO ALARM",
"READ",
"WRITE",
"HIHI",
"HIGH",
"LOLO",
"LOW",
"STATE",
"COS",
"COMM",
"TIMEOUT",
"HW_LIMIT",
"CALC",
"SCAN",
"LINK",
"SOFT",
"BAD_SUB",
"UDF",
"DISABLE_ALARM",
"SIMM_ALARM",
"alarm no status",
};
void updateStatusDisplay(atom *channel,unsigned int i)
{
if (channel->connected) {
if ((channel->data.D.status > ALARM_NSTATUS)
|| (channel->data.D.status < NO_ALARM)) {
fprintf(stderr,"updateMonitor : unknown alarm status (%s) !!!\n",
ca_name(channel->chId));
} else {
if ((channel->data.D.severity > ALARM_NSEV)
|| (channel->data.D.severity < NO_ALARM)) {
fprintf(stderr,"updateMonitor : unknown alarm severity (%s) !!!\n",
ca_name(channel->chId));
} else {
if (channel->monitored) {
winPrintf(channel->d[i].w,"%-8s %-8s monitor",
alarmStatusStrs[channel->data.D.status],
alarmSeverityStrs[channel->data.D.severity]);
} else {
winPrintf(channel->d[i].w,"%-8s %-8s",
alarmStatusStrs[channel->data.D.status],
alarmSeverityStrs[channel->data.D.severity]);
}
}
}
} else {
winPrintf(channel->d[i].w,"Not connected");
}
}
void updateDataDisplay(atom *channel,unsigned int i)
{
if (channel->connected) {
switch(ca_field_type(channel->chId)) {
case DBF_STRING :
winPrintf(channel->d[i].w,"%s",channel->data.S.value);
break;
case DBF_ENUM :
if (channel->data.E.value < channel->info.data.E.no_str &&
strlen(channel->info.data.E.strs[channel->data.E.value]) >
(size_t)0) {
winPrintf(channel->d[i].w,"%s",
channel->info.data.E.strs[channel->data.E.value]);
} else {
winPrintf(channel->d[i].w,"%d",channel->data.E.value);
}
break;
case DBF_CHAR :
channel->data.L.value=(long)(unsigned char)channel->data.L.value;
#if 1
winPrintf(channel->d[i].w,"%hu %s",
(unsigned char)channel->data.L.value,
channel->info.data.L.units?channel->info.data.L.units:"");
#else
winPrintf(channel->d[i].w,"%hu",
(unsigned char)channel->data.L.value);
#endif
break;
case DBF_INT :
case DBF_LONG :
#if 1
winPrintf(channel->d[i].w,"%d %s",
channel->data.L.value,
channel->info.data.L.units?channel->info.data.L.units:"");
#else
winPrintf(channel->d[i].w,"%d",channel->data.L.value);
#endif
break;
case DBF_FLOAT :
case DBF_DOUBLE :
winPrintf(channel->d[i].w,channel->format.str,channel->data.D.value);
break;
default :
break;
}
} else {
winPrintf(channel->d[i].w," ");
}
}
void updateLabelDisplay(atom *channel,unsigned int i)
{
if (channel->connected) {
winPrintf(channel->d[i].w,"%s",ca_name(channel->chId));
} else {
winPrintf(channel->d[i].w,"Unknown channel name!");
}
}
void updateTextDisplay(atom *channel,unsigned int i)
{
char tmp[40];
switch(ca_field_type(channel->chId)) {
case DBF_STRING :
sprintf(tmp,"%s",channel->data.S.value);
XmTextSetString(channel->d[i].w,tmp);
break;
case DBF_ENUM :
if (channel->data.E.value < channel->info.data.E.no_str &&
strlen(channel->info.data.E.strs[channel->data.E.value]) >
(size_t)0) {
sprintf(tmp,"%s",channel->info.data.E.strs[channel->data.E.value]);
} else {
sprintf(tmp,"%d",channel->data.E.value);
}
XmTextSetString(channel->d[i].w,tmp);
break;
case DBF_CHAR :
channel->data.L.value=(long)(unsigned char)channel->data.L.value;
case DBF_INT :
case DBF_LONG :
sprintf(tmp,"%d",channel->data.L.value);
XmTextSetString(channel->d[i].w,tmp);
break;
case DBF_FLOAT :
case DBF_DOUBLE :
sprintf(tmp,channel->format.str1,channel->data.D.value);
XmTextSetString(channel->d[i].w,tmp);
break;
}
}
void updateDisplay(atom *channel)
{
unsigned int mask;
int i;
if (channel->updateMask != NO_UPDATE) {
#if DEBUG_WINSOCK
fprintf(stderr,"updateDisplay: (! NO_UPDATE)\n");
#endif
mask = 1;
mask = mask << (LAST_ITEM - 1);
for (i=(LAST_ITEM-1);i>=0;i--) {
if ((channel->updateMask & mask) && (channel->d[i].proc)){
(*(channel->d[i].proc))(channel,i);
}
mask = mask >> 1;
}
}
channel->updateMask = NO_UPDATE;
}