From 9f3ddc35c41f4f177e001b5f248fcccd2d2118c4 Mon Sep 17 00:00:00 2001 From: Michael Davidsaver Date: Thu, 24 Mar 2016 11:33:27 -0400 Subject: [PATCH] more pvalink --- pdbApp/pvalink.cpp | 65 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 49 insertions(+), 16 deletions(-) diff --git a/pdbApp/pvalink.cpp b/pdbApp/pvalink.cpp index 4dcb11d..937d736 100644 --- a/pdbApp/pvalink.cpp +++ b/pdbApp/pvalink.cpp @@ -2,6 +2,7 @@ #include #include +#define EPICS_DBCA_PRIVATE_API #include #include #include @@ -323,6 +324,32 @@ void pvaLinkChannel::monitorEvent(pva::Monitor::shared_pointer const & monitor) errlogPrintf("pvaLink " #LOC " fails %s: %s\n", plink->precord->name, e.what()); \ } +void pvaReportLink(const struct link *plink, dbLinkReportInfo *pinfo) +{ + const char * fname = dbGetFieldName(pinfo->pentry), + * rname = dbGetRecordName(pinfo->pentry); + + TRY { + pinfo->connected = self->lchan->chan && self->lchan->chanmon; + + if(pinfo->connected) { + pinfo->readable = 1; + + if (pinfo->filter==dbLinkReportAll || pinfo->filter==dbLinkReportConnected) { + printf(LSET_REPORT_INDENT "%28s.%-4s ==> pva://%s.%s\n", + rname, fname, + self->name.c_str(), self->field.c_str()); + } + } else { + if (pinfo->filter==dbLinkReportAll || pinfo->filter==dbLinkReportDisconnected) { + printf(LSET_REPORT_INDENT "%28s.%-4s --> pva://%s.%s\n", + rname, fname, + self->name.c_str(), self->field.c_str()); + } + } + }CATCH(pvaReportLink) +} + void pvaRemoveLink(struct dbLocker *locker, struct link *plink) { try { @@ -330,6 +357,7 @@ void pvaRemoveLink(struct dbLocker *locker, struct link *plink) assert(self->alive); Guard G(self->lchan->lock); + plink->value.pv_link.backend = NULL; plink->value.pv_link.pvt = NULL; plink->value.pv_link.pvt = 0; plink->value.pv_link.pvlMask = 0; @@ -531,6 +559,8 @@ void pvaScanForward(struct link *plink) } lset pva_lset = { + LSET_API_VERSION, + &pvaReportLink, &pvaRemoveLink, &pvaIsConnected, &pvaGetDBFtype, @@ -552,31 +582,34 @@ void (*nextAddLinkHook)(struct link *link, short dbfType); void pvaAddLinkHook(struct link *link, short dbfType) { + const char *target = link->value.pv_link.pvname; + + if(strncmp(target, "pva://", 6)!=0) { + if(nextAddLinkHook) + (*nextAddLinkHook)(link, dbfType); + return; + } + + assert(link->precord); + assert(link->type == PV_LINK); + + target += 6; // skip "pva://" + try { - assert(link->precord); - assert(link->type == PV_LINK); - const char *target = link->value.pv_link.pvname; std::cerr<<"pvaLink '"< pvt(new pvaLink(link, target, dbfType)); - std::auto_ptr pvt(new pvaLink(link, target, dbfType)); + link->value.pv_link.pvt = pvt.release(); + link->value.pv_link.backend = "pva"; + link->type = CA_LINK; + link->lset = &pva_lset; - link->type = CA_LINK; - link->lset = &pva_lset; - link->value.pv_link.pvt = pvt.release(); - - return; - } - - return; }catch(std::exception& e){ errlogPrintf("Error setting up pva link: %s : %s\n", link->value.pv_link.pvname, e.what()); + // return w/ lset==NULL results in an invalid link (all operations error) } - if(nextAddLinkHook) - (*nextAddLinkHook)(link, dbfType); } void initPVALink(initHookState state)