mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-07-22 00:50:34 +08:00
Added some getters to the Node<> class
This commit is contained in:
@@ -150,10 +150,11 @@ public:
|
|||||||
int start(const TransferPriority node_status_transfer_priority = TransferPriority::Default);
|
int start(const TransferPriority node_status_transfer_priority = TransferPriority::Default);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the node name, e.g. "com.example.product_name". The node name can be set only once.
|
* Gets/sets the node name, e.g. "com.example.product_name". The node name can be set only once.
|
||||||
* Must be executed before the node is started, otherwise the node will refuse to start up.
|
* The name must be set before the node is started, otherwise the node will refuse to start up.
|
||||||
*/
|
*/
|
||||||
void setName(const char* name) { proto_nsp_.setName(name); }
|
const NodeStatusProvider::NodeName& getName() const { return proto_nsp_.getName(); }
|
||||||
|
void setName(const NodeStatusProvider::NodeName& name) { proto_nsp_.setName(name); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node health code helpers.
|
* Node health code helpers.
|
||||||
@@ -187,11 +188,14 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the node version information.
|
* Gets/sets the node version information.
|
||||||
*/
|
*/
|
||||||
void setSoftwareVersion(const protocol::SoftwareVersion& version) { proto_nsp_.setSoftwareVersion(version); }
|
void setSoftwareVersion(const protocol::SoftwareVersion& version) { proto_nsp_.setSoftwareVersion(version); }
|
||||||
void setHardwareVersion(const protocol::HardwareVersion& version) { proto_nsp_.setHardwareVersion(version); }
|
void setHardwareVersion(const protocol::HardwareVersion& version) { proto_nsp_.setHardwareVersion(version); }
|
||||||
|
|
||||||
|
const protocol::SoftwareVersion& getSoftwareVersion() const { return proto_nsp_.getSoftwareVersion(); }
|
||||||
|
const protocol::HardwareVersion& getHardwareVersion() const { return proto_nsp_.getHardwareVersion(); }
|
||||||
|
|
||||||
NodeStatusProvider& getNodeStatusProvider() { return proto_nsp_; }
|
NodeStatusProvider& getNodeStatusProvider() { return proto_nsp_; }
|
||||||
|
|
||||||
#if !UAVCAN_TINY
|
#if !UAVCAN_TINY
|
||||||
|
|||||||
@@ -51,6 +51,8 @@ public:
|
|||||||
typedef typename StorageType<typename protocol::NodeStatus::FieldTypes::vendor_specific_status_code>::Type
|
typedef typename StorageType<typename protocol::NodeStatus::FieldTypes::vendor_specific_status_code>::Type
|
||||||
VendorSpecificStatusCode;
|
VendorSpecificStatusCode;
|
||||||
|
|
||||||
|
typedef typename StorageType<typename protocol::GetNodeInfo::Response::FieldTypes::name>::Type NodeName;
|
||||||
|
|
||||||
explicit NodeStatusProvider(INode& node)
|
explicit NodeStatusProvider(INode& node)
|
||||||
: TimerBase(node)
|
: TimerBase(node)
|
||||||
, creation_timestamp_(node.getMonotonicTime())
|
, creation_timestamp_(node.getMonotonicTime())
|
||||||
@@ -119,8 +121,8 @@ public:
|
|||||||
* Can be set only once before the provider is started.
|
* Can be set only once before the provider is started.
|
||||||
* The provider will refuse to start if the node name is not set.
|
* The provider will refuse to start if the node name is not set.
|
||||||
*/
|
*/
|
||||||
const typename protocol::GetNodeInfo::Response::FieldTypes::name& getName() const { return node_info_.name; }
|
const NodeName& getName() const { return node_info_.name; }
|
||||||
void setName(const char* name);
|
void setName(const NodeName& name);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Node version information.
|
* Node version information.
|
||||||
|
|||||||
@@ -124,11 +124,11 @@ void NodeStatusProvider::setVendorSpecificStatusCode(VendorSpecificStatusCode co
|
|||||||
node_info_.status.vendor_specific_status_code = code;
|
node_info_.status.vendor_specific_status_code = code;
|
||||||
}
|
}
|
||||||
|
|
||||||
void NodeStatusProvider::setName(const char* name)
|
void NodeStatusProvider::setName(const NodeName& name)
|
||||||
{
|
{
|
||||||
if ((name != NULL) && (*name != '\0') && (node_info_.name.empty()))
|
if (node_info_.name.empty())
|
||||||
{
|
{
|
||||||
node_info_.name = name; // The string contents will be copied, not just pointer.
|
node_info_.name = name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user