![]() |
![]() |
![]() |
![]() |
ccsExit() closes the error stack if there is an error on it,
exits the Message System environment, disconnects Break
and Kill signals, clean-up LCC memory associated to the process and
broadcasts an Obituary message if required, only for processes having
obituary send flag defined at ccsInit.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_NOT_REGISTERED if process is not registered,
lccERR_VXWORKS if VxWorks functions calls error,
lccERR_QSERVER if Q server error,
lccERR_INTERNAL if LCC software failed.
SYNOPSIS #include "ccs.h"
ccsCOMPL_STAT ccsGetMyProcId(
ccsENVNAME envName,
ccsPROCNUM *procNum,
ccsPROCNAME procName,
ccsERROR *error
);
ccsGetMyProcId() returns the information about environment name,
process name and process number of the calling task.
envName <OUT> Returned environment name.
procNum <OUT> Returned process identification number.
procName <OUT> Returned process name.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid parameters,
lccERR_NOT_REGISTERED if the calling task is not registered.
SYNOPSIS #include "ccs.h"
ccsCOMPL_STAT ccsInit(
ccsPROCNAME procName,
vltUINT32 obituary,
void (*breakHandler)(int),
void (*killHandler)(int),
ccsERROR *error
);
ccsInit() resets the error stack, registers the process into
Message System environment and connects BREAK and KILL signal
handlers.
procName <IN> Process name (maximum 19 characters).
obituary <IN> Flag for obituary handling. Broadcast an obituary
message when exit, receive obituary messages from
other environments or processes. The values of the
flag are defined in ccs.h as ccsSEND_OBITUARY and
ccsRECV_OBITUARY, they can be ORed.
breakHandler <IN> Break handler, NULL = default handler
(msgHandleBreak).
killHandler <IN> Kill handler, NULL = default handler
(msgHandleKill).
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_PROC_NAME if invalid procName,
lccERR_PARAMETER if invalid obituary flag,
lccERR_IN_USE if process name is already used,
lccERR_VXWORKS if VxWorks functions calls error,
lccERR_QSERVER if Q server error,
lccERR_INTERNAL if LCC software failed.
ccsInit() MUST BE CALLED BEFORE any other LCC function requiring the
calling process to be registered is used.
ccsInit() must be called only once by a process.
The size of the msg queue used to receive messages from the Q Server
is currently defined by the variable msgMsgQSize. This variable is
initialised internally by function msgInit() at start-up.
When calling ccsInit quite some memory is allocated. Therefore the
stack of the task calling ccsInit should not be too small. It is
recommended to have a stack size of 30 kB for such a task.
status = ccsInit("myName", 0, myBreakHandler, myKillHandler, &error);
status = ccsInit("myName", ccsSEND_OBITUARY, NULL, NULL, &error);
status = ccsInit("myName", ccsSEND_OBITUARY | ccsRECV_OBITUARY,
NULL, NULL, &error);
SYNOPSIS #include "cmd.h"
ccsCOMPL_STAT cmdInit(
const ccsPROCNAME procName,
const char *defFile,
const char *interpretFile,
void (*breakHandler)(int),
void (*killHandler)(int),
void *argument,
ccsERROR *error
);
void cmdTerminate(void);
cmdInit() starts a Command Interpreter. It loads the Command Definition
and Command Interpreter tables then enters an infinite loop waiting for
commands.
The Command Interpreter exits when KILL or EXIT command is received.
Upon termination an obituary message is generated.
No default action is performed for BREAK command.
BREAK and KILL signals are propagated to spawned tasks.
Obituary messages are not processed by a Command Interpreter.
procName <IN> Name of the command interpreter instantiation
(maximum 19 characters).
defFile <IN> Command Definition file.
interpretFile <IN> Command Interpreter file.
breakHandler <IN> Break handler, NULL = no handler.
killHandler <IN> Kill handler, NULL = Command Interpreter performs
cleanup and exits when KILL is received.
argument <IN> User provided argument that can be retrieved
from functions or tasks associated with commands.
error <OUT> Returned error structure. If a null pointer is
given an internal error structure is allocated
and used.
cmdTerminate() triggers the termination of a Command Interpreter. This
function can be called only in the Command Interpreter task context,
i.e. from a command processing function or from the BREAK or KILL
handlers.
Command definition file <READ>
This file contains for each command its
parameters specifications
Command Interpreter file <READ>
This file contains for each each command
the entry point and the VxWorks run time
options.
No value is returned, unless initalisation phase fails and
FAILURE is returned.
In case of error detection, the error structure is updated with :
lccERR_VXWORKS if VxWorks functions calls failed,
lccERR_MEMORY if memory allocation failed,
lccERR_MSG_TYPE if not command message received,
lccERR_FILE_CDT if loading of Command Definition Table failed,
lccERR_FILE_CIT if loading of Command Interpreter Table failed,
lccERR_PARAMETER if invalid argument,
lccERR_INTERNAL if LCC functions calls failed.
The Command Definition Table file must be located either in
$INTROOT/CDT or $VLTROOT/CDT.
The Command Interpreter Table file must be located either in
$INTROOT/vw/CIT or $VLTROOT/vw/CIT.
If cmdInit is spawned from the VxWorks shell or from another task
the parameters given to cmdInit must be valid until they are copied by
the spawned Command Interpreter. Therefore the task spawning cmdInit
must not terminate until cmdInit has copied the parameters. This
is done when the Command Interpreter has registered with ccsInit.
if ((taskSpawn(xxSERVER_NAME,
xxSERVER_PRIORITY,
xxSERVER_OPTIONS,
xxSERVER_STACK,
(FUNCPTR) cmdInit,
(int)xxSERVER_NAME,
(int)xxServerCDT,
(int)xxServerCIT,
(int)NULL, default breakHandler (stop)
(int)NULL, default killHandler (exit)
0,
0, internal error stack used
0,
0,
0)) == ERROR)
{
error handling
}
cmdGetArgument() allows to get the value of the user supplied argument
of the Command Interpreter which received the command under execution.
The argument was supplied when the Command Interpreter has been started
by cmdInit().
cmdGetArgument() returns a non-NULL value only when the function from
which it is called is executed or has been spawned in order to execute
a command.
cmdTaskVar Command Interpreter private data.
cmdArgument Task variable containing the value of the argument for
commands executed as tasks.
SYNOPSIS #include "db.h"
dbTYPE dbNameToType(
char *name
);
void dbMemCpy(
char *buf1,
char *buf2,
dbTYPE dataType
);
ccsCOMPL_STAT dbFillBuf(
char **userBuf,
char *value,
vltINT32 *bufSize,
dbTYPE dataType
);
dbNameToType() returns the CCS data type from the data type name.
name <IN> Name of data type.
dbMemCpy() copies single value from buf2 to buf1 according to data type.
buf1 <IN> Pointer to destination parameter.
buf2 <IN> Pointer to the value to copy.
dataType <IN> Data type.
dbFillBuf() fills up the user buffer according to data type and updates
the user buffer pointer and size.
userBuf <INOUT> User buffer pointer.
value <IN> Pointer to value to be copied.
bufSize <INOUT> Returned current buffer size.
dataType <IN> Data type.
SYNOPSIS #include "db.h"
ccsCOMPL_STAT dbDeToStr( dbTYPE dataType,
void *buffer,
char *string,
vltINT8 fieldWidth,
vltUINT16 precision )
Formats a data element value into a printable string.
dataType <IN> Type of data to be formatted, for example:
dbINT8, dbUINT32, dbBYTES20, dbLOGICAL etc ..
buffer <IN> Pointer to the data element
string <OUT> ASCII formatted value. The formatted string will
always be terminated by a NULL character, which
is not included in the field width.
fieldWidth <IN> Specifies the formatting as follows :
- 0 Exactly as many characters as needed
- n < 0 Left-justified (blank-filled) in
n characters
- n > 0 Right-justified (blank-filled) in
n characters
precision <IN> Specifies the precision (maximum number of significant
digits) required if deType is dbFLOAT, dbDOUBLE,
dbPOLAR or dbRECTANGULAR. For the time data element
types (dbTIME_OF_DAY or dbABS_TIME), precision specifies
the number of digits used to express fractions of a
second.*
Some examples for the output of some data types.
Data Type | Output String Format
..............|........................................................
dbLOGICAL | Any nonzero value is printed as '1', otherwise as '0'.
dbPOLAR | {<magnitude>, <angle(deg)>, e.g. {1.35, -3.7d}
dbRECTANGULAR | {<real part><imaginary part>}, e.g. {6.37+4.3j}
dbABS_TIME | yyyy-mm-ddThh:mm:ss.uuuuuuu
dbDATE | yyyy-mm-dd
dbTIME | hh:mm:ss.uuuuuuu
dbXREF | @[71.2(4:5,6)]
If the specified length is insufficient then :
- The output of Numeric data (dbINT8, dbFLOAT, dbDOUBLE, etc .. )
is filled with '*'.
- The output of the other data (dbBYTESxx, dbPOLAR, dbABS_TIME, etc ..)
is truncated and marked with trailing ".."
The user must take care about the alignment of the pointers
passed to dbDeToStr(). This applies in particular when scanning
a record of a table. RTAP stores the data in an optimized way.
It is then up to the user to design the structure of the record
with a proper alignment.
See RTAP manuals for details.*
SYNOPSIS #include "db.h"
ccsCOMPL_STAT dbEnRemoteAccess(
ccsERROR *error
);
ccsCOMPL_STAT dbDisRemoteAccess(
ccsERROR *error
);
ccsCOMPL_STAT dbEnSim(
ccsERROR *error
);
ccsCOMPL_STAT dbDisSim(
ccsERROR *error
);
dbEnRemoteAccess() enables access to a remote database through dbRead
operations.
error <OUT> Returned error structure.
dbDisRemoteAccess() disables access to a remote database through dbRead
operations. At startup of the system, remote database access is
disabled.
error <OUT> Returned error structure.
dbEnSim() enables simulation of access to a remote database
through dbRead operations. When the simulation mode is enabled,
a specific error status is returned when a remote database is accessed
(lccERR_SIMULATION).
error <OUT> Returned error structure.
dbDisSim() disables simulation of access to a remote database
through dbRead operations. At startup of the system, simulation of
the remote database access is disabled.
error <OUT> Returned error structure.
SYNOPSIS #include "db.h"
ccsCOMPL_STAT dbAliasToName(
dbSYMADDRESS alias,
dbSYMADDRESS name,
ccsERROR *error
);
ccsCOMPL_STAT dbGetAlias(
dbSYMADDRESS name,
dbSYMADDRESS alias,
ccsERROR *error
);
dbAliasToName() gets the symbolic name from alias.
alias <IN> Point alias.
name <OUT> Returned absolute point name.
error <OUT> Returned error structure.
dbGetAlias() gets the alias of a point.
name <IN> Symbolic name of the point.
alias <OUT> Returned alias.
error <OUT> Returned error structure.
SUCCESS if everything OK
FAILURE if something wrong. The error structure is updated with :
lccERR_PARAMETER if a parameter has a bad value,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_INV_NAME if invalid point name syntax,
lccERR_REMOTE if in a remote database,
lccERR_POINT if name does not refer to a point.
SYNOPSIS #include "db.h"
ccsCOMPL_STAT dbGetAttrNames(
dbSYMADDRESS pointName,
vltUINT8 *attrCount,
vltUINT8 **ains,
dbATTRIBUTE **names,
ccsERROR *error
);
ccsCOMPL_STAT dbGetAttrInfo(
dbSYMADDRESS pointName,
dbATTRIBUTE attrName,
dbATTRTYPE *type,
vltUINT8 *fieldCnt,
vltUINT16 *recCnt,
vltUINT32 *recSize,
vltUINT16 *recsUsed,
dbTYPE *dataType,
ccsERROR *error
);
ccsCOMPL_STAT dbGetAttrNumber(
dbSYMADDRESS pointName,
vltUINT8 *attrCnt,
ccsERROR *error
);
ccsCOMPL_STAT dbGetFieldNames(
dbSYMADDRESS pointName,
dbATTRIBUTE attrName,
vltUINT8 *fieldCnt,
dbFIELDNAME **fieldName,
dbTYPE **dataType,
ccsERROR *error
);
For database functions using symbolic addressing in two parts,
pointName and attrName, the following combination of values are
allowed:
Addressed Item pointName attrName
-------------- --------- ---------
Point Point name dbEMPTY
Attribute Complete attribute name dbEMPTY
Attribute Point name .attributeName
Attribute Point name attributeName
The point can be addressed using the following syntax :
- by its symbolic address : ":branch1:branch2"
"<relative>branch1:branch2"
"<absolute>branch1:branch2"
- by its alias : "<alias>myalias"
- by specifying the environment : "|envName:branch1:branch2"
The routine takes care of the fact that the address is symbolic or
alias in order to be more performant.
If attrName = dbEMPTY, it is assumed that the attribute name is
directly specified in the pointName.
The attribute name can be specified WITH or WITHOUT the '.' at the
beginning.
dbGetAttrNames() gets attribute names, internal numbers and count
for a point.
pointName <IN> Name of the point to be searched for.
attrCount <OUT> Number of attributes in the point.
ains <OUT> All the attribute internal numbers, dynamically allocated
(see CAUTIONS below).
names <OUT> All the attribute names, dynamically allocated (see
CAUTIONS below).
error <OUT> Returned error structure.
dbGetAttrInfo() gets, for an attribute, the type, the number of fields,
the number of records, the number of used records and all the value
types.
pointName <IN> Name of the point to be searched for.
attrName <IN> Name of the attribute in the point to be searched for.
attrType <OUT> Attribute type: SCALAR, VECTOR or TABLE.
fieldCnt <OUT> Number of fields for table attribute. Always 1 for
SCALAR and VECTOR types.
recCnt <OUT> Number of records for table and vector attribute.
Always 1 for SCALAR type.
recSize <OUT> Size in bytes of a table record, or of a vector
element or of a scalar.
recsUsed <OUT> Index of the highest written record for a table or
vector (0 if no records have been used, record index
+1 otherwise).
dataType <OUT> All the value types (fields in a record, element of
a vector, scalar).
DataType is 'ZERO' terminated, therefore its size
must be at least 2 (for SCALARS and VECTORS). For
its size must be at least the number of fields
plus 1.
SCALARS and VECTOR are described by only one element.
For TABLES, it returns the type of each field of the
record.
error <OUT> Returned error structure.
dbGetAttrNumber() gets attribute count for a point.
pointName <IN> Name of the point to be searched for.
attrCnt <OUT> Number of attributes in the point.
error <OUT> Returned error structure.
dbGetFieldNames() gets field names for a table attribute.
pointName <IN> Name of the point to be searched for.
attrName <IN> Name of the attribute in the point to be searched for.
fieldCnt <OUT> Number of fields.
fieldName <OUT> All the field names, dynamically allocated (see
CAUTIONS below).
dataType <OUT> All the field types, dynamically allocated (see
CAUTIONS below).
DataType is 'ZERO' terminated, therefore its size
must be at least 2 (for SCALARS and VECTORS).
SCALARS and VECTOR are described by only one element.
For TABLES, it returns the type of each field of the
record .
error <OUT> Returned error structure.
SUCCESS if everything OK
FAILURE if something wrong. The error structure is updated with :
lccERR_PARAMETER if a parameter has a bad value,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_NOT_FOUND if no direct address can be associated to the
point/attribute names,
lccERR_INV_NAME if invalid point/attribute name syntax,
lccERR_INV_RECEL if incorrect record specification,
lccERR_INV_FIELD if incorrect field specification,
lccERR_REMOTE if in a remote database,
lccERR_POINT if name does not refer to a point,
lccERR_ATTRIBUTE if name does not refer to an attribute,
lccERR_ATTR_TYPE if attribute type is invalid.
Output parameters for which size is not easily known in advance are
dynamically allocated by the called function. The allocated memory
buffer will be reused between calls to the same function by the
same process and it will be automatically freed when the process
exits the Message System. It should NOT be FREED by the calling
process. The calling process should make a copy of the data if it
needs to keep the information before calling again the same function.
These functions can be called only by processes registered in the
Message System.
#include "db.h"
...
dbATTRIBUTE attribute;
dbSYMADDRESS pointName;
dbATTRTYPE attrType;
dbTYPE *dataType = NULL;
dbFIELDNAME *fieldName = NULL;
vltUINT8 fieldCnt;
vltUINT16 recCnt;
vltUINT16 recsUsed;
vltUINT32 recSize;
ccsERROR error;
...
strcpy(attribute, "param")
strcpy(pointName, ":branch1:branch2:mypoint");
if (dbGetAttrInfo(pointName, attribute, &attrType,
&fieldCnt, &recCnt, &recSize,
&recsUsed, dataType, &error) == FAILURE)
{
Process Error condition
}
...
strcpy(attribute, ".table");
if (dbGetFieldNames(pointName, attribute, &fieldCnt,
&fieldName, &dataType, &error) == FAILURE)
{
Process Error condition
}
...
SYNOPSIS #include "db.h"
ccsCOMPL_STAT dbGetCwp(
ccsENVNAME envName,
dbSYMADDRESS pointName,
ccsERROR *error
);
ccsCOMPL_STAT dbSetCwp(
dbSYMADDRESS pointName,
ccsERROR *error
);
dbGetCwp() returns the current working point of the calling process
if it is defined.
envName <IN> Environment name (maximum 7 characters, must match local
environment name).
ccsLOCAL_ENV defaults to the local environment.
name <OUT> Returned current working point. If no current working
point, was previously defined, a NULL pointer (root
point) is returned.
error <OUT> Returned error structure.
dbSetCwp() sets the current woking point of the calling process to
given name.
pointName <IN> New current working point.
error <OUT> Returned error structure.
The point can be addressed by either symbolic or alias name.
The name of the current working point is then pre-pended to all
relative names of the subsequent accessed points and attributes.
The concept of Current Working Point is local to each process and can
only be used in the local environment.
SUCCESS if everything OK.
FAILURE, the error structure is updated with :
dbGetCwp :
lccERR_PARAMETER if provided environment is different from
the local environment,
lccERR_NOT_REGISTERED if the calling process is not registered
in the Message System.
dbSetCwp :
lccERR_INV_NAME if invalid point name syntax,
lccERR_NOT_FOUND if no direct address can be associated to
point name,
lccERR_REMOTE if in a remote database,
lccERR_POINT if name does not refer to a point,
lccERR_MEMORY if memory allocation failure,
lccERR_NOT_REGISTERED if the calling process is not registered
in the Message System.
SYNOPSIS #include "db.h"
ccsCOMPL_STAT dbGetDirAddr(
const dbSYMADDRESS pointName,
const char *attrName,
dbDIRADDRESS *dirAddr,
ccsERROR *error
);
ccsCOMPL_STAT dbGetDirAddrInternal(
const dbSYMADDRESS pointName,
const char *attrName,
dbDIRADDRESS *dirAddr,
ccsERROR *error
);
ccsCOMPL_STAT dbDirAddrToName(
dbDIRADDRESS *dirAddr,
dbVIEW addrType,
dbSYMADDRESS name,
ccsERROR *error
);
ccsCOMPL_STAT dbDirAddrToNameInternal(
dbDIRADDRESS *dirAddr,
dbVIEW addrType,
dbSYMADDRESS name,
ccsERROR *error
);
ccsCOMPL_STAT dbTranslatePlin(
dbDIRADDRESS *dirAddress,
vltUINT16 *actualPlin,
ccsERROR *error
);
dbGetDirAddr() gets the direct address of a point or an attribute.
pointName <IN> Symbolic name of the point.
attrName <IN> Symbolic name of the attribute or dbEMPTY.
address <OUT> Returned direct address.
error <OUT> Returned error structure.
The following combination of values are allowed for parameters
pointName and attrName:
Addressed Item pointName attrName
-------------- ---------- -----------
Point Point name dbEMPTY
Attribute Complete attribute name dbEMPTY
Attribute Point name .attributeName
Attribute Point name attributeName
The point can be addressed using the following syntax :
- by its symbolic address : ":branch1:branch2"
"<relative>branch1:branch2"
"<absolute>branch1:branch2"
- by its alias : "<alias>myalias"
- by specifying the environment : "@envName:branch1:branch2"
The routine takes care of the fact that the address is symbolic or
alias in order to be more performant.
If attrName = dbEMPTY, it is assumed that the attribute name is
directly specified in the pointName.
The attribute name can be specified WITH or WITHOUT the '.' at the
beginning.
The data structure dirAddr is filled to a level of detail that
depend on the type of item addressed (point or attribute), and the
type of the attribute.
- addrLevel Addressing Level. This indicates the level of detail
of the information returned in the direct address.
- dbDIR_PLIN when a point address is given,
- dbDIR_AIN for SCALAR attribute,
- dbDIR_REC for VECTOR attribute,
- dbDIR_FIELD for TABLE attribute.
- plin Point internal number (rtPlin)
- ain Attribute internal number (rtAin)
The following parameters are filled up according to the type of
attribute and the record and field ranges specified in the
symbolic name:
- startRec First record to be accessed (VECTOR and TABLE)
- endRec Last record to be accessed (VECTOR and TABLE)
- startField First field to be accessed (TABLE)
- endField Last field to be accessed (TABLE)
dbDirAddrToName() converts direct address into a symbolic address
(absolute, relative or alias), as specified by addrType.
dirAddr <IN> Direct address
addrType <IN> Type of symbolic address returned
name <OUT> Symbolic name
error <OUT> Returned error structure
SUCCESS if everything OK
FAILURE if something wrong. The error structure is updated with :
lccERR_PARAMETER if pointName is NULL,
lccERR_DIRADDRESS if invalid direct address,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_NOT_FOUND if no direct address can be associated to
point/attribute name,
lccERR_INV_NAME if invalid point/attribute name syntax,
lccERR_INV_RECEL if incorrect record specification,
lccERR_INV_FIELD if incorrect field specification,
lccERR_REMOTE if in a remote database.
#include "db.h"
...
dbITEM attrName;
dbSYMADDRESS pointName;
dbDIRADDRESS dirAddr;
ccsERROR error;
...
strcpy(attrName, "param")
strcpy(pointName, ":branch1:branch2:mypoint");
...
if (dbGetDirAddr(pointName, attrName, &dirAddr, &error) == FAILURE)
{
Process Error condition
}
...
SYNOPSIS #include "db.h"
ccsCOMPL_STAT dbGetFamily(
dbSYMADDRESS pointName,
vltUINT16 *myself,
vltUINT16 *parent,
vltUINT16 *childCnt,
vltUINT16 **children,
ccsERROR *error
);
ccsCOMPL_STAT dbGetFamilyNames(
dbSYMADDRESS pointName,
dbVIEW addrType,
dbSYMADDRESS parent,
vltUINT16 *childCnt,
dbSYMADDRESS **children,
ccsERROR *error
);
ccsCOMPL_STAT dbGetParent(
dbSYMADDRESS pointName,
vltUINT16 *parent,
ccsERROR *error
);
dbGetFamily() retrieves the point internal indices of the point itself,
of its parent and of all its children.
pointName <IN> Name of the point to be searched for.
myself <OUT> Point internal index of the provided point.
parent <OUT> Point internal index of its parent.
childCnt <OUT> Its children number.
children <OUT> Point internal indices of its children, dynamically
allocated (see CAUTIONS below).
error <OUT> Returned error structure.
dbGetFamilyNames() gets names of child points and parent.
pointName <IN> Point name.
addrType <IN> Type of symbolic address returned.
parent <OUT> my "father" name.
childCnt <OUT> Number of children.
children <OUT> Array of names, dynamically allocated (see CAUTIONS
below).
error <OUT> Returned error structure.
dbGetParent() retrieves the point internal indices of the point itself
and of its parent.
pointName <IN> Name of the point to be searched for.
parent <OUT> Point internal index of its parent.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE if something wrong. The error structure is updated with :
lccERR_PARAMETER if a parameter has a bad value,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_INV_NAME if invalid point name syntax,
lccERR_REMOTE if in a remote database,
lccERR_POINT if name does not refer to a point,
lccERR_NOT_FOUND if no direct address can be associated to the
point name.
Output parameters for which size is not easily known in advance are
dynamically allocated by the called function. The allocated memory
buffer will be reused between calls to the same function by the
same process and it will be automatically freed when the process
exits the Message System. It should NOT be FREED by the calling
process. The calling process should make a copy of the data if it
needs to keep the information before calling again the same function.
These functions can be called only by processes registered in the
Message System.
dbListCreate, dbListGetId, dbListDestroy, dbListChangeEnv, dbListAdd, dbListModify, dbListRemove, dbListExtract, dbMultiWrite, dbMultiRead - manage list for multi read/write operations
SYNOPSIS #include "db.h"
ccsCOMPL_STAT dbListCreate(
char *listName,
ccsENVNAME envName,
vltINT8 useFlag,
dbLISTID *listId,
ccsERROR *error,
);
ccsCOMPL_STAT dbListGetId(
char *listName,
dbLISTID *listId,
ccsERROR *error
);
ccsCOMPL_STAT dbListDestroy(
dbLISTID listId,
ccsERROR *error
);
ccsCOMPL_STAT dbListChangeEnv(
dbLISTID listId,
ccsENVNAME newEnvName,
ccsERROR *error
);
ccsCOMPL_STAT dbListAdd(
dbLISTID listId,
dbSYMADDRESS attrName,
vltINT32 bufSize,
void *buffer,
ccsERROR *error
);
ccsCOMPL_STAT dbListModify(
dbLISTID listId,
dbSYMADDRESS attrName,
vltINT32 bufSize,
void *buffer,
ccsERROR *error
);
ccsCOMPL_STAT dbListRemove(
dbLISTID listId,
dbSYMADDRESS attrName,
ccsERROR *error
);
ccsCOMPL_STAT dbListExtract(
dbLISTID listId,
dbSYMADDRESS attrName,
dbATTRINFO *attrInfo,
ccsERROR *error
);
ccsCOMPL_STAT dbMultiWrite(
dbLISTID listId,
vltUINT8 writeMode,
ccsERROR *error
);
ccsCOMPL_STAT dbMultiRead(
dbLISTID listId,
ccsERROR *error
);
dbListCreate() creates an empty a list of attributes.
listName <IN> Name of the list
envName <IN> Name of the RTAP environement
useFlag <IN>
listId <OUT> Returned list identifier
error <OUT> Returned error structure
dbListGetId() gets the list identifier from the name
listName <IN> Name of the list
listId <OUT> Returned list identifier
error <OUT> Returned error structure
dbListDestroy() destroys a list of attributes
listId <IN> List Identifier
error <OUT> Returned error structure
dbListChangeEnv() replaces the environment name with another
listId <IN> List Identifier
newEnvName <IN> New environment name
error <OUT> Returned error structure
dbListAdd() inserts a new element in the list
listId <IN> List Identifier, as returned by dbListCreate().
attrName <IN> Symbolic address of the database attribute, including
the ranges
bufSize <IN> Amount of data to be read or written (in bytes).
buffer <IN> Pointer to the buffer where the values are stored.
Both for Read and Write operations
error <OUT> Returned error structure
dbListModify() modifies the configuration parameters of an element of
the list
listId <IN> List Identifier
attrName <IN> Symbolic address of the database attribute
bufSize <IN> Buffer size
buffer <IN> Pointer to the buffer with current values
error <OUT> Returned error structure
dbListRemove() removes an element from the list
listId <IN> List Identifier
attrName <IN> Symbolic address of the database attribute
error <OUT> Returned error structure
dbListExtract() gets the information returned after a read/write
operation
listId <IN> List Identifier
attrName <IN> Symbolic address of the database attribute
attrInfo <OUT> Extracted information
error <OUT> Returned error structure
dbMultiWrite() writes list of attributes
listId <IN> List Identifier
writeMode <IN> Write mode : dbBLOCK, dbNORMAL
error <OUT> Returned error structure
dbMultiRead() reads list of attributes
listId <IN> List Identifier
error <OUT> Returned error structure
SUCCESS if everything OK
FAILURE if something wrong. The error structure is updated with :
lccERR_PARAMETER if a parameter has a bad value,
lccERR_MEMORY if dynamic memory allocation failure,
lccERR_FULL if max number of lists reached,
lccERR_DUPLICATE if already existing list (dbListCreate),
if already existing attribute (dbListAdd),
lccERR_NOT_FOUND if list not found (dbListGetId, dbListRemove,
dbListExtract),
lccERR_REMOTE if remote environment when dbWRITE (dbListChangeEnv)
lccERR_DB_BLOCK_CNT when any read/write failed for
dbMultiRead/Write
lccERR_DB_READ when trying to read an empty list in dbMultiRead
lccERR_DB_WRITE when trying to write an empty list in dbMultiWrite
dbLISTID id1;
dbLISTID id2;
dbSYMADDRESS attrName1;
dbSYMADDRESS attrName2;
dbSYMADDRESS attrName3;
char buf1[256];
char buf2[256];
char buf3[256];
dbATTRINFO attrInfo1;
dbATTRINFO attrInfo2;
dbATTRINFO attrInfo3;
...
if ((dbListCreate("listRd", "LCU", dbREAD, &id1, &error) == FAILURE) ||
(dbListCreate("listWr", "LCU", dbWRITE, &id2, &error) == FAILURE))
{
Process failure condition
}
...
if ((dbListAdd(id1, attrName1, 256, buf1, &error) == FAILURE) ||
(dbListAdd(id1, attrName2, 256, buf2, &error) == FAILURE) ||
(dbListAdd(id1, attrName3, 256, buf3, &error) == FAILURE))
{
Process failure condition
}
if ((dbListAdd(id2, attrName1, 256, buf4, &error) == FAILURE) ||
(dbListAdd(id2, attrName2, 256, buf5, &error) == FAILURE) ||
(dbListAdd(id2, attrName3, 256, buf6, &error) == FAILURE))
{
Process failure condition
}
...
if (dbMultiWrite(id2, dbBLOCK, &error) == FAILURE)
{
Process failure condition
}
...
if ((dbMultiRead(id1, &error) == FAILURE) ||
(dbListExtract(id1, attrName1, &attrInfo1, &error) == FAILURE) ||
(dbListExtract(id1, attrName2, &attrInfo2, &error) == FAILURE) ||
(dbListExtract(id1, attrName3, &attrInfo3, &error) == FAILURE))
{
Process failure condition
}
...
if ((dbListDestroy(id1, &error) == FAILURE) ||
(dbListDestroy(id2, &error) == FAILURE))
{
Process failure condition
}
SYNOPSIS #include "db.h"
ccsCOMPL_STAT dbLoad(
char *rootName,
ccsERROR *error
);
ccsCOMPL_STAT dbUnload(
char *rootName,
ccsERROR *error
);
ccsCOMPL_STAT dbLoadBranch(
char *rootName,
dbSYMADDRESS point,
ccsERROR *error
);
ccsCOMPL_STAT dbUnloadBranch(
char *rootName,
dbSYMADDRESS point,
ccsERROR *error
);
dbLoad() creates the database structure initialized from disk,
discarding the old one if any.
rootName <IN> Root directory name for database load.
error <OUT> Returned error structure.
dbUnload() stores the current database structure on disk, in an existing
empty directory.
rootName <IN> Root directory name for database dump.
error <OUT> Returned error structure.
dbLoadBranch() creates a branch of a database. The branch below the
given point (including the point itself) is deleted and replaced by
the branch defined in rootName directory.
rootName <IN> Root directory name for database load.
point <IN> Point under which the branch is loaded.
error <OUT> Returned error structure.
dbUnloadBranch() stores a branch of the database to disk. The branch
is unloaded under the given root directory name. If for example, "./branch"
and ":motors:sensors" are given respectively as root directory and point
name, the branch will be unloaded as "./branch/sensors".
rootName <IN> Root directory name for database dump.
point <IN> Name of point defining the branch to be unloaded.
error <OUT> Returned error structure.
rootName <R/W> Root directory for database load or dump. This root
directory contains exactly one file for attributes
description, and one subdirectory for each point
(with <point_name> name). Each point subdirectory
is organized as the root directory.
SUCCESS if everything OK
FAILURE, the error structure is updated with:
lccERR_POINT if a branch is loaded or unloaded and the given
point is not valid,
lccERR_NOT_REGISTERED if caller not registered in Message System,
lccERR_FILE if file access error,
lccERR_MEMORY if memory allocation failure,
lccERR_LENGTH if point/attribute/field name is more than 19
characters,
lccERR_BAD_PARAM_VAL if value type does not match item value type,
lccERR_MAP_MAXIMUM if maximum number of items/records already
defined,
lccERR_DUPLICATE if point already defined or alias already exist,
lccERR_VXWORKS if VxWorks system call fails,
lccERR_DE_TYPE if wrong data type or value not valid for data
type,
lccERR_INV_RECEL if invalid number of records/fields.
SYNOPSIS #include "db.h"
ccsCOMPL_STAT dbLockPoint(
dbSYMADDRESS pointName,
vltUINT32 seconds,
ccsERROR *error
);
ccsCOMPL_STAT dbLockAttr(
dbSYMADDRESS name,
ccsERROR *error
);
ccsCOMPL_STAT dbUnlockPoint(
dbSYMADDRESS pointName,
ccsERROR *error
);
ccsCOMPL_STAT dbUnlockAttr(
dbSYMADDRESS name,
ccsERROR *error
);
dbLockPoint() locks all the attributes of the point for the caller.
This locking mechanism allows only the caller to access the attributes
in read and write modes. The point can be unlocked by anybody.
pointName <IN> Name of the point to be locked.
seconds <IN> Not used on LCU.
error <OUT> Returned error structure.
dbLockAttr() locks the attribute for the caller. This locking mechanism
allows only the caller to access the attribute in write mode, and
allows everybody to access the attribute in read mode. The attribute
can be unlocked by anybody.
name <IN> Name of the attribute to be locked.
error <OUT> Returned error structure.
dbUnlockPoint() unlocks all the attributes of the point. The point can
be unlocked by anybody.
pointName <IN> Name of the point to be unlocked.
error <OUT> Returned error structure.
dbUnlockAttr() locks the attribute. The attribute can be unlocked by
anybody.
name <IN> Name of the attribute to be unlocked.
error <OUT> Returned error structure.
SUCCESS if everything OK
FAILURE if something wrong. The error structure is updated with :
lccERR_MEMORY if dynamic memory allocation failure,
lccERR_REMOTE if in a remote database,
lccERR_POINT if name does not refer to a point,
lccERR_ATTRIBUTE if name does not refer to an attribute,
lccERR_LOCK if point/attribute already locked by an other user,
lccERR_SEM if database semaphore not reachable,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_NOT_FOUND if no direct address can be associated to the
point/attribute names.
dbReadSymbolic, dbReadDirect, dbWriteSymbolic, dbWriteDirect, dbReadScalar, dbWriteScalar, dbRead, dbWrite - access to database values
SYNOPSIS #include "db.h"
ccsCOMPL_STAT dbReadSymbolic(
const dbSYMADDRESS pointName,
const char attrName,
dbTYPE *dataType,
char *buffer,
vltINT32 size,
vltINT32 *actual,
vltUINT16 *recordCnt,
dbATTRTYPE *attrType,
ccsERROR *error
);
ccsCOMPL_STAT dbReadDirect(
const dbDIRADDRESS *dirAddr,
dbTYPE *dataType,
char *buffer,
vltINT32 size,
vltINT32 *actual,
vltUINT16 *recordCnt,
dbATTRTYPE *attrType,
ccsERROR *error
);
ccsCOMPL_STAT dbReadDirectInternal(
const dbDIRADDRESS *dirAddr,
dbTYPE *dataType,
char *buffer,
vltINT32 size,
vltINT32 *actual,
vltUINT16 *recordCnt,
dbATTRTYPE *attrType,
ccsERROR *error
);
ccsCOMPL_STAT dbWriteSymbolic(
const dbSYMADDRESS pointName,
const char *attrName,
const dbTYPE *dataType,
const char *buffer,
vltINT32 size,
vltINT32 *actual,
vltUINT16 recordCnt,
dbATTRTYPE attrType,
ccsERROR *error
);
ccsCOMPL_STAT dbWriteDirect (
const dbDIRADDRESS *dirAddr,
const dbTYPE *dataType,
const char *buffer,
vltINT32 size,
vltINT32 *actual,
vltUINT16 recordCnt,
dbATTRTYPE attrType,
ccsERROR *error
);
ccsCOMPL_STAT dbWriteDirectInternal (
const dbDIRADDRESS *dirAddr,
const dbTYPE *dataType,
const char *buffer,
vltINT32 size,
vltINT32 *actual,
vltUINT16 recordCnt,
dbATTRTYPE attrType,
ccsERROR *error
);
ccsCOMPL_STAT dbReadScalar(
const dbSYMADDRESS pointName,
char *buffer,
ccsERROR *error
);
ccsCOMPL_STAT dbRead(
const dbSYMADDRESS pointName,
char *buffer,
ccsERROR *error
);
ccsCOMPL_STAT dbWriteScalar(
const dbSYMADDRESS pointName,
const char *buffer,
ccsERROR *error
);
ccsCOMPL_STAT dbWrite(
const dbSYMADDRESS pointName,
const char *buffer,
ccsERROR *error
);
For database functions using symbolic addressing in two parts,
pointName and attrName, the following combination of values are
allowed:
pointName attrName
--------- --------
Complete attribute name dbEMPTY
Point name .attributeName
Point name attributeName
The point can be addressed using the following syntax :
- by its symbolic address : ":branch1:branch2"
"<relative>branch1:branch2"
"<absolute>branch1:branch2"
- by its alias : "<alias>myalias"
- by specifying the environment : "@envName:branch1:branch2"
The routine takes care of the fact that the address is symbolic or
alias in order to be more performant.
If attrName = dbEMPTY, it is assumed that the attribute name is directly
specified in the pointName.
The attribute name can be specified WITH or WITHOUT the '.' at the
begining.
dbReadSymbolic() reads, for an attribute given by name, its value(s)
and its type.
pointName <IN> Name of the attribute's point.
attrName <IN> Name of the attribute.
dataType <OUT> Returned data type(s) (integer, float, string, ...),
enough space must be allocated by the caller.
An array is returned with the last element equal to
dbUNDEFINED. For scalar and vectors, two types are
returned, for tables, number of fields + 1 types are
returned.
buffer <OUT> Where to written returned value(s).
(enough space must be allocated by the caller).
The buffer is organized as a byte stream where each
value takes always exactly the number of bytes its
type needs (e.g. 4 bytes for a dbUINT32, or 80 bytes
for a dbBYTES80, whatever is the actual size of the
string in memory). The values are written in the
buffer without delimitors, from the first to the last
field, from the first to the last record.
size <IN> Size of the output buffer.
actual <OUT> Used part of the output buffer, or required size if
buffer is too small.
recordCnt <OUT> Returned number of records.
attrType <OUT> Returned attribute type (dbSCALAR, dbVECTOR or dbTABLE).
error <OUT> Returned error structure.
dbReadDirect() reads, for an attribute given by internal address, its
value(s) and its type.
dirAddr <IN> Direct address of the attribute.
dataType <OUT> Data type(s) (integer, float, string, ....), as
in dbReadSymbolic.
buffer <OUT> Where to written returned value(s)
(enough space must be allocated by the caller).
The buffer is organized as a byte stream where each
value takes always exactly the number of bytes its
type needs (e.g. 4 bytes for a dbUINT32, or 80 bytes
for a dbBYTES80, whatever is the actual size of the
string in memory). The values are written in the
buffer without delimitors, from the first to the last
field, from the first to the last record.
size <IN> Size of the output buffer.
actual <OUT> Used part of the output buffer, or required size if
buffer is too small.
recordCnt <OUT> Returned number of records.
attrType <OUT> Returned attribute type (dbSCALAR, dbVECTOR or dbTABLE).
error <OUT> Returned error structure.
dbWriteSymbolic() writes, for an attribute given by name, its value(s).
pointName <IN> Name of the attribute's point.
attrName <IN> Name of the attribute.
dataType <IN> Data type(s) (integer, float, string, ....), as
in dbReadSymbolic, but types provided by the caller.
buffer <IN> Where to find value(s).
The buffer is organized as a byte stream where each
value takes always exactly the number of bytes its
type needs (e.g. 4 bytes for a dbUINT32, or 80 bytes
for a dbBYTES80, whatever is the actual size of the
string in memory). The values are read in the
buffer without delimitors, from the first to the last
field, from the first to the last record.
size <IN> Size of the input buffer.
actual <OUT> Used part of the input buffer.
recordCnt <IN> Number of records written.
attrType <IN> Attribute type (dbSCALAR, dbVECTOR or dbTABLE).
error <OUT> Returned error structure.
dbWriteDirect() writes, for an attribute given by internal address, its
value(s).
dirAddr <IN> Direct address of the attribute.
dataType <IN> Data type(s) (integer, float, string, ....), as
in dbReadSymbolic, but types provided by the caller.
buffer <IN> Where to find value(s).
The buffer is organized as a byte stream where each
value takes always exactly the number of bytes its
type needs (e.g. 4 bytes for a dbUINT32, or 80 bytes
for a dbBYTES80, whatever is the actual size of the
string in memory). The values are read in the
buffer without delimitors, from the first to the last
field, from the first to the last record.
size <IN> Size of the input buffer.
actual <OUT> Used part of the input buffer.
recordCnt <IN> Number of records written.
attrType <IN> Attribute type (dbSCALAR, dbVECTOR or dbTABLE).
error <OUT> Returned error structure.
dbReadScalar is a simplified read function for scalar attributes by
name.
pointName <IN> Name of the database attribute.
buffer <OUT> Where to put data. Data are returned in binary format,
e.g. the same format as for dbReadSymbolic.
error <OUT> Returned error structure.
dbWriteScalar is a simplified write function for scalar attributes by
name
pointName <IN> Name of the database attribute.
buffer <IN> Data to be written. Data must be in binary format, e.g.
the same format as for dbWriteSymbolic
error <OUT> Returned error structure.
dbRead is a utility to read scalar attributes from the VxWorks shell.
pointName <IN> Name of the database attribute.
buffer <OUT> Where to put data. Data are returned in ASCII format.
error <OUT> Returned error structure.
If a NULL pointer is given an internal
error structure is allocated and used.*
dbWrite is a utility to write scalar attributes from the VxWorks shell.
pointName <IN> Name of the database attribute.
buffer <IN> Data to be written. ASCII buffer or string.
error <OUT> Returned error structure.
If a NULL pointer is given an internal
error structure is allocated and used.*
SUCCESS if everything OK.
FAILURE, the error structure is updated with :
lccERR_MEMORY if dynamic memory allocation failure,
lccERR_PARAMETER if a parameter has a bad value,
lccERR_INV_NAME if invalid point/attribute name syntax,
lccERR_DIRADDRESS if direct address is not valid,
lccERR_REMOTE if operation is not allowed on a remote database or
remote access is disabled,
lccERR_ENV_NAME if invalid remote environment,
lccERR_SIMULATION if remote database simulation is enabled,
lccERR_ATTRIBUTE if name does not refer to an attribute,
lccERR_LOCK if point/attribute locked by an other user,
lccERR_SEM if database semaphore not reachable,
lccERR_ATTR_TYPE if wrong attribute type,
lccERR_DE_TYPE if wrong data type,
lccERR_INV_RECEL if wrong record count,
lccERR_INV_FIELD if incorrect field spcification,
lccERR_BUF_SIZE if output buffer too small (required size given in
actual output parameter) [dbRead] or input buffer does not
match data size [dbWrite],
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_INTERNAL if cannot access remote database.
Functions using symbolic addressing can be called only by
processes registered in the Message System.
#include "db.h"
...
dbATTRTYPE attrType;
dbTYPE dataType[2];
char userBuf[100];
vltINT32 actual
vltUINT16 recordCnt;
ccsERROR error;
...
if (dbReadSymbolic(":branch1:branch2:mypoint.param1", dbEMPTY,
dataType, userBuf, sizeof(userBuf), &actual,
&recordCnt, &attrType, &error) == FAILURE)
{
Process Error condition
}
dbATTRTYPE attrType;
dbTYPE dataType[2];
vltINT16 buffer[] = {1, 23, -56, 6};
vltINT32 bufSize;
vltINT32 actual;
vltUINT16 recordCnt;
dbDIRADDRESS dirAddr;
ccsERROR error;
...
dataType[0] = dbINT16;
dataType[1] = dbUNDEFINED;
attrType = dbVECTOR;
recordCnt = 4
bufSize = recordCnt * sizeof(vltINT16);
...
if (dbGetDirAddr(":branch1:branch2:mypoint",
"vector(3:6)", &dirAddr, &error) == FAILURE)
{
Process Error condition
}
...
if (dbWriteDirect(&dirAddr, dataType, buffer, bufSize,
&actual, recordCnt, attrType, &error) == FAILURE)
{
Process Error condition
}
dbSYMADDRESS scalar_uint16;
dbSYMADDRESS scalar_float;
vltUINT16 scalar_value;
vltFLOAT float_value;
char value[sizeof(vltBYTES256)];
...
if (dbWriteScalar(scalar_uint16, &scalar_value, &error) == FAILURE)
{
Process Error condition
}
...
if (dbWriteScalar(scalar_float, &float_value, &error) == FAILURE)
{
Process Error condition
}
...
if (dbReadScalar(scalar_float, &value, &error) == FAILURE)
{
Process Error condition
}
SYNOPSIS ccsCOMPL_STAT dbRestoreFile (
char *file,
char *cwp1,
char *cwp2,
char *cwp3,
char *cwp4,
ccsERROR *error)
dbRestoreFile() restores a backup generated by the CCS utility
dbBackup().
file <IN> specifies a file containing the data
to be restored.
cwpx <IN> causes dbRestoreFile() to substitute every
current working point found in cwpx
and matching <CWP1> by <CWP2>.
cwpx must be in the format "CWP1=CWP2".
<CWP2> must be a valid symbolic address.
By this option it is possible to move
data between environments/branches
and points. Maximum 4 substitutions
can be specified. No substitution is
performed if a NULL pointer is given.
Alternatively cmpx can be of the format "CWP".
In this case the first current working point
found will be substituted by CWP.
error <OUT> Returned error structure.
If a NULL pointer is given an internal
error structure is allocated and used.
"@lte19=@lte16"
<CWP> @lte19: -> @lte16:
<CWP> @lte19:PARAMS -> @lte16:PARAMS
<CWP> @lte19<alias>TestRoot -> @lte16<alias>TestRoot
"<relative>PARAMS=<relative>TEST"
<CWP> @lte19:PARAMS -> @lte19:PARAMS
<CWP> <relative>PARAMS -> <relative>TEST
<CWP> <relative>PARAMS:SCALARS -> <relative>TEST:SCALARS *
The following rules are applied during the restore operation:
- if a current working point specified in the input file
is not found, dbRestoreFile() terminates with an error
- an attribute is skipped and a warning is printed
on the stdout
- if a point or attribute specified in the input file
is not found
- if the attribute type in the input file does not
match the type defined in the database
- if the number of records/fields of an attribute found
in the input file do not match to the ones retrieved from
the database, only the records/fields matching the range
are restored. The other records/fields are skipped and
a warning is printed on the stdout.
SUCCESS upon successful termination
FAILURE the error structure is updated with :
lccERR_PARAMETER if invalid parameter,
lccERR_FILE if file access problem,
lccERR_DB_CONVERT if not possible to convert value,
lccERR_NOT_REGISTERED if the calling task is not registered.
lccERR_INV_NAME if invalid point name syntax,
lccERR_NOT_FOUND if no direct address can be associated to
point name,
lccERR_POINT if name does not refer to a point,
lccERR_MEMORY if memory allocation failure,
lccERR_ATTRIBUTE if name does not refer to an attribute,
lccERR_ATTR_TYPE if attribute type is invalid.
lccERR_LOCK if point/attribute locked by an other user,
lccERR_SEM if database semaphore not reachable,
lccERR_DE_TYPE if wrong data type,
dbRestoreFile needs around 25 kBytes of stack. Make sure that
the stack size of the task calling it is big enough. The stack
usage can be checked whith the VxWorks utility checkStack.
>dbRestoreFile "input.dat", 0, 0, 0, 0, error
restores all data in file input.dat
>dbRestoreFile "input.dat","@lte1:=@lte2:", 0, 0, 0, error
restores all data in file input.dat, whereby the
current working point @lte1: is set to @lte2:,
which means the data read from @lte1: is stored
on @lte2:.
Convert a string into the equivalent data element value.
dataType <IN> Type of data to be converted, for example : dbINT8,
dbUINT32, dbBYTES20, dbLOGICAL, dbPOLAR, etc ..
string <IN> ASCII representation of the value
buffer <OUT> User defined buffer of the type specified in the
dataType parameter.
Hereafter there are the string formats for some of the data types.
Data Type | Input String Format
........................................................................
dbLOGICAL only values of '0' or '1' are valid.
dbPOLAR {1.35, -3.7d} the two values are magnitude and angle (in degree).
dbRECTANGULAR {6.37+4.3j} the two values are real and imaginary parts
dbABS_TIME yyyy-mm-ddThh:mm:ss[.uuuuuuu]
dbDATE yyyy-mm-dd
dbTIME hh:mm:ss[.uuuuuuu]
#include "err.h"
ccsCOMPL_STAT errAdd ( ccsERROR *error,
const ccsMODULEID moduleId,
vltINT16 errorNumber,
const ccsLOC_ID locId,
char *format, (not Used on WS)
... )
Add a new log to the current error stack.
error <IN> Error Structure containing previous error context.
moduleId <IN> Module Identifier
errorNumber <IN> Error Number
locId <IN> Name of the routine/function generating the error
The preprocessor directive __FILE__ can be used.
format <IN> ( NOT USED ON WS or LCU using new format)
Format string for old format on LCU.
If not used set to NULL or empty string.
... <IN> Variable list of run time parameters.
Error numbers are identified by mnemonics.
A new error is processed as follows :
- Log previous error (if the stack not empty). If the environment name
is not the same as the local one, the error log is logged to the remote
environment.
- Get a new stack identifier (if stack empty).
- Increase the error sequence number.
- Set current error structure according to the new error condition.
A new stackId is read from the RTAP database.
The error message is read from the error definition and it looks like a
'printf format' containing conversion specifications to be applied to the
run time parameters.
SUCCESS A log is issued in the following cases :
- error structure is a NULL pointer.
- moduleId is not existing.
- the error number does not have the corresponding error format.
The current implementation uses the routine errAdd_v() which can be
embedded in other routines having a variable number of parameters.
(See K&R section : Variable length Argument List).
The implementation of the error system on the LCU now requires that the
error files are loaded on the LCU. To achive this all LCU modules must be
loaded with the function lcubootAutoLoad. Error files which are not loaded
by this function can be loaded with lcubootErrorLoad.
ccsERROR error;
:
:
if (funct2(p2,&error) == FAILURE)
{
if (error can be recovered)
{
errResetStack(&error);
}
else
{
errAdd(&error,"module",moduleERR_INV_PARAMETER,__FILE__,DUMMY,p2);
return(FAILURE);
}
}
If the last error of the sequence cannot be recovered, the stack must be
closed and reset.
error <IN> Error Structure containing previous error context.
Therefore as general rule it is up to the application to close the error
stack and then, if appropriate, generate an alarm to notify the user the
error could not be recovered.
#define MAIN
main ()
{
ccsERROR error;
if (funct1(p1,p2,&error) == FAILURE)
{
if (error cannot be recovered) errCloseStack(&error);
}
.
.
}
Copy the content of and error structure into another.
The stack belonging to one error structure is not copied.
errDest <OUT> Destination error structure
errSrc <IN> Error structure to be copied.
SYNOPSIS #include "err.h"
ccsCOMPL_STAT errDriverAdd(
ccsERROR *error,
const ccsMODULEID moduleId,
vltINT16 errorNumber,
const ccsLOC_ID locId,
char *format,
char *driverName,
vltINT16 driverError,
...
);
errDriverAdd() logs a driver error and modifies the current context.
error <IN> Current error structure to be modified.
moduleId <IN> moduleId of producer of error (maximum 7 characters).
errorNumber <IN> New error to add.
locId <IN> Name of the place (sub, func, proc) where the error
was found or reported (maximum 80 characters).
format <IN> Printf format for run time parameters.
Not required with new format.
driverName <IN> Identifies driver device name (maximum 80
characters).
driverError <IN> Driver error number.
... <IN> Run time parameters to be added to the error message.
status = ioctl (fd, cmd, arg);
if (status < 0)
{
errDriverAdd(error, lccMODULE_ID, <mod>ERR_DRIVER, __FILE__,"",
"/mcon0", status, ...);
return FAILURE;
}
#include "err.h"
vltLOGICAL errInStack (ccsERROR *error,
const ccsMODULEID moduleId,
vltINT16 errorNumber)
This routines allows the user to check if a given error is part of the
error stack : the error is univocally addressed by the moduleId and the
corresponding mnemonic.
error <IN> Error Structure containing current error context.
moduleId <IN> Module Identifier
errorNumber <IN> Error Number
ccsMODULEID mod;
ccsERROR error;
strcpy(mod,"trk");
if (errInStack(&error,mod,trkERR_PRESET) == ccsTRUE)
{
error trkERR_PRESET was found in the stack
}
else
{
The stack does not contain the error
}
SYNOPSIS #include "err.h"
ccsCOMPL_STAT errIsReason (ccsERROR *error,
const ccsMODULEID moduleId,
vltINT16 errorNumber,
vltLOGICAL *errFound,
ccsSTACK_ELEM **errDescription)
This routines allows the user to look for a specific error in the
error stack. The routine scans the error stack until it finds an
error matching both <moduleId> and <errorNumber> or it reaches the end.
error <IN> Error Structure containing current error context.
moduleId <IN> Module Identifier
errorNumber <IN> Error Number
errFound <OUT> Returned flag to indicate whether the specific error
in in the stack : ccsTRUE/ccsFALSE.
errDescription <OUT> Returns the pointer to the element in the error stack
containing the specific error, or NULL the error
has not been found.
Sometimes it does not not make sense to propagate to the higher level
all the detailed information on the cause of an error.
The application can look in the stack if specific error conditions have
occurred : for example an error can rise due to a bad quality of a DB
attribute, but the toplevel error could report the failure of a higher
level operation (for instance modERR_COMAND_FAILED ... )
ccsMODULEID mod;
ccsERROR error;
ccsSTACK_ELEM *stackElem;
vltLOGICAL errFound,
strcpy(mod,"trk");
if (errIsReason(&error,mod,trkERR_PRESET,&found,&stackElem) == FAILURE)
{
return(FAILURE);
}
if (found == ccsTRUE)
{
examine error description stored in stackElem.
...
errPrint((ccsERROR *) stackElem);
...
}
SYNOPSIS
#include "err.h"
ccsCOMPL_STAT errMergeStack( ccsERROR *errDest,
ccsERROR *errSrc,
char *flag )
Merge the error stack of errSrc to the one of errDest.
The stack of errSrc is addet to the stack of errDest according to the
flag specification -e.g.- TOP or BOTTOM.
errDest <OUT> Error Structure containing the stack to be modified
errSrc <IN> Error Structure containing the stack to be copied
flag <IN> Indicates how the two stack are merged.
The flag can assume these two values :
- errTOP , The errSrc stack will be added at the top
of the errDest stack.
- errBOTTOM The errSrc stack will be added at the bottom
of the errDest stack.
The stack identifier of the new added part of the stack will be changed
according to the lower part of the stack.
The description of the error stored in the ccsERROR structure is changed
according to the new top element of the stack.
Prints the content of the local error structure on the screen
error <IN> Error Structure containing previous error context.
The error information is presented as follows :
---------------------- Error Structure ----------------------
Time Stamp : yy-mm-dd hh:mm:ss.uuuuuu
Process Number : <pid> Process Name : <name>
Environment : <envName> StackId : <stackId> Sequence : <sequence N.>
Error Number : <number> Severity : <W>
ModuleId : <module> location : <location>
Error Text : < text ...>
#define MAIN
main ()
{
ccsERROR error;
if (funct1(p1,p2,&error) == FAILURE)
{
if (error cannot be recovered)
{
errPrint(&error);
errCloseStack(&error);
}
}
.
.
}
Initialize the error structure to start a new error stack.
error <IN>/<OUT> returned error structure
The routine initializes the following error parameters :
- envName = Environment name
- sequenceNumber = 0 This is used to check whether the stack is empty.
- runTimePar It is initialized as an empty string.
The routine must be called :
- Always at the beginning of an application. This is already included
in ccsInit().
- When a calling routine returns an error condition and such error
can be fixed.
ccsERROR error;
:
:
if (funct2(p2,&error) == FAILURE)
{
if (error can be recovered)
{
errResetStack(&error);
}
else
{
process error condition
}
}
errSetStack - Initialize the error structure according to the error context
sent back by the message system in the error reply message.
Initialize the error structure according to the error context
sent back by the message system in the error reply message.
error <OUT> Returned error structure initialized with the new stack
description.
message <IN> Message header
The following fields of the local error structure are initialized :
- envName
- sequenceNumber
- runTimePar
- stackId
#include "err.h"
ccsCOMPL_STAT errSysAdd ( ccsERROR *error,
const ccsMODULEID moduleId,
vltINT16 errorNumber,
const ccsLOC_ID locId,
char *format, (not Used on WS)
char *sysModule,
... )
Add RTAP, UNIX or VxWorks errors to the stack.
error <IN> Error Structure containing previous error context.
moduleId <IN> Module Identifier
errorNumber <IN> Error Number
locId <IN> Name of the routine/function generating the error
The preprocessor directive __FILE__ can be used.
format <IN> ( NOT USED WS or LCU using new format)
Format string for old format on LCU.
If not used set to NULL or empty string.
sysModule <IN> System producing the errors : UNIX, RTAP or VxWorks.
... <IN> Variable list of run time parameters.
Error numbers are identified by mnemonics.
Valid sysModule parameters are : modRTAP and modUNIX for CCS and
modVXWORKS for lcc.
A new error is processed as follows :
- Log previous error (if the stack not empty). If the environment name
is not the same as the local one, the error log is logged to the remote
environment.
UNIX Error : The UNIX global error number and error message is
converted into the CCS error format and logged.
RTAP Error : RTAP generates its own error stack and every element of the
stack is converted into the CCS error format and logged.
VxWorks Error : The VxWorks process error number and error message is
converted into the CCS error format and logged.
- Get a new stack identifier (if stack empty).
- Increase the error sequence number.
- Set current error structure according to the new error condition.
A new stackId is read from the RTAP database.
The error message is read from the error definition and it looks like a
'printf format' containing conversion specifications to be applied to the
run time parameters.
SUCCESS A log is issued in the following cases :
- error structure is a NULL pointer.
- moduleId is not existing.
- sysModule is not valid.
- the error number does not have the corresponding error format.
The current implementation uses the routine errSysAdd_v() which can be
embedded in other routines having a variable number of parameters.
(See K&R section : Variable length Argument List).
int funct2(int p2, ccsERROR *error)
{
if ((fileHandle = open(filename,O_RDWR)) == -1)
{
errSysAdd(error,"module",moduleERR_FILE,__FILE__,DUMMY,modUNIX,filename);
return(FAILURE);
}
if (rtapFunction(...) == rtFAILURE)
{
errSysAdd(error,"module",moduleERR_DB_READ,__FILE__,DUMMY,modRTAP,var1);
return(FAILURE);
}
if (vxworksFunction(...) == rtFAILURE)
{
errSysAdd(error,"module",moduleERR_DB_READ,__FILE__,DUMMY,
modVXWORKS,var1);
return(FAILURE);
}
return(SUCCESS);
}
SYNOPSIS #include "evt.h"
ccsCOMPL_STAT evtAttach(
dbSYMADDRESS attribute,
evtFILTER filter,
evtEVENT_ID *eventId,
ccsERROR *error
);
ccsCOMPL_STAT evtAttachAlarm(
dbSYMADDRESS attribute,
evtEVENT_ID *eventId,
ccsERROR *error
);
ccsCOMPL_STAT evtDetach(
evtEVENT_ID *eventId,
ccsERROR *error
);
evtAttach() requests events for a database element.
Events for SCALAR attributes (and single elements of VECTOR and TABLE)
attributes are generated according to the trigger condition given by
filter:
. evtANY_WRITE : event generated for every write,
. evtNOT_EQUAL : event generated whenever the value is changed,
. evtDEAD_BAND : event generated when the value has changed
more than the deadband or one of the limits is
crossed (deadband and limits are defined by
evtConfig()).
Events for VECTOR and TABLE attributes are generated on any write
(filter parameter is ignored).
Events are sent as messages (msgTYPE_EVENT) to the requesting process.
The body of an event message contains the event data (evtEVTREQ_REPLY).
Event messages can be parsed with evtParseMsg().
attribute <IN> Database element.
filter <IN> Trigger condition for events (scalars only).
eventId <OUT> Returned event identifier.
error <OUT> Returned error structure.
evtAttachAlarm() requests alarms for a database element. Alarms are
generated when the value of the element goes out of limit.
Alarms are sent as messages (msgTYPE_ALARM) to the requesting process.
The body of an alarm message contains the event data (evtEVTREQA_REPLY).
Alarm messages can be parsed with evtParseAlarmMsg().
attribute <IN> Database element.
eventId <OUT> Returned event identifier.
error <OUT> Returned error structure.
evtDetach() cancel the sending of the event identified by eventId.
eventId <IN> Event identifier.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid parameter,
lccERR_EVENT if a parameter is not configured for alarms,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_SEM if cannot enter the function.
Request an event when the attribute changes
No call to evtConfig required in this case
if (evtAttach (":PARAMS:SCALARS.scalar_int16",
evtNOT_EQUAL, &eventId, &error) == FAILURE)
{
error handling
}
Set up a deadband of 1.5 for a database attribute
deadband = 1.5;
if (evtConfig (":PARAMS:SCALARS.scalar_float",
evtCONF_DEADBAND,
0, 0, 0, 0, &deadBand, &error) == FAILURE)
{
error handling
}
Request an event when the attribute changes more than the
deadband
if (evtAttach (":PARAMS:SCALARS.scalar_float",
evtDEAD_BAND, &eventId, &error) == FAILURE)
{
error handling
}
Wait for the event (message of type msgTYPE_EVENT)
myFilter.accept=msgANY_MESSAGE;
if (msgRecvMsg (&myFilter, msgNO_TIMEOUT, &myMsg,
&error) == FAILURE)
{
error handling
}
if (msgParseMsg (myMsg, &msgType, &command,
&commandId, &orgId, &last, &buffer, &buflen,
&errMsg, &error) == FAILURE)
{
error handling
}
if (msgType == msgTYPE_EVENT)
{
if (evtParseMsg (myMsg, &myEventId, &trigCond,
&trigProc, &attrName, &attrType, &eventInfo,
NULL, &error) == FAILURE)
{
error handling
}
....
SYNOPSIS #include "evt.h"
#include "db.h"
ccsCOMPL_STAT evtConfig(
const dbSYMADDRESS name,
vltUINT8 bitfield,
const void *limitHH,
const void *limitH,
const void *limitL,
const void *limitLL,
const void *deadBand,
ccsERROR *error
);
ccsCOMPL_STAT evtConfigAbnormal(
const dbSYMADDRESS name,
vltUINT8 bitfield,
vltUINT16 alarmNumHH,
vltUINT16 alarmNumH,
vltUINT16 alarmNumL,
vltUINT16 alarmNumLL,
ccsERROR *error
);
evtConfig() sets the deadband for an attribute for event generation
and the limits for abnormal event generation. It is not necessary to
call this function if no deadband is used for normal event generation.
The different parameters to configure the event are:
limits (HH, H, L, LL) and deadband.
Attributes must be configured for event monitoring using this function
before evtAttach() is called with triggering condition evtDEADBAND.
name <IN> Attribute to be configured for event generation.
bitfield <IN> Bit field defining configuration, build by ORing
the following values:
. evtCONF_HH if HighHigh limit is provided,
. evtCONF_H if High limit is provided,
. evtCONF_L if Low limit is provided,
. evtCONF_LL if LowLow limit is provided,
. evtCONF_DEADBAND if deadband is provided.
evtCONF_ALL is also provided and stands for
all limits defined (HH, H, L, LL).
limitHH <IN> Value of the HighHigh limit.
limitH <IN> Value of the High limit.
limitL <IN> Value of the Low limit.
limitLL <IN> Value of the LowLow limit.
deadBand <IN> Value of the deadband.
error <OUT> Returned error structure.
evtConfigAbnormal() sets the alarm number for abnormal events
corresponding to the configured limits. The limits corresponding to
each provided alarm number must have been set with evtConfig() before
calling evtConfigAbnormal().
Abnormal events may be configured only for integer and real valued
attributes (including composite time and coordinates types).
Attributes must be configured for abnormal events using this function
with at least one alarm defined before evtAttachAlarm() is called.
name <IN> Attribute to be configured for abnormal event
generation.
bitfield <IN> Bit field defining configuration, build by ORing
the following values:
. evtCONF_HH if HighHigh alarm number is
provided,
. evtCONF_H if High alarm number is provided,
. evtCONF_L if Low alarm number is provided,
. evtCONF_LL if LowLow alarm number is provided.
alarmNumHH <IN> Alarm number for the HighHigh limit.
alarmNumH <IN> Alarm number for the High limit.
alarmNumL <IN> Alarm number for the Low limit.
alarmNumLL <IN> Alarm number for the LowLow limit.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with :
lccERR_PARAMETER if the operation is not allowed for the attribute
or invalid bitfield,
lccERR_ATTRIBUTE if name does not refer to an attribute,
lccERR_REMOTE if name refer to a remote database,
lccERR_EVENT if attribute is not configured for event or the limit
corresponding to an alarm number has not been defined,
lccERR_ORDER if limits are not ordered as increasing values,
lccERR_MULTI if more than one element is addressed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
These function can be called only by processes registered in the
Message System.
The values provided as limits and deadband must be of the same type as
the configured element.
Set up a deadband of 1.5 for a database attribute
deadBand = 1.5;
if (evtConfig (":PARAMS:SCALARS.scalar_float",
evtCONF_DEADBAND,
0, 0, 0, 0, &deadBand, &error) == FAILURE)
{
error handling
}
Set up a deadband of 1.5 and a high limit of 7.5 for a database
attribute
deadBand = 1.5;
highLimit = 7.5;
if (evtConfig (":PARAMS:SCALARS.scalar_double",
evtCONF_H+evtCONF_DEADBAND,
0, &highLimit, 0, 0, &deadBand, &error) == FAILURE)
{
error handling
}
Set up alarm number 5 for the high limit
if (evtConfigAbnormal (":PARAMS:SCALARS.scalar_double",
evtCONF_H, 0, 5, 0, 0, &error) == FAILURE)
{
error handling
}
SYNOPSIS #include "evt.h"
ccsCOMPL_STAT evtEnAlarm(
ccsERROR *error
);
ccsCOMPL_STAT evtDisAlarm(
ccsERROR *error
);
ccsCOMPL_STAT evtEnAllAlarm(
ccsERROR *error
);
ccsCOMPL_STAT evtDisAllAlarm(
ccsERROR *error
);
evtEnAlarm() enables the sending of abnormal event reports for
requesting process.
evtDisAlarm() disables the sending of abnormal event reports for
requesting process.
evtEnAllAlarm() enables the sending of abnormal event reports for
all processes.
evtDisAllAlarm() disables the sending of abnormal event reports for
all processes.
error <OUT> Returned error structure.
SUCCESS if everything OK
FAILURE, the error structure is updated with:
lccERR_SEM if cannot enter the function,
lccERR_INTERNAL if cannot enable/disable alarm.
SYNOPSIS #include "evt.h"
#include "db.h"
ccsCOMPL_STAT evtGetConfig(
const dbSYMADDRESS name,
dbTYPE *attrType,
vltUINT8 *limits,
void *limitHH,
void *limitH,
void *limitL,
void *limitLL,
void *deadband,
ccsERROR *error
);
ccsCOMPL_STAT evtGetAlarmConfig(
const dbSYMADDRESS name,
vltUINT8 *alarms,
vltUINT16 *alarmNumHH,
vltUINT16 *alarmNumH,
vltUINT16 *alarmNumL,
vltUINT16 *alarmNumLL,
ccsERROR *error
);
DESCRIPTION
evtGetConfig() and evtGetAlarmConfig() get the event/alarm
configuration for a database element.
name <IN> Name of element configured for event generation.
attrType <OUT> Returned attribute type.
limits <OUT> Bitfield defining which limits are defined, composed
of the following ORed values:
. evtCONF_HH if HighHigh limit is defined,
. evtCONF_H if High limit is defined,
. evtCONF_L if Low limit is defined,
. evtCONF_LL if LowLow limit is defined,
. evtCONF_DEADBAND if deadband is defined.
limitHH <OUT> Buffer where HighHigh limit is written.
limitH <OUT> Buffer where High limit is written.
limitL <OUT> Buffer where L limit is written.
limitLL <OUT> Buffer where LL limit is written.
deadband <OUT> Buffer where deadband is written.
alarms <OUT> Bitfield defining which alarms are defined, composed
the following ORed values:
. evtCONF_HH if HighHigh alarm number is defined,
. evtCONF_H if High alarm number is defined,
. evtCONF_L if Low alarm number is defined,
. evtCONF_LL if LowLow alarm number is defined.
alarmNumHH <OUT> Alarm number for HighHigh limit.
alarmNumH <OUT> Alarm number for High limit.
alarmNumL <OUT> Alarm number for Low limit.
alarmNumLL <OUT> Alarm number for LowLow limit.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE if something wrong. The error structure is updated with :
lccERR_PARAMETER if invalid parameter,
lccERR_ATTRIBUTE if name does not refer to a database element,
lccERR_REMOTE if in a remote database,
lccERR_MULTI if more than one element is addressed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
SYNOPSIS #include "evt.h"
ccsCOMPL_STAT evtSetSampleRate(
evtPERIOD period,
vltUINT32 seconds,
ccsERROR *error
);
ccsCOMPL_STAT evtSetSampleRate(
evtPERIOD *period,
vltUINT32 *seconds,
ccsERROR *error
);
evtSetSampleRate() sets the sampling rate for signals to be reported on
change. Default rate is one second.
period <IN> Acquisition period (evt10_MILLISECOND,
evt100_MILLISECOND or evtSECONDS).
seconds <IN> Number of seconds (only for evtSECONDS periods).
error <OUT> Returned error structure.
evtGetSampleRate() gets the current sampling rate used for signals to
be reported on change.
period <OUT> Acquisition period (evt10_MILLISECOND,
evt100_MILLISECOND or evtSECONDS).
seconds <OUT> Number of seconds (only for evtSECONDS periods).
error <OUT> Returned error structure.
SUCCESS if everything OK
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid period or number of seconds.
SYNOPSIS #include "evt.h"
ccsCOMPL_STAT evtParseMsg(
msgHEADER *message,
evtEVENT_ID *eventId,
vltUINT8 *trigCond,
msgPROCESSID *trigProc,
dbSYMADDRESS attrName,
dbATTRTYPE *attrType,
evtDATA *eventInfo,
char **userMsg,
ccsERROR *error
)
ccsCOMPL_STAT evtParseAlarmMsg(
msgHEADER *message,
evtEVENT_ID *eventId,
msgPROCESSID *trigProc,
dbSYMADDRESS attrName,
dbTYPE *dataType,
vltUINT16 *alarmNumber,
alarmSTATUS *oldStatus,
alarmSTATUS *newStatus,
char *oldValue,
char *newValue,
ccsERROR *error
)
evtParseMsg() parses the message received as a consequence of an event
notification.
message <IN> Pointer to message notification.
eventId <OUT> Event identifier.
trigCond <OUT> Event triggering condition.
trigProc <OUT> Process that triggered the event.
attrName <OUT> Name of attribute for which event is generated.
attrType <OUT> Type of attribute.
eventInfo <OUT> Event information.
userMsg <OUT> Attached user message, if any.
error <OUT> Returned error structure.
evtParseAlarmMsg() parses the message received as a consequence of an
alarm notification.
message <IN> Pointer to message notification.
eventId <OUT> Event identifier.
trigProc <OUT> Process that triggered the alarm.
attrName <OUT> Name of attribute for which alarm is generated.
dataType <OUT> Type of attribute.
alarmNumber <OUT> Alarm number.
oldStatus <OUT> Old alarm status. Must be an array of two element.
newStatus <OUT> New alarm status. Must be an array of two element.
Indicates the alarm status of the attribute, e.g.
the enumeration values
alarmLOWLOW = 1,
alarmLOW,
alarmNORMAL, No alarm
alarmHIGH,
alarmHIGHHIGH
oldValue <OUT> Old value of attribute. The buffer must be
at least 16 bytes long.
newValue <OUT> New value of attribute. The buffer must be
at least 16 bytes long.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid parameter,
lccERR_MSG_TYPE if invalid message type.
clude "evt.h"
.
.
ccsERROR error;
msgCMD *command;
char *buffer;
msgHEADER *myMsg;
evtEVENT_ID myEventId;
vltUINT8 trigCond;
msgPROCESSID trigProc;
dbSYMADDRESS attrName;
dbATTRTYPE attrType;
evtDATA eventInfo;
char *userMsg;
ccsERROR errMsg;
vltUINT8 msgType;
msgCMDID commandId;
msgPROCESSID *orgId;
msgLENGTH buflen;
vltLOGICAL last;
msgRECEIVEFILTER myFilter;
evtEVENT_ID eventId;
vltINT32 evtData;
vltINT32 almLimit = 10;
dbTYPE dataType[2];
vltUINT16 alarmNumber;
alarmSTATUS oldStatus[2], newStatus[2];
char oldValue[16], newValue[16];
vltINT32 value;
.
.
if (evtAttach (attrName, evtNOT_EQUAL, &eventId,
&error) == FAILURE)
{
error handling
}
if (evtAttachAlarm (attrName, &eventId, &error) == FAILURE)
{
error handling
}
myFilter.accept=msgANY_MESSAGE;
if (msgRecvMsg (&myFilter, msgNO_TIMEOUT, &myMsg, &error)
== FAILURE)
{
error handling
}
if (msgParseMsg (myMsg, &msgType, &command, &commandId, &orgId, &last,
&buffer, &buflen, &errMsg, &error)
== FAILURE)
{
error handling
}
if (msgType == msgTYPE_EVENT)
{
if (evtParseMsg (myMsg, &myEventId, &trigCond, &trigProc,
attrName, &attrType, &eventInfo, &userMsg,
&error) == FAILURE)
{
error handling
}
else if (msgType == msgTYPE_ALARM)
{
if (evtParseAlarmMsg (myMsg, &myEventId, &trigProc, attrName,
dataType, &alarmNumber, oldStatus,
newStatus,oldValue, newValue, &error)
== FAILURE)
{
error handling
}
if (newStatus[0] == alarmHIGH)
{
alarm handling
}
.
.
}
.
.
free(myMsg);
evtSingleEnable, evtSingleDisable, evtEnEvent, evtDisEvent, evtEnAllEvent, evtDisAllEvent - enable/disable the sending of reports
SYNOPSIS #include "evt.h"
ccsCOMPL_STAT evtSingleEnable(
evtEVENT_ID *eventId,
ccsERROR *error
);
ccsCOMPL_STAT evtSingleDisable(
evtEVENT_ID *eventId,
ccsERROR *error
);
ccsCOMPL_STAT evtEnEvent(
ccsERROR *error
);
ccsCOMPL_STAT evtDisEvent(
ccsERROR *error
);
ccsCOMPL_STAT evtEnAllEvent(
ccsERROR *error
);
ccsCOMPL_STAT evtDisAllEvent(
ccsERROR *error
);
evtSingleEnable() enables the reporting of an event for requesting
process.
evtSingleDisable() disables the reporting of an event for requesting
process.
evtEnEvent() enables the sending of event reports for requesting
process.
evtDisEvent() disables the sending of event reports for requesting
process.
evtEnAllEvent() enables the sending of event reports for all processes
evtDisAllEvent() disables the sending of event reports for all
processes.
eventId <IN> Event to enable.
error <OUT> Returned error structure.
SUCCESS if everything OK
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid parameter,
lccERR_ENV_NAME if invalid envName defined in eventId,
lccERR_INTERNAL if cannot enable/disable event,
lccERR_SEM if cannot enter the function.
Send CAN synch signal to CAN device. This triggers the device to send back analog
signal values which are configured to use sync
deviceName <IN> Name of the device
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_NOT_FOUND unknown signal name,
lccERR_DRIVER if driver function calls failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
Configure and read analog input signals.
if (ioConfigAnalog (":MOTOR1.current1", "/canio0", 0, ioINPUT, 1.0,
-10.0, 10.0, ioGAIN_1, 0, &error) == FAILURE)
{
...
}
if (ioConfigAnalog (":MOTOR1.current2", "/canio0", 1, ioINPUT, 1.0,
-10.0, 10.0, ioGAIN_1, 0, &error) == FAILURE)
{
...
}
....
if (ioConfigAnalog (":MOTOR1.current6", "/canio0", 5, ioINPUT, 1.0,
-10.0, 10.0, ioGAIN_1, 0, &error) == FAILURE)
{
...
}
if (ioConfigCANAnalogSync("/canio0",0,6,ccsTRUE, &error) == FAILURE)
{
...
}
if (ioCANSendSync("/canio0", &error) == FAILURE)
{
...
}
if (ioReadAnalog (":MOTOR.current1", ¤t1, &error) == FAILURE)
{
...
}
....
if (ioReadAnalog (":MOTOR.current6", ¤t6, &error) == FAILURE)
{
...
}
ioChangeBit() changes the state of the given single bit digital output
signal.
In LCU simulation mode, the hardware is not affected.
signalName <IN> Name of the signal.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_NOT_FOUND unknown signal name,
lccERR_SEM if critical section entering timeout,
lccERR_SIGNAL if signal is not single bit digital output,
lccERR_DRIVER if driver function calls failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
ioClearBit() sets a single bit digital output signal into its inactive
state.
In LCU simulation mode, the hardware is not affected.
signalName <IN> Name of the signal.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_NOT_FOUND unknown signal name
lccERR_SEM if critical section entering timeout,
lccERR_SIGNAL if signal is not single bit digital output,
lccERR_DRIVER if driver function calls failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
#include "io.h"
ccsCOMPL_STAT ioConfigAnalog(
dbSYMADDRESS signalName,
lccDEVICE_NAME deviceName,
vltUINT8 signalNumber,
ioIN_OUT inOut,
vltFLOAT convertFactor,
vltFLOAT lowerRange,
vltFLOAT higherRange,
ioGAIN gainFactor,
vltFLOAT simValue,
ccsERROR *error
);
Initialise an analog signal.
The analog driver is configured according to the given parameters.
signalName <IN> Name of the signal.
deviceName <IN> Name of the associated device (maximum 19
characters).
signalNumber <IN> Hardware analog signal number (0-15).
inOut <IN> Input or output signal (ioINPUT or ioOUTPUT).
convertFactor <IN> Conversion factor for analog signal.The conversion
factor converts the returned value from hardware
units to user units.
lowerRange <IN> Lower range for output analog signals.
higherRange <IN> Higher range for the output analog signals.
gainFactor <IN> Gain factor for analog signal(ioGAIN_1, ioGAIN_10,
ioGAIN_100 or ioGAIN_500).
simValue <IN> Default simulation value. Value returned in
simulation mode.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_PARAMETER if bad value input parameters,
lccERR_MEMORY if memory allocation error,
lccERR_SEM if critical section entering timeout,
lccERR_DRIVER if driver function call failed,
lccERR_RANGE if simulation value out of range,
lccERR_NO_IMAGE is no image of signal in database,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
Analog input signal 2, conversion factor 2.5, gain 1
Limits will be 2.5*10.0 and 2.5*(-10.0) resp.
if (ioConfigAnalog (":MOTOR1.current", "/aio0", 2, ioINPUT, 2.5,
-25.0, 25.0, ioGAIN_1, 0, &error) == FAILURE)
{
...
}
....
if (ioReadAnalog (":MOTOR.current", ¤t, &error) == FAILURE)
{
...
}
#include "io.h"
ccsCOMPL_STAT ioConfigCANAnalogSync(
lccDEVICE_NAME deviceName,
vltINT32 firstSignal,
vltINT32 numSignals,
vltLOGICAL syncEnable,
ccsERROR *error,
);
configure CAN analog signals to use synch access protocol
The driver is configured according to the given parameters.
deviceName <IN> Name of the device
firstSignal <IN> Number of the first signal of the device to use sync
numSignals <IN> Number of signals to use sync
syncEnable <IN> ccsTRUE if the signals shall be accesses via sync
error <OUT> Returned error structure.
The function defines which signals of a canio device are accesses with sync signal.
Only one set of signals per deveice can be defined to use sync, and they have to
be consequtive.
If a signal is configured for using sync, then the value is only updated
after a synch signal has been sent out on the CAN bus with the function ioCANSendSync.
When the synch signal is sent out on the CAN bus all signals configured for the sync
will be updated and can be read with ioReadAnalog or ioDReadAnalog. The sync signal can
only be used in connection with analog input signals.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_NOT_FOUND unknown signal name,
lccERR_DRIVER if driver function calls failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
Configure and read analog input signals.
if (ioConfigAnalog (":MOTOR1.current1", "/canio0", 0, ioINPUT, 1.0,
-10.0, 10.0, ioGAIN_1, 0, &error) == FAILURE)
{
...
}
if (ioConfigAnalog (":MOTOR1.current2", "/canio0", 1, ioINPUT, 1.0,
-10.0, 10.0, ioGAIN_1, 0, &error) == FAILURE)
{
...
}
....
if (ioConfigAnalog (":MOTOR1.current6", "/canio0", 5, ioINPUT, 1.0,
-10.0, 10.0, ioGAIN_1, 0, &error) == FAILURE)
{
...
}
if (ioConfigCANAnalogSync("/canio0",0,6,ccsTRUE, &error) == FAILURE)
{
...
}
if (ioCANSendSync("/canio0", &error) == FAILURE)
{
...
}
if (ioReadAnalog (":MOTOR.current1", ¤t1, &error) == FAILURE)
{
...
}
....
if (ioReadAnalog (":MOTOR.current6", ¤t6, &error) == FAILURE)
{
...
}
SYNOPSIS #include "io.h"
ccsCOMPL_STAT ioConfigDigital(
dbSYMADDRESS signalName,
lccDEVICE_NAME deviceName,
vltUINT8 startBit,
vltUINT8 bitNumber,
ioIN_OUT inOut,
ioLEVEL level,
vltUINT32 simValue,
ccsERROR *error,
);
Initialise a digital signal.
The driver is configured according to the given parameters.
signalName <IN> Name of the signal.
deviceName <IN> Name of the associated device (maximum 19
characters).
startBit <IN> First bit (0-63).
bitNumber <IN> Number of bits (1-32).
inOut <IN> Input or output signal (ioINPUT or ioOUTPUT)
level <IN> Logical level (ioHIGH or ioLOW).
simValue <IN> Default simulation value. Value returned in
simulation mode.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_PARAMETER if bad value input parameters,
lccERR_MEMORY if memory allocation error,
lccERR_SEM if critical section entering timeout,
lccERR_DRIVER if driver function call failed,
lccERR_RANGE if simulation value out of range,
lccERR_NO_IMAGE is no image of signal in database,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
Digital signal of one bit (bit 12), input, active low
if (ioConfigDigital (":MOTOR1.upperLimit", "/acro0", 12, 1, ioINPUT,
ioLOW, &error) == FAILURE)
{
...
}
Digital signal of one bit (bit 13), output, active low
if (ioConfigDigital (":MOTOR1.brake", "/acro0", 13, 1, ioOUTPUT,
ioLOW, &error) == FAILURE)
{
...
}
Digital signal of 12 bits (bits 16 to 27), output, active high
if (ioConfigDigital (":MOTOR1.velocity", "/acro0", 16, 12, ioOUTPUT,
ioHIGH, &error) == FAILURE)
{
...
}
...
if (ioReadDigital (":MOTOR.upperLimit", &upperLimit, &error)
== FAILURE)
{
...
}
...
if (ioSetBit (":MOTOR.brake", &error) == FAILURE)
{
...
}
...
if (ioWriteDigital (":MOTOR.velocity", 1000, &error)
== FAILURE)
{
...
}
...
#include "io.h"
ccsCOMPL_STAT ioConfigMenDigital(
lccDEVICE_NAME deviceName,
vltLOGICAL terminator,
ioMEN58_PORT port,
vltLOGICAL enableTrig,
vltLOGICAL latchOnTrig,
vltLOGICAL trigOnPosTrans,
ccsERROR *error,
);
Special configuration of the MEN M58 port.
deviceName <IN> Name of the associated device (maximum 19
characters).
terminator <IN> If true signals of the device are internally
terminated
port <IN> Port for enabling terminator. Valid values
are ioMEN58_PORT_A (bits 0 - 7), ioMEN58_PORT_B
(bits 8 - 15) or ioMEN58_PORT_B (bits 16 - 23).
enableTrig <IN> If true the trig signal is enabled
latchOnTrig <IN> If true the data ports are latched on the
external trig signal
trigOnPosTrans <IN> If true the trigger is active on low to high
transition
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_PARAMETER if bad value input parameters,
lccERR_MEMORY if memory allocation error,
lccERR_SEM if critical section entering timeout,
lccERR_DRIVER if driver function call failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
ioDChangeBit() changes the state of a single bit digital output signal.
In LCU simulation mode, the hardware is not affected.
address <IN> Direct address of signal.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_SEM if critical section entering timeout,
lccERR_IO_ADDRESS if invalid signal direct address,
lccERR_SIGNAL if signal is not single bit digital output,
lccERR_PARAMETER if direct address is NULL pointer,
lccERR_DRIVER if driver function calls failed.
ioDClearBit() sets a single bit digital signal to its inactive state.
In LCU simulation mode, the hardware is not affected.
address <IN> Direct address of signal.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_SEM if critical section entering timeout,
lccERR_IO_ADDRESS if invalid signal direct address,
lccERR_SIGNAL if signal is not single bit digital output,
lccERR_PARAMETER if direct address is NULL pointer,
lccERR_DRIVER if driver function calls failed.
SYNOPSIS #include "io.h"
ccsCOMPL_STAT ioDPulseBit(
ioDIRADDRESS *address,
vltUINT32 duration,
ccsERROR *error
);
ioDPulseBit() pulses a single bit digital output signal for the
specified duration.
When the LCU is in simulation mode, the function only returns a
SUCCESS status.
address <IN> Direct address of signal.
duration <IN> Pulse duration in milliseconds. If less than one
system tick, a short pulse of about 50 microseconds
is asked to the driver.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_SEM if critical section entering timeout,
lccERR_PARAMETER if direct address is NULL pointer,
lccERR_IO_ADDRESS if invalid signal direct address,
lccERR_SIGNAL if signal is not single bit digital output,
lccERR_DRIVER if driver function calls failed.
SYNOPSIS
#include "io.h"
ccsCOMPL_STAT ioDReadAnalog(
ioDIRADDRESS *address,
vltFLOAT *value,
ccsERROR *error
);
ioDReadAnalog() returns the value of the specified analog signal.
The value is read from the driver in nominal mode and a predefined
value is returned in simulation mode.
address <IN> Direct address of the signal.
value <OUT> Variable that will contain the read value.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_SEM if critical section entering timeout,
lccERR_IO_ADDRESS if invalid signal direct address,
lccERR_PARAMETER if direct address or value is NULL pointer,
lccERR_SIGNAL if signal is not analog input,
lccERR_DRIVER if driver function calls failed.
SYNOPSIS
#include "io.h"
ccsCOMPL_STAT ioDReadDigital(
ioDIRADDRESS *address,
vltUINT32 *value,
ccsERROR *error
);
ioDReadDigital() returns the value of the specified digital signal.
The value is read from the driver in nominal mode and a predefined
value is returned in simulation mode.
address <IN> Direct address of the signal.
value <OUT> Variable that will contain the read value.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_SEM if critical section entering timeout,
lccERR_IO_ADDRESS if invalid signal direct address,
lccERR_PARAMETER if direct address or value is NULL pointer,
lccERR_SIGNAL if signal is not digital input,
lccERR_DRIVER if driver function calls failed.
ioDSetBit() sets a single bit digital signal into its active state.
In LCU simulation mode, the hardware is not affected.
address <IN> Direct address of signal.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_SEM if critical section entering timeout,
lccERR_IO_ADDRESS if invalid signal direct address,
lccERR_PARAMETER if direct address is NULL pointer,
lccERR_SIGNAL if signal is not single bit digital output,
lccERR_DRIVER if driver function calls failed.
SYNOPSIS #include "io.h"
ccsCOMPL_STAT ioDWriteAnalog(
ioDIRADDRESS *address,
vltFLOAT value,
ccsERROR *error
);
ioDWriteAnalog() sets the value of an analog output signal.
In LCU simulation mode, the hardware is not affected.
address <IN> Direct address of the signal.
value <IN> Value to be written.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_RANGE if out of range value,
lccERR_SEM if critical section entering timeout,
lccERR_IO_ADDRESS if invalid signal direct address,
lccERR_PARAMETER if direct address is NULL pointer,
lccERR_SIGNAL if signal is not single analog output,
lccERR_DRIVER if driver function calls failed.
SYNOPSIS
#include "io.h"
ccsCOMPL_STAT ioDWriteDigital(
ioDIRADDRESS *address,
vltUINT32 value,
ccsERROR *error
);
ioDWriteDigital() sets the value of a digital output signal.
In LCU simulation mode, the hardware is not affected.
address <IN> Direct address of the signal.
value <IN> Value to be written.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_RANGE if out of range value,
lccERR_SEM if critical section entering timeout,
lccERR_IO_ADDRESS if invalid signal direct address,
lccERR_PARAMETER if direct address is NULL pointer,
lccERR_SIGNAL if signal is not single bit digital output,
lccERR_DRIVER if driver function calls failed.
ioEnableInterrupt - configure and enable interrupt of the MEN M58 trig
signal
ioDisableInterrupt - disable interrupt of the MEN M58 trig signal
#include "io.h"
ccsCOMPL_STAT ioEnableInterrupt(
lccDEVICE_NAME deviceName,
FUNCPTR* routine,
vltINT32 parameter,
ccsERROR *error,
);
ccsCOMPL_STAT ioDisableInterrupt(
lccDEVICE_NAME deviceName,
ccsERROR *error,
);
Enable/disable the interrupt for the trig signal of the MEN M58 digital
I/O module.
Before enabling/disabling the interupts the trig signal shall be
configured by the function ioConfigMenDigital().
ioEnableInterrupt() enables interrupt for the trig signal.
deviceName <IN> Name of the associated device (maximum 19
characters).
routine <IN> User routine which will be called on an interrupt.
The routine will run in task mode and not in
interrupt mode.
The routine shall have the interface:
intFunc(int parameter, int mask);
where parameter is the user defined parameter and
mask is the value of the input ports.
parameter <IN> User parameter which will be passed to the user
function.
error <OUT> Returned error structure.
ioDisableInterrupt() disables interrupt for the trig signal.
deviceName <IN> Name of the associated device (maximum 19
characters).
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_PARAMETER if bad value input parameters,
lccERR_MEMORY if memory allocation error,
lccERR_SEM if critical section entering timeout,
lccERR_DRIVER if driver function call failed,
lccERR_RANGE if simulation value out of range,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
SYNOPSIS #include "io.h"
ccsCOMPL_STAT ioGetAnalogConfig(
dbSYMADDRESS signalName,
lccDEVICE_NAME deviceName,
vltUINT32 *signalNumber,
ioIN_OUT *inOut,
vltFLOAT *convertFactor,
vltFLOAT *lowerRange,
vltFLOAT *higherRange,
ioGAIN *gainFactor,
vltFLOAT *simValue,
ccsERROR *error
);
ioGetAnalogConfig() gets the configuration of an analog signal.
signalName <IN> Name of the signal.
deviceName <OUT> Name of the associated device (maximum 19
characters).
signalNumber <OUT> Hardware analog signal number (0-15).
inOut <OUT> Input or output signal (ioINPUT or ioOUTPUT).
convertFactor <OUT> Conversion factor for analog signal.
lowerRange <OUT> Lower range for output analog signals.
higherRange <OUT> Higher range for the output analog signals.
gainFactor <OUT> Gain factor for analog signal (ioGAIN_1, ioGAIN_10,
ioGAIN_100 or ioGAIN_500).
simValue <OUT> Default simulation value.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_SEM if critical section entering timeout,
lccERR_NOT_FOUND unknown signal name,
lccERR_PARAMETER if output parameter is NULL pointer,
lccERR_SIGNAL if signal is not digital,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
SYNOPSIS #include "io.h"
ccsCOMPL_STAT ioGetDigitalConfig(
const dbSYMADDRESS signalName,
lccDEVICE_NAME deviceName,
vltUINT8 *startBit,
vltUINT8 *bitNumber,
ioIN_OUT *inOut,
ioLEVEL *level,
vltUINT32 *simValue,
ccsERROR *error
);
ioGetDigitalConfig() gets the configuration of a digital signal.
signalName <IN> Name of the signal.
deviceName <OUT> Name of the associated device (maximum 19
characters).
startBit <OUT> First bit (0-63).
bitNumber <OUT> Number of bits (1-32).
inOut <OUT> Input or output signal (ioINPUT or ioOUTPUT).
level <OUT> Logical level (ioHIGH or ioLOW).
simValue <OUT> Default simulation value.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_SEM if critical section entering timeout,
lccERR_NOT_FOUND unknown signal name,
lccERR_PARAMETER if output parameter is NULL pointer,
lccERR_SIGNAL if signal is not digital,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
SYNOPSIS #include "io.h"
ccsCOMPL_STAT ioGetDirectAddress(
dbSYMADDRESS signalName,
ioDIRADDRESS *address,
ccsERROR *error
);
ioGetDirectAddress() returns the direct address of the named signal.
signalName <IN> Name of the signal to be converted.
address <OUT> Returned direct address of signal.
error <OUT> Returned error structure.
SUCCESS if everything OK
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid signal name or address pointer,
lccERR_NOT_FOUND unknown signal name,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
SYNOPSIS #include "io.h"
ccsCOMPL_STAT ioGetList(
vltUINT32 *number,
ioSIGNAL **list,
ccsERROR *error
);
ioGetList() returns the list of all configured signals.
number <OUT> Number of signals in the list.
list <OUT> Array of signal descriptions. The list is
dynamically allocated by the function. Each
description contains:
. signal name,
. signal type (ioANALOG or ioDIGITAL),
. input or output (ioINPUT or ioOUTPUT).
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_SEM if critical section entering timeout,
lccERR_PARAMETER if output parameter is NULL pointer,
lccERR_MEMORY if memory allocation error.
SYNOPSIS #include "io.h"
ccsCOMPL_STAT ioPulseBit(
dbSYMADDRESS signalName,
vltUINT32 duration,
ccsERROR *error
);
ioPulseBit() pulses a single bit digital output signal for the
specified duration.
When the LCU is in simulation mode, the function only returns a
SUCCESS status.
signalName <IN> Name of the signal.
duration <IN> Pulse duration in milliseconds. If less than one
system tick, a short pulse of about 50 microseconds
is asked to the driver.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_NOT_FOUND unknown signal name
lccERR_SEM if critical section entering timeout,
lccERR_SIGNAL if signal is not single bit digital output,
lccERR_DRIVER if driver function calls failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
SYNOPSIS #include "io.h"
ccsCOMPL_STAT ioReadAnalog(
dbSYMADDRESS signalName,
vltFLOAT *value,
ccsERROR *error
);
ioReadAnalog() returns the value of the specified analog signal.
The value is read from the driver in nominal mode and a predefined
value is returned in simulation mode.
signalName <IN> Name of the signal.
value <OUT> Variable that will contain the read value.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_NOT_FOUND unknown signal name,
lccERR_SEM if critical section entering timeout,
lccERR_SIGNAL if signal is not digital output,
lccERR_PARAMETER if output parameter is NULL pointer,
lccERR_DRIVER if driver function calls failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
SYNOPSIS #include "io.h"
ccsCOMPL_STAT ioReadAnalogRaw(
dbSYMADDRESS signalName,
vltFLOAT *value,
vltFLOAT *rawValue,
ccsERROR *error
);
ioReadAnalogRaw() returns the value of the specified analog signal.
The value is read from the driver in nominal mode and a predefined
value is returned in simulation mode.
signalName <IN> Name of the signal.
value <OUT> Variable that will contain the read value.
rawValue <OUT> Variable that will contain the raw value.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_PARAMETER if an output parameter is a NULL pointer,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System
lccERR_NO_IMAGE if no image for the signal name,
lccERR_NOT_FOUND if unknown signal name,
lccERR_SIGNAL if signal is not analog input,
lccERR_SEM if critical section entering timeout,
lccERR_DRIVER if driver function calls failed.
SYNOPSIS #include "io.h"
ccsCOMPL_STAT ioReadDigital(
dbSYMADDRESS signalName,
vltUINT32 *value,
ccsERROR *error
);
ioReadDigital() returns the value of the specified digital signal.
The value is read from the driver in nominal mode and a predefined
value is returned in simulation mode.
signalName <IN> Name of the signal.
value <OUT> Variable that will contain the read value.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_NOT_FOUND unknown signal name,
lccERR_SEM if critical section entering timeout,
lccERR_SIGNAL if signal is not digital output,
lccERR_PARAMETER if output parameter is NULL pointer,
lccERR_DRIVER if driver function calls failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
SYNOPSIS #include "io.h"
ccsCOMPL_STAT ioSetAnalogSimValue
dbSYMADDRESS signalName,
vltFLOAT simValue,
ccsERROR *error
);
ioSetAnalogSimValue() sets the simulation value of an analog input
signal.
signalName <IN> Name of the signal.
simValue <IN> New simulation value.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_RANGE if out of range simulation value,
lccERR_NOT_FOUND unknown signal name,
lccERR_SEM if critical section entering timeout,
lccERR_SIGNAL if signal is not analog input,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
ioSetBit() sets a single bit digital signal into its active state.
In LCU simulation mode, the hardware is not affected.
signalName <IN> Name of the signal.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_NOT_FOUND unknown signal name
lccERR_SEM if critical section entering timeout,
lccERR_SIGNAL if signal is not single bit digital output,
lccERR_DRIVER if driver function calls failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
SYNOPSIS #include "io.h"
ccsCOMPL_STAT ioSetDigitalSimValue(
dbSYMADDRESS signalName,
vltUINT32 simValue,
ccsERROR *error
);
ioSetDigitalSimValue() sets the simulation value of a digital input
signal.
signalName <IN> Name of the signal.
simValue <IN> The new simulation value.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_RANGE if out of range simulation value,
lccERR_NOT_FOUND unknown signal name,
lccERR_SEM if critical section entering timeout,
lccERR_SIGNAL if signal is not digital input,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
SYNOPSIS #include "io.h"
ccsCOMPL_STAT ioStartSampling(
ioSCOPE scope,
vltUINT32 number,
dbSYMADDRESS *list,
ccsERROR *error
);
ccsCOMPL_STAT ioStopSampling(
ioSCOPE scope,
vltUINT32 number,
dbSYMADDRESS *list,
ccsERROR *error
);
These functions configure the sampling of signals not configured for
events.
ioStartSampling() starts the sampling of some signals or all signals.
ioStopSampling() stops the sampling of some signals or all signals.
scope <IN> Scope of logging (ioALL or ioSPECIFIC).
number <IN> When scope is ioSPECIFIC, number of names.
list <IN> List of specific signals.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_PARAMETER if scope or number of signals invalid, or if list
is NULL pointer,
lccERR_SEM if critical section entering timeout,
lccERR_NOT_FOUND if unknown signal name,
lccERR_SIGNAL if signal is ioOUTPUT,
lccERR_INTERNAL if lcc function call failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
SYNOPSIS #include "io.h"
ccsCOMPL_STAT ioWriteAnalog(
dbSYMADDRESS signalName,
vltFLOAT value,
ccsERROR *error
);
ioWriteAnalog() sets the value of an analog output signal.
In LCU simulation mode, the hardware is not affected.
signalName <IN> Name of the signal.
value <IN> Variable that contains the value to write.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_NOT_FOUND unknown signal name,
lccERR_RANGE if out of range value,
lccERR_SEM if critical section entering timeout,
lccERR_SIGNAL if signal is not analog output,
lccERR_DRIVER if driver function calls failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
SYNOPSIS #include "io.h"
ccsCOMPL_STAT ioWriteDigital(
dbSYMADDRESS signalName,
vltUINT32 value,
ccsERROR *error
);
ioWriteDigital() sets the value of a digital output signal.
In LCU simulation mode, the hardware is not affected.
signalName <IN> Name of the signal.
value <IN> Value to be written.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_NOT_FOUND unknown signal name,
lccERR_RANGE if out of range value,
lccERR_SEM if critical section entering timeout,
lccERR_SIGNAL if signal is not digital output,
lccERR_DRIVER if driver function calls failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
lccBootResult() displays the result of the LCU Common Software
initialisation done in the boot script. It also displays the start-up
error buffer, using errPrintFirstBuffer() function.
SYNOPSIS #include "lcc.h"
ccsCOMPL_STAT lccCheckConf(
vltUINT32 *number,
lccDEVICE_NAME **device,
ccsERROR *error
);
lccCheckConf() checks that all registered devices are correctly set-up.
number <OUT> Number of devices in error.
device <OUT> Array of names of devices in error, dynamically
allocated by the function.
error <OUT> Returned error structure.
SUCCESS if everything OK
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid parameter,
lccERR_VXWORKS if cannot access a device,
lccERR_MEMORY if cannot allocate memory for the report.
lccColdStart() reboots the LCU, loads and initializes all software
and hardware modules.
It sends the command EXIT to all devices controlled by the LCU.
Corresponds to a reboot and a warm-start.
Takes the LCU subsystem to state lccSTAND_BY, lccSTAND_ALONE or
lccON_LINE.
endMode <IN> LCU mode after performing the command.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_PARAMETER if wrong parameter value,
lccERR_SEM if critical section entering timeout,
lccERR_VXWORKS if VxWorks functions calls failed (files),
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_INTERNAL if database access failed.
SYNOPSIS #include "lccProvided.h"
ccsCOMPL_STAT lccDevEnterSim(
lccDEVICE_NAME deviceName,
ccsERROR *error
);
ccsCOMPL_STAT lccDevExitSim(
lccDEVICE_NAME deviceName,
vltUINT32 *number,
lccDEVICE_NAME **device,
ccsERROR *error
);
lccDevEnterSim() sets the device simulation flag.
lccDevExitSim() resets the device simulation flag only if no other
device is currently in simulation mode. It takes the LCU to state
LOADED and sends the STOP and OFF commands to all devices.
Any active procedure changing the LCU state is interrupted when a
device exists simulation,
deviceName <IN> Device name (maximum 19 characters).
number <OUT> Number of devices with error reply or no reply
device <OUT> List of devices in error, dynamically allocated.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid device name,
lccERR_SEM if the critical section cannot be entered,
lccERR_NOT_FOUND if device not found,
lccERR_VXWORKS if VxWorks functions calls failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_DEVICE if operation to devices failed,
lccERR_INTERNAL if LCC software failed.
These functions can be called only by processes registered in the
Message System.
The caller MUST free the memory allocated for the list of devices
in error.
As the function lccDevExitSim sends commands to all software devices,
if it is called from a software device based on a Command Interpreter
(CI), lccDevExitSim must be called from a function spawned as a task
from the CI.
SYNOPSIS #include "lcc.h"
ccsCOMPL_STAT lccEnSim(
vltUINT32 *number,
lccDEVICE_NAME **device,
ccsERROR *error
);
ccsCOMPL_STAT lccDisSim(
vltUINT32 *number,
lccDEVICE_NAME **device,
ccsERROR *error
);
lccEnSim() sets the LCU in simulation mode.
lccDisSim() exits simulation mode, LCU will be in state LOADED.
number <OUT> Number of devices with error reply or no reply.
device <OUT> List of devices in error, dynamically allocated.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_PARAMETERS if invalid parameter,
lccERR_SEM if critical section entering timeout,
lccERR_VXWORKS if VxWorks functions calls failed,
lccERR_INTERNAL if lcc software failed,
lccERR_INV_ACTION if the LCU is not in the LOADED state.
lccERR_DEVICE if operation to devices failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
lccERR_INTERNAL if LCC software failed,
These functions can be called only by processes registered in the
Message System.
The caller MUST free the memory allocated for the list of devices
in error.
lccFind() searchs for the relative path name fileName under
directory given by INTROOT environment variable then if not found
under the one given by VLTROOT environment variable.
The complete path name of the file is returned if the file is found.
fileName <IN> Relative path name of file.
fullPath <OUT> Full path file name. Must be allocated by the
caller.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid parameters,
lccERR_FILE if file is not found.
SYNOPSIS #include "lcc.h"
ccsCOMPL_STAT lccGetDeviceList(
vltUINT32 *number,
lccDEVICE **list,
ccsERROR *error
);
lccGetDeviceList() reports all devices configured in the LCU.
number <OUT> Number of devices.
list <OUT> Array of devices description, dynamically allocated
by the function. Each element is composed of:
. device name,
. name of device control process,
. status of the device.
error <OUT> Returned error structure.
SUCCESS if everything OK
FAILURE, the error structure is updated with:
lccERR_NOT_REGISTERED if calling process not registered in
Message System,
lccERR_PARAMETER if invalid parameter,
lccERR_INTERNAL if cannot get direct address of devices table
or cannot read database,
lccERR_MEMORY if cannot allocate memory for the report.
The user MUST free the memory allocated for the report.
This function can be called only by processes registered in the Message
System.
SYNOPSIS #include "lcc.h"
ccsCOMPL_STAT lccSetDeviceState(
lccDEVICE_NAME deviceName,
lccDEV_MODE state,
ccsERROR *error
);
ccsCOMPL_STAT lccGetDeviceState(
lccDEVICE_NAME deviceName,
lccDEV_MODE *state,
vltLOGICAL *simulation,
ccsERROR *error
);
lccSetDeviceState() sets the state of a device.
deviceName <IN> Device name (maximum 19 characters).
state <IN> Device state (lccDEV_OFF, lccDEV_LOADED,
lccDEV_STAND_BY or lccDEV_ON_LINE).
error <OUT> Returned error structure.
lccGetDeviceState() gets the state of a device.
deviceName <IN> Device name (maximum 19 characters).
state <OUT> Device state (lccDEV_OFF, lccDEV_LOADED,
lccDEV_STAND_BY or lccDEV_ON_LINE).
simulation <OUT> True = device in simulation.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid parameter,
lccERR_NOT_FOUND if device not found,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
SYNOPSIS #include "lccProvided.h"
ccsCOMPL_STAT lccSetDevTimeout(
vltUINT32 timeout,
ccsERROR *error
);
ccsCOMPL_STAT lccGetDevTimeout(
vltUINT32 *timeout,
ccsERROR *error
);
lccSetDevTimeout() sets the device timeout value.
timeout <IN> Timeout in seconds
error <OUT> Returned error structure.
lccGetDevTimeout() returns the actual device timeout value.
timout <OUT> Timeout in seconds.
error <OUT> Returned error structure.
lccGetId() gets the name of the LCU node, its Internet address, the
name of the boot node and its Internet address from VxWorks variable
sysBootParams.
id <OUT> LCU Id.
SYNOPSIS #include "lcc.h"
ccsCOMPL_STAT lccGetStatus(
lccMODE *mode,
lccOPERATION *operation,
vltLOGICAL *initPhase,
vltLOGICAL *simulation,
vltLOGICAL *devSim,
ccsERROR *error
);
lccGetStatus() gets the current mode and operation of the LCU.
It also indicates if the LCU is in initialisation phase and in
simulation or not.
mode <OUT> Combined LCU state, one of:
. lccLOADED if LCC or any device is in the
state LOADED or if any device is in the
state OFF,
. lccSTAND_BY if LCC or any device is in the
state STAND-BY and neither LCC nor any device
is in the state OFF or LOADED,
. lccSTAND_ALONE if LCC is in the state STAND-ALONE
and all the devices are in the state ON-LINE,
. lccON_LINE if LCC is in the state ON-LINE and
all the devices are in the state ON-LINE.
operation <OUT> Current operation in progress (lccNONE,
lccCOLD_START, lccWARM_START or lccSHUTTING_DOWN).
initPhase <OUT> True = Initialisation phase.
simulation <OUT> True = LCU in simulation.
devSim <OUT> True = one or more device in simulation.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_PARAMETER if any output parameters is a NULL pointer.
lccGetVersion() gets the current version of the LCU Common Software.
The version is defined as an ASCII string in lccInternal.h header file.
version <OUT> LCC version string.
SYNOPSIS #include "lcc.h"
ccsCOMPL_STAT lccInitFull(
lccMODE endMode,
vltLOGICAL conditional,
vltLOGICAL continueOnError,
vltUINT32 *number,
lccDEVICE_NAME **device,
ccsERROR *error
);
lccInitFull() initializes all devices conditionally or not,
sends the command INIT to all devices controlled by the LCU, followed
by command STANDBY if end mode is lccSTAND_BY or by command ONLINE
if end mode is lccSTAND_ALONE or lccON_LINE.
Takes the LCU subsystem from any state to state given by endMode.
endMode <IN> LCU mode after performing the command
(lccSTAND_BY, lccSTAND_ALONE or lccON_LINE).
conditional <IN> ccsTRUE = Initialise device if only not
previously done.
continueOnError <IN> ccsTRUE = Continue with next device if
initialisationof previous device failed.
number <OUT> Number of devices with error reply or no reply.
device <OUT> List of devices in error, dynamically allocated.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_SEM if critical section entering timeout,
lccERR_VXWORKS if VxWorks functions calls failed,
lccERR_PARAMETER if invalid parameter,
lccERR_DEVICE if operation to devices failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_INTERNAL if LCC software failed.
This function can be called only by processes registered in the
Message System.
The caller MUST free the memory allocated for the list of devices
in error.
This library provides the way to replace all calls to VxWorks malloc()
and free() by lccMalloc() and lccFree() therefore allowing the tracing
of the memory usage on the LCU. Each call to malloc() of free()
leads to print out a message on the LCU console indicating how many
bytes are allocated/freed and the total number of allocated bytes.
The tool function lccPrintMemory() displays the all memory partitions
up to 5000 entries.
SYNOPSIS #include "lcc.h"
ccsCOMPL_STAT lccOnLine(
vltUINT32 *number,
lccDEVICE_NAME **device,
ccsERROR *error
);
lccOnLine() sends the command ON_LINE to all devices controlled by
the LCU.
Takes the LCU from lccSTAND_BY to lccON_LINE.
number <OUT> Number of devices with error reply or no reply
device <OUT> List of devices in error, dynamically allocated.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_SEM if critical section entering timeout,
lccERR_VXWORKS if VxWorks functions calls failed,
lccERR_INV_ACTION if the LCU is not in the LOADED state,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_DEVICE if operation to devices failed,
lccERR_INTERNAL if lcc software failed.
SYNOPSIS #include "lcc.h"
ccsCOMPL_STAT lccReconfigure(
dbCONFIG_MODE mode,
char *buffer,
vltUINT32 size,
vltUINT32 *number,
lccDEVICE_NAME **device,
ccsERROR *error
);
lccReconfigure() does the same as the command lccShutdown and
additionally reconfigures the LCU.
Takes the LCU subsystem from state lccSTAND_BY, lccSTAND_ALONE or
lccON_LINE to state lccLOADED.
mode <IN> Input mode. Only dbCONFIG_FILE is supported
buffer <IN> File name. Same data format as
for dbRestoreFile().
size <IN> Note used
number <OUT> Number of devices with error reply or no reply.
device <OUT> List of devices in error, dynamically allocated.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid mode or buffer is NULL,
lccERR_SEM if critical section entering timeout,
lccERR_VXWORKS if VxWorks functions calls failed,
lccERR_DEVICE if operation to devices failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_INTERNAL if LCC software failed,
and all the errors returned by dbRestoreFile().
This function can be called only by processes registered in the
Message System.
The caller MUST free the memory allocated for the list of devices
in error.
SYNOPSIS #include "lcc.h"
ccsCOMPL_STAT lccRegisterDevice(
char *name,
void *probe,
lccDEVICE_ACCESS access,
lccDEVICE_CONFIG configIn,
lccDEVICE_CONFIG configOut,
ccsERROR *error
);
lccRegisterDevice() registers an I/O device.
The Device Module manages a list of devices. This function adds the
device to the list of devices.
A device cannot be registered twice.
The purpose of the list is to verify that all devices are installed
properly and remain installed.
All I/O devices shall call this function at installation. The probe
address shall be a read accessible address on the hardware device.
This will be used to check that the hardware is installed.
name <IN> Device name (maximum 19 characters).
probe <IN> Probe address.
access <IN> Access mode (lccBYTE_ACCESS, lccWORD_ACCESS or
lccLONG_WORD_ACCESS).
configIn <IN> Input configuration, used for analog board, one of:
. lccBIPOLAR_10V: -10V...+10V,
. lccUNIPOLAR_10V: 0V...+10V,
. lccBIPOLAR_5V: -5V...+5V,
. lccUNIPOLAR_5V: 0V...+5V,
. lccCONFIG_NONE: for digital devices.
configOut <IN> Output configuration, used for analog board (as
input configuration).
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid parameters,
lccERR_SEM if the critical section cannot be entered,
lccERR_IN_USE if device already registered,
lccERR_MEMORY if cannot allocate memory room for device.
lccReboot() reboots the LCU, loads and initalises all software modules.
All activities of the LCU are aborted.
Takes the LCU to state lccLOADED.
sysRes <IN> True = generate a SYSRESET signal on the VME bus.
error <OUT> Returned error structure.
None if the LCU reboots.
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid sysRes.
SYNOPSIS #include "lcc.h"
ccsCOMPL_STAT lccReload(
char *fileName,
vltUINT32 *number,
lccDEVICE_NAME **device,
ccsERROR *error
);
lccReload() does the same as the command lccShutdown and additionally
reloads the LCU software.
Takes the LCU subsystem from state lccSTAND_BY, lccSTAND_ALONE or
lccON_LINE to state lccLOADED.
fileName <IN> Complete pathname containing all modules to load.
number <OUT> Number of devices with error reply or no reply
device <OUT> List of devices in error, dynamically allocated.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid parameter,
lccERR_SEM if critical section entering timeout,
lccERR_VXWORKS if VxWorks functions calls failed,
lccERR_DEVICE if operation to devices failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_INTERNAL if LCC software failed,
This function can be called only by processes registered in the
Message System.
The caller MUST free the memory allocated for the list of devices
in error.
Cautions from reld() and unldLib man pages:
If the file was originally loaded using a complete pathname,
then reld() will use the complete name to locate the file.
If the file was originally loaded using a partial pathname,
then the current working directory must be changed to the
working directory in use at the time of the original load.
Once the module is unloaded, any calls to routines in
that module from other modules will fail unpredictably.
The user is responsible for ensuring that no modules are
unloaded that are used by other modules.
The routine lccRound rounds a double-precision value <x> to the
nearest integral value.
The routine lccIRound rounds a double-precision value <x> to the
nearest integer value.
The routine lccRound returns the double-precision representation
of <x> rounded to the nearest integral value.
The routine lccIRound returns The integer nearest to <x>.
SYNOPSIS #include "lcc.h"
ccsCOMPL_STAT lccSelfTest(
vltUINT32 *number,
lccDEVICE_NAME **device,
ccsERROR *error
);
lccSelfTest() runs automatically at start-up and on request.
Performs tests of the common hardware like CPU-boards, timing interface
boards, checks that the boards configured with the LCU are present and
configured properly. Then sends a self-test command to all devices.
number <OUT> Number of devices with error reply or no reply.
device <OUT> List of devices in error, dynamically allocated.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_SEM if semaphore access failed,
lccERR_MEMORY if dynamic memory allocation failed,
lccERR_DEVICE if operation to devices failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_INTERNAL if command execution failed.
This function can be called only by processes registered in the
Message System.
The caller MUST free the memory allocated for the list of devices
in error.
SYNOPSIS #include "lcc.h"
ccsCOMPL_STAT lccShutdown(
vltUINT32 *number,
lccDEVICE_NAME **device,
ccsERROR *error
);
lccShutdown() stops all HW and SW activities and initialises LCU SW.
It sends the commands STOP and OFF to all devices controlled by the LCU.
Takes the LCU subsystem from state lccSTAND_BY, lccSTAND_ALONE or
lccON_LINE to state lccLOADED.
number <OUT> Number of devices with error reply or no reply
device <OUT> List of devices in error, dynamically allocated.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_SEM if critical section entering timeout,
lccERR_VXWORKS if VxWorks functions calls failed,
lccERR_DEVICE if operation to devices failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_INTERNAL if LCC software failed.
This function can be called only by processes registered in the
Message System.
The caller MUST free the memory allocated for the list of devices
in error.
SYNOPSIS #include "lcc.h"
ccsCOMPL_STAT lccStandAlone(
vltUINT32 *number,
lccDEVICE_NAME **device,
ccsERROR *error
);
lccStandAlone() sends the command ONLINE to all devices controlled
by the LCU.
Takes the LCU from lccSTAND_BY to lccSTAND_ALONE mode.
number <OUT> Number of devices with error reply or no reply
device <OUT> List of devices in error, dynamically allocated.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_SEM if critical section entering timeout,
lccERR_VXWORKS if VxWorks functions calls failed,
lccERR_INV_ACTION if current LCU mode cannot support received
command,
lccERR_DEVICE if operation to devices failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_INTERNAL if LCC software failed.
This function can be called only by processes registered in the
Message System.
The caller MUST free the memory allocated for the list of devices
in error.
SYNOPSIS #include "lcc.h"
ccsCOMPL_STAT lccStandBy(
vltUINT32 *number,
lccDEVICE_NAME **device,
ccsERROR *error
);
lccStandBy() sends the command STAND_BY to all devices controlled
by the LCU.
Takes the LCU from lccSTAND_ALONE or lccON_LINE to lccSTAND_BY mode.
number <OUT> Number of devices with error reply or no reply
device <OUT> List of devices in error, dynamically allocated.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_SEM if critical section entering timeout,
lccERR_VXWORKS if VxWorks system call fails,
lccERR_INV_ACTION if the LCU is not in the LOADED state,
lccERR_DEVICE if operation to devices failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_INTERNAL if LCC software failed.
This function can be called only by processes registered in the
Message System.
The caller MUST free the memory allocated for the list of devices
in error.
SYNOPSIS #include "lcc.h"
ccsCOMPL_STAT lccStop(
vltUINT32 *number,
lccDEVICE_NAME **device,
ccsERROR *error
);
lccStop() sends the command STOP to all devices controlled by the LCU.
The LCU mode stays unchanged.
number <OUT> Number of devices with error reply or no reply
device <OUT> List of devices in error, dynamically allocated.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_VXWORKS if VxWorks functions calls failed,
lccERR_DEVICE if operation to devices failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_INTERNAL if LCC software failed.
This function can be called only by processes registered in the
Message System.
The caller MUST free the memory allocated for the list of devices
in error.
SUCCESS if everything OK
FAILURE, the error structure is updated with:
lccERR_SEM if critical section cannot be entered,
lccERR_VXWORKS if the watchdog cannot be deleted,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_INTERNAL if the database cannot be written or watchdog
cannot be started.
lccSymFindByName,
lccFindFunctionEntry,
lccFindSymbolAddress
- find symbol address in Global Symbol Table
#include "lccVxwArch.h"
STATUS lccSymFindByName(
IN SYMTAB_ID symTblId,
IN char *name,
OUT char **pAddr,
OUT SYM_TYPE *pType)
STATUS lccFindSymbolAddress(
IN char *symName,
OUT char **symAddr)
STATUS lccFindFunctionEntry(
IN char *fctName,
OUT FUNCPTR *fctAddr)
Idem symFindByName(2) with auto CPU selector.
This routine searches in the symbol table <symTblId> for a
symbol matching a specified <name>.
If the symbol is found, its value and type are copied to
<pValue> and <pType>.
<symTblId> IN : symbol table ID
<name> IN : symbol name to resolve
<pAddr> OUT : symbol address
<pType> OUT : symbol type
If the symbol table ID <symTblId> is NULL, the system symbol
table <sysSymTbl> is searched.
If <pAddr> or <pType> is NULL, the corresponding value
is not returned.
If multiple symbols have the same name but differ in type,
the routine chooses the matching symbol most recently
added to the symbol table.
The functions lccFindFunctionEntry() and lccFindSymbolAddress() are
identical to lccSymFindByName() but offer a simpler interface.
<name> IN : function / symbol name to resolve
<addr> OUT : function entry / symbol address
#include "lccTaskLib.h"
STATUS lccTaskCreate ( int *pTid, int stackSize )
STATUS lccTaskActive ( int tid, char *tskName,
int priority, int options, FUNCPTR entry,
int arg1,int arg2,int arg3,int arg4,int arg5,
int arg6,int arg7,int arg8,int arg9,int arg10 )
STATUS lccTaskVerify ( int tid )
STATUS lccTaskDelete ( int tid )
STATUS lccTaskRemove ( int tid )
int lccTaskId ( int tid )
These functions are wrappers around VxWorks Task Lib functions.
Since the task creation mechanism is taken off the VxWorks, the
memory allocation for the task and its stack is under application
control. This minimizes the fragmentation resulting from successive
task spawns for the same task as the memory is allocated once.
lccTaskCreate() is the first function to invoke so as to allocate the
required memory for the task and its stack.
OUT pTid : pointer to the task Id. It will be set with the address
of the allocated memory.
IN stackSize : size of the stack in bytes.
lccTaskActive() is the function that initializes and activates the task.
It behaves as taskSpawn().
IN tid : task Id as created by lccTaskCreate().
Other arguments as of taskSpawn().
lccTaskVerify() is the wrapper to taskIdVerify().
IN tid : task Id as created by lccTaskCreate().
lccTaskDelete() is the wrapper to taskDelete().
IN tid : task Id as created by lccTaskCreate().
lccTaskRemove() returns the allocated resources to the system.
It invokes taskDelete() if the task was running.
IN tid : task Id as created by lccTaskCreate().
lccTaskId() returns the corresponding vxWorks task Id.
IN tid : task Id as created by lccTaskCreate().
The value of <tid> used by these functions is *not* identical to the
task id returned by taskSpawn()!
The allocated resources (memory) are *not* returned automatically to the
system after a task created by lccTaskCreate() is not running any longer.
SYNOPSIS #include "lcc.h"
ccsCOMPL_STAT lccWaitFirstInit(
vltUINT32 timeOut,
lccDEVICE_NAME device,
ccsERROR *error
);
lccWaitFirstInit() waits until the next device has initialised or the
given time-out expires.
It returns the name of the next device that has initialised.
timeOut <IN> Time-out (in seconds).
device <OUT> Name of the device initialised.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid parameter,
lccERR_SEM if cannot protect the function,
lccERR_TIMEOUT if initialisation not complete.
lccWaitFullInit() waits until all devices have initialised or the
time-out expires.
timeOut <IN> Time-out (in seconds).
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_SEM if cannot protect the function,
lccERR_TIMEOUT if initialisation not complete.
SYNOPSIS #include "lcc.h"
ccsCOMPL_STAT lccWarmStart(
lccMODE endMode,
vltUINT32 *number,
lccDEVICE_NAME **device,
ccsERROR *error
);
lccWarmStart() initializes all software and hardware modules. It takes
the LCU from state lccLOADED to state lccSTAND_BY, lccSTAND_ALONE or
lccON_LINE.
It sends an INIT command to all devices controlled by the LCU, followed
by command STANDBY if end mode is lccSTAND_BY or by command ONLINE if
end mode is lccSTAND_ALONE or lccON_LINE.
endMode <IN> LCU mode after performing the command
(lccSTAND_BY, lccSTAND_ALONE or lccON_LINE).
number <OUT> Number of devices with error reply or no reply.
device <OUT> List of devices in error, dynamically allocated.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_PARAMETER if wrong parameter value,
lccERR_SEM if critical section entering timeout,
lccERR_VXWORKS if VxWorks functions calls failed,
lccERR_INV_ACTION if current LCU mode s not LOADED,
lccERR_DEVICE if initialization of devices failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_INTERNAL if LCC software failed.
This function can be called only by processes registered in the
Message System.
The caller MUST free the memory allocated for the list of devices
in error.
#include "log.h"
ccsCOMPL_STAT logData(
ccsMODULEID moduleId,
vltUINT8 logId,
char *logText
);
ccsCOMPL_STAT logData1 ( const ccsMODULEID moduleId,
vltUINT8 logId,
const char *logText
... )
logData() adds a logging message to the queue of messages.
logData1 :
The application provides a string containing format patterns to be used to
actually create the final log message. The parameters following 'logText' are
used as arguments to create the log message (as by printf)
moduleId <IN> Name of module requesting the log.
logId <IN> Log format definition identifier.
logText <IN> ASCII string containing the data to be logged
The application provides the string logtext describing the information
to be logged. The routine automatically concatenates this with the
'logging system' part.
logtext string format is application specific.
The 'logging system' part contains information on : timeStamp,
environment name, moduleId, process Name and number.
Parameter moduleId can be used for filtering of the log file.
LogId can be used to identify the format of the log. It is not used by
the log system itself, but can be used for filtering of the log file.
LCC uses internally logIds 1-10. LogIds 0-100 are reserved for LCC and
CCS.
LogIds 101- are available for applications.
In case of get time stamp error, time will be filled with zeroes.
In case of logging queue write error, the logs will be sent to the
logging file, defined at boot. If this also fails, they will be
printed on the LCU console.
logEnAnalog, logDisAnalog, logEnDigital, logDisDigital - enable or disable logging of analog and digital signals
SYNOPSIS #include "log.h"
ccsCOMPL_STAT logEnAnalog(
logSCOPE scope,
vltUINT32 number,
dbSYMADDRESS *list,
ccsERROR *error
);
ccsCOMPL_STAT logDisAnalog(
logSCOPE scope,
vltUINT32 number,
dbSYMADDRESS *list,
ccsERROR *error
);
ccsCOMPL_STAT logEnDigital(
logSCOPE scope,
vltUINT32 number,
dbSYMADDRESS *list,
ccsERROR *error
);
ccsCOMPL_STAT logDisDigital(
logSCOPE scope,
vltUINT32 number,
dbSYMADDRESS *list,
ccsERROR *error
);
These functions configure the logging of change of value of digital
and analog signals.
logEnAnalog() enables the logging of change of value of some analog
signals or all the analog signals.
logDisAnalog() disables the logging of some analog signals or all
analog signals.
logEnDigital() enables the logging of change of value of some digital
signals or all the digital signals.
logDisDigital() disables the logging of some digital signals or all
digital signals.
scope <IN> Scope of logging (logALL or logSPECIFIC).
number <IN> When scope is logSPECIFIC, number of names.
list <IN> List of specific signals.
error <OUT> Returned error structure.
SUCCESS if everything ok
FAILURE, the error structure is updated with:
lccERR_PARAMETER if scope or number of signals invalid, or if list
is NULL pointer,
lccERR_SEM if critical section entering timeout,
lccERR_NOT_FOUND if unknown signal name,
lccERR_INTERNAL if lcc function call failed,
lccERR_SIGNAL if signal type mismatched when specific
signal are enabled,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System.
SYNOPSIS #include "log.h"
ccsCOMPL_STAT logEnMsg(
logSCOPE scope,
ccsPROCNAME procName,
ccsERROR *error
);
ccsCOMPL_STAT logDisMsg(
logSCOPE scope,
ccsPROCNAME procName,
ccsERROR *error
);
logEnMsg() enables logging of messages to/from a given process or
all processes.
logDisMsg() disables logging of messages to/from a given process or
all processes.
scope <IN> Scope of logging (logALL for all processes or
logSPECIFIC for a specific process).
procName <IN> Process name if specific (maximum 19 characters).
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid scope,
lccERR_PROC_NAME if invalid procName,
lccERR_NOT_REGISTERED if process is not registered,
lccERR_SEM if critical section entering timeout.
SYNOPSIS #include "log.h"
ccsCOMPL_STAT logEnReadDb(
logSCOPE scope,
vltUINT32 number,
dbSYMADDRESS *list,
ccsERROR *error
);
ccsCOMPL_STAT logDisReadDb(
logSCOPE scope,
vltUINT32 number,
dbSYMADDRESS *list,
ccsERROR *error
);
ccsCOMPL_STAT logEnWriteDb(
logSCOPE scope,
vltUINT32 number,
dbSYMADDRESS *list,
ccsERROR *error
);
ccsCOMPL_STAT logDisWriteDb(
logSCOPE scope,
vltUINT32 number,
dbSYMADDRESS *list,
ccsERROR *error
);
logEnReadDb() enables the logging of all read accesses made in the
database, or on the points (i.e. all its attributes) and attributes
given in the list.
scope <IN> Scope of the logging : all the database or given list.
number <IN> Number of elements in the list (specific scope).
list <IN> List of points and attributes (specific scope).
error <OUT> Returned error structure.
logDisReadDb() disables the logging of all read accesses made in the
database, or on the points (i.e. all its attributes) and attributes
given in the list.
scope <IN> Scope of the logging : all the database or given list.
number <IN> Number of elements in the list (specific scope).
list <IN> List of points and attributes (specific scope).
error <OUT> Returned error structure.
logEnWriteDb() enables the logging of all write accesses made in the
database, or on the points (i.e. all its attributes) and attributes
given in the list.
scope <IN> Scope of the logging : all the database or given list.
number <IN> Number of elements in the list (specific scope).
list <IN> List of points and attributes (specific scope).
error <OUT> Returned error structure.
logDisWriteDb() disables the logging of all write accesses made in the
databas, or on the points (i.e. all its attributes) and attributes
given in the liste.
scope <IN> Scope of the logging : all the database or given list.
number <IN> Number of elements in the list (specific scope).
list <IN> List of points and attributes (specific scope).
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE if something wrong. The error structure is updated with :
lccERR_PARAMETER if scope not logALL or logSPECIFIC,
lccERR_REMOTE if in a remote database,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_INV_NAME if invalid point/attribute name syntax.
SYNOPSIS #include "log.h"
ccsCOMPL_STAT logFitsAction ( const ccsMODULEID module,
const logDICTIONARY fitsDict,
const logCATEGORY fitsCat,
const logFITS_KEY fitsSys,
const logACTION fitsAction)
Generates a log describing an action : typical examples are opening
and closing operations or moving the telescope.
module <IN> Module's name.
fitsDict <IN> Defines the dictionary where to check the correctness
of the Fits action verb and keywords.
This information is stored internally and it is used
as default value when this is NULL.
fitsCat <IN> Category : it is pre-defined and designated by a
3-letter abbreviation.
Examples of 'category' are DET (Detector)
TEL (Telescope) ADA (Adapter) or INS (Instrument)
fitsSys <IN> Subsystem : identifies a component in a category and
can consist of zero or at maximum 2 words.
Several subsystems are separated by ",".
Examples of 'subsystems' are GRIS (grism), LAMP,
CCD (detector Chip) or EXPO (Exposure Descrition)
fitsAction <IN> Single verb defining the action
The log will be stored in the following format :
hh:mm:ss> -action category [subsystem(s)] /comment [mask]
Note That :
- The 'subsystem' parameter is optional
- The 'comment' is taken from the dictionary.
FAILURE When a parameter is not correct : a log is generated
specifying the wrong parameter: either a NULL pointer
or the parameter is too long.
SUCCESS .
logFitsSetMask("TE1");
logFitsAction("mod","TCS","TEL","SOFTW","START");
The next call will use the default value "TCS" as dictionary name
logFitsAction("mod",NULL,"TEL","","PRESET");
SYNOPSIS #include "log.h"
ccsCOMPL_STAT logFitsComment ( const ccsMODULEID module,
const char *who,
const char *text)
Store a string as a Operational Log in Fits Format describing a
comment : the comment can contain a tag identifying 'who'
generated the log.
module <IN> Module's name.
who <IN> Defines 'who' generated the code : logNULL, logSTAFF
logOBSERVER , logREMOTE_CONTROL, logNIGHT_ASSISTANT.
text <IN> Text to be inserted as comment
Two different record formats are provided according to the value of
parameter <who>.
If <who> = logNULL the format is
hh:mm:ss>/free-format comment up to 50 chars.
otherwise
hh:mm:ss>/COMMENT NN free-format comment, possibly spanning several lines
Where NN is a two letter code specifying <who> generated the code.
SUCCESS .
FAILURE For parameter with NULL pointers
In this case a log describing the error condition is generated.
logFitsComment("mod",logNULL,"This is my comment");
logFitsComment("mod",logREMOTE_CONTROL,"Let's sleep a bit");
SYNOPSIS #include "log.h"
ccsCOMPL_STAT logFitsEvent ( const ccsMODULEID module,
logFITS_TYPE what,
const char *text)
This routine provides a way to log a brief description associated to
'unforseen' events or 'recovery' actions.
module <IN> Module's name.
what <IN> Type of log : FITS_UNFORSEEN, FITS_RECOVERY
text <IN> Text to be inserted as comment. The maximum length
of the string is logFITS_TEXT_LEN.
'Unforseen' events are typically associated to failure conditions
and are logged with the following format :
hh:mm:ss>/UNFORSEEN: followed by a brief description of the event
Very often a there is a 'Recovery' action follows in response to
an 'Unforseen' event and are logged as follows :
hh:mm:ss>/RECOVERY: followed by a brief description of the action
SUCCESS .
FAILURE For parameter with NULL pointers
In this case a log describing the error condition is generated.
logFitsEvent("mod",FITS_UNFORSEEN,"Calibration Lamp not available");
logFitsEvent("mod",FITS_RECOVERY,"Got new calibration lamp");
logFitsParRecord , logIntParRecord , logRealParRecord - Logs a parameter as Operational Log in Fits Format
SYNOPSIS #include "log.h"
ccsCOMPL_STAT logFitsParRecord ( const ccsMODULEID module,
const logDICTIONARY fitsDict,
const logCATEGORY fitsCat,
const logFITS_KEY fitsSys,
const logFITS_KEY fitsParam,
const void *value)
ccsCOMPL_STAT logIntParRecord ( const ccsMODULEID module,
const logDICTIONARY fitsDict,
const logCATEGORY fitsCat,
const logFITS_KEY fitsSys,
const logFITS_KEY fitsParam,
int value)
ccsCOMPL_STAT logRealParRecord ( const ccsMODULEID module,
const logDICTIONARY fitsDict,
const logCATEGORY fitsCat,
const logFITS_KEY fitsSys,
const logFITS_KEY fitsParam,
double value)
Generate a log recording information on the status of the components
of a given system : typical examples are wind speed, guide star RA/DEC
or exposure number.
logFitsParRecord
Basic routine supporting the logging of parameters for the following
data types : vltINT32, vltDOUBLE, vltLOGICAL or a string.
logIntParRecord
Extension supporting the logging of parameters defined in the VLT
integer data types : vltINT8, vltINT16, vltINT32
logRealParRecord
Extension supporting the logging of parameters defined in the VLT
'real' data types : vltFLOAT, vltDOUBLE.
Parameter description :
module <IN> Module's name.
fitsDict <IN> Defines the dictionary where to check the correctness
of the Fits action verb and keywords.
This information is stored internally and it is used
as default value when this is NULL.
fitsCat <IN> Category : it is pre-defined and designated by a
3-letter abbreviation.
Examples of 'category' are DET (Detector)
TEL (Telescope) ADA (Adapter) or INS (Instrument)
fitsSys <IN> Subsystem : identifies a component in a category and
can consist of zero or at maximum 2 words.
Several subsystems are separated by ",".
Examples of 'subsystems' are GRIS (grism), LAMP,
CCD (detector Chip) or EXPO (Exposure Descrition)
fitsParam <IN> Identifies the parameter withing the subsystem.
Examples of keywords for 'parameter' are ALT (Altitude)
TEMP (Temperature) or WLEN (Wavelength)
value <IN> The current value associated to the parameter.
The log will be stored in the following format :
hh:mm:ss>category [subsystem(s) parameter]=value / comment
Note That :
- The 'subsystem' parameter is optional
- The 'comment' is taken from the data dictionary.
- The final format for 'value' is taken from the data dictionary.
FAILURE When a parameter is not correct : a log is generated
specifying the wrong parameter: either a NULL pointer
or the parameter is too long.
SUCCESS .
vltDOUBLE azAngle;
vltDOUBLE decRef;
logFitsSetMask("TE1");
logFitsParRecord("mod","TCS","TEL","POS","ALT",&azAngle);
The next call will use the default value "TCS" as dictionary name
logFitsParRecord("mod",NULL,"TEL","REF","DEC",&decRef);
Sets the default value for the mask parameter used to log
Operational Logs in FITS format. This parameter appears always
as last string of the log.
mask <IN> String representing the log mask. The string must be
at most logMASK_LEN chars long.
SYNOPSIS #include "log.h"
ccsCOMPL_STAT logGetEventList(
vltUINT32 *number,
logEVENT **list,
ccsERROR *error
);
logGetEventList() reports all events enabled for logging.
Five types of event exist: message, database read, database write,
digital I/O and analog I/O. The events are sorted by type.
number <OUT> Number of events in list.
list <OUT> Array of auotmatic logging descriptions, each
each composed of:
. event type (logMESSAGE, logDB_READ,
logDB_WRITE, logDIGITAL_IO or logANALOG_IO),
. log scope (logALL or logSPECIFIC),
. name of process if event type is logMESSAGE,
name of database attribute if event type is
logDB_READ or logDB_WRITE, otherwise name of
signal.
The array is dynamically allocated by the function.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid parameters,
lccERR_MEMORY if cannot allocate memory for the report,
lccERR_SEM if log semaphore not reachable.
msgHandleBreak() is the default signal handler for BREAK command. The
only action performed by this default handler is to log a message.
It is connected to SIGUSR1 signal by ccsInit() if no signal handler
for BREAK command is provided.
msgHandleKill() is the default signal handler for KILL command. It
exits the Message System and deletes the task.
It is connected to SIGUSR2 signal by ccsInit() if no signal handler
for KILL command is provided.
The following example is the default kill handler:
#include "CCS.h"
void msgHandleKill(void)
{
ccsERROR errorStructure;
ccsERROR *error = &errorStructure;
errResetStack(error);
logData(lccModuleId, lccLOG_STRING, msgHandleKillName);
if (ccsExit(error) != SUCCESS)
ERROR_LOG(lccERR_INTERNAL, msgHandleKillName, "ccsExit", 0);
taskDelete(taskIdSelf());
}
In case the task is a Command Interpreter, the kill handler should be
as folows:
#include "CCS.h"
void cmdHandleKill(void)
{
logData(lccModuleId, lccLOG_STRING, cmdHandleKillName);
cmdTerminate();
}
SYNOPSIS #include "msgProvided.h"
ccsCOMPL_STAT msgGetProcIdByName (
const ccsENVNAME envName,
const ccsPROCNAME procName,
msgPROCESSID *procId,
ccsERROR *error
)
msgGetProcIdByName() retrieves the process ID for the process
specified by its process name.
envName <IN> environment name; if a NULL pointer or ccsLOCAL_ENV
the process-ID of <procName> running in the local
environment is returned;
procName <IN> name of process for which to retrieve the process-ID
procId <OUT> process ID to be returned, which is a structure defined
as follows
typedef struct {
ccsENVNAME envname;
ccsPROCNUM procnum;
vltUINT8 reserved;
} msgPROCESSID;
envName is a character string defining the environment
in which the process is running.
procnum is the process number uniquely identifying the
process within its own environment.
error <OUT> error handling data structure
SYNOPSIS #include "msg.h"
ccsCOMPL_STAT msgParseMsg(
msgHEADER *message,
vltUINT8 *msgType,
msgCMD **command,
msgCMDID *commandId,
msgPROCESSID **orgId,
vltLOGICAL *lastReply,
char **buffer,
msgLENGTH *buflen,
ccsERROR *errmsg,
ccsERROR *error
);
msgParseMsg() returns a set of pointers to the different sections of
a message.
message <IN> Pointer to message to parse.
msgType <OUT> Message type.
command <OUT> Pointer to command.
commandId <OUT> CommandId.
orgId <OUT> Pointer to originator processId.
lastReply <OUT> Last reply flag (only for msgREPLY message type).
buffer <OUT> Pointer to buffer.
buflen <OUT> Length of buffer.
errmsg <OUT> Pointer to error structure in msg.
error <OUT> Returned error structure in case of parse error.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid parameter,
lccERR_MSG_TYPE if invalid message type.
#include "msg.h"
...
ccsERROR error;
ccsERROR errmsg;
msgHEADER *myMsg;
vltUINT8 msgType;
msgCMD *command;
msgCMDID commandId;
msgPROCESSID *orgId;
char *buffer;
msgLENGTH buflen;
vltLOGICAL last;
...
if (ccsInit(...) == FAILURE)
{
Process error condition
}
...
if (msgRecvMsg(...) == FAILURE)
{
Process error condition
}
...
if (msgParseMsg(myMsg, &msgType, &command, &commandId, &orgId,
&last, &buffer, &buflen, &errmsg, &error) == FAILURE)
{
Process error condition
}
...
SYNOPSIS #include "msg.h"
ccsCOMPL_STAT msgPing(
ccsENVNAME envName,
ccsPROCNAME procName,
vltLOGICAL reply,
ccsERROR *error
);
msgPing() checks if <procName> running on <environment> is alive
sending a PING-command to that process.
envName <IN> Name of environment where the process is running.
procName <IN> Name of process.
reply <IN> Flag indicating whether a reply should be returned
or not.
error <OUT> Returned error structure.
An application (<procName>, destination of the PING command) has not
to handle the PING-command, it is internally handled by the message
system.
If <reply> is set, a reply is returned to the originator of the PING
command, which has to process it.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid parameters.
if (msgPing(envName, procName, &error) == FAILURE)
{
... process not running ...
... error processing ...
}
else
{
... normal processing ...
}
SYNOPSIS #include "msg.h"
ccsCOMPL_STAT msgRecvMsg(
msgRECEIVEFILTER *filter,
msgTIMEOUT timeout,
msgHEADER **message,
ccsERROR *error
);
ccsCOMPL_STAT msgSetFilter()
const ccsENVNAME envname,
const ccsPROCNAME procName,
msgFILTERTYPE filterType,
msgCMDID commandId,
msgCMD command,
msgRECEIVEFILTER *filter,
ccsERROR *error
);
msgRecvMsg() read a message using filtering criteria.
filter <IN> Provides filtering information (msgANY_MESSAGE,
msgANY_REPLY, msgREPLIES_FROM, msgREPLY_FOR_CMD,
msgREPLY_FOR_CMDID, msgACK_FROM, msgPROCNAME_FROM,
msgPROCNUM_FROM).
timeout <IN> Maximum waiting time (number of milliseconds or
msgNO_TIMEOUT or msgNO_WAIT).
message <OUT> Pointer to the message. The message buffer is
allocated by msgRecvMsg() and must be deallocated
by the caller. This works differently from CCS
where the next call to msgRecvMsg() deallocates
the message buffer.
error <OUT> Returned error structure.
msgSetFilter() setup a receive filter.
envname <IN> Source environment name (maximum 7 characters).
ccsLOCAL_ENV defaults to local environment.
procName <IN> Source process name (maximum 19 characters).
filterType <IN> Filter type (msgANY_MESSAGE, msgANY_REPLY,
msgREPLIES_FROM, msgREPLY_FOR_CMD or
msgREPLY_FOR_CMDID).
commandId <IN> Command Id in case of msgREPLY_FOR_CMDID.
command <IN> Command in case of msgREPLY_FOR_CMD.
filter <OUT> Provides filtering information.
error <OUT> Returned error structure.
SUCCESS if everything OK
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid filter or timeout parameters,
lccERR_NOT_REGISTERED if process is not registered,
lccERR_MEMORY if memory allocation failed,
lccERR_Q_EMPTY if no matching message in input queue,
lccERR_TIMEOUT if timeout expired before a matching message arrived,
lccERR_SEM if cannot enter critical section,
lccERR_QSERVER if Q server error,
lccERR_INTERNAL if LCC software failed.
These functions can be called only by processes registered in the
Message System.
Applications have to free the message buffer after use.
EVENT and ALARMS messages are considered as replies for message
filtering.
#include "msg.h"
...
ccsERROR error;
msgHEADER *myMsg;
msgRECEIVEFILTER myfilter;
if (ccsInit(...) == FAILURE)
{
Process error condition
}
...
myFilter.filterType = msgANY_MESSAGE;
...
if (msgRecvMsg(&myfilter, msgNO_TIMEOUT, &myMsg, &error) == FAILURE)
{
Process error condition
}
...
The message must be explicitly freed by the application
free(myMsg);
Put a message back into the input queue.
message <IN> Message to be requeued.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_PARAMETER if message is NULL,
lccERR_MEMORY if memory allocation failed,
lccERR_MSG_SIZE if message too big,
lccERR_INTERNAL if timer Get UTC function error,
lccERR_QSERVER if Q server error.
The source process Id of the requeued message is the receive process
itself (i.e. source equals destination).
Be careful for message filtering.
Requeue a requeued message simply put the message again into the input
queue of the receive process.
SYNOPSIS #include "msg.h"
ccsCOMPL_STAT msgScheduleProcess(
ccsENVNAME envName,
char *runstring,
ccsRUNOPT *runOptions
ccsERROR *error
);
Execute the specified runstring as a process on the given target
environment.
A SCHEDULE command is sent to the msgServer process on the target
environment that will schedule the process. The runstring is an Ascci
string composed by all process parameters, separated by commas. The
process will parse the string.
envName <IN> Where process must be started (maximum 19 characters).
ccsLOCAL_ENV defaults to local environment.
runstring <IN> Ascii string of scheduled process name and
parameters. The string shall contain the name of the
process to schedule plus the run time parameters
separated by space. The run time parameters can be of
type string, integer or real. Strings must be enclosed
in double quotes, e.g. "myTask \"string\" 12 123.5".
runOptions <IN> Runoption structure as defined in msg.h.
If "zeroed" remote env will use defaults.
Runoption is a union depending on if destination
environment is unix or VxWorks.
vxto
vltUINT32 priority - task priority on VxWorks
vltUINT32 options - task options on VwWorks
vltUINT32 stacksize - stack size on VxWorks
char *taskname - task name on VxWorks
Strings MUST be NULL terminated !
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid runString or runOptions is NULL,
lccERR_SEM if critical section entering timeout,
lccERR_MEMORY if memory allocation failed,
lccERR_NOT_REGISTERED if the calling process is not registered in
the Message System,
lccERR_QSERVER if Q server error.
This function can be called only by processes registered in the
Message System.
The default command Id of the command message sent to the Message
System is defined to be a dummy value. It is transparent to user
applications.
#include "msg.h"
...
ccsERROR error;
ccsENVNAME env;
char runString[20];
ccsRUNOPT runOptions;
...
if (ccsInit(...) == FAILURE)
{
Process error condition
}
...
-- runstring with string, real, integer and empty string ---
strcpy(runString, "myTask \"myString\" 12.5 199 \"\"");
runoptions.vxto.priority = 100;
runoptions.vxto.options = 0;
runoptions.vxto.stacksize = 40000;
runoptions.vxto.taskname = "mytaskname";
strcpy(env, "lcu6");
if (msgScheduleProcess(env, runString, &runOptions, &error) == FAILURE)
{
Process error condition
}
...
SYNOPSIS #include "msg.h"
ccsCOMPL_STAT msgSendCommand(
char *command,
msgCMDID commandId,
ccsENVNAME destenv,
ccsPROCNAME destproc,
char *buffer,
msgLENGTH buflen,
msgCHECKFLAG flag,
ccsERROR *error
);
Send the given command to the specified destination process.
Wait for ACK message if remote destination, i.e. different
environment names. The Q Server will generate a NACK message
if ACK timeout. The timout is defined by Q Server boot script.
command <IN> Command to be sent (maximum 7 characters).
commandId <IN> User supplied identifier or defaulted.
destenv <IN> Destination environment name (maximum 7 characters).
ccsLOCAL_ENV default to local environment.
destproc <IN> Destination process name (maximum 19 characters).
buffer <IN> Buffer with command parameters.
buflen <IN> Buffer length. Max len = 8kB - header size.
flag <IN> Flag specifying checks to be done. Not used on LCU.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_MSG_SIZE if message too big,
lccERR_PARAMETER if invalid command name,
lccERR_PROC_NAME if invalid process name,
lccERR_ENV_NAME if invalid environment name,
lccERR_NOT_REGISTERED if the sending process is not registered,
lccERR_MEMORY if memory allocation failed,
lccERR_ACK if Nack received,
lccERR_VXWORKS if VxWorks functions calls error,
lccERR_SEM if cannot enter critical section,
lccERR_QSERVER if Q server error,
lccERR_INTERNAL if LCC software failed.
#include "msg.h"
...
ccsERROR error;
msgCMD command;
ccsENVNAME destEnv;
ccsPROCNAME destProc;
char cmdpar[] = "my cmd buffer";
...
if (ccsInit(...) == FAILURE)
{
Process error condition
}
...
strcpy(destProc, "myProcess");
strcpy(destEnv, "myEnv");
strcpy(command, "MYCMD");
if (msgSendCommand(command, 0, destEnv, destProc,
cmdpar, strlen(cmdpar) + 1, 0, &error) == FAILURE)
{
Process error condition
}
...
SYNOPSIS #include "msg.h"
ccsCOMPL_STAT msgSendReply(
msgPROCESSID *destId,
msgCMDID commandId,
msgCMD command,
char *buffer,
msgLENGTH buflen,
vltLOGICAL lastreply,
ccsERROR *errmsg,
ccsERROR *error
);
ccsCOMPL_STAT msgReplyWithId(
msgPROCESSID *sourceId,
msgPROCESSID *destId,
msgCMDID commandId,
msgCMD command,
char *buffer,
msgLENGTH buflen,
vltLOGICAL lastreply,
ccsERROR *errmsg,
ccsERROR *error
);
These functions send a reply or an error reply message. A normal reply
is sent if errmsg->errorNumber is 0 otherwise an error reply is sent.
The error shall be reset with the function errResetStack.
msgSendReply () uses the source processId get from the task variable.
msgReplyWithId () uses the source processId given as parameter.
sourceId <IN> ProcessId to be used as source.
destId <IN> Destination of the reply, as found in the source
field of the command.
commandId <IN> As found in the command.
command <IN> As found in the command (maximum 7 characters).
buffer <IN> Buffer containing the reply.
buflen <IN> Buffer length. Max len = 8kB - header size..
lastreply <IN> Flag indicating if another reply follows. Should be
set to ccsFALSE if more replies follow.
errmsg <IN> Error structure returned in msg.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_PARAMETER if source or destination processId is NULL,
command NULL or empty, or lastReply flag invalid,
lccERR_MEMORY if memory allocation failed,
lccERR_NOT_REGISTERED if process is not registered,
lccERR_MSG_SIZE if message too big,
lccERR_VXWORKS if VxWorks functions calls error,
lccERR_QSERVER if Q server error,
lccERR_INTERNAL if LCC software failed,
The returned command and commandId parameters must match the ones
found in the command replied to.
These functions can be called only by processes registered in the
Message System.
They use the errorNumber of the errmsg error structure to determine if
it is an error reply or a normal reply. If the errorNumber is not 0,
then an error reply is sent. The body of an error reply contains the
error structure; the user supplied buffer is ignored.
#include "msg.h"
...
ccsERROR error;
ccsERROR errmsg;
msgCMD command;
msgCMDID commandId;
msgPROCESSID *orgId;
char *buffer;
msgLENGTH buflen;
...
if (ccsInit(...) == FAILURE)
{
Process error condition
}
...
if (msgRecvMsg(...) == FAILURE)
{
Process error condition
}
...
if (msgParseMsg(...) == FAILURE)
{
Process error condition
}
...
sprintf(buffer,"My reply string");
buflen = strlen(buffer) + 1; // to include null
errResetStack(&errmsg); // this is a normal reply
...
if (msgSendReply(orgId,
commandId,
command,
buffer,
buflen,
ccsTRUE, // this is last reply
&errmsg,
&error) == FAILURE)
{
Process error condition
}
...
SYNOPSIS #include "timer.h"
ccsCOMPL_STAT timerCancelRequest(
vltUINT32 requestId,
ccsERROR *error
);
timerCancelRequest() cancels a timer request.
If the value of the request identifier correspond to one of the timers,
the corresponding timer is stopped.
If the request identifier corresponds to a pulse (1 second or 10
millisecond), the corresponding pulse is stopped.
Otherwise the request is removed from the list of requests.
requestId <IN> Timer request id.
error <OUT> Returned error structure.
SUCCESS if everything OK
FAILURE, the error structure is updated with:
lccERR_DRIVER if cannot stop the corresponding timer or pulse,
lccERR_NOT_FOUND if the request cannot be found,
lccERR_SEM if critical section cannot be entered.
SYNOPSIS #include "timer.h"
ccsCOMPL_STAT timerConnectOnPulse(
timerPULSE pulse,
timerPULSE_MODE mode,
SEM_ID *semId,
vltUINT32 *requestId,
ccsERROR *error
);
timerConnectOnPulse() connects a task to a pulse (10 millisecond or
one second).
It cannot be re-used if the pulse is already in use.
It returns a request identifier and a semaphore identifier. The
sempahore is given each time the pulse expires.
The service is available in simulation mode with a resolution of one
system tick.
pulseId <IN> Pulse identification (timerSECOND or
timer10_MILLISECOND).
mode <IN> Mode of activation (timerPULSE_ONCE or timerPULSE_PER).
semId <OUT> Semaphore identifier.
requestId <OUT> Request identifier (PULSE_10M or PULSE_SEC).
error <OUT> Returned error structure.
SUCCESS if everything OK
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid parameters,
lccERR_IN_USE if pulse is not free,
lccERR_VXWORKS if VxWorks system call fails,
lccERR_DRIVER if cannot get UTC time from the driver
or if cannot configure the timer,
lccERR_SEM if critical section cannot be entered.
SYNOPSIS #include "timer.h"
ccsCOMPL_STAT timerGetStatus(
timerTIMER_STATE *timerState,
timerPULSE_STATE *pulseState,
timsMODE *mode,
ccsERROR *error
);
timerGetStatus() returns the Time Handling module status.
The Time Handling module status is defined by:
- state of the timers (free or busy),
- state of the pulses (free or busy),
- system mode (local or UTC, simulation or normal).
timerState <OUT> Timer states (timerFREE or timerBUSY).
pulseState <OUT> Pulse states (timerFREE or timerBUSY).
mode <OUT> Mode of the Time module (timsUTC, timsLOCAL or
timsSIMULATION).
error <OUT> Returned error structure.
SUCCESS if everything OK
FAILURE, the error structure is updated with:
lccERR_DRIVER if cannot read the driver,
lccERR_SEM if critical section cannot be entered.
SYNOPSIS #include "timer.h"
ccsCOMPL_STAT timerGetTimerStatus(
vltUINT16 timerId,
timerSTATE *state,
vltLOGICAL *started,
timerTIMER_MODE *mode,
ccsTIMEVAL *lastTime,
ccsTIMEVAL *nextTime,
ccsERROR *error
);
timerGetTimerStatus() returns the status of a specific timer.
The status of a timer is defined by:
- state of the timer (free or busy),
- timer started/stopped,
- timer mode (interrupt once, periodic, on specific UTC, ... ),
- time of last interrupt,
- time of next interrupt.
timerId <IN> Timer id (0-4).
state <OUT> State (timerFREE or timerBUSY).
started <OUT> Timer started (True = Yes).
mode <OUT> Timer mode (timerONCE_IMMEDIATE,
timerONCE_AFTER_TIME_GATE, timerONCE_AFTER_HW_GATE,
timerPER_IMMEDIATE, timerPER_AFTER_TIME_GATE,
timerPER_AFTER_HW_GATE, timerAFTER_TIME_GATE,
timerAFTER_HW_GATE, timerUTC or timerPER_AFTER_UTC).
lastTime <OUT> Time of last interrupt.
nextTime <OUT> Time of next interrupt.
error <OUT> Returned error structure.
If the timer was configured with mode timerONCE_AFTER_HW_GATE,
timerPER_AFTER_HW_GATE or timerAFTER_HW_GATE, the time of next
interrupt cannot be returned since it depends on external gating
signal.
The next interrupt time structure will be set to (0,0).
The value will also be set when the timer is not configured.
Value of lastTime parameter will be set to (0,0) when ther timer is
not configured or when it has not yet interrupted.
SUCCESS if everything OK
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid parameter,
lccERR_SIMULATION if system mode is simulation (timers not
accessible),
lccERR_DRIVER if error from driver,
lccERR_SEM if critical section cannot be entered.
SYNOPSIS #include "timer.h"
ccsCOMPL_STAT timerScheduleProcess(
ccsENVNAME envName,
char *runString,
ccsRUNOPT *runOptions,
timerSCHEDULE_MODE mode,
const ccsTIMEVAL *startTime,
const ccsTIMEVAL *interval,
vltUINT32 *requestId,
ccsERROR *error
);
timerScheduleProcess() enables the scheduling of a process synchronised
to the Time Reference System.
Several processes can be scheduled in parallel.
The Time Handler manages a list of requests associated to SCHEDULING
and MESSAGE SENDING requests types. This function adds the request to
the list of requests.
This service is available in simulation mode.
The resolution of the service is one system tick.
envName <IN> Where to schedule (maximum 19 characters). Only local
environment is supported on LCU's.
runString <IN> Task entry name and parameters.
runOptions <IN> VxWorks run-time options. Default VxWorks options
are used if a NULL pointer is given as argument.
mode <IN> Mode of activation, one of:
timerSCHEDULE_ONCE: one shot activation after delay,
timerSCHEDULE_PER: periodic activation after delay,
timerSCHEDULE_UTC: one shot activation after UTC,
timerSCHEDULE_PER_AFTER_UTC: periodic activation
after UTC.
startTime <IN> Start time for modes timerSCHEDULE_UTC and
timerSCHEDULE_PER_AFTER_UTC.
interval <IN> Interval for periodic activation.
requestId <OUT> Request identifier.
error <OUT> Returned error structure.
SUCCESS if everything OK
FAILURE, the error structure is updated with:
lccERR_MEMORY if cannot allocate the memory for the request,
lccERR_PARAMETER if an invalid parameter is found,
lccERR_SEM if critical section cannot be entered.
SYNOPSIS #include "timer.h"
ccsCOMPL_STAT timerSendCommand(
timerSCHEDULE_MODE mode,
ccsTIMEVAL *startTime,
ccsTIMEVAL *interval,
msgCMD command,
msgCMDID commandId,
ccsENVNAME destenv,
ccsPROCNAME destproc,
char *buffer,
msgLENGTH buflen,
msgCHECKFLAG checkFlag,
vltUINT32 *requestId,
ccsERROR *error
);
timerSendCommand() enable the sending of a command synchronised to the
Time Reference System.
Several commands can be sent in parallel.
The Time Handler manages a list of requests associated to SCHEDULING
and MESSAGE SENDING requests types. This function adds the request to
the list of requests.
This service is available in simulation mode.
The resolution of the service is one system tick.
mode <IN> Mode of activation, one of:
timerSCHEDULE_ONCE: one shot activation after delay,
timerSCHEDULE_PER: periodic activation after delay,
timerSCHEDULE_UTC: one shot activation after UTC,
timerSCHEDULE_PER_AFTER_UTC: periodic activation
after UTC.
startTime <IN> Start time for modes timerSCHEDULE_UTC and
timerSCHEDULE_PER_AFTER_UTC.
interval <IN> Interval for periodic activation.
command <IN> Command name (maximum 7 characters).
commandId <IN> Command identifier.
destenv <IN> Where to send the command (maximum 7 characters).
destproc <IN> To whom : process name (maximum 19 characters).
buffer <IN> Command message body.
buflen <IN> Message body length.
checkFlag <IN> Flag specifying checks to be done (currently not
used).
requestId <OUT> Request identifier.
error <OUT> Returned error structure.
SUCCESS if everything OK
FAILURE, the error structure is updated with:
lccERR_MEMORY if cannot allocate the memory for the request
lccERR_PARAMETER if an invalid parameter is found,
lccERR_SEM if critical section cannot be entered.
SYNOPSIS #include "timer.h"
ccsCOMPL_STAT timerSendReply(
timerSCHEDULE_MODE mode,
ccsTIMEVAL *startTime,
ccsTIMEVAL *interval,
msgPROCESSID *destId,
msgCMDID commandId,
msgCMD command,
char *buffer,
msgLENGTH buflen,
vltLOGICAL lastReply,
vltUINT32 *requestId,
ccsERROR *error
);
timerSendReply() enables the sending of a reply synchronised to the
Time Reference System.
Several replies can be sent in parallel.
The Time Handler manages a list of requests associated to SCHEDULING
and MESSAGE SENDING requests types. This function adds the request to
the list of requests.
This service is available in simulation mode.
The resolution of the service is one system tick.
mode <IN> Mode of activation, one of:
timerSCHEDULE_ONCE: one shot activation after delay,
timerSCHEDULE_PER: periodic activation after delay,
timerSCHEDULE_UTC: one shot activation after UTC,
timerSCHEDULE_PER_AFTER_UTC: periodic activation
after UTC.
startTime <IN> Start time for modes timerSCHEDULE_UTC and
timerSCHEDULE_PER_AFTER_UTC.
interval <IN> Interval for periodic activation.
destId <IN> Destination of the reply
commandId <IN> Command identifier.
command <IN> Command name (maximum 7 characters).
buffer <IN> Command message body.
buflen <IN> Message body length.
lastReply <IN> Flag to indicate if another reply follows.
requestId <OUT> Request identifier.
error <OUT> Returned error structure.
SUCCESS if everything OK
FAILURE, the error structure is updated with:
lccERR_MEMORY if cannot allocate the memory for the request
lccERR_PARAMETER if an invalid parameter is found,
lccERR_SEM if critical section cannot be entered.
#include "timer.h"
ccsCOMPL_STAT timerSetInterrupt(
void *address,
timerTIMER_MODE mode,
ccsTIMEVAL *startTime,
ccsTIMEVAL *interval,
void *argument,
vltUINT32 *requestId,
ccsERROR *error
);
ccsCOMPL_STAT timerSetInterruptTimer(
void *address,
timerTIMER_MODE mode,
ccsTIMEVAL *startTime,
ccsTIMEVAL *interval,
vltUINT8 timerId,
void *argument,
vltUINT32 *requestId,
ccsERROR *error
);
timerSetInterrupt() connect an interrupt to timer 0.
timerSetInterruptTimer() connect an interrupt to timer 0 or 5.
It cannot be used if the system mode is simulation mode (there is no
TIM module installed) or if the timer 0 is already in use.
address <IN> Address of interrupt routine.
mode <IN> Activation mode, one of:
timerONCE_IMMEDIATE: activation once after the given
time starting immediately.
timerONCE_AFTER_TIME_GATE: activation once after the
given time starting on the next 100 ms gating
signal.
timerONCE_AFTER_HW_GATE: activation once after the
given time starting on the hardware gating
signal. If the gating signal changes when the
timer is still counting, the timer stops when
the signal is "low" and counts when the signal
is "high".
timerPER_IMMEDIATE: periodic activation with a given
rate starting immediately.
timerPER_AFTER_TIME_GATE: periodic activation with a
given rate starting on the next 100 ms gating
signal.
timerPER_AFTER_HW_GATE: periodic activation with a
given rate starting on the hardware gating
signal. If the gating signal changes when the
timer is still counting, the timer stops when the
signal is "low" and counts when the signal is
"high".
timerAFTER_TIME_GATE: activation after a given time
starting on each 100 ms gating signal.
timerAFTER_HW_GATE: activation after a given time
starting each time the hardware gating signal is
set. If the gating signal changes when the timer
is still counting, the timer stops when the
signal is "low" and counts when the signal is
"high".
timerUTC: activation on a given UTC.
timerPER_AFTER_UTC: periodic activation with given
rate starting at the given UTC.
startTime <IN> Start time.
interval <IN> Interval for periodic activation.
argument <IN> Argument to pass to interrupt routine
requestId <OUT> Request identifier.
error <OUT> Returned error structure.
ditionally for timerSetInterruptTimer:
timerId <IN> Timer identifier (0 or 5)
SUCCESS if everything OK
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid parameters,
lccERR_SIMULATION if system mode is simulation,
lccERR_IN_USE if timer is not free,
lccERR_DRIVER if cannot configure the timer,
lccERR_SEM if critical section cannot be entered.
myInterruptHandler (vltINT32 arg)
{
...
}
ccsCOMPLT_STAT myRoutine(...,error)
{
ccsTIMEVAL startTime;
ccsTIMEVAL interval;
vltUINT32 timerId;
vltINT32 arg;
Schedule interrupt periodically every millisecond
startTime.tv_sec=0;
startTime.tv_usec=0;
interval.tv_sec=0;
interval.tv_usec=1000;
if (timerInterrupt ((FUNCPTR)myInterrutpHandler,
timerPER_IMMEDIATE, &startTime, &interval,
arg, &timerId, error) == FAILURE)
{
...
}
...
SYNOPSIS #include "timer.h"
ccsCOMPL_STAT timerSetTask(
timerTIMER_MODE mode,
ccsTIMEVAL *startTime,
ccsTIMEVAL *interval,
vltUINT8 timerId,
SEM_ID *semId,
vltUINT32 *requestId,
ccsERROR *error
);
timerSetTask() connects a task to a timer (1 to 4).
It cannot be used if the system mode is simulation mode (there is no
TIM module installed) and the timer uses a gating signal, or if the
specified timer is already in use.
It returns a request identifier and a semaphore identifier. The
semaphore is given each time the timer expires.
The service is available in simulation mode with a resolution of one
system tick.
mode <IN> Activation mode, one of:
timerONCE_IMMEDIATE: activation once after the given
time starting immediately.
timerONCE_AFTER_TIME_GATE: activation once after the
given time starting on the next 100 ms gating
signal.
timerONCE_AFTER_HW_GATE: activation once after the
given time starting on the hardware gating
signal. If the gating signal changes when the
timer is still counting, the timer stops when
the signal is "low" and counts when the signal
is "high".
timerPER_IMMEDIATE: periodic activation with a given
rate starting immediately.
timerPER_AFTER_TIME_GATE: periodic activation with a
given rate starting on the next 100 ms gating
signal.
timerPER_AFTER_HW_GATE: periodic activation with a
given rate starting on the hardware gating
signal. If the gating signal changes when the
timer is still counting, the timer stops when the
signal is "low" and counts when the signal is
"high".
timerAFTER_TIME_GATE: activation after a given time
starting on each 100 ms gating signal.
timerAFTER_HW_GATE: activation after a given time
starting each time the hardware gating signal is
set. If the gating signal changes when the timer
is still counting, the timer stops when the
signal is "low" and counts when the signal is
"high".
timerUTC: activation on a given UTC.
timerPER_AFTER_UTC: periodic activation with given
rate starting at the given UTC.
startTime <IN> Start time.
interval <IN> Interval for periodic activation.
timerId <IN> Timer identifier (1-4).
semId <OUT> Semaphore identifier.
requestId <OUT> Request identifier.
error <OUT> Returned error structure.
SUCCESS if everything OK
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid parameters,
lccERR_IN_USE if timer is not free,
lccERR_VXWORKS if VxWorks function call fails,
lccERR_DRIVER if cannot configure the timer,
lccERR_SEM if critical section cannot be entered.
This function can be called only by processes registered in the
Message System.
The caller MUST free the memory allocated for the list of devices
in error.
ccsTIMEVAL startTime;
ccsTIMEVAL interval;
SEM_ID timerSem;
vltUINT32 timerId;
Schedule this task once at specific UTC. Use timer 1.
startTime.tv_sec=myUTC;
startTime.tv_usec=0;
interval.tv_sec=0;
interval_tv_usec=0;
timerSetTask (timerUTC, &startTime, &interval, 1, &timerSem,
&timerId, &error) == FAILURE)
{
...
}
Wait for timer
semTake (timerSem, WAIT_FOREVER);
....
timerSleep() delays a task with high resolution.
It uses the timer 3 for that purpose. In case the timer is not
available, it uses the standard VxWorks taskDelay() function.
A timeout value of (microsecs + 2 ticks) will be used for the
timer in order to avoid the task being blocked foreverin case
of any problem.
microsecs <IN> Number of microseconds to sleep.
error <OUT> Returned error structure.
SUCCESS if everything OK
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid parameters,
lccERR_SEM if sempahore cannot be taken.
SYNOPSIS ccsCOMPL_STAT timsAddTime(
const ccsTIMEVAL *time1,
const ccsTIMEVAL *time2,
ccsTIMEVAL *time,
ccsERROR *error
);
ccsCOMPL_STAT timsSubTime(
const ccsTIMEVAL *time1,
const ccsTIMEVAL *time2,
ccsTIMEVAL *time,
ccsERROR *error
);
timsAddTime() adds two time values in internal format.
time1 <IN> First operand.
time2 <IN> Second operand.
time <OUT> result = time1 + time2.
error <OUT> Returned error structure.
timsSubTime() subtracts time values in internal format.
time1 <IN> First operand.
time2 <IN> Second operand.
time <OUT> result = time1 - time2.
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid parameter,
lccERR_TIME if time 2 is > time1 (timsSubTime),
lccERR_VXWORKS if conversion error.
timsGetMode() returns the operating mode of the Time Handling module.
mode <OUT> Current mode (timsUTC, timsLOCAL or timsSIMULATION).
error <OUT> Returned error structure.
SUCCESS if everything OK.
FAILURE, and the error structure is updated with:
lccERR_PARAMETER if NULL pointer.
SYNOPSIS #include "tims.h"
ccsCOMPL_STAT timsGetUTC(
ccsTIMEVAL *UTC,
timsMODE *mode,
ccsERROR *error
);
timsGetUTC() returns the Universal Time and the mode of the Time
Handling module.
UTC <OUT> Returned UTC.
mode <OUT> Mode of the Time Handling module (timsUTC, timsLOCAL
or timsSIMULATION).
error <OUT> Returned error structure.
SUCCESS if everything OK
FAILURE, the error structure is updated with:
lccERR_PARAMETER if UTC and/or mode are NULL pointers,
lccERR_DRIVER if cannot get UTC time from the driver.
SYNOPSIS #include "tims.h"
ccsCOMPL_STAT timsIsoStringToTime (
const char *string,
timsTIME_FORMAT format,
ccsTIMEVAL *time1,
ccsERROR *error
);
timsIsoStringToTime() converts a string given as input to a
timeval structure according to the specified format.
Following input formats are excepted:
timsABS_TIME input format "yyyy-mm-ddThh:mm:ss[.uuuuuu]"
timsTIME_OF_DAY input format "hh:mm:ss.uuuu"
timsDATE input format "yyyy-mm-dd"
string <IN> String containing the specified time
format <IN> Format type e.g. timsABS_TIME
time1 <OUT> Pointer to a ccsTIMEVAL
error <OUT> Returned error structure.
If the function returns SUCCESS its content is undefined.
If the function returns FAILURE the structure is set.
SUCCESS on success
FAILURE on failure an error structure is set.
One of the following error code is returned :
ccsERR_NULL_PTR
ccsERR_PARAMETER
ccsERR_TIMS_CONVERT
or from LCC :
lccERR_PARAMETER
lccERR_TIMS_CONVERT
#include "tims.h"
...
ccsERROR error;
ccsTIMEVAL time;
char buf[80];
...
if (ccsInit(...) == FAILURE)
... error processing ...
...
if (timsIsoStringToTime (buf,timsABS_TIME,&time,&error) == FAILURE)
... error processing ...
...
timsSetMode() sets the operating mode of the Time Handling module.
The mode can be one of:
timsUTC : the TIM module is set in UTC mode.
timsLOCAL : the TIM module is set in local mode.
timsSIMUALTION: if no timer or pulse is active, simulation mode is
entered. In this mode, the Time Handling module
uses the VxWorks system tick to update the UTC
time.
mode <IN> New mode.
error <OUT> Returned error structure.
SUCCESS if everything OK
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid parameter,
lccERR_IN_USE if timers and/or pulses still active,
lccERR_DRIVER if cannot configure the TIM module.
timsSetUTC() sets the UTC, when in local or simulation mode.
UTC <IN> New value for UTC.
error <OUT> Returned error structure.
SUCCESS if everything OK
FAILURE, the error structure is updated with:
lccERR_PARAMETER if invalid parameter,
lccERR_DRIVER if cannot configure the TIM module,
lccERR_SEM if critical section cannot be entered.
SYNOPSIS #include "tims.h"
ccsCOMPL_STAT timsTimeToIsoString (
const ccsTIMEVAL *time1,
timsTIME_FORMAT format,
vltUINT8 precision,
char **string,
ccsERROR *error
);
timsTimeToIsoString() converts the time value time1 to a string
according to the specified format.
Following formats are supported:
timsABS_TIME returns "yyyy-mm-ddThh:mm:ss[.uuuuuu]"
timsTIME_OF_DAY returns "hh:mm:ss[.uuuuuu]"
timsDATE returns "yyyy-mm-dd"
time1 <IN> Pointer to a ccsTIMEVAL
format <IN> Format type e.g. timsABS_TIME
precision <IN> integer [0-6] defining the fraction of seconds
string <OUT> String containing the translated time
error <OUT> Returned error structure.
If the function returns SUCCESS its content is undefined.
If the function returns FAILURE the structure is set.
SUCCESS on success
FAILURE on failure an error structure is set.
One of the following error code is returned:
ccsERR_PARAMETER
ccsERR_TIMS_CONVERT
ccsERR_NULL_PTR
or from LCC :
lccERR_PARAMETER
lccERR_TIMS_CONVERT
#include "tims.h"
...
ccsERROR error;
ccsTIMEVAL time;
char buf[80];
...
if (ccsInit(...) == FAILURE)
... error processing ...
...
if (timsTimeToIsoString (&time,timsABS_TIME,TRUE,TRUE,&buf,&error) == FAILURE)
... error processing ...
...
SYNOPSIS #include "tims.h"
vltDOUBLE timsUTCToJD (ccsTIMEVAL *ut)
vltDOUBLE timsUTCToMJD(ccsTIMEVAL *ut)
void timsJDToUTC( vltDOUBLE jd, ccsTIMEVAL *utc )
void timsMJDToUTC( vltDOUBLE mjd, ccsTIMEVAL *utc )
timsUTCToJD() converts a time from UT into Julian Date.
timsUTCToMJD() converts a time from UT into Modified Julian Date.
IN ut time in UT
timsJDToUTC() converts a time from Julian Date to UT.
IN jd time in Julian Date
OUT ut time in UT
timsMJDToUTC() converts a time from Modified Julian Date to UT.
IN mjd time in Modified Julian Date
OUT ut time in UT
![]() Quadralay Corporation http://www.webworks.com Voice: (512) 719-3399 Fax: (512) 719-3606 sales@webworks.com |
![]() |
![]() |
![]() |
![]() |