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.SDLAppModel
29 * @desc Abstarct model for SDL applications
31 * @filesource app/model/sdl/AppModel.js
35 SDL.SDLAppModel = Em.Object.extend( {
73 * Current language of applications UI component
80 * Current language of applications TTS and applications VR component
84 TTSVRLanguage: 'EN-US',
87 * Array of Soft Buttons
94 * Array of Objects for TBTTurnList
101 * URL to application Icon
105 appIcon: 'images/info/info_leftMenu_apps_ico.png',
108 * Application commands list
115 * Return current menu commands
119 currentCommandsList: function() {
120 return this.get( 'commandsList' ).filterProperty( 'parent', this.get( 'currentSubMenuId' ) );
121 }.property( 'this.commandsList.@each', 'this.currentSubMenuId' ),
124 * Current command submenu identificator
131 * Return current submenu name
135 currentSubMenuLabel: function() {
136 var submenu = this.get( 'commandsList' ).filterProperty( 'menuId', this.get( 'currentSubMenuId' ) );
137 return submenu.length ? submenu[0].name : 'Options';
138 }.property( 'this.currentSubMenuId' ),
141 * Interaction chooses data
145 interactionChoices: {},
148 * Update Soft Buttons will handle on command Show
152 updateSoftButtons: function( buttons ) {
153 // delete existing buttons from array
154 this.softButtons.splice( 0 );
156 // push new buttons to array
157 this.get( 'softButtons' ).pushObjects( buttons );
161 * Add command to list
165 addCommand: function( params ) {
167 this.get( 'commandsList' ).pushObject( {
168 commandId: params.cmdId,
169 name: params.menuParams.menuName,
170 parent: params.menuParams.parentID ? params.menuParams.parentID : 0,
171 position: params.menuParams.position,
172 icon: params.cmdIcon ? params.cmdIcon.value : null
177 * Delete command from list
181 deleteCommand: function( commandId ) {
183 this.get( 'commandsList' ).removeObjects( this.get( 'commandsList' ).filterProperty( 'commandId', commandId ) );
187 * Add submenu to commands list
191 addSubMenu: function( params ) {
193 this.get( 'commandsList' ).pushObject( {
194 menuId: params.menuId,
195 name: params.menuName,
197 position: params.position
202 * Delete submenu and related commands from list
206 deleteSubMenu: function( menuId ) {
208 // don't delete if current submenu active
209 if( this.get( 'currentSubMenuId' ) == menuId ){
211 // SDL.SDLAppController.onSubMenu(0);
215 this.get( 'commandsList' ).removeObjects( this.get( 'commandsList' ).filterProperty( 'menuId', menuId ) );
217 // remove commands from deleted submenu
218 this.get( 'commandsList' ).removeObjects( this.get( 'commandsList' ).filterProperty( 'parent', menuId ) );
224 * SDL UI PreformInteraction response handeler open Perform Interaction
225 * screen and show choices
227 * @param {Object} message
228 * @param {Number} performInteractionRequestId
230 onPreformInteraction: function( message, performInteractionRequestId ) {
232 var i = 0, length = message.interactionChoiceSetIDList.length;
234 SDL.InteractionChoicesView.clean();
236 for( i = 0; i < length; i++ ){
237 var choiceSetId = message.interactionChoiceSetIDList[i];
238 SDL.InteractionChoicesView.preformChoices( this.interactionChoices[choiceSetId], performInteractionRequestId, message.timeout );
240 SDL.VRPopUp.CreateInteractionChoise( this.interactionChoices[choiceSetId], performInteractionRequestId );
243 SDL.InteractionChoicesView.activate( message.initialText );
245 // Show Initial prompt
246 SDL.SDLModel.onPrompt( message.initialPrompt );
250 * SDL UI CreateInteraction response handeler push set of commands to voice
255 onCreateInteraction: function( message ) {
257 this.interactionChoices[message.interactionChoiceSetID] = message.choiceSet;
262 * SDL UI DeleteInteraction response handeler close current interaction set
263 * window (if opened) and delete current set commands from voice recognition
268 onDeleteInteraction: function( message ) {
269 delete this.interactionChoices[message.interactionChoiceSetID];
273 * SDL UI Slider response handeler open Slider window with received
278 onSlider: function( message ) {
280 SDL.SliderView.loadData( message );
282 SDL.SliderView.activate( this.appName );
284 setTimeout( function() {
285 if( SDL.SliderView.active ){
286 SDL.SliderView.deactivate();
288 }, message.params.timeout );