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: Ned Arnold <[email protected]>
Cc: [email protected]
Date: Mon, 26 Sep 2011 17:39:09 -0400
Thank you again for your responses.  Unfortunately, I have encountered another problem, this time involving code that has been escaped to C.  The new version of my program is shown below.  Without the re-entrant option, the code runs perfectly fine.  With the re-entrant option, however, I am met with several errors. The SNL user's manual says that the SNC automatically refers to variables in the struct UserVar by running the code " pVar->xxx", but that such references have to be handled manually for escaped C code. How do I handle such situations manually?

/* Sample Program */
program sncExample

option +r; /* reentrant */

float i;

float pv;
assign pv to "testioc:magnet{mag}";

%{

    void helloWorld(i) {
        printf("Hello World! You have just called a C function, and the variable i is %5.1f \n", i);
    }

}%

ss ss1 {

   state one {
       when() {
       i = 1;
       %% helloWorld(i);
       pv = 1;
       pvPut(pv);
       sleep(1);
       } state two
   }

   state two {
       when () {
       i = 2;
       %% helloWorld(i);
       pv = 2;
       pvPut(pv);
       sleep(1);
       } state one
   }

}


Thanks,

Brad Pietrzak

On Thu, Sep 22, 2011 at 6:02 PM, Ned Arnold <[email protected]> wrote:
>>From outside the ioc, is there any way to determine what the value of mag is?

You could have the sequence program pvPut() the PV name to a string record which could then be observed with any channel access client (camonitor, edm, BOY).  This is also a common debugging tool for sequence programs ... writing messages to the user.


>>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.

You would probably use an MBBO record which gives a menu of up to 16 strings and provides an index (0-15) for the one selected. The sequence program would get the index to the selection and determine the appropriate PV.

  Ned



From: "Bradley Pietrzak" <[email protected]>
To: "J. Lewis Muir" <[email protected]>
Cc: [email protected]
Sent: Thursday, September 22, 2011 3:59:48 PM
Subject: Re: Combing Two State Sets into One


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 J. Lewis Muir
References:
Re: Combing Two State Sets into One Bradley Pietrzak
Re: Combing Two State Sets into One Ned Arnold

Navigate by Date:
Prev: devLib2 release 2.2 Michael Davidsaver
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 Ned Arnold
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 ·