#include <xplDevice.h>
The xplDevice class provides all the functionality required to create a basic xPL-enabled application. It handles the sending and receiving of xPL messages, sends heartbeats and supports comfiguration via xPLHal All the main application has to do is to watch a pair of events. The first can be obtained by calling xplDevice::GetMsgEvent, and is signalled whenever an xPL message has been received, and is not a message that the xPL Device deals with automatically. The message can be obtained by calling xplDevice::GetMsg. The second event is used to indicate that the config items have been changed, and is obtained by calling xplDevice::GetConfigEvent.
The procedure for creating and initialising an xplDevice object is as follows:
1) Create a communications object for the xplDevice to use. For LAN or Internet communications, create an xplUDP object.
2) Call xplDevice::Create to generate a new xplDevice object, passing in the communications object created in step 1.
3) Create any config items that your application requires, and use the AddConfigItem method to add them to the xplDevice.
4) Finish with a call to xplDevice::Init. This will load any existing configuration and signal the config event so your application can do any initialisation that is based on its config item values.
That is all there is to it. When you are finished, simply call xplDevice::Destroy to delete the xplDevice object.
Note: xPL messages not related to configuration will be ignored until the application leaves config mode (i.e. when the user has configured it in xPLHal). During this time your application will also be unable to send any xPL Messages, and should hold off performing its main functions. The method xplDevice::IsInConfigMode can be used to determine whether your processing should go ahead.
Public Member Functions | |
bool | Init () |
Initialises the xplDevice. | |
bool | Deinit () |
Deinitialises the xplDevice. | |
void | Pause () |
Pauses the xplDevice. | |
void | Resume () |
Unpauses the xplDevice. | |
bool | IsWaitingForHub () const |
Tests whether the application is waiting for the hub to appear. | |
bool | IsInConfigMode () const |
Tests whether the application is in config mode. | |
bool | SendMsg (xplMsg *_pMsg) |
Sends an xPL message. | |
xplMsg * | GetMsg () |
Gets the next xPL message from the queue of received messages. | |
HANDLE | GetMsgEvent () |
Gets an event that when signalled, indicates that an xPL message has been received. | |
HANDLE | GetConfigEvent () |
Gets an event that when signalled, indicates that the config items have changed. | |
bool | AddConfigItem (xplConfigItem *_pItem) |
Adds a config item to the device. | |
bool | RemoveConfigItem (string const &_name) |
Removes a config item to the device. | |
xplConfigItem const * | GetConfigItem (string const &_name) const |
Gets the config item with the specified name. | |
string const & | GetVendorId () const |
Gets the vendor ID string. | |
string const & | GetDeviceId () const |
Gets the device ID string. | |
string const & | GetInstanceId () const |
Gets the instance ID string. | |
string const & | GetCompleteId () const |
Gets a complete ID string. | |
void | SetInstanceId (string const &_instanceId) |
Sets the instance id. | |
Static Public Member Functions | |
static xplDevice * | Create (string const &_vendorId, string const &_deviceId, string const &_version, bool const _bConfigInRegistry, bool const _bFilterMsgs, xplComms *_pComms) |
Create an xplDevice. | |
static void | Destroy (xplDevice *_pDevice) |
Deletes the xplDevice and cleans up any associated objects. |