Experimental Physics and Industrial Control System
Hi
At the Keck observatory, most of our sequencers call 'C' functions (hmmm
these are sequencers running on vxWorks with EPICS 3.13.10). Seems to me
it is just a matter of linking and loading.
What you proposed should be functional except, I think, the static for
the softCheck function may be a problem as it will exist in a C source
file separate from the SNL file and may not be resolved correctly (you
might have to experiment).
--------You can include C like this:
%%#include <string.h>
%%#ifdef vxWorks
%%int strcasecmp( char *s1, char *s2 );
%%int strncasecmp( char *s1, char *s2, int n );
%%#endif /* Taken from etcLib for vxWorks */
%%#include <epicsPrint.h>
%%#include "knlConst.h" /* for USE() macro (need ANSI pre-processor) */
%%RCSID( "$Id" );
/* avoids "not used" warning */
%%RCSID( "$Id" );
---------Both of the following when clauses make calls to C functions:
/*
* INIT_START state. Check instrument and focal station are
achievable
* and identify needed subsystems
*/
state INIT_START {
/*
* Determine whether the instrument and focal station are
* achievable in the current hardware configuration. If not,
* and if BYPASS is not active, enter INIT_FAIL state (so
* BYPASS ignores "not achievable" errors)
*/
when ( !efTest( bypassFlag ) && !tcsInstrumentAchievable(
tel, /* telescope name */
secModuleId, /* secondary module */
casModuleId, /* cassegrain module */
fwdModuleId, /* forward cass module
*/
instrument, /* instrument */
focalstation ) ) { /* focal station */
LOGMSG( LOG_MAIN, "tcsMain: INIT_START -> STANDBY
[achievable?]\n");
SETSTAT( "STBY", S_stby, S_knl_fault, "wrong config for
instr" );
efClear( readConfigFlag );
/* pretend never initialized so bypass will start from
scratch */
alreadyInit = FALSE;
} state INIT_FAIL
/*
* Otherwise, determine which subsystems are needed for the
* instrument and focal station. If there's a problem,
* enter INIT_FAIL state
*/
when ( ( nSubsys = tcsSubsystemsNeeded(
secModuleId, /* secondary module */
casModuleId, /* cassegrain module */
fwdModuleId, /* forward cass module
*/
instrument, /* instrument */
focalstation, /* focal station */
MAXSUBSYS, /* max #subsystems */
tcsNeeded ) ) < 0 ) { /* "needed" array */
LOGMSG( LOG_MAIN, "tcsMain: INIT_START -> STANDBY
[needed?]\n" );
SETSTAT( "STBY", S_stby, S_knl_fault, "can't determine
subsystems");
} state INIT_FAIL
--------Also note: that If I need an 'if clause' to allow a change to a
different state that I typically use an intermediate state and an event
flag. So from state A each of the when clauses will branch to state B
but if a special condition needs to be trapped in state A then I set an
event flag in the pertinent 'when' clause of state A. Within state B,
that event flag will be captured and cause an appropriate action or a
branch to fault state D, all other 'when' clauses in state B (perhaps
just default behavior) will branch to state C (non-faulted state).
Perhaps, a little cumbersome/obtuse but serviceable.
State A {
when ( acceleration < -3.0 ) {
if ( passenger_weight > 15.0 ) efSet( deployPassAirBag );
} state B
}
State B {
when (efTestandClear(deployPassAirBag) ) { popPassAirBag(); }
state C
when () {} state C
}
State C {
when () {
if ( driver_weight > 15.0 ) popDriverAirBag();
} state accident
}
--------With any luck, that will save your beer, if it is sitting on the
seat when someone backs into you while you are carrying your groceries
into the house.
Okay, that was a bit contrived and there is a better way of doing it
but, hopefully, you get the idea.
Happy New Year,
AH
-----Original Message-----
From: Dennis Nicklaus [mailto:[email protected]]
Sent: Wednesday, January 03, 2007 7:19 AM
To: [email protected]
Subject: C function in when() clause of sequencer
Hi,
Is it possible to call a C function to avoid having a very cumbersome
when clause in my epics
sequencer program? I get some compiler error or other when I try
different variations,
so I'm hoping someone can tell me the best way to handle this.
What I want is instead of this:
when ((vacuumReading >vacuum_high) ||(tempReading >tempCerm_high)
||(eminusReading >electron_high) ||(pmtReading
>pmtlight_high))
{
} state backOff
I would like to do this:
%{
/*
This function checks for exceeding any of the soft limits.
*/
static int softCheck()
{
return(
(vacuumReading >vacuum_high)
||(tempReading >tempCerm_high)
||(eminusReading >electron_high)
||(pmtReading >pmtlight_high)
);
}
}%
...
when (softCheck())
} state backOff
Thanks,
Dennis
- Replies:
- RE: C function in when() clause of sequencer Laznovsky, Michael
- References:
- C function in when() clause of sequencer Dennis Nicklaus
- Navigate by Date:
- Prev:
Re: C function in when() clause of sequencer Eric Norum
- Next:
RE: C function in when() clause of sequencer Laznovsky, Michael
- 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
2020
2021
2022
2023
2024
- Navigate by Thread:
- Prev:
Re: C function in when() clause of sequencer Eric Norum
- Next:
RE: C function in when() clause of sequencer Laznovsky, Michael
- 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
2020
2021
2022
2023
2024