diff options
author | Justin Dickow <jjdickow@gmail.com> | 2014-03-18 13:46:46 -0400 |
---|---|---|
committer | Justin Dickow <jjdickow@gmail.com> | 2014-03-18 13:46:46 -0400 |
commit | ba492fb83c258bc60ca68120ce964a95b41133b5 (patch) | |
tree | af99c087941d65a19831397c1ec5eb34850cfc7f /SDL_Core/src/components/HMI/ffw | |
parent | 8504605b01177da2e55bee6abe4c3f20c82da379 (diff) | |
download | smartdevicelink-ba492fb83c258bc60ca68120ce964a95b41133b5.tar.gz |
initial commit for API 3.0 (replaced all)
Diffstat (limited to 'SDL_Core/src/components/HMI/ffw')
-rw-r--r--[-rwxr-xr-x] | SDL_Core/src/components/HMI/ffw/BasicCommunicationRPC.js | 835 | ||||
-rw-r--r--[-rwxr-xr-x] | SDL_Core/src/components/HMI/ffw/ButtonsRPC.js | 287 | ||||
-rw-r--r--[-rwxr-xr-x] | SDL_Core/src/components/HMI/ffw/Framework.js | 80 | ||||
-rw-r--r-- | SDL_Core/src/components/HMI/ffw/NavigationRPC.js | 319 | ||||
-rw-r--r--[-rwxr-xr-x] | SDL_Core/src/components/HMI/ffw/RPCClient.js | 551 | ||||
-rw-r--r--[-rwxr-xr-x] | SDL_Core/src/components/HMI/ffw/RPCObserver.js | 192 | ||||
-rw-r--r--[-rwxr-xr-x] | SDL_Core/src/components/HMI/ffw/TTSRPC.js | 401 | ||||
-rw-r--r--[-rwxr-xr-x] | SDL_Core/src/components/HMI/ffw/UIRPC.js | 1511 | ||||
-rw-r--r--[-rwxr-xr-x] | SDL_Core/src/components/HMI/ffw/VRRPC.js | 287 | ||||
-rw-r--r-- | SDL_Core/src/components/HMI/ffw/VehicleInfoRPC.js | 405 | ||||
-rw-r--r--[-rwxr-xr-x] | SDL_Core/src/components/HMI/ffw/WebSocket.js | 152 |
11 files changed, 3443 insertions, 1577 deletions
diff --git a/SDL_Core/src/components/HMI/ffw/BasicCommunicationRPC.js b/SDL_Core/src/components/HMI/ffw/BasicCommunicationRPC.js index 96407e113..afc619bfa 100755..100644 --- a/SDL_Core/src/components/HMI/ffw/BasicCommunicationRPC.js +++ b/SDL_Core/src/components/HMI/ffw/BasicCommunicationRPC.js @@ -2,15 +2,14 @@ * Copyright (c) 2013, Ford Motor Company All rights reserved. * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * · Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * · Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * · Neither the name of the Ford Motor Company nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. + * modification, are permitted provided that the following conditions are met: · + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. · Redistributions in binary + * form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided + * with the distribution. · Neither the name of the Ford Motor Company nor the + * names of its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -31,278 +30,566 @@ * mobile apps, geting the list of devices and applications and data transfer. */ -FFW.BasicCommunication = FFW.RPCObserver.create( { - - /** - * access to basic RPC functionality - */ - client: FFW.RPCClient.create( { - componentName: "BasicCommunicationClient" - } ), - - getAppListRequestId: -1, - getDeviceListRequestId: -1, - activateAppRequestId: -1, - onAppRegisteredSubscribeRequestId: -1, - onAppUnregisteredSubscribeRequestId: -1, - onAppRegisteredUnsubscribeRequestId: -1, - onAppUnregisteredUnsubscribeRequestId: -1, - - // const - onAppRegisteredNotification: "BasicCommunication.OnAppRegistered", - onAppUnregisteredNotification: "BasicCommunication.OnAppUnregistered", - onDeviceListUpdatedNotification: "BasicCommunication.OnDeviceListUpdated", - - /** - * init object - */ - init: function() { - }, - - /** - * connect to RPC bus - */ - connect: function() { - - this.client.connect( this, 600 ); - }, - - /** - * disconnect from RPC bus - */ - disconnect: function() { - this.client.disconnect(); - }, - - /** - * Client is registered - we can send request starting from this point of - * time - */ - onRPCRegistered: function() { - Em.Logger.log( "FFW.BasicCommunicationRPC.onRPCRegistered" ); - this._super(); - - // subscribe to notifications - this.onAppRegisteredSubscribeRequestId = this.client.subscribeToNotification( this.onAppRegisteredNotification ); - this.onAppUnregisteredSubscribeRequestId = this.client.subscribeToNotification( this.onAppUnregisteredNotification ); - this.onDeviceListUpdatedNotificationId = this.client.subscribeToNotification( this.onDeviceListUpdatedNotification ); - }, - - /** - * Client is unregistered - no more requests - */ - onRPCUnregistered: function() { - Em.Logger.log( "FFW.BasicCommunicationRPC.onRPCUnregistered" ); - this._super(); - - // unsubscribe from notifications - this.onAppRegusteredUnsubscribeRequestId = this.client.unsubscribeFromNotification( this.onAppRegisteredNotification ); - this.onAppUnregusteredUnsubscribeRequestId = this.client.unsubscribeFromNotification( this.onAppUnregisteredNotification ); - this.onDeviceListUpdatedNotificationId = this.client.unsubscribeFromNotification( this.onDeviceListUpdatedNotification ); - }, - - /** - * Client disconnected. - */ - onRPCDisconnected: function() { - if( SDL.SDLAppController ){ - SDL.SDLAppController.onSDLDisconected(); - } - }, - - /** - * when result is received from RPC component this function is called It is - * the propriate place to check results of reuqest execution Please use - * previously store reuqestID to determine to which request repsonse belongs - * to - */ - onRPCResult: function( response ) { - Em.Logger.log( "FFW.BasicCommunicationRPC.onRPCResult" ); - this._super(); - - if( response.result.method == "BasicCommunication.GetAppListResponse" ){ - if( SDL.States.info.active ){ - SDL.SDLController.onGetAppList( response.result.appList ); +FFW.BasicCommunication = FFW.RPCObserver + .create( { + + /** + * access to basic RPC functionality + */ + client: FFW.RPCClient.create( { + componentName: "BasicCommunication" + }), + + onAppRegisteredSubscribeRequestID: -1, + onAppUnregisteredSubscribeRequestID: -1, + onPlayToneSubscribeRequestID: -1, + onSDLCloseSubscribeRequestID: -1, + + onAppRegisteredUnsubscribeRequestID: -1, + onAppUnregisteredUnsubscribeRequestID: -1, + onPlayToneUnsubscribeRequestID: -1, + onSDLCloseUnsubscribeRequestID: -1, + + // const + onAppRegisteredNotification: "BasicCommunication.OnAppRegistered", + onAppUnregisteredNotification: "BasicCommunication.OnAppUnregistered", + onPlayToneNotification: "BasicCommunication.PlayTone", + onSDLCloseNotification: "BasicCommunication.OnSDLClose", + + /** + * init object + */ + init: function() { + + }, + + /** + * connect to RPC bus + */ + connect: function() { + + this.client.connect(this, 600); // Magic number is unique identifier + // for component + }, + + /** + * disconnect from RPC bus + */ + disconnect: function() { + + this.client.disconnect(); + }, + + /** + * Client is registered - we can send request starting from this point + * of time + */ + onRPCRegistered: function() { + + Em.Logger.log("FFW.BasicCommunicationRPC.onRPCRegistered"); + this._super(); + + // subscribe to notifications + this.onAppRegisteredSubscribeRequestID = this.client + .subscribeToNotification(this.onAppRegisteredNotification); + this.onAppUnregisteredSubscribeRequestID = this.client + .subscribeToNotification(this.onAppUnregisteredNotification); + this.onPlayToneSubscribeRequestID = this.client + .subscribeToNotification(this.onPlayToneNotification); + this.onSDLCloseSubscribeRequestID = this.client + .subscribeToNotification(this.onSDLCloseNotification); + + }, + + /** + * Client is unregistered - no more requests + */ + onRPCUnregistered: function() { + + Em.Logger.log("FFW.BasicCommunicationRPC.onRPCUnregistered"); + this._super(); + + // unsubscribe from notifications + this.onAppRegisteredUnsubscribeRequestID = this.client + .unsubscribeFromNotification(this.onAppRegisteredNotification); + this.onAppUnregisteredUnsubscribeRequestID = this.client + .unsubscribeFromNotification(this.onAppUnregisteredNotification); + this.onPlayToneUnsubscribeRequestID = this.client + .unsubscribeFromNotification(this.onPlayToneUpdatedNotification); + this.onSDLCloseUnsubscribeRequestID = this.client + .unsubscribeFromNotification(this.onSDLCloseNotification); + }, + + /** + * Client disconnected. + */ + onRPCDisconnected: function() { + + if (SDL.SDLAppController) { + SDL.SDLAppController.onSDLDisconected(); } - } - - if( response.result.method == "BasicCommunication.GetDeviceListResponse" ){ - if( SDL.States.info.active ){ - SDL.SDLModel.onGetDeviceList( response.result ); + }, + + /** + * when result is received from RPC component this function is called It + * is the propriate place to check results of reuqest execution Please + * use previously store reuqestID to determine to which request repsonse + * belongs to + */ + onRPCResult: function(response) { + + Em.Logger.log("FFW.BasicCommunicationRPC.onRPCResult"); + this._super(); + }, + + /** + * handle RPC erros here + */ + onRPCError: function(error) { + + Em.Logger.log("FFW.BasicCommunicationRPC.onRPCError"); + this._super(); + }, + + /** + * handle RPC notifications here + */ + onRPCNotification: function(notification) { + + Em.Logger.log("FFW.BasicCommunicationRPC.onRPCNotification"); + this._super(); + + if (notification.method == this.onAppRegisteredNotification) { + SDL.SDLModel.onAppRegistered(notification.params); + this.OnFindApplications(); } - } - - if( response.id == this.activateAppRequestId ){ - // - } - }, - - /** - * handle RPC erros here - */ - onRPCError: function( error ) { - Em.Logger.log( "FFW.BasicCommunicationRPC.onRPCError" ); - this._super(); - }, - - /** - * handle RPC notifications here - */ - onRPCNotification: function( notification ) { - Em.Logger.log( "FFW.BasicCommunicationRPC.onRPCNotification" ); - this._super(); - - if( notification.method == this.onAppRegisteredNotification ){ - SDL.SDLModel.onAppRegistered( notification.params.application ); - this.getAppList(); - } - - if( notification.method == this.onAppUnregisteredNotification ){ - // remove app from list - SDL.SDLModel.onAppUnregistered( notification.params ); - } - if( notification.method == this.onDeviceListUpdatedNotification ){ - SDL.SDLModel.onGetDeviceList( notification.params ); - } - }, - - /** - * handle RPC requests here - */ - onRPCRequest: function( request ) { - Em.Logger.log( "FFW.BasicCommunicationRPC.onRPCRequest" ); - this._super(); - - // nothing to do, it is client - }, - - /** - * Request for list of avaliable applications - */ - getAppList: function() { - this.getAppListRequestId = this.client.generateId(); - - var JSONMessage = { - "jsonrpc": "2.0", - "id": this.getAppListRequestId, - "method": "BasicCommunication.GetAppList", - "params": {} - }; - this.client.send( JSONMessage ); - }, - - /** - * send notification when version of protocol vas changed - * - * @params {Number} - */ - OnVersionChanged: function( version ) { - Em.Logger.log( "FFW.BasicCommunication.OnVersionChanged" ); - - // send repsonse - var JSONMessage = { - "jsonrpc": "2.0", - "method": "BasicCommunication.OnVersionChanged", - "params": { - "versionNumber": version + if (notification.method == this.onAppUnregisteredNotification) { + // remove app from list + SDL.SDLModel.onAppUnregistered(notification.params); } - }; - this.client.send( JSONMessage ); - }, - - /** - * Request for list of avaliable devices - */ - getDeviceList: function() { - this.getDeviceListRequestId = this.client.generateId(); - - var JSONMessage = { - "jsonrpc": "2.0", - "id": this.getDeviceListRequestId, - "method": "BasicCommunication.GetDeviceList", - "params": {} - }; - this.client.send( JSONMessage ); - }, - - /** - * Sending data from HMI for processing in BasicCommunication - * - * @params {Array} - */ - SendData: function( data ) { - Em.Logger.log( "FFW.BasicCommunication.SendData" ); - - if( !data ){ - data = - [ - "Data for sending from HMI to Mobile application." - ]; - } - // send request - var JSONMessage = { - "jsonrpc": "2.0", - "id": this.client.idStart, - "method": "BasicCommunication.SendData", - "params": { - "data": data + if (notification.method == this.onPlayToneNotification) { + SDL.SDLModel.onPlayTone(); } - }; - if( SDL.SDLModel.sendDataExtend ){ - JSONMessage.params["url"] = "http://projects.genivi.org/smartphonelink/"; - JSONMessage.params["timeout"] = 10000; - } - - this.client.send( JSONMessage ); - }, - - /** - * Notification when user returned to application - * - * @params {Number} - */ - ActivateApp: function( appId ) { - Em.Logger.log( "FFW.BasicCommunication.ActivateApp" ); - - // send request - - var JSONMessage = { - "jsonrpc": "2.0", - "id": this.client.idStart, - "method": "BasicCommunication.ActivateApp", - "params": { - "appName": SDL.SDLController.getApplicationModel( appId ).appName, - "appId": appId + if (notification.method == this.onSDLCloseNotification) { + //notification handler method + } + }, + + /** + * handle RPC requests here + */ + onRPCRequest: function(request) { + + Em.Logger.log("FFW.BasicCommunicationRPC.onRPCRequest"); + this._super(); + + if (this.validationCheck(request)) { + + if (request.method == "BasicCommunication.MixingAudioSupported") { + this.MixingAudioSupported(true); + } + if (request.method == "BasicCommunication.AllowAllApps") { + this.AllowAllApps(true); + } + if (request.method == "BasicCommunication.AllowApp") { + this.AllowApp(true); + } + if (request.method == "BasicCommunication.AllowDeviceToConnect") { + this + .AllowDeviceToConnect(request.id, request.method, allow); + } + if (request.method == "BasicCommunication.UpdateAppList") { + if (SDL.States.info.active) { + SDL.SDLController + .onGetAppList(request.params.applications); + } + this.sendBCResult(SDL.SDLModel.resultCode["SUCCESS"], + request.id, + request.method); + } + if (request.method == "BasicCommunication.UpdateDeviceList") { + SDL.SDLModel.onGetDeviceList(request.params); + this.sendBCResult(SDL.SDLModel.resultCode["SUCCESS"], + request.id, + request.method); + } + if (request.method == "BasicCommunication.ActivateApp") { + SDL.SDLController.getApplicationModel(request.params.appID).turnOnSDL(); + this.sendBCResult(SDL.SDLModel.resultCode["SUCCESS"], request.id, request.method); + } } - }; - this.client.send( JSONMessage ); - }, - - /** - * Sent notification that user was turned off the app and the reason why - * - * @params {String} - * @params {String} - * @params {Number} - */ - DeactivateApp: function( appName, reason, appId ) { - Em.Logger.log( "FFW.BasicCommunication.OnAppDeactivated" ); - - // send request - - var JSONMessage = { - "jsonrpc": "2.0", - "method": "BasicCommunication.OnAppDeactivated", - "params": { - "appName": appName, - "appId": appId, - "reason": reason + }, + + /** + * send response from onRPCRequest + * + * @param {Number} + * resultCode + * @param {Number} + * id + * @param {String} + * method + */ + sendBCResult: function(resultCode, id, method) { + + Em.Logger.log("FFW." + method + "Response"); + + if (resultCode === SDL.SDLModel.resultCode["SUCCESS"]) { + + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": id, + "result": { + "code": resultCode, // type (enum) from SDL protocol + "method": method + } + }; + this.client.send(JSONMessage); } - }; - this.client.send( JSONMessage ); - } + }, + + /** + * send response from onRPCRequest + * + * @param {Number} + * id + * @param {String} + * method + * @param {Boolean} + * allow + */ + AllowDeviceToConnect: function(id, method, allow) { + + Em.Logger.log("FFW." + method + "Response"); + + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": id, + "result": { + "code": SDL.SDLModel.resultCode["SUCCESS"], // type (enum) + // from SDL + // protocol + "method": method, + "allow": true + } + }; + this.client.send(JSONMessage); + + }, + + /** + * notification that UI is ready BasicCommunication should be sunscribed + * to this notification + */ + onReady: function() { + + Em.Logger.log("FFW.BasicCommunication.onReady"); + + var JSONMessage = { + "jsonrpc": "2.0", + "method": "BasicCommunication.OnReady" + }; + this.client.send(JSONMessage); + }, + + /** + * Send request if application was activated + * + * @param {number} appID + */ + OnAppActivated: function(appID) { + + Em.Logger.log("FFW.BasicCommunication.OnAppActivated"); + + // send notification + var JSONMessage = { + "jsonrpc": "2.0", + "method": "BasicCommunication.OnAppActivated", + "params": { + "appID": appID + } + }; + this.client.send(JSONMessage); + }, + + /** + * This methos is request to get list of registered apps. + */ + OnFindApplications: function() { + + Em.Logger.log("FFW.BasicCommunication.OnFindApplications"); + + var JSONMessage = { + "jsonrpc": "2.0", + "method": "BasicCommunication.OnFindApplications" + }; + + if (SDL.SDLModel.CurrDeviceInfo.name + || SDL.SDLModel.CurrDeviceInfo.id) { + + JSONMessage.params = { + "deviceInfo": SDL.SDLModel.CurrDeviceInfo + }; + } + + this.client.send(JSONMessage); + }, + + /** + * Request for list of avaliable devices + */ + getDeviceList: function() { + + Em.Logger.log("FFW.BasicCommunication.GetDeviceList"); + + this.getDeviceListRequestID = this.client.generateID(); + + var JSONMessage = { + "id": this.getDeviceListRequestID, + "jsonrpc": "2.0", + "method": "BasicCommunication.GetDeviceList" + }; + this.client.send(JSONMessage); + }, + + /** + * Invoked by UI component when user switches to any functionality which + * is not other mobile application. + * + * @params {String} + * @params {Number} + */ + OnAppDeactivated: function(reason, appID) { + + Em.Logger.log("FFW.BasicCommunication.OnAppDeactivated"); + + // send request + + var JSONMessage = { + "jsonrpc": "2.0", + "method": "BasicCommunication.OnAppDeactivated", + "params": { + "appID": appID, + "reason": reason + } + }; + this.client.send(JSONMessage); + }, + + /** + * Initiated by HMI user. In response optional list of found devices - + * if not provided, not were found. + */ + OnStartDeviceDiscovery: function() { + + Em.Logger.log("FFW.BasicCommunication.OnStartDeviceDiscovery"); + + // send request + + var JSONMessage = { + "jsonrpc": "2.0", + "method": "BasicCommunication.OnStartDeviceDiscovery" + }; + this.client.send(JSONMessage); + }, + + /** + * Used by HMI when User chooses to exit application. + * + * @params {Number} + */ + ExitApplication: function(appID) { + + Em.Logger.log("FFW.BasicCommunication.OnExitApplication"); + + // send request + + var JSONMessage = { + "jsonrpc": "2.0", + "method": "BasicCommunication.OnExitApplication", + "params": { + "appID": appID + } + }; + this.client.send(JSONMessage); + }, + + /** + * Sent by HMI to SDL to close all registered applications. + * + * @params {String} + */ + ExitAllApplications: function(reason) { + + Em.Logger.log("FFW.BasicCommunication.OnExitAllApplications"); + + // send request + + var JSONMessage = { + "jsonrpc": "2.0", + "method": "BasicCommunication.OnExitAllApplications", + "params": { + "reason": reason + } + }; + this.client.send(JSONMessage); + }, + + /** + * Response with params of the last one supports mixing audio (ie + * recording TTS command and playing audio). + * + * @params {Number} + */ + MixingAudioSupported: function(attenuatedSupported) { + + Em.Logger.log("FFW.BasicCommunication.MixingAudioSupportedResponse"); + + // send request + + var JSONMessage = { + "id": this.client.idStart, + "jsonrpc": "2.0", + "result": { + "code": 0, + "attenuatedSupported": attenuatedSupported, + "method": "BasicCommunication.MixingAudioSupported" + } + }; + this.client.send(JSONMessage); + }, + + /** + * Response with Results by user/HMI allowing SDL functionality or + * disallowing access to all mobile apps. + * + * @params {Number} + */ + AllowAllApps: function(allowed) { + + Em.Logger.log("FFW.BasicCommunication.AllowAllAppsResponse"); + + // send request + + var JSONMessage = { + "id": this.client.idStart, + "jsonrpc": "2.0", + "result": { + "code": 0, + "method": "BasicCommunication.AllowAllApps", + "allowed": allowed + } + }; + this.client.send(JSONMessage); + }, + + /** + * Response with result of allowed application + * + * @params {Number} + */ + AllowApp: function(allowed) { + + Em.Logger.log("FFW.BasicCommunication.AllowAppResponse"); + + // send request + + var JSONMessage = { + "id": this.client.idStart, + "jsonrpc": "2.0", + "result": { + "code": 0, + "method": "BasicCommunication.AllowApp", + "allowed": allowed + } + }; + this.client.send(JSONMessage); + }, + + /** + * Notifies if device was choosed + * + * @param {String} + * deviceName + * @param {Number} + * appID + */ + OnDeviceChosen: function(deviceName, appID) { + + Em.Logger.log("FFW.BasicCommunication.OnDeviceChosen"); + + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "method": "BasicCommunication.OnDeviceChosen", + "params": { + "deviceInfo": { + "name": deviceName, + "id": appID + } + } + }; + this.client.send(JSONMessage); + }, + + /** + * Send error response from onRPCRequest + * + * @param {Number} + * resultCode + * @param {Number} + * id + * @param {String} + * method + */ + sendError: function(resultCode, id, method, message) { + + Em.Logger.log("FFW." + method + "Response"); + + if (resultCode != SDL.SDLModel.resultCode["SUCCESS"]) { + + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": id, + "error": { + "code": resultCode, // type (enum) from SDL protocol + "message": message, + "data": { + "method": method + } + } + }; + this.client.send(JSONMessage); + } + }, + + /** + * Initiated by HMI. + */ + OnSystemRequest: function() { + + Em.Logger.log("FFW.BasicCommunication.OnSystemRequest"); + + // send request + + var JSONMessage = { + "jsonrpc": "2.0", + "method": "BasicCommunication.OnStartDeviceDiscovery", + "params":{ + "requestType": "HTTP", + "url": "http://127.0.0.1", + "fileType": "BINARY", + "offset": 1000, + "length": 10000 + } + }; + this.client.send(JSONMessage); + } -} ) + }) diff --git a/SDL_Core/src/components/HMI/ffw/ButtonsRPC.js b/SDL_Core/src/components/HMI/ffw/ButtonsRPC.js index 1b5b8174f..d3134295e 100755..100644 --- a/SDL_Core/src/components/HMI/ffw/ButtonsRPC.js +++ b/SDL_Core/src/components/HMI/ffw/ButtonsRPC.js @@ -2,15 +2,14 @@ * Copyright (c) 2013, Ford Motor Company All rights reserved. * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * · Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * · Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * · Neither the name of the Ford Motor Company nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. + * modification, are permitted provided that the following conditions are met: · + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. · Redistributions in binary + * form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided + * with the distribution. · Neither the name of the Ford Motor Company nor the + * names of its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -38,19 +37,22 @@ FFW.Buttons = FFW.RPCObserver.create( { */ client: FFW.RPCClient.create( { componentName: "Buttons" - } ), + }), /* * connect to RPC bus */ connect: function() { - this.client.connect( this, 200 ); + + this.client.connect(this, 200); // Magic number is unique identifier for + // component }, /* * disconnect from RPC bus */ disconnect: function() { + this.client.disconnect(); }, @@ -59,7 +61,8 @@ FFW.Buttons = FFW.RPCObserver.create( { * time */ onRPCRegistered: function() { - Em.Logger.log( "FFW.Buttons.onRPCRegistered" ); + + Em.Logger.log("FFW.Buttons.onRPCRegistered"); this._super(); }, @@ -67,7 +70,8 @@ FFW.Buttons = FFW.RPCObserver.create( { * Client is unregistered - no more requests */ onRPCUnregistered: function() { - Em.Logger.log( "FFW.Buttons.onRPCUnregistered" ); + + Em.Logger.log("FFW.Buttons.onRPCUnregistered"); this._super(); }, @@ -84,142 +88,163 @@ FFW.Buttons = FFW.RPCObserver.create( { * previously store reuqestID to determine to which request repsonse belongs * to */ - onRPCResult: function( response ) { - Em.Logger.log( "FFW.Buttons.onRPCResult" ); + onRPCResult: function(response) { + + Em.Logger.log("FFW.Buttons.onRPCResult"); this._super(); }, /* * handle RPC erros here */ - onRPCError: function( error ) { - Em.Logger.log( "FFW.Buttons.onRPCError" ); + onRPCError: function(error) { + + Em.Logger.log("FFW.Buttons.onRPCError"); this._super(); }, /* * handle RPC notifications here */ - onRPCNotification: function( notification ) { - Em.Logger.log( "FFW.Buttons.onRPCNotification" ); + onRPCNotification: function(notification) { + + Em.Logger.log("FFW.Buttons.onRPCNotification"); this._super(); }, /* * handle RPC requests here */ - onRPCRequest: function( request ) { - Em.Logger.log( "FFW.Buttons.onRPCRequest" ); + onRPCRequest: function(request) { + + Em.Logger.log("FFW.Buttons.onRPCRequest"); this._super(); - if( request.method == "Buttons.GetCapabilities" ){ + if (request.method == "Buttons.GetCapabilities") { // send repsonse var JSONMessage = { "jsonrpc": "2.0", "id": request.id, "result": { - "capabilities": - [ - { - "name": "PRESET_0", - "shortPressAvailable": true, - "longPressAvailable": true, - "upDownAvailable": true - }, - { - "name": "PRESET_1", - "shortPressAvailable": true, - "longPressAvailable": true, - "upDownAvailable": true - }, - { - "name": "PRESET_2", - "shortPressAvailable": true, - "longPressAvailable": true, - "upDownAvailable": true - }, - { - "name": "PRESET_3", - "shortPressAvailable": true, - "longPressAvailable": true, - "upDownAvailable": true - }, - { - "name": "PRESET_4", - "shortPressAvailable": true, - "longPressAvailable": true, - "upDownAvailable": true - }, - { - "name": "PRESET_5", - "shortPressAvailable": true, - "longPressAvailable": true, - "upDownAvailable": true - }, - { - "name": "PRESET_6", - "shortPressAvailable": true, - "longPressAvailable": true, - "upDownAvailable": true - }, - { - "name": "PRESET_7", - "shortPressAvailable": true, - "longPressAvailable": true, - "upDownAvailable": true - }, - { - "name": "PRESET_8", - "shortPressAvailable": true, - "longPressAvailable": true, - "upDownAvailable": true - }, - { - "name": "PRESET_9", - "shortPressAvailable": true, - "longPressAvailable": true, - "upDownAvailable": true - }, - { - "name": "OK", - "shortPressAvailable": true, - "longPressAvailable": true, - "upDownAvailable": true - }, - { - "name": "SEEKLEFT", - "shortPressAvailable": true, - "longPressAvailable": true, - "upDownAvailable": true - }, - { - "name": "SEEKRIGHT", - "shortPressAvailable": true, - "longPressAvailable": true, - "upDownAvailable": true - }, - { - "name": "TUNEUP", - "shortPressAvailable": true, - "longPressAvailable": true, - "upDownAvailable": true - }, - { - "name": "TUNEDOWN", - "shortPressAvailable": true, - "longPressAvailable": true, - "upDownAvailable": true - } - ], + "capabilities": [ + { + "name": "PRESET_0", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "PRESET_1", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "PRESET_2", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "PRESET_3", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "PRESET_4", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "PRESET_5", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "PRESET_6", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "PRESET_7", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "PRESET_8", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "PRESET_9", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "OK", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "SEEKLEFT", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "SEEKRIGHT", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "TUNEUP", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "TUNEDOWN", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + } + ], "presetBankCapabilities": { "onScreenPresetsAvailable": true }, - "method": "Buttons.GetCapabilitiesResponse", - "resultCode": "SUCCESS" // type (enum) from SDL protocol + "code": 0, + "method": "Buttons.GetCapabilities" + } + }; + this.client.send(JSONMessage); + } + }, + + /** + * Send error response from onRPCRequest + * + * @param {Number} + * resultCode + * @param {Number} + * id + * @param {String} + * method + */ + sendError: function(resultCode, id, method, message) { + + Em.Logger.log("FFW." + method + "Response"); + + if (resultCode) { + + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": id, + "error": { + "code": resultCode, // type (enum) from SDL protocol + "message": message, + "data": { + "method": method + } } }; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); } }, @@ -228,9 +253,9 @@ FFW.Buttons = FFW.RPCObserver.create( { * when the RPC link is up or failed to connect and all the views are * rendered. */ - buttonPressed: function( id, type ) { + buttonPressed: function(id, type) { - Em.Logger.log( "FFW.Buttons.buttonPressed " + type ); + Em.Logger.log("FFW.Buttons.buttonPressed " + type); var JSONMessage = { "jsonrpc": "2.0", @@ -241,7 +266,7 @@ FFW.Buttons = FFW.RPCObserver.create( { } }; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); }, /* @@ -249,9 +274,9 @@ FFW.Buttons = FFW.RPCObserver.create( { * when the RPC link is up or failed to connect and all the views are * rendered. */ - buttonEvent: function( id, type ) { + buttonEvent: function(id, type) { - Em.Logger.log( "FFW.Buttons.buttonEvent " + type ); + Em.Logger.log("FFW.Buttons.OnButtonEvent " + type); var JSONMessage = { "jsonrpc": "2.0", @@ -262,7 +287,7 @@ FFW.Buttons = FFW.RPCObserver.create( { } }; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); }, @@ -271,9 +296,9 @@ FFW.Buttons = FFW.RPCObserver.create( { * when the RPC link is up or failed to connect and all the views are * rendered. */ - buttonPressedCustom: function( name, type, softButtonID ) { + buttonPressedCustom: function(name, type, softButtonID) { - // Em.Logger.log("FFW.Buttons.buttonPressedCustom " + type); + Em.Logger.log("FFW.Buttons.OnButtonPress " + type); var JSONMessage = { "jsonrpc": "2.0", @@ -285,7 +310,7 @@ FFW.Buttons = FFW.RPCObserver.create( { } }; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); }, /* @@ -293,9 +318,9 @@ FFW.Buttons = FFW.RPCObserver.create( { * when the RPC link is up or failed to connect and all the views are * rendered. */ - buttonEventCustom: function( name, type, softButtonID ) { + buttonEventCustom: function(name, type, softButtonID) { - // Em.Logger.log("FFW.Buttons.buttonEventCustom " + type); + Em.Logger.log("FFW.Buttons.OnButtonEvent " + type); var JSONMessage = { "jsonrpc": "2.0", @@ -307,7 +332,7 @@ FFW.Buttons = FFW.RPCObserver.create( { } }; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); } -} ) +}) diff --git a/SDL_Core/src/components/HMI/ffw/Framework.js b/SDL_Core/src/components/HMI/ffw/Framework.js index c73e47f94..4ab772528 100755..100644 --- a/SDL_Core/src/components/HMI/ffw/Framework.js +++ b/SDL_Core/src/components/HMI/ffw/Framework.js @@ -1,40 +1,40 @@ -/* - * Copyright (c) 2013, Ford Motor Company All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * · Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * · Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * · Neither the name of the Ford Motor Company nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/** - * @name FFW - * @desc Setup framework namespace and settings - * @category Framework - * @filesource app/Framework.js - * @version 1.0 - */ - -FFW = Em.Object.create( { - - init: function() { - Em.Logger.log( 'FFW: Framework init' ); - } -} );
\ No newline at end of file +/*
+ * Copyright (c) 2013, Ford Motor Company All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met: ·
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. · Redistributions in binary
+ * form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided
+ * with the distribution. · Neither the name of the Ford Motor Company nor the
+ * names of its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+/**
+ * @name FFW
+ * @desc Setup framework namespace and settings
+ * @category Framework
+ * @filesource app/Framework.js
+ * @version 1.0
+ */
+
+FFW = Em.Object.create( {
+
+ init: function() {
+
+ Em.Logger.log('FFW: Framework init');
+ }
+});
\ No newline at end of file diff --git a/SDL_Core/src/components/HMI/ffw/NavigationRPC.js b/SDL_Core/src/components/HMI/ffw/NavigationRPC.js new file mode 100644 index 000000000..b08a19adc --- /dev/null +++ b/SDL_Core/src/components/HMI/ffw/NavigationRPC.js @@ -0,0 +1,319 @@ +/* + * Copyright (c) 2013, Ford Motor Company All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are met: · + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. · Redistributions in binary + * form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided + * with the distribution. · Neither the name of the Ford Motor Company nor the + * names of its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE + * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS + * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN + * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) + * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ +/* + * Reference implementation of Navigation component. + * + * Interface to get or set some essential information sent from SDLCore. + * Navigation is responsible for the navigationApp functionality provided by the + * application: display graphics and multimedia components, is responsible for + * the transfer of managed manipulations, generated by the user to the server. + * + */ + +FFW.Navigation = FFW.RPCObserver.create( { + + /** + * If true then Navigation is present and ready to communicate with SDL. + * + * @type {Boolean} + */ + isReady: true, + + /** + * access to basic RPC functionality + */ + client: FFW.RPCClient.create( { + componentName: "Navigation" + }), + + // temp var for debug + appID: 1, + + /** + * connect to RPC bus + */ + connect: function() { + + this.client.connect(this, 800); // Magic number is unique identifier for + // component + }, + + /** + * disconnect from RPC bus + */ + disconnect: function() { + + this.client.disconnect(); + }, + + /** + * Client is registered - we can send request starting from this point of + * time + */ + onRPCRegistered: function() { + + Em.Logger.log("FFW.Navigation.onRPCRegistered"); + this._super(); + + // subscribe to notifications + }, + + /** + * Client is unregistered - no more requests + */ + onRPCUnregistered: function() { + + Em.Logger.log("FFW.Navigation.onRPCUnregistered"); + this._super(); + + // unsubscribe from notifications + }, + + /** + * Client disconnected. + */ + onRPCDisconnected: function() { + + }, + + /** + * when result is received from RPC component this function is called It is + * the propriate place to check results of request execution Please use + * previously store reuqestID to determine to which request repsonse belongs + * to + */ + onRPCResult: function(response) { + + Em.Logger.log("FFW.Navigation.onRPCResult"); + this._super(); + }, + + /** + * handle RPC erros here + */ + onRPCError: function(error) { + + Em.Logger.log("FFW.Navigation.onRPCError"); + this._super(); + }, + + /** + * handle RPC notifications here + */ + onRPCNotification: function(notification) { + + Em.Logger.log("FFW.Navigation.onRPCNotification"); + this._super(); + + if (notification.method == this.onStopStreamNotification) { + SDL.SDLModel.onStopStream(notification.params.appID); + } + }, + + /** + * handle RPC requests here + */ + onRPCRequest: function(request) { + + Em.Logger.log("FFW.Navigation.onRPCRequest"); + if (this.validationCheck(request)) { + + var resultCode = null; + + switch (request.method) { + case "Navigation.IsReady": { + + Em.Logger.log("FFW." + request.method + "Response"); + + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": request.id, + "result": { + "available": this.get('isReady'), + "code": SDL.SDLModel.resultCode["SUCCESS"], + "method": "Navigation.IsReady" + } + }; + + this.client.send(JSONMessage); + + break; + } + case "Navigation.AlertManeuver": { + + this.sendNavigationResult(SDL.SDLModel.resultCode["SUCCESS"], + request.id, + request.method); + + break; + } + case "Navigation.ShowConstantTBT": { + + SDL.SDLModel.tbtActivate(request.params); + this.sendNavigationResult(SDL.SDLModel.resultCode["SUCCESS"], + request.id, + request.method); + + break; + } + case "Navigation.UpdateTurnList": { + + SDL.SDLModel.tbtTurnListUpdate(request.params); + this.sendNavigationResult(SDL.SDLModel.resultCode["SUCCESS"], + request.id, + request.method); + + break; + } + case "Navigation.StartAudioStream": { + + SDL.SDLModel.startAudioStream(request.params); + + this.sendNavigationResult(SDL.SDLModel.resultCode["SUCCESS"], + request.id, + request.method); + + break; + } + case "Navigation.StopAudioStream": { + + SDL.SDLModel.stoptAudioStream(request.params.appID); + + this.sendNavigationResult(SDL.SDLModel.resultCode["SUCCESS"], + request.id, + request.method); + + break; + } + case "Navigation.StartStream": { + + SDL.SDLModel.startStream(request.params); + + this.sendNavigationResult(SDL.SDLModel.resultCode["SUCCESS"], + request.id, + request.method); + + break; + } + case "Navigation.StopStream": { + + SDL.SDLModel.stopStream(request.params.appID); + + this.sendNavigationResult(SDL.SDLModel.resultCode["SUCCESS"], + request.id, + request.method); + + break; + } + } + } + }, + + /** + * Send error response from onRPCRequest + * + * @param {Number} + * resultCode + * @param {Number} + * id + * @param {String} + * method + */ + sendError: function(resultCode, id, method, message) { + + Em.Logger.log("FFW." + method + "Response"); + + if (resultCode != SDL.SDLModel.resultCode["SUCCESS"]) { + + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": id, + "error": { + "code": resultCode, // type (enum) from SDL protocol + "message": message, + "data": { + "method": method + } + } + }; + this.client.send(JSONMessage); + } + }, + + /** + * send response from onRPCRequest + * + * @param {Number} + * resultCode + * @param {Number} + * id + * @param {String} + * method + */ + sendNavigationResult: function(resultCode, id, method) { + + Em.Logger.log("FFW.UI." + method + "Response"); + + if (resultCode === SDL.SDLModel.resultCode["SUCCESS"]) { + + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": id, + "result": { + "code": resultCode, // type (enum) from SDL protocol + "method": method + } + }; + this.client.send(JSONMessage); + } + }, + + /** + * Notifies if TBTClientState was activated + * + * @param {String} + * state + * @param {Number} + * appID + */ + onTBTClientState: function(state, appID) { + + Em.Logger.log("FFW.Navigation.OnTBTClientState"); + + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "method": "Navigation.OnTBTClientState", + "params": { + "state": state + } + }; + this.client.send(JSONMessage); + } +})
\ No newline at end of file diff --git a/SDL_Core/src/components/HMI/ffw/RPCClient.js b/SDL_Core/src/components/HMI/ffw/RPCClient.js index 0a7fe065a..744bbbc53 100755..100644 --- a/SDL_Core/src/components/HMI/ffw/RPCClient.js +++ b/SDL_Core/src/components/HMI/ffw/RPCClient.js @@ -1,261 +1,290 @@ -/* - * Copyright (c) 2013, Ford Motor Company All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * · Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * · Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * · Neither the name of the Ford Motor Company nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * Base class for RPC client - * - * Class provides access to basic functionality of RPC components Message Broker - * as: registerComponent unregisterComponent subscription to notifications logic - * to calculate request id - */ - -FFW.RPCClient = Em.Object.extend( { - - /* - * transport layer for messages exchange - */ - socket: null, // instance of websocket - - /* - * url for message broker - */ - url: "ws://localhost:8087", - - /* - * Component name in RPC system It is unique. - */ - componentName: null, - - /* - * observer of RPC states - */ - observer: null, - - /* - * these variables are used to have unique request ids for different - * components in RPC bus idStart is received as a response for - * registerRPCComponent messages. space for ids for specific RPC component - * is allocated by message broker - */ - idStart: -1, - idRange: 1000, - requestId: -1, - - registerRequestId: -1, - unregisterRequestId: -1, - - /* - * Open WebSocket and initialize handlers - */ - connect: function( observer, startId ) { - this.observer = observer; - this.idStart = startId; - - this.socket = new WebSocket( this.url, 'sample' ); - - var self = this; - - this.socket.onopen = function( evt ) { - self.onWSOpen( evt ) - }; - this.socket.onclose = function( evt ) { - self.onWSClose( evt ) - }; - this.socket.onmessage = function( evt ) { - self.onWSMessage( evt ) - }; - this.socket.onerror = function( evt ) { - self.onWSError( evt ) - }; - - }, - - /* - * Close WebSocket connection Please make sure that component was - * unregistered in advance - */ - disconnect: function() { - this.unregisterRPCComponent(); - }, - - /* - * WebSocket connection is ready Now RPC component can be registered in - * message broker - */ - onWSOpen: function( evt ) { - Em.Logger.log( "RPCCLient.onWSOpen" ); - - this.registerRPCComponent(); - }, - - /* - * when result is received from RPC component this function is called It is - * the propriate place to check results of reuqest execution Please use - * previously store reuqestID to determine to which request repsonse belongs - * to - */ - onWSMessage: function( evt ) { - Em.Logger.log( "Message received: " + evt.data ); - - var jsonObj = JSON.parse( evt.data ); - - // handle component registration - if( jsonObj.id == this.registerRequestId ){ - if( jsonObj.error == null ){ - this.requestId = this.idStart = jsonObj.result; - this.observer.onRPCRegistered(); - } - // handle component unregistration - }else if( jsonObj.id == this.unregisterRequestId ){ - if( jsonObj.error == null ){ - this.socket.close(); - this.observer.onRPCUnregistered(); - } - // handle result, error, notification, requests - }else{ - if( jsonObj.id == null ){ - this.observer.onRPCNotification( jsonObj ); - }else{ - if( jsonObj.result != null ) - this.observer.onRPCResult( jsonObj ); - else if( jsonObj.error != null ) - this.observer.onRPCError( jsonObj ); - else - this.observer.onRPCRequest( jsonObj ); - } - } - }, - - /* - * WebSocket connection is closed Please make sure that RPCComponent was - * dunregistered in advance - */ - onWSClose: function( evt ) { - Em.Logger.log( "RPCClient: Connection is closed" ); - this.observer.onRPCDisconnected(); - }, - - /* - * WebSocket connection errors handling - */ - onWSError: function( evt ) { - // Em.Logger.log("ERROR: " + evt.data); - Em.Logger.log( "ERROR: " ); - }, - - /* - * register component is RPC bus - */ - registerRPCComponent: function() { - this.registerRequestId = this.idStart; - - var JSONMessage = { - "jsonrpc": "2.0", - "id": this.registerRequestId, - "method": "MB.registerComponent", - "params": { - "componentName": this.componentName - } - }; - this.send( JSONMessage ); - }, - - /* - * unregister component is RPC bus - */ - unregisterRPCComponent: function() { - this.unregisterRequestId = this.generateId(); - - var JSONMessage = { - "jsonrpc": "2.0", - "id": this.unregisterRequestId, - "method": "MB.unregisterComponent", - "params": { - "componentName": this.componentName - } - }; - this.send( JSONMessage ); - }, - - /* - * Subscribes to notification. Returns the request's id. - */ - subscribeToNotification: function( notification ) { - var msgId = this.generateId(); - var JSONMessage = { - "jsonrpc": "2.0", - "id": msgId, - "method": "MB.subscribeTo", - "params": { - "propertyName": notification - } - }; - this.send( JSONMessage ); - return msgId; - }, - - /* - * Unsubscribes from notification. Returns the request's id. - */ - unsubscribeFromNotification: function( notification ) { - var msgId = this.client.generateId(); - var JSONMessage = { - "jsonrpc": "2.0", - "id": msgId, - "method": "MB.unsubscribeFrom", - "params": { - "propertyName": notification - } - }; - this.send( JSONMessage ); - return msgId; - }, - - /* - * stringify object and send via socket connection - */ - send: function( obj ) { - if( this.socket.readyState == this.socket.OPEN ){ - var strJson = JSON.stringify( obj ); - Em.Logger.log( strJson ); - this.socket.send( strJson ); - }else{ - Em.Logger.error( "RPCClient: Can't send message since socket is not ready" ); - } - }, - - /* - * Generate id for new request to RPC component Function has to be used as - * private - */ - generateId: function() { - this.requestId++; - if( this.requestId >= this.idStart + this.idRange ) - this.requestId = this.idStart; - return this.requestId; - } - -} )
\ No newline at end of file +/*
+ * Copyright (c) 2013, Ford Motor Company All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met: ·
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. · Redistributions in binary
+ * form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided
+ * with the distribution. · Neither the name of the Ford Motor Company nor the
+ * names of its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * Base class for RPC client
+ *
+ * Class provides access to basic functionality of RPC components Message Broker
+ * as: registerComponent unregisterComponent subscription to notifications logic
+ * to calculate request id
+ */
+
+FFW.RPCClient = Em.Object
+ .extend( {
+
+ /*
+ * transport layer for messages exchange
+ */
+ socket: null, // instance of websocket
+
+ /*
+ * url for message broker
+ */
+ url: "ws://localhost:8087",
+// url: FLAGS.WEBSOCKET_URL,
+
+ /*
+ * Component name in RPC system It is unique.
+ */
+ componentName: null,
+
+ /*
+ * observer of RPC states
+ */
+ observer: null,
+
+ /*
+ * these variables are used to have unique request ids for different
+ * components in RPC bus idStart is received as a response for
+ * registerRPCComponent messages. space for ids for specific RPC
+ * component is allocated by message broker
+ */
+ idStart: -1,
+ idRange: 1000,
+ requestId: -1,
+
+ registerRequestId: -1,
+ unregisterRequestId: -1,
+
+ /*
+ * Open WebSocket and initialize handlers
+ */
+ connect: function(observer, startId) {
+
+ this.observer = observer;
+ this.idStart = startId;
+
+ this.socket = new WebSocket(this.url);
+
+ var self = this;
+
+ this.socket.onopen = function(evt) {
+
+ self.onWSOpen(evt)
+ };
+ this.socket.onclose = function(evt) {
+
+ self.onWSClose(evt)
+ };
+ this.socket.onmessage = function(evt) {
+
+ self.onWSMessage(evt)
+ };
+ this.socket.onerror = function(evt) {
+
+ self.onWSError(evt)
+ };
+
+ },
+
+ /*
+ * Close WebSocket connection Please make sure that component was
+ * unregistered in advance
+ */
+ disconnect: function() {
+
+ this.unregisterRPCComponent();
+ },
+
+ /*
+ * WebSocket connection is ready Now RPC component can be registered in
+ * message broker
+ */
+ onWSOpen: function(evt) {
+
+ Em.Logger.log("RPCCLient.onWSOpen");
+
+ this.registerRPCComponent();
+ },
+
+ /*
+ * when result is received from RPC component this function is called It
+ * is the propriate place to check results of reuqest execution Please
+ * use previously store reuqestID to determine to which request repsonse
+ * belongs to
+ */
+ onWSMessage: function(evt) {
+
+ Em.Logger.log("Message received: " + evt.data);
+
+ var jsonObj = JSON.parse(evt.data);
+
+ // handle component registration
+ if (jsonObj.id == this.registerRequestId && jsonObj.method == null && typeof jsonObj.result == 'number') {
+ if (jsonObj.error == null) {
+ this.requestId = this.idStart = jsonObj.result;
+ this.observer.onRPCRegistered();
+ }
+ // handle component unregistration
+ } else if (jsonObj.id == this.unregisterRequestId) {
+ if (jsonObj.error == null) {
+ this.socket.close();
+ this.observer.onRPCUnregistered();
+ }
+ // handle result, error, notification, requests
+ } else {
+ if (jsonObj.id == null) {
+ this.observer.onRPCNotification(jsonObj);
+ } else {
+ if (jsonObj.result != null)
+ this.observer.onRPCResult(jsonObj);
+ else if (jsonObj.error != null)
+ this.observer.onRPCError(jsonObj);
+ else
+ this.observer.onRPCRequest(jsonObj);
+ }
+ }
+ },
+
+ /*
+ * WebSocket connection is closed Please make sure that RPCComponent was
+ * dunregistered in advance
+ */
+ onWSClose: function(evt) {
+
+ Em.Logger.log("RPCClient: Connection is closed");
+
+ SDL.SDLController.unregisterComponentStatus(this.observer.client.componentName);
+
+ var self = this;
+ setTimeout(function(){
+ self.connect(self.observer, self.idStart);
+ }, 5000);
+ this.observer.onRPCDisconnected();
+ },
+
+ /*
+ * WebSocket connection errors handling
+ */
+ onWSError: function(evt) {
+
+ // Em.Logger.log("ERROR: " + evt.data);
+ Em.Logger.log("ERROR: ");
+ },
+
+ /*
+ * register component is RPC bus
+ */
+ registerRPCComponent: function() {
+
+ this.registerRequestId = this.idStart;
+
+ var JSONMessage = {
+ "jsonrpc": "2.0",
+ "id": this.registerRequestId,
+ "method": "MB.registerComponent",
+ "params": {
+ "componentName": this.componentName
+ }
+ };
+ this.send(JSONMessage);
+ },
+
+ /*
+ * unregister component is RPC bus
+ */
+ unregisterRPCComponent: function() {
+
+ this.unregisterRequestId = this.generateId();
+
+ var JSONMessage = {
+ "jsonrpc": "2.0",
+ "id": this.unregisterRequestId,
+ "method": "MB.unregisterComponent",
+ "params": {
+ "componentName": this.componentName
+ }
+ };
+ this.send(JSONMessage);
+ },
+
+ /*
+ * Subscribes to notification. Returns the request's id.
+ */
+ subscribeToNotification: function(notification) {
+
+ var msgId = this.generateId();
+ var JSONMessage = {
+ "jsonrpc": "2.0",
+ "id": msgId,
+ "method": "MB.subscribeTo",
+ "params": {
+ "propertyName": notification
+ }
+ };
+ this.send(JSONMessage);
+ return msgId;
+ },
+
+ /*
+ * Unsubscribes from notification. Returns the request's id.
+ */
+ unsubscribeFromNotification: function(notification) {
+
+ var msgId = this.client.generateId();
+ var JSONMessage = {
+ "jsonrpc": "2.0",
+ "id": msgId,
+ "method": "MB.unsubscribeFrom",
+ "params": {
+ "propertyName": notification
+ }
+ };
+ this.send(JSONMessage);
+ return msgId;
+ },
+
+ /*
+ * stringify object and send via socket connection
+ */
+ send: function(obj) {
+
+ if (this.socket.readyState == this.socket.OPEN) {
+ var strJson = JSON.stringify(obj);
+ Em.Logger.log(strJson);
+
+ var logTime = new Date();
+ console.log(logTime.getHours() + ":" + logTime.getMinutes() + ":" + logTime.getSeconds() + ":" + logTime.getMilliseconds());
+
+ this.socket.send(strJson);
+ } else {
+ Em.Logger
+ .error("RPCClient: Can't send message since socket is not ready");
+ }
+ },
+
+ /*
+ * Generate id for new request to RPC component Function has to be used
+ * as private
+ */
+ generateId: function() {
+
+ this.requestId++;
+ if (this.requestId >= this.idStart + this.idRange)
+ this.requestId = this.idStart;
+ return this.requestId;
+ }
+
+ })
diff --git a/SDL_Core/src/components/HMI/ffw/RPCObserver.js b/SDL_Core/src/components/HMI/ffw/RPCObserver.js index 42b027170..9fd422d78 100755..100644 --- a/SDL_Core/src/components/HMI/ffw/RPCObserver.js +++ b/SDL_Core/src/components/HMI/ffw/RPCObserver.js @@ -1,76 +1,116 @@ -/* - * Copyright (c) 2013, Ford Motor Company All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * · Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * · Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * · Neither the name of the Ford Motor Company nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/** - * @desc Observer of RPCClient - * - */ - -FFW.RPCObserver = Em.Object.extend( { - - onRPCRegistered: function() { - // request necessary parameters from Backend - Em.Logger.log( "FFW.RPCObserver.Registered" ); - }, - - onRPCUnregistred: function() { - Em.Logger.log( "FFW.RPCObserver.onUnregistered" ); - }, - - onRPCDisconnected: function() { - Em.Logger.log( "FFW.RPCObserver.onRPCDisconnected" ); - }, - - /* - * when result is received from RPC component this function is called It is - * the propriate place to check results of reuqest execution Please use - * previously store reuqestID to determine to which request repsonse belongs - * to - */ - onRPCResult: function( result ) { - - // parse JSON string and set necessary properties - }, - - /* - */ - onRPCError: function( error ) { - - // parse JSON string and set necessary properties - }, - - /* - */ - onRPCNotification: function( notification ) { - - // parse JSON string and set necessary properties - }, - - onRPCRequest: function( request ) { - - // parse JSON string and send back necessary data - } -} )
\ No newline at end of file +/*
+ * Copyright (c) 2013, Ford Motor Company All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met: ·
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. · Redistributions in binary
+ * form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided
+ * with the distribution. · Neither the name of the Ford Motor Company nor the
+ * names of its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+/**
+ * @desc Observer of RPCClient
+ */
+
+FFW.RPCObserver = Em.Object
+ .extend( {
+
+ onRPCRegistered: function() {
+
+ // request necessary parameters from Backend
+ SDL.SDLController.registeredComponentStatus(this.client.componentName);
+ },
+
+ onRPCUnregistered: function() {
+
+ Em.Logger.log("FFW.RPCObserver.onUnregistered");
+ },
+
+ onRPCDisconnected: function() {
+
+ Em.Logger.log("FFW.RPCObserver.onRPCDisconnected");
+ },
+
+ /*
+ * when result is received from RPC component this function is called It
+ * is the propriate place to check results of reuqest execution Please
+ * use previously store reuqestID to determine to which request repsonse
+ * belongs to
+ */
+ onRPCResult: function(result) {
+
+ // parse JSON string and set necessary properties
+ },
+
+ /*
+ */
+ onRPCError: function(error) {
+
+ // parse JSON string and set necessary properties
+ },
+
+ /*
+ */
+ onRPCNotification: function(notification) {
+
+ // parse JSON string and set necessary properties
+ },
+
+ onRPCRequest: function(request) {
+
+ // parse JSON string and send back necessary data
+ },
+
+ validationCheck: function(request) {
+
+ if (request && request.method) {
+ var parsedMethod = request.method.split(/[.]/), validateFunc, result;
+
+ //if (request.params && "appID" in request.params && SDL.SDLModel.registeredApps.filterProperty('appID', request.params.appID).length > 0) {
+ if (request.params && request.params.appID >= 0 && !SDL.SDLModel.registeredApps.filterProperty('appID', request.params.appID)) {
+ Em.Logger.error('No application registered with current appID!');
+ return false;
+ }
+
+ if (SDL.RPCController[parsedMethod[0]][parsedMethod[1]]) {
+ validateFunc = SDL.RPCController[parsedMethod[0]][parsedMethod[1]];
+ result = validateFunc(request.params);
+
+ if (result.resultCode != SDL.SDLModel.resultCode["SUCCESS"]) {
+ this.sendError(result.resultCode,
+ request.id,
+ request.method,
+ result.resultMessage);
+ return false;
+ } else {
+ return true;
+ }
+ } else {
+ this
+ .sendError(SDL.SDLModel.resultCode["UNSUPPORTED_REQUEST"],
+ request.id,
+ request.method,
+ 'Unsupported incoming request! ' + parsedMethod[0]
+ + '.' + parsedMethod[1]);
+ Em.Logger.error('No method "' + parsedMethod[0] + '.'
+ + parsedMethod[1] + '"');
+ return false;
+ }
+ }
+ }
+ });
\ No newline at end of file diff --git a/SDL_Core/src/components/HMI/ffw/TTSRPC.js b/SDL_Core/src/components/HMI/ffw/TTSRPC.js index 85a1bea34..fe205e555 100755..100644 --- a/SDL_Core/src/components/HMI/ffw/TTSRPC.js +++ b/SDL_Core/src/components/HMI/ffw/TTSRPC.js @@ -2,15 +2,14 @@ * Copyright (c) 2013, Ford Motor Company All rights reserved. * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * · Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * · Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * · Neither the name of the Ford Motor Company nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. + * modification, are permitted provided that the following conditions are met: · + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. · Redistributions in binary + * form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided + * with the distribution. · Neither the name of the Ford Motor Company nor the + * names of its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -33,24 +32,48 @@ FFW.TTS = FFW.RPCObserver.create( { + /** + * If true then TTS is present and ready to communicate with SDL. + * + * @type {Boolean} + */ + isReady: true, + + /** + * Request id of current running Speak request + * + * @type {Boolean} + */ + requestId: null, + + /** + * Flag to determine if Speak request was aborted + * + * @type {Boolean} + */ + aborted: false, + /* * access to basic RPC functionality */ client: FFW.RPCClient.create( { componentName: "TTS" - } ), + }), /* * connect to RPC bus */ connect: function() { - this.client.connect( this, 300 ); + + this.client.connect(this, 300); // Magic number is unique identifier for + // component }, /* * disconnect from RPC bus */ disconnect: function() { + this.client.disconnect(); }, @@ -59,7 +82,8 @@ FFW.TTS = FFW.RPCObserver.create( { * time */ onRPCRegistered: function() { - Em.Logger.log( "FFW.TTS.onRPCRegistered" ); + + Em.Logger.log("FFW.TTS.onRPCRegistered"); this._super(); }, @@ -67,7 +91,8 @@ FFW.TTS = FFW.RPCObserver.create( { * Client is unregistered - no more requests */ onRPCUnregistered: function() { - Em.Logger.log( "FFW.TTS.onRPCUnregistered" ); + + Em.Logger.log("FFW.TTS.onRPCUnregistered"); this._super(); }, @@ -84,136 +109,262 @@ FFW.TTS = FFW.RPCObserver.create( { * previously store reuqestID to determine to which request repsonse belongs * to */ - onRPCResult: function( response ) { - Em.Logger.log( "FFW.TTS.onRPCResult" ); + onRPCResult: function(response) { + + Em.Logger.log("FFW.TTS.onRPCResult"); this._super(); }, /* * handle RPC erros here */ - onRPCError: function( error ) { - Em.Logger.log( "FFW.TTS.onRPCError" ); + onRPCError: function(error) { + + Em.Logger.log("FFW.TTS.onRPCError"); this._super(); }, /* * handle RPC notifications here */ - onRPCNotification: function( notification ) { - Em.Logger.log( "FFW.TTS.onRPCNotification" ); + onRPCNotification: function(notification) { + + Em.Logger.log("FFW.TTS.onRPCNotification"); this._super(); }, /* * handle RPC requests here */ - onRPCRequest: function( request ) { - Em.Logger.log( "FFW.TTS.onRPCRequest" ); + onRPCRequest: function(request) { + + Em.Logger.log("FFW.TTS.onRPCRequest"); this._super(); - switch( request.method ){ - case "TTS.Speak": { - SDL.SDLModel.onPrompt( request.params.ttsChunks.splice( 0, 1 ) ); - - // send repsonse - var JSONMessage = { - "jsonrpc": "2.0", - "id": request.id, - "result": { - "resultCode": "SUCCESS", // type (enum) from SDL - // protocol - "method": "TTS.SpeakResponse" - } - }; - this.client.send( JSONMessage ); + switch (request.method) { + case "TTS.Speak": { - break; + if (SDL.TTSPopUp.active) { + FFW.TTS.sendError(SDL.SDLModel.resultCode["REJECTED"], request.id, "TTS.Speak", "TTS in progress. Rejected."); + } else { + this.requestId = request.id; + SDL.SDLModel.onPrompt(request.params.ttsChunks); } - case "TTS.GetCapabilities": { - - // send repsonse - var JSONMessage = { - "jsonrpc": "2.0", - "id": request.id, - "result": { - "capabilities": - [ - "TEXT" - ], - - "resultCode": "SUCCESS", // type (enum) from SDL - // protocol - "method": "TTS.GetCapabilitiesResponse" - } - }; - this.client.send( JSONMessage ); - break; - } - case "TTS.GetSupportedLanguages": { - - var JSONMessage = { - "jsonrpc": "2.0", - "id": request.id, - "result": { - "resultCode": "SUCCESS", // type (enum) from SDL - // protocol - "method": "TTS.GetSupportedLanguagesResponse", - "languages": SDL.SDLModel.sdlLanguagesList - } - }; - this.client.send( JSONMessage ); + break; + } + case "TTS.SetGlobalProperties": { - break; - } - case "TTS.GetLanguage": { - - var JSONMessage = { - "jsonrpc": "2.0", - "id": request.id, - "result": { - "resultCode": "SUCCESS", // type (enum) from SDL - // protocol - "method": "TTS.GetLanguageResponse", - "language": SDL.SDLModel.hmiTTSVRLanguage - } - }; - this.client.send( JSONMessage ); + SDL.SDLModel.setProperties(request.params); - break; - } - case "TTS.ChangeRegistration": { - - SDL.SDLModel.changeRegistrationTTSVR( request.params.language ); - - // send repsonse - var JSONMessage = { - "jsonrpc": "2.0", - "id": request.id, - "result": { - "resultCode": "SUCCESS", // type (enum) from SDL - // protocol - "method": "TTS.ChangeRegistrationResponse" + this.sendTTSResult(SDL.SDLModel.resultCode["SUCCESS"], + request.id, + request.method); + + break; + } + case "TTS.StopSpeaking": { + + SDL.SDLModel.TTSStopSpeaking(); + + this.sendTTSResult(SDL.SDLModel.resultCode["SUCCESS"], + request.id, + request.method); + + break; + } + case "TTS.GetCapabilities": { + + Em.Logger.log("FFW." + request.method + "Response"); + + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": request.id, + "result": { + "speechCapabilities": [ + "TEXT", + "PRE_RECORDED" + ], + "prerecordedSpeechCapabilities": [ + "HELP_JINGLE", + "INITIAL_JINGLE", + "LISTEN_JINGLE", + "POSITIVE_JINGLE", + "NEGATIVE_JINGLE" + ], + "code": SDL.SDLModel.resultCode["SUCCESS"], // type (enum) + // from SDL + // protocol + "method": "TTS.GetCapabilities" + } + }; + this.client.send(JSONMessage); + + break; + } + case "TTS.PerformInteraction": + { + + SDL.SDLModel.onPrompt(request.params.initialPrompt); + + SDL.SDLModel.interactionData.helpPrompt = request.params.helpPrompt; + + var request = request; + + setTimeout(function(){ + if (SDL.InteractionChoicesView.active) { + //FFW.TTS.requestId = request.id; + SDL.SDLModel.onPrompt(request.params.timeoutPrompt); + SDL.SDLModel.interactionData.helpPrompt = null; + } + }, request.params.timeout - 2000); //Magic numer is a platform depended HMI behavior: -2 seconds for timeout prompt + + this.sendTTSResult(SDL.SDLModel.resultCode["SUCCESS"], request.id, "TTS.PerformInteraction"); + + break; + } + case "TTS.GetSupportedLanguages": { + + Em.Logger.log("FFW." + request.method + "Response"); + + var JSONMessage = { + "jsonrpc": "2.0", + "id": request.id, + "result": { + "code": SDL.SDLModel.resultCode["SUCCESS"], // type (enum) + // from SDL + "method": "TTS.GetSupportedLanguages", + "languages": SDL.SDLModel.sdlLanguagesList + } + }; + this.client.send(JSONMessage); + + break; + } + case "TTS.GetLanguage": { + + Em.Logger.log("FFW." + request.method + "Response"); + + var JSONMessage = { + "jsonrpc": "2.0", + "id": request.id, + "result": { + "code": SDL.SDLModel.resultCode["SUCCESS"], // type (enum) + // from SDL + "method": "TTS.GetLanguage", + "language": SDL.SDLModel.hmiTTSVRLanguage + } + }; + this.client.send(JSONMessage); + + break; + } + case "TTS.ChangeRegistration": { + + SDL.SDLModel.changeRegistrationTTSVR(request.params.language, request.params.appID); + + this.sendTTSResult(SDL.SDLModel.resultCode["SUCCESS"], + request.id, + request.method); + + break; + } + + case "TTS.IsReady": { + + Em.Logger.log("FFW." + request.method + "Response"); + + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": request.id, + "result": { + "available": this.get('isReady'), + "code": SDL.SDLModel.resultCode["SUCCESS"], + "method": "TTS.IsReady" + } + }; + + this.client.send(JSONMessage); + + break; + } + + default: { + // statements_def + break; + } + } + }, + + /** + * Send error response from onRPCRequest + * + * @param {Number} + * resultCode + * @param {Number} + * id + * @param {String} + * method + */ + sendError: function(resultCode, id, method, message) { + + Em.Logger.log("FFW." + method + "Response"); + + if (resultCode != SDL.SDLModel.resultCode["SUCCESS"]) { + + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": id, + "error": { + "code": resultCode, // type (enum) from SDL protocol + "message": message, + "data": { + "method": method } - }; - this.client.send( JSONMessage ); + } + }; + this.client.send(JSONMessage); + } + }, - break; - } + /** + * send response from onRPCRequest + * + * @param {Number} + * resultCode + * @param {Number} + * id + * @param {String} + * method + */ + sendTTSResult: function(resultCode, id, method) { - default: { - // statements_def - break; - } + Em.Logger.log("FFW." + method + "Response"); + + if (resultCode === SDL.SDLModel.resultCode["SUCCESS"]) { + + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": id, + "result": { + "code": resultCode, // type (enum) from SDL protocol + "method": method + } + }; + this.client.send(JSONMessage); } }, /* * Notifies if sdl TTS components language was changed */ - OnLanguageChange: function( lang ) { - Em.Logger.log( "FFW.TTS.OnLanguageChange" ); + OnLanguageChange: function(lang) { + + Em.Logger.log("FFW.TTS.OnLanguageChange"); // send repsonse var JSONMessage = { @@ -223,6 +374,34 @@ FFW.TTS = FFW.RPCObserver.create( { "language": lang } }; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); + }, + + /** + * Initiated by TTS module to let SDL know that TTS session has started. + */ + Started: function() { + + Em.Logger.log("FFW.TTS.Started"); + + var JSONMessage = { + "jsonrpc": "2.0", + "method": "TTS.Started" + }; + this.client.send(JSONMessage); + }, + + /** + * Initiated by TTS module to let SDL know that TTS session has stopped. + */ + Stopped: function() { + + Em.Logger.log("FFW.TTS.Stopped"); + + var JSONMessage = { + "jsonrpc": "2.0", + "method": "TTS.Stopped" + }; + this.client.send(JSONMessage); } -} )
\ No newline at end of file +})
\ No newline at end of file diff --git a/SDL_Core/src/components/HMI/ffw/UIRPC.js b/SDL_Core/src/components/HMI/ffw/UIRPC.js index 619d76e84..8970cda2c 100755..100644 --- a/SDL_Core/src/components/HMI/ffw/UIRPC.js +++ b/SDL_Core/src/components/HMI/ffw/UIRPC.js @@ -1,17 +1,16 @@ /* * Copyright (c) 2013, Ford Motor Company All rights reserved. - * + * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * · Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * · Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * · Neither the name of the Ford Motor Company nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * + * modification, are permitted provided that the following conditions are met: · + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. · Redistributions in binary + * form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided + * with the distribution. · Neither the name of the Ford Motor Company nor the + * names of its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE @@ -26,637 +25,1321 @@ */ /* * Reference implementation of UI component. - * + * * Interface to get or set some essential information sent from SDLCore. UI is * responsible for the functionality provided by the application: display * graphics and multimedia components, is responsible for the transfer of * managed manipulations, generated by the user to the server. - * + * */ -FFW.UI = FFW.RPCObserver.create( { +FFW.UI = FFW.RPCObserver.create({ - /* + /** + * If true then UI is present and ready to communicate with SDL. + * + * @type {Boolean} + */ + isReady: true, + + /** * access to basic RPC functionality */ - client: FFW.RPCClient.create( { + client: FFW.RPCClient.create({ componentName: "UI" - } ), + }), // temp var for debug - appId: 1, + appID: 1, - onVRChoiseSubscribeRequestId: -1, - onVRChoiseUnsubscribeRequestId: -1, + onShowNotificationSubscribeRequestID: -1, + + onShowNotificationUnsubscribeRequestID: -1, // const - onVRChoiseNotification: "VR.OnChoise", + onShowNotificationNotification: "UI.ShowNotification", - /* + /** * ids for requests AudioPassThru */ - performAudioPassThruRequestId: -1, - endAudioPassThruRequestId: -1, + performAudioPassThruRequestID: -1, + endAudioPassThruRequestID: -1, - /* + /** * connect to RPC bus */ - connect: function() { - this.client.connect( this, 400 ); + connect: function () { + + this.client.connect(this, 400); // Magic number is unique identifier + // for component }, - /* + /** * disconnect from RPC bus */ - disconnect: function() { + disconnect: function () { + this.client.disconnect(); }, - /* - * Client is registered - we can send request starting from this point of - * time + /** + * Client is registered - we can send request starting from this point + * of time */ - onRPCRegistered: function() { - Em.Logger.log( "FFW.UI.onRPCRegistered" ); + onRPCRegistered: function () { + + Em.Logger.log("FFW.UI.onRPCRegistered"); this._super(); // subscribe to notifications - this.onVRChoiseSubscribeRequestId = this.client.subscribeToNotification( this.onVRChoiseNotification ); - - // notify other components that UI is ready - // main purpose is to nitofy SDLCore - this.onReady(); + this.onShowNotificationSubscribeRequestID = this.client.subscribeToNotification(this.onShowNotificationNotification); }, - /* + /** * Client is unregistered - no more requests */ - onRPCUnregistered: function() { - Em.Logger.log( "FFW.UI.onRPCUnregistered" ); + onRPCUnregistered: function () { + + Em.Logger.log("FFW.UI.onRPCUnregistered"); this._super(); // unsubscribe from notifications - this.onVRChoiseUnsubscribeRequestId = this.client.unsubscribeFromNotification( this.onVRChoiseNotification ); + this.onShowNotificationUnsubscribeRequestID = this.client.unsubscribeFromNotification(this.onShowNotificationNotification); }, - /* + /** * Client disconnected. */ - onRPCDisconnected: function() { + onRPCDisconnected: function () { }, - /* - * when result is received from RPC component this function is called It is - * the propriate place to check results of request execution Please use - * previously store reuqestID to determine to which request repsonse belongs - * to + /** + * when result is received from RPC component this function is called It + * is the propriate place to check results of request execution Please + * use previously store reuqestID to determine to which request repsonse + * belongs to */ - onRPCResult: function( response ) { - Em.Logger.log( "FFW.UI.onRPCResult" ); + onRPCResult: function (response) { + + Em.Logger.log("FFW.UI.onRPCResult"); this._super(); }, - /* + /** * handle RPC erros here */ - onRPCError: function( error ) { - Em.Logger.log( "FFW.UI.onRPCError" ); + onRPCError: function (error) { + + Em.Logger.log("FFW.UI.onRPCError"); this._super(); }, - /* + /** * handle RPC notifications here */ - onRPCNotification: function( notification ) { - Em.Logger.log( "FFW.UI.onRPCNotification" ); + onRPCNotification: function (notification) { + + Em.Logger.log("FFW.UI.onRPCNotification"); this._super(); - if( notification.method == this.onVRChoiseNotification ){ - this.interactionResponse( "SUCCESS", notification.params.choiceId ); + if (notification.method == this.onShowNotificationNotification) { + // to do } }, - /* + /** * handle RPC requests here */ - onRPCRequest: function( request ) { - Em.Logger.log( "FFW.UI.onRPCRequest" ); - this._super(); + onRPCRequest: function (request) { - var resultCode = null; + Em.Logger.log("FFW.UI.onRPCRequest"); - switch( request.method ){ - case "UI.Show": { + if (this.validationCheck(request)) { - // Close TBT - SDL.TurnByTurnView.deactivate(); + switch (request.method) { + case "UI.Alert": + { - SDL.SDLController.getApplicationModel( request.params.appId ).onSDLUIShow( request.params ); - - this.sendUIResult( "SUCCESS", request.id, request.method ); - - break; - } - case "UI.Alert": { + SDL.SDLModel.onUIAlert(request.params, request.id); - SDL.SDLModel.onUIAlert( request.params, request.id ); + break; + } + case "UI.Show": + { - break; - } - case "UI.SetGlobalProperties": { + SDL.TurnByTurnView.deactivate(); + SDL.SDLController.getApplicationModel(request.params.appID).onSDLUIShow(request.params); + this.sendUIResult(SDL.SDLModel.resultCode["SUCCESS"], request.id, request.method); - SDL.SDLModel.setProperties( request.params ); + break; + } + case "UI.SetGlobalProperties": + { + SDL.SDLModel.setProperties(request.params); - this.sendUIResult( "SUCCESS", request.id, request.method ); + this.sendUIResult(SDL.SDLModel.resultCode["SUCCESS"], request.id, request.method); - break; - } - case "UI.ResetGlobalProperties": { + break; + } + case "UI.ResetGlobalProperties": + { - // reset all requested properties - SDL.SDLModel.resetProperties( request.params ); + this.sendUIResult(SDL.SDLModel.resultCode["SUCCESS"], request.id, request.method); - this.sendUIResult( "SUCCESS", request.id, request.method ); + break; + } + case "UI.AddCommand": + { - break; - } - case "UI.AddCommand": { + SDL.SDLController.getApplicationModel(request.params.appID).addCommand(request); - SDL.SDLController.getApplicationModel( request.params.appId ).addCommand( request.params ); + break; + } + case "UI.DeleteCommand": + { - this.sendUIResult( "SUCCESS", request.id, request.method ); + SDL.SDLController.getApplicationModel(request.params.appID).deleteCommand(request.params.cmdID, request.id); - break; - } - case "UI.DeleteCommand": { + break; + } + case "UI.AddSubMenu": + { - SDL.SDLController.getApplicationModel( request.params.appId ).deleteCommand( request.params.cmdId ); + SDL.SDLController.getApplicationModel(request.params.appID).addSubMenu(request); - this.sendUIResult( "SUCCESS", request.id, request.method ); + break; + } + case "UI.DeleteSubMenu": + { - break; - } - case "UI.AddSubMenu": { + var resultCode = SDL.SDLController.getApplicationModel(request.params.appID).deleteSubMenu(request.params.menuID); + this.sendUIResult(resultCode, request.id, request.method); - SDL.SDLController.getApplicationModel( request.params.appId ).addSubMenu( request.params ); + break; + } + case "UI.PerformInteraction": + { - this.sendUIResult( "SUCCESS", request.id, request.method ); + SDL.SDLModel.uiPerformInteraction(request); - break; - } - case "UI.DeleteSubMenu": { + break; + } + case "UI.SetMediaClockTimer": + { + + var resultCode = SDL.SDLController.getApplicationModel(request.params.appID).sdlSetMediaClockTimer(request.params); + if (resultCode === SDL.SDLModel.resultCode["SUCCESS"]) { + this.sendUIResult(resultCode, request.id, request.method); + } else { + this.sendError(resultCode, request.id, request.method, 'Request is ignored, because the intended result is already in effect.'); + } - var resultCode = SDL.SDLController.getApplicationModel( request.params.appId ).deleteSubMenu( request.params.menuId ); + break; + } + case "UI.Slider": + { - this.sendUIResult( resultCode, request.id, request.method ); + SDL.SDLModel.uiSlider(request); - break; - } - case "UI.CreateInteractionChoiceSet": { + break; + } + case "UI.ScrollableMessage": + { - SDL.SDLController.getApplicationModel( request.params.appId ).onCreateInteraction( request.params ); + SDL.SDLModel.onSDLScrolableMessage(request, request.id); - this.sendUIResult( "SUCCESS", request.id, request.method ); + break; + } + case "UI.ChangeRegistration": + { - break; - } - case "UI.DeleteInteractionChoiceSet": { + SDL.SDLModel.changeRegistrationUI(request.params.language, request.params.appID); + this.sendUIResult(SDL.SDLModel.resultCode["SUCCESS"], request.id, request.method); - SDL.SDLController.getApplicationModel( request.params.appId ).onDeleteInteraction( request.params ); + break; + } + case "UI.SetDisplayLayout": + { + + var senResponseFlag = false; + + switch (request.params.displayLayout){ + case "MEDIA": { + senResponseFlag = true; + break; + } + case "NON-MEDIA": { + senResponseFlag = true; + break; + } + case "DEFAULT": { + senResponseFlag = true; + break; + } + case "ONSCREEN_PRESETS": { + senResponseFlag = true; + break; + } + case "NAV_FULLSCREEN_MAP": { + senResponseFlag = true; + break; + } + case "NAV_KEYBOARD": { + senResponseFlag = true; + break; + } + case "NAV_LIST": { + senResponseFlag = true; + break; + } + } - this.sendUIResult( "SUCCESS", request.id, request.method ); + if (senResponseFlag) { + + Em.Logger.log("FFW." + request.method + "Response"); + + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": request.id, + "result": { + "displayCapabilities": { + "displayType": "GEN2_8_DMA", + "textFields": [ + "mainField1", + "mainField2", + "mainField3", + "mainField4", + "statusBar", + "mediaClock", + "mediaTrack", + "alertText1", + "alertText2", + "alertText3", + "scrollableMessageBody", + "initialInteractionText", + "navigationText1", + "navigationText2", + "ETA", + "totalDistance", + "navigationText", + "audioPassThruDisplayText1", + "audioPassThruDisplayText2", + "sliderHeader", + "sliderFooter", + "notificationText", + "menuName", + "secondaryText", + "tertiaryText", + "timeToDestination", + "turnText" + ], + "imageFields": [ + { + "name": "softButtonImage", + "imageTypeSupported": + [ + "GRAPHIC_BMP", + "GRAPHIC_JPEG", + "GRAPHIC_PNG" + ], + "imageResolution": + { + "resolutionWidth": 64, + "resolutionHeight": 64 + } + }, + { + "name": "choiceImage", + "imageTypeSupported": + [ + "GRAPHIC_BMP", + "GRAPHIC_JPEG", + "GRAPHIC_PNG" + ], + "imageResolution": + { + "resolutionWidth": 64, + "resolutionHeight": 64 + } + }, + { + "name": "choiceSecondaryImage", + "imageTypeSupported": + [ + "GRAPHIC_BMP", + "GRAPHIC_JPEG", + "GRAPHIC_PNG" + ], + "imageResolution": + { + "resolutionWidth": 64, + "resolutionHeight": 64 + } + }, + { + "name": "vrHelpItem", + "imageTypeSupported": + [ + "GRAPHIC_BMP", + "GRAPHIC_JPEG", + "GRAPHIC_PNG" + ], + "imageResolution": + { + "resolutionWidth": 64, + "resolutionHeight": 64 + } + }, + { + "name": "turnIcon", + "imageTypeSupported": + [ + "GRAPHIC_BMP", + "GRAPHIC_JPEG", + "GRAPHIC_PNG" + ], + "imageResolution": + { + "resolutionWidth": 64, + "resolutionHeight": 64 + } + }, + { + "name": "menuIcon", + "imageTypeSupported": + [ + "GRAPHIC_BMP", + "GRAPHIC_JPEG", + "GRAPHIC_PNG" + ], + "imageResolution": + { + "resolutionWidth": 64, + "resolutionHeight": 64 + } + }, + { + "name": "cmdIcon", + "imageTypeSupported": + [ + "GRAPHIC_BMP", + "GRAPHIC_JPEG", + "GRAPHIC_PNG" + ], + "imageResolution": + { + "resolutionWidth": 64, + "resolutionHeight": 64 + } + }, + { + "name": "graphic", + "imageTypeSupported": + [ + "GRAPHIC_BMP", + "GRAPHIC_JPEG", + "GRAPHIC_PNG" + ], + "imageResolution": + { + "resolutionWidth": 64, + "resolutionHeight": 64 + } + }, + { + "name": "showConstantTBTIcon", + "imageTypeSupported": + [ + "GRAPHIC_BMP", + "GRAPHIC_JPEG", + "GRAPHIC_PNG" + ], + "imageResolution": + { + "resolutionWidth": 64, + "resolutionHeight": 64 + } + }, + { + "name": "showConstantTBTNextTurnIcon", + "imageTypeSupported": + [ + "GRAPHIC_BMP", + "GRAPHIC_JPEG", + "GRAPHIC_PNG" + ], + "imageResolution": + { + "resolutionWidth": 64, + "resolutionHeight": 64 + } + }, + { + "name": "showConstantTBTNextTurnIcon", + "imageTypeSupported": + [ + "GRAPHIC_BMP", + "GRAPHIC_JPEG", + "GRAPHIC_PNG" + ], + "imageResolution": + { + "resolutionWidth": 64, + "resolutionHeight": 64 + } + } + ], + "mediaClockFormats": [ + "CLOCK1", "CLOCK2", "CLOCK3", "CLOCKTEXT1", "CLOCKTEXT2", "CLOCKTEXT3", "CLOCKTEXT4" + ], + "graphicSupported": true, + "imageCapabilities": ["DYNAMIC"], + "templatesAvailable": ["TEMPLATE"], + "screenParams": { + "resolution": { + "resolutionWidth": 800, + "resolutionHeight": 480 + }, + "touchEventAvailable": { + "pressAvailable": true, + "multiTouchAvailable": true, + "doublePressAvailable": false + } + }, + "numCustomPresetsAvailable": 8 + }, + "buttonCapabilities": [ + { + "name": "PRESET_0", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "PRESET_1", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "PRESET_2", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "PRESET_3", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "PRESET_4", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "PRESET_5", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "PRESET_6", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "PRESET_7", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "PRESET_8", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "PRESET_9", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "OK", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "SEEKLEFT", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "SEEKRIGHT", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "TUNEUP", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + }, { + "name": "TUNEDOWN", + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true + } + ], + "softButtonCapabilities": [{ + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true, + "imageSupported": true + }], + "presetBankCapabilities": { + "onScreenPresetsAvailable": true + }, + "code": SDL.SDLModel.resultCode["SUCCESS"], + "method": "UI.SetDisplayLayout" + } + }; + + this.client.send(JSONMessage); + + } else { + this.sendError(SDL.SDLModel.resultCode["UNSUPPORTED_RESOURCE"], request.id, request.method, "Unsupported display layout!") + } - break; - } - case "UI.PerformInteraction": { + break; + } + case "UI.SetAppIcon": + { - SDL.SDLModel.uiPerformInteraction( request.params, request.id ); + SDL.SDLModel.onSDLSetAppIcon(request.params, request.id, request.method); - break; - } - case "UI.SetMediaClockTimer": { + break; + } + case "UI.PerformAudioPassThru": + { - var resultCode = SDL.SDLController.getApplicationModel( request.params.appId ).sdlSetMediaClockTimer( request.params ); + this.performAudioPassThruRequestID = request.id; + SDL.SDLModel.UIPerformAudioPassThru(request.params); - this.sendUIResult( resultCode, request.id, request.method ); + break; + } + case "UI.EndAudioPassThru": + { - break; - } - case "UI.OnAppActivated": { + this.endAudioPassThruRequestID = request.id; - break; - } - case "UI.Slider": { + SDL.SDLModel.UIEndAudioPassThru(); - SDL.SDLModel.uiSlider( request ); + break; + } + case "UI.GetSupportedLanguages": + { + + Em.Logger.log("FFW." + request.method + "Response"); + + var JSONMessage = { + "id": request.id, + "jsonrpc": "2.0", + "result": { + "code": SDL.SDLModel.resultCode["SUCCESS"], // type + // (enum) + // from + // SDL + "method": "UI.GetSupportedLanguages", + "languages": SDL.SDLModel.sdlLanguagesList + } + }; + this.client.send(JSONMessage); + + break; + } + case "UI.GetLanguage": + { + + Em.Logger.log("FFW." + request.method + "Response"); + + var JSONMessage = { + "jsonrpc": "2.0", + "id": request.id, + "result": { + "code": SDL.SDLModel.resultCode["SUCCESS"], // type + // (enum) + // from + // SDL + "method": "UI.GetLanguage", + "language": SDL.SDLModel.hmiUILanguage + } + }; + this.client.send(JSONMessage); + + break; + } + case "UI.GetCapabilities": + { + + Em.Logger.log("FFW." + request.method + "Response"); + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": request.id, + "result": { + "displayCapabilities": { + "displayType": "GEN2_8_DMA", + "textFields": [ + "mainField1", + "mainField2", + "mainField3", + "mainField4", + "statusBar", + "mediaClock", + "mediaTrack", + "alertText1", + "alertText2", + "alertText3", + "scrollableMessageBody", + "initialInteractionText", + "navigationText1", + "navigationText2", + "ETA", + "totalDistance", + "navigationText", + "audioPassThruDisplayText1", + "audioPassThruDisplayText2", + "sliderHeader", + "sliderFooter", + "notificationText", + "menuName", + "secondaryText", + "tertiaryText", + "timeToDestination", + "turnText" + ], + "imageFields": [ + { + "name": "softButtonImage", + "imageTypeSupported": + [ + "GRAPHIC_BMP", + "GRAPHIC_JPEG", + "GRAPHIC_PNG" + ], + "imageResolution": + { + "resolutionWidth": 64, + "resolutionHeight": 64 + } + }, + { + "name": "choiceImage", + "imageTypeSupported": + [ + "GRAPHIC_BMP", + "GRAPHIC_JPEG", + "GRAPHIC_PNG" + ], + "imageResolution": + { + "resolutionWidth": 64, + "resolutionHeight": 64 + } + }, + { + "name": "choiceSecondaryImage", + "imageTypeSupported": + [ + "GRAPHIC_BMP", + "GRAPHIC_JPEG", + "GRAPHIC_PNG" + ], + "imageResolution": + { + "resolutionWidth": 64, + "resolutionHeight": 64 + } + }, + { + "name": "vrHelpItem", + "imageTypeSupported": + [ + "GRAPHIC_BMP", + "GRAPHIC_JPEG", + "GRAPHIC_PNG" + ], + "imageResolution": + { + "resolutionWidth": 64, + "resolutionHeight": 64 + } + }, + { + "name": "turnIcon", + "imageTypeSupported": + [ + "GRAPHIC_BMP", + "GRAPHIC_JPEG", + "GRAPHIC_PNG" + ], + "imageResolution": + { + "resolutionWidth": 64, + "resolutionHeight": 64 + } + }, + { + "name": "menuIcon", + "imageTypeSupported": + [ + "GRAPHIC_BMP", + "GRAPHIC_JPEG", + "GRAPHIC_PNG" + ], + "imageResolution": + { + "resolutionWidth": 64, + "resolutionHeight": 64 + } + }, + { + "name": "cmdIcon", + "imageTypeSupported": + [ + "GRAPHIC_BMP", + "GRAPHIC_JPEG", + "GRAPHIC_PNG" + ], + "imageResolution": + { + "resolutionWidth": 64, + "resolutionHeight": 64 + } + }, + { + "name": "graphic", + "imageTypeSupported": + [ + "GRAPHIC_BMP", + "GRAPHIC_JPEG", + "GRAPHIC_PNG" + ], + "imageResolution": + { + "resolutionWidth": 64, + "resolutionHeight": 64 + } + }, + { + "name": "showConstantTBTIcon", + "imageTypeSupported": + [ + "GRAPHIC_BMP", + "GRAPHIC_JPEG", + "GRAPHIC_PNG" + ], + "imageResolution": + { + "resolutionWidth": 64, + "resolutionHeight": 64 + } + }, + { + "name": "showConstantTBTNextTurnIcon", + "imageTypeSupported": + [ + "GRAPHIC_BMP", + "GRAPHIC_JPEG", + "GRAPHIC_PNG" + ], + "imageResolution": + { + "resolutionWidth": 64, + "resolutionHeight": 64 + } + }, + { + "name": "showConstantTBTNextTurnIcon", + "imageTypeSupported": + [ + "GRAPHIC_BMP", + "GRAPHIC_JPEG", + "GRAPHIC_PNG" + ], + "imageResolution": + { + "resolutionWidth": 64, + "resolutionHeight": 64 + } + } + ], + "mediaClockFormats": [ + "CLOCK1", "CLOCK2", "CLOCK3", "CLOCKTEXT1", "CLOCKTEXT2", "CLOCKTEXT3", "CLOCKTEXT4" + ], + "graphicSupported": true, + "imageCapabilities": ["DYNAMIC"], + "templatesAvailable": ["TEMPLATE"], + "screenParams": { + "resolution": { + "resolutionWidth": 800, + "resolutionHeight": 480 + }, + "touchEventAvailable": { + "pressAvailable": true, + "multiTouchAvailable": true, + "doublePressAvailable": false + } + }, + "numCustomPresetsAvailable": 8 + }, + "audioPassThruCapabilities": { + "samplingRate": "44KHZ", + "bitsPerSample": "8_BIT", + "audioType": "PCM" + }, + "hmiZoneCapabilities": "FRONT", + "softButtonCapabilities": { + "shortPressAvailable": true, + "longPressAvailable": true, + "upDownAvailable": true, + "imageSupported": true + }, + "code": SDL.SDLModel.resultCode["SUCCESS"], + "method": "UI.GetCapabilities" + } + }; + + this.client.send(JSONMessage); + + break; + } + case "UI.IsReady": + { + + Em.Logger.log("FFW." + request.method + "Response"); + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": request.id, + "result": { + "available": this.get('isReady'), + "code": SDL.SDLModel.resultCode["SUCCESS"], + "method": "UI.IsReady" + } + }; + + this.client.send(JSONMessage); + + break; + } + case "UI.ClosePopUp": + { - break; - } - case "UI.ScrollableMessage": { + SDL.SDLController.closePopUp(); - SDL.SDLModel.onSDLScrolableMessage( request.params, request.id ); - break; - } - case "UI.ChangeRegistration": { + Em.Logger.log("FFW." + request.method + "Response"); + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": request.id, + "result": { + "code": SDL.SDLModel.resultCode["SUCCESS"], + "method": "UI.ClosePopUp" + } + }; - SDL.SDLModel.changeRegistrationUI( request.params.hmiDisplayLanguage ); + this.client.send(JSONMessage); - this.sendUIResult( "SUCCESS", request.id, request.method ); + break; + } + case "UI.ShowVrHelp": + { - break; - } - case "UI.SetAppIcon": { + //SDL.SDLModel.ShowVrHelp(request.params); - SDL.SDLModel.onSDLSetAppIcon( request.params, request.id, request.method ); + this.sendUIResult(SDL.SDLModel.resultCode["SUCCESS"], request.id, request.method); - break; - } - case "UI.PerformAudioPassThru": { + break; + } + case "UI.ShowKeyboard": + { - this.performAudioPassThruRequestId = request.id; + SDL.SDLModel.uiShowKeyboard(request.params); - SDL.SDLModel.UIPerformAudioPassThru( request.params ); + this.sendUIResult(SDL.SDLModel.resultCode["SUCCESS"], request.id, request.method); - break; + break; + } + default: + { + // statements_def + break; + } } - case "UI.EndAudioPassThru": { + } + }, - this.endAudioPassThruRequestId = request.id; + /** + * Send error response from onRPCRequest + * + * @param {Number} + * resultCode + * @param {Number} + * id + * @param {String} + * method + */ + sendError: function (resultCode, id, method, message) { - SDL.SDLModel.UIEndAudioPassThru(); + Em.Logger.log("FFW." + method + "Response"); - break; - } - case "UI.GetSupportedLanguages": { - - var JSONMessage = { - "jsonrpc": "2.0", - "id": request.id, - "result": { - "resultCode": "SUCCESS", // type (enum) from SDL - // protocol - "method": "UI.GetSupportedLanguagesResponse", - "languages": SDL.SDLModel.sdlLanguagesList - } - }; - this.client.send( JSONMessage ); + if (resultCode !== 0) { - break; - } - case "UI.GetLanguage": { - - var JSONMessage = { - "jsonrpc": "2.0", - "id": request.id, - "result": { - "resultCode": "SUCCESS", // type (enum) from SDL - // protocol - "method": "UI.GetLanguageResponse", - "hmiDisplayLanguage": SDL.SDLModel.hmiUILanguage + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": id, + "error": { + "code": resultCode, // type (enum) from SDL protocol + "message": message, + "data": { + "method": method } - }; - this.client.send( JSONMessage ); - - break; - } - case "UI.ShowConstantTBT": { - - SDL.SDLModel.tbtActivate( request.params ); - - this.sendUIResult( "SUCCESS", request.id, request.method ); - - break; - } - case "UI.UpdateTurnList": { - - SDL.SDLModel.tbtTurnListUpdate( request.params ); - - this.sendUIResult( "SUCCESS", request.id, request.method ); - - break; - } - case "UI.AlertManeuver": { - - SDL.SDLModel.onUIAlertManeuver( request.params ); + } + }; + this.client.send(JSONMessage); + } + }, - this.sendUIResult( "SUCCESS", request.id, request.method ); + /** + * send response from onRPCRequest + * + * @param {Number} + * resultCode + * @param {Number} + * id + * @param {String} + * method + */ + sendUIResult: function (resultCode, id, method) { - break; - } - case "UI.DialNumber": { + Em.Logger.log("FFW." + method + "Response"); - SDL.SDLModel.dialNumber( request.params ); + if (resultCode === SDL.SDLModel.resultCode["SUCCESS"]) { - this.sendUIResult( "SUCCESS", request.id, request.method ); + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": id, + "result": { + "code": resultCode, // type (enum) from SDL protocol + "method": method + } + }; + this.client.send(JSONMessage); + } + }, - break; - } - case "UI.GetCapabilities": { - // send repsonse - var JSONMessage = { - "jsonrpc": "2.0", - "id": request.id, - "result": { - "displayCapabilities": { - "displayType": "GEN2_8_DMA", - "textFields": - [ - { - "name": "mainField1", - "characterSet": "TYPE2SET", - "width": 1, - "rows": 1 - }, - { - "name": "mainField2", - "characterSet": "TYPE2SET", - "width": 1, - "rows": 1 - }, - { - "name": "statusBar", - "characterSet": "TYPE2SET", - "width": 1, - "rows": 1 - }, - { - "name": "mediaClock", - "characterSet": "TYPE2SET", - "width": 1, - "rows": 1 - }, - { - "name": "mediaTrack", - "characterSet": "TYPE2SET", - "width": 1, - "rows": 1 - }, - { - "name": "alertText1", - "characterSet": "TYPE2SET", - "width": 1, - "rows": 1 - }, - { - "name": "alertText2", - "characterSet": "TYPE2SET", - "width": 1, - "rows": 1 - } - ], - "mediaClockFormats": - [ - "CLOCK1", - "CLOCK2", - "CLOCKTEXT1", - "CLOCKTEXT2", - "CLOCKTEXT3" - ] - }, - "hmiZoneCapabilities": - [ - "FRONT", - "BACK" - ], - "softButtonCapabilities": - [ - { - "shortPressAvailable": true, - "longPressAvailable": true, - "upDownAvailable": true, - "imageSupported": true - } - ], - "method": "UI.GetCapabilitiesResponse", - "resultCode": "SUCCESS" // type (enum) from SDL protocol - } - }; + /** + * send response from onRPCRequest + * + * @param {Number} + * resultCode + * @param {Number} + * id + */ + alertResponse: function (resultCode, id) { - this.client.send( JSONMessage ); + Em.Logger.log("FFW.UI.AlertResponse"); - break; - } + if (resultCode === SDL.SDLModel.resultCode["SUCCESS"]) { - default: { - // statements_def - break; - } + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": id, + "result": { + "code": resultCode, // type (enum) from SDL protocol + "method": 'UI.Alert' + } + }; + this.client.send(JSONMessage); + } else { + this.sendError(resultCode, id, "UI.Alert", 'Alert request aborted.'); } }, - /* + /** * send response from onRPCRequest + * + * @param {Number} + * resultCode + * @param {Number} + * sliderRequestID + * @param {Number} + * sliderPosition */ - sendUIResult: function( resultCode, id, method ) { + sendSliderResult: function (resultCode, sliderRequestID, sliderPosition) { - Em.Logger.log( "FFW.UI." + method + "Response" ); - if( resultCode ){ + Em.Logger.log("FFW.UI.SliderResponse"); + + if (resultCode === SDL.SDLModel.resultCode["SUCCESS"]) { // send repsonse var JSONMessage = { "jsonrpc": "2.0", - "id": id, + "id": sliderRequestID, "result": { - "resultCode": resultCode, // type (enum) from SDL protocol - "method": method + "Response" + "code": resultCode, // type (enum) from SDL protocol + "method": 'UI.Slider' } }; - this.client.send( JSONMessage ); - } - }, - sendSliderResult: function( resultCode, sliderRequestId, sliderPosition ) { - var JSONMessage = { - "jsonrpc": "2.0", - "id": sliderRequestId, - "result": { - "resultCode": resultCode, // type (enum) from SDL protocol - "method": "UI.SliderResponse" + if (sliderPosition) { + JSONMessage.result.sliderPosition = sliderPosition; } - }; + } else { + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": sliderRequestID, + "error": { + "code": resultCode, // type (enum) from SDL protocol + "message": 'Slider request aborted.', + "data": { + "method": 'UI.Slider' + } + } + }; - if( sliderPosition ){ - JSONMessage.result.sliderPosition = sliderPosition; + if (sliderPosition) { + JSONMessage.error.data.sliderPosition = sliderPosition; + } } - this.client.send( JSONMessage ); + this.client.send(JSONMessage); }, - /* - * send notification when command was triggered + /** + * Notification method to send touch event data to SDLCore + * + * @param {Number} appID + * @param {String} methodName */ - onCommand: function( commandId, appId ) { - Em.Logger.log( "FFW.UI.onCommand" ); + onResetTimeout: function (appID, methodName) { + + Em.Logger.log("FFW.UI.OnResetTimeout"); var JSONMessage = { "jsonrpc": "2.0", - "method": "UI.OnCommand", + "method": "UI.OnResetTimeout", "params": { - "commandId": commandId, - "appId": appId + "methodName": methodName, + "appID": appID } }; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); }, - /* + /** * send notification when command was triggered + * + * @param {Number} + * commandID + * @param {Number} + * appID */ - onCommandSoftButton: function( softButtonID, appId ) { - Em.Logger.log( "FFW.UI.onCommand" ); + onCommand: function (commandID, appID) { + + Em.Logger.log("FFW.UI.onCommand"); var JSONMessage = { "jsonrpc": "2.0", "method": "UI.OnCommand", "params": { - "commandId": softButtonID, - "appId": appId + "cmdID": commandID, + "appID": appID } }; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); }, - /* - * send notification when command was triggered + /** + * Notification method to send touch event data to SDLCore + * + * @param {String} type + * @param {Object} touchLists + * @param {Object} info */ - interactionResponse: function( resultCode, performInteractionRequestId, commandId ) { - Em.Logger.log( "FFW.UI.PerformInteractionResponse" ); + onTouchEvent: function (type, event) { + + Em.Logger.log("FFW.UI.OnTouchEvent"); - // send repsonse var JSONMessage = { "jsonrpc": "2.0", - "id": performInteractionRequestId, - "result": { - "resultCode": resultCode, - "method": "UI.PerformInteractionResponse" + "method": "UI.OnTouchEvent", + "params": { + "type": type, + "event": event } }; - - if( commandId ){ - JSONMessage.result.choiceID = commandId; - } - - this.client.send( JSONMessage ); + this.client.send(JSONMessage); }, - /* - * notification that UI is ready BasicCommunication should be sunscribed to - * this notification + /** + * send notification when command was triggered + * + * @param {Number} + * softButtonID + * @param {Number} + * appID */ - onReady: function() { - Em.Logger.log( "FFW.UI.onReady" ); + onCommandSoftButton: function (softButtonID, appID) { - var JSONMessage = { - "jsonrpc": "2.0", - "method": "UI.OnReady" - }; - this.client.send( JSONMessage ); - }, - - /* - * send notification when DriverDistraction PopUp is visible - */ - onDriverDistraction: function( driverDistractionState ) { - Em.Logger.log( "FFW.UI.DriverDistraction" ); + Em.Logger.log("FFW.UI.onCommand"); - // send repsonse var JSONMessage = { "jsonrpc": "2.0", - "method": "UI.OnDriverDistraction", + "method": "UI.OnCommand", "params": { - "state": driverDistractionState, - "appId": 0 + "commandID": softButtonID, + "appID": appID } }; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); }, - /* - * Notifies if system context is changed + /** + * send notification when command was triggered + * + * @param {Number} appID + * @param {Number} resultCode + * @param {Number} commandID + * @param {String} manualTextEntry */ - OnSystemContext: function( systemContextValue ) { - Em.Logger.log( "FFW.UI.OnSystemContext" ); + interactionResponse: function (appID, resultCode, commandID, manualTextEntry) { - // send repsonse - var JSONMessage = { - "jsonrpc": "2.0", - "method": "UI.OnSystemContext", - "params": { - "systemContext": systemContextValue + Em.Logger.log("FFW.UI.PerformInteractionResponse"); + + if (resultCode === SDL.SDLModel.resultCode["SUCCESS"]) { + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": appID, + "result": { + "code": resultCode, + "method": "UI.PerformInteraction" + } + }; + + if (commandID) { + JSONMessage.result.choiceID = commandID; } - }; - this.client.send( JSONMessage ); + + if (manualTextEntry) { + JSONMessage.result.manualTextEntry = manualTextEntry; + } + } else { + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": appID, + "error": { + "code": resultCode, // type (enum) from SDL protocol + "message": "Perform Interaction error response.", + "data": { + "method": "UI.PerformInteraction" + } + } + }; + } + + this.client.send(JSONMessage); }, - /* - * Notifies if application was activated + /** + * send notification when DriverDistraction PopUp is visible + * + * @param {String} + * driverDistractionState */ - OnAppActivated: function( appName ) { - Em.Logger.log( "FFW.UI.OnAppActivated" ); + onDriverDistraction: function (driverDistractionState) { + + Em.Logger.log("FFW.UI.DriverDistraction"); // send repsonse var JSONMessage = { "jsonrpc": "2.0", - "method": "UI.OnAppActivated", + "method": "UI.OnDriverDistraction", "params": { - "appName": appName + "state": driverDistractionState } }; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); }, - /* - * Notifies if device was choosed + /** + * Notifies if system context is changed + * + * @param {String} + * systemContextValue */ - OnDeviceChosen: function( deviceName ) { - Em.Logger.log( "FFW.UI.OnDeviceChosen" ); + OnSystemContext: function (systemContextValue) { + + Em.Logger.log("FFW.UI.OnSystemContext"); // send repsonse var JSONMessage = { "jsonrpc": "2.0", - "method": "UI.OnDeviceChosen", + "method": "UI.OnSystemContext", "params": { - "deviceName": deviceName + "systemContext": systemContextValue } }; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); }, - /* + /** * Notifies if sdl UI components language was changed + * + * @param {String} + * lang */ - OnLanguageChange: function( lang ) { - Em.Logger.log( "FFW.UI.OnLanguageChange" ); + OnLanguageChange: function (lang) { + + Em.Logger.log("FFW.UI.OnLanguageChange"); // send repsonse var JSONMessage = { "jsonrpc": "2.0", "method": "UI.OnLanguageChange", "params": { - "hmiDisplayLanguage": lang + "language": lang } }; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); }, - /* - * Notifies if TBTClientState was activated + /** + * Sends notification on SDL Core display keyboard value + * + * @param {String} + * */ - onTBTClientState: function( state, appId ) { - Em.Logger.log( "FFW.UI.OnTBTClientState" ); + OnKeyboardInput: function (value) { + + Em.Logger.log("FFW.UI.OnKeyboardInput"); // send repsonse var JSONMessage = { "jsonrpc": "2.0", - "method": "UI.OnTBTClientState", + "method": "UI.OnKeyboardInput", "params": { - "state": state, - "appId": appId + "data": value, + "event": "KEYPRESS" } }; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); } -} ) +}) diff --git a/SDL_Core/src/components/HMI/ffw/VRRPC.js b/SDL_Core/src/components/HMI/ffw/VRRPC.js index 77deb2a3b..cfc8b07fe 100755..100644 --- a/SDL_Core/src/components/HMI/ffw/VRRPC.js +++ b/SDL_Core/src/components/HMI/ffw/VRRPC.js @@ -2,15 +2,14 @@ * Copyright (c) 2013, Ford Motor Company All rights reserved. * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * · Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * · Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * · Neither the name of the Ford Motor Company nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. + * modification, are permitted provided that the following conditions are met: · + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. · Redistributions in binary + * form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided + * with the distribution. · Neither the name of the Ford Motor Company nor the + * names of its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -35,24 +34,34 @@ FFW.VR = FFW.RPCObserver.create( { + /** + * If true then VR is present and ready to communicate with SDL. + * + * @type {Boolean} + */ + isReady: true, + /* * access to basic RPC functionality */ client: FFW.RPCClient.create( { componentName: "VR" - } ), + }), /* * connect to RPC bus */ connect: function() { - this.client.connect( this, 500 ); + + this.client.connect(this, 500); // Magic number is unique identifier for + // component }, /* * disconnect from RPC bus */ disconnect: function() { + this.client.disconnect(); }, @@ -61,7 +70,8 @@ FFW.VR = FFW.RPCObserver.create( { * time */ onRPCRegistered: function() { - Em.Logger.log( "FFW.VR.onRPCRegistered" ); + + Em.Logger.log("FFW.VR.onRPCRegistered"); this._super(); }, @@ -69,7 +79,8 @@ FFW.VR = FFW.RPCObserver.create( { * Client is unregistered - no more requests */ onRPCUnregistered: function() { - Em.Logger.log( "FFW.VR.onRPCUnregistered" ); + + Em.Logger.log("FFW.VR.onRPCUnregistered"); this._super(); }, @@ -86,155 +97,159 @@ FFW.VR = FFW.RPCObserver.create( { * previously store reuqestID to determine to which request repsonse belongs * to */ - onRPCResult: function( response ) { - Em.Logger.log( "FFW.VR.onRPCResult" ); + onRPCResult: function(response) { + + Em.Logger.log("FFW.VR.onRPCResult"); this._super(); }, /* * handle RPC erros here */ - onRPCError: function( error ) { - Em.Logger.log( "FFW.VR.onRPCError" ); + onRPCError: function(error) { + + Em.Logger.log("FFW.VR.onRPCError"); this._super(); }, /* * handle RPC notifications here */ - onRPCNotification: function( notification ) { - Em.Logger.log( "FFW.VR.onRPCNotification" ); + onRPCNotification: function(notification) { + + Em.Logger.log("FFW.VR.onRPCNotification"); this._super(); }, /* * send notification when command was triggered */ - onCommand: function( element ) { - Em.Logger.log( "FFW.VR.onCommand" ); + onCommand: function(element) { + + Em.Logger.log("FFW.VR.onCommand"); var JSONMessage = { "jsonrpc": "2.0", "method": "VR.OnCommand", "params": { - "commandId": element.commandId + "commandID": element.commandID } }; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); - SDL.VRPopUp.set( 'VRActive', false ); + SDL.VRPopUp.set('VRActive', false); }, /* * handle RPC requests here */ - onRPCRequest: function( request ) { - Em.Logger.log( "FFW.VR.onRPCRequest" ); - this._super(); + onRPCRequest: function(request) { + + Em.Logger.log("FFW.VR.onRPCRequest"); + if (this.validationCheck(request)) { - switch( request.method ){ + switch (request.method) { case "VR.AddCommand": { - SDL.SDLModel.addCommandVR( request.params ); + SDL.SDLModel.addCommandVR(request.params); - // send repsonse - var JSONMessage = { - "jsonrpc": "2.0", - "id": request.id, - "result": { - "resultCode": "SUCCESS", // type (enum) from SDL - // protocol - "method": request.method + "Response" - } - }; - this.client.send( JSONMessage ); + this.sendVRResult(SDL.SDLModel.resultCode["SUCCESS"], + request.id, + request.method); break; } case "VR.DeleteCommand": { - SDL.SDLModel.deleteCommandVR( request.params.cmdId ); + SDL.SDLModel.deleteCommandVR(request.params.cmdID); - // send repsonse - var JSONMessage = { - "jsonrpc": "2.0", - "id": request.id, - "result": { - "resultCode": "SUCCESS", // type (enum) from SDL - // protocol - "method": request.method + "Response" - } - }; - this.client.send( JSONMessage ); + this.sendVRResult(SDL.SDLModel.resultCode["SUCCESS"], + request.id, + request.method); break; } case "VR.GetSupportedLanguages": { + Em.Logger.log("FFW." + request.method + "Response"); + var JSONMessage = { "jsonrpc": "2.0", "id": request.id, "result": { - "resultCode": "SUCCESS", // type (enum) from SDL - // protocol - "method": "VR.GetSupportedLanguagesResponse", + "code": SDL.SDLModel.resultCode["SUCCESS"], // type + // (enum) + // from SDL + "method": "VR.GetSupportedLanguages", "languages": SDL.SDLModel.sdlLanguagesList } }; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); break; } case "VR.GetLanguage": { + Em.Logger.log("FFW." + request.method + "Response"); + var JSONMessage = { "jsonrpc": "2.0", "id": request.id, "result": { - "resultCode": "SUCCESS", // type (enum) from SDL - // protocol - "method": "VR.GetLanguageResponse", + "code": SDL.SDLModel.resultCode["SUCCESS"], // type + // (enum) + // from SDL + "method": "VR.GetLanguage", "language": SDL.SDLModel.hmiTTSVRLanguage } }; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); break; } - case "VR.GetCapabilities": { + case "VR.ChangeRegistration": { + + SDL.SDLModel.changeRegistrationTTSVR(request.params.language, request.params.appID); + + this.sendVRResult(SDL.SDLModel.resultCode["SUCCESS"], + request.id, + request.method); + + break; + } + case "VR.IsReady": { + + Em.Logger.log("FFW." + request.method + "Response"); // send repsonse var JSONMessage = { "jsonrpc": "2.0", "id": request.id, "result": { - "capabilities": - [ - "TEXT" - ], - "method": "VR.GetCapabilitiesResponse", - "resultCode": "SUCCESS" // type (enum) from SDL protocol + "available": this.get('isReady'), + "code": 0, + "method": "VR.IsReady" } }; - this.client.send( JSONMessage ); + + this.client.send(JSONMessage); break; } - case "VR.ChangeRegistration": { + case "VR.GetCapabilities": { - SDL.SDLModel.changeRegistrationTTSVR( request.params.language ); + Em.Logger.log("FFW." + request.method + "Response"); - // send repsonse var JSONMessage = { "jsonrpc": "2.0", "id": request.id, "result": { - "resultCode": "SUCCESS", // type (enum) from SDL - // protocol - "method": request.method + "Response" + "code": SDL.SDLModel.resultCode["SUCCESS"], + "method": "VR.GetCapabilities", + "vrCapabilities": ["TEXT"] } }; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); break; } @@ -243,49 +258,141 @@ FFW.VR = FFW.RPCObserver.create( { // statements_def break; } + } + } + }, + + /** + * Send error response from onRPCRequest + * + * @param {Number} + * resultCode + * @param {Number} + * id + * @param {String} + * method + */ + sendError: function(resultCode, id, method, message) { + + Em.Logger.log("FFW." + method + "Response"); + + if (resultCode != SDL.SDLModel.resultCode["SUCCESS"]) { + + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": id, + "error": { + "code": resultCode, // type (enum) from SDL protocol + "message": message, + "data": { + "method": method + } + } + }; + this.client.send(JSONMessage); } + }, + /** + * send response from onRPCRequest + * + * @param {Number} + * resultCode + * @param {Number} + * id + * @param {String} + * method + */ + sendVRResult: function(resultCode, id, method) { + + Em.Logger.log("FFW." + method + "Response"); + + if (resultCode === SDL.SDLModel.resultCode["SUCCESS"]) { + + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": id, + "result": { + "code": resultCode, // type (enum) from SDL protocol + "method": method + } + }; + this.client.send(JSONMessage); + } }, /* * send notification when command was triggered from VR */ - onChoise: function( commandId ) { - Em.Logger.log( "FFW.VR.PerformInteractionResponse" ); + onChoise: function(commandID) { + + Em.Logger.log("FFW.VR.PerformInteraction"); var JSONMessage = { "jsonrpc": "2.0", "method": "VR.OnChoise", "params": { - "choiceID": commandId + "choiceID": commandID } }; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); }, - /* + /** + * Initiated by VR module to let SDL know that VR session has started. + */ + Started: function() { + + Em.Logger.log("FFW.VR.Started"); + + var JSONMessage = { + "jsonrpc": "2.0", + "method": "VR.Started" + }; + this.client.send(JSONMessage); + }, + + /** + * Initiated by VR module to let SDL know that VR session has stopped. + */ + Stopped: function() { + + Em.Logger.log("FFW.VR.Stopped"); + + var JSONMessage = { + "jsonrpc": "2.0", + "method": "VR.Stopped" + }; + this.client.send(JSONMessage); + }, + + /** * send notification when command was triggered */ - onCommand: function( commandId, appId ) { - Em.Logger.log( "FFW.VR.onCommand" ); + onCommand: function(commandID, appID) { + + Em.Logger.log("FFW.VR.onCommand"); var JSONMessage = { "jsonrpc": "2.0", "method": "VR.OnCommand", "params": { - "cmdID": commandId, - "appId": appId + "cmdID": commandID, + "appID": appID } }; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); }, - /* + /** * Notifies if sdl VR components language was changed */ - OnLanguageChange: function( lang ) { - Em.Logger.log( "FFW.VR.OnLanguageChange" ); + OnLanguageChange: function(lang) { + + Em.Logger.log("FFW.VR.OnLanguageChange"); // send repsonse var JSONMessage = { @@ -295,6 +402,6 @@ FFW.VR = FFW.RPCObserver.create( { "language": lang } }; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); } -} )
\ No newline at end of file +})
\ No newline at end of file diff --git a/SDL_Core/src/components/HMI/ffw/VehicleInfoRPC.js b/SDL_Core/src/components/HMI/ffw/VehicleInfoRPC.js index 27fb9ce9a..6d969e0ca 100644 --- a/SDL_Core/src/components/HMI/ffw/VehicleInfoRPC.js +++ b/SDL_Core/src/components/HMI/ffw/VehicleInfoRPC.js @@ -2,15 +2,14 @@ * Copyright (c) 2013, Ford Motor Company All rights reserved. * * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * · Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * · Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * · Neither the name of the Ford Motor Company nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. + * modification, are permitted provided that the following conditions are met: · + * Redistributions of source code must retain the above copyright notice, this + * list of conditions and the following disclaimer. · Redistributions in binary + * form must reproduce the above copyright notice, this list of conditions and + * the following disclaimer in the documentation and/or other materials provided + * with the distribution. · Neither the name of the Ford Motor Company nor the + * names of its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE @@ -37,23 +36,33 @@ FFW.VehicleInfo = FFW.RPCObserver.create( { /** + * If true then VehicleInfo is present and ready to communicate with SDL. + * + * @type {Boolean} + */ + isReady: true, + + /** * access to basic RPC functionality */ client: FFW.RPCClient.create( { componentName: "VehicleInfo" - } ), + }), /** * connect to RPC bus */ connect: function() { - this.client.connect( this, 600 ); + + this.client.connect(this, 700); // Magic number is unique identifier for + // component }, /** * disconnect from RPC bus */ disconnect: function() { + this.client.disconnect(); }, @@ -62,7 +71,8 @@ FFW.VehicleInfo = FFW.RPCObserver.create( { * time */ onRPCRegistered: function() { - Em.Logger.log( "FFW.VehicleInfo.onRPCRegistered" ); + + Em.Logger.log("FFW.VehicleInfo.onRPCRegistered"); this._super(); }, @@ -70,7 +80,8 @@ FFW.VehicleInfo = FFW.RPCObserver.create( { * Client is unregistered - no more requests */ onRPCUnregistered: function() { - Em.Logger.log( "FFW.VehicleInfo.onRPCUnregistered" ); + + Em.Logger.log("FFW.VehicleInfo.onRPCUnregistered"); this._super(); }, @@ -87,24 +98,27 @@ FFW.VehicleInfo = FFW.RPCObserver.create( { * previously store reuqestID to determine to which request repsonse belongs * to */ - onRPCResult: function( response ) { - Em.Logger.log( "FFW.VehicleInfo.onRPCResult" ); + onRPCResult: function(response) { + + Em.Logger.log("FFW.VehicleInfo.onRPCResult"); this._super(); }, /** * handle RPC erros here */ - onRPCError: function( error ) { - Em.Logger.log( "FFW.VehicleInfo.onRPCError" ); + onRPCError: function(error) { + + Em.Logger.log("FFW.VehicleInfo.onRPCError"); this._super(); }, /** * handle RPC notifications here */ - onRPCNotification: function( notification ) { - Em.Logger.log( "FFW.VehicleInfo.onRPCNotification" ); + onRPCNotification: function(notification) { + + Em.Logger.log("FFW.VehicleInfo.onRPCNotification"); this._super(); }, @@ -113,60 +127,260 @@ FFW.VehicleInfo = FFW.RPCObserver.create( { * * @type {Object} request */ - onRPCRequest: function( request ) { - Em.Logger.log( "FFW.VehicleInfo.onRPCRequest" ); - this._super(); + onRPCRequest: function(request) { + + Em.Logger.log("FFW.VehicleInfo.onRPCRequest"); + if (this.validationCheck(request)) { + + switch (request.method) { + case "VehicleInfo.GetVehicleData": { + + SDL.SDLVehicleInfoModel.getVehicleData(request); + + break; + } + + case "VehicleInfo.ReadDID": { + + SDL.SDLVehicleInfoModel.vehicleInfoReadDID(request.params, + request.id); + + break; + } + + case "VehicleInfo.GetDTCs": { + + SDL.SDLVehicleInfoModel.vehicleInfoGetDTCs(request.params, + request.id); + + break; + } + + case "VehicleInfo.DiagnosticMessage": { + + Em.Logger.log("FFW." + request.method + "Response"); + + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": request.id, + "result": { + "messageDataResult": [200], + "code": SDL.SDLModel.resultCode["SUCCESS"], + "method": "VehicleInfo.DiagnosticMessage" + } + }; + + this.client.send(JSONMessage); + + break; + + break; + } + + case "VehicleInfo.SubscribeVehicleData": { + + SDL.SDLVehicleInfoModel.SubscribeVehicleData(request); + + break; + } + + case "VehicleInfo.UnsubscribeVehicleData": { - if( request.method == "VehicleInfo.GetVehicleData" ){ + SDL.SDLVehicleInfoModel.UnsubscribeVehicleData(request); - var vehicleData = SDL.SDLVehicleInfoModel.getVehicleData( request.params ), resultCode; + break; + } + + case "VehicleInfo.GetVehicleType": { + + SDL.SDLVehicleInfoModel.getVehicleType(request.id); + + break; + } - if( vehicleData ){ - resultCode = "SUCCESS"; - }else{ - resultCode = "GENERIC_ERROR"; + case "VehicleInfo.IsReady": { + + Em.Logger.log("FFW." + request.method + "Response"); + + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": request.id, + "result": { + "available": this.get('isReady'), + "code": SDL.SDLModel.resultCode["SUCCESS"], + "method": "VehicleInfo.IsReady" + } + }; + + this.client.send(JSONMessage); + + break; } + default: { + // statements_def + break; + } + } + } + }, + + /** + * Send error response from onRPCRequest + * + * @param {Number} + * resultCode + * @param {Number} + * id + * @param {String} + * method + */ + sendError: function(resultCode, id, method, message) { + + Em.Logger.log("FFW." + method + "Response"); + + if (resultCode != SDL.SDLModel.resultCode["SUCCESS"]) { + // send repsonse var JSONMessage = { "jsonrpc": "2.0", - "id": request.id, - "result": { - "resultCode": resultCode, // type (enum) from SDL protocol - "method": "VehicleInfo.GetVehicleDataResponse" - // request.params.dataType: vehicleData + "id": id, + "error": { + "code": resultCode, // type (enum) from SDL protocol + "message": message, + "data": { + "method": method + } } }; - JSONMessage.result[SDL.SDLVehicleInfoModel.vehicleData[request.params.dataType].type] = vehicleData; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); } + }, - if( request.method == "VehicleInfo.ReadDID" ){ + /** + * Send response from onRPCRequest + * + * @param {Number} + * resultCode + * @param {Number} + * id + * @param {String} + * method + */ + sendVIResult: function(resultCode, id, method) { - SDL.SDLVehicleInfoModel.vehicleInfoReadDID( request.params, request.id ); + Em.Logger.log("FFW." + method + "Response"); + if (resultCode === SDL.SDLModel.resultCode["SUCCESS"]) { + + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": id, + "result": { + "code": resultCode, + "method": method + } + }; + this.client.send(JSONMessage); } + }, - if( request.method == "VehicleInfo.GetDTCs" ){ + /** + * Send response from onRPCRequest + * + * @param {Number} resultCode + * @param {Number} id + * @param {String} method + * @param {Object} data + */ + sendVISubscribeVehicleDataResult: function(resultCode, id, method, data) { - SDL.SDLVehicleInfoModel.vehicleInfoGetDTCs( request.params, request.id ); + Em.Logger.log("FFW." + method + "Response"); + if (resultCode === SDL.SDLModel.resultCode["SUCCESS"]) { + + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": id, + "result": data + }; + + JSONMessage.result.code = resultCode; + JSONMessage.result.method = method; + + this.client.send(JSONMessage); } + }, - if( request.method == "VehicleInfo.GetVehicleType" ){ + /** + * Send error response from onRPCRequest + * + * @param {Number} + * resultCode + * @param {Number} + * id + * @param {String} + * method + */ + sendGetVehicleDataError: function(resultCode, id, method, message, data) { - SDL.SDLVehicleInfoModel.getVehicleType( request.id ); + Em.Logger.log("FFW." + method + "Response"); + + if (resultCode != SDL.SDLModel.resultCode["SUCCESS"]) { + + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": id, + "error": { + "code": resultCode, // type (enum) from SDL protocol + "message": message, + "data": data + } + }; + JSONMessage.error.data.method = method; + this.client.send(JSONMessage); } }, /** + * Send error response from onRPCRequest + * + * @param {Number} + * resultCode + * @param {Number} + * id + * @param {String} + * method + */ + sendGetVehicleDataResut: function(resultCode, id, method, data) { + + Em.Logger.log("FFW." + method + "Response"); + + // send repsonse + var JSONMessage = { + "jsonrpc": "2.0", + "id": id, + "result": data + }; + JSONMessage.result.code = resultCode; + JSONMessage.result.method = method; + this.client.send(JSONMessage); + }, + + /** * Notifies if data was changed * * @type {Object} params */ - OnVehicleData: function( params ) { - Em.Logger.log( "FFW.VehicleInfo.OnVehicleData" ); + OnVehicleData: function(params) { + + Em.Logger.log("FFW.VehicleInfo.OnVehicleData"); // send repsonse var JSONMessage = { @@ -174,7 +388,7 @@ FFW.VehicleInfo = FFW.RPCObserver.create( { "method": "VehicleInfo.OnVehicleData", "params": params }; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); }, /** @@ -183,20 +397,21 @@ FFW.VehicleInfo = FFW.RPCObserver.create( { * @type {string} vehicleType * @type {int} id */ - GetVehicleTypeResponse: function( vehicleType, id ) { - Em.Logger.log( "FFW.VehicleInfo.GetVehicleType" ); + GetVehicleTypeResponse: function(vehicleType, id) { + + Em.Logger.log("FFW.VehicleInfo.GetVehicleTypeResponse"); var JSONMessage = { "jsonrpc": "2.0", "id": id, "result": { - "resultCode": "SUCCESS", // type (enum) from SDL protocol - "method": "VehicleInfo.GetVehicleTypeResponse", + "code": SDL.SDLModel.resultCode["SUCCESS"], + "method": "VehicleInfo.GetVehicleType", "vehicleType": vehicleType } }; - this.client.send( JSONMessage ); + this.client.send(JSONMessage); }, /** @@ -208,72 +423,52 @@ FFW.VehicleInfo = FFW.RPCObserver.create( { * @type {string} result * @type {int} id */ - vehicleInfoReadDIDResponse: function( dataResult, data, info, result, id ) { - Em.Logger.log( "FFW.VehicleInfo.ReadDID" ); + vehicleInfoReadDIDResponse: function(didResult, resultCode, id) { + + Em.Logger.log("FFW.VehicleInfo.ReadDIDResponse"); var JSONMessage; // send repsonse - if( result != 'ENCRYPTED' ){ - JSONMessage = { - "jsonrpc": "2.0", - "id": id, - "result": { - "resultCode": result, // type (enum) from SDL protocol - "method": "VehicleInfo.ReadDIDResponse", - "info": info, - "dataResult": dataResult, - "data": data - } - }; - }else{ - JSONMessage = { - "jsonrpc": "2.0", - "id": id, - "result": { - "resultCode": result, // type (enum) from SDL protocol - "method": "VehicleInfo.ReadDIDResponse", - "info": info - } - }; - } - this.client.send( JSONMessage ); + JSONMessage = { + "jsonrpc": "2.0", + "id": id, + "result": { + "code": SDL.SDLModel.resultCode[resultCode], // type (enum) + // from SDL + // protocol + "method": "VehicleInfo.ReadDID", + "didResult": didResult + } + }; + this.client.send(JSONMessage); }, /** * GetDTCs Response * - * @type {array} data - * @type {string} info - * @type {string} result - * @type {int} id + * @type {Number} ecuHeader + * @type {Array} dtc + * @type {String} result + * @type {Number} id */ - vehicleInfoGetDTCsResponse: function( data, info, result, id ) { - Em.Logger.log( "FFW.VehicleInfo.GetDTCs" ); + vehicleInfoGetDTCsResponse: function(ecuHeader, dtc, result, id) { + + Em.Logger.log("FFW.VehicleInfo.GetDTCsResponse"); var JSONMessage; // send repsonse - if( result != 'ENCRYPTED' ){ - JSONMessage = { - "jsonrpc": "2.0", - "id": id, - "result": { - "resultCode": result, // type (enum) from SDL protocol - "method": "VehicleInfo.GetDTCsResponse", - "info": info, - "dtcList": data - } - }; - }else{ - JSONMessage = { - "jsonrpc": "2.0", - "id": id, - "result": { - "resultCode": result, // type (enum) from SDL protocol - "method": "VehicleInfo.GetDTCsResponse", - "info": info - } - }; - } - this.client.send( JSONMessage ); + JSONMessage = { + "jsonrpc": "2.0", + "id": id, + "result": { + "code": SDL.SDLModel.resultCode[result], // type (enum) from + // SDL protocol + "method": "VehicleInfo.GetDTCs", + "ecuHeader": ecuHeader, + "dtc": dtc + } + }; + + this.client.send(JSONMessage); } -} )
\ No newline at end of file +})
\ No newline at end of file diff --git a/SDL_Core/src/components/HMI/ffw/WebSocket.js b/SDL_Core/src/components/HMI/ffw/WebSocket.js index c126f3c09..7b508b406 100755..100644 --- a/SDL_Core/src/components/HMI/ffw/WebSocket.js +++ b/SDL_Core/src/components/HMI/ffw/WebSocket.js @@ -1,75 +1,77 @@ -/* - * Copyright (c) 2013, Ford Motor Company All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: - * · Redistributions of source code must retain the above copyright notice, - * this list of conditions and the following disclaimer. - * · Redistributions in binary form must reproduce the above copyright notice, - * this list of conditions and the following disclaimer in the documentation - * and/or other materials provided with the distribution. - * · Neither the name of the Ford Motor Company nor the names of its - * contributors may be used to endorse or promote products derived from this - * software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - */ -/* - * WebSocket interface mockup - * - * Android WebView and browser don't support WebSocket This class provides - * interface mockup to have seamless code for different platforms - * JavaScriptFacade is used instead of real WebSocket connection - * - */ - -FFW.WebSocket = Em.Object.extend( { - - readyState: 1, - - /* - * add observer of messages from Android - */ - init: function() { - FFW.WebSocketSimulator.addClient( this ); - }, - - /* - * remove observer of Android messages on connection close - */ - close: function() { - FFW.WebSocketSimulator.removeClient( this ); - // simulate connection is closed - this.onclose( null ); - }, - - /* - * send message to Android native code Java Script facade is used instead of - * real WebSocket connection - */ - send: function( jsonMessage ) { - FFW.WebSocketSimulator.send( this.clientName, jsonMessage ); - }, - - // handlers for web socket events - onclose: null, - onerror: null, - onmessage: null, - onopen: null, - - /* - * used for identification of sender and receiver of particular message - * from/to Android - */ - clientName: '' -} ); +/*
+ * Copyright (c) 2013, Ford Motor Company All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met: ·
+ * Redistributions of source code must retain the above copyright notice, this
+ * list of conditions and the following disclaimer. · Redistributions in binary
+ * form must reproduce the above copyright notice, this list of conditions and
+ * the following disclaimer in the documentation and/or other materials provided
+ * with the distribution. · Neither the name of the Ford Motor Company nor the
+ * names of its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+/*
+ * WebSocket interface mockup
+ *
+ * Android WebView and browser don't support WebSocket This class provides
+ * interface mockup to have seamless code for different platforms
+ * JavaScriptFacade is used instead of real WebSocket connection
+ *
+ */
+
+FFW.WebSocket = Em.Object.extend( {
+
+ readyState: 1,
+
+ /*
+ * add observer of messages from Android
+ */
+ init: function() {
+
+ FFW.WebSocketSimulator.addClient(this);
+ },
+
+ /*
+ * remove observer of Android messages on connection close
+ */
+ close: function() {
+
+ FFW.WebSocketSimulator.removeClient(this);
+ // simulate connection is closed
+ this.onclose(null);
+ },
+
+ /*
+ * send message to Android native code Java Script facade is used instead of
+ * real WebSocket connection
+ */
+ send: function(jsonMessage) {
+
+ FFW.WebSocketSimulator.send(this.clientName, jsonMessage);
+ },
+
+ // handlers for web socket events
+ onclose: null,
+ onerror: null,
+ onmessage: null,
+ onopen: null,
+
+ /*
+ * used for identification of sender and receiver of particular message
+ * from/to Android
+ */
+ clientName: ''
+});
|