gxPL  1.0
Tools, Application and Framework for xPL
Devices

Detailed Description

gxPLDevice xPL corresponds to a device. This is the basic network element. It is identified by vendor ID, device and instance. A device signals its arrival and departure on the network by transmitting a heartbeat message.
It starts working after having had an echo to his heartbeat.
gxPL provides two types of devices: simple devices and configurable devices.
A device must be instantiated from an application using the gxPLAppAddDevice() or gxPLAppAddConfigurableDevice().

Collaboration diagram for Devices:

Modules

 Groups
 
 Filters
 
 Configurable devices
 

Functions

gxPLDevice * gxPLAppAddDevice (gxPLApplication *app, const char *vendor_id, const char *device_id, const char *instance_id)
 Adds a new device to an application. More...
 
gxPLDevice * gxPLAppDeviceAt (gxPLApplication *app, int index)
 Return a device at a given index. More...
 
int gxPLAppDeviceCount (gxPLApplication *app)
 Return number of devices.
 
int gxPLAppDeviceIndex (gxPLApplication *app, const gxPLDevice *device)
 Return index for a given device. More...
 
int gxPLAppRemoveDevice (gxPLApplication *app, gxPLDevice *device)
 Removes a device. More...
 
const char * gxPLDeviceDeviceId (const gxPLDevice *device)
 Gets the device identifier. More...
 
int gxPLDeviceDeviceIdSet (gxPLDevice *device, const char *device_id)
 Sets the device identifier. More...
 
int gxPLDeviceEnable (gxPLDevice *device, bool enabled)
 Enabled or not a device. More...
 
int gxPLDeviceHeartbeatInterval (const gxPLDevice *device)
 Gets the heartbeat interval. More...
 
int gxPLDeviceHeartbeatIntervalSet (gxPLDevice *device, int interval)
 Sets the heartbeat interval. More...
 
long gxPLDeviceHeartbeatLast (const gxPLDevice *device)
 Gets the time of the last heartbeat sent. More...
 
const gxPLIdgxPLDeviceId (const gxPLDevice *device)
 Gets the identifier. More...
 
int gxPLDeviceIdSet (gxPLDevice *device, const gxPLId *id)
 Sets the identifier. More...
 
const char * gxPLDeviceInstanceId (const gxPLDevice *device)
 Gets the instance identifier. More...
 
int gxPLDeviceInstanceIdSet (gxPLDevice *device, const char *instance_id)
 Sets the instance identifier. More...
 
int gxPLDeviceIsConfigurale (const gxPLDevice *device)
 Indicates whether the device is configurable. More...
 
int gxPLDeviceIsConfigured (const gxPLDevice *device)
 Indicates whether the device is configured. More...
 
int gxPLDeviceIsEnabled (const gxPLDevice *device)
 Indicates whether the device is enabled. More...
 
int gxPLDeviceIsHubConfirmed (const gxPLDevice *device)
 Indicates whether the device has detected a hub. More...
 
int gxPLDeviceIsReportOwnMessages (const gxPLDevice *device)
 Indicates whether the device will transmit its own messages to the listeners. More...
 
int gxPLDeviceIsRespondToBroadcast (const gxPLDevice *device)
 Indicates whether the device will respond to broadcast messages. More...
 
int gxPLDeviceListenerAdd (gxPLDevice *device, gxPLDeviceListener listener, gxPLMessageType type, char *schema_class, char *schema_type, void *udata)
 Add a listener for the device. More...
 
int gxPLDeviceListenerRemove (gxPLDevice *device, gxPLDeviceListener listener)
 Remove a device listener. More...
 
gxPLApplication * gxPLDeviceParent (gxPLDevice *device)
 Gets the parent gxPLApplication object. More...
 
int gxPLDeviceReportOwnMessagesSet (gxPLDevice *device, bool isreportownmsg)
 Process own messages. More...
 
int gxPLDeviceRespondToBroadcastSet (gxPLDevice *device, bool respond)
 Enable the response to broadcast messages. More...
 
