Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
uavcan::DynamicNodeIDClient Class Reference

#include <dynamic_node_id_client.hpp>

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

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 ()
 
- Private Member Functions inherited from uavcan::TimerBase
MonotonicTime getDeadline () const
 
MonotonicDuration getPeriod () const
 
SchedulergetScheduler () 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, AllocationCallbackdnida_sub_
 
NodeID preferred_node_id_
 
uint8_t size_of_received_unique_id_
 
uint8_t unique_id_ [protocol::HardwareVersion::FieldTypes::unique_id::MaxSize]
 

Detailed Description

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.

Member Typedef Documentation

◆ AllocationCallback

typedef MethodBinder<DynamicNodeIDClient*, void (DynamicNodeIDClient::*) (const ReceivedDataStructure<protocol::dynamic_node_id::Allocation>&)> uavcan::DynamicNodeIDClient::AllocationCallback
private

Definition at line 36 of file dynamic_node_id_client.hpp.

◆ UniqueID

typedef protocol::HardwareVersion::FieldTypes::unique_id uavcan::DynamicNodeIDClient::UniqueID

Definition at line 66 of file dynamic_node_id_client.hpp.

Member Enumeration Documentation

◆ Mode

Enumerator
ModeWaitingForTimeSlot 
ModeDelayBeforeFollowup 
NumModes 

Definition at line 38 of file dynamic_node_id_client.hpp.

Constructor & Destructor Documentation

◆ DynamicNodeIDClient()

uavcan::DynamicNodeIDClient::DynamicNodeIDClient ( INode node)
inline

Definition at line 68 of file dynamic_node_id_client.hpp.

Member Function Documentation

◆ getAllocatedNodeID()

NodeID uavcan::DynamicNodeIDClient::getAllocatedNodeID ( ) const
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).

Returns
If allocation is complete, a valid unicast node ID will be returned. If allocation is not complete yet, a non-unicast node ID will be returned.

Definition at line 102 of file dynamic_node_id_client.hpp.

◆ getAllocatorNodeID()

NodeID uavcan::DynamicNodeIDClient::getAllocatorNodeID ( ) const
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).

Returns
If allocation is complete, a valid unicast node ID will be returned. If allocation is not complete yet, an non-unicast node ID will be returned.

Definition at line 110 of file dynamic_node_id_client.hpp.

◆ getRandomDuration()

MonotonicDuration uavcan::DynamicNodeIDClient::getRandomDuration ( uint32_t  lower_bound_msec,
uint32_t  upper_bound_msec 
)
staticprivate

Definition at line 18 of file uc_dynamic_node_id_client.cpp.

◆ handleAllocation()

void uavcan::DynamicNodeIDClient::handleAllocation ( const ReceivedDataStructure< protocol::dynamic_node_id::Allocation > &  msg)
private

Definition at line 92 of file uc_dynamic_node_id_client.cpp.

◆ handleTimerEvent()

void uavcan::DynamicNodeIDClient::handleTimerEvent ( const TimerEvent event)
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.

◆ isAllocationComplete()

bool uavcan::DynamicNodeIDClient::isAllocationComplete ( ) const
inline

Use this method to determine when allocation is complete.

Definition at line 94 of file dynamic_node_id_client.hpp.

◆ restartTimer()

void uavcan::DynamicNodeIDClient::restartTimer ( const Mode  mode)
private

Definition at line 26 of file uc_dynamic_node_id_client.cpp.

◆ start()

int uavcan::DynamicNodeIDClient::start ( const UniqueID unique_id,
const NodeID  preferred_node_id = NodeID::Broadcast,
const TransferPriority  transfer_priority = TransferPriority::OneHigherThanLowest 
)
Parameters
unique_idUnique ID of the local node. Must be the same as in the hardware version struct.
preferred_node_idNode ID that the application would like to take; set to broadcast (zero) if the application doesn't have any preference (this is default).
transfer_priorityTransfer priority, Normal by default.
Returns
Zero on success Negative error code on failure -ErrLogic if 1. the node is not in passive mode or 2. the client is already started

Definition at line 147 of file uc_dynamic_node_id_client.cpp.

◆ terminate()

void uavcan::DynamicNodeIDClient::terminate ( )
private

Definition at line 11 of file uc_dynamic_node_id_client.cpp.

Member Data Documentation

◆ allocated_node_id_

NodeID uavcan::DynamicNodeIDClient::allocated_node_id_
private

Definition at line 52 of file dynamic_node_id_client.hpp.

◆ allocator_node_id_

NodeID uavcan::DynamicNodeIDClient::allocator_node_id_
private

Definition at line 53 of file dynamic_node_id_client.hpp.

◆ dnida_pub_

Publisher<protocol::dynamic_node_id::Allocation> uavcan::DynamicNodeIDClient::dnida_pub_
private

Definition at line 45 of file dynamic_node_id_client.hpp.

◆ dnida_sub_

Subscriber<protocol::dynamic_node_id::Allocation, AllocationCallback> uavcan::DynamicNodeIDClient::dnida_sub_
private

Definition at line 46 of file dynamic_node_id_client.hpp.

◆ preferred_node_id_

NodeID uavcan::DynamicNodeIDClient::preferred_node_id_
private

Definition at line 51 of file dynamic_node_id_client.hpp.

◆ size_of_received_unique_id_

uint8_t uavcan::DynamicNodeIDClient::size_of_received_unique_id_
private

Definition at line 49 of file dynamic_node_id_client.hpp.

◆ unique_id_

uint8_t uavcan::DynamicNodeIDClient::unique_id_[protocol::HardwareVersion::FieldTypes::unique_id::MaxSize]
private

Definition at line 48 of file dynamic_node_id_client.hpp.


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


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