C# Class DeviceHive.DeviceEngine

Base class for DeviceHive .NET Micro Framework devices. All custom devices should be inherited from it.
Show file Open project: devicehive/devicehive-.net-mf Class Usage Examples

Protected Properties

Property Type Description
DcClient IFrameworkClient

Public Methods

Method Description
Connect ( ) : bool

Connects device to network

This function should be called by implementers to make the device connect to DeviceHive network.

Init ( ) : bool

Initializes the device

This function should be called by implementers before any calls to other DeveiceEngine's functions.

ProcessCommands ( ) : bool

Default command processing

This function performs a default command processing, including handling equipment commands and firing events. It should be invoked by implementers to perform a single command processing loop. So, it should be ran continuously.

SendNotification ( INotification notification ) : bool

Sends a notification to the DeviceHive network

This function can be used by implementers to send device-specific notifications.

Protected Methods

Method Description
CreateDeviceData ( ) : Device

This function should be overridden by implementers to return a specific DeviceData structure.

CreateEquipment ( ) : void

Initializes device equipment structure

This function should be overridden by implementers to construct device equipment and fill DeviceData equipment hashtable with equipment. This function is invoked after the device has connected to data network and registered itself. Normally, the constructed equipment should be initialized and send its status to DeviceHive network.

Private Methods

Method Description
FindDevice ( string code ) : EquipmentEngine

Locates an equipment by a specified code

RegisterEquipment ( ) : bool

Registers all equipment in DeviceHive network

UnregisterEquipment ( ) : bool

Unregisters equipment

Method Details

Connect() public method

Connects device to network
This function should be called by implementers to make the device connect to DeviceHive network.
public Connect ( ) : bool
return bool

CreateDeviceData() protected abstract method

This function should be overridden by implementers to return a specific DeviceData structure.
protected abstract CreateDeviceData ( ) : Device
return Device

CreateEquipment() protected abstract method

Initializes device equipment structure
This function should be overridden by implementers to construct device equipment and fill DeviceData equipment hashtable with equipment. This function is invoked after the device has connected to data network and registered itself. Normally, the constructed equipment should be initialized and send its status to DeviceHive network.
protected abstract CreateEquipment ( ) : void
return void

Init() public method

Initializes the device
This function should be called by implementers before any calls to other DeveiceEngine's functions.
public Init ( ) : bool
return bool

ProcessCommands() public method

Default command processing
This function performs a default command processing, including handling equipment commands and firing events. It should be invoked by implementers to perform a single command processing loop. So, it should be ran continuously.
public ProcessCommands ( ) : bool
return bool

SendNotification() public method

Sends a notification to the DeviceHive network
This function can be used by implementers to send device-specific notifications.
public SendNotification ( INotification notification ) : bool
notification INotification Notification to be sent
return bool

Property Details

DcClient protected property

DeviceHive client used to handle API calls.
protected IFrameworkClient DcClient
return IFrameworkClient