mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-18 05:23:34 +08:00
Node<> and NodeStatusProvider updated
This commit is contained in:
@@ -156,19 +156,25 @@ public:
|
||||
void setName(const char* name) { proto_nsp_.setName(name); }
|
||||
|
||||
/**
|
||||
* Status code helpers.
|
||||
* Node health code helpers.
|
||||
*/
|
||||
void setStatusOk() { proto_nsp_.setStatusOk(); }
|
||||
void setStatusInitializing() { proto_nsp_.setStatusInitializing(); }
|
||||
void setStatusWarning() { proto_nsp_.setStatusWarning(); }
|
||||
void setStatusCritical() { proto_nsp_.setStatusCritical(); }
|
||||
void setHealthOk() { proto_nsp_.setHealthOk(); }
|
||||
void setHealthWarning() { proto_nsp_.setHealthWarning(); }
|
||||
void setHealthError() { proto_nsp_.setHealthError(); }
|
||||
void setHealthCritical() { proto_nsp_.setHealthCritical(); }
|
||||
|
||||
/**
|
||||
* Sets the status OFFLINE and publishes it immediately.
|
||||
* Node mode code helpers.
|
||||
* Note that INITIALIZATION is the default mode; the application has to manually set it to OPERATIONAL.
|
||||
*/
|
||||
void setStatusOffline()
|
||||
void setModeOperational() { proto_nsp_.setModeOperational(); }
|
||||
void setModeInitialization() { proto_nsp_.setModeInitialization(); }
|
||||
void setModeMaintenance() { proto_nsp_.setModeMaintenance(); }
|
||||
void setModeSoftwareUpdate() { proto_nsp_.setModeSoftwareUpdate(); }
|
||||
|
||||
void setModeOfflineAndPublish()
|
||||
{
|
||||
proto_nsp_.setStatusOffline();
|
||||
proto_nsp_.setModeOffline();
|
||||
(void)proto_nsp_.forcePublish();
|
||||
}
|
||||
|
||||
|
||||
@@ -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