const char * gxPLDeviceVendorId (const gxPLDevice *device)
 Gets the vendor identifier. More...
 
int gxPLDeviceVendorIdSet (gxPLDevice *device, const char *vendor_id)
 Sets the vendor identifier. More...
 
const char * gxPLDeviceVersion (const gxPLDevice *device)
 Gets the version string. More...
 
int gxPLDeviceVersionSet (gxPLDevice *device, const char *version)
 Sets the version. More...
 

Typedefs

typedef void(* gxPLDeviceListener) (gxPLDevice *, gxPLMessage *, void *)
 Listener for a device The end-user can add listener functions that will be called each time the device will receive messages addressed or broadcast it.
.
 

Function Documentation

gxPLDevice* gxPLAppAddDevice ( gxPLApplication *  app,
const char *  vendor_id,
const char *  device_id,
const char *  instance_id 
)

Adds a new device to an application.

Parameters
apppointer to a gxPLApplication object
vendor_idpointer to the vendor id
device_idpointer to the device id
instance_idpointer to the instance id
Returns
pointer on the device, NULL if error occurs
Examples:
sender/gxpl-sender.c.
gxPLDevice* gxPLAppDeviceAt ( gxPLApplication *  app,
int  index 
)

Return a device at a given index.

Parameters
apppointer to a gxPLApplication object
indexof the device
Returns
If the index is out of range, return NULL
int gxPLAppDeviceIndex ( gxPLApplication *  app,
const gxPLDevice *  device 
)

Return index for a given device.

Parameters
apppointer to a gxPLApplication object
devicepointer on the device
Returns
the index, -1 if not found
int gxPLAppRemoveDevice ( gxPLApplication *  app,
gxPLDevice *  device 
)

Removes a device.

Parameters
apppointer to a gxPLApplication object
devicepointer on the device
Returns
0, -1 if an error occurs
const char* gxPLDeviceDeviceId ( const gxPLDevice *  device)

Gets the device identifier.

Parameters
devicepointer on the device
Returns
the device identifier, NULL if error occurs
int gxPLDeviceDeviceIdSet ( gxPLDevice *  device,
const char *  device_id 
)

Sets the device identifier.

Parameters
devicepointer on the device
device_idpointer to the device id
Returns
0, -1 if an error occurs
int gxPLDeviceEnable ( gxPLDevice *  device,
bool  enabled 
)

Enabled or not a device.

Parameters
devicepointer on the device
enabledtrue for eanbled
Returns
0, -1 if an error occurs
Examples:
logger/gxpl-logger.c.
int gxPLDeviceHeartbeatInterval ( const gxPLDevice *  device)

Gets the heartbeat interval.

Parameters
devicepointer on the device
Returns
the interval in seconds, -1
int gxPLDeviceHeartbeatIntervalSet ( gxPLDevice *  device,
int  interval 
)

Sets the heartbeat interval.

Parameters
devicepointer on the device
intervalinterval in seconds
Returns
0, -1 if an error occurs
long gxPLDeviceHeartbeatLast ( const gxPLDevice *  device)

Gets the time of the last heartbeat sent.

The time is given in a unit dependent on the host system, most of the time is given in seconds. On a unix system with a real time clock that value is the number of seconds since the first second of January 1, 1970.

Parameters
devicepointer on the device
Returns
the last time, -1 if error occurs
const gxPLId* gxPLDeviceId ( const gxPLDevice *  device)

Gets the identifier.

Parameters
devicepointer on the device
Returns
the identifier, NULL if error occurs
int gxPLDeviceIdSet ( gxPLDevice *  device,
const gxPLId id 
)

Sets the identifier.

Parameters
devicepointer on the device
idpointer to identifier
Returns
0, -1 if an error occurs
const char* gxPLDeviceInstanceId ( const gxPLDevice *  device)

Gets the instance identifier.

Parameters
devicepointer on the device
Returns
the device instance, NULL if error occurs
int gxPLDeviceInstanceIdSet ( gxPLDevice *  device,
const char *  instance_id 
)

