YARP
Yet Another Robot Platform
DiagnosticStatus.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
9 // This is an automatically generated file.
10 
11 // Generated from the following "diagnostic_msgs/DiagnosticStatus" msg definition:
12 // # This message holds the status of an individual component of the robot.
13 // #
14 //
15 // # Possible levels of operations
16 // byte OK=0
17 // byte WARN=1
18 // byte ERROR=2
19 // byte STALE=3
20 //
21 // byte level # level of operation enumerated above
22 // string name # a description of the test/component reporting
23 // string message # a description of the status
24 // string hardware_id # a hardware unique string
25 // KeyValue[] values # an array of values associated with the status
26 //
27 // Instances of this class can be read and written with YARP ports,
28 // using a ROS-compatible format.
29 
30 #ifndef YARP_ROSMSG_diagnostic_msgs_DiagnosticStatus_h
31 #define YARP_ROSMSG_diagnostic_msgs_DiagnosticStatus_h
32 
33 #include <yarp/os/Wire.h>
34 #include <yarp/os/Type.h>
35 #include <yarp/os/idl/WireTypes.h>
36 #include <string>
37 #include <vector>
39 
40 namespace yarp {
41 namespace rosmsg {
42 namespace diagnostic_msgs {
43 
45 {
46 public:
47  static const std::uint8_t OK = 0;
48  static const std::uint8_t WARN = 1;
49  static const std::uint8_t ERROR = 2;
50  static const std::uint8_t STALE = 3;
51  std::uint8_t level;
52  std::string name;
53  std::string message;
54  std::string hardware_id;
55  std::vector<yarp::rosmsg::diagnostic_msgs::KeyValue> values;
56 
58  level(0),
59  name(""),
60  message(""),
61  hardware_id(""),
62  values()
63  {
64  }
65 
66  void clear()
67  {
68  // *** OK ***
69 
70  // *** WARN ***
71 
72  // *** ERROR ***
73 
74  // *** STALE ***
75 
76  // *** level ***
77  level = 0;
78 
79  // *** name ***
80  name = "";
81 
82  // *** message ***
83  message = "";
84 
85  // *** hardware_id ***
86  hardware_id = "";
87 
88  // *** values ***
89  values.clear();
90  }
91 
92  bool readBare(yarp::os::ConnectionReader& connection) override
93  {
94  // *** level ***
95  level = connection.expectInt8();
96 
97  // *** name ***
98  int len = connection.expectInt32();
99  name.resize(len);
100  if (!connection.expectBlock((char*)name.c_str(), len)) {
101  return false;
102  }
103 
104  // *** message ***
105  len = connection.expectInt32();
106  message.resize(len);
107  if (!connection.expectBlock((char*)message.c_str(), len)) {
108  return false;
109  }
110 
111  // *** hardware_id ***
112  len = connection.expectInt32();
113  hardware_id.resize(len);
114  if (!connection.expectBlock((char*)hardware_id.c_str(), len)) {
115  return false;
116  }
117 
118  // *** values ***
119  len = connection.expectInt32();
120  values.resize(len);
121  for (int i=0; i<len; i++) {
122  if (!values[i].read(connection)) {
123  return false;
124  }
125  }
126 
127  return !connection.isError();
128  }
129 
130  bool readBottle(yarp::os::ConnectionReader& connection) override
131  {
132  connection.convertTextMode();
133  yarp::os::idl::WireReader reader(connection);
134  if (!reader.readListHeader(9)) {
135  return false;
136  }
137 
138  // *** level ***
139  level = reader.expectInt8();
140 
141  // *** name ***
142  if (!reader.readString(name)) {
143  return false;
144  }
145 
146  // *** message ***
147  if (!reader.readString(message)) {
148  return false;
149  }
150 
151  // *** hardware_id ***
152  if (!reader.readString(hardware_id)) {
153  return false;
154  }
155 
156  // *** values ***
157  if (connection.expectInt32() != BOTTLE_TAG_LIST) {
158  return false;
159  }
160  int len = connection.expectInt32();
161  values.resize(len);
162  for (int i=0; i<len; i++) {
163  if (!values[i].read(connection)) {
164  return false;
165  }
166  }
167 
168  return !connection.isError();
169  }
170 
172  bool read(yarp::os::ConnectionReader& connection) override
173  {
174  return (connection.isBareMode() ? readBare(connection)
175  : readBottle(connection));
176  }
177 
178  bool writeBare(yarp::os::ConnectionWriter& connection) const override
179  {
180  // *** level ***
181  connection.appendInt8(level);
182 
183  // *** name ***
184  connection.appendInt32(name.length());
185  connection.appendExternalBlock((char*)name.c_str(), name.length());
186 
187  // *** message ***
188  connection.appendInt32(message.length());
189  connection.appendExternalBlock((char*)message.c_str(), message.length());
190 
191  // *** hardware_id ***
192  connection.appendInt32(hardware_id.length());
193  connection.appendExternalBlock((char*)hardware_id.c_str(), hardware_id.length());
194 
195  // *** values ***
196  connection.appendInt32(values.size());
197  for (size_t i=0; i<values.size(); i++) {
198  if (!values[i].write(connection)) {
199  return false;
200  }
201  }
202 
203  return !connection.isError();
204  }
205 
206  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
207  {
208  connection.appendInt32(BOTTLE_TAG_LIST);
209  connection.appendInt32(9);
210 
211  // *** level ***
212  connection.appendInt32(BOTTLE_TAG_INT8);
213  connection.appendInt8(level);
214 
215  // *** name ***
216  connection.appendInt32(BOTTLE_TAG_STRING);
217  connection.appendInt32(name.length());
218  connection.appendExternalBlock((char*)name.c_str(), name.length());
219 
220  // *** message ***
221  connection.appendInt32(BOTTLE_TAG_STRING);
222  connection.appendInt32(message.length());
223  connection.appendExternalBlock((char*)message.c_str(), message.length());
224 
225  // *** hardware_id ***
226  connection.appendInt32(BOTTLE_TAG_STRING);
227  connection.appendInt32(hardware_id.length());
228  connection.appendExternalBlock((char*)hardware_id.c_str(), hardware_id.length());
229 
230  // *** values ***
231  connection.appendInt32(BOTTLE_TAG_LIST);
232  connection.appendInt32(values.size());
233  for (size_t i=0; i<values.size(); i++) {
234  if (!values[i].write(connection)) {
235  return false;
236  }
237  }
238 
239  connection.convertTextMode();
240  return !connection.isError();
241  }
242 
244  bool write(yarp::os::ConnectionWriter& connection) const override
245  {
246  return (connection.isBareMode() ? writeBare(connection)
247  : writeBottle(connection));
248  }
249 
250  // This class will serialize ROS style or YARP style depending on protocol.
251  // If you need to force a serialization style, use one of these classes:
254 
255  // The name for this message, ROS will need this
256  static constexpr const char* typeName = "diagnostic_msgs/DiagnosticStatus";
257 
258  // The checksum for this message, ROS will need this
259  static constexpr const char* typeChecksum = "d0ce08bc6e5ba34c7754f563a9cabaf1";
260 
261  // The source text for this message, ROS will need this
262  static constexpr const char* typeText = "\
263 # This message holds the status of an individual component of the robot.\n\
264 # \n\
265 \n\
266 # Possible levels of operations\n\
267 byte OK=0\n\
268 byte WARN=1\n\
269 byte ERROR=2\n\
270 byte STALE=3\n\
271 \n\
272 byte level # level of operation enumerated above \n\
273 string name # a description of the test/component reporting\n\
274 string message # a description of the status\n\
275 string hardware_id # a hardware unique string\n\
276 KeyValue[] values # an array of values associated with the status\n\
277 \n\
278 \n\
279 ================================================================================\n\
280 MSG: diagnostic_msgs/KeyValue\n\
281 string key # what to label this value when viewing\n\
282 string value # a value to track over time\n\
283 ";
284 
285  yarp::os::Type getType() const override
286  {
288  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
289  typ.addProperty("message_definition", yarp::os::Value(typeText));
290  return typ;
291  }
292 };
293 
294 } // namespace diagnostic_msgs
295 } // namespace rosmsg
296 } // namespace yarp
297 
298 #endif // YARP_ROSMSG_diagnostic_msgs_DiagnosticStatus_h
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus
Definition: DiagnosticStatus.h:45
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::ERROR
static const std::uint8_t ERROR
Definition: DiagnosticStatus.h:49
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::WARN
static const std::uint8_t WARN
Definition: DiagnosticStatus.h:48
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::level
std::uint8_t level
Definition: DiagnosticStatus.h:51
yarp::os::idl::WireReader::readString
bool readString(std::string &str, bool *is_vocab=nullptr)
Definition: WireReader.cpp:339
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::write
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: DiagnosticStatus.h:244
WireTypes.h
BOTTLE_TAG_LIST
#define BOTTLE_TAG_LIST
Definition: Bottle.h:30
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::writeBare
bool writeBare(yarp::os::ConnectionWriter &connection) const override
Definition: DiagnosticStatus.h:178
yarp::os::idl::BottleStyle
Definition: BottleStyle.h:22
yarp::os::Type
Definition: Type.h:24
yarp::os::idl::WirePortable::read
virtual bool read(yarp::os::idl::WireReader &reader)
Definition: WirePortable.cpp:14
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::readBottle
bool readBottle(yarp::os::ConnectionReader &connection) override
Definition: DiagnosticStatus.h:130
yarp::os::ConnectionWriter::appendInt8
virtual void appendInt8(std::int8_t data)=0
Send a representation of a 8-bit integer to the network connection.
yarp::os::ConnectionReader::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
BOTTLE_TAG_STRING
#define BOTTLE_TAG_STRING
Definition: Bottle.h:28
Wire.h
BOTTLE_TAG_INT8
#define BOTTLE_TAG_INT8
Definition: Bottle.h:21
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::rosStyle
yarp::os::idl::BareStyle< yarp::rosmsg::diagnostic_msgs::DiagnosticStatus > rosStyle
Definition: DiagnosticStatus.h:252
yarp::os::ConnectionReader::expectInt8
virtual std::int8_t expectInt8()=0
Read a 8-bit integer from the network connection.
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::STALE
static const std::uint8_t STALE
Definition: DiagnosticStatus.h:50
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::clear
void clear()
Definition: DiagnosticStatus.h:66
yarp::os::ConnectionWriter::isError
virtual bool isError() const =0
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::DiagnosticStatus
DiagnosticStatus()
Definition: DiagnosticStatus.h:57
yarp::os::Type::byName
static Type byName(const char *name)
Definition: Type.cpp:174
KeyValue.h
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::readBare
bool readBare(yarp::os::ConnectionReader &connection) override
Definition: DiagnosticStatus.h:92
yarp::os::ConnectionReader::expectInt32
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
yarp::os::Type::addProperty
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:137
Type.h
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::typeText
static constexpr const char * typeText
Definition: DiagnosticStatus.h:262
yarp::os::ConnectionWriter
An interface for writing to a network connection.
Definition: ConnectionWriter.h:40
yarp::os::ConnectionReader::isError
virtual bool isError() const =0
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::values
std::vector< yarp::rosmsg::diagnostic_msgs::KeyValue > values
Definition: DiagnosticStatus.h:55
yarp::os::ConnectionReader::convertTextMode
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary.
yarp::os::idl::WirePortable
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:26
yarp::os::ConnectionWriter::isBareMode
virtual bool isBareMode() const =0
Check if the connection is bare mode.
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::typeName
static constexpr const char * typeName
Definition: DiagnosticStatus.h:256
yarp::os::ConnectionWriter::convertTextMode
virtual bool convertTextMode()=0
Converts a standard description in binary into a textual description, if the connection is in text-mo...
yarp::os::ConnectionWriter::appendInt32
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::read
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: DiagnosticStatus.h:172
yarp::os::idl::WireReader
IDL-friendly connection reader.
Definition: WireReader.h:33
yarp::os::ConnectionReader
An interface for reading from a network connection.
Definition: ConnectionReader.h:40
yarp::os::idl::BareStyle
Definition: BareStyle.h:22
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::OK
static const std::uint8_t OK
Definition: DiagnosticStatus.h:47
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::typeChecksum
static constexpr const char * typeChecksum
Definition: DiagnosticStatus.h:259
diagnostic_msgs
Definition: AddDiagnostics.h:22
yarp
The main, catch-all namespace for YARP.
Definition: environment.h:18
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::message
std::string message
Definition: DiagnosticStatus.h:53
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::bottleStyle
yarp::os::idl::BottleStyle< yarp::rosmsg::diagnostic_msgs::DiagnosticStatus > bottleStyle
Definition: DiagnosticStatus.h:253
yarp::os::idl::WireReader::expectInt8
std::int8_t expectInt8()
Definition: WireReader.h:87
yarp::os::ConnectionWriter::appendExternalBlock
virtual void appendExternalBlock(const char *data, size_t len)=0
Send a block of data to the network connection, without making a copy.
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::writeBottle
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
Definition: DiagnosticStatus.h:206
yarp::os::ConnectionReader::expectBlock
virtual bool expectBlock(char *data, size_t len)=0
Read a block of data from the network connection.
yarp::os::Value
A single value (typically within a Bottle).
Definition: Value.h:47
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::getType
yarp::os::Type getType() const override
Definition: DiagnosticStatus.h:285
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::hardware_id
std::string hardware_id
Definition: DiagnosticStatus.h:54
yarp::rosmsg::diagnostic_msgs::DiagnosticStatus::name
std::string name
Definition: DiagnosticStatus.h:52
yarp::os::idl::WireReader::readListHeader
bool readListHeader()
Definition: WireReader.cpp:470
yarp::os::idl::WirePortable::write
virtual bool write(const yarp::os::idl::WireWriter &writer) const
Definition: WirePortable.cpp:20