File Information
Library: IoT/Devices
Package: Generated
Header: IoT/Devices/IDevice.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:
- io.macchina.composite (Composite)
- io.macchina.accelerometer (Accelerometer)
- io.macchina.barcode (BarcodeReader)
- io.macchina.gnss (GNSSSensor)
- io.macchina.gyroscope (Gyroscope)
- io.macchina.io (IO)
- io.macchina.led (LED)
- io.macchina.magnetometer (Magnetometer)
- io.macchina.rotary (RotaryEncoder)
- io.macchina.sensor (Sensor)
- io.macchina.boolean (BooleanSensor)
- io.macchina.counter (Counter)
- io.macchina.serial (SerialDevice)
- io.macchina.switch (Switch)
- io.macchina.trigger (Trigger)
- io.macchina.datapoint (Datapoint)
- io.macchina.datapoint.scalar (ScalarDatapoint)
- io.macchina.datapoint.vector (VectorDatapoint)
- io.macchina.datapoint.counter (CounterDatapoint)
- io.macchina.datapoint.boolean (BooleanDatapoint)
- io.macchina.datapoint.string (StringDatapoint)
- io.macchina.datapoint.enum (EnumDatapoint)
- io.macchina.datapoint.flags (FlagsDatapoint)
Inheritance
Direct Base Classes: Poco::OSP::Service
All Base Classes: Poco::OSP::Service, Poco::RefCountedObject
Known Derived Classes: CounterRemoteObject, CompositeRemoteObject, IFlagsDatapoint, ILED, SensorRemoteObject, BarcodeReaderRemoteObject, BooleanDatapointRemoteObject, BooleanSensorRemoteObject, FlagsDatapointRemoteObject, ICounterDatapoint, IGyroscope, ISerialDevice, IRotaryEncoder, LEDRemoteObject, VectorDatapointRemoteObject, IBooleanDatapoint, IDatapoint, IORemoteObject, MagnetometerRemoteObject, RotaryEncoderRemoteObject, SerialDeviceRemoteObject, TriggerRemoteObject, DeviceRemoteObject, ISwitch, ISensor, EnumDatapointRemoteObject, IIO, ScalarDatapointRemoteObject, CameraRemoteObject, CounterDatapointRemoteObject, DatapointRemoteObject, GNSSSensorRemoteObject, IBarcodeReader, IComposite, ICounter, IVectorDatapoint, IGNSSSensor, IScalarDatapoint, IStringDatapoint, SwitchRemoteObject, AccelerometerRemoteObject, GyroscopeRemoteObject, IAccelerometer, IBooleanSensor, ICamera, IEnumDatapoint, IMagnetometer, ITrigger, StringDatapointRemoteObject
Member Summary
Member Functions: getFeature, getPropertyBool, getPropertyDouble, getPropertyInt, getPropertyInt16, getPropertyInt64, getPropertyString, getPropertyTimestamp, hasFeature, hasProperty, isA, remoting__enableEvents, remoting__typeId, setFeature, setPropertyBool, setPropertyDouble, setPropertyInt, setPropertyInt16, setPropertyInt64, setPropertyString, setPropertyTimestamp, type
Inherited Functions: duplicate, isA, referenceCount, release, type
Types Aliases
Ptr
using Ptr = Poco::AutoPtr < IDevice >;
Constructors
IDevice
IDevice();
Creates a IDevice.
Destructor
~IDevice
virtual ~IDevice();
Destroys the IDevice.
Member Functions
getFeature
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 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 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 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 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 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 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 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 bool hasFeature(
const std::string & name
) const = 0;
Returns true if the feature with the given name is known, or false otherwise.
hasProperty
virtual bool hasProperty(
const std::string & name
) const = 0;
Returns true if the property with the given name exists, or false otherwise.
isA
bool isA(
const std::type_info & otherType
) const;
Returns true if the class is a subclass of the class given by otherType.
See also: Poco::OSP::Service::isA()
remoting__enableEvents
virtual std::string remoting__enableEvents(
Poco::RemotingNG::Listener::Ptr pListener,
bool enable = bool (true)
) = 0;
Enable or disable delivery of remote events.
The given Listener instance must implement the Poco::RemotingNG::EventListener interface, otherwise this method will fail with a RemotingException.
This method is only used with Proxy objects; calling this method on a RemoteObject will do nothing.
remoting__typeId
static const Poco::RemotingNG::Identifiable::TypeId & remoting__typeId();
Returns the TypeId of the class.
setFeature
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 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 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 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 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 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 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 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.
type
const std::type_info & type() const;
Returns the type information for the object's class.
See also: Poco::OSP::Service::type()
Variables
statusChanged
Poco::BasicEvent < const IoT::Devices::DeviceStatusChange > statusChanged;