AgIsoStack++
A control-function-focused implementation of the major ISOBUS and J1939 protocols
Loading...
Searching...
No Matches
can_NAME.cpp
Go to the documentation of this file.
1//================================================================================================
8//================================================================================================
11
12namespace isobus
13{
14 NAME::NAME(std::uint64_t rawNAMEData) :
15 rawName(rawNAMEData)
16 {
17 }
18
19 bool NAME::operator==(const NAME &obj) const
20 {
21 return this->rawName == obj.rawName;
22 }
23
25 {
26 return (0 != (rawName >> 63));
27 }
28
30 {
31 rawName &= ~(static_cast<std::uint64_t>(1) << 63);
32 rawName |= (static_cast<std::uint64_t>(value) << 63);
33 }
34
35 std::uint8_t NAME::get_industry_group() const
36 {
37 return ((rawName >> 60) & 0x07);
38 }
39
40 void NAME::set_industry_group(std::uint8_t value)
41 {
42 if (value > 0x07)
43 {
44 LOG_ERROR("[NAME]: Industry group out of range, must be between 0 and 7");
45 }
46 rawName &= ~static_cast<std::uint64_t>(0x7000000000000000);
47 rawName |= (static_cast<std::uint64_t>(value & 0x07) << 60);
48 }
49
51 {
52 return ((rawName >> 56) & 0x0F);
53 }
54
55 void NAME::set_device_class_instance(std::uint8_t value)
56 {
57 if (value > 0x0F)
58 {
59 LOG_ERROR("[NAME]: Device class instance out of range, must be between 0 and 15");
60 }
61 rawName &= ~static_cast<std::uint64_t>(0xF00000000000000);
62 rawName |= (static_cast<std::uint64_t>(value & 0x0F) << 56);
63 }
64
65 std::uint8_t NAME::get_device_class() const
66 {
67 return ((rawName >> 49) & 0x7F);
68 }
69
70 void NAME::set_device_class(std::uint8_t value)
71 {
72 if (value > 0x7F)
73 {
74 LOG_ERROR("[NAME]: Device class out of range, must be between 0 and 127");
75 }
76 rawName &= ~static_cast<std::uint64_t>(0xFE000000000000);
77 rawName |= (static_cast<std::uint64_t>(value & 0x7F) << 49);
78 }
79
80 std::uint8_t NAME::get_function_code() const
81 {
82 return ((rawName >> 40) & 0xFF);
83 }
84
85 void NAME::set_function_code(std::uint8_t value)
86 {
87 rawName &= ~static_cast<std::uint64_t>(0xFF0000000000);
88 rawName |= (static_cast<std::uint64_t>(value & 0xFF) << 40);
89 }
90
91 std::uint8_t NAME::get_function_instance() const
92 {
93 return ((rawName >> 35) & 0x1F);
94 }
95
96 void NAME::set_function_instance(std::uint8_t value)
97 {
98 if (value > 0x1F)
99 {
100 LOG_ERROR("[NAME]: Function instance out of range, must be between 0 and 31");
101 }
102 rawName &= ~static_cast<std::uint64_t>(0xF800000000);
103 rawName |= (static_cast<std::uint64_t>(value & 0x1F) << 35);
104 }
105
106 std::uint8_t NAME::get_ecu_instance() const
107 {
108 return ((rawName >> 32) & 0x07);
109 }
110
111 void NAME::set_ecu_instance(std::uint8_t value)
112 {
113 if (value > 0x07)
114 {
115 LOG_ERROR("[NAME]: ECU instance out of range, must be between 0 and 7");
116 }
117 rawName &= ~static_cast<std::uint64_t>(0x700000000);
118 rawName |= (static_cast<std::uint64_t>(value & 0x07) << 32);
119 }
120
121 std::uint16_t NAME::get_manufacturer_code() const
122 {
123 return ((rawName >> 21) & 0x07FF);
124 }
125
126 void NAME::set_manufacturer_code(std::uint16_t value)
127 {
128 if (value > 0x07FF)
129 {
130 LOG_ERROR("[NAME]: Manufacturer code out of range, must be between 0 and 2047");
131 }
132 rawName &= ~static_cast<std::uint64_t>(0xFFE00000);
133 rawName |= (static_cast<std::uint64_t>(value & 0x07FF) << 21);
134 }
135
136 std::uint32_t NAME::get_identity_number() const
137 {
138 return (rawName & 0x001FFFFF);
139 }
140
141 void NAME::set_identity_number(uint32_t value)
142 {
143 if (value > 0x001FFFFF)
144 {
145 LOG_ERROR("[NAME]: Identity number out of range, must be between 0 and 2097151");
146 }
147 rawName &= ~static_cast<std::uint64_t>(0x1FFFFF);
148 rawName |= static_cast<std::uint64_t>(value & 0x1FFFFF);
149 }
150
151 std::uint64_t NAME::get_full_name() const
152 {
153 return rawName;
154 }
155
156 void NAME::set_full_name(std::uint64_t value)
157 {
158 rawName = value;
159 }
160
161} // namespace isobus
A class that represents a control function's NAME.
A class that acts as a logging sink. The intent is that someone could make their own derived class of...
A class that represents an ISO11783 control function NAME from an address claim.
Definition can_NAME.hpp:24
std::uint8_t get_ecu_instance() const
Gets the ecu instance encoded in the NAME.
Definition can_NAME.cpp:106
bool get_arbitrary_address_capable() const
Returns if the ECU is capable of address arbitration.
Definition can_NAME.cpp:24
NAME(std::uint64_t rawNAMEData=0)
Constructor for a NAME.
Definition can_NAME.cpp:14
std::uint8_t get_function_instance() const
Gets the function instance encoded in the NAME.
Definition can_NAME.cpp:91
void set_device_class_instance(std::uint8_t value)
Sets the device class instance (vehicle system) to be encoded in the NAME.
Definition can_NAME.cpp:55
void set_manufacturer_code(std::uint16_t value)
Sets the manufacturer code encoded in the NAME.
Definition can_NAME.cpp:126
void set_ecu_instance(std::uint8_t value)
Sets the ecu instance encoded in the NAME.
Definition can_NAME.cpp:111
void set_function_instance(std::uint8_t value)
Sets the function instance encoded in the NAME.
Definition can_NAME.cpp:96
std::uint16_t get_manufacturer_code() const
Gets the manufacturer code encoded in the NAME.
Definition can_NAME.cpp:121
void set_function_code(std::uint8_t value)
Sets the function code encoded in the NAME.
Definition can_NAME.cpp:85
std::uint64_t rawName
A raw, 64 bit NAME encoded with all NAMEParameters.
Definition can_NAME.hpp:518
void set_industry_group(std::uint8_t value)
Sets the industry group encoded in the NAME.
Definition can_NAME.cpp:40
std::uint8_t get_function_code() const
Gets the function code encoded in the NAME.
Definition can_NAME.cpp:80
std::uint8_t get_device_class_instance() const
Returns the device class (vehicle system) encoded in the NAME.
Definition can_NAME.cpp:50
std::uint64_t get_full_name() const
Gets the raw 64 bit NAME.
Definition can_NAME.cpp:151
std::uint8_t get_industry_group() const
Returns the industry group encoded in the NAME.
Definition can_NAME.cpp:35
bool operator==(const NAME &obj) const
A useful way to compare session objects to each other for equality.
Definition can_NAME.cpp:19
void set_identity_number(std::uint32_t value)
Sets the identity number encoded in the NAME.
Definition can_NAME.cpp:141
void set_arbitrary_address_capable(bool value)
Sets the data in the NAME that corresponds to the arbitration capability of the ECU.
Definition can_NAME.cpp:29
std::uint8_t get_device_class() const
Returns the device class (vehicle system) encoded in the NAME.
Definition can_NAME.cpp:65
void set_full_name(std::uint64_t value)
Sets the raw, encoded 64 bit NAME.
Definition can_NAME.cpp:156
void set_device_class(std::uint8_t value)
Sets the device class (vehicle system) to be encoded in the NAME.
Definition can_NAME.cpp:70
std::uint32_t get_identity_number() const
Gets the identity number encoded in the NAME.
Definition can_NAME.cpp:136
This namespace encompasses all of the ISO11783 stack's functionality to reduce global namespace pollu...