00001 // this is for emacs file handling -*- mode: c++; indent-tabs-mode: nil -*- 00002 00003 // -- BEGIN LICENSE BLOCK ---------------------------------------------- 00004 // This file is part of FZIs ic_workspace. 00005 // 00006 // This program is free software licensed under the LGPL 00007 // (GNU LESSER GENERAL PUBLIC LICENSE Version 3). 00008 // You can find a copy of this license in LICENSE folder in the top 00009 // directory of the source code. 00010 // 00011 // © Copyright 2016 FZI Forschungszentrum Informatik, Karlsruhe, Germany 00012 // 00013 // -- END LICENSE BLOCK ------------------------------------------------ 00014 00015 //---------------------------------------------------------------------- 00022 //---------------------------------------------------------------------- 00023 #ifndef ICL_HARDWARE_CAN_T_CAN_FILTER_MESSAGES_H_INCLUDED 00024 #define ICL_HARDWARE_CAN_T_CAN_FILTER_MESSAGES_H_INCLUDED 00025 00026 #include "icl_hardware_can/tCanMessage.h" 00027 #include "icl_hardware_can/ImportExport.h" 00028 00029 #include <icl_core/tString.h> 00030 00031 #include <fstream> 00032 #include <boost/filesystem.hpp> 00033 #include <map> 00034 00035 namespace icl_hardware { 00036 namespace can { 00037 00044 class ICL_HARDWARE_CAN_IMPORT_EXPORT tCanFilterMessages 00045 { 00046 public: 00048 tCanFilterMessages(); 00049 00051 ~tCanFilterMessages(); 00052 00053 void Open(const std::string identifer); 00054 00055 bool getStatus() const; 00056 00058 bool checkMessage(const tCanMessage& msg) const; 00059 00060 protected: 00061 00062 bool byteIsChangingConstantly(unsigned int i, unsigned int id) const; 00063 00064 void mapContentOfFile(); 00065 void StringToCanMsg(icl_hardware::can::tCanMessage &msg, std::string str); 00066 00067 int PrepareFiles(); 00068 00069 void setDataFileName(const boost::filesystem::path &file_name); 00070 const boost::filesystem::path & getDataFileName() const; 00071 00072 private: 00073 struct DataWrapper 00074 { 00075 unsigned char data[8]; 00076 }; 00077 00078 std::map<unsigned int, DataWrapper> m_table_id_to_data; 00079 std::multimap<unsigned int, unsigned int> m_table_id_to_changing_bytes; 00080 00082 std::ifstream m_data_file; 00083 00084 boost::filesystem::path *m_data_file_name; 00085 00086 DataWrapper m_message_data; 00087 00088 bool is_initialized; 00089 }; 00090 00091 } 00092 } 00093 00094 #endif