moved include files from base/include
This commit is contained in:
@@ -9,6 +9,11 @@ include $(EPICS)/config/CONFIG_BASE
|
||||
USR_LDLIBS = -ll
|
||||
YACCOPT = -d -v
|
||||
|
||||
INC += seq.h
|
||||
INC += seqCom.h
|
||||
INC += seqU.h
|
||||
INC += seq_taskLib.h
|
||||
|
||||
SRCS.c = ../snc_main.c ../parse.c ../phase2.c ../gen_ss_code.c \
|
||||
../gen_tables.c sncVersion.c snc.c
|
||||
|
||||
|
||||
@@ -0,0 +1,198 @@
|
||||
/* /share/epicsH %W% %G%
|
||||
*
|
||||
* DESCRIPTION: Definitions for the run-time sequencer.
|
||||
*
|
||||
* Author: Andy Kozubal
|
||||
* Date:
|
||||
*
|
||||
* Experimental Physics and Industrial Control System (EPICS)
|
||||
*
|
||||
* Copyright 1991,2,3, the Regents of the University of California,
|
||||
* and the University of Chicago Board of Governors.
|
||||
*
|
||||
* This software was produced under U.S. Government contracts:
|
||||
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
|
||||
* and (W-31-109-ENG-38) at Argonne National Laboratory.
|
||||
*
|
||||
* Initial development by:
|
||||
* The Controls and Automation Group (AT-8)
|
||||
* Ground Test Accelerator
|
||||
* Accelerator Technology Division
|
||||
* Los Alamos National Laboratory
|
||||
*
|
||||
* Co-developed with
|
||||
* The Controls and Computing Group
|
||||
* Accelerator Systems Division
|
||||
* Advanced Photon Source
|
||||
* Argonne National Laboratory
|
||||
*
|
||||
* Modification Log:
|
||||
* -----------------
|
||||
* 07mar91,ajk Changed SSCB semaphore id names.
|
||||
* 05jul91,ajk Added function prototypes.
|
||||
* 16dec91,ajk Setting up for VxWorks version 5.
|
||||
* 27apr92,ajk Changed to new event flag mode (SSCB & PROG changed).
|
||||
* 27apr92,ajk Removed getSemId from CHAN.
|
||||
* 28apr92,ajk Implemented new event flag mode.
|
||||
* 17feb93,ajk Fixed some functions prototypes.
|
||||
* 10jun93,ajk Removed VxWorks V4/V5 conditional compile.
|
||||
* 20jul93,ajk Removed non-ANSI function definitions.
|
||||
* 21mar94,ajk Implemented new i/f with snc (see seqCom.h).
|
||||
* 21mar94,ajk Implemented assignment of array elements to db. Also,
|
||||
allow "unlimited" number of channels.
|
||||
* 28mar94,ajk Added time stamp support.
|
||||
* 29mar94,ajk Added dbOffset in db_channel structure; allows faster processing
|
||||
of values returned with monitors and pvGet().
|
||||
*/
|
||||
#ifndef INCLseqh
|
||||
#define INCLseqh
|
||||
|
||||
#ifndef TRUE
|
||||
#include <ctype.h>
|
||||
#endif
|
||||
|
||||
#include "seqCom.h"
|
||||
|
||||
#ifndef VOID
|
||||
#include "cadef.h"
|
||||
#include "db_access.h"
|
||||
#include "alarm.h"
|
||||
#ifdef vxWorks
|
||||
#include "vxWorks.h"
|
||||
#include "ioLib.h"
|
||||
#include "semLib.h"
|
||||
#include "taskLib.h"
|
||||
#endif /* vxWorks */
|
||||
#endif
|
||||
|
||||
/* Structure to hold information about database channels */
|
||||
struct db_channel
|
||||
{
|
||||
/* These are supplied by SNC */
|
||||
char *dbAsName; /* channel name from assign statement */
|
||||
char *pVar; /* ptr to variable */
|
||||
char *pVarName; /* variable name string */
|
||||
char *pVarType; /* variable type string (e.g. ("int") */
|
||||
int count; /* number of elements in array */
|
||||
int efId; /* event flag id if synced */
|
||||
int eventNum; /* event number */
|
||||
BOOL monFlag; /* TRUE if channel is to be monitored */
|
||||
|
||||
/* These are filled in at run time */
|
||||
char *dbName; /* channel name after macro expansion */
|
||||
int index; /* index in array of db channels */
|
||||
chid chid; /* ptr to channel id (from ca_search()) */
|
||||
BOOL assigned; /* TRUE only if channel is assigned */
|
||||
BOOL connected; /* TRUE only if channel is connected */
|
||||
BOOL getComplete; /* TRUE if previous pvGet completed */
|
||||
short dbOffset; /* Offset to value in db access structure */
|
||||
short status; /* last db access status code */
|
||||
TS_STAMP timeStamp; /* time stamp */
|
||||
int dbCount; /* actual count for db access */
|
||||
short severity; /* last db access severity code */
|
||||
short size; /* size (in bytes) of single variable element */
|
||||
short getType; /* db get type (e.g. DBR_STS_INT) */
|
||||
short putType; /* db put type (e.g. DBR_INT) */
|
||||
BOOL monitored; /* TRUE if channel IS monitored */
|
||||
evid evid; /* event id (supplied by CA) */
|
||||
SEM_ID getSemId; /* semaphore id for async get */
|
||||
struct state_program *sprog; /* state program that owns this structure */
|
||||
};
|
||||
typedef struct db_channel CHAN;
|
||||
|
||||
/* Structure to hold information about a state */
|
||||
struct state_info_block
|
||||
{
|
||||
char *pStateName; /* state name */
|
||||
FUNCPTR actionFunc; /* ptr to action routine for this state */
|
||||
FUNCPTR eventFunc; /* ptr to event routine for this state */
|
||||
FUNCPTR delayFunc; /* ptr to delay setup routine for this state */
|
||||
bitMask *pEventMask; /* event mask for this state */
|
||||
};
|
||||
typedef struct state_info_block STATE;
|
||||
|
||||
#define MAX_NDELAY 20 /* max # delays allowed in each SS */
|
||||
/* Structure to hold information about a State Set */
|
||||
struct state_set_control_block
|
||||
{
|
||||
char *pSSName; /* state set name (for debugging) */
|
||||
int taskId; /* task id */
|
||||
int taskPriority; /* task priority */
|
||||
SEM_ID syncSemId; /* semaphore for event sync */
|
||||
SEM_ID getSemId; /* semaphore for synchronous pvGet() */
|
||||
int numStates; /* number of states */
|
||||
STATE *pStates; /* ptr to array of state blocks */
|
||||
short currentState; /* current state index */
|
||||
short nextState; /* next state index */
|
||||
short prevState; /* previous state index */
|
||||
short errorState; /* error state index (-1 if none defined) */
|
||||
short transNum; /* highest priority trans. # that triggered */
|
||||
bitMask *pMask; /* current event mask */
|
||||
int numDelays; /* number of delays activated */
|
||||
ULONG delay[MAX_NDELAY]; /* queued delay value in tics */
|
||||
BOOL delayExpired[MAX_NDELAY]; /* TRUE if delay expired */
|
||||
ULONG timeEntered; /* time that a state was entered */
|
||||
struct state_program *sprog; /* ptr back to state program block */
|
||||
};
|
||||
typedef struct state_set_control_block SSCB;
|
||||
|
||||
/* Macro table */
|
||||
typedef struct macro {
|
||||
char *pName;
|
||||
char *pValue;
|
||||
} MACRO;
|
||||
|
||||
/* All information about a state program.
|
||||
The address of this structure is passed to the run-time sequencer:
|
||||
*/
|
||||
struct state_program
|
||||
{
|
||||
char *pProgName; /* program name (for debugging) */
|
||||
int taskId; /* task id (main task) */
|
||||
BOOL task_is_deleted;/* TRUE if main task has been deleted */
|
||||
int taskPriority; /* task priority */
|
||||
SEM_ID caSemId; /* semiphore for locking CA events */
|
||||
CHAN *pChan; /* table of channels */
|
||||
int numChans; /* number of db channels, incl. unassigned */
|
||||
int assignCount; /* number of db channels assigned */
|
||||
int connCount; /* number of channels connected */
|
||||
SSCB *pSS; /* array of state set control blocks */
|
||||
int numSS; /* number of state sets */
|
||||
char *pVar; /* ptr to user variable area */
|
||||
int varSize; /* # bytes in user variable area */
|
||||
MACRO *pMacros; /* ptr to macro table */
|
||||
char *pParams; /* program paramters */
|
||||
bitMask *pEvents; /* event bits for event flags & db */
|
||||
int numEvents; /* number of events */
|
||||
int options; /* options (bit-encoded) */
|
||||
FUNCPTR exitFunc; /* exit function */
|
||||
SEM_ID logSemId; /* logfile locking semaphore */
|
||||
int logFd; /* logfile file descr. */
|
||||
};
|
||||
typedef struct state_program SPROG;
|
||||
|
||||
#define MAX_MACROS 50
|
||||
|
||||
/* Task parameters */
|
||||
#define SPAWN_STACK_SIZE 10000
|
||||
#define SPAWN_OPTIONS VX_DEALLOC_STACK | VX_FP_TASK | VX_STDIO
|
||||
#define SPAWN_PRIORITY 100
|
||||
|
||||
/* Function declarations for internal sequencer funtions */
|
||||
int seqConnect(SPROG *);
|
||||
VOID seqEventHandler(struct event_handler_args);
|
||||
VOID seqConnHandler(struct connection_handler_args);
|
||||
VOID seqCallbackHandler(struct event_handler_args);
|
||||
VOID seqWakeup(SPROG *, int);
|
||||
int seq(struct seqProgram *, char *, int);
|
||||
VOID seqFree(SPROG *);
|
||||
int sequencer(SPROG *, int, char *);
|
||||
VOID ssEntry(SPROG *, SSCB *);
|
||||
int sprogDelete(int);
|
||||
int seqMacParse(char *, SPROG *);
|
||||
char *seqMacValGet(MACRO *, char *);
|
||||
VOID seqMacEval(char *, char *, int, MACRO *);
|
||||
STATUS seq_log();
|
||||
SPROG *seqFindProg(int);
|
||||
|
||||
#endif /* INCLseqh */
|
||||
@@ -0,0 +1,150 @@
|
||||
/* * base/include seqCom.h,v 1.3 1995/10/10 01:25:08 wright Exp
|
||||
*
|
||||
* DESCRIPTION: Common definitions for state programs and run-time sequencer.
|
||||
*
|
||||
* Author: Andy Kozubal
|
||||
* Date: 01mar94
|
||||
*
|
||||
* Experimental Physics and Industrial Control System (EPICS)
|
||||
*
|
||||
* Copyright 1993 the Regents of the University of California,
|
||||
* and the University of Chicago Board of Governors.
|
||||
*
|
||||
* This software was produced under U.S. Government contracts:
|
||||
* (W-7405-ENG-36) at the Los Alamos National Laboratory,
|
||||
* and (W-31-109-ENG-38) at Argonne National Laboratory.
|
||||
*
|
||||
* Initial development by:
|
||||
* The Controls and Automation Group (AT-8)
|
||||
* Ground Test Accelerator
|
||||
* Accelerator Technology Division
|
||||
* Los Alamos National Laboratory
|
||||
* Modification Log:
|
||||
* -----------------
|
||||
*
|
||||
*/
|
||||
#ifndef INCLseqComh
|
||||
#define INCLseqComh
|
||||
|
||||
#define MAGIC 940501 /* current magic number for SPROG */
|
||||
|
||||
#include "tsDefs.h" /* time stamp defs */
|
||||
|
||||
/* Bit encoding for run-time options */
|
||||
#define OPT_DEBUG (1<<0) /* turn on debugging */
|
||||
#define OPT_ASYNC (1<<1) /* use async. gets */
|
||||
#define OPT_CONN (1<<2) /* wait for all connections */
|
||||
#define OPT_REENT (1<<3) /* generate reentrant code */
|
||||
#define OPT_NEWEF (1<<4) /* new event flag mode */
|
||||
#define OPT_TIME (1<<5) /* get time stamps */
|
||||
#define OPT_VXWORKS (1<<6) /* include VxWorks files */
|
||||
|
||||
/* Macros to handle set & clear event bits */
|
||||
#define NBITS 32 /* # bits in bitMask word */
|
||||
typedef long bitMask;
|
||||
|
||||
#define bitSet(word, bitnum) (word[(bitnum)/NBITS] |= (1<<((bitnum)%NBITS)))
|
||||
#define bitClear(word, bitnum) (word[(bitnum)/NBITS] &= ~(1<<((bitnum)%NBITS)))
|
||||
#define bitTest(word, bitnum) ((word[(bitnum)/NBITS] & (1<<((bitnum)%NBITS))) != 0)
|
||||
|
||||
#ifndef TRUE
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
#endif /* TRUE */
|
||||
|
||||
typedef int (*PFUNC)(); /* ptr to a function */
|
||||
typedef long SS_ID; /* state set id */
|
||||
|
||||
#ifdef OFFSET
|
||||
#undef OFFSET
|
||||
#endif
|
||||
/* The OFFSET macro calculates the byte offset of a structure member
|
||||
* from the start of a structure */
|
||||
#define OFFSET(structure, member) ((int) &(((structure *) 0) -> member))
|
||||
|
||||
/* Structure to hold information about database channels */
|
||||
struct seqChan
|
||||
{
|
||||
char *dbAsName; /* assigned channel name */
|
||||
void *pVar; /* ptr to variable (-r option)
|
||||
* or structure offset (+r option) */
|
||||
char *pVarName; /* variable name, including subscripts */
|
||||
char *pVarType; /* variable type, e.g. "int" */
|
||||
int count; /* element count for arrays */
|
||||
int eventNum; /* event number for this channel */
|
||||
int efId; /* event flag id if synced */
|
||||
int monFlag; /* TRUE if channel is to be monitored */
|
||||
};
|
||||
|
||||
/* Structure to hold information about a state */
|
||||
struct seqState
|
||||
{
|
||||
char *pStateName; /* state name */
|
||||
PFUNC actionFunc; /* action routine for this state */
|
||||
PFUNC eventFunc; /* event routine for this state */
|
||||
PFUNC delayFunc; /* delay setup routine for this state */
|
||||
bitMask *pEventMask; /* event mask for this state */
|
||||
};
|
||||
|
||||
/* Structure to hold information about a State Set */
|
||||
struct seqSS
|
||||
{
|
||||
char *pSSName; /* state set name */
|
||||
struct seqState *pStates; /* array of state blocks */
|
||||
int numStates; /* number of states in this state set */
|
||||
int errorState; /* error state index (-1 if none defined) */
|
||||
};
|
||||
|
||||
/* All information about a state program */
|
||||
struct seqProgram
|
||||
{
|
||||
int magic; /* magic number */
|
||||
char *pProgName; /* program name (for debugging) */
|
||||
struct seqChan *pChan; /* table of channels */
|
||||
int numChans; /* number of db channels */
|
||||
struct seqSS *pSS; /* array of state set info structs */
|
||||
int numSS; /* number of state sets */
|
||||
int varSize; /* # bytes in user variable area */
|
||||
char *pParams; /* program paramters */
|
||||
int numEvents; /* number of event flags */
|
||||
int options; /* options (bit-encoded) */
|
||||
PFUNC exitFunc; /* exit function */
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Function declarations for interface between state program & sequencer.
|
||||
* Notes:
|
||||
* "seq_" is added by SNC to guarantee global uniqueness.
|
||||
* These functions appear in the module seq_if.c.
|
||||
* The SNC must generate these modules--see gen_ss_code.c.
|
||||
*/
|
||||
/*#define ANSI*/
|
||||
#ifdef ANSI
|
||||
void seq_efSet(SS_ID, int); /* set an event flag */
|
||||
int seq_efTest(SS_ID, int); /* test an event flag */
|
||||
int seq_efClear(SS_ID, int); /* clear an event flag */
|
||||
int seq_efTestAndClear(SS_ID, int); /* test & clear an event flag */
|
||||
int seq_pvGet(SS_ID, int); /* get pv value */
|
||||
int seq_pvPut(SS_ID, int); /* put pv value */
|
||||
TS_STAMP seq_pvTimeStamp(SS_ID, int); /* get time stamp value */
|
||||
int seq_pvAssign(SS_ID, int, char *);/* assign/connect to a pv */
|
||||
int seq_pvMonitor(SS_ID, int); /* enable monitoring on pv */
|
||||
int seq_pvStopMonitor(SS_ID, int); /* disable monitoring on pv */
|
||||
int seq_pvStatus(SS_ID, int); /* returns pv alarm status code */
|
||||
int seq_pvSeverity(SS_ID, int); /* returns pv alarm severity */
|
||||
int seq_pvAssigned(SS_ID, int); /* returns TRUE if assigned */
|
||||
int seq_pvConnected(SS_ID, int); /* TRUE if connected */
|
||||
int seq_pvGetComplete(SS_ID, int); /* TRUE if last get completed */
|
||||
int seq_pvChannelCount(SS_ID); /* returns number of channels */
|
||||
int seq_pvConnectCount(SS_ID); /* returns number of channels connected */
|
||||
int seq_pvAssignCount(SS_ID); /* returns number of channels assigned */
|
||||
int seq_pvCount(SS_ID, int); /* returns number of elements in array */
|
||||
void seq_pvFlush(); /* flush put/get requests */
|
||||
int seq_pvIndex(SS_ID, int); /* returns index of pv */
|
||||
int seq_seqLog(); /* Logging: variable number of parameters */
|
||||
void seq_delayInit(SS_ID, int, float);/* initialize a delay entry */
|
||||
int seq_delay(SS_ID, int); /* test a delay entry */
|
||||
char *seq_macValueGet(SS_ID, char *); /* Given macro name, return ptr to value */
|
||||
#endif /* ANSI */
|
||||
#endif /* INCLseqComh */
|
||||
@@ -0,0 +1,13 @@
|
||||
/* $Id$ */
|
||||
typedef long bitMask;
|
||||
#define bitSet(word, bitnum) (word[bitnum/NBITS] |= (1<<(bitnum%NBITS)))
|
||||
#define NBITS 32 /* # bits in bit mask word */
|
||||
#define NWRDS 8 /* # words in bit fields */
|
||||
#define MAGIC 920505 /* magic number for SPROG */
|
||||
/* Bit encoding for run-time options */
|
||||
#define OPT_DEBUG (1<<0)
|
||||
#define OPT_ASYNC (1<<1)
|
||||
#define OPT_CONN (1<<2)
|
||||
#define OPT_REENT (1<<3)
|
||||
#define OPT_NEWEF (1<<4)
|
||||
#define MAX_NDELAY 20 /* max # delays allowed in each SS */
|
||||
@@ -0,0 +1,93 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
#ifdef DECTHREAD
|
||||
#include <pthread.h>
|
||||
#include <timers.h>
|
||||
#endif
|
||||
#ifdef FSUTHREAD
|
||||
#include "pthread/pthread.h"
|
||||
#endif
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <errno.h>
|
||||
#include <setjmp.h>
|
||||
#include <stdio.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#define GLOBALLOCK \
|
||||
{\
|
||||
pthread_lock_global_np(); \
|
||||
}
|
||||
|
||||
#define GLOBALUNLOCK \
|
||||
{\
|
||||
pthread_unlock_global_np(); \
|
||||
}
|
||||
|
||||
|
||||
#define FASTLOCKINIT(PFAST_LOCK) \
|
||||
{\
|
||||
mutex_init(PFAST_LOCK,0,NULL); \
|
||||
}
|
||||
|
||||
#define FASTLOCKFREE(PFAST_LOCK) \
|
||||
{\
|
||||
pthread_mutex_destroy(PFAST_LOCK); \
|
||||
}
|
||||
|
||||
#define FASTLOCK(PFAST_LOCK) \
|
||||
{\
|
||||
mutex_enter( (PFAST_LOCK)); \
|
||||
}
|
||||
|
||||
#define FASTUNLOCK(PFAST_LOCK) \
|
||||
{\
|
||||
mutex_exit( (PFAST_LOCK)); \
|
||||
}
|
||||
|
||||
#define FASTLOCKNOWAIT(PFAST_LOCK) \
|
||||
{\
|
||||
mutex_tryenter( (PFAST_LOCK)); \
|
||||
}
|
||||
|
||||
/* #define DEBUG */
|
||||
|
||||
#define THDNUM 100
|
||||
|
||||
#define ST_INIT 0
|
||||
#define ST_LOCKED 1
|
||||
#define ST_RUNNING 2
|
||||
#define ST_SUSPEND 3
|
||||
#define ST_CANCELED 4
|
||||
|
||||
/*char *st_status[] = {
|
||||
"INIT",
|
||||
"LOCKED",
|
||||
"RUNNING",
|
||||
"SUSPENDED",
|
||||
"CANCELED"};
|
||||
*/
|
||||
|
||||
/* DEC/POSIX type to FSU POSIX type*/
|
||||
#ifdef FSUTHREAD
|
||||
#define pthread_startroutine_t pthread_func_t
|
||||
#define pthread_addr_t any_t
|
||||
#endif
|
||||
|
||||
/* Sun Solaris 5.0 using DEC/ POSIX */
|
||||
#define thread_id_t pthread_t
|
||||
#define mutex_t pthread_mutex_t
|
||||
#define condvar_t pthread_cond_t
|
||||
|
||||
#define STATUS int
|
||||
|
||||
#define PROMPT "Seq> " /* prompt string */
|
||||
#define MAXLINSIZE 81 /* command line width */
|
||||
|
||||
#define check(status,string) if(status == -1)perror(string)
|
||||
|
||||
#define FAST_LOCK pthread_mutex_t /* fastlock for pthread_mutex_t */
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user