From 75df3a5267873c0bad7c8d90b8ae95e17a514957 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Tue, 10 Oct 2023 16:51:19 -0700 Subject: [PATCH] ioc: pvalink add newer lset functions --- ioc/pvalink.h | 17 ++++++++++--- ioc/pvalink_link.cpp | 2 ++ ioc/pvalink_lset.cpp | 58 +++++++++++++++++++++++++++++++++++++++----- 3 files changed, 67 insertions(+), 10 deletions(-) diff --git a/ioc/pvalink.h b/ioc/pvalink.h index 7b8bfca0d..e64636f0d 100644 --- a/ioc/pvalink.h +++ b/ioc/pvalink.h @@ -37,6 +37,11 @@ #include "utilpvt.h" #include "dbmanylocker.h" + +#if EPICS_VERSION_INTtime) { plink->precord->time = self->snap_time; } - log_debug_printf(_logger, "%s: %s not valid", __func__, self->channelName.c_str()); + log_debug_printf(_logger, "%s: %s not valid\n", __func__, self->channelName.c_str()); return -1; } @@ -367,6 +367,12 @@ long pvaGetValue(DBLINK *plink, short dbrType, void *pbuffer, self->snap_severity = NO_ALARM; } + if(self->fld_message && self->snap_severity!=0) { + self->snap_message = self->fld_message.as(); + } else { + self->snap_message.clear(); + } + if((self->snap_severity!=NO_ALARM && self->sevr == pvaLink::MS) || (self->snap_severity==INVALID_ALARM && self->sevr == pvaLink::MSI)) { @@ -489,8 +495,9 @@ long pvaGetUnits(const DBLINK *plink, char *units, int unitsSize) return -1; } -long pvaGetAlarm(const DBLINK *plink, epicsEnum16 *status, - epicsEnum16 *severity) +long pvaGetAlarmMsg(const DBLINK *plink, + epicsEnum16 *status, epicsEnum16 *severity, + char *msgbuf, size_t msgbuflen) { TRY { Guard G(self->lchan->lock); @@ -502,6 +509,14 @@ long pvaGetAlarm(const DBLINK *plink, epicsEnum16 *status, if(status) { *status = self->snap_severity ? LINK_ALARM : NO_ALARM; } + if(msgbuf && msgbuflen) { + if(self->snap_message.empty()) { + msgbuf[0] = '\0'; + } else { + epicsSnprintf(msgbuf, msgbuflen-1u, "%s", self->snap_message.c_str()); + msgbuf[msgbuflen-1u] = '\0'; + } + } log_debug_printf(_logger, "%s: %s %s %i %i\n", __func__, plink->precord->name, self->channelName.c_str(), severity ? *severity : 0, status ? *status : 0); return 0; @@ -509,7 +524,13 @@ long pvaGetAlarm(const DBLINK *plink, epicsEnum16 *status, return -1; } -long pvaGetTimeStamp(const DBLINK *plink, epicsTimeStamp *pstamp) +long pvaGetAlarm(const DBLINK *plink, epicsEnum16 *status, + epicsEnum16 *severity) +{ + return pvaGetAlarmMsg(plink, status, severity, nullptr, 0); +} + +long pvaGetTimeStampTag(const DBLINK *plink, epicsTimeStamp *pstamp, epicsUTag *ptag) { TRY { Guard G(self->lchan->lock); @@ -518,12 +539,20 @@ long pvaGetTimeStamp(const DBLINK *plink, epicsTimeStamp *pstamp) if(pstamp) { *pstamp = self->snap_time; } + if(ptag) { + *ptag = self->snap_tag; + } log_debug_printf(_logger, "%s: %s %s %i %i\n", __func__, plink->precord->name, self->channelName.c_str(), pstamp ? pstamp->secPastEpoch : 0, pstamp ? pstamp->nsec : 0); return 0; }CATCH() return -1; } +long pvaGetTimeStamp(const DBLINK *plink, epicsTimeStamp *pstamp) +{ + return pvaGetTimeStampTag(plink, pstamp, nullptr); +} + long pvaPutValueX(DBLINK *plink, short dbrType, const void *pbuffer, long nRequest, bool wait) { @@ -615,6 +644,17 @@ void pvaScanForward(DBLINK *plink) }CATCH() } +#if EPICS_VERSION_INT>=VERSION_INT(3,16,1,0) +long pvaDoLocked(struct link *plink, dbLinkUserCallback rtn, void *priv) +{ + TRY { + Guard G(self->lchan->lock); + return (*rtn)(plink, priv); + }CATCH() + return 1; +} +#endif // >= 3.16.1 + #undef TRY #undef CATCH @@ -638,8 +678,14 @@ lset pva_lset = { &pvaGetTimeStamp, &pvaPutValue, &pvaPutValueAsync, - &pvaScanForward - //&pvaReportLink, + &pvaScanForward, +#if EPICS_VERSION_INT>=VERSION_INT(3,16,1,0) + &pvaDoLocked, +#endif +#if EPICS_VERSION_INT>=VERSION_INT(7,0,6,0) + &pvaGetAlarmMsg, + &pvaGetTimeStampTag, +#endif }; } // namespace pvxlink