From 55d6405b3c8a482a5515fcaed3fec67873e04e80 Mon Sep 17 00:00:00 2001 From: Andrew Johnson Date: Tue, 22 Jul 2008 21:21:11 +0000 Subject: [PATCH] Added ascaStats(), for Mantis #281. --- src/as/asCa.c | 34 +++++++++++++++++++++++++++++++--- src/as/asCa.h | 6 +++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/src/as/asCa.c b/src/as/asCa.c index 67f784275..d61499a6f 100644 --- a/src/as/asCa.c +++ b/src/as/asCa.c @@ -1,11 +1,10 @@ /*asCa.c*/ /*************************************************************************\ -* Copyright (c) 2002 The University of Chicago, as Operator of Argonne +* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne * National Laboratory. * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. -* EPICS BASE Versions 3.13.7 -* and higher are distributed subject to a Software License Agreement found +* EPICS BASE is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. \*************************************************************************/ /* Author: Marty Kraimer Date: 10-15-93 */ @@ -303,3 +302,32 @@ int epicsShareAPI ascarFP(FILE *fp,int level) fprintf(fp,"%d channels %d not connected\n",n,nbad); return(0); } + +void epicsShareAPI ascaStats(int *pchans, int *pdiscon) +{ + ASG *pasg; + int n = 0; + int nbad = 0; + + if(!pasbase) { + if (pchans) *pchans = n; + if (pdiscon) *pdiscon = nbad; + return; + } + pasg = (ASG *)ellFirst(&pasbase->asgList); + while (pasg) { + ASGINP *pasginp; + pasginp = (ASGINP *)ellFirst(&pasg->inpList); + while (pasginp) { + CAPVT *pcapvt = (CAPVT *)pasginp->capvt; + chid chid = pcapvt->chid; + ++n; + if (ca_state(chid) != cs_conn) ++nbad; + pasginp = (ASGINP *)ellNext((ELLNODE *)pasginp); + } + pasg = (ASG *)ellNext((ELLNODE *)pasg); + } + if (pchans) *pchans = n; + if (pdiscon) *pdiscon = nbad; +} + diff --git a/src/as/asCa.h b/src/as/asCa.h index 1a4128b5b..efc5ccbb5 100644 --- a/src/as/asCa.h +++ b/src/as/asCa.h @@ -1,10 +1,9 @@ /*************************************************************************\ -* Copyright (c) 2002 The University of Chicago, as Operator of Argonne +* Copyright (c) 2008 UChicago Argonne LLC, as Operator of Argonne * National Laboratory. * Copyright (c) 2002 The Regents of the University of California, as * Operator of Los Alamos National Laboratory. -* EPICS BASE Versions 3.13.7 -* and higher are distributed subject to a Software License Agreement found +* EPICS BASE is distributed subject to a Software License Agreement found * in file LICENSE that is included with this distribution. \*************************************************************************/ /* asCa.h */ @@ -22,6 +21,7 @@ epicsShareFunc void epicsShareAPI asCaStart(void); epicsShareFunc void epicsShareAPI asCaStop(void); epicsShareFunc int epicsShareAPI ascar(int level); epicsShareFunc int epicsShareAPI ascarFP(FILE *fp, int level); +epicsShareFunc void epicsShareAPI ascaStats(int *pchans, int *pdiscon); #ifdef __cplusplus }