g+
g+ Communities
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  <20122013  2014  Index 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014 
<== Date ==> <== Thread ==>

Subject: RE: structs and SNL
From: Mark Rivers <rivers@cars.uchicago.edu>
To: "'Pierrick Hanlet'" <hanlet@fnal.gov>
Cc: "tech-talk@aps.anl.gov" <tech-talk@aps.anl.gov>
Date: Thu, 20 Dec 2012 21:51:14 +0000
> Does your response mean that I can then simply extract the value
> of myVar from which was filled in my function and called from
> the SNL code by:  PV->myVar?  If so, I still have a problem.

The fact that the name myVar is the same in the SNL and the struct is not relevant, they are different things.

Your C code would need to copy the value from the struct to the float myVar.

    pVar->myVar = PV.myVar;

If you want to look at an example which uses escaped C functions and the pVar pointer look at

motor/motorApp/NewportSrc/XPS_trajectoryScan.st in the synApps "motor" module:

http://www.aps.anl.gov/bcda/synApps/motor/

Cheers,
Mark



From: Pierrick Hanlet [mailto:hanlet@fnal.gov] 
Sent: Thursday, December 20, 2012 3:29 PM
To: Mark Rivers
Cc: 'Zelazny, Michael Stanley'; tech-talk@aps.anl.gov
Subject: Re: structs and SNL

Hi all,
Thanks for the help.  I'm still confused, however.
I have the struct defined in a header file which I do have escaped:
%%#include "MICEStates.h"
The name of the struct is PV.

I then define the same variables in my SNL code
float myVar   (also in the struct).

I have a C function which uses the same header file and and fills the
variables in the struct.  This code I successfully build into the SNL
code.

Does your response mean that I can then simply extract the value
of myVar from which was filled in my function and called from
the SNL code by:  PV->myVar?  If so, I still have a problem.

The documentation states:
The sequencer allocates the structure area at run time and passes a pointer
to this structure into the program.  The structure has the following type:
struct UserVar *pVar;

Sorry if I'm slow on understanding.
Pierrick


On 12/20/2012 02:14 PM, Mark Rivers wrote: 
You must escape declarations of variables with types like struct, they are not known types to SNL.

Mark


-----Original Message-----
From: tech-talk-bounces@aps.anl.gov [mailto:tech-talk-bounces@aps.anl.gov] On Behalf Of Zelazny, Michael Stanley
Sent: Thursday, December 20, 2012 11:22 AM
To: Pierrick Hanlet
Cc: tech-talk@aps.anl.gov
Subject: RE: structs and SNL

If you "escape to C" the .h with "%%" then you'll have to do the same with your struct declaration.

cc-ing tech-talk for further comments from others.
________________________________________
From: Pierrick Hanlet [hanlet@fnal.gov]
Sent: Thursday, December 20, 2012 6:07 AM
To: Zelazny, Michael Stanley
Subject: structs and SNL

Hi Michael,
I think that I understand reentrant to mean (in part) that variables in SNL and C-code
can be related.  Assuming that is true, then I'm attempting to implement the section
"Variable Modification for Reentrant Option".  My C code reads our database and I
would like to use some of the variables from there in an entry block of a particular
state.

So, in the top-level declarations I define a number a variables which have the same
declaration as those in a struct in a header which I include in the top-level with %%
escape:

option +r;

%%#include "MICEStates.h"

char name[50];
...

If I understand the documentation, I should be able to do:
struct PV *cPV;
where PV is the name of my struct in the header file (I also tried UserVar, as
in the example).  However, at compile time, I get the error "type specifier".
This error follows the "struct" statement wherever I put it in the code.

Can you tell me what I'm doing incorrectly?
Thank you.
Pierrick--
"Whether you think you can or think you can't, either way, you are correct" -- Henry Ford
_______________________________________________________________
Pierrick Hanlet
IIT/Fermilab
+1-630-840-5555 (FNAL)
+1-312-567-5745 (IIT)
+1-630-697-8758/+44-79-48-860-197 (US/UK mobile)


-- 
"Whether you think you can or think you can't, either way, you are correct" -- Henry Ford
_______________________________________________________________
Pierrick Hanlet
IIT/Fermilab
+1-630-840-5555 (FNAL)
+1-312-567-5745 (IIT)
+1-630-697-8758/+44-79-48-860-197 (US/UK mobile)


References:
SNL with C Pierrick M Hanlet
RE: SNL with C Zelazny, Michael Stanley
Re: SNL with C Pierrick Hanlet
RE: SNL with C Zelazny, Michael Stanley
RE: structs and SNL Zelazny, Michael Stanley
RE: structs and SNL Mark Rivers
Re: structs and SNL Pierrick Hanlet

Navigate by Date:
Prev: Re: structs and SNL Pierrick Hanlet
Next: CSS XY Graph Pause John Dobbins
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014 
Navigate by Thread:
Prev: Re: structs and SNL Pierrick Hanlet
Next: RE: SNL with C Mark Rivers
Index: 1994  1995  1996  1997  1998  1999  2000  2001  2002  2003  2004  2005  2006  2007  2008  2009  2010  2011  <20122013  2014 
ANJ, 18 Nov 2013 Valid HTML 4.01! · Home · News · About · Base · Modules · Extensions · Distributions · Download ·
· EPICSv4 · IRMIS · Talk · Bugs · Documents · Links · Licensing ·