Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SubscribeVehicleData/UnsubscribeVehicleData response #34

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions app/model/sdl/Abstract/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,6 @@ SDL.SDLModel = Em.Object.extend({

},

/**
* List of subscribed data on VehicleInfo model
*
* @type {Object}
*/
subscribedData: {},

applicationStatusBar: '',

updateStatusBar: function() {
Expand Down
10 changes: 0 additions & 10 deletions app/model/sdl/MediaModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ SDL.SDLMediaModel = SDL.ABSAppModel.extend({

this._super();

var subscribeVIData = {};

for (var key in SDL.SDLVehicleInfoModel.vehicleData) {
if (key != 'externalTemperature') {
subscribeVIData[key] = false;
}
}

this.set('subscribedData', subscribeVIData);

// init properties here
this.set('appInfo', Em.Object.create({
field1: '<field1>',
Expand Down
10 changes: 0 additions & 10 deletions app/model/sdl/NonMediaModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,6 @@ SDL.SDLNonMediaModel = SDL.ABSAppModel.extend({

this._super();

var subscribeVIData = {};

for (var key in SDL.SDLVehicleInfoModel.vehicleData) {
if (key != 'externalTemperature') {
subscribeVIData[key] = false;
}
}

this.set('subscribedData', subscribeVIData);

// init properties here
this.set('appInfo', Em.Object.create({
field1: '<field1>',
Expand Down
76 changes: 32 additions & 44 deletions app/model/sdl/VehicleInfoModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,20 @@ SDL.SDLVehicleInfoModel = Em.Object.create(
getVehicleType: function(id) {
FFW.VehicleInfo.GetVehicleTypeResponse(this.vehicleType, id);
},
/**
* Method to get currently available vehicle data parameters
*/
getAvailableVehicleData: function() {
var availableVIData = [];

for (var key in this.vehicleData) {
if (key != 'externalTemperature') {
availableVIData.push(key);
}
}

return availableVIData;
},
/**
* SDL VehicleInfo.GetDTCs handler fill data for response about vehicle
* errors
Expand Down Expand Up @@ -402,25 +416,21 @@ SDL.SDLVehicleInfoModel = Em.Object.create(
*/
SubscribeVehicleData: function(message) {
var subscribeVIData = {};
var availableData = this.getAvailableVehicleData();

for (var key in message.params) {
if (key === 'clusterModeStatus') {
key = 'clusterModes';
}
if (SDL.SDLModel.subscribedData[key] === true) {
subscribeVIData[key] = {
dataType: this.eVehicleDataType[key],
resultCode: 'DATA_ALREADY_SUBSCRIBED'
};
} else if (key === 'externalTemperature') {
if (availableData.indexOf(key) >= 0) {
subscribeVIData[key] = {
dataType: this.eVehicleDataType[key],
resultCode: 'VEHICLE_DATA_NOT_AVAILABLE'
resultCode: 'SUCCESS'
};
} else {
SDL.SDLModel.subscribedData[key] = true;
subscribeVIData[key] = {
dataType: this.eVehicleDataType[key],
resultCode: 'SUCCESS'
resultCode: 'VEHICLE_DATA_NOT_AVAILABLE'
};
}
}
Expand All @@ -435,32 +445,28 @@ SDL.SDLVehicleInfoModel = Em.Object.create(
* @type {Object} message
*/
UnsubscribeVehicleData: function(message) {
var subscribeVIData = {};
var unsubscribeVIData = {};
var availableData = this.getAvailableVehicleData();

for (var key in message.params) {
if (key === 'clusterModeStatus') {
key = 'clusterModes';
}
if (SDL.SDLModel.subscribedData[key] === false) {
subscribeVIData[key] = {
if (availableData.indexOf(key) >= 0) {
unsubscribeVIData[key] = {
dataType: this.eVehicleDataType[key],
resultCode: 'DATA_NOT_SUBSCRIBED'
};
} else if (key === 'externalTemperature') {
subscribeVIData[key] = {
dataType: this.eVehicleDataType[key],
resultCode: 'VEHICLE_DATA_NOT_AVAILABLE'
resultCode: 'SUCCESS'
};
} else {
SDL.SDLModel.subscribedData[key] = false;
subscribeVIData[key] = {
unsubscribeVIData[key] = {
dataType: this.eVehicleDataType[key],
resultCode: 'SUCCESS'
resultCode: 'VEHICLE_DATA_NOT_AVAILABLE'
};
}
}
FFW.VehicleInfo.sendVISubscribeVehicleDataResult(
SDL.SDLModel.data.resultCode.SUCCESS, message.id, message.method,
subscribeVIData
unsubscribeVIData
);
},
/**
Expand Down Expand Up @@ -497,22 +503,6 @@ SDL.SDLVehicleInfoModel = Em.Object.create(
);
}
},
/**
* Function send prndl vehicle conditions on FFW.VehicleInfo.OnVehicleData
* for notification when data changes
*/
onVehicleDataChanged: function() {
var appID = null;
for (var i = 0; i < SDL.SDLModel.data.registeredApps.length; i++) {
appID = SDL.SDLModel.data.registeredApps[i].appID;
if (SDL.SDLModel.subscribedData['prndl']) {
var jsonData = {};
jsonData['prndl'] = this.vehicleData['prndl'];
FFW.VehicleInfo.OnVehicleData(jsonData);
return;
}
}
}.observes('this.vehicleData.prndl'),
/**
* Function send gps vehicle conditions on FFW.VehicleInfo.OnVehicleData
* for notification when data changes
Expand All @@ -526,12 +516,10 @@ SDL.SDLVehicleInfoModel = Em.Object.create(
this.set('vehicleData.gps.latitudeDegrees', lat);
this.set('vehicleData.gps.longitudeDegrees', lng);
for (var i = 0; i < SDL.SDLModel.data.registeredApps.length; i++) {
if (SDL.SDLModel.subscribedData['gps']) {
var jsonData = {};
jsonData['gps'] = this.vehicleData['gps'];
FFW.VehicleInfo.OnVehicleData(jsonData);
return;
}
var jsonData = {};
jsonData['gps'] = this.vehicleData['gps'];
FFW.VehicleInfo.OnVehicleData(jsonData);
return;
}
},
/**
Expand Down