29 #ifndef INCLUDE_OLA_RDM_RDMMESSAGEPRINTERS_H_
30 #define INCLUDE_OLA_RDM_RDMMESSAGEPRINTERS_H_
34 #include <ola/messaging/MessagePrinter.h>
55 ola::messaging::GenericMessagePrinter::DEFAULT_INDENT,
59 std::string TransformLabel(
const std::string &label) {
60 std::string new_label = label;
73 Stream() << field->Value() << std::endl;
84 if (m_messages.empty()) {
87 m_messages.back().status_type = field->Value();
88 m_messages.back().status_type_defined =
true;
92 if (m_messages.empty()) {
95 status_message &message = m_messages.back();
96 if (message.int_offset < MAX_INT_FIELDS) {
97 message.int16_fields[message.int_offset++] = field->Value();
102 if (m_messages.empty()) {
105 status_message &message = m_messages.back();
106 if (message.uint_offset < MAX_UINT_FIELDS) {
107 message.uint16_fields[message.uint_offset++] = field->Value();
112 status_message message;
113 m_messages.push_back(message);
117 void PostStringHook() {
118 std::vector<status_message>::const_iterator iter = m_messages.begin();
119 for (; iter != m_messages.end(); ++iter) {
120 if (!iter->status_type_defined ||
121 iter->uint_offset != MAX_UINT_FIELDS ||
122 iter->int_offset != MAX_INT_FIELDS) {
123 OLA_WARN <<
"Invalid status message";
128 iter->uint16_fields[1],
129 iter->int16_fields[0],
130 iter->int16_fields[1]);
133 if (iter->uint16_fields[0]) {
134 Stream() <<
"Sub-device " << iter->uint16_fields[0] <<
": ";
137 if (message.empty()) {
138 Stream() <<
" message-id: " << iter->uint16_fields[1] <<
", data1: "
139 << iter->int16_fields[0] <<
", data2: "
140 << iter->int16_fields[1] << std::endl;
142 Stream() << message << std::endl;
148 enum { MAX_INT_FIELDS = 2 };
149 enum { MAX_UINT_FIELDS = 2 };
150 struct status_message {
152 uint16_t uint16_fields[MAX_UINT_FIELDS];
153 int16_t int16_fields[MAX_INT_FIELDS];
157 bool status_type_defined;
159 status_message() : uint_offset(0), int_offset(0), status_type(0),
160 status_type_defined(
false) {}
162 std::vector<status_message> m_messages;
173 : m_manufacturer_id(manufacturer_id),
174 m_root_store(root_store) {}
177 m_pids.insert(message->Value());
181 void PostStringHook() {
182 std::set<uint16_t>::const_iterator iter = m_pids.begin();
183 for (; iter != m_pids.end(); ++iter) {
184 Stream() <<
" " << ola::strings::ToHex(*iter);
186 *iter, m_manufacturer_id);
188 std::string name = descriptor->Name();
190 Stream() <<
" (" << name <<
")";
192 Stream() << std::endl;
197 std::set<uint16_t> m_pids;
198 uint16_t m_manufacturer_id;
209 const std::string name = message->GetDescriptor()->Name();
210 if (name ==
"product_category") {
211 Stream() << TransformLabel(name) <<
": "
214 ola::messaging::GenericMessagePrinter::Visit(message);
219 std::string TransformLabel(
const std::string &label) {
220 std::string new_label = label;
233 Stream() <<
EncodeString(message->Value()) << std::endl;
244 m_product_ids.insert(message->Value());
247 void PostStringHook() {
248 std::set<uint16_t>::const_iterator iter = m_product_ids.begin();
249 for (; iter != m_product_ids.end(); ++iter) {
255 std::set<uint16_t> m_product_ids;
265 m_languages.insert(message->Value());
268 void PostStringHook() {
269 std::set<std::string>::const_iterator iter = m_languages.begin();
270 for (; iter != m_languages.end(); ++iter) {
275 std::set<std::string> m_languages;
289 m_year = message->Value();
293 if (m_offset < CLOCK_FIELDS) {
294 m_fields[m_offset] = message->Value();
299 void PostStringHook() {
300 if (m_offset != CLOCK_FIELDS) {
301 Stream() <<
"Malformed packet";
303 Stream() << std::setfill(
'0') << std::setw(2)
304 <<
static_cast<int>(m_fields[1]) <<
"/"
305 << static_cast<int>(m_fields[0]) <<
"/"
307 <<
static_cast<int>(m_fields[2]) <<
":"
308 << static_cast<int>(m_fields[3]) <<
":"
309 <<
static_cast<int>(m_fields[4]) << std::endl;
313 enum { CLOCK_FIELDS = 5};
315 uint8_t m_fields[CLOCK_FIELDS];
316 unsigned int m_offset;
325 if (m_slot_info.empty()) {
328 m_slot_info.back().type = field->Value();
329 m_slot_info.back().type_defined =
true;
333 if (m_slot_info.empty()) {
336 if (!m_slot_info.back().offset_defined) {
337 m_slot_info.back().offset = field->Value();
338 m_slot_info.back().offset_defined =
true;
340 m_slot_info.back().label = field->Value();
341 m_slot_info.back().label_defined =
true;
347 m_slot_info.push_back(slot);
351 void PostStringHook() {
352 std::vector<slot_info>::const_iterator iter = m_slot_info.begin();
353 for (; iter != m_slot_info.end(); ++iter) {
354 if (!iter->offset_defined ||
355 !iter->type_defined ||
356 !iter->label_defined) {
364 Stream() <<
" offset: " << iter->offset <<
", type: " << iter->type
365 <<
", label: " << iter->label << std::endl;
367 Stream() <<
"Slot offset " << iter->offset <<
": " << slot << std::endl;
382 slot_info() : offset(0), offset_defined(
false), type(0),
383 type_defined(
false), label(0), label_defined(
false) {}
385 std::vector<slot_info> m_slot_info;
395 const std::string name = message->GetDescriptor()->Name();
396 if (name ==
"type") {
397 Stream() << TransformLabel(name) <<
": "
399 }
else if (name ==
"unit") {
400 Stream() << TransformLabel(name) <<
": ";
401 if (message->Value() == UNITS_NONE) {
406 Stream() << std::endl;
407 }
else if (name ==
"prefix") {
408 Stream() << TransformLabel(name) <<
": ";
409 if (message->Value() == PREFIX_NONE) {
414 Stream() << std::endl;
415 }
else if (name ==
"supports_recording") {
416 Stream() << TransformLabel(name) <<
": ";
417 std::string supports_recording =
419 if (supports_recording.empty()) {
422 Stream() << supports_recording;
424 Stream() << std::endl;
426 ola::messaging::GenericMessagePrinter::Visit(message);
431 std::string TransformLabel(
const std::string &label) {
432 std::string new_label = label;
439 #endif // INCLUDE_OLA_RDM_RDMMESSAGEPRINTERS_H_
string SensorTypeToString(uint8_t type)
Definition: RDMHelper.cpp:659
Definition: RDMMessagePrinters.h:241
Various misc RDM functions.
Definition: RDMMessagePrinters.h:81
string EncodeString(const string &original)
Encode any unprintable characters in a string as hex, returning a copy.
Definition: StringUtils.cpp:302
Definition: MessagePrinter.h:35
string SensorSupportsRecordingToString(uint8_t supports_recording)
Definition: RDMHelper.cpp:742
Holds information about RDM PIDs.
string StatusTypeToString(uint8_t status_type)
Definition: RDMHelper.cpp:1037
A RDM unique identifier (UID).
#define OLA_WARN
Definition: Logging.h:73
Definition: RDMMessagePrinters.h:282
Definition: RDMMessagePrinters.h:70
Definition: RDMMessagePrinters.h:392
Definition: RDMMessagePrinters.h:262
string SlotInfoToString(uint8_t slot_type, uint16_t slot_label)
Definition: RDMHelper.cpp:759
Definition: MessagePrinter.h:70
string StatusMessageIdToString(uint16_t message_id, int16_t data1, int16_t data2)
Definition: RDMHelper.cpp:895
Definition: RDMMessagePrinters.h:230
Definition: RDMMessagePrinters.h:169
const PidDescriptor * GetDescriptor(const std::string &pid_name) const
Lookup a PLASA-defined parameter by name.
Definition: PidStore.cpp:48
Definition: RDMMessagePrinters.h:206
Definition: Message.h:157
Definition: RDMMessagePrinters.h:51
Various string utility functions.
void CustomCapitalizeLabel(string *s)
Similar to CapitalizeLabel() but this also capitalized known acronyms.
Definition: StringUtils.cpp:437
string ProductDetailToString(uint16_t detail)
Definition: RDMHelper.cpp:450
Definition: Message.h:183
The namespace containing all OLA symbols.
Definition: Credentials.cpp:44
string ProductCategoryToString(uint16_t category)
Definition: RDMHelper.cpp:314
string UnitToString(uint8_t unit)
Definition: RDMHelper.cpp:1068
The root of the RDM parameter descriptor store.
Definition: PidStore.h:68
Header file for OLA Logging.
Definition: Message.h:208
void ToLower(string *s)
Convert a string to lower case.
Definition: StringUtils.cpp:404
Definition: RDMMessagePrinters.h:322
Definition: Message.h:242
string PrefixToString(uint8_t prefix)
Definition: RDMHelper.cpp:257
Definition: PidStore.h:246