mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-17 02:13:34 +08:00
OTR deinterfaced
This commit is contained in:
@@ -47,7 +47,6 @@ class UAVCAN_EXPORT Node : public INode
|
||||
typedef PoolAllocator<MemPoolSize, MemPoolBlockSize> Allocator;
|
||||
|
||||
Allocator pool_allocator_;
|
||||
OutgoingTransferRegistry outgoing_trans_reg_;
|
||||
Scheduler scheduler_;
|
||||
|
||||
NodeStatusProvider proto_nsp_;
|
||||
@@ -75,8 +74,7 @@ protected:
|
||||
|
||||
public:
|
||||
Node(ICanDriver& can_driver, ISystemClock& system_clock)
|
||||
: outgoing_trans_reg_(pool_allocator_)
|
||||
, scheduler_(can_driver, pool_allocator_, system_clock, outgoing_trans_reg_)
|
||||
: scheduler_(can_driver, pool_allocator_, system_clock)
|
||||
, proto_nsp_(*this)
|
||||
#if !UAVCAN_TINY
|
||||
, proto_dtp_(*this)
|
||||
|
||||
@@ -92,8 +92,8 @@ class UAVCAN_EXPORT Scheduler : Noncopyable
|
||||
void pollCleanup(MonotonicTime mono_ts, uint32_t num_frames_processed_with_last_spin);
|
||||
|
||||
public:
|
||||
Scheduler(ICanDriver& can_driver, IPoolAllocator& allocator, ISystemClock& sysclock, IOutgoingTransferRegistry& otr)
|
||||
: dispatcher_(can_driver, allocator, sysclock, otr)
|
||||
Scheduler(ICanDriver& can_driver, IPoolAllocator& allocator, ISystemClock& sysclock)
|
||||
: dispatcher_(can_driver, allocator, sysclock)
|
||||
, prev_cleanup_ts_(sysclock.getMonotonic())
|
||||
, deadline_resolution_(MonotonicDuration::fromMSec(DefaultDeadlineResolutionMs))
|
||||
, cleanup_period_(MonotonicDuration::fromMSec(DefaultCleanupPeriodMs))
|
||||
|
||||
@@ -31,7 +31,6 @@ class UAVCAN_EXPORT SubNode : public INode
|
||||
typedef PoolAllocator<MemPoolSize, MemPoolBlockSize> Allocator;
|
||||
|
||||
Allocator pool_allocator_;
|
||||
OutgoingTransferRegistry outgoing_trans_reg_;
|
||||
Scheduler scheduler_;
|
||||
|
||||
uint64_t internal_failure_cnt_;
|
||||
@@ -46,8 +45,7 @@ protected:
|
||||
|
||||
public:
|
||||
SubNode(ICanDriver& can_driver, ISystemClock& system_clock) :
|
||||
outgoing_trans_reg_(pool_allocator_),
|
||||
scheduler_(can_driver, pool_allocator_, system_clock, outgoing_trans_reg_),
|
||||
scheduler_(can_driver, pool_allocator_, system_clock),
|
||||
internal_failure_cnt_(0)
|
||||
{ }
|
||||
|
||||
|
||||
@@ -81,7 +81,7 @@ class UAVCAN_EXPORT Dispatcher : Noncopyable
|
||||
{
|
||||
CanIOManager canio_;
|
||||
ISystemClock& sysclock_;
|
||||
IOutgoingTransferRegistry& outgoing_transfer_reg_;
|
||||
OutgoingTransferRegistry outgoing_transfer_reg_;
|
||||
TransferPerfCounter perf_;
|
||||
|
||||
class ListenerRegistry
|
||||
@@ -133,10 +133,10 @@ class UAVCAN_EXPORT Dispatcher : Noncopyable
|
||||
void notifyRxFrameListener(const CanRxFrame& can_frame, CanIOFlags flags);
|
||||
|
||||
public:
|
||||
Dispatcher(ICanDriver& driver, IPoolAllocator& allocator, ISystemClock& sysclock, IOutgoingTransferRegistry& otr)
|
||||
Dispatcher(ICanDriver& driver, IPoolAllocator& allocator, ISystemClock& sysclock)
|
||||
: canio_(driver, allocator, sysclock)
|
||||
, sysclock_(sysclock)
|
||||
, outgoing_transfer_reg_(otr)
|
||||
, outgoing_transfer_reg_(allocator)
|
||||
#if !UAVCAN_TINY
|
||||
, rx_listener_(NULL)
|
||||
#endif
|
||||
@@ -201,7 +201,7 @@ public:
|
||||
* @}
|
||||
*/
|
||||
|
||||
IOutgoingTransferRegistry& getOutgoingTransferRegistry() { return outgoing_transfer_reg_; }
|
||||
OutgoingTransferRegistry& getOutgoingTransferRegistry() { return outgoing_transfer_reg_; }
|
||||
|
||||
#if !UAVCAN_TINY
|
||||
LoopbackFrameListenerRegistry& getLoopbackFrameListenerRegistry() { return loopback_listeners_; }
|
||||
|
||||
@@ -60,23 +60,8 @@ public:
|
||||
* Outgoing transfer registry keeps track of Transfer ID values for all currently existing local transfer senders.
|
||||
* If a local transfer sender was inactive for a sufficiently long time, the outgoing transfer registry will
|
||||
* remove the respective Transfer ID tracking object.
|
||||
*
|
||||
* TODO: Deinterface this.
|
||||
*/
|
||||
class UAVCAN_EXPORT IOutgoingTransferRegistry
|
||||
{
|
||||
public:
|
||||
static const MonotonicDuration MinEntryLifetime;
|
||||
|
||||
virtual ~IOutgoingTransferRegistry() { }
|
||||
|
||||
virtual TransferID* accessOrCreate(const OutgoingTransferRegistryKey& key, MonotonicTime new_deadline) = 0;
|
||||
virtual bool exists(DataTypeID dtid, TransferType tt) const = 0;
|
||||
virtual void cleanup(MonotonicTime deadline) = 0;
|
||||
};
|
||||
|
||||
|
||||
class UAVCAN_EXPORT OutgoingTransferRegistry : public IOutgoingTransferRegistry, Noncopyable
|
||||
class UAVCAN_EXPORT OutgoingTransferRegistry : Noncopyable
|
||||
{
|
||||
struct Value
|
||||
{
|
||||
@@ -127,54 +112,19 @@ class UAVCAN_EXPORT OutgoingTransferRegistry : public IOutgoingTransferRegistry,
|
||||
Map<OutgoingTransferRegistryKey, Value> map_;
|
||||
|
||||
public:
|
||||
static const MonotonicDuration MinEntryLifetime;
|
||||
|
||||
explicit OutgoingTransferRegistry(IPoolAllocator& allocator)
|
||||
: map_(allocator)
|
||||
{ }
|
||||
|
||||
virtual TransferID* accessOrCreate(const OutgoingTransferRegistryKey& key, MonotonicTime new_deadline);
|
||||
TransferID* accessOrCreate(const OutgoingTransferRegistryKey& key, MonotonicTime new_deadline);
|
||||
|
||||
virtual bool exists(DataTypeID dtid, TransferType tt) const;
|
||||
bool exists(DataTypeID dtid, TransferType tt) const;
|
||||
|
||||
virtual void cleanup(MonotonicTime ts);
|
||||
void cleanup(MonotonicTime ts);
|
||||
};
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/*
|
||||
* OutgoingTransferRegistry
|
||||
* TODO: deinterface and move to .cpp
|
||||
*/
|
||||
inline
|
||||
TransferID* OutgoingTransferRegistry::accessOrCreate(const OutgoingTransferRegistryKey& key,
|
||||
MonotonicTime new_deadline)
|
||||
{
|
||||
UAVCAN_ASSERT(!new_deadline.isZero());
|
||||
Value* p = map_.access(key);
|
||||
if (p == NULL)
|
||||
{
|
||||
p = map_.insert(key, Value());
|
||||
if (p == NULL)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
UAVCAN_TRACE("OutgoingTransferRegistry", "Created %s", key.toString().c_str());
|
||||
}
|
||||
p->deadline = new_deadline;
|
||||
return &p->tid;
|
||||
}
|
||||
|
||||
inline
|
||||
bool OutgoingTransferRegistry::exists(DataTypeID dtid, TransferType tt) const
|
||||
{
|
||||
return NULL != map_.find(ExistenceCheckingPredicate(dtid, tt));
|
||||
}
|
||||
|
||||
inline
|
||||
void OutgoingTransferRegistry::cleanup(MonotonicTime ts)
|
||||
{
|
||||
map_.removeAllWhere(DeadlineExpiredPredicate(ts));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
#endif // UAVCAN_TRANSPORT_OUTGOING_TRANSFER_REGISTRY_HPP_INCLUDED
|
||||
|
||||
Reference in New Issue
Block a user