I implemented this in the same way and it works beautifully!
If anything, at least this was a very good didactic exercise with the transform record. But indeed the mbbiDirect is what i was looking for.
Thanks for the advice 🙂
Marco
From: Brown, Garth <gwbrown at slac.stanford.edu>
Sent: 04 August 2022 15:45
To: Marco A. Barra Montevechi Filho <marco.filho at lnls.br>; tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>; Rolf Keitel <rolf at triumf.ca>
Subject: Re: Implementing transform field
That was my thought as well, mbbiDirect with bi. It sounds like you're trying to do the same sort of thing as in some code I'm currently working with. Here's a few lines as an example:
record(mbbiDirect, "$(P):BLM_STS_REG_BITS") {
field(DESC, "BLM common status register")
field(INP, "$(P):BLM_STS_REG CP MSI")
}
record(bi, "$(P):FLT_LATCH") {
field(DESC, "BCS Fault (Latched)")
field(INP, "$(P):BLM_STS_REG_BITS.B0 CP MSI")
field(ZNAM, "FAULT")
field(ZSV, "MAJOR")
field(ONAM, "OK")
}
record(bi, "$(P):FLT_LIVE") {
field(DESC, "BCS Comparator trip")
field(INP, "$(P):BLM_STS_REG_BITS.B1 CP MSI")
field(ZNAM, "TRIP")
field(ZSV, "MAJOR")
field(ONAM, "OK")
}
record(bi, "$(P):VL_OVP_DET") {
field(DESC, "Input overrange")
field(INP, "$(P):BLM_STS_REG_BITS.B2 CP MSI")
field(ZNAM, "OK")
field(ONAM, "OVERRANGE")
field(OSV, "MAJOR")
}
-Garth
From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of Rolf Keitel via Tech-talk <tech-talk at aps.anl.gov>
Sent: Thursday, August 4, 2022 9:40 AM
To: Marco A. Barra Montevechi Filho <marco.filho at lnls.br>; tech-talk at aps.anl.gov <tech-talk at aps.anl.gov>
Subject: Re: Implementing transform field
Hi Marco,
why don't you use a mbbiDirect record to read the modbus register and then 16 bi records pointing the INP fields of the bi records to the mbbiRecord's B0..BF fields.
- rolf -
On 2022-08-04 7:19 a.m., Marco A. Barra Montevechi Filho via Tech-talk wrote:
Good morning, all!
Im trying to implement the transform field in an IOC but im not getting the expected result:
i have an analog in record reading a bitmask value from a modbus register. Since the bitmask has 16 bits, i want to perform 16 bitwise operations to transform each bit in a
binary in record thus transforming each 0 or 1 into a different string.
Since i dont want to need to create 16 calcout records, i thought i could use the
transform record to perform all bitwise operations and push each one of them into a different
binary in record. So after reading the documentation i tried to perform a calculation with
transform just for testing:
record(ai,
"${BL}:${H}:${EQ}:BitmaskGetter")
{
field(DESC,
"Bitmask used by other pvs.")
field(DTYP,"asynInt32")
field(INP,"@asyn(SIP_EMODBUS_1_1_Rd_Status,0,1000)MODBUS_DATA")
field(SCAN, "I/O Intr")
field(FLNK,
"${BL}:${H}:${EQ}:StatusSeparator")
}
record(transform,
"${BL}:${H}:${EQ}:StatusSeparator"){
field(DESC,
"PV to process status bitmask")
field(INPA,
"${BL}:${H}:${EQ}:StatusBitmask")
field(CLCA,
"A+1")
field(OUTA,
"${BL}:${H}:${EQ}:EnableStatus")
field(SCAN,
"Passive")
}
record(bi,
"${BL}:${H}:${EQ}:EnableStatus"){
field(DESC,
"Power supply status")
field(ZNAM,
"Stopped")
field(ONAM,
"Started")
}
So i expected that while caget in BitmaskGetter returns 0, caget into StatusSeparator.A would return 1 and EnableStatus would return "Started". It is not what happens: StatusSeparator returns 0 and EnableStatus returns "Stopped".
To test if the calculation is right, i tried substituting the transform record to a
calc one:
record(ai,
"${BL}:${H}:${EQ}:BitmaskGetter")
{
field(DESC,
"Bitmask used by other pvs.")
field(DTYP,"asynInt32")
field(INP,"@asyn(SIP_EMODBUS_1_1_Rd_Status,0,1000)MODBUS_DATA")
field(SCAN, "I/O Intr")
field(FLNK,
"test_calc")
}
record(calcout,
"${BL}:${H}:${EQ}:StatusSeparator""){
field(DESC,
"PV to process status bitmask")
field(INPA,
"${BL}:${H}:${EQ}:StatusBitmask")
field(CALC,
"A+1")
field(OUT,
"${BL}:${H}:${EQ}:EnableStatus")
}
record(bi,
"${BL}:${H}:${EQ}:EnableStatus"){
field(DESC,
"Power supply status")
field(ZNAM,
"Stopped")
field(ONAM,
"Started")
}
And now caget into StatusSeparator returns 1, StatusSeparator.A returns 0, BitmaskGetter returns 0 and EnableStatus returns "Started", as expected.
So i figure field OUTA from the transform record pushes the value in field A (which is zero) to the EnableStatus link. If this is the case, is there any way at all to push the result from CLCA to the EnableStatus link? Also,in which field is the
result from CLCA field stored, if any?
Thanks in advance,
Marco
Aviso Legal: Esta mensagem e seus anexos podem conter informações confidenciais e/ou de uso restrito. Observe atentamente seu conteúdo e considere eventual consulta
ao remetente antes de copiá-la, divulgá-la ou distribuí-la. Se você recebeu esta mensagem por engano, por favor avise o remetente e apague-a imediatamente.
Disclaimer: This email and its attachments may contain confidential and/or privileged information. Observe its content carefully and consider possible querying
to the sender before copying, disclosing or distributing it. If you have received this email by mistake, please notify the sender and delete it immediately.
--
Rolf Keitel, Ph.D.
Researcher Emeritus
Office:
TRIUMF, 4004 Wesbrook Mall
Vancouver, BC, V6T 2A3
604 222 7453
Home:
4158 West 13th Ave
Vancouver, BC, V6R 2T6
604 228 0594
e-mail:
rolf at triumf.ca
|