LdmrsApp.cpp
Go to the documentation of this file.
00001 //
00002 // LdmrsApp.cpp
00003 //
00004 // Demo application. Receives all datatypes and just prints the data.
00005 //
00006 
00007 #include "LdmrsApp.hpp"
00008 #include "../tools/errorhandler.hpp"    // for printInfoMessage()
00009 #include "../tools/toolbox.hpp"                 // for toString()
00010 #include "../datatypes/Scan.hpp"
00011 #include "../datatypes/Object.hpp"
00012 #include "../datatypes/Msg.hpp"
00013 #include "../datatypes/Measurement.hpp"
00014 #include "../datatypes/Fields.hpp"
00015 #include "../datatypes/EvalCases.hpp"
00016 #include "../datatypes/EvalCaseResults.hpp"
00017 
00018 namespace application
00019 {
00020 
00021 //
00022 // Constructor
00023 //
00024 LdmrsApp::LdmrsApp(Manager* manager)
00025 {
00026         m_beVerbose = true;
00027 
00028         printInfoMessage("LdmrsApp constructor done.", m_beVerbose);
00029 }
00030 
00031 
00032 // Destructor
00033 // Clean up all dynamic data structures
00034 LdmrsApp::~LdmrsApp()
00035 {
00036         printInfoMessage("LdmrsApp says Goodbye!", m_beVerbose);
00037 }
00038 
00039 
00040 //
00041 // Receiver for new data from the manager.
00042 //
00043 void LdmrsApp::setData(BasicData& data)
00044 {
00045         //
00046         // Do something with it.
00047         //
00048         // Here, we just print what we've got.
00049         //
00050         std::string datatypeStr;
00051         std::string sourceIdStr;
00052 
00053         switch (data.getDatatype())
00054         {
00055                 case Datatype_Scan:
00056                         datatypeStr = "Scan (" + ::toString(((Scan&)data).getNumPoints()) + " points)";
00057                         {
00058                                 // Print the scan start timestamp (NTP time) 
00059                                 Scan* scan = dynamic_cast<Scan*>(&data);
00060                                 const ScannerInfo* info = scan->getScannerInfoByDeviceId(1);
00061  
00062                                 if (info != NULL)
00063                                 {
00064                                         const Time& time = info->getStartTimestamp();
00065                                         printInfoMessage("LdmrsApp::setData(): Scan start time: " + time.toString(), m_beVerbose);
00066                                 }
00067                         }
00068                         break;
00069                 case Datatype_Objects:
00070                         datatypeStr = "Objects (" + ::toString(((ObjectList&)data).size()) + " objects)";
00071                         break;
00072                 case Datatype_Fields:
00073                         datatypeStr = "Fields (" + ::toString(((Fields&)data).getFields().size()) + " fields, " +
00074                                                         ::toString(((Fields&)data).getNumberOfValidFields()) + " of which are valid)";
00075                         break;
00076                 case Datatype_EvalCases:
00077                         datatypeStr = "EvalCases (" + ::toString(((EvalCases&)data).getEvalCases().size()) + " cases)";
00078                         break;
00079                 case Datatype_EvalCaseResults:
00080                         datatypeStr = "EvalCaseResults (" + ::toString(((EvalCaseResults&)data).size()) + " case results)";
00081                         break;
00082                 case Datatype_Msg:
00083                         datatypeStr = "Msg (" + ((Msg&)data).toString() + ")";
00084                         break;
00085                 case Datatype_MeasurementList:
00086                         datatypeStr = "MeasurementList (" + ::toString(((MeasurementList&)data).m_list.size()) +" entries)";
00087                         break;
00088                 default:
00089                         datatypeStr = "(unknown)";
00090         }
00091         
00092         sourceIdStr = ::toString(data.getSourceId());
00093         
00094         printInfoMessage("LdmrsApp::setData(): Called with data of type " + datatypeStr + " from ID " + sourceIdStr + ".", m_beVerbose);
00095 }
00096 
00097 }       // namespace application


libsick_ldmrs
Author(s): SICK AG , Martin Günther , Jochen Sprickerhof
autogenerated on Wed Jun 14 2017 04:04:50