-
Notifications
You must be signed in to change notification settings - Fork 2
/
line.c
178 lines (154 loc) · 5.42 KB
/
line.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
/*************************************************************************\
* 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.
\*************************************************************************/
/* line.c */
/************************DESCRIPTION***********************************
Routines for alloc, init, and update of a displayed line
**********************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include "alarm.h"
#include "alh.h"
#include "alLib.h"
#include "sllLib.h"
#include "axSubW.h"
#include "line.h"
#include "axArea.h"
#include "ax.h"
/* global variables */
extern char * alhAlarmSeverityString[];
extern char * alhAlarmStatusString[];
extern char *bg_char[];
static char buff[LINEMESSAGE_SIZE];
/*********************************************************************
* This function returns a string with 5 characters which shows
* the group mask. The input to this function is the group
* mask array.
*********************************************************************/
void awGetMaskString(int mask[ALARM_NMASK],char *s)
{
strcpy(s,"-----");
if (mask[ALARMCANCEL] > 0) *s = 'C';
if (mask[ALARMDISABLE] > 0) *(s+1) = 'D';
if (mask[ALARMACK] > 0) *(s+2) = 'A';
if (mask[ALARMACKT] > 0) *(s+3) = 'T';
if (mask[ALARMLOG] > 0) *(s+4) = 'L';
*(s+5) = '\0';
}
/*********************************************************************
* This function allocates space for new line
*********************************************************************/
struct anyLine *awAllocLine()
{
struct anyLine *pLine;
pLine = (struct anyLine *)calloc(1,sizeof(struct anyLine));
return(pLine);
}
/*********************************************************************
* This function updates the channel line mask , status & severity
*********************************************************************/
void awUpdateChanLine(struct anyLine *chanLine)
{
struct chanData *cdata;
CLINK *clink;
clink = (CLINK *)chanLine->link;
if (!clink) return;
cdata = clink->pchanData;
chanLine->unackSevr = cdata->unackSevr;
chanLine->curSevr = cdata->curSevr;
chanLine->curStat = cdata->curStat;
if (cdata->curMask.Disable == MASK_ON ||
cdata->curMask.Cancel == MASK_ON) {
chanLine->curSevr = 0;
chanLine->unackSevr = 0;
}
if (cdata->curMask.Ack == MASK_ON) {
chanLine->unackSevr = 0;
}
alGetMaskString(cdata->curMask,buff);
if (cdata->noAckTimerId ) buff[2]='H';
sprintf(chanLine->mask,"<%s>",buff);
strcpy(chanLine->message," ");
if (!cdata->curMask.Disable && !cdata->curMask.Cancel &&
(cdata->curSevr || cdata->unackSevr)){
sprintf(chanLine->message,"<%s,%s>",
alhAlarmStatusString[cdata->curStat],
alhAlarmSeverityString[cdata->curSevr]);
if (cdata->unackSevr){
sprintf(buff,",<%s>",
alhAlarmSeverityString[cdata->unackSevr]);
strcat(chanLine->message,buff);
}
}
if(cdata->highestBeepSevr>1) strcpy(chanLine->highestBeepSevrString,
bg_char[cdata->highestBeepSevr]);
else strcpy(chanLine->highestBeepSevrString," ");
}
/***************************************************************************
* This function updates the group line mask , status & severity, summary
***************************************************************************/
void awUpdateGroupLine(struct anyLine *groupLine)
{
struct groupData *gdata;
GLINK *glink;
int i;
glink = (GLINK *)groupLine->link;
if (!glink) return;
gdata = glink->pgroupData;
awGetMaskString(gdata->mask,buff);
if (gdata->noAckTimerId ) buff[2]='H';
sprintf(groupLine->mask,"<%s>",buff);
for (i=0;i<ALH_ALARM_NSEV;i++){
groupLine->curSev[i] = gdata->curSev[i];
}
groupLine->unackSevr = alHighestSeverity(gdata->unackSev);
groupLine->curSevr = alHighestSeverity(gdata->curSev);
strcpy(groupLine->message," ");
if (groupLine->unackSevr || alHighestSeverity(gdata->curSev)){
sprintf(groupLine->message,"(%d,%d,%d,%d,%d)",
gdata->curSev[ERROR_STATE],
gdata->curSev[INVALID_ALARM],
gdata->curSev[MAJOR_ALARM],
gdata->curSev[MINOR_ALARM],
gdata->curSev[NO_ALARM]);
}
if(gdata->highestBeepSevr>1) strcpy(groupLine->highestBeepSevrString,
bg_char[gdata->highestBeepSevr]);
else strcpy(groupLine->highestBeepSevrString," ");
}
/***************************************************
Initializes all line fields
****************************************************/
void initLine(struct anyLine *line)
{
line->link = NULL;
line->cosCallback = NULL;
line->linkType = 0;
line->unackSevr = 0;
line->curSevr = 0;
line->pname = 0;
line->alias = 0;
}
/***************************************************
Initializes all subWindow lines
****************************************************/
void initializeLines(SNODE *lines)
{
struct anyLine *line;
line = (struct anyLine *)sllFirst(lines);
while (line){
initLine(line);
line = (struct anyLine *)sllNext(line);
}
}