summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorasanoaozora <fifitaneki@hotmail.com>2016-06-09 15:57:37 +0200
committerasanoaozora <fifitaneki@hotmail.com>2016-06-09 15:57:37 +0200
commit3be3648d49a1d29d00b6fe3e9a44fa1959204629 (patch)
tree4d2cc889298f1b0b708584f6ca7047568c3fc910 /test
parent3e757d93f5f525e7278834397112c7028231c3ff (diff)
downloadnavigation-3be3648d49a1d29d00b6fe3e9a44fa1959204629.tar.gz
HTML panel and c++ addons (for simulation) aligned with nodejs 4.2.6
Diffstat (limited to 'test')
-rw-r--r--test/html-based-panel/node-cpp-lbs-modules/FuelStopAdvisorWrapper.cpp23
-rw-r--r--test/html-based-panel/node-cpp-lbs-modules/FuelStopAdvisorWrapper.hpp2
-rw-r--r--test/html-based-panel/node-cpp-lbs-modules/NavigationCoreWrapper.cpp10
-rw-r--r--test/html-based-panel/node-cpp-lbs-modules/PositioningEnhancedPositionWrapper.cpp7
-rw-r--r--test/html-based-panel/node-cpp-lbs-modules/dbus-proxies/DemonstratorProxy.cpp2
-rw-r--r--test/html-based-panel/node-cpp-lbs-modules/package.json3
-rw-r--r--test/html-based-panel/simulation-panel.html82
7 files changed, 46 insertions, 83 deletions
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<v8::Object> 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<v8::Value
void FuelStopAdvisorWrapper::GetInstantData(const v8::FunctionCallbackInfo<v8::Value> &args) {
v8::Isolate* isolate = args.GetIsolate();
-
// Retrieves the pointer to the wrapped object instance.
FuelStopAdvisorWrapper* obj = ObjectWrap::Unwrap<FuelStopAdvisorWrapper>(args.This());
@@ -234,21 +233,19 @@ void FuelStopAdvisorWrapper::GetInstantData(const v8::FunctionCallbackInfo<v8::V
for (std::map< uint16_t, ::DBus::Variant >::iterator iter = instant_data.begin(); iter != instant_data.end(); iter++) {
v8::Local<v8::Object> 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<v8::V
args.GetReturnValue().Set(ret);
}
-void FuelStopAdvisorWrapper::GetSpeed(const v8::FunctionCallbackInfo<v8::Value> &args) {
+void FuelStopAdvisorWrapper::GetEngineSpeed(const v8::FunctionCallbackInfo<v8::Value> &args) {
v8::Isolate* isolate = args.GetIsolate();
// Retrieves the pointer to the wrapped object instance.
FuelStopAdvisorWrapper* obj = ObjectWrap::Unwrap<FuelStopAdvisorWrapper>(args.This());
+ DBus::Variant variant = obj->mp_demonstratorProxy->mp_managerProxy->GetSpeed();
+ DBus::MessageIter it = variant.reader();
+ uint16_t engineSpeed;
+ it >> engineSpeed;
+
v8::Local<v8::Object> 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<v8::Object> 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<v8::Valu
FuelStopAdvisorWrapper* obj = ObjectWrap::Unwrap<FuelStopAdvisorWrapper>(args.This());
v8::Local<v8::Object> 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<v8::Value> &args);
void FuelStopAdvisorWarning(const bool& destinationCantBeReached);
- static void GetSpeed(const v8::FunctionCallbackInfo<v8::Value> &args);
+ static void GetEngineSpeed(const v8::FunctionCallbackInfo<v8::Value> &args);
static void GetLevel(const v8::FunctionCallbackInfo<v8::Value> &args);
static void GetInstantConsumption(const v8::FunctionCallbackInfo<v8::Value> &args);
static void GetOdometer(const v8::FunctionCallbackInfo<v8::Value> &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<v8::Function> 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<v8::Value> argv[argc];
argv[0]=v8::Local<v8::Value>::New(isolate,v8::Int32::New(isolate,guidanceStatus));
argv[1]=v8::Local<v8::Value>::New(isolate,v8::Uint32::New(isolate,routeHandle));
- v8::Local<v8::Function> fct;
- fct.New(isolate,signalGuidanceStatusChanged);
+ v8::Local<v8::Function> fct = v8::Local<v8::Function>::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<v8::Value> argv[argc];
argv[0]=v8::Local<v8::Value>::New(isolate,v8::Int32::New(isolate,simulationStatus));
- v8::Local<v8::Function> fct;
- fct.New(isolate,signalSimulationStatusChanged);
+ v8::Local<v8::Function> fct = v8::Local<v8::Function>::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<v8::Function> PositioningEnhancedPositionWrapper::constructor;
v8::Persistent<v8::Function> 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<v8::Value> argv[argc];
argv[0] = v8::Local<v8::Value>::New(isolate,v8::Uint32::New(isolate,data.p.high));
argv[1] = v8::Local<v8::Value>::New(isolate,v8::Uint32::New(isolate,data.p.low));
- v8::Local<v8::Function> fct;
- fct.New(isolate,signalPositionUpdate);
+ v8::Local<v8::Function> fct= v8::Local<v8::Function>::New(isolate,signalPositionUpdate);
fct->Call(isolate->GetCurrentContext()->Global(), argc, argv);
}
void PositioningEnhancedPositionWrapper::SetPositionUpdateListener(const v8::FunctionCallbackInfo<v8::Value> &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:
<tr>
<td>Fuel instant</td>
<td id=fuel_instant></td>
- <td>L/H</td>
+ <td>L/100</td>
</tr>
<tr>
<td>Vehicle speed</td>
@@ -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);
})
<!-- scenarii -->
@@ -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();
}