FireSync API
 All Classes Files Functions Variables Typedefs Friends Macros Modules Pages
kSystem Class Reference

Description

Represents a collection of FireSync nodes (sensors).

The kSystem class supports node discovery, provides a variety of convenience functions to support multi-node operations, and supports receiving data and health messages from nodes.

When using the normal kSystem constructor (kSystem_Construct), an initial round of node discovery occurs before the constructor returns. After construction, any nodes that were detected can be accessed using the kSystem_NodeCount and kSystem_NodeAt methods.

Changes to system topology (e.g., new sensor found, existing sensor goes offline) are detected asynchronously in a background thread. However, nodes are not automatically added to or removed from a system object. To learn whether topology changes have been detected, use the thread-safe kSystem_HasChanges method. To update the system object to reflect the latest changes, use the kSystem_Refresh method.

The kSystem_Connect, kSystem_Disconnect, kSystem_Verify, and kSystem_Apply methods can be used to perform common system-wide operations.

The kSystem_Start and kSystem_Stop methods are typically used to start/stop data acquisition and processing activities across multiple nodes. The kSystem_SetDataHandler function can be used to register for asynchronous data delivery. Alternatively, the kSystem_ReceiveData function can be used to poll for new data messages. A variety of other methods are provided for more advanced start/stop operations.

The kSystem_OpenHealth and kSystem_CloseHealth methods are typically used to open/close channels to receive periodic health messages from nodes. The kSystem_SetHealthHandler function can be used to register for asynchronous health delivery. Alternatively, the kSystem_ReceiveHealth function can be used to poll for new health messages.

kSystem methods are not thread-safe, except where noted.

The following example illustrates how to connect, register for data, and start all nodes.

kStatus MyApp_RunSensors(MyApp app)
{
kSystem system = kNULL;
{
//construct a FireSync system object; discovers nodes in the network
kTest(kSystem_Construct(&system, kNULL));
//establish control connections to all sensors (best effort; does not fail if some cannot be connected)
//register for data messages
kTest(kSystem_SetDataHandler(system, MyApp_OnData, app));
//start all connected sensors
kTest(kSystem_Start(system));
//give the sensors a few seconds to run; any data messages will be received by the registered handler
kTest(kThread_Sleep(5*1000*1000));
//stop all connected sensors
kTest(kSystem_Stop(system));
}
{
kObject_Destroy(system);
}
return kOK;
}
kStatus kCall MyApp_OnData(MyApp app, kSystem system, kMsgInfo msgInfo)
{
//do something with the data
//...
kObject_Dispose(msgInfo);
return kOK;
}
Inheritance diagram for kSystem:
Inheritance graph

Public Member Functions

kStatus kSystem_AddDiscovery (kSystem system, kDiscoveryProvider provider)
 Adds a discovery provider to the system. More...
 
kStatus kSystem_AddDiscoveryAdapter (kSystem system, const kChar *interfaceName)
 Specifies a network adapter to be used for discovery. More...
 
kStatus kSystem_AddServerNode (kSystem system, kHxNode hardwareNode, kSvNode *serverNode)
 Adds a server node to the system. More...
 
kStatus kSystem_Apply (kSystem system)
 Sends current settings to all modified nodes. More...
 
kSystemChange kSystem_Changes (kSystem system)
 Reports system changes that have occurred. More...
 
kStatus kSystem_ClearData (kSystem system)
 Clears all data from the data queue. More...
 
kStatus kSystem_ClearDiscovery (kSystem system)
 Removes all discovery providers and adapters from the system. More...
 
kStatus kSystem_ClearHealth (kSystem system)
 Clears all health messages from the health queue. More...
 
kStatus kSystem_CloseData (kSystem system)
 Closes data connections to all connected nodes. More...
 
kStatus kSystem_CloseHealth (kSystem system)
 Closes all health channels. More...
 
kStatus kSystem_CloseHostHealth (kSystem system)
 Closes channel to local host health provider. More...
 
kStatus kSystem_Connect (kSystem system)
 Attempts to connects to all discovered nodes. More...
 
kStatus kSystem_Construct (kSystem *system, kAlloc allocator)
 Constructs a kSystem object with default discovery providers. More...
 
kStatus kSystem_ConstructEx (kSystem *system, kAlloc allocator)
 Constructs a kSystem object without automatically starting discovery clients. More...
 
kStatus kSystem_ConstructServerSystem (kSystem *system, kSvNode *serverNode, kAlloc allocator)
 Constructs a kSystem object and adds a server node that is bound to the hardware platform singleton node. More...
 
kSize kSystem_DataNetBufferSize (kSystem system)
 Gets the per-node network buffer size for data channels. More...
 
kSize kSystem_DataQueueSize (kSystem system)
 Reports the maximum total data size of all items in the data queue. More...
 
kStatus kSystem_Disconnect (kSystem system)
 Disconnects from all nodes. More...
 
kStatus kSystem_EndDataSession (kSystem system)
 Ends data collection from all connected nodes until the next time that nodes are started/resumed. More...
 
kStatus kSystem_EngageNodes (kSystem system, k64u startTime, k64s startEncoder)
 Engages all connected nodes (finalizes a start or resume operation). More...
 
