mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 21:53:33 +08:00
Node<> and NodeStatusProvider updated
This commit is contained in:
@@ -18,7 +18,12 @@ namespace uavcan
|
||||
{
|
||||
/**
|
||||
* Provides the status and basic information about this node to other network participants.
|
||||
*
|
||||
* Usually the application does not need to deal with this class directly - it's instantiated by the node class.
|
||||
*
|
||||
* Default values:
|
||||
* - health - OK
|
||||
* - mode - INITIALIZATION
|
||||
*/
|
||||
class UAVCAN_EXPORT NodeStatusProvider : private TimerBase
|
||||
{
|
||||
@@ -54,7 +59,9 @@ public:
|
||||
{
|
||||
UAVCAN_ASSERT(!creation_timestamp_.isZero());
|
||||
|
||||
node_info_.status.status_code = protocol::NodeStatus::STATUS_INITIALIZING;
|
||||
node_info_.status.mode = protocol::NodeStatus::MODE_INITIALIZATION;
|
||||
|
||||
node_info_.status.health = protocol::NodeStatus::HEALTH_OK;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -78,15 +85,25 @@ public:
|
||||
uavcan::MonotonicDuration getStatusPublicationPeriod() const;
|
||||
|
||||
/**
|
||||
* Local node status code control.
|
||||
* Local node health code control.
|
||||
*/
|
||||
uint8_t getStatusCode() const { return node_info_.status.status_code; }
|
||||
void setStatusCode(uint8_t code);
|
||||
void setStatusOk() { setStatusCode(protocol::NodeStatus::STATUS_OK); }
|
||||
void setStatusInitializing() { setStatusCode(protocol::NodeStatus::STATUS_INITIALIZING); }
|
||||
void setStatusWarning() { setStatusCode(protocol::NodeStatus::STATUS_WARNING); }
|
||||
void setStatusCritical() { setStatusCode(protocol::NodeStatus::STATUS_CRITICAL); }
|
||||
void setStatusOffline() { setStatusCode(protocol::NodeStatus::STATUS_OFFLINE); }
|
||||
uint8_t getHealth() const { return node_info_.status.health; }
|
||||
void setHealth(uint8_t code);
|
||||
void setHealthOk() { setHealth(protocol::NodeStatus::HEALTH_OK); }
|
||||
void setHealthWarning() { setHealth(protocol::NodeStatus::HEALTH_WARNING); }
|
||||
void setHealthError() { setHealth(protocol::NodeStatus::HEALTH_ERROR); }
|
||||
void setHealthCritical() { setHealth(protocol::NodeStatus::HEALTH_CRITICAL); }
|
||||
|
||||
/**
|
||||
* Local node mode code control.
|
||||
*/
|
||||
uint8_t getMode() const { return node_info_.status.mode; }
|
||||
void setMode(uint8_t code);
|
||||
void setModeOperational() { setMode(protocol::NodeStatus::MODE_OPERATIONAL); }
|
||||
void setModeInitialization() { setMode(protocol::NodeStatus::MODE_INITIALIZATION); }
|
||||
void setModeMaintenance() { setMode(protocol::NodeStatus::MODE_MAINTENANCE); }
|
||||
void setModeSoftwareUpdate() { setMode(protocol::NodeStatus::MODE_SOFTWARE_UPDATE); }
|
||||
void setModeOffline() { setMode(protocol::NodeStatus::MODE_OFFLINE); }
|
||||
|
||||
/**
|
||||
* Local node vendor-specific status code control.
|
||||
|
||||
Reference in New Issue
Block a user