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