IoT::DeviceStatus

class DeviceStatusService

File Information

Library: IoT/DeviceStatus
Package: DeviceStatusService
Header: IoT/DeviceStatus/DeviceStatusService.h

Description

The DeviceStatusService keeps track of the current operational status of a device.

Member Summary

Member Functions: acknowledge, acknowledgeUpTo, clearStatus, clearStatusOfSource, messages, postStatus, postStatusAsync, remove, reset, status, statusOfSource

Types Aliases

Ptr

using Ptr = Poco::SharedPtr < DeviceStatusService >;

StatusID

using StatusID = Poco::UInt32;

Constructors

DeviceStatusService

DeviceStatusService();

Creates the DeviceStatusService.

Destructor

~DeviceStatusService virtual

virtual ~DeviceStatusService();

Destroys the DeviceStatusService.

Member Functions

acknowledge virtual

virtual DeviceStatus acknowledge(
    Poco::Int64 id
) = 0;

Marks the message with the given ID as acknowledged, if it is acknowledgeable.

Returns the new device status.

acknowledgeUpTo virtual

virtual DeviceStatus acknowledgeUpTo(
    Poco::Int64 id
) = 0;

Marks all acknowledgeable messages up to (and including) the given ID as acknowledged.

Returns the new device status.

clearStatus virtual

virtual DeviceStatus clearStatus(
    const std::string & messageClass
) = 0;

Clears the status update with the given messageClass and removes it from the message history.

Returns the new device status.

clearStatusOfSource virtual

virtual DeviceStatus clearStatusOfSource(
    const std::string & source
) = 0;

Clears all status updates with the given source and removes them from the message history.

Returns the new device status.

messages virtual

virtual std::vector < StatusMessage > messages(
    int maxMessages = 0
) const = 0;

Retrieves stored status messages. If maxMessages is > 0, will at most return maxMessages messages.

postStatus virtual

virtual DeviceStatusChange postStatus(
    const StatusUpdate & statusUpdate
) = 0;

Updates the device status.

Returns a DeviceStatusChange structure.

postStatusAsync virtual

virtual void postStatusAsync(
    const StatusUpdate & statusUpdate
) = 0;

Updates the device status asynchronously.

The actual status update in the database will be done asynchronously in a separate thread.

remove virtual

virtual DeviceStatus remove(
    Poco::Int64 id
) = 0;

Removes the message with the given ID from the message history.

Returns the new device status.

reset virtual

virtual void reset() = 0;

Resets the device status to DEVICE_STATUS_OK and removes all messages.

status virtual

virtual DeviceStatus status() const = 0;

Returns the current global device status.

Only unacknowledged status updates are considered in determining the current status.

statusOfSource virtual

virtual DeviceStatus statusOfSource(
    const std::string & source
) const = 0;

Returns the current source-specific device status, considering only status updates with the given source.

Only unacknowledged status updates are considered in determining the current status.

Variables

statusChanged

Poco::BasicEvent < const DeviceStatusChange > statusChanged;

Fired when the device status level has changed. Not every call to postStatus() or postStatusAsync() will trigger a statusChanged event.

statusUpdated

Poco::BasicEvent < const DeviceStatusChange > statusUpdated;

Fired when the device status has been updated by calling postStatus() or postStatusAsync(), regardless of whether the device status level has changed or not.

Securely control IoT edge devices from anywhere   Connect a Device