2 * Copyright (c) 2013, Ford Motor Company All rights reserved.
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.
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.
28 * @name SDL.SDLController
29 * @desc Main SDL Controller
30 * @category Controller
31 * @filesource app/controller/sdl/SDLController.js
35 SDL.SDLController = Em.Object.create( {
38 * Current system context
42 sysContext: function() {
44 if( SDL.VRPopUp.VRActive ){
48 if( SDL.AlertPopUp.active ){
52 if( SDL.TBTClientStateView.active || SDL.VehicleInfo.active || SDL.DriverDistraction.active ){
53 return 'HMI_OBSCURED';
56 if( SDL.OptionsView.active ){
60 if( SDL.States.info.nonMedia.active || SDL.States.media.sdlmedia.active ){
66 }.property( 'SDL.DriverDistraction.active', 'SDL.OptionsView.active', 'SDL.VRPopUp.VRActive', 'SDL.AlertPopUp.active', 'SDL.TBTClientStateView.active',
67 'SDL.VehicleInfo.active', 'SDL.States.info.nonMedia.active', 'SDL.States.media.sdlmedia.active' ),
70 * List of SDL application models
76 1: SDL.SDLNonMediaModel
80 * Default action for SoftButtons: closes window, popUp or clears
85 defaultActionSoftButton: function( element ) {
86 switch( element.groupName ){
89 SDL.AlertPopUp.deactivate( true );
92 case "ScrollableMessage": {
93 SDL.ScrollableMessage.deactivate();
96 case "TurnByTurnView": {
97 SDL.TurnByTurnView.deactivate();
100 case "NonMediaView": {
101 SDL.SDLController.getApplicationModel( element.appId ).clearAppOverLay();
105 SDL.SDLController.getApplicationModel( element.appId ).clearAppOverLay();
113 * Action to show Voice Recognition PopUp
115 activateVRPopUp: function() {
116 SDL.VRPopUp.activateVRPopUp();
120 * Action for SoftButtons that closes popUp or window and opens applications
125 stealFocusSoftButton: function( element ) {
126 switch( element.groupName ){
129 SDL.AlertPopUp.deactivate();
130 SDL.SDLController.getApplicationModel( element.appId ).turnOnSDL();
133 case "ScrollableMessage": {
134 SDL.ScrollableMessage.deactivate();
135 SDL.SDLController.getApplicationModel( element.appId ).turnOnSDL();
143 * Action for SoftButtons that clears popUps timer and it become visible all
144 * the time until user user closes it
148 keepContextSoftButton: function( element ) {
149 switch( element.groupName ){
152 SDL.AlertPopUp.set( 'timer', 0 );
155 case "ScrollableMessage": {
156 SDL.ScrollableMessage.set( 'timer', 0 );
164 * Method to close AlertMeneuverPopUp view
166 closeAlertMeneuverPopUp: function() {
167 SDL.AlertManeuverPopUp.set( 'activate', false );
171 * Method to open Turn List view from TBT
173 * @param {Number} appId AppId of activated sdl application
175 tbtTurnList: function( appId ) {
176 SDL.TBTTurnList.activate( appId );
180 * Method to sent notification with selected state of TBT Client State
184 tbtClientStateSeleced: function( state ) {
185 FFW.UI.onTBTClientState( state, SDL.SDLAppController.model.appId );
189 * Method to sent notification ABORTED for PerformInteractionChoise
191 interactionChoiseCloseResponse: function( result, performInteractionRequestId ) {
192 FFW.UI.interactionResponse( result, performInteractionRequestId );
196 * Method to sent notification for Alert
198 * @param {String} result
199 * @param {Number} alertRequestId
201 alertResponse: function( result, alertRequestId ) {
202 FFW.UI.sendUIResult( result, alertRequestId, 'UI.Alert' );
206 * Method to sent notification for Scrollable Message
208 * @param {String} result
209 * @param {Number} messageRequestId
211 scrollableMessageResponse: function( result, messageRequestId ) {
212 FFW.UI.sendUIResult( result, messageRequestId, 'UI.ScrollableMessage' );
216 * Method to sent notification for Slider
218 * @param {String} result
219 * @param {Number} sliderRequestId
221 sliderResponse: function( result, sliderRequestId ) {
222 FFW.UI.sendUIResult( result, sliderRequestId, 'UI.Slider' );
226 * Method to call performAudioPassThruResponse with Result code parameters
228 * @param {Object} element Button object
230 callPerformAudioPassThruPopUpResponse: function( element ) {
231 this.performAudioPassThruResponse( element.responseResult );
235 * Method close PerformAudioPassThruPopUp and call response from UIRPC back
238 * @param {String} result Result code
240 performAudioPassThruResponse: function( result ) {
241 SDL.SDLModel.set( 'AudioPassThruState', false );
242 FFW.UI.sendUIResult( result, FFW.UI.performAudioPassThruRequestId, "UI.PerformAudioPassThru" );
246 * Method to set language for UI component with parameters sent from SDLCore
249 onLanguageChangeUI: function() {
250 FFW.UI.OnLanguageChange( SDL.SDLModel.hmiUILanguage );
251 }.observes( 'SDL.SDLModel.hmiUILanguage' ),
254 * Method to set language for TTS and VR components with parameters sent
255 * from SDLCore to UIRPC
257 onLanguageChangeTTSVR: function() {
258 FFW.TTS.OnLanguageChange( SDL.SDLModel.hmiTTSVRLanguage );
259 FFW.VR.OnLanguageChange( SDL.SDLModel.hmiTTSVRLanguage );
260 }.observes( 'SDL.SDLModel.hmiTTSVRLanguage' ),
263 * Register application
265 * @param {Object} params
266 * @param {Number} applicationType
268 registerApplication: function( params, applicationType ) {
270 SDL.SDLModel.get( 'registeredApps' ).pushObject( SDL.SDLController.applicationModels[applicationType].create( {
272 appName: params.appName,
273 deviceName: params.deviceName
279 * Unregister application
281 * @param {Number} appId
283 unregisterApplication: function( appId ) {
285 this.getApplicationModel( appId ).onDeleteApplication( appId );
287 this.getApplicationModel( appId ).set( 'active', false );
289 var index = SDL.SDLModel.registeredApps.indexOf( SDL.SDLModel.registeredApps.filterProperty( 'appId', appId )[0] );
291 SDL.SDLModel.registeredApps.replace( index, 1 );
293 this.set( 'model', null );
298 * SDL Driver Distraction ON/OFF switcher
300 selectDriverDistraction: function() {
301 if( SDL.SDLModel.driverDistractionState ){
302 FFW.UI.onDriverDistraction( "DD_ON" );
304 FFW.UI.onDriverDistraction( "DD_OFF" );
306 }.observes( 'SDL.SDLModel.driverDistractionState' ),
309 * SDL Protocol Version 2 ON/OFF switcher
311 selectProtocolVersion: function() {
312 if( SDL.SDLModel.protocolVersion2State ){
313 FFW.BasicCommunication.OnVersionChanged( 2 );
315 FFW.BasicCommunication.OnVersionChanged( 1 );
317 }.observes( 'SDL.SDLModel.protocolVersion2State' ),
320 * Get application model
324 getApplicationModel: function( applicationId ) {
325 return SDL.SDLModel.registeredApps.filterProperty( 'appId', applicationId )[0];
329 * Function returns ChangeDeviceView back to previous state
331 turnChangeDeviceViewBack: function() {
332 SDL.States.goToStates( 'info.apps' );
336 * Enter screen vith list of devices application model
338 onGetDeviceList: function() {
339 SDL.States.goToStates( 'info.devicelist' );
340 FFW.BasicCommunication.getDeviceList();
344 * Send notification if device was choosed
346 * @param element: SDL.Button
348 onDeviceChoosed: function( element ) {
349 FFW.UI.OnDeviceChosen( element.deviceName );
350 this.turnChangeDeviceViewBack();
354 * Method creates list of Application ID's Then call HMI method for display
355 * a list of Applications
359 onGetAppList: function( appList ) {
360 SDL.SDLModel.onGetAppList( appList );
364 * Method call's request to get list of applications
366 findNewApps: function() {
367 FFW.BasicCommunication.getAppList();
371 * Method activates selected registered application
375 onActivateSDLApp: function( element ) {
376 this.getApplicationModel( element.appId ).turnOnSDL();
380 * Method sent custom softButtons pressed and event status to RPC
384 onSoftButtonActionUpCustom: function( element ) {
385 if( element.time > 0 ){
386 FFW.Buttons.buttonEventCustom( "CUSTOM_BUTTON", "BUTTONUP", element.softButtonID );
388 FFW.Buttons.buttonEventCustom( "CUSTOM_BUTTON", "BUTTONUP", element.softButtonID );
389 FFW.Buttons.buttonPressedCustom( "CUSTOM_BUTTON", "SHORT", element.softButtonID );
391 clearTimeout( element.timer );
396 * Method sent custom softButtons pressed and event status to RPC
400 onSoftButtonActionDownCustom: function( element ) {
401 FFW.Buttons.buttonEventCustom( "CUSTOM_BUTTON", "BUTTONDOWN", element.softButtonID );
403 element.timer = setTimeout( function() {
404 FFW.Buttons.buttonPressedCustom( "CUSTOM_BUTTON", "LONG", element.softButtonID );
410 * Method sent softButtons pressed and event status to RPC
415 onSoftButtonActionUp: function( element ) {
416 if( element.time > 0 ){
417 FFW.Buttons.buttonEvent( element.presetName, "BUTTONUP" );
419 FFW.Buttons.buttonEvent( element.presetName, "BUTTONUP" );
420 FFW.Buttons.buttonPressed( element.presetName, "SHORT" );
422 clearTimeout( element.timer );
427 * Method sent softButtons Ok pressed and event status to RPC
431 onSoftButtonOkActionDown: function( name ) {
432 FFW.Buttons.buttonEvent( name, "BUTTONDOWN" );
436 * Method sent softButton OK pressed and event status to RPC
440 onSoftButtonOkActionUp: function( name ) {
441 FFW.Buttons.buttonEvent( name, "BUTTONUP" );
442 FFW.Buttons.buttonPressed( name, "SHORT" );
443 SDL.SDLAppController.model.set( 'isPlaying', !SDL.SDLAppController.model.isPlaying );
447 * Method sent softButtons pressed and event status to RPC
452 onSoftButtonActionDown: function( element ) {
453 FFW.Buttons.buttonEvent( element.presetName, "BUTTONDOWN" );
455 element.timer = setTimeout( function() {
456 FFW.Buttons.buttonPressed( element.presetName, "LONG" );
462 * Send system context
464 onSystemContextChange: function() {
465 FFW.UI.OnSystemContext( this.get( 'sysContext' ) );