libsmoco
Low-level interface library for Segment Motion Controller system
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Library Session Functions
Collaboration diagram for Library Session Functions:

Functions

SMOCO_CTX smoco_init (xlog_session_t logger)
 Initialize library and obtain resource handle. More...
 
SMOCO_STATUS smoco_terminate (SMOCO_CTX ctx)
 Terminate session with libsmoco. More...
 
SMOCO_STATUS smoco_set_iolog (SMOCO_CTX ctx, xlog_session_t iolog)
 Specify a low-level I/O logger. More...
 
SMOCO_STATUS smoco_set_txlog (SMOCO_CTX ctx, xlog_session_t txlog)
 Specify a transaction logger. More...
 
SMOCO_STATUS smoco_set_estop_flag (SMOCO_CTX ctx, int *p_estop)
 Set client flag for triggering emergency stop. More...
 
SMOCO_STATUS smoco_set_async_cb_timer (SMOCO_CTX ctx, unsigned ms)
 Set time interval for SMOCO_TXEVT_TIMER_TICK events during async operations. More...
 

Detailed Description

Function Documentation

SMOCO_CTX smoco_init ( xlog_session_t  logger)

Initialize library and obtain resource handle.

Allocates and initializes data structure for segment data. Call this function first to initiate a usage session, before any other use of libsmoco routines.

Parameters
loggerLogging session handle from xLog, or NULL if logging is not needed.
Returns
On success, returns an allocated context handle ("SMOCO context"), which must be freed by calling smoco_terminate(). A return of 0 (NULL) indicates an error.
SMOCO_STATUS smoco_set_async_cb_timer ( SMOCO_CTX  ctx,
unsigned  ms 
)

Set time interval for SMOCO_TXEVT_TIMER_TICK events during async operations.

Parameters
ctxContext handle for this session
msDesired interval in milliseconds
Returns
SMOCO_ST_SUCCESS if successful, any other value indicates an error.
SMOCO_STATUS smoco_set_estop_flag ( SMOCO_CTX  ctx,
int *  p_estop 
)

Set client flag for triggering emergency stop.

A client application can provide libsmoco with an int pointer, which will be watched for a nonzero value. When a nonzero value is found, a global emergency stop command will be issued to all connected SMOCO nodes.

Parameters
ctxContext handle for this session
p_estopPointer to an integer value, to be monitored for nonzero value
Returns
SMOCO_ST_SUCCESS if successful, any other value indicates an error.
SMOCO_STATUS smoco_set_iolog ( SMOCO_CTX  ctx,
xlog_session_t  iolog 
)

Specify a low-level I/O logger.

A client application can specify an xLog session to which low-level SMOCO I/O will be logged, one message per line. The format of this data is tab-separated, so it's not recommended to reuse an xLog session that's being used for other outputs. Note in particular that this logging session should be distinct from that specified to smoco_init(). If this function is not called, low-level I/O logging will not be performed.

Parameters
ctxContext handle for this session
iologxLog session handle
Returns
SMOCO_ST_SUCCESS if successful, any other value indicates an error.
SMOCO_STATUS smoco_set_txlog ( SMOCO_CTX  ctx,
xlog_session_t  txlog 
)

Specify a transaction logger.

A client application can specify an Xlog session to which "transaction" (long-running actuator movement) tracking logs will be written. The format of this data is tab-separated, so it's not recommended to reuse an Xlog session that's being used for other outputs. Note in particular that this logging session should be distinct from that specified to smoco_init(). If this function is not called, transaction logging will not be performed.

Parameters
ctxContext handle for this session
txlogXlog session handle
Returns
SMOCO_ST_SUCCESS if successful, any other value indicates an error.
SMOCO_STATUS smoco_terminate ( SMOCO_CTX  ctx)

Terminate session with libsmoco.

End any ongoing mechanical activity, disconnect network socket, terminate threads, clear memory buffer and deallocate.

Parameters
ctxContext handle for this session.
Returns
SMOCO_ST_SUCCESS if successful, any other value indicates an error.