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  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
<== Date ==> <== Thread ==>

Subject: Re: Combing Two State Sets into One
From: Bradley Pietrzak <[email protected]>
To: "J. Lewis Muir" <[email protected]>
Cc: [email protected]
Date: Thu, 22 Sep 2011 16:59:48 -0400
Hi everybody,

Thank you so much for all of your help. I cannot possibly explain how grateful I am.  I now can successfully use one state set to operate on many different PVs, but I do have one more question.  From outside the ioc, is there any way to determine what the value of mag is? In other words, is there some linux shell command that is equivalent to typing "seq sncExample, "mag=1"" in the epics shell?  My first thought is to have mag=1 when some PV (perhaps one called magSelect) is equal to 1, but I am having trouble doing this.

Thanks,

Brad Pietrzak

On Thu, Sep 22, 2011 at 12:32 PM, J. Lewis Muir <[email protected]> wrote:
On 9/22/11 10:53 AM, Bradley Pietrzak wrote:
> Hello,
>
> The state notation language program shown below runs successfully.
> "magnet1" and "magnet2" are nothing more than simple analog inputs.
> Clearly, state sets one and two are identical, except for the process
> variables on which they operate.  Ultimately, I'd like to combine the two
> state sets into a single state set which can operate on either pv1 or pv2,
> depending on which of the two variables I "pass" into it.  Does the state
> notation compiler allow for such functionality? Any help would be greatly
> appreciated.

Hi, Bradley.

If you don't need the two state sets to interact with one
another, you could just make the SNL program reentrant ('+r' SNL
compiler option) and use an SNL macro and start two instances of
the SNL program.  For example:

 program sncExample

 option +r;

 float pv1;
 assign pv1 to "{MAGNET}";

 ss ss1 {

     state one {
         pv1 = 1;
         pvPut(pv1);
         } state two

     state two {
         pv1 = 2;
         pvPut(pv1);
     } state one
 }

Then start two instances, one with MAGNET=magnet1 and the other
with MAGNET=magnet2.

If you need to do it in one SNL program, you could do something
like: set a PV variable indicating which PV you want to operate
on, and then just use a conditional statement in the next state
to do the pvPut on the correct PV.

Or you could dynamically assign the PV at run-time.  That is, in
the first state, assign the PV to "magnet1" or "magnet2" using
the SNL pvAssign function.  Transition to another state to wait
for it to connect using pvConnected (or perhaps pvAssignCount()
== pvConnectCount()).  Then transition to a third state which
does the pvPut.

A fourth possibility would be to obtain the variable index via
pvIndex for each PV you want to write to.  Then in the first
state, set a variable indicating the target index (i.e. which PV
you want to operate on), and in the second state invoke the
seq_pvPut C function with the target index.

Lewis

--
J. Lewis Muir
Software Engineer
IMCA-CAT


Replies:
Re: Combing Two State Sets into One Eric Norum
Re: Combing Two State Sets into One Ned Arnold
References:
Combing Two State Sets into One Bradley Pietrzak
Re: Combing Two State Sets into One J. Lewis Muir

Navigate by Date:
Prev: Re: Combing Two State Sets into One J. Lewis Muir
Next: Re: Combing Two State Sets into One Eric Norum
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
Navigate by Thread:
Prev: Re: Combing Two State Sets into One J. Lewis Muir
Next: Re: Combing Two State Sets into One Eric Norum
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  <20112012  2013  2014  2015  2016  2017  2018  2019  2020  2021  2022  2023  2024 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· Search · EPICS V4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·