#include <dynamic_node_id_client.hpp>
Public Types | |
typedef protocol::HardwareVersion::FieldTypes::unique_id | UniqueID |
Public Member Functions | |
DynamicNodeIDClient (INode &node) | |
NodeID | getAllocatedNodeID () const |
NodeID | getAllocatorNodeID () const |
bool | isAllocationComplete () const |
int | start (const UniqueID &unique_id, const NodeID preferred_node_id=NodeID::Broadcast, const TransferPriority transfer_priority=TransferPriority::OneHigherThanLowest) |
Private Types | |
typedef MethodBinder< DynamicNodeIDClient *, void(DynamicNodeIDClient::*)(const ReceivedDataStructure< protocol::dynamic_node_id::Allocation > &)> | AllocationCallback |
enum | Mode { ModeWaitingForTimeSlot, ModeDelayBeforeFollowup, NumModes } |
Private Member Functions | |
void | handleAllocation (const ReceivedDataStructure< protocol::dynamic_node_id::Allocation > &msg) |
virtual void | handleTimerEvent (const TimerEvent &) |
void | restartTimer (const Mode mode) |
void | terminate () |
![]() | |
MonotonicTime | getDeadline () const |
MonotonicDuration | getPeriod () const |
Scheduler & | getScheduler () const |
bool | isRunning () const |
void | startOneShotWithDeadline (MonotonicTime deadline) |
void | startOneShotWithDelay (MonotonicDuration delay) |
void | startPeriodic (MonotonicDuration period) |
void | stop () |
TimerBase (INode &node) | |
Static Private Member Functions | |
static MonotonicDuration | getRandomDuration (uint32_t lower_bound_msec, uint32_t upper_bound_msec) |
Private Attributes | |
NodeID | allocated_node_id_ |
NodeID | allocator_node_id_ |
Publisher< protocol::dynamic_node_id::Allocation > | dnida_pub_ |
Subscriber< protocol::dynamic_node_id::Allocation, AllocationCallback > | dnida_sub_ |
NodeID | preferred_node_id_ |
uint8_t | size_of_received_unique_id_ |
uint8_t | unique_id_ [protocol::HardwareVersion::FieldTypes::unique_id::MaxSize] |
This class implements client-side logic of dynamic node ID allocation procedure.
Once started, the object will be publishing dynamic node ID allocation requests at the default frequency defined by the specification, until a Node ID is granted by the allocator.
If the local node is equipped with redundant CAN interfaces, all of them will be used for publishing requests and listening for responses.
Once dynamic allocation is complete (or not needed anymore), the object can be deleted.
Note that this class uses std::rand(), which must be correctly seeded before use.
Definition at line 31 of file dynamic_node_id_client.hpp.
|
private |
Definition at line 36 of file dynamic_node_id_client.hpp.
typedef protocol::HardwareVersion::FieldTypes::unique_id uavcan::DynamicNodeIDClient::UniqueID |
Definition at line 66 of file dynamic_node_id_client.hpp.
|
private |
Enumerator | |
---|---|
ModeWaitingForTimeSlot | |
ModeDelayBeforeFollowup | |
NumModes |
Definition at line 38 of file dynamic_node_id_client.hpp.
|
inline |
Definition at line 68 of file dynamic_node_id_client.hpp.
|
inline |
This method allows to retrieve the node ID that was allocated to the local node. If no node ID was allocated yet, the returned node ID will be invalid (non-unicast).
Definition at line 102 of file dynamic_node_id_client.hpp.
|
inline |
This method allows to retrieve node ID of the allocator that granted our Node ID. If no node ID was allocated yet, the returned node ID will be invalid (non-unicast).
Definition at line 110 of file dynamic_node_id_client.hpp.
|
staticprivate |
Definition at line 18 of file uc_dynamic_node_id_client.cpp.
|
private |
Definition at line 92 of file uc_dynamic_node_id_client.cpp.
|
privatevirtual |
Implement this method in your class to receive callbacks.
Implements uavcan::TimerBase.
Definition at line 43 of file uc_dynamic_node_id_client.cpp.
|
inline |
Use this method to determine when allocation is complete.
Definition at line 94 of file dynamic_node_id_client.hpp.
|
private |
Definition at line 26 of file uc_dynamic_node_id_client.cpp.
int uavcan::DynamicNodeIDClient::start | ( | const UniqueID & | unique_id, |
const NodeID | preferred_node_id = NodeID::Broadcast , |
||
const TransferPriority | transfer_priority = TransferPriority::OneHigherThanLowest |
||
) |
unique_id | Unique ID of the local node. Must be the same as in the hardware version struct. |
preferred_node_id | Node ID that the application would like to take; set to broadcast (zero) if the application doesn't have any preference (this is default). |
transfer_priority | Transfer priority, Normal by default. |
Definition at line 147 of file uc_dynamic_node_id_client.cpp.
|
private |
Definition at line 11 of file uc_dynamic_node_id_client.cpp.
|
private |
Definition at line 52 of file dynamic_node_id_client.hpp.
|
private |
Definition at line 53 of file dynamic_node_id_client.hpp.
|
private |
Definition at line 45 of file dynamic_node_id_client.hpp.
|
private |
Definition at line 46 of file dynamic_node_id_client.hpp.
|
private |
Definition at line 51 of file dynamic_node_id_client.hpp.
|
private |
Definition at line 49 of file dynamic_node_id_client.hpp.
|
private |
Definition at line 48 of file dynamic_node_id_client.hpp.