return parseInt(value, 10);
}
+function kmhToMph(value) {
+ "use strict";
+ var kmh = parseInteger(value);
+ return Math.round(kmh * 0.621371);
+}
+
function parseTirePressure(value) {
"use strict";
var floatValue = parseFloat(value).toFixed(2);
"FrontDefrost" : {
attributeName : "defrostWindow",
callBackPropertyName : "frontDefrost",
- interfaceName : "defrost"
- //zone : new Zone(["Front"])
+ interfaceName : "defrost",
+ zone : new Zone(["front"])
},
"RearDefrost" : {
attributeName : "defrostWindow",
callBackPropertyName : "rearDefrost",
- interfaceName : "defrost"
- //zone : new Zone(["Rear"])
+ interfaceName : "defrost",
+ zone : new Zone(["rear"])
},
"FanSpeed" : {
attributeName : "fanSpeedLevel",
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",
"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",
interfaceName : "climateControl"
},
"AirflowDirection" : {
- attributeName : "airflowDirection",
+ attributeName : "airflowDirectionW3C",
callBackPropertyName : "airflowDirection",
interfaceName : "climateControl",
conversionFunction : parseInteger
}
},
"VehicleSpeed" : {
- attributeName : "vehicleSpeed",
+ attributeName : "speed",
callBackPropertyName : "speed",
interfaceName : "vehicleSpeed",
- conversionFunction : parseInteger
+ conversionFunction : kmhToMph
},
"Odometer" : {
attributeName : "odometer",
callBackPropertyName : "FrontBlwrSpeedCmd",
//interfaceName : "FrontBlwrSpeedCmd"
},
- "HeatedSeatFRModeRequest" : {
- attributeName : "HeatedSeatFRModeRequest",
- callBackPropertyName : "HeatedSeatFRModeRequest",
- //interfaceName : "HeatedSeatFRModeRequest"
- },
"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",
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 || data.zone.value.length === 0)) ||
+ ((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;
- }
}
}
}
* @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) {
}
}
- // this.status[indicator] = status === "true";
if (mappingProperty !== undefined) {
var objectName = mappingElement.interfaceName;
- var propertyZone = parseInt(mappingElement.zone, 2);
- var propertyValue = {};
- propertyValue[mappingProperty] = newValue;
- propertyValue.zone = propertyZone;
+ var zoneValue = (mappingElement.zone && mappingElement.zone.value) ? mappingElement.zone.value : undefined;
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 " + zoneValue + " 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();
- }
+
};