libs
libuavcan
libuavcan
include
uavcan
node
sub_node.hpp
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2015 Pavel Kirienko <pavel.kirienko@gmail.com>
3
*/
4
5
#ifndef UAVCAN_SUB_NODE_NODE_HPP_INCLUDED
6
#define UAVCAN_SUB_NODE_NODE_HPP_INCLUDED
7
8
#include <cassert>
9
#include <
uavcan/build_config.hpp
>
10
#include <
uavcan/node/abstract_node.hpp
>
11
12
#if UAVCAN_TINY
13
# error "This functionality is not available in tiny mode"
14
#endif
15
16
namespace
uavcan
17
{
23
template
<std::
size_t
MemPoolSize = 0>
24
class
UAVCAN_EXPORT
SubNode
:
public
INode
25
{
26
typedef
typename
27
Select
<(MemPoolSize > 0),
28
PoolAllocator<MemPoolSize, MemPoolBlockSize>
,
// If pool size is specified, use default allocator
29
IPoolAllocator
&
// Otherwise use reference to user-provided allocator
30
>::Result
Allocator
;
31
32
Allocator
pool_allocator_
;
33
Scheduler
scheduler_
;
34
35
uint64_t
internal_failure_cnt_
;
36
37
protected
:
38
virtual
void
registerInternalFailure
(
const
char
* msg)
39
{
40
internal_failure_cnt_++;
41
UAVCAN_TRACE
(
"Node"
,
"Internal failure: %s"
, msg);
42
(void)msg;
43
}
44
45
public
:
49
SubNode
(
ICanDriver
& can_driver,
50
ISystemClock
& system_clock) :
51
scheduler_(can_driver, pool_allocator_, system_clock),
52
internal_failure_cnt_(0)
53
{ }
54
58
SubNode
(
ICanDriver
& can_driver,
59
ISystemClock
& system_clock,
60
IPoolAllocator
& allocator) :
61
pool_allocator_(allocator),
62
scheduler_(can_driver, pool_allocator_, system_clock),
63
internal_failure_cnt_(0)
64
{ }
65
66
virtual
typename
RemoveReference<Allocator>::Type
&
getAllocator
() {
return
pool_allocator_; }
67
68
virtual
Scheduler
&
getScheduler
() {
return
scheduler_; }
69
virtual
const
Scheduler
&
getScheduler
()
const
{
return
scheduler_; }
70
71
uint64_t
getInternalFailureCount
()
const
{
return
internal_failure_cnt_; }
72
};
73
74
}
75
76
#endif // Include guard
uavcan::SubNode
Definition:
sub_node.hpp:24
uavcan::uint64_t
std::uint64_t uint64_t
Definition:
std.hpp:27
uavcan::SubNode::getScheduler
virtual Scheduler & getScheduler()
Definition:
sub_node.hpp:68
uavcan::ICanDriver
Definition:
libuavcan/libuavcan/include/uavcan/driver/can.hpp:207
uavcan::SubNode::getInternalFailureCount
uint64_t getInternalFailureCount() const
Definition:
sub_node.hpp:71
UAVCAN_TRACE
#define UAVCAN_TRACE(...)
Definition:
libuavcan/libuavcan/include/uavcan/debug.hpp:31
uavcan::PoolAllocator< MemPoolSize, MemPoolBlockSize >
uavcan::SubNode::SubNode
SubNode(ICanDriver &can_driver, ISystemClock &system_clock, IPoolAllocator &allocator)
Definition:
sub_node.hpp:58
uavcan::IPoolAllocator
Definition:
dynamic_memory.hpp:21
uavcan::SubNode::getAllocator
virtual RemoveReference< Allocator >::Type & getAllocator()
Definition:
sub_node.hpp:66
abstract_node.hpp
uavcan::SubNode::internal_failure_cnt_
uint64_t internal_failure_cnt_
Definition:
sub_node.hpp:35
uavcan::Select
struct UAVCAN_EXPORT Select
Definition:
templates.hpp:80
uavcan::Scheduler
Definition:
scheduler.hpp:63
UAVCAN_EXPORT
#define UAVCAN_EXPORT
Definition:
libuavcan/libuavcan/include/uavcan/build_config.hpp:108
uavcan::INode
Definition:
abstract_node.hpp:19
uavcan::RemoveReference::Type
T Type
Definition:
templates.hpp:112
uavcan::SubNode::scheduler_
Scheduler scheduler_
Definition:
sub_node.hpp:33
build_config.hpp
uavcan::SubNode< NodeMemPoolSize >::Allocator
Select<(MemPoolSize > 0), PoolAllocator< MemPoolSize, MemPoolBlockSize >, IPoolAllocator & >::Result Allocator
Definition:
sub_node.hpp:30
uavcan::SubNode::registerInternalFailure
virtual void registerInternalFailure(const char *msg)
Definition:
sub_node.hpp:38
uavcan::SubNode::getScheduler
virtual const Scheduler & getScheduler() const
Definition:
sub_node.hpp:69
uavcan::SubNode::pool_allocator_
Allocator pool_allocator_
Definition:
sub_node.hpp:32
uavcan
Definition:
libuavcan/libuavcan/include/uavcan/build_config.hpp:204
uavcan::ISystemClock
Definition:
system_clock.hpp:19
uavcan::SubNode::SubNode
SubNode(ICanDriver &can_driver, ISystemClock &system_clock)
Definition:
sub_node.hpp:49
uavcan_communicator
Author(s):
autogenerated on Fri Dec 13 2024 03:10:03