YARP
Yet Another Robot Platform
DiagnosticArray.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 // This is an automatically generated file.
7 
8 // Generated from the following "diagnostic_msgs/DiagnosticArray" msg definition:
9 // # This message is used to send diagnostic information about the state of the robot
10 // Header header #for timestamp
11 // DiagnosticStatus[] status # an array of components being reported on// Instances of this class can be read and written with YARP ports,
12 // using a ROS-compatible format.
13 
14 #ifndef YARP_ROSMSG_diagnostic_msgs_DiagnosticArray_h
15 #define YARP_ROSMSG_diagnostic_msgs_DiagnosticArray_h
16 
17 #include <yarp/os/Wire.h>
18 #include <yarp/os/Type.h>
19 #include <yarp/os/idl/WireTypes.h>
20 #include <string>
21 #include <vector>
24 
25 namespace yarp {
26 namespace rosmsg {
27 namespace diagnostic_msgs {
28 
30 {
31 public:
33  std::vector<yarp::rosmsg::diagnostic_msgs::DiagnosticStatus> status;
34 
36  header(),
37  status()
38  {
39  }
40 
41  void clear()
42  {
43  // *** header ***
44  header.clear();
45 
46  // *** status ***
47  status.clear();
48  }
49 
50  bool readBare(yarp::os::ConnectionReader& connection) override
51  {
52  // *** header ***
53  if (!header.read(connection)) {
54  return false;
55  }
56 
57  // *** status ***
58  int len = connection.expectInt32();
59  status.resize(len);
60  for (int i=0; i<len; i++) {
61  if (!status[i].read(connection)) {
62  return false;
63  }
64  }
65 
66  return !connection.isError();
67  }
68 
69  bool readBottle(yarp::os::ConnectionReader& connection) override
70  {
71  connection.convertTextMode();
72  yarp::os::idl::WireReader reader(connection);
73  if (!reader.readListHeader(2)) {
74  return false;
75  }
76 
77  // *** header ***
78  if (!header.read(connection)) {
79  return false;
80  }
81 
82  // *** status ***
83  if (connection.expectInt32() != BOTTLE_TAG_LIST) {
84  return false;
85  }
86  int len = connection.expectInt32();
87  status.resize(len);
88  for (int i=0; i<len; i++) {
89  if (!status[i].read(connection)) {
90  return false;
91  }
92  }
93 
94  return !connection.isError();
95  }
96 
98  bool read(yarp::os::ConnectionReader& connection) override
99  {
100  return (connection.isBareMode() ? readBare(connection)
101  : readBottle(connection));
102  }
103 
104  bool writeBare(yarp::os::ConnectionWriter& connection) const override
105  {
106  // *** header ***
107  if (!header.write(connection)) {
108  return false;
109  }
110 
111  // *** status ***
112  connection.appendInt32(status.size());
113  for (size_t i=0; i<status.size(); i++) {
114  if (!status[i].write(connection)) {
115  return false;
116  }
117  }
118 
119  return !connection.isError();
120  }
121 
122  bool writeBottle(yarp::os::ConnectionWriter& connection) const override
123  {
124  connection.appendInt32(BOTTLE_TAG_LIST);
125  connection.appendInt32(2);
126 
127  // *** header ***
128  if (!header.write(connection)) {
129  return false;
130  }
131 
132  // *** status ***
133  connection.appendInt32(BOTTLE_TAG_LIST);
134  connection.appendInt32(status.size());
135  for (size_t i=0; i<status.size(); i++) {
136  if (!status[i].write(connection)) {
137  return false;
138  }
139  }
140 
141  connection.convertTextMode();
142  return !connection.isError();
143  }
144 
146  bool write(yarp::os::ConnectionWriter& connection) const override
147  {
148  return (connection.isBareMode() ? writeBare(connection)
149  : writeBottle(connection));
150  }
151 
152  // This class will serialize ROS style or YARP style depending on protocol.
153  // If you need to force a serialization style, use one of these classes:
156 
157  // The name for this message, ROS will need this
158  static constexpr const char* typeName = "diagnostic_msgs/DiagnosticArray";
159 
160  // The checksum for this message, ROS will need this
161  static constexpr const char* typeChecksum = "60810da900de1dd6ddd437c3503511da";
162 
163  // The source text for this message, ROS will need this
164  static constexpr const char* typeText = "\
165 # This message is used to send diagnostic information about the state of the robot\n\
166 Header header #for timestamp\n\
167 DiagnosticStatus[] status # an array of components being reported on\n\
168 ================================================================================\n\
169 MSG: std_msgs/Header\n\
170 # Standard metadata for higher-level stamped data types.\n\
171 # This is generally used to communicate timestamped data \n\
172 # in a particular coordinate frame.\n\
173 # \n\
174 # sequence ID: consecutively increasing ID \n\
175 uint32 seq\n\
176 #Two-integer timestamp that is expressed as:\n\
177 # * stamp.sec: seconds (stamp_secs) since epoch (in Python the variable is called 'secs')\n\
178 # * stamp.nsec: nanoseconds since stamp_secs (in Python the variable is called 'nsecs')\n\
179 # time-handling sugar is provided by the client library\n\
180 time stamp\n\
181 #Frame this data is associated with\n\
182 # 0: no frame\n\
183 # 1: global frame\n\
184 string frame_id\n\
185 \n\
186 ================================================================================\n\
187 MSG: diagnostic_msgs/DiagnosticStatus\n\
188 # This message holds the status of an individual component of the robot.\n\
189 # \n\
190 \n\
191 # Possible levels of operations\n\
192 byte OK=0\n\
193 byte WARN=1\n\
194 byte ERROR=2\n\
195 byte STALE=3\n\
196 \n\
197 byte level # level of operation enumerated above \n\
198 string name # a description of the test/component reporting\n\
199 string message # a description of the status\n\
200 string hardware_id # a hardware unique string\n\
201 KeyValue[] values # an array of values associated with the status\n\
202 \n\
203 \n\
204 ================================================================================\n\
205 MSG: diagnostic_msgs/KeyValue\n\
206 string key # what to label this value when viewing\n\
207 string value # a value to track over time\n\
208 ";
209 
210  yarp::os::Type getType() const override
211  {
213  typ.addProperty("md5sum", yarp::os::Value(typeChecksum));
214  typ.addProperty("message_definition", yarp::os::Value(typeText));
215  return typ;
216  }
217 };
218 
219 } // namespace diagnostic_msgs
220 } // namespace rosmsg
221 } // namespace yarp
222 
223 #endif // YARP_ROSMSG_diagnostic_msgs_DiagnosticArray_h
#define BOTTLE_TAG_LIST
Definition: Bottle.h:28
An interface for reading from a network connection.
virtual bool isBareMode() const =0
Check if the connection is bare mode.
virtual std::int32_t expectInt32()=0
Read a 32-bit integer from the network connection.
virtual bool convertTextMode()=0
Reads in a standard description in text mode, and converts it to a standard description in binary.
virtual bool isError() const =0
An interface for writing to a network connection.
virtual bool isError() const =0
virtual bool isBareMode() const =0
Check if the connection is bare mode.
virtual bool convertTextMode()=0
Converts a standard description in binary into a textual description, if the connection is in text-mo...
virtual void appendInt32(std::int32_t data)=0
Send a representation of a 32-bit integer to the network connection.
static Type byName(const char *name)
Definition: Type.cpp:171
Type & addProperty(const char *key, const Value &val)
Definition: Type.cpp:134
A single value (typically within a Bottle).
Definition: Value.h:45
A "tamed" Portable, that promises to serialize itself in an IDL-friendly way.
Definition: WirePortable.h:23
virtual bool read(yarp::os::idl::WireReader &reader)
virtual bool write(const yarp::os::idl::WireWriter &writer) const
IDL-friendly connection reader.
Definition: WireReader.h:30
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
std::vector< yarp::rosmsg::diagnostic_msgs::DiagnosticStatus > status
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
bool writeBare(yarp::os::ConnectionWriter &connection) const override
bool readBare(yarp::os::ConnectionReader &connection) override
static constexpr const char * typeChecksum
bool writeBottle(yarp::os::ConnectionWriter &connection) const override
yarp::os::idl::BottleStyle< yarp::rosmsg::diagnostic_msgs::DiagnosticArray > bottleStyle
bool readBottle(yarp::os::ConnectionReader &connection) override
yarp::os::idl::BareStyle< yarp::rosmsg::diagnostic_msgs::DiagnosticArray > rosStyle
yarp::os::Type getType() const override
bool write(yarp::os::ConnectionWriter &connection) const override
Write this object to a network connection.
Definition: Header.h:159
bool read(yarp::os::ConnectionReader &connection) override
Read this object from a network connection.
Definition: Header.h:112
The main, catch-all namespace for YARP.
Definition: dirs.h:16