2 * Copyright (c) 2012, Intel Corporation.
4 * This program is licensed under the terms and conditions of the
5 * Apache License, version 2.0. The full text of the Apache License is at
6 * http://www.apache.org/licenses/LICENSE-2.0
10 /* ---------------------- vehicle event typedef --------------------------- */
12 function VehicleEventType()
24 "ExteriorTemperature",
28 "InteriorTemperature",
36 "TransmissionShiftPosition",
42 /* set random initial values for all the props */
45 var prop = this.event[i];
46 this.value[prop] = Math.floor(Math.random() * 1000000);
50 VehicleEventType.prototype.getSupportedEventList = function(val)
52 /* for undefined just assume everything */
53 if((val == undefined)||(val === ""))
56 /* grab every event with case insensitive prefix of val */
57 var value = val.toLowerCase();
61 var prop = this.event[i].toLowerCase();
62 if(prop.indexOf(value) === 0)
64 list[list.length] = prop;
68 /* if the target val isn't alone, remove it, it's a grouping */
69 var idx = list.indexOf(value);
70 if((idx >= 0)&&(list.length > 1))
77 VehicleEventType.prototype.getValueEventList = function(val)
79 var i, j, list = this.getSupportedEventList(val);
80 for(i = 0; i < list.length; i++)
82 for(j = i + 1; j < list.length; j++)
84 if(list[j].indexOf(list[i]) === 0)
94 VehicleEventType.prototype.getValuesEventList = function(vals)
97 for(i = 0; i < vals.length; i++)
99 var sublist = this.getValueEventList(vals[i]);
100 for(j = 0; j < sublist.length; j++)
102 if(list.indexOf(sublist[j]) < 0)
104 list[list.length] = sublist[j];
111 VehicleEventType.prototype.isValueEvent = function(val)
113 var list = this.getValueEventList(val);
114 return(list.length === 1);
117 VehicleEventType.prototype.getValue = function(prop)
119 return this.value[prop];
122 VehicleEventType.prototype.isValid = function(prop)
124 return (this.event.indexOf(prop) >= 0);
127 VehicleEventType.prototype.setValue = function(prop, newval)
129 this.value[prop] = newval;