diff --git a/src/epics/seq/main.c b/src/epics/seq/main.c index b91337a19c243e16e172363f89ff3d598b4320fc..efe12884af534185f700a9ef2de1dcd468d5cffd 100644 --- a/src/epics/seq/main.c +++ b/src/epics/seq/main.c @@ -292,6 +292,9 @@ void registerFilters(); void setupFMArrays(char *,int*,dbAddr*,dbAddr*); void resyncFMArrays(int *,dbAddr*); void processFMChanCommands(int*,dbAddr*,dbAddr*,int*,int,SET_ERR_TABLE*); +void countDisconnectedChannels(int); +void saveStrSetPoint(int, const char*); +void updateStrVarSetPoint(int); #ifdef CA_SDF long countDisconnectedChans(); @@ -1633,11 +1636,7 @@ int spChecker(int monitorAll, SET_ERR_TABLE setErrTable[],int wcVal, char *wcstr } // If this is a string type, then get as string. } else { - if (caStringSetpointInitted[ii] == 1) - { - strcpy(cdTable[ii].data.strval, caStringSetpoint[ii]); - caStringSetpointInitted[ii] = 2; - } + updateStrVarSetPoint(ii); status = GET_VALUE_STR(paddr,sval,sizeof(sval),&mtime, NULL); //&(cdTable[ii].connected)); if(strcmp(cdTable[ii].data.strval,sval) != 0 || listAll) { @@ -2041,10 +2040,7 @@ int readConfig( char *pref, ///< EPICS channel prefix from EPICS environment. { if(strcmp(cdTable[ii].chname,cdTableP[chNumP].chname) == 0) { -#if CA_SDF - sprintf(caStringSetpoint[ii],"%s",s3); - caStringSetpointInitted[ii] = 1; -#endif + saveStrSetPoint(ii, s3); fmatch = 1; if(cdTable[ii].datatype == SDF_STR || (!isdigit(s3[0]) && strncmp(s3,"-",1) != 0)) { @@ -2290,6 +2286,39 @@ void processFMChanCommands(int *fMask, dbAddr *fmMaskAddr, dbAddr *fmCtrlAddr, i #ifdef CA_SDF +/*! + * @brief count the disconnected channels if we are not on the disconnected page + */ +void countDisconnectedChannels(int curTable) +{ + if (curTable != SDF_TABLE_DISCONNECTED) + { + chDisconnectedCount = countDisconnectedChans(); + } +} + +/*! + * @brief store the setpoint value for a pv + * @note this stores the value that will be set by updateStrVarSetPoint + */ +void saveStrSetPoint(int index, const char* value) +{ + sprintf(caStringSetpoint[index],"%s",value); + caStringSetpointInitted[index] = 1; +} + +/*! + * @brief Ensure that the setpoint value is set for the given str variable + */ +void updateStrVarSetPoint(int index) +{ + if (caStringSetpointInitted[index] == 1) + { + strcpy(cdTable[index].data.strval, caStringSetpoint[index]); + caStringSetpointInitted[index] = 2; + } +} + long countDisconnectedChans() { int jj = 0; @@ -2310,7 +2339,7 @@ void nullCACallback(struct event_handler_args args) {} int getCAIndex(char *entry, ADDRESS *addr) { int ii = 0; - if (!entry || !addr) return; + if (!entry || !addr) return 1; for (ii = 0; ii < chNum; ++ii) { if (strcmp(cdTable[ii].chname, entry) == 0) { *addr = ii; @@ -2799,8 +2828,8 @@ void setupCASDF() for (ii = 0; ii < SDF_MAX_CHANS; ++ii) { bzero((void *)&(cdTableP[ii]), sizeof(cdTableP[ii])); } - for (ii = 0; ii < 1000; ++ii) { - bzero((void *)&(filterTable[1000]), sizeof(filterTable[ii])); + for (ii = 0; ii < SDF_MAX_FMSIZE; ++ii) { + bzero((void *)&(filterTable[ii]), sizeof(filterTable[ii])); } for (ii = 0; ii < SDF_ERR_TSIZE; ++ii) { bzero((void *)&(setErrTable[ii]), sizeof(setErrTable[ii])); @@ -2822,6 +2851,19 @@ void cleanupCASDF() pthread_mutex_destroy(&caStateMutex); } #else + +void countDisconnectedChannels(int curTable) +{ +} + +void saveStrSetPoint(int index, const char* value) +{ +} + +void updateStrVarSetPoint(int index) +{ +} + int getDbValueDouble(ADDRESS *paddr,double *dest,time_t *tp) { struct buffer { DBRtime @@ -3485,12 +3527,7 @@ sleep(5); if(pageNum < 0) pageNum = 0; status = dbPutField(&pagereqaddr,DBR_LONG,&ropts,1); // Init to zero. } -#ifdef CA_SDF - if (tsrVal != SDF_TABLE_DISCONNECTED) - { - chDisconnectedCount = countDisconnectedChans(); - } -#endif + countDisconnectedChannels(tsrVal); switch(tsrVal) { case SDF_TABLE_DIFFS: // Need to clear selections when moving between tables.