Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

latest upstream #3

Open
wants to merge 31 commits into
base: upstream
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
# in the file LICENSE that is included with this distribution.
#*************************************************************************
#
# Makefile,v 1.18 2008/12/03 17:20:17 jba Exp
# Makefile,v 1.22 2013/04/22 16:07:23 jba Exp
#
TOP=../..
include $(TOP)/configure/CONFIG
Expand Down Expand Up @@ -157,11 +157,11 @@ alh_DB_SRCS = alh_DB.c

alh_printer_SRCS = printer.c

PROD_HOST_DEFAULT = alh alh_printer
PROD_HOST_DEFAULT = alh alh_printer alh_DB
PROD_HOST_WIN32 = alh

WIN32_RUNTIME=MD
USR_CFLAGS_WIN32 += /DWIN32 /D_WINDOWS
USR_CFLAGS_WIN32 += -DWIN32 -D_WINDOWS
ifndef BORLAND
USR_LDFLAGS_WIN32 += /SUBSYSTEM:WINDOWS
endif
Expand Down
19 changes: 11 additions & 8 deletions alConfig.c
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,10 @@ int caConnect)

fp = fopen(filename,"r");
if(fp==NULL) {
perror("Could not open Alarm Configuration File");
sprintf(buf,
"Could not open Alarm Configuration File: %.*s",
(int)MAX_STRING_LENGTH-42,filename);
perror(buf);
exit(-1);
}

Expand Down Expand Up @@ -182,7 +185,7 @@ struct mainGroup *pmainGroup)

parent_link = *pglink;

rtn = sscanf(buf,"%20s%32s%32s",command,parent,name);
rtn = sscanf(buf,"%20s%64s%64s",command,parent,name);

if(rtn!=3) {
print_error(buf,"Invalid GROUP command");
Expand Down Expand Up @@ -227,7 +230,7 @@ struct mainGroup *pmainGroup)
parent_link = parent_link->parent;

if(parent_link==NULL) {
print_error(buf,"Can not find parent");
print_error(buf,"Cannot find parent");
return;
}

Expand All @@ -254,7 +257,7 @@ struct mainGroup *pmainGroup)

if (pglink) parent_link = *pglink;

rtn = sscanf(buf,"%20s%32s%s",command,parent,name);
rtn = sscanf(buf,"%20s%64s%s",command,parent,name);

if(rtn!=3) {
print_error(buf,"Invalid INCLUDE command");
Expand Down Expand Up @@ -361,7 +364,7 @@ int caConnect,struct mainGroup *pmainGroup)
parent_link = parent_link->parent;

if(parent_link==NULL) {
print_error(buf,"Can not find parent");
print_error(buf,"Cannot find parent");
return;
}

