Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 9 additions & 3 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,15 @@ cache:
#---------------------------------#

install:
# for the sequencer
- cinst re2c
- cmd: git submodule update --init --recursive

- powershell -Command "Invoke-WebRequest https://www.python.org/ftp/python/3.10.9/python-3.10.9-amd64.exe -OutFile python-install.exe"
- start /wait python-install.exe /quiet InstallAllUsers=1 PrependPath=1 Include_test=0
- refreshenv
- python -m pip install --upgrade pip setuptools

# For the sequencer
- choco install re2c -y
- git submodule update --init --recursive

#---------------------------------#
# repository cloning #
Expand Down
28 changes: 27 additions & 1 deletion pdbApp/pvif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@

#include <epicsExport.h>

#ifdef HAVE_UTAG
#define CUSTOM_ALARM_MSG
#endif

#ifdef EPICS_VERSION_INT
# if EPICS_VERSION_INT>=VERSION_INT(3,16,1,0)
# define USE_INT64
Expand Down Expand Up @@ -344,18 +348,32 @@ void attachAll(PVX& pvm, const pvd::PVStructurePtr& pv)
}

template<typename Meta>
#ifdef CUSTOM_ALARM_MSG
void mapStatus(const Meta& meta, pvd::PVInt* status, pvd::PVString* message, dbChannel *chan)
#else
void mapStatus(const Meta& meta, pvd::PVInt* status, pvd::PVString* message)
#endif
{
#ifdef CUSTOM_ALARM_MSG
pdbRecordIterator info(chan);
const char *userMsg = info.info("Q:alarm:msg");
#endif
#ifdef HAVE_UTAG
if(meta.amsg[0]!='\0') {
message->put(meta.amsg);
} else
#endif
#ifdef CUSTOM_ALARM_MSG
if(userMsg != NULL && meta.status > NO_ALARM) {
message->put(userMsg);
} else
#endif
{
if(meta.status<ALARM_NSTATUS)
message->put(epicsAlarmConditionStrings[meta.status]);
else
message->put("???");

}
// Arbitrary mapping from DB status codes
unsigned out;
switch(meta.status) {
Expand Down Expand Up @@ -425,7 +443,11 @@ void putTime(const pvTimeAlarm& pv, unsigned dbe, db_field_log *pfl)

putMetaImpl(pv, meta);
if(dbe&DBE_ALARM) {
#ifdef CUSTOM_ALARM_MSG
mapStatus(meta, pv.status.get(), pv.message.get(), pv.chan);
#else
mapStatus(meta, pv.status.get(), pv.message.get());
#endif
pv.severity->put(meta.severity);
}
}
Expand Down Expand Up @@ -571,7 +593,11 @@ void putMeta(const pvCommon& pv, unsigned dbe, db_field_log *pfl)
putMetaImpl(pv, meta);
#define FMAP(MNAME, FNAME) pv.MNAME->put(meta.FNAME)
if(dbe&DBE_ALARM) {
#ifdef CUSTOM_ALARM_MSG
mapStatus(meta, pv.status.get(), pv.message.get(), pv.chan);
#else
mapStatus(meta, pv.status.get(), pv.message.get());
#endif
FMAP(severity, severity);
}
if(dbe&DBE_PROPERTY) {
Expand Down
10 changes: 10 additions & 0 deletions testApp/test_custom_alarm.db
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
record(ai, "custom:ai") {
field(DESC, "Custom Analog Input for Alarm Test")
field(DTYP, "Soft Channel")
field(SCAN, "Passive")
field(HIHI, "50.0")
field(HIGH, "40.0")
field(HHSV, "MAJOR")
field(HSV, "MINOR")
info(Q:alarm:msg, "Custom Msg Alarm AI!")
}
66 changes: 66 additions & 0 deletions testApp/testpvif.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@
#include "pvif.h"
#include "utilities.h"


#ifdef HAVE_UTAG
#define CUSTOM_ALARM_MSG
#endif

namespace pvd = epics::pvData;

extern "C"
Expand Down Expand Up @@ -637,12 +642,70 @@ void testFilters()
testFieldEqual<pvd::PVShortArray>(root, "dut.value", expected);
#endif // >= 7.0
}
#ifdef CUSTOM_ALARM_MSG
void testCustomAlarmMessage()
{
testDiag("testCustomAlarmMessage");

TestIOC IOC;

testdbReadDatabase("p2pTestIoc.dbd", NULL, NULL);
p2pTestIoc_registerRecordDeviceDriver(pdbbase);
testdbReadDatabase("test_custom_alarm.db", NULL, NULL);

aiRecord *prec_custom_ai = (aiRecord*)testdbRecordPtr("custom:ai");
testTrue(prec_custom_ai != NULL);

IOC.init();

DBCH chan_ai("custom:ai");

pvd::PVStructurePtr root;
p2p::auto_ptr<PVIF> pvif_ai;
{
ScalarBuilder builder_ai(chan_ai);

pvd::StructureConstPtr dtype_root(pvd::getFieldCreate()->createFieldBuilder()
->add("custom_ai", builder_ai.dtype())
->createStructure());

root = pvd::getPVDataCreate()->createPVStructure(dtype_root);
pvif_ai.reset(builder_ai.attach(root, FieldName("custom_ai")));
}

pvd::BitSet mask;

dbScanLock((dbCommon*)prec_custom_ai);
prec_custom_ai->val = 55.0;
dbProcess((dbCommon*)prec_custom_ai);
dbScanUnlock((dbCommon*)prec_custom_ai);

pvif_ai->put(mask, DBE_ALARM|DBE_PROPERTY, NULL);

testFieldEqual<pvd::PVString>(root, "custom_ai.alarm.message", "Custom Msg Alarm AI!");
testFieldEqual<pvd::PVInt>(root, "custom_ai.alarm.severity", 2);
testFieldEqual<pvd::PVInt>(root, "custom_ai.alarm.status", 1);

dbScanLock((dbCommon*)prec_custom_ai);
prec_custom_ai->val = 25.0;
dbProcess((dbCommon*)prec_custom_ai);
dbScanUnlock((dbCommon*)prec_custom_ai);
pvif_ai->put(mask, DBE_ALARM|DBE_PROPERTY, NULL);

testFieldEqual<pvd::PVString>(root, "custom_ai.alarm.message", "NO_ALARM");
testFieldEqual<pvd::PVInt>(root, "custom_ai.alarm.severity", 0);
testFieldEqual<pvd::PVInt>(root, "custom_ai.alarm.status", 0);
}
#endif // CUSTOM_ALARM_MSG
} // namespace

MAIN(testpvif)
{
#ifdef CUSTOM_ALARM_MSG
testPlan(105);
#else
testPlan(98);
#endif
#ifdef USE_INT64
testDiag("Testing of 64-bit field access");
#else
Expand All @@ -651,5 +714,8 @@ MAIN(testpvif)
testScalar();
testPlain();
testFilters();
#ifdef CUSTOM_ALARM_MSG
testCustomAlarmMessage();
#endif
return testDone();
}