- Adapted indenation to new agreed upon system
- Fixed bad status in poldi zug driver
This commit is contained in:
166
pardef.h
166
pardef.h
@ -21,17 +21,17 @@ typedef struct ParInfo {
|
||||
struct ParInfo *next;
|
||||
char *name;
|
||||
Logger *log;
|
||||
int saveIt; /* bool */
|
||||
int saveLog; /* bool */
|
||||
ReadyState state; /* enum ReadyState */
|
||||
int sugarStatus; /* =1: sugar object made */
|
||||
int saveIt; /* bool */
|
||||
int saveLog; /* bool */
|
||||
ReadyState state; /* enum ReadyState */
|
||||
int sugarStatus; /* =1: sugar object made */
|
||||
} ParInfo;
|
||||
|
||||
#define PAR_LEVELS 8
|
||||
#define PAR_NAN -999999.
|
||||
#define PAR_LNAN -999999
|
||||
|
||||
typedef void (*ParDef)(void *);
|
||||
typedef void (*ParDef) (void *);
|
||||
|
||||
typedef struct ParClass {
|
||||
char *name;
|
||||
@ -41,18 +41,18 @@ typedef struct ParClass {
|
||||
} ParClass;
|
||||
|
||||
typedef struct ParData {
|
||||
pObjectDescriptor desc; /* SICS object descriptor */
|
||||
ParClass *class; /* class descriptor */
|
||||
pObjectDescriptor desc; /* SICS object descriptor */
|
||||
ParClass *class; /* class descriptor */
|
||||
ParDef pardef;
|
||||
char *creationCmd; /* the command to create this object */
|
||||
char *name; /* object name */
|
||||
time_t logTime; /* last logging time */
|
||||
char *creationCmd; /* the command to create this object */
|
||||
char *name; /* object name */
|
||||
time_t logTime; /* last logging time */
|
||||
int logPending;
|
||||
int period; /* logging interval */
|
||||
ParInfo *infoList; /* list for additional info on parameters */
|
||||
pICallBack pCall; /* sics callback function */
|
||||
SConnection *conn; /* last connection with user or manager priv. */
|
||||
int verbose; /* verbosity, mainly for tests */
|
||||
int period; /* logging interval */
|
||||
ParInfo *infoList; /* list for additional info on parameters */
|
||||
pICallBack pCall; /* sics callback function */
|
||||
SConnection *conn; /* last connection with user or manager priv. */
|
||||
int verbose; /* verbosity, mainly for tests */
|
||||
} ParData;
|
||||
|
||||
/*
|
||||
@ -117,39 +117,40 @@ typedef struct ParData {
|
||||
to make its contents valid whenever they are used.
|
||||
|
||||
*/
|
||||
void ParName(char *name); /* name must not change during lifetime of the object,
|
||||
normally it is a constant */
|
||||
void ParName(char *name); /* name must not change during lifetime of the object,
|
||||
normally it is a constant */
|
||||
/*
|
||||
Options (to be called before parameter type definitions):
|
||||
*/
|
||||
void ParFmt(char *fmt); /* format (float only) */
|
||||
void ParAccess(int access); /* access rights (default usInternal = read only) */
|
||||
void ParSave(int save); /* save on status file (0: do not svae, 1: save, 2: saved by driver
|
||||
(default: 0 for ParAccess(usInternal), 1 for others) */
|
||||
void ParEnum(char *list[]); /* automatic keyword to number conversion */
|
||||
void ParList(char *group); /* ParList may be repeated with several group arguments,
|
||||
to appear on a list <group> subcommand. Give NULL
|
||||
for std list. */
|
||||
void ParTail(char *tail); /* comment to appear after list entry (e.g. units).
|
||||
If ParList is not called, ParTail will force to appear
|
||||
in standard list. */
|
||||
void ParLogAs(char *name); /* switch log on and give sugar name (NULL for no logging) */
|
||||
void ParFmt(char *fmt); /* format (float only) */
|
||||
void ParAccess(int access); /* access rights (default usInternal = read only) */
|
||||
void ParSave(int save); /* save on status file (0: do not svae, 1: save, 2: saved by driver
|
||||
(default: 0 for ParAccess(usInternal), 1 for others) */
|
||||
void ParEnum(char *list[]); /* automatic keyword to number conversion */
|
||||
void ParList(char *group); /* ParList may be repeated with several group arguments,
|
||||
to appear on a list <group> subcommand. Give NULL
|
||||
for std list. */
|
||||
void ParTail(char *tail); /* comment to appear after list entry (e.g. units).
|
||||
If ParList is not called, ParTail will force to appear
|
||||
in standard list. */
|
||||
void ParLogAs(char *name); /* switch log on and give sugar name (NULL for no logging) */
|
||||
|
||||
/*
|
||||
Parameter type definitions:
|
||||
select one out of these per parameter, with
|
||||
a pointer to the corresponding object member as argument
|
||||
*/
|
||||
void ParFloat(float *value, float defValue);
|
||||
void ParInt(int *value, int defValue);
|
||||
void ParFixedStr(char *value, int maxsize, char *defValue); /* fixed size string */
|
||||
void ParStr(char **value, char *defValue); /* dynamic string */
|
||||
void ParFloat(float *value, float defValue);
|
||||
void ParInt(int *value, int defValue);
|
||||
void ParFixedStr(char *value, int maxsize, char *defValue); /* fixed size string */
|
||||
void ParStr(char **value, char *defValue); /* dynamic string */
|
||||
|
||||
typedef int (*ParCommand)(void *object, void *userarg, int argc, char *argv[]);
|
||||
typedef int (*ParCommand) (void *object, void *userarg, int argc,
|
||||
char *argv[]);
|
||||
/* command function to be executed */
|
||||
int ParCmd(ParCommand cmd, void *userarg); /* command, returns 0 when not executed
|
||||
else return value from cmd, default access
|
||||
is usUser */
|
||||
int ParCmd(ParCommand cmd, void *userarg); /* command, returns 0 when not executed
|
||||
else return value from cmd, default access
|
||||
is usUser */
|
||||
/*
|
||||
If code has to be executed for a specific to a parameter and and action,
|
||||
ParActionIs (see below) may be used. Typical usage:
|
||||
@ -162,84 +163,85 @@ typedef struct ParData {
|
||||
|
||||
There are predefined actions which are all handled by this module:
|
||||
*/
|
||||
typedef enum {
|
||||
PAR_NOOP, /* no operation */
|
||||
PAR_INIT, /* initialize object (called during initialisation) */
|
||||
PAR_SHOW, /* show single parameter (1) */
|
||||
PAR_SET, /* set a single parameter (1) */
|
||||
PAR_GET, /* get a single float parameter (1) */
|
||||
PAR_LIST, /* list all or a group of parameters (2) */
|
||||
PAR_LOG, /* log all parameters activated for logging (2) */
|
||||
PAR_LOGSWITCH, /* (de)activate single parameter for logging (1) */
|
||||
PAR_SAVE, /* save all parameters activated for saving (2) */
|
||||
PAR_SAVESWITCH,/* (de)activate single parameter for saving (1) */
|
||||
PAR_KILL /* kill content (called before remove) */
|
||||
} ParAct;
|
||||
typedef enum {
|
||||
PAR_NOOP, /* no operation */
|
||||
PAR_INIT, /* initialize object (called during initialisation) */
|
||||
PAR_SHOW, /* show single parameter (1) */
|
||||
PAR_SET, /* set a single parameter (1) */
|
||||
PAR_GET, /* get a single float parameter (1) */
|
||||
PAR_LIST, /* list all or a group of parameters (2) */
|
||||
PAR_LOG, /* log all parameters activated for logging (2) */
|
||||
PAR_LOGSWITCH, /* (de)activate single parameter for logging (1) */
|
||||
PAR_SAVE, /* save all parameters activated for saving (2) */
|
||||
PAR_SAVESWITCH, /* (de)activate single parameter for saving (1) */
|
||||
PAR_KILL /* kill content (called before remove) */
|
||||
} ParAct;
|
||||
|
||||
int ParActionIs(ParAct action);
|
||||
int ParActionIs(ParAct action);
|
||||
/* to be called inside the pardef function.
|
||||
returns 0, when the action is not active.
|
||||
returns 1 or -1 when the action is active.
|
||||
the return value -1 is used under following conditions:
|
||||
- for actions marked with (1), when the name does not match
|
||||
(for this case ParActionIs may be called between the call to ParName
|
||||
for the parameter referred and before the next call to ParName)
|
||||
(for this case ParActionIs may be called between the call to ParName
|
||||
for the parameter referred and before the next call to ParName)
|
||||
- for actions marked with (2), when the parameter was not used
|
||||
(for this case ParActionIs must be called after the parameter definition
|
||||
for the parameter referred and before the next call to ParName)
|
||||
(for this case ParActionIs must be called after the parameter definition
|
||||
for the parameter referred and before the next call to ParName)
|
||||
*/
|
||||
|
||||
void ParStdDef(void); /* handle the standard parameters "verbose" and "driver" */
|
||||
void *ParObject(void); /* get the current object (to be called by functions
|
||||
called inside pardef, when the object is not in the argument
|
||||
list */
|
||||
void ParLogReady(ReadyState state); /* set ready state for log */
|
||||
FILE *ParSaveFile(void); /* get the save-file name when action is PAR_SAVE */
|
||||
char *ParGetValueArg(); /* get the set argument for floats and ints. If this function
|
||||
is called, the caller is reponsible for assigning the value
|
||||
to the object parameter */
|
||||
void ParStdDef(void); /* handle the standard parameters "verbose" and "driver" */
|
||||
void *ParObject(void); /* get the current object (to be called by functions
|
||||
called inside pardef, when the object is not in the argument
|
||||
list */
|
||||
void ParLogReady(ReadyState state); /* set ready state for log */
|
||||
FILE *ParSaveFile(void); /* get the save-file name when action is PAR_SAVE */
|
||||
char *ParGetValueArg(); /* get the set argument for floats and ints. If this function
|
||||
is called, the caller is reponsible for assigning the value
|
||||
to the object parameter */
|
||||
|
||||
/*
|
||||
functions to be used outside pardef:
|
||||
*/
|
||||
int ParLog(void *object); /* log all parameters of this object, but only if not
|
||||
already logged in the interval, returns >= 0 when done,
|
||||
or < 0, when not done (execute PAR_LOG action) */
|
||||
void ParKill(void *object); /* free the object (execute PAR_KILL action) */
|
||||
void ParGetFloat(SConnection *con, void *object, char *name, float *value);
|
||||
int ParLog(void *object); /* log all parameters of this object, but only if not
|
||||
already logged in the interval, returns >= 0 when done,
|
||||
or < 0, when not done (execute PAR_LOG action) */
|
||||
void ParKill(void *object); /* free the object (execute PAR_KILL action) */
|
||||
void ParGetFloat(SConnection * con, void *object, char *name,
|
||||
float *value);
|
||||
/* get a float parameter (execute PAR_GET action) */
|
||||
void *ParCast(ParClass *class, void *object);
|
||||
void *ParCast(ParClass * class, void *object);
|
||||
/* returns object, if the object has type "class" or
|
||||
inherits type "class", returns NULL otherwise */
|
||||
void *ParCheck(ParClass *class, void *object) ;
|
||||
void *ParCheck(ParClass * class, void *object);
|
||||
/* dumps core when object has not or does not inherit "class" */
|
||||
void *ParMakeClass(ParClass *class, ParClass *base) ;
|
||||
void *ParMakeClass(ParClass * class, ParClass * base);
|
||||
/* initialize "class". base defines its base class or NULL
|
||||
when ParData is its direct base class */
|
||||
|
||||
void *ParMake(SConnection *con, char *name, ParClass *class, ParDef pardef, char *creationCmd);
|
||||
|
||||
void *ParMake(SConnection * con, char *name, ParClass * class,
|
||||
ParDef pardef, char *creationCmd);
|
||||
/* make an object of class "class", and declare its
|
||||
pardef function. Add it as command "name" to SICS,
|
||||
and execute pardef with PAR_INIT action.
|
||||
When creationCmd is not NULL, it is saved in order to
|
||||
recreate the object.
|
||||
|
||||
|
||||
The SICS system will execute:
|
||||
- PAR_SHOW, PAR_SET, PAR_LIST, PAR_LOGSWITCH
|
||||
from the corresponding command
|
||||
from the corresponding command
|
||||
- PAR_LOG after a PAR_SET action
|
||||
- PAR_SAVE after a parameter change on any SICS command
|
||||
- PAR_KILL on RemoveCommand */
|
||||
|
||||
char *ParArg2Str(int argc, char *argv[], char *res, int maxsize);
|
||||
char *ParArg2Str(int argc, char *argv[], char *res, int maxsize);
|
||||
/* convert args to text. if res==NULL, the result is
|
||||
allocated and maxsize is ignored */
|
||||
|
||||
void ParSaveConn(void *object, SConnection *con);
|
||||
|
||||
void ParSaveConn(void *object, SConnection * con);
|
||||
/* save connection for further use */
|
||||
|
||||
void ParInitPar(void *object, char *name);
|
||||
|
||||
void ParInitPar(void *object, char *name);
|
||||
/* inititalize dynamic parameter */
|
||||
|
||||
#endif
|
||||
|
||||
|
Reference in New Issue
Block a user