Classes | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
uavcan::NodeStatusMonitor Class Reference

#include <node_status_monitor.hpp>

Inheritance diagram for uavcan::NodeStatusMonitor:
Inheritance graph
[legend]

Classes

struct  Entry
 
struct  NodeStatus
 
struct  NodeStatusChangeEvent
 

Public Member Functions

NodeID findNodeWithWorstHealth () const
 
template<typename Operator >
void forEachNode (Operator op) const
 
void forgetAllNodes ()
 
void forgetNode (NodeID node_id)
 
NodeStatus getNodeStatus (NodeID node_id) const
 
bool isNodeKnown (NodeID node_id) const
 
 NodeStatusMonitor (INode &node)
 
int start ()
 
virtual ~NodeStatusMonitor ()
 

Protected Member Functions

virtual void handleNodeStatusChange (const NodeStatusChangeEvent &event)
 
virtual void handleNodeStatusMessage (const ReceivedDataStructure< protocol::NodeStatus > &msg)
 

Private Types

enum  { TimerPeriodMs100 = 2 }
 
typedef MethodBinder< NodeStatusMonitor *, void(NodeStatusMonitor::*)(const ReceivedDataStructure< protocol::NodeStatus > &)> NodeStatusCallback
 
typedef MethodBinder< NodeStatusMonitor *, void(NodeStatusMonitor::*)(const TimerEvent &)> TimerCallback
 

Private Member Functions

void changeNodeStatus (const NodeID node_id, const Entry new_entry_value)
 
EntrygetEntry (NodeID node_id) const
 
void handleNodeStatus (const ReceivedDataStructure< protocol::NodeStatus > &msg)
 
void handleTimerEvent (const TimerEvent &)
 

Private Attributes

Entry entries_ [NodeID::Max]
 
Subscriber< protocol::NodeStatus, NodeStatusCallbacksub_
 
TimerEventForwarder< TimerCallbacktimer_
 

Detailed Description

This class implements the core functionality of a network monitor. It can be extended by inheritance to add more complex logic, or used directly as is.

Definition at line 22 of file node_status_monitor.hpp.

Member Typedef Documentation

◆ NodeStatusCallback

typedef MethodBinder<NodeStatusMonitor*, void (NodeStatusMonitor::*)(const ReceivedDataStructure<protocol::NodeStatus>&)> uavcan::NodeStatusMonitor::NodeStatusCallback
private

Definition at line 77 of file node_status_monitor.hpp.

◆ TimerCallback

typedef MethodBinder<NodeStatusMonitor*, void (NodeStatusMonitor::*)(const TimerEvent&)> uavcan::NodeStatusMonitor::TimerCallback
private

Definition at line 79 of file node_status_monitor.hpp.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
TimerPeriodMs100 

Definition at line 73 of file node_status_monitor.hpp.

Constructor & Destructor Documentation

◆ NodeStatusMonitor()

uavcan::NodeStatusMonitor::NodeStatusMonitor ( INode node)
inlineexplicit

Definition at line 184 of file node_status_monitor.hpp.

◆ ~NodeStatusMonitor()

virtual uavcan::NodeStatusMonitor::~NodeStatusMonitor ( )
inlinevirtual

Definition at line 189 of file node_status_monitor.hpp.

Member Function Documentation

◆ changeNodeStatus()

void uavcan::NodeStatusMonitor::changeNodeStatus ( const NodeID  node_id,
const Entry  new_entry_value 
)
inlineprivate

Definition at line 105 of file node_status_monitor.hpp.

◆ findNodeWithWorstHealth()

NodeID uavcan::NodeStatusMonitor::findNodeWithWorstHealth ( ) const
inline

This helper method allows to quickly estimate the overall network health. Health of the local node is not considered. Returns an invalid Node ID value if there's no known nodes in the network.

Definition at line 277 of file node_status_monitor.hpp.

◆ forEachNode()

template<typename Operator >
void uavcan::NodeStatusMonitor::forEachNode ( Operator  op) const
inline

Calls the operator for every known node. Operator signature: void (NodeID, NodeStatus)

Definition at line 306 of file node_status_monitor.hpp.

◆ forgetAllNodes()

void uavcan::NodeStatusMonitor::forgetAllNodes ( )
inline

Make all nodes unknown.

Definition at line 226 of file node_status_monitor.hpp.

◆ forgetNode()

void uavcan::NodeStatusMonitor::forgetNode ( NodeID  node_id)
inline

Make the node unknown.

Definition at line 210 of file node_status_monitor.hpp.

◆ getEntry()

Entry& uavcan::NodeStatusMonitor::getEntry ( NodeID  node_id) const
inlineprivate

Definition at line 96 of file node_status_monitor.hpp.

◆ getNodeStatus()

NodeStatus uavcan::NodeStatusMonitor::getNodeStatus ( NodeID  node_id) const
inline

Returns status of a given node. Unknown nodes are considered offline. Complexity O(1).

Definition at line 239 of file node_status_monitor.hpp.

◆ handleNodeStatus()

void uavcan::NodeStatusMonitor::handleNodeStatus ( const ReceivedDataStructure< protocol::NodeStatus > &  msg)
inlineprivate

Definition at line 125 of file node_status_monitor.hpp.

◆ handleNodeStatusChange()

virtual void uavcan::NodeStatusMonitor::handleNodeStatusChange ( const NodeStatusChangeEvent event)
inlineprotectedvirtual

Called when a node becomes online, changes status or goes offline. Refer to uavcan.protocol.NodeStatus for the offline timeout value. Overriding is not required.

Reimplemented in uavcan::NodeInfoRetriever.

Definition at line 168 of file node_status_monitor.hpp.

◆ handleNodeStatusMessage()

virtual void uavcan::NodeStatusMonitor::handleNodeStatusMessage ( const ReceivedDataStructure< protocol::NodeStatus > &  msg)
inlineprotectedvirtual

Called for every received message uavcan.protocol.NodeStatus after handleNodeStatusChange(), even if the status code did not change. Overriding is not required.

Reimplemented in uavcan::NodeInfoRetriever.

Definition at line 178 of file node_status_monitor.hpp.

◆ handleTimerEvent()

void uavcan::NodeStatusMonitor::handleTimerEvent ( const TimerEvent )
inlineprivate

Definition at line 138 of file node_status_monitor.hpp.

◆ isNodeKnown()

bool uavcan::NodeStatusMonitor::isNodeKnown ( NodeID  node_id) const
inline

Whether the class has observed this node at least once since initialization. Complexity O(1).

Definition at line 262 of file node_status_monitor.hpp.

◆ start()

int uavcan::NodeStatusMonitor::start ( )
inline

Starts the monitor. Destroy the object to stop it. Returns negative error code.

Definition at line 196 of file node_status_monitor.hpp.

Member Data Documentation

◆ entries_

Entry uavcan::NodeStatusMonitor::entries_[NodeID::Max]
mutableprivate

Definition at line 94 of file node_status_monitor.hpp.

◆ sub_

Subscriber<protocol::NodeStatus, NodeStatusCallback> uavcan::NodeStatusMonitor::sub_
private

Definition at line 81 of file node_status_monitor.hpp.

◆ timer_

TimerEventForwarder<TimerCallback> uavcan::NodeStatusMonitor::timer_
private

Definition at line 83 of file node_status_monitor.hpp.


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


uavcan_communicator
Author(s):
autogenerated on Fri Dec 13 2024 03:10:05