Skip to content

Commit

Permalink
Fix onResetTimeout logic
Browse files Browse the repository at this point in the history
Fix OnResetTimeout logic for next RPC:

- Alert
- Slider
- ScrollableMessage
- Speak
- PerformInteraction

Also answer to review
  • Loading branch information
ValeriiMalkov committed Nov 20, 2018
1 parent 814c278 commit 0e141d3
Show file tree
Hide file tree
Showing 18 changed files with 423 additions and 128 deletions.
15 changes: 14 additions & 1 deletion app/controller/sdl/RController.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,6 +582,19 @@ SDL.RController = SDL.SDLController.extend(
}

return properties;
}
},

/**
* isEmptyObject function. Checks that the object is empty
*/
isEmptyObject: function(object) {
var l = 0;
for (var key in object) {
if(object.hasOwnProperty(key)) {
++l;
}
}
return l == 0;
},
}
);
14 changes: 2 additions & 12 deletions app/model/SeatModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -402,16 +402,6 @@ SDL.SeatModel = Em.Object.create({
Em.Object.create(SDL.deepCopy(SDL.SeatModel.tempSeatControlData)));
},

isEmptyObject: function(object) {
var l = 0;
for (var key in object) {
if(object.hasOwnProperty(key)) {
++l;
}
}
return l == 0;
},

