On 7/27/22 09:28, Wang, Andrew wrote:
HI Michael and Andrew,
Thank you for the suggestion! That is a good idea to check the input type before proceeding further with the union.
It occurred to me yesterday that there is another way to accomplish this within
the link abstraction. Link to the NAME field. Either with stringin (if record
names are <40 characters) or aai/waveform (if longer).
record(ai, "my:name:is") {}
record(ai, "my:name:XXXXXXXXXXXXXXXXXXXXXXXXXX:is:realllllllylongggggggx") {}
record(stringin, "short:name") {
field(INP , "my:name:is.NAME NPP")
field(PINI, "YES")
}
record(aai, "long:name") {
field(FTVL, "CHAR")
field(NELM, "128")
field(INP , "my:name:XXXXXXXXXXXXXXXXXXXXXXXXXX:is:realllllllylongggggggx.NAME$ NPP")
field(PINI, "YES")
}
Yeah, so the reason I am doing this is because I am interested in using the streamReload function from StreamDevice for certain records. I didn't want to hard code the record name for the streamReload function and would rather use the record name specified in the input links.
For instance, in my aSub function, I wanted to steer away from doing this:
record(aSub, "reload_rec_for_setting_voltage")
{
field(SNAM, "reload")
}
static long reload(aSubRecord *prec)
{
streamReload("voltage_rec")
return 0;
}
My aim was to do this instead:
record(aSub, "reload_rec_for_setting_voltage")
{
field(SNAM, "reload")
field(INPA, "voltage_rec")
}
static long reload(aSubRecord *prec)
{
DBLINK inpa = prec->inpa;
if (inpa.type == DB_LINK)
{
char *rec_name = inpa.value.pv_link.pvname;
streamReload(rec_name);
}
}
This will allow me to use the aSub record for other records I want to apply streamReload to. I didn't want to create 10+ individual functions for each record I wanted to use streamReload on.
Thanks,
Andy
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*From:* Michael Davidsaver <mdavidsaver at gmail.com>
*Sent:* Wednesday, July 27, 2022 8:30 AM
*To:* Wang, Andrew <wang126 at llnl.gov>
*Cc:* EPICS tech-talk <tech-talk at aps.anl.gov>
*Subject:* Re: Retrieving record name from aSub input/output fields
On 7/26/22 16:53, Wang, Andrew via Tech-talk wrote:
Update. I think I got it. I had to do the following.
static long func(aSubRecord *prec)
{
DBLINK inpa = prec->inpa;
Be aware that 'inpa.value' is a C union.
So it is strongly recommended to test 'prec->inp.type' before accessing.
In this case you are assuming that 'prec->inp.type==DB_LINK'.
char *rec_name = inpa.value.pv_link.pvname;
printf(“Record name in INPA is %s\n”, rec_name);
Also, what motivates this? Have you found an operation that
isn't covered by the link abstraction?
return 0;
}
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
*From:* Wang, Andrew
*Sent:* Tuesday, July 26, 2022 4:17 PM
*To:* EPICS tech-talk <tech-talk at aps.anl.gov>
*Subject:* Retrieving record name from aSub input/output fields
Hi all,
Quick question this time. I was wondering if there was a way to retrieve the name of the record referenced in an OUTLINK/INLINK field such as INPA, OUTA, etc. in the aSub routine.
For instance, suppose I had an aSub record such as the following.
record(aSub, “example”)
{
field(SNAM, “func”)
field(INPA, “rec_in_inpa”)
}
I would like to be able to print the name of the record in INPA within “func”.
static long func(aSubRecord *prec)
{
char *rec_name = prec->____;
printf(“Record name in INPA is %s\n”, rec_name);
return 0;
}
Thanks,
Andy
Purple ribbon awareness <https://urldefense.us/v3/__https://www.disabled-world.com/disability/awareness/ribbons.php*purple__;Iw!!G2kpM7uM-TzIFchu!inuIyxNM2XJXWKnvIjTejbSyl70ULfXoS2SJBJ1rrGgMtiBGic7GoQpea6to21OpaNc$ >
- References:
- Retrieving record name from aSub input/output fields Wang, Andrew via Tech-talk
- Re: Retrieving record name from aSub input/output fields Wang, Andrew via Tech-talk
- Re: Retrieving record name from aSub input/output fields Michael Davidsaver via Tech-talk
- Re: Retrieving record name from aSub input/output fields Wang, Andrew via Tech-talk
- Navigate by Date:
- Prev:
Re: Implementing transform field Marco A. Barra Montevechi Filho via Tech-talk
- Next:
Re: Implementing transform field Marco A. Barra Montevechi Filho 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>
2023
2024
2025
- Navigate by Thread:
- Prev:
Re: Retrieving record name from aSub input/output fields Wang, Andrew via Tech-talk
- Next:
Re: Retrieving record name from aSub input/output fields Andrew Johnson 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>
2023
2024
2025
|