From 3be3648d49a1d29d00b6fe3e9a44fa1959204629 Mon Sep 17 00:00:00 2001 From: asanoaozora Date: Thu, 9 Jun 2016 15:57:37 +0200 Subject: HTML panel and c++ addons (for simulation) aligned with nodejs 4.2.6 --- .../FuelStopAdvisorWrapper.cpp | 23 +++--- .../FuelStopAdvisorWrapper.hpp | 2 +- .../node-cpp-lbs-modules/NavigationCoreWrapper.cpp | 10 ++- .../PositioningEnhancedPositionWrapper.cpp | 7 +- .../dbus-proxies/DemonstratorProxy.cpp | 2 +- .../node-cpp-lbs-modules/package.json | 3 +- test/html-based-panel/simulation-panel.html | 82 ++++++---------------- 7 files changed, 46 insertions(+), 83 deletions(-) (limited to 'test') diff --git a/test/html-based-panel/node-cpp-lbs-modules/FuelStopAdvisorWrapper.cpp b/test/html-based-panel/node-cpp-lbs-modules/FuelStopAdvisorWrapper.cpp index 3a8fa80..111442f 100644 --- a/test/html-based-panel/node-cpp-lbs-modules/FuelStopAdvisorWrapper.cpp +++ b/test/html-based-panel/node-cpp-lbs-modules/FuelStopAdvisorWrapper.cpp @@ -150,7 +150,7 @@ void FuelStopAdvisorWrapper::Init(v8::Local target) { NODE_SET_PROTOTYPE_METHOD(tpl, "setTripDataUpdatedListener", SetTripDataUpdatedListener); NODE_SET_PROTOTYPE_METHOD(tpl, "setFuelStopAdvisorWarningListener", SetFuelStopAdvisorWarningListener); NODE_SET_PROTOTYPE_METHOD(tpl, "setTripDataResettedListener", SetTripDataResettedListener); - NODE_SET_PROTOTYPE_METHOD(tpl, "getSpeed", GetSpeed); + NODE_SET_PROTOTYPE_METHOD(tpl, "getEngineSpeed", GetEngineSpeed); NODE_SET_PROTOTYPE_METHOD(tpl, "getLevel", GetLevel); NODE_SET_PROTOTYPE_METHOD(tpl, "getInstantConsumption", GetInstantConsumption); NODE_SET_PROTOTYPE_METHOD(tpl, "getOdometer", GetOdometer); @@ -222,7 +222,6 @@ void FuelStopAdvisorWrapper::GetVersion(const v8::FunctionCallbackInfo &args) { v8::Isolate* isolate = args.GetIsolate(); - // Retrieves the pointer to the wrapped object instance. FuelStopAdvisorWrapper* obj = ObjectWrap::Unwrap(args.This()); @@ -234,21 +233,19 @@ void FuelStopAdvisorWrapper::GetInstantData(const v8::FunctionCallbackInfo::iterator iter = instant_data.begin(); iter != instant_data.end(); iter++) { v8::Local data = v8::Object::New(isolate); ::DBus::Variant value = iter->second; - printf("GetInstantData%d\n",iter->first); - printf("GetInstantData%s\n",value.signature().c_str()); data->Set(v8::String::NewFromUtf8(isolate,"key"), v8::Uint32::New(isolate,iter->first)); switch (iter->first) { case GENIVI_FUELSTOPADVISOR_FUEL_LEVEL: - data->Set(v8::String::NewFromUtf8(isolate,"value"), v8::Int32::New(isolate,15)); + data->Set(v8::String::NewFromUtf8(isolate,"value"), v8::Uint32::New(isolate,value.reader().get_uint16())); break; case GENIVI_FUELSTOPADVISOR_INSTANT_FUEL_CONSUMPTION_PER_DISTANCE: - data->Set(v8::String::NewFromUtf8(isolate,"value"), v8::Int32::New(isolate,55)); + data->Set(v8::String::NewFromUtf8(isolate,"value"), v8::Uint32::New(isolate,value.reader().get_uint16())); break; case GENIVI_FUELSTOPADVISOR_TANK_DISTANCE: - data->Set(v8::String::NewFromUtf8(isolate,"value"), v8::Int32::New(isolate,300)); + data->Set(v8::String::NewFromUtf8(isolate,"value"), v8::Uint32::New(isolate,value.reader().get_uint16())); break; case GENIVI_FUELSTOPADVISOR_ENHANCED_TANK_DISTANCE: - data->Set(v8::String::NewFromUtf8(isolate,"value"), v8::Int32::New(isolate,400)); + data->Set(v8::String::NewFromUtf8(isolate,"value"), v8::Uint32::New(isolate,value.reader().get_uint16())); break; default: break; @@ -259,13 +256,19 @@ void FuelStopAdvisorWrapper::GetInstantData(const v8::FunctionCallbackInfo &args) { +void FuelStopAdvisorWrapper::GetEngineSpeed(const v8::FunctionCallbackInfo &args) { v8::Isolate* isolate = args.GetIsolate(); // Retrieves the pointer to the wrapped object instance. FuelStopAdvisorWrapper* obj = ObjectWrap::Unwrap(args.This()); + DBus::Variant variant = obj->mp_demonstratorProxy->mp_managerProxy->GetSpeed(); + DBus::MessageIter it = variant.reader(); + uint16_t engineSpeed; + it >> engineSpeed; + v8::Local ret = v8::Object::New(isolate); + ret->Set( 0, v8::Uint32::New(isolate, engineSpeed) ); args.GetReturnValue().Set(ret); } @@ -300,6 +303,7 @@ void FuelStopAdvisorWrapper::GetInstantConsumption(const v8::FunctionCallbackInf v8::Local ret = v8::Object::New(isolate); ret->Set( 0, v8::Uint32::New(isolate,consumption) ); + printf("GetInstantConsumption\n"); args.GetReturnValue().Set(ret); } @@ -311,6 +315,7 @@ void FuelStopAdvisorWrapper::GetOdometer(const v8::FunctionCallbackInfo(args.This()); v8::Local ret = v8::Object::New(isolate); + printf("GetOdometer\n"); args.GetReturnValue().Set(ret); } 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 23da191..926f883 100644 --- a/test/html-based-panel/node-cpp-lbs-modules/FuelStopAdvisorWrapper.hpp +++ b/test/html-based-panel/node-cpp-lbs-modules/FuelStopAdvisorWrapper.hpp @@ -72,7 +72,7 @@ protected: static void SetFuelStopAdvisorWarningListener(const v8::FunctionCallbackInfo &args); void FuelStopAdvisorWarning(const bool& destinationCantBeReached); - static void GetSpeed(const v8::FunctionCallbackInfo &args); + static void GetEngineSpeed(const v8::FunctionCallbackInfo &args); static void GetLevel(const v8::FunctionCallbackInfo &args); static void GetInstantConsumption(const v8::FunctionCallbackInfo &args); static void GetOdometer(const v8::FunctionCallbackInfo &args); 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 90fc7d0..881ae49 100644 --- a/test/html-based-panel/node-cpp-lbs-modules/NavigationCoreWrapper.cpp +++ b/test/html-based-panel/node-cpp-lbs-modules/NavigationCoreWrapper.cpp @@ -37,15 +37,14 @@ v8::Persistent NavigationCoreWrapper::signalSimulationStatusChange void NavigationCoreWrapper::GuidanceStatusChanged(const int32_t& guidanceStatus, const uint32_t& routeHandle) { v8::Isolate* isolate = v8::Isolate::GetCurrent(); - + v8::HandleScope handleScope(isolate); const unsigned argc = 2; v8::Local argv[argc]; argv[0]=v8::Local::New(isolate,v8::Int32::New(isolate,guidanceStatus)); argv[1]=v8::Local::New(isolate,v8::Uint32::New(isolate,routeHandle)); - v8::Local fct; - fct.New(isolate,signalGuidanceStatusChanged); + v8::Local fct = v8::Local::New(isolate,signalGuidanceStatusChanged); fct->Call(isolate->GetCurrentContext()->Global(), argc, argv); } @@ -71,14 +70,13 @@ void NavigationCoreWrapper::SetGuidanceStatusChangedListener(const v8::FunctionC void NavigationCoreWrapper::SimulationStatusChanged(const int32_t& simulationStatus) { v8::Isolate* isolate = v8::Isolate::GetCurrent(); - + v8::HandleScope handleScope(isolate); const unsigned argc = 1; v8::Local argv[argc]; argv[0]=v8::Local::New(isolate,v8::Int32::New(isolate,simulationStatus)); - v8::Local fct; - fct.New(isolate,signalSimulationStatusChanged); + v8::Local fct = v8::Local::New(isolate,signalSimulationStatusChanged); fct->Call(isolate->GetCurrentContext()->Global(), argc, argv); } diff --git a/test/html-based-panel/node-cpp-lbs-modules/PositioningEnhancedPositionWrapper.cpp b/test/html-based-panel/node-cpp-lbs-modules/PositioningEnhancedPositionWrapper.cpp index 8c58df8..64fde14 100644 --- a/test/html-based-panel/node-cpp-lbs-modules/PositioningEnhancedPositionWrapper.cpp +++ b/test/html-based-panel/node-cpp-lbs-modules/PositioningEnhancedPositionWrapper.cpp @@ -36,6 +36,8 @@ v8::Persistent PositioningEnhancedPositionWrapper::constructor; v8::Persistent PositioningEnhancedPositionWrapper::signalPositionUpdate; void PositioningEnhancedPositionWrapper::PositionUpdate(const uint64_t& changedValues) { v8::Isolate* isolate = v8::Isolate::GetCurrent(); + v8::HandleScope handleScope(isolate); + printf("PositionUpdate\n"); const unsigned argc = 2; uint64to32 data; @@ -43,8 +45,7 @@ void PositioningEnhancedPositionWrapper::PositionUpdate(const uint64_t& changedV v8::Local argv[argc]; argv[0] = v8::Local::New(isolate,v8::Uint32::New(isolate,data.p.high)); argv[1] = v8::Local::New(isolate,v8::Uint32::New(isolate,data.p.low)); - v8::Local fct; - fct.New(isolate,signalPositionUpdate); + v8::Local fct= v8::Local::New(isolate,signalPositionUpdate); fct->Call(isolate->GetCurrentContext()->Global(), argc, argv); } void PositioningEnhancedPositionWrapper::SetPositionUpdateListener(const v8::FunctionCallbackInfo &args) @@ -203,7 +204,7 @@ void PositioningEnhancedPositionWrapper::GetPositionInfo(const v8::FunctionCallb ret->Set(ret->Length(), data); } - args.GetReturnValue().Set(v8::DEFAULT); + args.GetReturnValue().Set(ret); } diff --git a/test/html-based-panel/node-cpp-lbs-modules/dbus-proxies/DemonstratorProxy.cpp b/test/html-based-panel/node-cpp-lbs-modules/dbus-proxies/DemonstratorProxy.cpp index 2c01e4f..e7e5361 100644 --- a/test/html-based-panel/node-cpp-lbs-modules/dbus-proxies/DemonstratorProxy.cpp +++ b/test/html-based-panel/node-cpp-lbs-modules/dbus-proxies/DemonstratorProxy.cpp @@ -75,7 +75,7 @@ DBus::Variant ManagerProxy::GetLevel() DBus::Variant ManagerProxy::GetSpeed() { - return (mp_engine_speed_properties->Get("org.automotive.EngineSpeed","EngineSpeed")); + return (mp_engine_speed_properties->Get("org.automotive.EngineSpeed","Speed")); } DBus::Variant ManagerProxy::GetInstantConsumption() diff --git a/test/html-based-panel/node-cpp-lbs-modules/package.json b/test/html-based-panel/node-cpp-lbs-modules/package.json index af66f57..bc31117 100644 --- a/test/html-based-panel/node-cpp-lbs-modules/package.json +++ b/test/html-based-panel/node-cpp-lbs-modules/package.json @@ -21,7 +21,8 @@ "gcontext": "0.0.3", "nan": "^2.3.5", "python-shell": "0.4.0", - "enum": "2.3.0" + "enum": "2.3.0", + "segfault-handler": "1.0.0" }, "devDependencies": { "chai": "~3.5.0", diff --git a/test/html-based-panel/simulation-panel.html b/test/html-based-panel/simulation-panel.html index f2c6aa2..f9b0ac1 100644 --- a/test/html-based-panel/simulation-panel.html +++ b/test/html-based-panel/simulation-panel.html @@ -46,7 +46,7 @@ STEP: Fuel instant - L/H + L/100 Vehicle speed @@ -110,82 +110,33 @@ socket_simulation_warning.on('feedback', function(message) { }) socket_simulation_get.on('positioning_answer', function(message) { - if(message.request === 'getPositionInfo') - { - getPositionInfoReturn(message.answer); - } + var funcCall = message.request + "Return"; + window[funcCall](message.answer); }) socket_simulation_signal.on('positioning_signal', function(message) { -console.log(message); - if(message.signal === 'positionUpdate') - { - positionUpdate(message.data); - } + var funcCall = message.signal; + window[funcCall](message.data); }) socket_simulation_get.on('navigationcore_answer', function(message) { - if(message.request === 'getGuidanceStatus') - { - getGuidanceStatusReturn(message.answer); - } else { - if(message.request === 'getSimulationStatus') - { - getSimulationStatusReturn(message.answer); - } - } + var funcCall = message.request + "Return"; + window[funcCall](message.answer); }) socket_simulation_signal.on('navigationcore_signal', function(message) { -console.log(message); - if(message.signal === 'guidanceStatusChanged') - { - guidanceStatusChanged(message.data); - } else { - if(message.signal === 'simulationStatusChanged') - { - simulationStatusChanged(message.data); - } - } + var funcCall = message.signal; + window[funcCall](message.data); }) socket_simulation_get.on('demonstrator_answer', function(message) { - if(message.request === 'getVersion') - { - getVersionReturn(message.answer); - } else { - if(message.request === 'getPositionInfo') - { - getPositionInfoReturn(message.answer); - } else { - if(message.request === 'getInstantData') - { - getInstantDataReturn(message.answer); - } else { - if(message.request === 'getLevel') - { - getLevelReturn(message.answer); - } else { - if(message.request === 'getInstantConsumption') - { - getInstantConsumptionReturn(message.answer); - } - } - } - } - } + var funcCall = message.request + "Return"; + window[funcCall](message.answer); }) socket_simulation_signal.on('demonstrator_signal', function(message) { - if(message.signal === 'tripDataUpdated') - { - tripDataUpdated(message.data); - } else { - if(message.signal === 'fuelStopAdvisorWarning') - { - fuelStopAdvisorWarning(message.data); - } - } + var funcCall = message.signal; + window[funcCall](message.data); }) @@ -289,6 +240,12 @@ function getLevel() { function getLevelReturn(answer) { document.getElementById("tank").innerHTML = answer[0]; } +function getEngineSpeed() { + socket_simulation_get.emit('demonstrator_request', {interface: 'FuelStopAdvisor', method: 'getEngineSpeed', parameters: []}); +} +function getEngineSpeedReturn(answer) { + document.getElementById("engine_speed").innerHTML = answer[0]; +} function getInstantConsumption() { socket_simulation_get.emit('demonstrator_request', {interface: 'FuelStopAdvisor', method: 'getInstantConsumption', parameters: []}); } @@ -307,6 +264,7 @@ function tripDataUpdated(number) { //for the moment, the changedValues is not used getInstantData(); getLevel(); + getEngineSpeed(); getInstantConsumption(); } -- cgit v1.2.1