dfs:function(from, to) {
var result = SDL.deepCopy(from);
for (var key in from) {
Expand All @@ -427,13 +417,13 @@ SDL.SeatModel = Em.Object.create({
}

var temp = this.dfs(from[key],to[key]);
if (!this.isEmptyObject(temp)) {
if (!SDL.SDLController.isEmptyObject(temp)) {
result[key] = from[key];
continue;
}
}
var temp = this.dfs(from[key], to[key]);
if (!this.isEmptyObject(temp)) {
if (!SDL.SDLController.isEmptyObject(temp)) {
result[key] = temp;
} else {
delete result[key];
Expand Down
3 changes: 2 additions & 1 deletion app/model/sdl/Abstract/AppModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,8 @@ SDL.ABSAppModel = Em.Object.extend(
*/
onSlider: function(message) {
SDL.SliderView.loadData(message);
SDL.SliderView.activate(this.appName, message.params.timeout);
SDL.SliderView.setText(this.appName);
SDL.SliderView.activate(message.params.timeout);
}
}
);
58 changes: 39 additions & 19 deletions app/model/sdl/Abstract/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,11 @@ SDL.SDLModel = Em.Object.extend({

applicationStatusBar: '',

/**
* timeout for VR
*/
timeout: null,

updateStatusBar: function() {

if (this.data.limitedExist &&
Expand Down Expand Up @@ -1025,13 +1030,11 @@ SDL.SDLModel = Em.Object.extend({
setTimeout(function() {
if (SDL.SDLModel.data.vrActiveRequests.vrPerformInteraction) { // If VR PerformInteraction session is still active
SDL.SDLModel.onPrompt(message.params.timeoutPrompt);
SDL.ResetTimeoutPopUp.ActivatePopUp();
} else if (!message.params.grammarID &&
SDL.SDLController.getApplicationModel(message.params.appID
).activeRequests.uiPerformInteraction) {
// If UI PerformInteraction session is still active and PerformInteraction mode is MANUAL only
SDL.SDLModel.onPrompt(message.params.timeoutPrompt);
SDL.ResetTimeoutPopUp.ActivatePopUp();
}

}, message.params.timeout - 2000
Expand All @@ -1045,23 +1048,7 @@ SDL.SDLModel = Em.Object.extend({

this.data.set('performInteractionSession', message.params.grammarID);
SDL.SDLModel.data.set('VRActive', true);

setTimeout(function() {
if (SDL.SDLModel.data.VRActive) {
if (SDL.SDLModel.data.vrActiveRequests.vrPerformInteraction) {
SDL.SDLController.vrInteractionResponse(
SDL.SDLModel.data.resultCode['TIMED_OUT']
);
} else {
console.error(
'SDL.SDLModel.data.vrActiveRequests.vrPerformInteraction is empty!'
);
}

SDL.SDLModel.data.set('VRActive', false);
}
}, message.params.timeout
);
this.vrTimeout(message.params.timeout);

SDL.InteractionChoicesView.timerUpdate();
} else {
Expand All @@ -1071,7 +1058,40 @@ SDL.SDLModel = Em.Object.extend({
);
}
},

/**
* deactivateVr function.
*/
deactivateVr: function() {
SDL.SDLController.vrInteractionResponse(
SDL.SDLModel.data.resultCode['SUCCESS']
);
SDL.SDLModel.data.set('VRActive', false);

},

/**
* vrTimeout function
*/
vrTimeout: function(timer) {
self = SDL.SDLModel;
clearTimeout(self.timeout);
self.timeout = setTimeout(function() {
if (SDL.SDLModel.data.VRActive) {
if (SDL.SDLModel.data.vrActiveRequests.vrPerformInteraction) {
SDL.SDLController.vrInteractionResponse(
SDL.SDLModel.data.resultCode['TIMED_OUT']
);
} else {
console.error(
'SDL.SDLModel.data.vrActiveRequests.vrPerformInteraction is empty!'
);
}
SDL.SDLModel.data.set('VRActive', false);
}
}, timer
);
},
/**
* SDL UI Slider response handler show popup window
*
Expand Down
24 changes: 23 additions & 1 deletion app/view/home/controlButtons.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,30 @@ SDL.ControlButtons = Em.ContainerView.create({
'phoneCall',
'keyboard',
'imageMode',
'imageModeLabel'
'imageModeLabel',
'resetPeriodLabel',
'resetPeriodInput'
],

resetPeriodLabel: SDL.Label.extend({
elementId: 'resetPeriodLabel',
classNames: 'resetPeriodLabel',
content: 'Reset period, ms:'
}
),

resetPeriodInput: Ember.TextField.extend(
{
elementId: 'resetPeriodInput',
classNames: 'resetPeriodInput',
value: 10000,
type:'number',
keyUp: function(event, view) {
SDL.ResetTimeoutPopUp.set('resetPeriod', this.value/1000);
}
}
),

imageModeLabel: SDL.Label.extend({
elementId: 'imageModeLabel',
classNames: 'imageModeLabel',
Expand Down
30 changes: 25 additions & 5 deletions app/view/sdl/AlertPopUp.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ SDL.AlertPopUp = Em.ContainerView.create(
active: false,
timer: null,
timeout: null,
ttsTimer: null,
ttsTimeout: null,
progressIndicator: false,
/**
* Wagning image on Alert PopUp
Expand Down Expand Up @@ -129,7 +131,7 @@ SDL.AlertPopUp = Em.ContainerView.create(
);
}else {
SDL.SDLController.alertResponse(
SDL.SDLModel.data.resultCode.SUCCESS, this.alertRequestId
SDL.SDLModel.data.resultCode['ABORTED'], this.alertRequestId
);
}
SDL.SDLController.onSystemContextChange();
Expand Down Expand Up @@ -227,20 +229,38 @@ SDL.AlertPopUp = Em.ContainerView.create(
}
}
this.set('active', true);
this.setTimer(message.duration ? message.duration : this.defaultTimeout);
this.setTimerUI(message.duration ? message.duration : this.defaultTimeout);

},

/*
* function setTimer. Sets the active timer of the view
* function setTimerTTS. Sets the active timer of the view for TTS RPC
*/
setTimerTTS: function(time){
var self = SDL.AlertPopUp;
self.set('ttsTimeout', time);
clearTimeout(self.ttsTimer);
self.ttsTimer = setTimeout(
function() {
clearTimeout(self.ttsTimer);
}, self.ttsTimeout
);
},

/*
* function setTimerUI. Sets the active timer of the view for UI RPC
*/
setTimer: function(time){
setTimerUI: function(time){
var self = SDL.AlertPopUp;
self.set('timeout', time);
clearTimeout(self.timer);
self.timer = setTimeout(
function() {
self.deactivate('timeout');
self.set('active', false);
clearTimeout(self.timer);
self.set('content1', '');
self.set('content2', '');
self.set('content3', '');
}, self.timeout
);
}
Expand Down
Loading

0 comments on commit 0e141d3

Please sign in to comment.