Sets the instance identifier.

Parameters
devicepointer on the device
instance_idpointer to the instance id
Returns
0, -1 if an error occurs
int gxPLDeviceIsConfigurale ( const gxPLDevice *  device)

Indicates whether the device is configurable.

Parameters
devicepointer on the device
Returns
true, false, -1 if an error occurs
int gxPLDeviceIsConfigured ( const gxPLDevice *  device)

Indicates whether the device is configured.

Parameters
devicepointer on the device
Returns
true, false, -1 if an error occurs
Examples:
logger/gxpl-logger.c.
int gxPLDeviceIsEnabled ( const gxPLDevice *  device)

Indicates whether the device is enabled.

Parameters
devicepointer on the device
Returns
true if enabled, false if not, -1 if an error occurs
int gxPLDeviceIsHubConfirmed ( const gxPLDevice *  device)

Indicates whether the device has detected a hub.

Parameters
devicepointer on the device
Returns
true, false, -1 if an error occurs
int gxPLDeviceIsReportOwnMessages ( const gxPLDevice *  device)

Indicates whether the device will transmit its own messages to the listeners.

Parameters
devicepointer on the device
Returns
true, false, -1 if an error occurs
int gxPLDeviceIsRespondToBroadcast ( const gxPLDevice *  device)

Indicates whether the device will respond to broadcast messages.

Parameters
devicepointer on the device
Returns
true if respond, false if not, -1 if an error occurs
int gxPLDeviceListenerAdd ( gxPLDevice *  device,
gxPLDeviceListener  listener,
gxPLMessageType  type,
char *  schema_class,
char *  schema_type,
void *  udata 
)

Add a listener for the device.

This function allows the user to install a listener that will be called for each message received for the service.
Only messages matching type, schema_class and schema_type are forwarded to the listener.

Parameters
devicepointer on the device
listenerthe function listening device messages
typetype of message to be processed, gxPLMessageAny to manage any
schema_classschema class to process, NULL to manage everything
schema_typeschema type to process, NULL to manage everything
udatapointer to the user data that will be passed to the listener, NULL if not used.
Returns
0, -1 if error occurs
int gxPLDeviceListenerRemove ( gxPLDevice *  device,
gxPLDeviceListener  listener 
)

Remove a device listener.

Parameters
devicepointer on the device
listenerthe listener
Returns
0, -1 if error occurs
gxPLApplication* gxPLDeviceParent ( gxPLDevice *  device)

Gets the parent gxPLApplication object.

Parameters
devicepointer on the device
Returns
pointer to an gxPLApplication object that is the parent of the device, NULL if error occurs
int gxPLDeviceReportOwnMessagesSet ( gxPLDevice *  device,
bool  isreportownmsg 
)

Process own messages.

Parameters
devicepointer on the device
isreportownmsgtrue or flase
Returns
0, -1 if an error occurs
int gxPLDeviceRespondToBroadcastSet ( gxPLDevice *  device,
bool  respond 
)

Enable the response to broadcast messages.

Parameters
devicepointer on the device
respondtrue for respond
Returns
0, -1 if an error occurs
const char* gxPLDeviceVendorId ( const gxPLDevice *  device)

Gets the vendor identifier.

Parameters
devicepointer on the device
Returns
the vendor identifier, NULL if error occurs
int gxPLDeviceVendorIdSet ( gxPLDevice *  device,
const char *  vendor_id 
)

Sets the vendor identifier.

Parameters
devicepointer on the device
vendor_idpointer to the vendor id
Returns
0, -1 if an error occurs
const char* gxPLDeviceVersion ( const gxPLDevice *  device)

Gets the version string.

This information is transmitted with the heartbeat.

Parameters
devicepointer on the device
Returns
the last time, NULL if error occurs
int gxPLDeviceVersionSet ( gxPLDevice *  device,
const char *  version 
)

Sets the version.

Parameters
devicepointer on the device
version
Returns
0, -1 if an error occurs
Examples:
logger/gxpl-logger.c.