• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mavlink / MAVSDK / 4899817366

pending completion
4899817366

Pull #1772

github

GitHub
Merge c0bb90862 into e4e9c71dd
Pull Request #1772: Refactor MAVLinkParameters into client and server classes

2192 of 2192 new or added lines in 34 files covered. (100.0%)

7708 of 24812 relevant lines covered (31.07%)

19.96 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

20.2
/src/mavsdk/plugins/param/param.cpp
1
// WARNING: THIS FILE IS AUTOGENERATED! As such, it should not be edited.
2
// Edits need to be made to the proto files
3
// (see https://github.com/mavlink/MAVSDK-Proto/blob/master/protos/param/param.proto)
4

5
#include <iomanip>
6

7
#include "param_impl.h"
8
#include "plugins/param/param.h"
9

10
namespace mavsdk {
11

12
using IntParam = Param::IntParam;
13
using FloatParam = Param::FloatParam;
14
using CustomParam = Param::CustomParam;
15
using AllParams = Param::AllParams;
16

17
Param::Param(System& system) : PluginBase(), _impl{std::make_unique<ParamImpl>(system)} {}
×
18

19
Param::Param(std::shared_ptr<System> system) :
8✔
20
    PluginBase(),
21
    _impl{std::make_unique<ParamImpl>(system)}
8✔
22
{}
8✔
23

24
Param::~Param() {}
8✔
25

26
std::pair<Param::Result, int32_t> Param::get_param_int(std::string name) const
5✔
27
{
28
    return _impl->get_param_int(name);
5✔
29
}
30

31
Param::Result Param::set_param_int(std::string name, int32_t value) const
2✔
32
{
33
    return _impl->set_param_int(name, value);
2✔
34
}
35

36
std::pair<Param::Result, float> Param::get_param_float(std::string name) const
5✔
37
{
38
    return _impl->get_param_float(name);
5✔
39
}
40

41
Param::Result Param::set_param_float(std::string name, float value) const
2✔
42
{
43
    return _impl->set_param_float(name, value);
2✔
44
}
45

46
std::pair<Param::Result, std::string> Param::get_param_custom(std::string name) const
4✔
47
{
48
    return _impl->get_param_custom(name);
4✔
49
}
50

51
Param::Result Param::set_param_custom(std::string name, std::string value) const
2✔
52
{
53
    return _impl->set_param_custom(name, value);
2✔
54
}
55

56
Param::AllParams Param::get_all_params() const
4✔
57
{
58
    return _impl->get_all_params();
4✔
59
}
60

61
Param::Result Param::select_component(int32_t component_id, ProtocolVersion protocol_version) const
6✔
62
{
63
    return _impl->select_component(component_id, protocol_version);
6✔
64
}
65

66
bool operator==(const Param::IntParam& lhs, const Param::IntParam& rhs)
×
67
{
68
    return (rhs.name == lhs.name) && (rhs.value == lhs.value);
×
69
}
70

71
std::ostream& operator<<(std::ostream& str, Param::IntParam const& int_param)
×
72
{
73
    str << std::setprecision(15);
×
74
    str << "int_param:" << '\n' << "{\n";
×
75
    str << "    name: " << int_param.name << '\n';
×
76
    str << "    value: " << int_param.value << '\n';
×
77
    str << '}';
×
78
    return str;
×
79
}
80

81
bool operator==(const Param::FloatParam& lhs, const Param::FloatParam& rhs)
×
82
{
83
    return (rhs.name == lhs.name) &&
×
84
           ((std::isnan(rhs.value) && std::isnan(lhs.value)) || rhs.value == lhs.value);
×
85
}
86

87
std::ostream& operator<<(std::ostream& str, Param::FloatParam const& float_param)
×
88
{
89
    str << std::setprecision(15);
×
90
    str << "float_param:" << '\n' << "{\n";
×
91
    str << "    name: " << float_param.name << '\n';
×
92
    str << "    value: " << float_param.value << '\n';
×
93
    str << '}';
×
94
    return str;
×
95
}
96

97
bool operator==(const Param::CustomParam& lhs, const Param::CustomParam& rhs)
×
98
{
99
    return (rhs.name == lhs.name) && (rhs.value == lhs.value);
×
100
}
101

102
std::ostream& operator<<(std::ostream& str, Param::CustomParam const& custom_param)
×
103
{
104
    str << std::setprecision(15);
×
105
    str << "custom_param:" << '\n' << "{\n";
×
106
    str << "    name: " << custom_param.name << '\n';
×
107
    str << "    value: " << custom_param.value << '\n';
×
108
    str << '}';
×
109
    return str;
×
110
}
111

112
bool operator==(const Param::AllParams& lhs, const Param::AllParams& rhs)
×
113
{
114
    return (rhs.int_params == lhs.int_params) && (rhs.float_params == lhs.float_params) &&
×
115
           (rhs.custom_params == lhs.custom_params);
×
116
}
117

118
std::ostream& operator<<(std::ostream& str, Param::AllParams const& all_params)
×
119
{
120
    str << std::setprecision(15);
×
121
    str << "all_params:" << '\n' << "{\n";
×
122
    str << "    int_params: [";
×
123
    for (auto it = all_params.int_params.begin(); it != all_params.int_params.end(); ++it) {
×
124
        str << *it;
×
125
        str << (it + 1 != all_params.int_params.end() ? ", " : "]\n");
×
126
    }
127
    str << "    float_params: [";
×
128
    for (auto it = all_params.float_params.begin(); it != all_params.float_params.end(); ++it) {
×
129
        str << *it;
×
130
        str << (it + 1 != all_params.float_params.end() ? ", " : "]\n");
×
131
    }
132
    str << "    custom_params: [";
×
133
    for (auto it = all_params.custom_params.begin(); it != all_params.custom_params.end(); ++it) {
×
134
        str << *it;
×
135
        str << (it + 1 != all_params.custom_params.end() ? ", " : "]\n");
×
136
    }
137
    str << '}';
×
138
    return str;
×
139
}
140

141
std::ostream& operator<<(std::ostream& str, Param::Result const& result)
×
142
{
143
    switch (result) {
×
144
        case Param::Result::Unknown:
×
145
            return str << "Unknown";
×
146
        case Param::Result::Success:
×
147
            return str << "Success";
×
148
        case Param::Result::Timeout:
×
149
            return str << "Timeout";
×
150
        case Param::Result::ConnectionError:
×
151
            return str << "Connection Error";
×
152
        case Param::Result::WrongType:
×
153
            return str << "Wrong Type";
×
154
        case Param::Result::ParamNameTooLong:
×
155
            return str << "Param Name Too Long";
×
156
        case Param::Result::NoSystem:
×
157
            return str << "No System";
×
158
        case Param::Result::ParamValueTooLong:
×
159
            return str << "Param Value Too Long";
×
160
        case Param::Result::Failed:
×
161
            return str << "Failed";
×
162
        default:
×
163
            return str << "Unknown";
×
164
    }
165
}
166

167
std::ostream& operator<<(std::ostream& str, Param::ProtocolVersion const& protocol_version)
×
168
{
169
    switch (protocol_version) {
×
170
        case Param::ProtocolVersion::V1:
×
171
            return str << "V1";
×
172
        case Param::ProtocolVersion::Ext:
×
173
            return str << "Ext";
×
174
        default:
×
175
            return str << "Unknown";
×
176
    }
177
}
178

179
} // namespace mavsdk
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc