SickSafetyscanners.h
Go to the documentation of this file.
00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*-
00002 
00003 // -- BEGIN LICENSE BLOCK ----------------------------------------------
00004 
00024 // -- END LICENSE BLOCK ------------------------------------------------
00025 
00026 //----------------------------------------------------------------------
00033 //----------------------------------------------------------------------
00034 
00035 #ifndef SICK_SAFETYSCANNERS_SICKSAFETYSCANNERS_H
00036 #define SICK_SAFETYSCANNERS_SICKSAFETYSCANNERS_H
00037 
00038 #include <ros/ros.h>
00039 
00040 #include <boost/function.hpp>
00041 #include <boost/scoped_ptr.hpp>
00042 #include <boost/thread.hpp>
00043 
00044 #include <iostream>
00045 #include <string>
00046 #include <vector>
00047 
00048 #include <sick_safetyscanners/communication/AsyncTCPClient.h>
00049 #include <sick_safetyscanners/communication/AsyncUDPClient.h>
00050 #include <sick_safetyscanners/data_processing/ParseData.h>
00051 #include <sick_safetyscanners/data_processing/UDPPacketMerger.h>
00052 #include <sick_safetyscanners/datastructure/CommSettings.h>
00053 #include <sick_safetyscanners/datastructure/ConfigData.h>
00054 #include <sick_safetyscanners/datastructure/PacketBuffer.h>
00055 
00056 #include <sick_safetyscanners/cola2/ChangeCommSettingsCommand.h>
00057 #include <sick_safetyscanners/cola2/Cola2Session.h>
00058 #include <sick_safetyscanners/cola2/DeviceNameVariableCommand.h>
00059 #include <sick_safetyscanners/cola2/FieldGeometryVariableCommand.h>
00060 #include <sick_safetyscanners/cola2/FieldHeaderVariableCommand.h>
00061 #include <sick_safetyscanners/cola2/MeasurementCurrentConfigVariableCommand.h>
00062 #include <sick_safetyscanners/cola2/MeasurementPersistentConfigVariableCommand.h>
00063 #include <sick_safetyscanners/cola2/MonitoringCaseTableHeaderVariableCommand.h>
00064 #include <sick_safetyscanners/cola2/MonitoringCaseVariableCommand.h>
00065 #include <sick_safetyscanners/cola2/TypeCodeVariableCommand.h>
00066 
00067 namespace sick {
00068 
00072 class SickSafetyscanners
00073 {
00074 public:
00079   typedef boost::function<void(const sick::datastructure::Data&)> packetReceivedCallbackFunction;
00080 
00087   SickSafetyscanners(packetReceivedCallbackFunction newPacketReceivedCallbackFunction,
00088                      sick::datastructure::CommSettings* settings);
00089 
00093   virtual ~SickSafetyscanners();
00094 
00099   bool run();
00100 
00105   void changeSensorSettings(const sick::datastructure::CommSettings& settings);
00106 
00112   void requestTypeCode(const sick::datastructure::CommSettings& settings,
00113                        sick::datastructure::TypeCode& type_code);
00114 
00121   void requestFieldData(const sick::datastructure::CommSettings& settings,
00122                         std::vector<sick::datastructure::FieldData>& field_data);
00123 
00130   void requestDeviceName(const sick::datastructure::CommSettings& settings,
00131                          std::string& device_name);
00132 
00139   void requestPersistentConfig(const datastructure::CommSettings& settings,
00140                                sick::datastructure::ConfigData& config_data);
00147   void
00148   requestMonitoringCases(const sick::datastructure::CommSettings& settings,
00149                          std::vector<sick::datastructure::MonitoringCaseData>& monitoring_cases);
00150 
00151 
00152 private:
00153   packetReceivedCallbackFunction m_newPacketReceivedCallbackFunction;
00154 
00155   std::shared_ptr<boost::asio::io_service> m_io_service_ptr;
00156   std::shared_ptr<boost::asio::io_service::work> m_io_work_ptr;
00157   std::shared_ptr<sick::communication::AsyncUDPClient> m_async_udp_client_ptr;
00158   std::shared_ptr<sick::communication::AsyncTCPClient> m_async_tcp_client_ptr;
00159   boost::scoped_ptr<boost::thread> m_udp_client_thread_ptr;
00160 
00161   std::shared_ptr<sick::cola2::Cola2Session> m_session_ptr;
00162 
00163   std::shared_ptr<sick::data_processing::UDPPacketMerger> m_packet_merger_ptr;
00164 
00165   std::string m_device_name;
00166   int m_active_case_number;
00167 
00168   void processUDPPacket(const datastructure::PacketBuffer& buffer);
00169   bool UDPClientThread();
00170   void processTCPPacket(const sick::datastructure::PacketBuffer& buffer);
00171   void startTCPConnection(const sick::datastructure::CommSettings& settings);
00172   void changeCommSettingsInColaSession(const datastructure::CommSettings& settings);
00173   void stopTCPConnection();
00174   void requestTypeCodeInColaSession(sick::datastructure::TypeCode& type_code);
00175   void requestFieldDataInColaSession(std::vector<sick::datastructure::FieldData>& fields);
00176   void requestDeviceNameInColaSession(std::string& device_name);
00177   void requestPersistentConfigInColaSession(sick::datastructure::ConfigData& config_data);
00178   void requestMonitoringCaseDataInColaSession(
00179     std::vector<sick::datastructure::MonitoringCaseData>& monitoring_cases);
00180 };
00181 
00182 } // namespace sick
00183 
00184 
00185 #endif // SICK_SAFETYSCANNERS_SICKSAFETYSCANNERS_H


sick_safetyscanners
Author(s): Lennart Puck
autogenerated on Tue May 7 2019 03:27:36