Hi- I can think of at least two ways of doing what you want; one a standard feature of SNL, and the
other a "weird trick".
#1: Use "pvAssign" in a loop, with generated PV names (as shown below):
https://www-csr.bessy.de/control/SoftDist/sequencer/search.html?q=pvassign
#2: Dynamic arg string: if the macro names and values are easily generated as suggested in
the original post, you could write a separate SNL wrapper program which builds the arg string
at runtime and then calls your program with it, for example (macro & variable declarations
omitted):
program run_myExample ( ... meta-macros? ... )
ss run_myExample
{
state doit {
when (1) {
%% extern struct seqProgram seqmyExample; // ref to your SNL program
%% static char args[ ARGBUF_SIZE ]; // arg buffer: should be large enough to hold
// full final string
args[0] = '\0';
for ( n = 1; n <= N; n++ ) { // append macros for devices 1..N
%% sprintf(
%% &args[ strlen(args) ],
%% "%smacro%d=MyExp:MyDevice-%02d:Unit",
%% (n > 0)? "," : "",
%% n,n );
}
%% seq( & seqmyExample, args, STACK_SIZE ); // start your main SNL program; seq is
// just another function, after all
} state done
}
state done {
when (delay(999999)) {} state done // delay forever (or maybe exit?)
}
}
Then in the startup script just run "seq &run_myExample" instead of the original. You could also add
macros to the wrapper to generate different PV names, as you suggest.
Example compiles but not tested, but I use basically this method to start a variable number of per-device
seq threads based on the runtime contents of in-memory EPICS DBs.
cheers
Mike
https://www.psi.ch
From:
[email protected] <[email protected]>
On Behalf Of GAGET Alexis via Tech-talk
Sent: Montag, 15. April 2019 17:22
Subject: [SNL] possibility to cut the argument string.
Dear All,
I have a SNL sequence with a lot of macro, i find the call in the iocshell really not readable
i.e :
seq myExample “macro1=MyExp:MyDevice-01:Unit, macro2=MyExp:MyDevice-02:Unit, macro3=MyExp:MyDevice-03:Unit, macro4=MyExp:MyDevice-04:Unit….To infinity and beyond”
Is there any way to maybe cut the string ?
i.e :
seq myExample “macro1=MyExp:MyDevice-01:Unit”+
“macro1=MyExp:MyDevice-02:Unit”+
“macro2=MyExp:MyDevice-03:Unit”+
“ macro3=MyExp:MyDevice-04:Unit”+
“….To infinity and beyond”
(of course it doesn’t work, I’ve tried different possibility but I haven’t found… maybe it’s obvious
I want my sequence as much generic as possible, so substitutions macros offers a good possibility to call differents PVs.
If it’s not possible yet, is it possible to maybe create an issue somewhere to ask the feature ?
Thanks for your help.
...
Alexis GAGET
CEA Saclay - DRF/Irfu/DIS/LDISC
[email protected]