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  <20202021  2022  2023  2024  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  <20202021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Splitting a string in a protocol file
From: Michael Davidsaver via Tech-talk <tech-talk at aps.anl.gov>
To: "Wang, Andrew" <wang126 at llnl.gov>
Cc: "tech-talk at aps.anl.gov" <tech-talk at aps.anl.gov>
Date: Thu, 17 Dec 2020 12:47:25 -0800
On 12/17/20 11:47 AM, Wang, Andrew via Tech-talk wrote:
> Hi,
> 
>  
> 
> I’m relatively new to EPICS and I have been tasked with writing drivers for a Keysight oscilloscope. One of the commands that I need to set up is the following:
> 
>  
> 
> :CHANnel<N>:SCALe
> 
>  
> 
> This command requires a channel number and a value. So if I wanted to set the vertical scale of Channel 2 to 50 V, I would do
> 
>  
> 
> :CHANnel2:SCALe 50
> 
>  
> 
> I would like to work on both my protocol file and database file, but I am not sure how to go about it. This is what I currently have.
> 
>  
> 
> record(aao, "set_vert_scale")
> 
> {
> 
>               field(DESC, "Set vertical scale for a channel")
> 
>               field(DTYP, "stream")
> 
>               field(FTVL, "STRING")
> 
>               field(OUT, "@keysightOsc.proto setVertScale $(PORT)")
> 
> }
> 
>  
> 
> setVertScale
> 
> {
> 
>               separator = “,”
> 
>               out "%s:SCALe ";
> 
> }
> 
>  
> 
> My goal is for the user to enter a command such as caput set_vert_scale CHAN1,5 so that the string can be split in a manner such that CHAN1 and 5 can be concatenated to the beginning and end of :SCALe.

The usual practice would be for these two logically independent settings
to be made through two different PVs.

eg.

> record(ao, "$(P)Ch$(N):VScale")
> {
>               field(DTYP, "stream")
>               field(OUT, "@keysightOsc.proto setVertScale($N)) $(PORT)")
> }

> setVertScale
> {
>     out ":CHAN\$1:SCAL %f";
> }

This fits nicely with a streamdevice feature to pass parameters
to protocols.  So "\$1" in the .proto file would expand to the value of "$(N)"
from the .db file.  This also lets you load the .db file repeatably
for each channel.

dbLoadRecord("mydigcommon.db", "P=someprefix,PORT=theport")
dbLoadRecord("mydigchan.db", "P=someprefix,PORT=theport,N=1")
dbLoadRecord("mydigchan.db", "P=someprefix,PORT=theport,N=2")
...

References:
Splitting a string in a protocol file Wang, Andrew via Tech-talk

Navigate by Date:
Prev: Re: Splitting a string in a protocol file Johnson, Andrew N. via Tech-talk
Next: Re: Intended use of NTMultiChannel Paduan Donadio, Marcio 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  <20202021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Splitting a string in a protocol file Johnson, Andrew N. via Tech-talk
Next: puzzle running softIocPVA Rolf Keitel 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  <20202021  2022  2023  2024 
ANJ, 19 Dec 2020 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·