EPICS Controls Argonne National Laboratory

Experimental Physics and
Industrial Control System

1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  <20232024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  <20232024 
<== Date ==> <== Thread ==>

Subject: Re: NTEnum
From: Gabriel Fedel via Tech-talk <tech-talk at aps.anl.gov>
To: Michael Davidsaver <mdavidsaver at gmail.com>
Cc: tech-talk at aps.anl.gov
Date: Mon, 24 Jul 2023 09:15:57 +0200


On 7/22/23 18:13, Michael Davidsaver wrote:
On 7/21/23 00:42, Gabriel Fedel via Tech-talk wrote:
Hi Tech-Talk,

I'm playing a bit with the NTEnum (https://docs.epics-controls.org/en/latest/specs/Normative-Types-Specification.html#ntenum), and I'm wondering if would be possible to use a string as the input so I would get its index.

Something like:

pvput PVEnum "ABC"

This is what should happen now.

I'm failing to get this behavior.

I'm playing a bit with this example (from here - https://github.com/epics-base/pva2pva/blob/master/iocBoot/iocimagedemo/ntenum.db) :

record(longout, "$(P):ENUM:INDEX") {
    field(VAL, "1")
    field(PINI, "YES")
    info(Q:group, {
        "$(P):ENUM":{
            +id:"epics:nt/NTEnum:1.0",
            "value":{+type:"structure", +id:"enum_t"},
            "value.index":{+type:"plain", +channel:"VAL", +putorder:"0"},
            "":{+type:"meta", +channel:"VAL"}
        }
    })
}

record(aai, "$(P):ENUM:CHOICES") {
    field(FTVL, "STRING")
    field(NELM, "64")
    field(INP , {const:["ZERO", "ONE"]})
    info(Q:group, {
        "$(P):ENUM":{
            +id:"epics:nt/NTEnum:1.0",
            "value.choices":{+type:"plain", +channel:"VAL"}
        }
    })
}

---
I included putorder on the INDEX, the only behavior I could have was :

* I can pvput to ENUM:INDEX (an integer), and when a read the ENUM I get the choice
* I can "pvput ENUM value.index=0" and then when I pvget I get the choice


I tried to include a new stringout record to be my "string index" but also didn't work.

Am I considering a non-valid use case for the NTEnum ?

NTEnum is a bit awkward as it requires that clients be aware of
value.index and value.choices.  In the specific case of pvput
the code involved is here.

https://github.com/epics-base/pvAccessCPP/blob/581d100a029e6f68f3c1830b90509b3ee5ebd7a0/pvtoolsSrc/pvput.cpp#L180-L202

Note that this code is triggered when field being written is a
sub-structure with ID "enum_t".  So it isn't limited to NTEnum.


pvget PVEnum
return : 5

"pvget PVEnum value.index" would print the numeric index.


I couldn't make this pvget syntax works. Actually, I'm not sure how to get one specific field using pvget.


I'm using this db as a start point: https://github.com/epics-base/pva2pva/blob/master/iocBoot/iocimagedemo/ntenum.db

Thanks in advance
Cheers



--
Gabriel Fedel
Embedded Software Developer  / Integrated Control System Division

European Spallation Source ERIC
P.O. Box 176, SE-221 00 Lund, Sweden
Visiting address: Partikelgatan 2, 224 84 Lund
Mobile: +46 72 179 23 01
E-mail: gabriel.fedel at ess.eu
ess.eu

References:
NTEnum Gabriel Fedel via Tech-talk
Re: NTEnum Michael Davidsaver via Tech-talk

Navigate by Date:
Prev: RE: SNCSEQ Downloading TZVETKOV Stephane via Tech-talk
Next: Re: SNCSEQ Downloading Ralph Lange via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  <20232024 
Navigate by Thread:
Prev: Re: NTEnum Michael Davidsaver via Tech-talk
Next: Need help with Phoebus Alarm E-logger and Interface to the E-mail Charles Jenkins via Tech-talk
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  2012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  <20232024 
ANJ, 24 Jul 2023 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·