Skip to content

Commit 2e6e254

Browse files
mked-luxoftjacobkeeler
authored andcommitted
Feature/service status update to hmi (#184)
* Add custom result code of GetSystemTime response * Add implementation of Service Status Update * Add timeout for request received service type * Adding log message to the ServiceUpdatePopUp * Adding of minimize size for other popups * Adding processing of PROTECTION_ENFORCED reason
1 parent 0407855 commit 2e6e254

File tree

10 files changed

+526
-53
lines changed

10 files changed

+526
-53
lines changed

app/AppViews.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ SDL.AppViews = Em.ContainerView.extend(
6767
SDL.BottomControls,
6868
SDL.TTSPopUp,
6969
SDL.AlertPopUp,
70+
SDL.ServiceUpdatePopUp,
7071
SDL.AlertManeuverPopUp,
7172
SDL.AudioPassThruPopUp,
7273
SDL.VRPopUp,

app/controller/SettingsController.js

Lines changed: 70 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,22 @@ SDL.SettingsController = Em.Object.create(
3535
{
3636
activeState: 'settings.policies',
3737
hiddenLeftMenu: false,
38+
39+
/**
40+
* @name getSystemTimeResultCode
41+
* @desc parameter of response result code
42+
* for GetSystemTime RPC. Initial value sets as a zero which equals with
43+
* SUCCESS result code.
44+
*/
45+
getSystemTimeResultCode: 0,
46+
47+
/**
48+
* @name getSystemTimeButtonText
49+
* @desc parameter for changing text of
50+
* GetSystemTime result code button
51+
*/
52+
getSystemTimeButtonText: 'GetSystemTime result code - SUCCESS',
53+
3854
/**
3955
* File name for SDL.OnSystemRequest
4056
* Came in SDL.PolicyUpdate request
@@ -329,29 +345,49 @@ SDL.SettingsController = Em.Object.create(
329345
* @param {Boolean} abort
330346
*/
331347
policyUpdateRetry: function(abort) {
348+
if(SDL.SDLModel.data.policyUpdateRetry.isIterationInProgress) {
349+
return;
350+
}
332351
clearTimeout(SDL.SDLModel.data.policyUpdateRetry.timer);
333352
SDL.SDLModel.data.policyUpdateRetry.timer = null;
334-
if (abort !== 'ABORT' && (
335-
SDL.SDLModel.data.policyUpdateRetry.try <
336-
SDL.SDLModel.data.policyUpdateRetry.retry.length)) {
337-
SDL.SDLModel.data.policyUpdateRetry.oldTimer =
338-
SDL.SDLModel.data.policyUpdateRetry.oldTimer +
339-
SDL.SDLModel.data.policyUpdateRetry.timeout * 1000 +
340-
SDL.SDLModel.data.policyUpdateRetry.retry[SDL.SDLModel.data.policyUpdateRetry.try] *
341-
1000;
353+
354+
var sendOnSystemRequest = function() {
355+
SDL.SDLModel.data.policyUpdateRetry.isIterationInProgress = false;
356+
FFW.BasicCommunication.OnSystemRequest(
357+
'PROPRIETARY',
358+
SDL.SettingsController.policyUpdateFile,
359+
SDL.SDLModel.data.policyURLs[0].url,
360+
SDL.SDLModel.data.policyURLs[0].appID
361+
);
362+
}
363+
if(!SDL.SDLModel.data.policyUpdateRetry.isRetry) {
364+
SDL.SDLModel.data.policyUpdateRetry.isRetry = true;
365+
SDL.SDLModel.data.policyUpdateRetry.isIterationInProgress = true;
342366
SDL.SDLModel.data.policyUpdateRetry.timer = setTimeout(
343367
function() {
344-
FFW.BasicCommunication.OnSystemRequest(
345-
'PROPRIETARY',
346-
SDL.SettingsController.policyUpdateFile,
347-
SDL.SDLModel.data.policyURLs[0].url,
348-
SDL.SDLModel.data.policyURLs[0].appID
349-
);
350-
SDL.SettingsController.policyUpdateRetry();
368+
sendOnSystemRequest();
369+
}, 1000
370+
);
371+
return;
372+
}
373+
var length = SDL.SDLModel.data.policyUpdateRetry.retry.length;
374+
if(length == SDL.SDLModel.data.policyUpdateRetry.try) {
375+
SDL.SDLModel.data.policyUpdateRetry.isRetry = false;
376+
}
377+
if (abort !== 'ABORT' && SDL.SDLModel.data.policyUpdateRetry.isRetry) {
378+
379+
SDL.SDLModel.data.policyUpdateRetry.oldTimer =
380+
SDL.SDLModel.data.policyUpdateRetry.retry[SDL.SDLModel.data.policyUpdateRetry.try] * 1000;
381+
382+
SDL.SDLModel.data.policyUpdateRetry.timer = setTimeout(
383+
function() {
384+
sendOnSystemRequest();
351385
}, SDL.SDLModel.data.policyUpdateRetry.oldTimer
352386
);
387+
SDL.SDLModel.data.policyUpdateRetry.isIterationInProgress = true;
353388
SDL.SDLModel.data.policyUpdateRetry.try++;
354389
} else {
390+
SDL.SDLModel.data.policyUpdateRetry.isRetry = false;
355391
clearTimeout(SDL.SDLModel.data.policyUpdateRetry.timer);
356392
SDL.SDLModel.data.policyUpdateRetry = {
357393
timeout: null,
@@ -392,6 +428,25 @@ SDL.SettingsController = Em.Object.create(
392428
SDL.SeatModel.goToStates();
393429
SDL.States.goToStates('settings.seat');
394430
}
431+
},
432+
433+
/**
434+
* @function changeGetSystemTimeResultCode
435+
* @description Change result code of GetSystemTime response to SDL
436+
*/
437+
changeGetSystemTimeResultCode: function() {
438+
var successResultCode = SDL.SDLModel.data.resultCode.SUCCESS;
439+
440+
this.set('getSystemTimeResultCode',
441+
this.getSystemTimeResultCode == successResultCode
442+
? SDL.SDLModel.data.resultCode.REJECTED
443+
: SDL.SDLModel.data.resultCode.SUCCESS);
444+
445+
var buttonText = "GetSystemTime result code - ";
446+
this.set('getSystemTimeButtonText',
447+
this.getSystemTimeResultCode == successResultCode
448+
? buttonText + 'SUCCESS'
449+
: buttonText + 'REJECTED');
395450
}
396451
}
397452
);

app/model/sdl/Abstract/data.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,9 @@ SDL.SDLModelData = Em.Object.create(
7373
retry: [],
7474
try: null,
7575
timer: null,
76-
oldTimer: 0
76+
oldTimer: 0,
77+
isRetry: false,
78+
isIterationInProgress: false
7779
},
7880
/**
7981
* Application's container for current processed requests on VR component

app/view/sdl/PopUp.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,15 @@ SDL.PopUp = Em.ContainerView.extend(
4242
'backButton'
4343
],
4444
classNameBindings: [
45-
'this.active:active_state:inactive_state'
45+
'this.active:active_state:inactive_state',
46+
'minimalSize'
4647
],
4748
popUpId: 0,
4849
/**
4950
* Callback function to return result of made action by user
5051
*/
5152
callback: null,
53+
minimalSize: false,
5254
content: 'Title',
5355
active: false,
5456
timer: null,

app/view/sdl/ServiceUpdatePopUp.js

Lines changed: 242 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,242 @@
1+
/*
2+
* Copyright (c) 2019, Ford Motor Company All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without
5+
* modification, are permitted provided that the following conditions are met:
6+
* · Redistributions of source code must retain the above copyright notice,
7+
* this list of conditions and the following disclaimer.
8+
* · Redistributions in binary form must reproduce the above copyright notice,
9+
* this list of conditions and the following disclaimer in the documentation
10+
* and/or other materials provided with the distribution.
11+
* · Neither the name of the Ford Motor Company nor the names of its
12+
* contributors may be used to endorse or promote products derived from this
13+
* software without specific prior written permission.
14+
*
15+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16+
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17+
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18+
* ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19+
* LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20+
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21+
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22+
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23+
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24+
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25+
* POSSIBILITY OF SUCH DAMAGE.
26+
*/
27+
/**
28+
* @name SDL.ServiceUpdatePopUp
29+
* @desc Service update pop up module visual representation
30+
* @category View
31+
* @filesource app/view/sdl/ServiceUpdatePopUp.js
32+
* @version 1.0
33+
*/
34+
35+
SDL.ServiceUpdatePopUp = Em.ContainerView.create(
36+
{
37+
elementId: 'ServiceUpdatePopUp',
38+
classNames: 'ServiceUpdatePopUp',
39+
classNameBindings: [
40+
'active'
41+
],
42+
childViews: [
43+
'message',
44+
'progressIndicatorView',
45+
'backButton',
46+
'serviceEventLabel',
47+
'serviceTypeLabel',
48+
'serviceReasonLabel'
49+
],
50+
51+
timer: null,
52+
active: false,
53+
content: '',
54+
progress: false,
55+
serviceEventContent: '',
56+
serviceTypeContent: '',
57+
serviceReasonContent: '',
58+
59+
progressIndicatorView: Em.View.extend(
60+
{
61+
elementId: 'progress',
62+
classNameBindings: 'this.parentView.progress:progress'
63+
}
64+
),
65+
backButton: SDL.Button.extend(
66+
{
67+
classNames: 'button backButton',
68+
text: 'X',
69+
click: function() {
70+
this._parentView.deactivate();
71+
},
72+
buttonAction: true,
73+
onDown: false
74+
}
75+
),
76+
message: SDL.Label.extend(
77+
{
78+
elementId: 'text',
79+
classNames: 'text',
80+
contentBinding: 'parentView.content'
81+
}
82+
),
83+
serviceEventLabel: SDL.Label.extend(
84+
{
85+
elementId: 'serviceEventLabel',
86+
classNames: 'serviceEventLabel',
87+
contentBinding: 'parentView.serviceEventContent'
88+
}
89+
),
90+
serviceTypeLabel: SDL.Label.extend(
91+
{
92+
elementId: 'serviceTypeLabel',
93+
classNames: 'serviceTypeLabel',
94+
contentBinding: 'parentView.serviceTypeContent'
95+
}
96+
),
97+
serviceReasonLabel: SDL.Label.extend(
98+
{
99+
elementId: 'serviceReasonLabel',
100+
classNames: 'serviceReasonLabel',
101+
contentBinding: 'parentView.serviceReasonContent'
102+
}
103+
),
104+
105+
/**
106+
* @function deactivate
107+
* @desc Deactivate ServiceUpdatePopUp
108+
*
109+
*/
110+
deactivate: function() {
111+
this.set('active', false);
112+
this.set('progress', false);
113+
this.set('content', '');
114+
this.set('infoContent', '');
115+
this.set('serviceTypeContent', '');
116+
this.set('serviceEventContent', '');
117+
this.set('serviceReasonContent', '');
118+
},
119+
120+
setLogMessage: function(serviceType, serviceEvent, serviceReason) {
121+
this.set('serviceTypeContent', serviceType ? 'Service type: ' + serviceType : '');
122+
this.set('serviceEventContent', serviceEvent ? 'Service event: ' + serviceEvent : '');
123+
this.set('serviceReasonContent', serviceReason ? 'Service reason: ' + serviceReason : '');
124+
},
125+
/**
126+
* @function activate
127+
* @desc activate ServiceUpdatePopUp
128+
* @param {string} serviceType
129+
* @param {string} serviceEvent
130+
* @param {string} serviceReason
131+
*/
132+
activate: function(serviceType, serviceEvent, serviceReason) {
133+
if(serviceType === undefined) {
134+
return;
135+
}
136+
this.setLogMessage(serviceType, serviceEvent, serviceReason);
137+
switch (serviceEvent) {
138+
case 'REQUEST_RECEIVED': {
139+
this.setContentByServiceType(serviceType);
140+
this.set('progress', this.get('content') != '');
141+
this.set('active', this.get('content') != '');
142+
break;
143+
}
144+
case 'REQUEST_ACCEPTED': {
145+
var self = this;
146+
this.timer = setTimeout(
147+
function() {
148+
self.deactivate();
149+
},
150+
2000
151+
);
152+
break;
153+
}
154+
case 'REQUEST_REJECTED': {
155+
this.rejectedRequest(serviceReason);
156+
var self = this;
157+
this.timer = setTimeout(
158+
function() {
159+
self.deactivate();
160+
},
161+
5000
162+
);
163+
break;
164+
}
165+
default: {
166+
if(serviceReason !== undefined) {
167+
this.rejectedRequest(serviceReason);
168+
var self = this;
169+
this.timer = setTimeout(
170+
function() {
171+
self.deactivate();
172+
},
173+
5000
174+
);
175+
}
176+
break;
177+
}
178+
}
179+
},
180+
181+
/**
182+
* @function setContentByServiceType
183+
* @param {string} serviceType
184+
* @description Check serviceType and set content of popUp
185+
*/
186+
setContentByServiceType: function(serviceType) {
187+
switch(serviceType) {
188+
case 'VIDEO': {
189+
this.set('content', 'Starting Video Stream');
190+
break;
191+
}
192+
case 'AUDIO': {
193+
this.set('content', 'Starting Audio Stream');
194+
break;
195+
}
196+
default: break;
197+
}
198+
},
199+
200+
/**
201+
* @function rejectedRequest
202+
* @desc Processing reason of rejected request
203+
* @param {string} reason
204+
*/
205+
rejectedRequest: function(reason) {
206+
this.set('active', true);
207+
this.set('progress',false);
208+
209+
switch(reason) {
210+
case 'PTU_FAILED': {
211+
this.set('content', 'Unable to update apps.' +
212+
'Make sure your device has an internet connection');
213+
break;
214+
}
215+
case 'INVALID_CERT': {
216+
this.set('content', 'System is unable to authenticate the app');
217+
break;
218+
}
219+
case 'INVALID_TIME': {
220+
this.set('content', 'Unable to get valid time.' +
221+
'Make sure your device has access to GPS signal');
222+
break;
223+
}
224+
case 'PROTECTION_ENFORCED': {
225+
this.set('content', 'Attempting to start unprotected service which '
226+
+ 'is configured as a force protected');
227+
break;
228+
}
229+
case 'PROTECTION_DISABLED': {
230+
this.set('content', 'Attempting to start protected service which '
231+
+ 'is configured as force unprotected');
232+
break;
233+
}
234+
default: {
235+
this.set('content', 'Rejected by unknown reason');
236+
break;
237+
}
238+
}
239+
}
240+
}
241+
);
242+

0 commit comments

Comments
 (0)