From af9ff30e6cce533e820c28f893046dca1db7b628 Mon Sep 17 00:00:00 2001 From: Brian Jones Date: Fri, 12 Dec 2014 15:43:47 -0800 Subject: [PATCH] Updates to utilize AMB set calls Change-Id: I9d39c469b3c00bb067fa3a29f230bcbbfb1758ca --- js/services/carIndicator.js | 75 ++++++++++++++++++++-------------------- packaging/modello-common.changes | 3 ++ 2 files changed, 41 insertions(+), 37 deletions(-) diff --git a/js/services/carIndicator.js b/js/services/carIndicator.js index 99d33a6..e82a4c1 100644 --- a/js/services/carIndicator.js +++ b/js/services/carIndicator.js @@ -220,15 +220,15 @@ CarIndicator.prototype._mappingTable = { attributeName : "targetTemperature", callBackPropertyName : "targetTemperatureRight", interfaceName : "climateControl", - conversionFunction : parseInteger - //zone : new Zone(["Right"]) + conversionFunction : parseInteger, + zone : new Zone(["front", "right"]) }, "TargetTemperatureLeft" : { attributeName : "targetTemperature", callBackPropertyName : "targetTemperatureLeft", interfaceName : "climateControl", - conversionFunction : parseInteger - //zone : new Zone(["Left"]) + conversionFunction : parseInteger, + zone : new Zone(["front", "left"]) }, "Hazard" : { attributeName : "hazard", @@ -243,14 +243,14 @@ CarIndicator.prototype._mappingTable = { "SeatHeaterRight" : { attributeName : "seatHeater", callBackPropertyName : "seatHeaterRight", - interfaceName : "climateControl" - //zone : new Zone(["Right"]) + interfaceName : "climateControl", + zone : new Zone(["front", "right"]) }, "SeatHeaterLeft" : { attributeName : "seatHeater", callBackPropertyName : "seatHeaterLeft", - interfaceName : "climateControl" - //zone : new Zone(["Left"]) + interfaceName : "climateControl", + zone : new Zone(["front", "left"]) }, "Parking" : { attributeName : "parking", @@ -317,7 +317,7 @@ CarIndicator.prototype._mappingTable = { } }, "VehicleSpeed" : { - attributeName : "vehicleSpeed", + attributeName : "speed", callBackPropertyName : "speed", interfaceName : "vehicleSpeed", conversionFunction : parseInteger @@ -405,29 +405,21 @@ CarIndicator.prototype._mappingTable = { //interfaceName : "FrontTSetLeftCmd" }, "FrontBlwrSpeedCmd" : { - attributeName : "FrontBlwrSpeedCmd", + attributeName : "fanSpeedLevel", callBackPropertyName : "FrontBlwrSpeedCmd", - //interfaceName : "FrontBlwrSpeedCmd" - }, - "HeatedSeatFRModeRequest" : { - attributeName : "HeatedSeatFRModeRequest", - callBackPropertyName : "HeatedSeatFRModeRequest", - //interfaceName : "HeatedSeatFRModeRequest" + interfaceName : "climateControl" }, "HeatedSeatFRRequest" : { - attributeName : "HeatedSeatFRRequest", + attributeName : "seatHeater", callBackPropertyName : "HeatedSeatFRRequest", - //interfaceName : "HeatedSeatFRRequest" - }, - "HeatedSeatFLModeRequest" : { - attributeName : "HeatedSeatFLModeRequest", - callBackPropertyName : "HeatedSeatFLModeRequest", - //interfaceName : "HeatedSeatFLModeRequest" + interfaceName : "climateControl", + zone : new Zone(["front", "right"]) }, "HeatedSeatFLRequest" : { - attributeName : "HeatedSeatFLRequest", + attributeName : "seatHeater", callBackPropertyName : "HeatedSeatFLRequest", - //interfaceName : "HeatedSeatFLRequest" + interfaceName : "climateControl", + zone : new Zone(["front", "left"]) }, "FLHSDistrCmd" : { attributeName : "FLHSDistrCmd", @@ -532,13 +524,14 @@ CarIndicator.prototype.onDataUpdate = function(data, self, lisenersID) { for ( var element in self._mappingTable) { if (self._mappingTable.hasOwnProperty(element) && self._mappingTable[element].interfaceName !== undefined) { if (self._mappingTable[element].interfaceName.toLowerCase() === data.interfaceName.toLowerCase() && - self._mappingTable[element].attributeName.toLowerCase() === property.toLowerCase()) { - /* jshint bitwise: false */ - if (!(zone ^ self._mappingTable[element].zone)) { - /* jshint bitwise: true */ + self._mappingTable[element].attributeName.toLowerCase() === property.toLowerCase() && + ((!self._mappingTable[element].zone && !data.zone) || + ((self._mappingTable[element].zone && data.zone) && + (typeof(self._mappingTable[element].zone.equals) === typeof(data.zone.equals)) && + self._mappingTable[element].zone.equals(data.zone))) + ) { mapping = self._mappingTable[element]; break; - } } } } @@ -684,7 +677,7 @@ CarIndicator.prototype.getStatus = function(callback) { * @param text_status {string} new status . * @param callback {function} callback function. */ -CarIndicator.prototype.setStatus = function(indicator, newValue, callback, zone) { +CarIndicator.prototype.setStatus = function(indicator, newValue, zone) { "use strict"; var mappingElement, mappingProperty; for ( var element in this._mappingTable) { @@ -707,14 +700,22 @@ CarIndicator.prototype.setStatus = function(indicator, newValue, callback, zone) propertyValue.zone = propertyZone; if (typeof (navigator.vehicle) !== 'undefined') { - navigator.vehicle.set(objectName, propertyValue, function(msg) { - console.error("Set error: " + msg); - }); + if (typeof (navigator.vehicle[objectName]) !== 'undefined' && typeof (navigator.vehicle[objectName].set) !== 'undefined') { + console.log("trying to set: " + objectName + "." + mappingProperty + " in zone " + mappingElement.zone.value + " to " + newValue); + var value = {}; + value[mappingProperty] = newValue; + navigator.vehicle[objectName].set(value, mappingElement.zone).then(function() { + console.log("Set success!"); + }, function(error) { + console.log("Set failed! " + error.message); + }); + } + else + console.error("Can't set status for " + objectName + " because it doesn't exist " + indicator); + } else { console.warn("Vehicle API is not available."); } } - if (!!callback) { - callback(); - } + }; diff --git a/packaging/modello-common.changes b/packaging/modello-common.changes index 48e9441..a705d1e 100644 --- a/packaging/modello-common.changes +++ b/packaging/modello-common.changes @@ -1,3 +1,6 @@ +* Fri Dec 12 2014 Brian Jones accepted/tizen/ivi/20141204.025516-1-gb36e67a +- Updates to utilize AMB set calls + * Wed Dec 03 2014 Jimmy Huang accepted/tizen/ivi/20141202.054026-1-ge06950b - Added sanity check before calling Vehicle api -- 2.7.4