kStatus kSystem_ErrorAt (kSystem system, kSize index, kChar *error, kSize capacity)
 Gets the verification error string at the specified index. More...
 
kSize kSystem_ErrorCount (kSystem system)
 Returns the number of errors that were detected when the system was last verified. More...
 
kStatus kSystem_FindDiscoveryProvider (kSystem system, kType providerType, kDiscoveryProvider *provider)
 Locates the specified discovery provider. More...
 
kStatus kSystem_FindNode (kSystem system, k32u id, kNode *node)
 Finds the node with the specified id. More...
 
kBool kSystem_HasChanges (kSystem system)
 Reports whether the system has changes that require a refresh. More...
 
kNode kSystem_NodeAt (kSystem system, kSize index)
 Gets the node at the specified index. More...
 
kSize kSystem_NodeCount (kSystem system)
 Reports the number of nodes in the system. More...
 
kStatus kSystem_OpenData (kSystem system)
 Opens data connections to all connected nodes. More...
 
kStatus kSystem_OpenHealth (kSystem system)
 Opens health channels to all connected nodes. More...
 
kStatus kSystem_OpenHostHealth (kSystem system)
 Opens channel to local host health provider. More...
 
kStatus kSystem_ReceiveData (kSystem system, kMsgInfo *msg, k64u timeout)
 Waits until at least one data message has been received and then returns the message. More...
 
kStatus kSystem_ReceiveHealth (kSystem system, kHealthMsg *info, k64u timeout)
 Waits until at least one health message has been received and then returns the message. More...
 
kStatus kSystem_Refresh (kSystem system)
 Updates client state to reflect any changes that have occurred in the node network. More...
 
kStatus kSystem_RefreshEx (kSystem system, kBool forceAll, kArrayList removed, kArrayList added, kArrayList refreshed)
 Updates client state to reflect any changes that have occurred in the node network. More...
 
kStatus kSystem_RemoveAllServerNodes (kSystem system)
 Removes all server nodes from the system. More...
 
kStatus kSystem_RemoveDiscovery (kSystem system, kType providerType)
 Removes a discovery provider from the system. More...
 
kStatus kSystem_RemoveServerNode (kSystem system, k32u nodeId)
 Removes a server node from the system. More...
 
kStatus kSystem_SetDataHandler (kSystem system, kCallbackFx function, kPointer receiver)
 Registers a callback function that can be used to receive data messages. More...
 
kStatus kSystem_SetDataNetBufferSize (kSystem system, kSize size)
 Sets the per-node network buffer size for data channels. More...
 
kStatus kSystem_SetDataQueueSize (kSystem system, kSize size)
 Sets the maximum amount of data retained by the data queue. More...
 
kStatus kSystem_SetHealthHandler (kSystem system, kCallbackFx function, kPointer receiver)
 Registers a callback function that can be used to receive health messages. More...
 
kStatus kSystem_SetHostHealthProvider (kSystem system, kHealth provider, k32u id)
 Installs a health provider that can be used to generate health statistics for the local host. More...
 
kStatus kSystem_SetNodeFilter (kSystem system, kNodeFilterFx filter, kPointer receiver)
 Registers a callback function that can be used to filter discovered nodes. More...
 
kStatus kSystem_Start (kSystem system)
 Opens data connections and starts all connected sensors. More...
 
kStatus kSystem_StartDiscovery (kSystem system)
 Starts discovery client. More...
 
kStatus kSystem_StartNodes (kSystem system)
 Prepares all connected nodes to be started. More...
 
kStatus kSystem_StartRescue (kSystem system)
 Starts broadcasting rescue request messages. More...
 
kStatus kSystem_Stop (kSystem system)
 Ends data sessions and stops all connected sensors. More...
 
kStatus kSystem_StopDiscovery (kSystem system)
 Stops discovery client. More...
 
kStatus kSystem_StopNodes (kSystem system)
 Stops all connected nodes. More...
 
kStatus kSystem_StopRescue (kSystem system)
 Stops broadcasting rescue request messages. More...
 
kStatus kSystem_Verify (kSystem system)
 Checks the validity of all system settings. More...
 
kStatus kSystem_WarningAt (kSystem system, kSize index, kChar *warning, kSize capacity)
 Gets the verification warning string at the specified index. More...
 
kSize kSystem_WarningCount (kSystem system)
 Returns the number of warnings that were detected when the system was last verified. More...
 

Related

#define kSYSTEM_DATA_NET_BUFFER_SIZE_LARGE
 Recommended net buffer size for systems with few sensors (e.g., 1-2).
 
#define kSYSTEM_DATA_NET_BUFFER_SIZE_MEDIUM
 Recommended net buffer size for systems with multiple sensors (e.g., 3-10).
 
#define kSYSTEM_DATA_NET_BUFFER_SIZE_SMALL
 Recommended net buffer size for systems with many sensors (e.g., 10+).
 
#define kSYSTEM_DATA_NET_BUFFER_SIZE_DEFAULT
 Default net buffer size.
 

The documentation for this class was generated from the following files: