-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhl_action_base.cpp
92 lines (83 loc) · 2.84 KB
/
hl_action_base.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
#include <iomanip>
#include "hl_action_base.h"
namespace mavsdk {
bool operator==(const HLActionBase::HLActionItem& lhs, const HLActionBase::HLActionItem& rhs)
{
return (
((rhs.index == lhs.index)) &&
(rhs.name == lhs.name) && (rhs.description == lhs.description));
}
std::ostream& operator<<(std::ostream& str, HLActionBase::HLActionItem const& hl_action_item)
{
str << std::setprecision(15);
str << "hl_action_item:\n";
str << "{\n";
str << " index: " << hl_action_item.index << '\n';
str << " command: " << hl_action_item.command << '\n';
str << " name: " << hl_action_item.name << '\n';
str << " description: " << hl_action_item.description << '\n';
str << '}';
return str;
}
bool operator==(const HLActionBase::HLActionList& lhs, const HLActionBase::HLActionList& rhs)
{
return (rhs.items == lhs.items);
}
std::ostream& operator<<(std::ostream& str, HLActionBase::HLActionList const& hl_action_list)
{
str << std::setprecision(15);
str << "hl_action_list:\n";
str << "{\n";
str << " hl_action_items: [";
if (hl_action_list.items.size() == 0) {
str << "]\n";
} else {
for (auto it = hl_action_list.items.begin(); it != hl_action_list.items.end(); ++it) {
str << '\n' << *it;
str << (it + 1 != hl_action_list.items.end() ? "," : "]\n");
}
}
str << '}';
return str;
}
std::ostream& operator<<(std::ostream& str, HLActionBase::Ack const& ack)
{
switch (ack) {
case HLActionBase::Ack::Accepted:
return str << "Accepted";
case HLActionBase::Ack::Error:
return str << "Error";
case HLActionBase::Ack::NoSpace:
return str << "NoSpace";
case HLActionBase::Ack::InvalidSequence:
return str << "InvalidSequence";
case HLActionBase::Ack::Cancelled:
return str << "Cancelled";
case HLActionBase::Ack::Unknown:
default:
return str << "Unknown";
}
}
std::ostream& operator<<(std::ostream& str, HLActionBase::Result const& result)
{
switch (result) {
case HLActionBase::Result::Success:
return str << "Success";
case HLActionBase::Result::ConnectionError:
return str << "Connection Error";
case HLActionBase::Result::ProtocolError:
return str << "Protocol Error";
case HLActionBase::Result::Busy:
return str << "Busy";
case HLActionBase::Result::Timeout:
return str << "Timeout";
case HLActionBase::Result::InvalidArgument:
return str << "Invalid Argument";
case HLActionBase::Result::TransferCancelled:
return str << "Transfer Cancelled";
case HLActionBase::Result::Unknown:
default:
return str << "Unknown";
}
}
} // namespace mavsdk