TOBI SignalServer
0.1
|
00001 /* 00002 This file is part of the TOBI SignalServer. 00003 00004 Commercial Usage 00005 Licensees holding valid Graz University of Technology Commercial 00006 licenses may use this file in accordance with the Graz University 00007 of Technology Commercial License Agreement provided with the 00008 Software or, alternatively, in accordance with the terms contained in 00009 a written agreement between you and Graz University of Technology. 00010 00011 -------------------------------------------------- 00012 00013 GNU General Public License Usage 00014 Alternatively, this file may be used under the terms of the GNU 00015 General Public License version 3.0 as published by the Free Software 00016 Foundation and appearing in the file gpl.txt included in the 00017 packaging of this file. Please review the following information to 00018 ensure the GNU General Public License version 3.0 requirements will be 00019 met: http://www.gnu.org/copyleft/gpl.html. 00020 00021 In case of GNU General Public License Usage ,the TOBI SignalServer 00022 is distributed in the hope that it will be useful, 00023 but WITHOUT ANY WARRANTY; without even the implied warranty of 00024 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00025 GNU General Public License for more details. 00026 00027 You should have received a copy of the GNU General Public License 00028 along with the TOBI SignalServer. If not, see <http://www.gnu.org/licenses/>. 00029 00030 Copyright 2010 Graz University of Technology 00031 Contact: SignalServer@tobi-project.org 00032 */ 00033 00038 #ifndef EEG_SIMULATOR_MSGMPARSER 00039 #define EEG_SIMULATOR_MSGMPARSER 00040 00041 #include <map> 00042 #include <string> 00043 #include <boost/cstdint.hpp> 00044 00045 namespace tobiss 00046 { 00047 00048 //----------------------------------------------------------------------------- 00049 00054 class EEGSimMsgParser 00055 { 00056 public: 00057 00058 static const unsigned int MESSAGE_VERSION; 00059 00063 EEGSimMsgParser(std::string& str_buffer); 00067 virtual ~EEGSimMsgParser(); 00068 00069 //------------------------------------------ 00070 00071 public: 00076 struct EEGConfig 00077 { 00078 public: 00079 double scaling_; 00080 double offset_; 00081 }; 00082 00087 struct SineConfig 00088 { 00089 public: 00090 double freq_; 00091 double amplitude_; 00092 double phase_; 00093 }; 00094 00095 enum MessageType 00096 { 00097 Invalid, 00098 GetConfig, 00099 Config 00100 }; 00101 00102 void parseMessage(); 00103 MessageType getMessageType() 00104 { 00105 return type_; 00106 } 00107 00108 void getConfigs(std::map<boost::uint16_t, EEGConfig>& eeg, 00109 std::multimap<boost::uint16_t, SineConfig>& sine); 00110 std::string buildConfigMsgString(std::map<boost::uint16_t, EEGConfig>& eeg, 00111 std::multimap<boost::uint16_t, SineConfig>& sine); 00112 00113 std::string getOKMsg(); 00114 std::string getErrorMsg(); 00115 00116 private: 00117 MessageType parseMessageType(); 00118 void checkMessage(); 00119 void parseConfigMessage(); 00120 00121 //------------------------------------------ 00122 00123 private: 00124 MessageType type_; 00125 std::string& str_buffer_; 00126 std::map<std::string, MessageType> msg_types_map_; 00127 std::map<boost::uint16_t, EEGConfig> eeg_config_; 00128 std::multimap<boost::uint16_t, SineConfig> sine_configs_; 00129 }; 00130 00131 } // tobiss 00132 00133 00134 00135 00136 #endif // EEG_SIMULATOR_MSGMPARSER