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 * Reference implementation of TTS component.
30 * TTS is responsible for playing sound data sent from SDLCore to notify user
31 * about some events happened.
34 FFW.TTS = FFW.RPCObserver.create( {
37 * access to basic RPC functionality
39 client: FFW.RPCClient.create( {
47 this.client.connect( this, 300 );
51 * disconnect from RPC bus
53 disconnect: function() {
54 this.client.disconnect();
58 * Client is registered - we can send request starting from this point of
61 onRPCRegistered: function() {
62 Em.Logger.log( "FFW.TTS.onRPCRegistered" );
67 * Client is unregistered - no more requests
69 onRPCUnregistered: function() {
70 Em.Logger.log( "FFW.TTS.onRPCUnregistered" );
75 * Client disconnected.
77 onRPCDisconnected: function() {
82 * when result is received from RPC component this function is called It is
83 * the propriate place to check results of reuqest execution Please use
84 * previously store reuqestID to determine to which request repsonse belongs
87 onRPCResult: function( response ) {
88 Em.Logger.log( "FFW.TTS.onRPCResult" );
93 * handle RPC erros here
95 onRPCError: function( error ) {
96 Em.Logger.log( "FFW.TTS.onRPCError" );
101 * handle RPC notifications here
103 onRPCNotification: function( notification ) {
104 Em.Logger.log( "FFW.TTS.onRPCNotification" );
109 * handle RPC requests here
111 onRPCRequest: function( request ) {
112 Em.Logger.log( "FFW.TTS.onRPCRequest" );
115 switch( request.method ){
117 SDL.SDLModel.onPrompt( request.params.ttsChunks.splice( 0, 1 ) );
124 "resultCode": "SUCCESS", // type (enum) from SDL
126 "method": "TTS.SpeakResponse"
129 this.client.send( JSONMessage );
133 case "TTS.GetCapabilities": {
145 "resultCode": "SUCCESS", // type (enum) from SDL
147 "method": "TTS.GetCapabilitiesResponse"
150 this.client.send( JSONMessage );
154 case "TTS.GetSupportedLanguages": {
160 "resultCode": "SUCCESS", // type (enum) from SDL
162 "method": "TTS.GetSupportedLanguagesResponse",
163 "languages": SDL.SDLModel.sdlLanguagesList
166 this.client.send( JSONMessage );
170 case "TTS.GetLanguage": {
176 "resultCode": "SUCCESS", // type (enum) from SDL
178 "method": "TTS.GetLanguageResponse",
179 "language": SDL.SDLModel.hmiTTSVRLanguage
182 this.client.send( JSONMessage );
186 case "TTS.ChangeRegistration": {
188 SDL.SDLModel.changeRegistrationTTSVR( request.params.language );
195 "resultCode": "SUCCESS", // type (enum) from SDL
197 "method": "TTS.ChangeRegistrationResponse"
200 this.client.send( JSONMessage );
213 * Notifies if sdl TTS components language was changed
215 OnLanguageChange: function( lang ) {
216 Em.Logger.log( "FFW.TTS.OnLanguageChange" );
221 "method": "TTS.OnLanguageChange",
226 this.client.send( JSONMessage );