diff options
author | <philippe colliot> | 2016-05-03 17:13:44 +0200 |
---|---|---|
committer | <philippe colliot> | 2016-05-03 17:13:44 +0200 |
commit | 9633477ee8cbd4ad9c44b892ec4789ff61a3c4ce (patch) | |
tree | 7908455656376a13c77202b1165bd483d395c80e /test | |
parent | b7b3869aa6eeb13c312f2748b01d71aa50f60421 (diff) | |
download | navigation-9633477ee8cbd4ad9c44b892ec4789ff61a3c4ce.tar.gz |
Create a new draft panel for viewer
Diffstat (limited to 'test')
4 files changed, 164 insertions, 18 deletions
diff --git a/test/html-based-panel/node-cpp-lbs-modules/FuelStopAdvisorWrapper.hpp b/test/html-based-panel/node-cpp-lbs-modules/FuelStopAdvisorWrapper.hpp index 4ce09a8..c01d1cf 100644 --- a/test/html-based-panel/node-cpp-lbs-modules/FuelStopAdvisorWrapper.hpp +++ b/test/html-based-panel/node-cpp-lbs-modules/FuelStopAdvisorWrapper.hpp @@ -43,15 +43,6 @@ // header file. // using namespace v8; -static int32_t -int32_variant(DBus::Variant variant) -{ - int32_t ret; - DBus::MessageIter iter=variant.reader(); - iter >> ret; - return ret; -} - class FuelStopAdvisorWrapper : public node::ObjectWrap { friend void DemonstratorProxy::TripDataResetted(const uint8_t &number); friend void DemonstratorProxy::TripDataUpdated(const uint8_t &number); diff --git a/test/html-based-panel/node-cpp-lbs-modules/NavigationCoreWrapper.cpp b/test/html-based-panel/node-cpp-lbs-modules/NavigationCoreWrapper.cpp index 830e0f0..d06a7d6 100644 --- a/test/html-based-panel/node-cpp-lbs-modules/NavigationCoreWrapper.cpp +++ b/test/html-based-panel/node-cpp-lbs-modules/NavigationCoreWrapper.cpp @@ -113,6 +113,7 @@ void NavigationCoreWrapper::Init(v8::Handle<v8::Object> target) { NODE_SET_PROTOTYPE_METHOD(constructor, "getGuidanceStatus", GetGuidanceStatus); NODE_SET_PROTOTYPE_METHOD(constructor, "setSimulationStatusChangedListener", SetSimulationStatusChangedListener); NODE_SET_PROTOTYPE_METHOD(constructor, "getSimulationStatus", GetSimulationStatus); + NODE_SET_PROTOTYPE_METHOD(constructor, "getPosition", GetPosition); // This has to be last, otherwise the properties won't show up on the // object in JavaScript. @@ -182,4 +183,56 @@ v8::Handle<v8::Value> NavigationCoreWrapper::GetSimulationStatus(const v8::Argum } +v8::Handle<v8::Value> NavigationCoreWrapper::GetPosition(const v8::Arguments& args) +{ + v8::HandleScope scope; //to properly clean up v8 handles + std::vector< int32_t > valuesToReturn; + std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > > position; + + if (args.Length() < 1) { + return v8::ThrowException( + v8::Exception::TypeError(v8::String::New("getPosition requires at least 1 argument")) + ); + } + + if (args[0]->IsArray()) { + v8::Handle<v8::Array> array = v8::Handle<v8::Array>::Cast(args[0]); + for(uint32_t i=0;i<array->Length();i++) + { + v8::Handle<v8::Value> value = v8::Handle<v8::Object>::Cast(array->Get(i)); + valuesToReturn.push_back(value->ToInt32()->Int32Value()); + } + } else { + return v8::ThrowException( + v8::Exception::TypeError(v8::String::New("getPosition requires an array as argument")) + ); + } + + // Retrieves the pointer to the wrapped object instance. + NavigationCoreWrapper* obj = ObjectWrap::Unwrap<NavigationCoreWrapper>(args.This()); + position = obj->mp_navigationCoreProxy->mp_navigationCoreMapMatchedPositionProxy->GetPosition(valuesToReturn); + + v8::Local<v8::Array> ret = v8::Array::New(); + + for (std::map< int32_t, ::DBus::Struct< uint8_t, ::DBus::Variant > >::iterator iter = position.begin(); iter != position.end(); iter++) { + v8::Local<v8::Object> data = v8::Object::New(); + ::DBus::Struct< uint8_t, ::DBus::Variant > value; + data->Set(v8::String::New("key"), v8::Int32::New(iter->first)); + value = iter->second; + switch (iter->first) { + case GENIVI_NAVIGATIONCORE_LATITUDE: + case GENIVI_NAVIGATIONCORE_LONGITUDE: + case GENIVI_NAVIGATIONCORE_ALTITUDE: + case GENIVI_NAVIGATIONCORE_SPEED: + case GENIVI_NAVIGATIONCORE_HEADING: + default: + data->Set(v8::String::New("value"), v8::Number::New(value._2)); + break; + } + ret->Set(ret->Length(), data); + } + + return scope.Close(ret); +} + NODE_MODULE(NavigationCoreWrapper, RegisterModule); diff --git a/test/html-based-panel/node-cpp-lbs-modules/NavigationCoreWrapper.hpp b/test/html-based-panel/node-cpp-lbs-modules/NavigationCoreWrapper.hpp index 3dbfe36..99cc9f7 100644 --- a/test/html-based-panel/node-cpp-lbs-modules/NavigationCoreWrapper.hpp +++ b/test/html-based-panel/node-cpp-lbs-modules/NavigationCoreWrapper.hpp @@ -43,15 +43,6 @@ // header file. // using namespace v8; -static DBus::Variant -variant_int32(int32_t i) -{ - DBus::Variant variant; - DBus::MessageIter iter=variant.writer(); - iter << i; - return variant; -} - class NavigationCoreWrapper : public node::ObjectWrap { friend void NavigationCoreProxy::GuidanceStatusChanged(const int32_t& guidanceStatus, const uint32_t& routeHandle); friend void NavigationCoreProxy::SimulationStatusChanged(const int32_t &simulationStatus); @@ -69,6 +60,7 @@ protected: static v8::Handle<v8::Value> New(const v8::Arguments& args); static v8::Handle<v8::Value> GetGuidanceStatus(const v8::Arguments& args); static v8::Handle<v8::Value> GetSimulationStatus(const v8::Arguments& args); + static v8::Handle<v8::Value> GetPosition(const v8::Arguments& args); static v8::Handle<v8::Value> SetGuidanceStatusChangedListener(const v8::Arguments& args); void GuidanceStatusChanged(const int32_t& guidanceStatus, const uint32_t& routeHandle); diff --git a/test/html-based-panel/viewer-panel.html b/test/html-based-panel/viewer-panel.html new file mode 100644 index 0000000..e038e6d --- /dev/null +++ b/test/html-based-panel/viewer-panel.html @@ -0,0 +1,110 @@ +<!DOCTYPE html> +<html lang="en"> +<head> +<meta charset="utf-8" /> +<title>Viewer panel for the FSA (draft)</title> +<link rel="stylesheet" href="style-sheets/stylesheet.css"> +<!-- to be fixed, use relative paths --> +<script type="text/javascript" src="./node_modules/socket.io/node_modules/socket.io-client/socket.io.js"></script> +<script type="text/javascript" src="./node_modules/enum/enum-2.3.0.js"></script> +</head> +<body> +<header> +<h1>Viewer</h1> +</header> + +<section> +START TIME: <h id="start_time"></h><br> +VERSION: <h id="version"></h><br> +</section> + +<section> +<div style="float: left; width: 360px;"> +<table style="width:100%"> + <caption>Inputs</caption> + <col width="200"> + <col width="100"> + <col width="60"> + <tr> + <td>Latitude</td> + <td id=latitude></td> + <td>deg</td> + </tr> + <tr> + <td>Longitude</td> + <td id=longitude></td> + <td>deg</td> + </tr> +</table> +</div> +</section> + +<footer> +Copyright © PCA Peugeot Citroen +</footer> + +<script type="text/javascript"> + +<!-- sockets management --> +var socket_simulation_get = io.connect('http://localhost:8080/simulation_get'); //namespace simulation_get +var socket_simulation_signal = io.connect('http://localhost:8080/simulation_signal'); //namespace simulation_signal +var socket_simulation_warning = io.connect('http://localhost:8080/simulation_warning'); //namespace simulation_warning + +socket_simulation_warning.on('feedback', function(message) { + alert('Message received from the server : ' + message); +}) + +socket_simulation_get.on('navigationcore_answer', function(message) { + if(message.request === 'getPosition') + { + getPositionReturn(message.answer); + } +}) + +socket_simulation_signal.on('positioning_signal', function(message) { +console.log(message); + if(message.signal === 'positionUpdate') + { + positionUpdate(message.data); + } +}) + +<!-- DBus GENIVI constants --> +var genivi_constants = new Enum({'GENIVI_NAVIGATIONCORE_LATITUDE': 160, 'GENIVI_NAVIGATIONCORE_LONGITUDE': 161}); + +<!-- initialization --> +var today=new Date(); +document.getElementById("start_time").innerHTML=today; + +getPosition(); + +<!-- getters --> +function getPosition() { + var data = [160,161]; // + socket_simulation_get.emit('navigationcore_request', {interface: 'NavigationCoreMapMatchedPosition', method: 'getPosition', parameters: data}); +} +function getPositionReturn(answer) { + for ( var i=0; i<answer.length; i++ ) { + switch(answer[i].key) + { + case 160: + document.getElementById("latitude").innerHTML=answer[i].value.toFixed(6); + break; + case 161: + document.getElementById("longitude").innerHTML=answer[i].value.toFixed(6); + break; + } + } +} + +<!-- setters --> + +<!-- signals --> +function positionUpdate(changedValues) { +//for the moment, the changedValues is not used + getPosition(); +} + +</script> +</body> +</html> |