Hej Kas and Mark,
I have been doing some kind of work to implement the “metadata interface” for asyn.
For the moment, that is put aside - a lot of stuff is working,
but cleanup is needed, and a review.
Reading this conversation, should we make a video-call, Mark, Kaz ?
BR
/Torsten
> On 7 Jul 2022, at 15:39, Mark Rivers via Tech-talk <tech-talk at aps.anl.gov> wrote:
>
> > You could store the enum strings and the enum values in a std::set,
>
> I meant to say std::map, not std::set.
>
> Mark
>
>
> From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of Mark Rivers via Tech-talk <tech-talk at aps.anl.gov>
> Sent: Thursday, July 7, 2022 8:35 AM
> To: Gofron, Kazimierz <kgofron at bnl.gov>
> Cc: tech-talk <tech-talk at aps.anl.gov>
> Subject: Re: Set/get enum value of mbbo from within AD driver
>
> Hi Kaz,
>
> > In general asyn port drivers don’t have any way of knowing what the mbbo/mbbi enum strings are.
>
> I should clarify that statement. It is true if the enum strings are defined in your database file like you showed:
>
> record(mbbo, "$(P)$(R)TriggerMode")
> {
> field(ZRST, "PEXSTART_NEXSTOP")
> field(ZRVL, "0")
> field(ONST, "NEXSTART_PEXSTOP")
> field(ONVL, "1")
> field(TWST, "PEXSTART_TIMERSTOP")
> field(TWVL, "2")
> field(THST, "NEXSTART_TIMERSTOP")
> field(THVL, "3")
> field(FRST, "AUTOTRIGSTART_TIMERSTOP")
> field(FRVL, "4")
> field(FVST, "CONTINUOUS")
> field(FVVL, "5")
> field(SXST, "SOFTWARESTART_TIMERSTOP")
> field(SXVL, "6")
> field(SVST, "SOFTWARESTART_TIMERSTOP")
> field(SVVL, "7")
> }
> }
> (Note: it seems you have an error in the database since the last 2 enum strings are identical?)
>
> However, as I said previously you can define those enum strings and enum values in your driver and populate the record with them if you implement the readEnum() method. Then your database file will simply look like this:
>
> record(mbbo, "$(P)$(R)TriggerMode")
> {
> }
>
> In that case your driver will know what the strings are. You could store the enum strings and the enum values in a std::set, where the enum string is the map key and the enum value is the map value. For example:
>
> Put this in the private driver member data.
> std::map<std::string, int> mTriggerModeMap;
>
> Put this in the constructor.
> mTriggerModeMap["PEXSTART_NEXSTOP"] = 0;
> mTriggerModeMap["NEXSTART_PEXSTOP"] = 1;
> mTriggerModeMap["PEXSTART_TIMERSTOP"] = 2;
> mTriggerModeMap["NEXSTART_TIMERSTOP"] = 3;
> mTriggerModeMap["AUTOTRIGSTART_TIMERSTOP"] = 4;
> mTriggerModeMap["CONTINUOUS"] = 5;
> mTriggerModeMap["SOFTWARESTART_TIMERSTOP"] = 6;
> mTriggerModeMap["SOFTWARESTART_TIMERSTOP"] = 7;
>
> You can then assign the values with setIntegerParam using the strings:
>
> This will set the triggerMode parameter to 3:
> setIntegerParam(triggerMode, mTriggerModeMap["NEXSTART_TIMERSTOP"])
>
> This is my first draft of the readEnum method you would need to add to your driver.
>
> asynStatus myDriver::readEnum(asynUser *pasynUser, char *strings[], int values[], int severities[],
> size_t nElements, size_t *nIn)
> {
> int function = pasynUser->reason;
> *nIn = 0;
>
> if (function == triggerMode) {
> for (auto it : mTriggerMap) {
> if (strings[*nIn]) free(strings[*nIn]);
> strings[*nIn] = epicsStrDup(it->first.c_str());
> values[*nIn] = it->second;
> severities[*nIn] = 0;
> (*nIn)++;
> }
> }
> return asynSuccess;
> }
>
> Mark
>
> From: Tech-talk <tech-talk-bounces at aps.anl.gov> on behalf of Mark Rivers via Tech-talk <tech-talk at aps.anl.gov>
> Sent: Wednesday, July 6, 2022 6:00 PM
> To: Gofron, Kazimierz <kgofron at bnl.gov>
> Cc: tech-talk <tech-talk at aps.anl.gov>
> Subject: RE: Set/get enum value of mbbo from within AD driver
>
> Hi Kaz,
>
> Unfortunately what you want to do is not possible for a number of reasons:
>
> - The mbbi record support to device support interface deals only with numbers (RVAL, SHFT, ZRVL, etc.). Look at the read_mbbi documentation here:
https://epics.anl.gov/base/R7-0/6-docs/mbbiRecord.html
> - For this reason asyn device support only supports the mbbo and mbbi records using the asynInt32 and asunUInt32Digital interfaces, not the asynOctet interface.
> - In general asyn port drivers don’t have any way of knowing what the mbbo/mbbi enum strings are. The only method by which those strings can be passed to the driver is via write() method in the asynEnum interface, or equivalently the asynPortDriver::writeEnum()
method. These can pass the enum strings and values to the driver. However there is currently no device support that actually calls those methods, so drivers have no idea what the enum strings are.
>
> Mark
>
> From: Gofron, Kazimierz <kgofron at bnl.gov>
> Sent: Wednesday, July 6, 2022 4:57 PM
> To: Mark Rivers <rivers at cars.uchicago.edu>
> Cc: tech-talk <tech-talk at aps.anl.gov>
> Subject: Re: Set/get enum value of mbbo from within AD driver
>
> Hi Mark,
>
> Ad 1: Need to read/set enum string value of mbbo/mbbi record, instead of .VAL field within ADDriver.
> VAL field is read/set with setIntegerParam() and getIntegerParam(), and I am looking for equivalent function for mbbo enum, if they exist.
>
> ================
> Looking for equivalent to setting/reading enum using caget/caput (instead of setting mbbo .VAL to 2), like below:
>
> setting mbbo:
> ```
> gofron@HP/base/bin/linux-x86_64$ ./caput TPX3-TEST:cam1:TriggerMode "PEXSTART_NEXSTOP"
> Old : TPX3-TEST:cam1:TriggerMode AUTOTRIGSTART_TIMERSTOP
> New : TPX3-TEST:cam1:TriggerMode PEXSTART_NEXSTOP
> ```
>
> or reading enum string of mbbo record:
> ```
> kgofron@kgofron-HP-Z6-G4-Workstation:/epics/src/RHEL8/base/bin/linux-x86_64$ ./caget TPX3-TEST:cam1:TriggerMode
> TPX3-TEST:cam1:TriggerMode PEXSTART_NEXSTOP
>
> ```
> ================
>
> The mbbo record is defined:
>
> record(mbbo, "$(P)$(R)TriggerMode")
> {
> field(ZRST, "PEXSTART_NEXSTOP")
> field(ZRVL, "0")
> field(ONST, "NEXSTART_PEXSTOP")
> field(ONVL, "1")
> field(TWST, "PEXSTART_TIMERSTOP")
> field(TWVL, "2")
> field(THST, "NEXSTART_TIMERSTOP")
> field(THVL, "3")
> field(FRST, "AUTOTRIGSTART_TIMERSTOP")
> field(FRVL, "4")
> field(FVST, "CONTINUOUS")
> field(FVVL, "5")
> field(SXST, "SOFTWARESTART_TIMERSTOP")
> field(SXVL, "6")
> field(SVST, "SOFTWARESTART_TIMERSTOP")
> field(SVVL, "7")
> }
>
> Thanks for looking into this,
>
> Kaz
> From: Mark Rivers <rivers at cars.uchicago.edu>
> Sent: Wednesday, July 6, 2022 4:13 PM
> To: Gofron, Kazimierz <kgofron at bnl.gov>
> Cc: tech-talk <tech-talk at aps.anl.gov>
> Subject: RE: Set/get enum value of mbbo from within AD driver
>
> Hi Kaz,
>
> Ø Is there a way to set/get enum string value of mbbo/mbbi record from within areaDetector driver?
>
> I want to be clear about what you are asking. Are you asking whether an areaDetector driver can
>
> 1) Select the mbbi value using a string (rather than a number)?
> or
> 2) Change the string and/or integer value associated with a particular enum index?
>
> It is not currently possible to do 1), you can only select by number, not by string.
>
> It is possible to do 2). That is done with the asynEnum interface. You implement methods that override one or more of these asynPortDriver methods:
> - readEnum
> - writeEnum
> - doCallbacksEnum
>
> This is used in many areaDetector drivers so that they can populate the enum strings and values with appropriate values for a particular detector model. These are some of the drivers that implement readEnum() to set enum strings and values:
>
> - andor3.cpp
> - andorCCD.cpp
> - ADGenICam.cpp
> - GenICamFeature.cpp
> - arvFeature.cpp
> - ADVimba.cpp
> - VimbaFeature.cpp
>
> Mark
>
>
>
>
> From: Tech-talk <tech-talk-bounces at aps.anl.gov> On Behalf Of Gofron, Kazimierz via Tech-talk
> Sent: Wednesday, July 6, 2022 2:43 PM
> To: tech-talk at aps.anl.gov
> Subject: Set/get enum value of mbbo from within AD driver
>
> Hi all,
>
> Is there a way to set/get enum string value of mbbo/mbbi record from within areaDetector driver?
>
> I can set/get Enum values using caput/caget, but setIntegerParam()/getIntegerParam() which are appropriate for mbbo/mbbi are not appropriate for enum, and setStringParam()/getStrinParam are not compatible with mbbo/mbbi type.
>
> Also mbbo/mbbi do not have SVAL field, that sCalcoutRecord has.
>
> Thanks,
>
> Kaz
>
>