IoT::Devices

class Device

File Information

Library: IoT/Devices
Package: Devices
Header: IoT/Devices/Device.h

Description

The base class for all devices and sensors.

This class defines a generic interface for setting and querying device properties and features.

The class also defines an event for notifications about changes to the device status.

Every implementation of Device should expose the following properties:

  • symbolicName: A name in reverse DNS notation that identifies the specific implementation of the device type.
  • type (string): A name in reverse DNS notation that identifies the generic device type (e.g., "io.macchina.serial").
  • name (string): A human-readable device type (e.g., "Serial Port").
  • status (int): Current device status (DeviceStatus); optional.

The following generic device types are currently defined:

Inheritance

Known Derived Classes: FlagsDatapoint, RotaryEncoder, ScalarDatapoint, SerialDevice, Camera, IO, LED, Switch, VectorDatapoint, BooleanSensor, EnumDatapoint, GNSSSensor, StringDatapoint, CounterDatapoint, Magnetometer, Sensor, Datapoint, BarcodeReader, BooleanDatapoint, Trigger, Composite, Accelerometer, Counter, Gyroscope

Member Summary

Member Functions: getFeature, getPropertyBool, getPropertyDouble, getPropertyInt, getPropertyInt16, getPropertyInt64, getPropertyString, getPropertyTimestamp, hasFeature, hasProperty, setFeature, setPropertyBool, setPropertyDouble, setPropertyInt, setPropertyInt16, setPropertyInt64, setPropertyString, setPropertyTimestamp

Constructors

Device

Device();

Creates the Device.

Destructor

~Device virtual

virtual ~Device();

Destroys the Device.

Member Functions

getFeature virtual

virtual bool getFeature(
    const std::string & name
) const = 0;

Returns true if the feature with the given name is enabled, or false otherwise.

getPropertyBool virtual

virtual bool getPropertyBool(
    const std::string & name
) const = 0;

Returns the value of the device property with the given name.

Throws a Poco::NotFoundException if the property with the given name is unknown.

getPropertyDouble virtual

virtual double getPropertyDouble(
    const std::string & name
) const = 0;

Returns the value of the device property with the given name.

Throws a Poco::NotFoundException if the property with the given name is unknown.

getPropertyInt virtual

virtual int getPropertyInt(
    const std::string & name
) const = 0;

Returns the value of the device property with the given name.

Throws a Poco::NotFoundException if the property with the given name is unknown.

getPropertyInt16 virtual

virtual Poco::Int16 getPropertyInt16(
    const std::string & name
) const = 0;

Returns the value of the device property with the given name.

Throws a Poco::NotFoundException if the property with the given name is unknown.

getPropertyInt64 virtual

virtual Poco::Int64 getPropertyInt64(
    const std::string & name
) const = 0;

Returns the value of the device property with the given name.

Throws a Poco::NotFoundException if the property with the given name is unknown.

getPropertyString virtual

virtual std::string getPropertyString(
    const std::string & name
) const = 0;

Returns the value of the device property with the given name.

Throws a Poco::NotFoundException if the property with the given name is unknown.

getPropertyTimestamp virtual

virtual Poco::Timestamp getPropertyTimestamp(
    const std::string & name
) const = 0;

Returns the value of the device property with the given name.

Throws a Poco::NotFoundException if the property with the given name is unknown.

hasFeature virtual

virtual bool hasFeature(
    const std::string & name
) const = 0;

Returns true if the feature with the given name is known, or false otherwise.

hasProperty virtual

virtual bool hasProperty(
    const std::string & name
) const = 0;

Returns true if the property with the given name exists, or false otherwise.

setFeature virtual

virtual void setFeature(
    const std::string & name,
    bool enable
) = 0;

Enables or disables the feature with the given name.

Which features are supported is defined by the actual device implementation.

setPropertyBool virtual

virtual void setPropertyBool(
    const std::string & name,
    bool value
) = 0;

Sets a device property.

Which properties are supported is defined by the actual device implementation.

setPropertyDouble virtual

virtual void setPropertyDouble(
    const std::string & name,
    double value
) = 0;

Sets a device property.

Which properties are supported is defined by the actual device implementation.

setPropertyInt virtual

virtual void setPropertyInt(
    const std::string & name,
    int value
) = 0;

Sets a device property.

Which properties are supported is defined by the actual device implementation.

setPropertyInt16 virtual

virtual void setPropertyInt16(
    const std::string & name,
    Poco::Int16 value
) = 0;

Sets a device property.

Which properties are supported is defined by the actual device implementation.

setPropertyInt64 virtual

virtual void setPropertyInt64(
    const std::string & name,
    Poco::Int64 value
) = 0;

Sets a device property.

Which properties are supported is defined by the actual device implementation.

setPropertyString virtual

virtual void setPropertyString(
    const std::string & name,
    const std::string & value
) = 0;

Sets a device property.

Which properties are supported is defined by the actual device implementation.

setPropertyTimestamp virtual

virtual void setPropertyTimestamp(
    const std::string & name,
    Poco::Timestamp value
) = 0;

Sets a device property.

Which properties are supported is defined by the actual device implementation.

Variables

statusChanged

Poco::BasicEvent < const DeviceStatusChange > statusChanged;

Fired when the status of the device changes.

Implementing this event is optional. A device implementation should document if this event is supported.

Securely control IoT edge devices from anywhere   Connect a Device