BeeeOn Gateway  v2020.3.1-2-g6f737dc
Platform to interconnect the IoT world
Data Structures | Public Types | Public Member Functions | Protected Types | Protected Member Functions
BeeeOn::DeviceStatusFetcher Class Reference

DeviceStatusFetcher is responsible for fetching pairing state of devices for the registered status handlers. The fetching is performed asynchronously and independently resulting in calling to the method DeviceStatusHandler::handleRemoteStatus() on the appropriate handlers. More...

#include <DeviceStatusFetcher.h>

Inheritance diagram for BeeeOn::DeviceStatusFetcher:
BeeeOn::CommandSender BeeeOn::StoppableRunnable BeeeOn::Loggable

Data Structures

class  PrefixAnswer
 To simplify Answer management, include the prefix of the connected ServerDeviceListCommand inside the answer. More...
 
class  PrefixStatus
 

Public Types

typedef Poco::SharedPtr
< DeviceStatusFetcher
Ptr
 
- Public Types inherited from BeeeOn::StoppableRunnable
typedef Poco::SharedPtr
< StoppableRunnable
Ptr
 

Public Member Functions

void setIdleDuration (const Poco::Timespan &duration)
 Set duration how long to sleep while there is nothing to do.
 
void setWaitTimeout (const Poco::Timespan &timeout)
 Set timeout for AnswerQueue::wait() call.
 
void setRepeatTimeout (const Poco::Timespan &timeout)
 Set timeout to wait until a request is re-issued after its unsuccessful finish (Answer was not fully successful).
 
void registerHandler (DeviceStatusHandler::Ptr handler)
 Register the given device status handler. The DeviceStatusFetcher would request a remote pairing registry (server) for the paired devices for that handler.
 
void clearHandlers ()
 Unregister all registered device status handlers.
 
void run () override
 
void stop () override
 
- Public Member Functions inherited from BeeeOn::CommandSender
void setCommandDispatcher (CommandDispatcher *dispatcher)
 
void dispatch (Poco::AutoPtr< Command > cmd, Poco::AutoPtr< Answer > answer)
 
void dispatch (Poco::AutoPtr< Command > cmd)
 
AnswerQueueanswerQueue ()
 

Protected Types

enum  FetchStatus { NOTHING, WOULD_REPEAT, ACTIVE }
 Denote certain situations of the status fetching.
 

Protected Member Functions

FetchStatus fetchUndone ()
 Determine status handlers for which no fully successful request was made and dispatch ServerDeviceListCommand for them. More...
 
PrefixAnswer::Ptr handleDirtyAnswer (Answer::Ptr answer)
 Check status of the given answer and if it is not pending and castable to PrefixAnswer, it performs cast and returns it. More...
 
std::set
< DeviceStatusHandler::Ptr > 
matchHandlers (const PrefixAnswer::Ptr answer) const
 
void processAnswer (PrefixAnswer::Ptr answer, std::set< DeviceStatusHandler::Ptr > handler)
 Process results of the given answer and the matching status handler. When any of the results is unsuccessful, all the answer is considered unsuccessful and it would be marked for repeated fetch. More...
 
void collectPaired (std::set< DeviceID > &paired, const std::vector< DeviceID > &received, const DevicePrefix &prefix) const
 Process paired devices as given in a single Answer result. Only devices matching the given prefix would be used. Other devices are considered as a bug somewhere.
 

Detailed Description

DeviceStatusFetcher is responsible for fetching pairing state of devices for the registered status handlers. The fetching is performed asynchronously and independently resulting in calling to the method DeviceStatusHandler::handleRemoteStatus() on the appropriate handlers.

Member Function Documentation

DeviceStatusFetcher::FetchStatus DeviceStatusFetcher::fetchUndone ( )
protected

Determine status handlers for which no fully successful request was made and dispatch ServerDeviceListCommand for them.

Returns
whether there something to do
DeviceStatusFetcher::PrefixAnswer::Ptr DeviceStatusFetcher::handleDirtyAnswer ( Answer::Ptr  answer)
protected

Check status of the given answer and if it is not pending and castable to PrefixAnswer, it performs cast and returns it.

Returns
instance of PrefixAnswer if it should be processed or null
set< DeviceStatusHandler::Ptr > DeviceStatusFetcher::matchHandlers ( const PrefixAnswer::Ptr  answer) const
protected
Returns
status handler matching the given answer (by prefix)
void DeviceStatusFetcher::processAnswer ( PrefixAnswer::Ptr  answer,
std::set< DeviceStatusHandler::Ptr >  handler 
)
protected

Process results of the given answer and the matching status handler. When any of the results is unsuccessful, all the answer is considered unsuccessful and it would be marked for repeated fetch.

If there is at least one successful result, the method DeviceStatusHandler::handleRemoteStatus() is called once on the given handler as a result of the answer processing.

void DeviceStatusFetcher::stop ( )
overridevirtual

Stop the runnable. The call should not block.

Implements BeeeOn::StoppableRunnable.


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