From fc40ef1b8681e359f24ab618e13dc8a2ec1b8d2f Mon Sep 17 00:00:00 2001 From: Klemen Vodopivec Date: Fri, 31 Dec 2021 21:44:35 -0500 Subject: [PATCH] Add OUT field Now that we have static output value type, it makes sense to have an OUT field. --- pycalcRecord.md | 3 +++ src/pycalcRecord.cpp | 1 + src/pycalcRecord.dbd | 4 ++++ testApp/Db/pycalcrectest.db | 4 ++++ 4 files changed, 12 insertions(+) diff --git a/pycalcRecord.md b/pycalcRecord.md index 9e76db2..7b1d390 100644 --- a/pycalcRecord.md +++ b/pycalcRecord.md @@ -37,6 +37,9 @@ record processes unless Python code could not be executed. The result value is converted to the type specified in FTVL which can be one of the following: LONG, DOUBLE, STRING. +If an output link is specified in OUT field, the same value from VAL is +sent to the output link. + ### Python expression The purpose of this record is to be able to execute arbitrary Python code by passing multiple parameters from EPICS PVs. The actual code to be executed diff --git a/src/pycalcRecord.cpp b/src/pycalcRecord.cpp index 6291043..5b56b3f 100644 --- a/src/pycalcRecord.cpp +++ b/src/pycalcRecord.cpp @@ -217,6 +217,7 @@ static long processRecord(dbCommon *common) } recGblGetTimeStamp(rec); + dbPutLink(&rec->out, rec->ftvl, rec->val, 1); auto monitor_mask = recGblResetAlarms(rec); if (rec->ctx->processCbStatus == -1) { diff --git a/src/pycalcRecord.dbd b/src/pycalcRecord.dbd index cb28914..8a7f620 100644 --- a/src/pycalcRecord.dbd +++ b/src/pycalcRecord.dbd @@ -32,6 +32,10 @@ recordtype(pycalc) { initial("DOUBLE") menu(menuFtype) } + field(OUT,DBF_OUTLINK) { + prompt("Output Specification") + interest(1) + } field(INPA,DBF_INLINK) { prompt("Input Link A") diff --git a/testApp/Db/pycalcrectest.db b/testApp/Db/pycalcrectest.db index cf60b88..072c5a7 100644 --- a/testApp/Db/pycalcrectest.db +++ b/testApp/Db/pycalcrectest.db @@ -4,6 +4,9 @@ record(ai, "PyCalcTest:Input1") { record(ai, "PyCalcTest:Input2") { field(INP, "6.4") } +record(longin, "PyCalcTest:Output") { + field(VAL, "-1") +} record(pycalc, "PyCalcTest:MathExpr") { field(INPA, "17") field(INPB, "3") @@ -16,6 +19,7 @@ record(pycalc, "PyCalcTest:AdaptiveTypes") { field(FTB, "DOUBLE") field(CALC, "pow(max([A, B]), 2)") field(FTVL, "LONG") + field(OUT, "PyCalcTest:Output PP") } record(pycalc, "PyCalcTest:InvalidAlarm") { field(CALC, "unknown_function()")