From: Kevron Rees Date: Fri, 17 Jan 2014 19:38:23 +0000 (-0800) Subject: removed regex parsing X-Git-Tag: accepted/tizen/ivi/20140129.180129~8 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=c1e9bde690b82b3a5321c09bff657c33efabd6c6;p=profile%2Fivi%2Fautomotive-message-broker.git removed regex parsing --- diff --git a/plugins/gpsnmea/CMakeLists.txt b/plugins/gpsnmea/CMakeLists.txt index f4a3b66..8a64834 100644 --- a/plugins/gpsnmea/CMakeLists.txt +++ b/plugins/gpsnmea/CMakeLists.txt @@ -7,7 +7,7 @@ include_directories(${CMAKE_SOURCE_DIR}/lib ${include_dirs} ${gio_INCLUDE_DIRS} add_library(gpsnmea MODULE ${gpsnmea_sources}) set_target_properties(gpsnmea PROPERTIES PREFIX "") -target_link_libraries(gpsnmea amb -L${CMAKE_CURRENT_BINARY_DIR}/lib amb-plugins-common -L${CMAKE_CURRENT_BINARY_DIR}/plugins/common ${link_libraries} boost_regex ${gio_LIBRARIES}) +target_link_libraries(gpsnmea amb -L${CMAKE_CURRENT_BINARY_DIR}/lib amb-plugins-common -L${CMAKE_CURRENT_BINARY_DIR}/plugins/common ${link_libraries} ${gio_LIBRARIES}) install(TARGETS gpsnmea LIBRARY DESTINATION lib/automotive-message-broker) diff --git a/plugins/gpsnmea/gpsnmea.cpp b/plugins/gpsnmea/gpsnmea.cpp index b5fa7eb..29335cc 100644 --- a/plugins/gpsnmea/gpsnmea.cpp +++ b/plugins/gpsnmea/gpsnmea.cpp @@ -23,7 +23,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA #include #include -#include #include #include @@ -44,19 +43,6 @@ inline T2 lexical_cast(const std::string &in) { return out; } -std::string gprmcRegEx = "[\\$]?GPRMC,([0-1][0-9]|2[0-3])([0-5][0-9])([0-5][0-9])," /** time hh mm ss **/ - "([AV])," /** Status A= Active, V= Void **/ - "([0-8][0-9]|90)([0-5][0-9]\\.[0-9]{4})," /** latitude **/ - "([NS])," /** lat North or South **/ - "(180|0[0-9]{2}|1[0-7][0-9])([0-5][0-9]\\.[0-9]{4})," /** longitude **/ - "([EW])," /** lon E or W **/ - "([0-9]{3}\\.[0-9])," /** Speed in knots **/ - "(3[0-5][0-9]|[0-2][0-9]{2}\\.[0-9])," /** Direction **/ - "(3[0-1]|[1-2][0-9]|0[1-9])(0[1-9]|1[0-2])([0-9]{2})," /** Date stamp **/ - "(180|[1][0-7][0-9]|[0][0-9]{2}\\.[0-9])," /** Magnetic variation **/ - "([EW])" /** Magnetic Direction **/ - "\\*([0-9,A-F]{2})"; - class Location { public: @@ -131,7 +117,6 @@ private: VehicleProperty::VehicleSpeedType mSpeed; BasicPropertyType mGpsTime; - boost::regex regularExpression; bool isActive; std::string mUuid; @@ -156,39 +141,31 @@ void Location::parse(string nmea) { parseGpgga(nmea); } + else + { + DebugOut(DebugOut::Warning)<<"unknown/unhandled message: "< tokens; + boost::split(tokens, gprmc, boost::is_any_of(",")); - if (boost::regex_match (gprmc, tokens, regularExpression) ) + if(tokens[2] == "A") { + isActive = true; + } + parseTime(tokens[1].substr(0,2),tokens[1].substr(2,2),tokens[1].substr(4,2),tokens[9].substr(0,2),tokens[9].substr(2,2),tokens[9].substr(4,2)); - if(tokens[4] == "A") - { - isActive = true; - } - - int i=0; - for(auto tok : tokens) - { - DebugOut(0)<(dir); + try { + uint16_t d = boost::lexical_cast(dir); - VehicleProperty::DirectionType temp(d); - if(mDirection != temp) + VehicleProperty::DirectionType temp(d); + if(mDirection != temp) + { + mDirection = temp; + routingEngine->updateProperty(&mDirection, mUuid); + } + } + catch(...) { - mDirection = temp; - routingEngine->updateProperty(&mDirection, mUuid); + DebugOut(DebugOut::Warning)<<"Failed to parse direction: "< conf Location location(routingEngine, mUuid); location.parse("GPRMC,061211,A,2351.9605,S,15112.5239,E,000.0,053.4,170303,009.9,E*6E"); - DebugOut()<<"lat: "<