this.socketProtocol = "http-only";
/* override the websocket address if parameters are given */
- if(url != undefined) this.socketUrl = url;
- if(protocol != undefined) this.socketProtocol = protocol;
+ if(url !== undefined) this.socketUrl = url;
+ if(protocol !== undefined) this.socketProtocol = protocol;
this.VehicleMethodCall = function(id, name, successCB, errorCB)
{
this.start = function()
{
me.timeout = setTimeout(function(){
- if(me.errorCB != undefined)
+ if(me.errorCB !== undefined)
{
me.errorCB("\""+me.name+"\" method timed out after "+self.timeouttime+"ms");
}
}
this.finish = function()
{
- if(me.timeout != undefined)
+ if(me.timeout !== undefined)
{
clearTimeout(me.timeout);
}
{
if(!this.connected)
{
- if(errorCB != undefined)
+ if(errorCB !== undefined)
{
errorCB("\""+obj.name+"\" method failed because socket is closed");
}
this.send(obj, successCB, errorCB);
}
+Vehicle.prototype.getHistory = function(namelist, beginDate, endDate, successCB, errorCB)
+{
+ if(namelist.length <= 0)
+ {
+ return;
+ }
+
+ var dataobj = {
+ "property" : namelist,
+ "timeBegin" : (beginDate.getTime() / 1000).toString(),
+ "timeEnd" : (endDate.getTime() / 1000).toString(),
+ "sequenceBegin" : "-1",
+ "sequenceEnd" : "-1"
+ }
+
+ var obj = {
+ "type" : "method",
+ "name": "getRanged",
+ "transactionid" : this.generateTransactionId(),
+ "data" : dataobj
+ };
+ this.send(obj, successCB, errorCB);
+}
+
Vehicle.prototype.set = function(namelist, valuelist, successCB, errorCB)
{
if((namelist.length != valuelist.length)||(namelist.length <= 0))
return;
}
- if((event == undefined)||(event.type == undefined)||
- (event.name == undefined))
+ if((event === undefined)||(event.type === undefined)||
+ (event.name === undefined))
{
self.iErrorCB("BADLY FORMED MESSAGE: "+msg);
return;
if(call&&(!call.done)&&(call.transactionid === event.transactionid))
{
call.finish();
- if(event.error != undefined)
+ if(event.error !== undefined)
{
call.errorCB(event.error);
}
- if(event.data != undefined)
+ if(event.data !== undefined && call.successCB !== undefined)
{
call.successCB(event.data);
}