Skip to content

Commit

Permalink
Revert "Add comparator to track difference before and after (smartdev…
Browse files Browse the repository at this point in the history
  • Loading branch information
LiliiaShlikhtLuxoft committed Sep 17, 2021
1 parent 872d647 commit 3a87e06
Showing 1 changed file with 18 additions and 59 deletions.
77 changes: 18 additions & 59 deletions app/controller/sdl/RCModulesController.js
Original file line number Diff line number Diff line change
Expand Up @@ -785,18 +785,6 @@ SDL.RCModulesController = Em.Object.create({
location_name = FLAGS.VehicleEmulationType;
}

let getDataDifference = (one, another) => {
var diff = {};
for (var param in one) {
if (undefined !== another[param] &&
SDL.SDLController.compareObjects(another[param], one[param]) > 0) {
diff[param] = another[param];
}
}

return diff;
};

var dataToReturn = {};
switch (moduleType) {
case 'RADIO':
Expand Down Expand Up @@ -843,18 +831,15 @@ SDL.RCModulesController = Em.Object.create({
);
return;
} else {
const data_before = SDL.deepCopy(this.radioModels[location_name].getRadioControlData(false));
const radioControlData =
var radioControlData =
this.radioModels[location_name].setRadioData(
data.params.moduleData.radioControlData);
if (this.radioModels[location_name].radioControlStruct.radioEnable) {
this.radioModels[location_name].saveCurrentOptions();
}

const changedFields = getDataDifference(data_before, radioControlData);
if (Object.keys(changedFields).length > 0) {
if (Object.keys(radioControlData).length > 0) {
FFW.RC.onInteriorVehicleDataNotification({moduleType:'RADIO', moduleId: moduleUUId,
radioControlData: changedFields});
radioControlData: radioControlData});
}
dataToReturn.radioControlData = radioControlData;
}
Expand Down Expand Up @@ -885,14 +870,12 @@ SDL.RCModulesController = Em.Object.create({
return;
}
}
const data_before = SDL.deepCopy(this.climateModels[location_name].generateClimateControlData());
var climateControlData =
this.climateModels[location_name].setClimateData(
data.params.moduleData.climateControlData);
const changedFields = getDataDifference(data_before, climateControlData);
if (Object.keys(changedFields).length > 0) {
if (Object.keys(data.params.moduleData.climateControlData).length > 0) {
FFW.RC.onInteriorVehicleDataNotification({moduleType:'CLIMATE', moduleId: moduleUUId,
climateControlData: changedFields});
climateControlData: climateControlData});
}
dataToReturn.climateControlData = climateControlData;
}
Expand All @@ -909,15 +892,12 @@ SDL.RCModulesController = Em.Object.create({
);
return;
} else {
const data_before = SDL.deepCopy(this.audioModels[location_name].getAudioControlData());
var audioControlData = (data.params.moduleData.audioControlData.keepContext!=null) ?
this.audioModels[location_name].setAudioControlDataWithKeepContext(data.params.moduleData.audioControlData, location_name) :
this.audioModels[location_name].setAudioControlData(data.params.moduleData.audioControlData, location_name);

const changedFields = getDataDifference(data_before, audioControlData);
if (Object.keys(changedFields).length > 0) {
this.audioModels[location_name].setAudioControlDataWithKeepContext(data.params.moduleData.audioControlData, location_name) :
this.audioModels[location_name].setAudioControlData(data.params.moduleData.audioControlData, location_name);
if (Object.keys(data.params.moduleData.audioControlData).length > 0) {
FFW.RC.onInteriorVehicleDataNotification({moduleType:'AUDIO', moduleId: moduleUUId,
audioControlData: changedFields});
audioControlData: audioControlData});
}
if(data.params.moduleData.audioControlData.source === 'MOBILE_APP') {
FFW.RC.OnIVDNotificationWasSent = true;
Expand All @@ -930,14 +910,11 @@ SDL.RCModulesController = Em.Object.create({
case 'HMI_SETTINGS':
{
if(data.params.moduleData.hmiSettingsControlData){
const data_before = SDL.deepCopy(this.hmiSettingsModels[location_name].getHmiSettingsControlData());
var hmiSettingsControlData = this.hmiSettingsModels[location_name].setHmiSettingsData(
data.params.moduleData.hmiSettingsControlData);

const changedFields = getDataDifference(data_before, hmiSettingsControlData);
if (Object.keys(changedFields).length > 0) {
if (Object.keys(data.params.moduleData.hmiSettingsControlData).length > 0) {
FFW.RC.onInteriorVehicleDataNotification({moduleType:'HMI_SETTINGS', moduleId: moduleUUId,
hmiSettingsControlData: changedFields});
hmiSettingsControlData: hmiSettingsControlData});
}
dataToReturn.hmiSettingsControlData = hmiSettingsControlData;
}
Expand All @@ -946,26 +923,12 @@ SDL.RCModulesController = Em.Object.create({
case 'LIGHT':
{
if(data.params.moduleData.lightControlData){
const data_before_tmp = SDL.deepCopy(this.lightModels[location_name].getLightControlData());
let data_before = {
lightState: []
};

var lightControlData = this.lightModels[location_name].setLightControlData(
data.params.moduleData.lightControlData);

data_before_tmp.lightState.forEach( (element_dest) => {
lightControlData.lightState.forEach( (element_target) => {
if (element_target.id == element_dest.id) {
data_before.lightState.push(element_dest);
}
});
});

const changedFields = getDataDifference(data_before, lightControlData);
if (Object.keys(changedFields).length > 0) {
FFW.RC.onInteriorVehicleDataNotification({moduleType:'LIGHT', moduleId: moduleUUId,
lightControlData: changedFields});
if (Object.keys(lightControlData).length > 0) {
FFW.RC.onInteriorVehicleDataNotification({moduleType:'LIGHT', moduleId: moduleUUId,
lightControlData: data.params.moduleData.lightControlData});
}
dataToReturn.lightControlData = lightControlData;
}
Expand All @@ -974,15 +937,11 @@ SDL.RCModulesController = Em.Object.create({
case 'SEAT':
{
if(data.params.moduleData.seatControlData){
const data_before = SDL.deepCopy(this.seatModels[location_name].getSeatControlData());
var seatControlData = this.seatModels[location_name].setSeatControlData(
data.params.moduleData.seatControlData
);

const changedFields = getDataDifference(data_before, seatControlData);
if (Object.keys(changedFields).length > 0) {
FFW.RC.onInteriorVehicleDataNotification({moduleType:'SEAT', moduleId: moduleUUId,
seatControlData: changedFields});
data.params.moduleData.seatControlData);
if (Object.keys(data.params.moduleData.seatControlData).length > 0) {
FFW.RC.onInteriorVehicleDataNotification({moduleType:'SEAT', moduleId: moduleUUId,
seatControlData: seatControlData});
}
dataToReturn.seatControlData = seatControlData;
}
Expand Down

0 comments on commit 3a87e06

Please sign in to comment.