LdmrsApp.cpp
Go to the documentation of this file.
1 //
2 // LdmrsApp.cpp
3 //
4 // Demo application. Receives all datatypes and just prints the data.
5 //
6 
7 #include "LdmrsApp.hpp"
8 #include "../tools/errorhandler.hpp" // for printInfoMessage()
9 #include "../tools/toolbox.hpp" // for toString()
10 #include "../datatypes/Scan.hpp"
11 #include "../datatypes/Object.hpp"
12 #include "../datatypes/Msg.hpp"
13 #include "../datatypes/Measurement.hpp"
14 #include "../datatypes/Fields.hpp"
15 #include "../datatypes/EvalCases.hpp"
16 #include "../datatypes/EvalCaseResults.hpp"
17 
18 namespace application
19 {
20 
21 //
22 // Constructor
23 //
25 {
26  m_beVerbose = true;
27 
28  printInfoMessage("LdmrsApp constructor done.", m_beVerbose);
29 }
30 
31 
32 // Destructor
33 // Clean up all dynamic data structures
35 {
36  printInfoMessage("LdmrsApp says Goodbye!", m_beVerbose);
37 }
38 
39 
40 //
41 // Receiver for new data from the manager.
42 //
44 {
45  //
46  // Do something with it.
47  //
48  // Here, we just print what we've got.
49  //
50  std::string datatypeStr;
51  std::string sourceIdStr;
52 
53  switch (data.getDatatype())
54  {
55  case Datatype_Scan:
56  datatypeStr = "Scan (" + ::toString(((Scan&)data).getNumPoints()) + " points)";
57  {
58  // Print the scan start timestamp (NTP time)
59  Scan* scan = dynamic_cast<Scan*>(&data);
60  const ScannerInfo* info = scan->getScannerInfoByDeviceId(1);
61 
62  if (info != NULL)
63  {
64  const Time& time = info->getStartTimestamp();
65  printInfoMessage("LdmrsApp::setData(): Scan start time: " + time.toString(), m_beVerbose);
66  }
67  }
68  break;
69  case Datatype_Objects:
70  datatypeStr = "Objects (" + ::toString(((ObjectList&)data).size()) + " objects)";
71  break;
72  case Datatype_Fields:
73  datatypeStr = "Fields (" + ::toString(((Fields&)data).getFields().size()) + " fields, " +
74  ::toString(((Fields&)data).getNumberOfValidFields()) + " of which are valid)";
75  break;
76  case Datatype_EvalCases:
77  datatypeStr = "EvalCases (" + ::toString(((EvalCases&)data).getEvalCases().size()) + " cases)";
78  break;
80  datatypeStr = "EvalCaseResults (" + ::toString(((EvalCaseResults&)data).size()) + " case results)";
81  break;
82  case Datatype_Msg:
83  datatypeStr = "Msg (" + ((Msg&)data).toString() + ")";
84  break;
86  datatypeStr = "MeasurementList (" + ::toString(((MeasurementList&)data).m_list.size()) +" entries)";
87  break;
88  default:
89  datatypeStr = "(unknown)";
90  }
91 
92  sourceIdStr = ::toString(data.getSourceId());
93 
94  printInfoMessage("LdmrsApp::setData(): Called with data of type " + datatypeStr + " from ID " + sourceIdStr + ".", m_beVerbose);
95 }
96 
97 } // namespace application
std::string toString(const PositionWGS84::PositionWGS84SourceType &type)
Definition: Time.hpp:44
#define printInfoMessage(a, b)
const Time & getStartTimestamp() const
Definition: ScannerInfo.hpp:73
void setData(BasicData &data)
Definition: LdmrsApp.cpp:43
const ScannerInfo * getScannerInfoByDeviceId(UINT8 id) const
Definition: Scan.cpp:360
LdmrsApp(Manager *manager)
Definition: LdmrsApp.cpp:24
std::string toString() const
Definition: Time.cpp:40


libsick_ldmrs
Author(s): SICK AG , Martin Günther , Jochen Sprickerhof
autogenerated on Mon Oct 26 2020 03:27:30