2 * Copyright (c) 2013, Ford Motor Company All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 * · Redistributions of source code must retain the above copyright notice,
7 * this list of conditions and the following disclaimer.
8 * · Redistributions in binary form must reproduce the above copyright notice,
9 * this list of conditions and the following disclaimer in the documentation
10 * and/or other materials provided with the distribution.
11 * · Neither the name of the Ford Motor Company nor the names of its
12 * contributors may be used to endorse or promote products derived from this
13 * software without specific prior written permission.
15 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 * POSSIBILITY OF SUCH DAMAGE.
28 * @name SDL.SDLVehicleInfoModel
29 * @desc SDL model with vehicle information used instead of CAN network.
30 * VehicleInfoModel is simulation of real CAN network.
32 * @filesource app/model/sdl/SDLVehicleInfoModel.js
36 SDL.SDLVehicleInfoModel = Em.Object.create( {
39 * Stored VehicleInfo transmission state Data
57 prndlSelectState: 'PARK',
60 * Stored VehicleInfo Data
67 'data': "ECU 1 Test Data"
70 'data': "ECU 2 Test Data"
75 * Type of current vehicle: make of the vehicle, model of the vehicle, model
76 * Year of the vehicle, trim of the vehicle.
88 * Stored VehicleInfo Data
93 'VEHICLEDATA_SPEED': {
97 'VEHICLEDATA_ENGINERPM': {
101 'VEHICLEDATA_FUELLEVEL': {
105 'VEHICLEDATA_FUELECONOMY': {
107 type: 'avgFuelEconomy'
109 'VEHICLEDATA_BATTVOLTS': {
111 type: 'batteryVoltage'
113 'VEHICLEDATA_EXTERNTEMP': {
115 type: 'externalTemperature'
118 data: '52-452-52-752',
121 'VEHICLEDATA_PRNDLSTATUS': {
125 'VEHICLEDATA_BATTERYPACKVOLTAGE': {
127 type: 'batteryPackVoltage'
129 'VEHICLEDATA_BATTERYCURRENT': {
131 type: 'batteryPackCurrent'
133 'VEHICLEDATA_BATTERYTEMPERATURE': {
135 type: 'batteryPackTemperature'
137 'VEHICLEDATA_ENGINETORQUE': {
141 'VEHICLEDATA_ODOMETER': {
145 'VEHICLEDATA_TRIPODOMETER': {
149 'VEHICLEDATA_GENERICBINARY': {
151 type: 'genericbinary'
153 'VEHICLEDATA_SATESN': {
157 'VEHICLEDATA_RAINSENSOR': {
163 'longitudeDegrees': 423293,
164 'latitudeDegrees': -830464,
171 'compassDirection': 'SOUTHWEST',
187 * Method to set selected state of vehicle transmission to vehicleData
189 onPRNDLSelected: function() {
190 if( this.prndlSelectState ) {
191 this.set( 'vehicleData.VEHICLEDATA_PRNDLSTATUS.data', this.prndlSelectState );
193 }.observes( 'this.prndlSelectState' ),
196 * Method calls GetVehicleType response
200 getVehicleType: function( id ) {
201 FFW.VehicleInfo.GetVehicleTypeResponse( this.vehicleType, id );
205 * SDL VehicleInfo.GetDTCs handler fill data for response about vehicle
208 * @type {Object} params
211 vehicleInfoGetDTCs: function( params, id ) {
212 var data = [], i = 0, info = "Inormation about reported DTC's", result = "";
214 for( i = 0; i < 3; i++ ){
215 data.push( params.encrypted ? "0" : {
223 if( params.encrypted ){
224 result = 'ENCRYPTED';
225 FFW.BasicCommunication.SendData( data );
226 FFW.VehicleInfo.vehicleInfoGetDTCsResponse( null, info, result, id );
228 FFW.VehicleInfo.vehicleInfoGetDTCsResponse( data, info, result, id );
233 * SDL VehicleInfo.ReadDID handler send response about vehicle conditions
235 * @type {Object} params
238 vehicleInfoReadDID: function( params, id ) {
239 var data = [], i = 0, info = '', dataResult = [], resultCode = "";
240 // magic number used because there is no huge database on HMI of vehicle
242 if( this.ecuDIDData[1].data ){
243 info = this.ecuDIDData[1].data;
246 result = "INVALID_DATA";
249 for( i = 0; i < params.didLocation.length; i++ ){
251 dataResult[i] = 'SUCCESS';
254 dataResult[i] = "INVALID_DATA";
259 if( params.encrypted ){
260 result = 'ENCRYPTED';
261 FFW.BasicCommunication.SendData( data );
262 FFW.VehicleInfo.vehicleInfoReadDIDResponse( null, null, info, result, id );
264 FFW.VehicleInfo.vehicleInfoReadDIDResponse( dataResult, data, info, result, id );
269 * Function returns response message to VehicleInfoRPC
271 * @type {Object} message
273 getVehicleData: function( message ) {
275 return this.vehicleData[message.dataType].data;
280 * Function send all vehicle conditions on FFW.VehicleInfo.OnVehicleData fo
281 * notification when data changes
283 onVehicleDataChanged: function() {
286 for( var i in this.vehicleData ){
287 jsonData[this.vehicleData[i].type] = this.vehicleData[i].data;
289 FFW.VehicleInfo.OnVehicleData( jsonData );
291 }.observes( 'this.vehicleData.VEHICLEDATA_PRNDLSTATUS.data' )