-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathcan_control_function.cpp
69 lines (57 loc) · 1.56 KB
/
can_control_function.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
//================================================================================================
/// @file can_control_function.cpp
///
/// @brief Defines a base class to represent a generic ISOBUS control function.
/// @author Adrian Del Grosso
/// @author Daan Steenbergen
///
/// @copyright 2022 The Open-Agriculture Developers
//================================================================================================
#include "can_control_function.hpp"
#include "can_constants.hpp"
#include <string>
namespace isobus
{
Mutex ControlFunction::controlFunctionProcessingMutex;
isobus::ControlFunction::ControlFunction(NAME NAMEValue, std::uint8_t addressValue, std::uint8_t CANPort, Type type) :
controlFunctionType(type),
controlFunctionNAME(NAMEValue),
address(addressValue),
canPortIndex(CANPort)
{
}
std::uint8_t ControlFunction::get_address() const
{
return address;
}
bool ControlFunction::get_address_valid() const
{
return ((BROADCAST_CAN_ADDRESS != address) && (NULL_CAN_ADDRESS != address));
}
std::uint8_t ControlFunction::get_can_port() const
{
return canPortIndex;
}
NAME ControlFunction::get_NAME() const
{
return controlFunctionNAME;
}
ControlFunction::Type ControlFunction::get_type() const
{
return controlFunctionType;
}
std::string ControlFunction::get_type_string() const
{
switch (controlFunctionType)
{
case Type::Internal:
return "Internal";
case Type::External:
return "External";
case Type::Partnered:
return "Partnered";
default:
return "Unknown";
}
}
} // namespace isobus