Hi:
Not sure how to pick the "best" solution, but here are your options..
For a basic VAL = condition ? A : B type decision you can use the calc record.
Processed every time, computing a new value every time.
Anybody can see the CALC, so easy to inspect and maintain.
But length of CALC is limited, and if you need to split a larger expressions over multiple CALC records, it's soon getting hard to understand.
In a subroutine record (aSub) you can implement "larger" computations, but then nobody can see/change them without looking at the
source code, recompiling it, i.e. a bit harder to maintain.
If you want to conditionally process records, the calcout record can do that via OOPT settings.
Same advantages and limitations as basic calc record.
If you want to conditionally compute and process things, the SNL sequencer can do that, but as with the subroutine record you now have snl/C code, i.e. separate source code, not easily inspected like records and their fields at runtime.
Thanks,
Kay
From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of Mark Davis via Tech-talk <tech-talk at aps.anl.gov>
Sent: Monday, April 27, 2020 11:05 AM
To: tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>; John Priller <priller at nscl.msu.edu>
Subject: [EXTERNAL] Tips for doing conditional logic in EPICS records
Hi all,
I am looking for some tips on the best way to implement logic such as
the following using EPICS records:
flag = 1;
for (each new set of readings) {
if (readbackA == fixedVal1) flag = 1; else
if (flag == 1) setVal = readbackB; else
if (readBackC == fixedVal2) setVal = readbackD;
flag = 0;
}
For the initial setting I figured simply a record that includes the
initial value in the VAL field (and PINI set to "Yes"?).
The for "loop" would be simply an FLNK in the record (or last in a
sequence of records) that gets the new readings, triggering the
processing of the the record that handles the 1st if condition (in this
case, I have one record that gets them all at once).
At that point how to best to proceed is not obvious to me, and there are
probably lots of possibilities (A sequence of calcout or scalcout
records? Maybe a transform record?)
Suggestions?
--
Mark Davis
NSCL/FRIB Control Systems Software Engineer
davism50 at msu.edu
|