Expand Down Expand Up @@ -444,7 +447,7 @@ int context,int caConnect,struct mainGroup *pmainGroup)
if (strncmp(&buf[1],"HEARTBEATPV",11)==0) { /*HEARTBEATPV*/

if (pmainGroup->heartbeatPV.name) return;
rtn = sscanf(buf,"%20s%32s%f%d",command,name,&rateIn,&valueIn);
rtn = sscanf(buf,"%20s%64s%f%d",command,name,&rateIn,&valueIn);
if(rtn>=2) {
if(rtn>=3) rate = rateIn;
if(rtn>=4) value = valueIn;
Expand Down Expand Up @@ -491,7 +494,7 @@ int context,int caConnect,struct mainGroup *pmainGroup)
if (gcdata->pforcePV && gcdata->pforcePV->name) return;
if (!gcdata->pforcePV) gcdata->pforcePV=(FORCEPV*)calloc(1,sizeof(FORCEPV));
dbl=0.0;
rtn = sscanf(buf,"%20s%32s%6s%lf%9s",command,name,mask,&dbl,string);
rtn = sscanf(buf,"%20s%64s%6s%lf%9s",command,name,mask,&dbl,string);
if(rtn>=3) alSetMask(mask,&(gcdata->pforcePV->forceMask));
if (rtn >= 4) gcdata->pforcePV->forceValue = dbl;
else gcdata->pforcePV->forceValue=1;
Expand Down Expand Up @@ -598,7 +601,7 @@ int context,int caConnect,struct mainGroup *pmainGroup)
if (strncmp(&buf[1],"SEVRPV",6)==0) { /*SEVRPV*/

if(strcmp(gcdata->sevrPVName,"-") != 0) return;
rtn = sscanf(buf,"%20s%32s",command,name);
rtn = sscanf(buf,"%20s%64s",command,name);
if(rtn>=2) {
gcdata->sevrPVName = (char *)calloc(1,strlen(name)+1);
strcpy(gcdata->sevrPVName,name);
Expand Down
74 changes: 49 additions & 25 deletions alLib.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ static void alNewAlarmProcess(int stat,int sev, int acks,int ackt,
void alSetAckTChan(CLINK *clink,int ackt);
short alHighestBeepSeverity(int sevr[ALH_ALARM_NSEV], int beepSevr);
static void alSetBeepSevCount(GLINK* glink,int beepSevr,int oldBeepSevr);
static void alAlarmFilterReset(CLINK *clink);

char *Strncat(
char *dest,
Expand All @@ -57,7 +58,8 @@ char *Strncat(
/* max must be >= 0 and no more than stringsize - 1 */
/* for char string[10]; max must be <= 9 */

size_t l, newMax;
int newMax;
size_t l;
char *s;

l = strlen( dest );
Expand Down Expand Up @@ -578,23 +580,14 @@ static void alarmCountFilter_callback(XtPointer cd, XtIntervalId *id)
{
COUNTFILTER *countFilter=(COUNTFILTER *)cd;
time_t alarmTime;
int j;

#if DEBUG_CALLBACKS
{
static int n=0;

printf("alarmCountFilter_callback: n=%d\n",n++);
}
{ static int n=0; printf("alarmCountFilter_callback: n=%d\n",n++); }
#endif
alarmTime = countFilter->alarmTime;
countFilter->alarmTime=0;
countFilter->timeoutId=0;
/* reset alarm count filter when new alarm is processed */
if (countFilter->inputCount){
for (j=0;j<=2*(countFilter->inputCount)-1;j++){countFilter->alarmTimeHistory[j]=0;}
}
countFilter->countIndex=0;
alAlarmFilterReset(countFilter->clink);
alNewAlarmProcess(countFilter->stat,countFilter->sev,
countFilter->acks,countFilter->ackt,
countFilter->value,countFilter->clink,alarmTime);
Expand Down Expand Up @@ -668,7 +661,7 @@ void alNewEvent(int stat,int sevr,int acks,int acktCA,char *value,CLINK *clink)
void alNewAlarmFilter(int stat,int sev,int acks,int ackt,char *value,CLINK *clink)
{
struct chanData *cdata;
int sevr_prev, i, j;
int sevr_prev, i;
time_t alarmTime;
COUNTFILTER *countFilter;

Expand All @@ -693,8 +686,8 @@ void alNewAlarmFilter(int stat,int sev,int acks,int ackt,char *value,CLINK *clin
return;
}

/* Process if inputCount or inputSeconds is zero */
if (countFilter->inputSeconds==0 || countFilter->inputCount==0) {
/* Process if inputSeconds is zero */
if (countFilter->inputSeconds==0 ) {
alNewAlarmProcess(stat,sev,acks,ackt,value,clink,alarmTime);
return;
}
Expand Down Expand Up @@ -726,32 +719,34 @@ void alNewAlarmFilter(int stat,int sev,int acks,int ackt,char *value,CLINK *clin
}


/* process changes in acks and ackt and if no timeout then add timeout */
if ( cdata->curSevr!=0 && sev==0 ){
if ( countFilter->inputCount != -1 ) {

/* if inputCount not -1 process changes in acks and ackt and add timeout */
alNewAlarmProcess(cdata->curStat,cdata->curSevr,acks,ackt,value,clink,alarmTime);
if (countFilter->timeoutId==0) {
countFilter->timeoutId = XtAppAddTimeOut(appContext,
(unsigned long)countFilter->inputSeconds*1000,
alarmCountFilter_callback,(XtPointer)countFilter);
countFilter->alarmTime=alarmTime;
}
} else {

/* if inputCount is -1 dont start a timeout, reset filter and process new alarm state*/
alAlarmFilterReset(clink);
alNewAlarmProcess(stat,sev,acks,ackt,value,clink,alarmTime);
}
}

/* check in/out alarm count within time interval*/
if ( countFilter->inputCount > 0 ) {
if ( (sevr_prev==0 && sev!=0) || (sevr_prev!=0 && sev==0)){
i = countFilter->countIndex;
if ( !countFilter->alarmTimeHistory ||
(countFilter->alarmTimeHistory[i] &&
(((int)difftime(alarmTime,countFilter->alarmTimeHistory[i]))<=countFilter->inputSeconds))){
/* reset alarm count filter when new alarm is processed */
if (countFilter->inputCount){
for (j=0;j<=2*(countFilter->inputCount)-1;j++){countFilter->alarmTimeHistory[j]=0;}
}
if (countFilter->timeoutId){
XtRemoveTimeOut(countFilter->timeoutId);
countFilter->timeoutId=0;
}
countFilter->countIndex=0;

alAlarmFilterReset(clink);
alNewAlarmProcess(stat,sev,acks,ackt,value,clink,alarmTime);
} else {
countFilter->alarmTimeHistory[i] = alarmTime;
Expand All @@ -761,8 +756,37 @@ void alNewAlarmFilter(int stat,int sev,int acks,int ackt,char *value,CLINK *clin
}
}
}
}
}


/***********************************************************
alNewAlarmFilterReset
************************************************************/
void alAlarmFilterReset(CLINK *clink)
{
COUNTFILTER *countFilter;
struct chanData *cdata;
int j;

if (clink == NULL ) return;
cdata = clink->pchanData;
if (cdata == NULL ) return;
countFilter = cdata->countFilter;
if (countFilter == NULL ) return;

/* reset alarm count filter when new alarm is processed */
countFilter->countIndex=0;
if (countFilter->inputCount){
for (j=0;j<=2*(countFilter->inputCount)-1;j++){countFilter->alarmTimeHistory[j]=0;}
}
if (countFilter->timeoutId){
XtRemoveTimeOut(countFilter->timeoutId);
countFilter->timeoutId=0;
}
}


/***********************************************************
alNewAlarmProcess
************************************************************/
Expand Down
Loading