Programming Guide (JScript)



Yüklə 6,96 Mb.
Pdf görüntüsü
səhifə6/22
tarix07.11.2018
ölçüsü6,96 Mb.
#78683
1   2   3   4   5   6   7   8   9   ...   22

14
1.  
2.  
  var grayid = Event.SourceId;
  var grayname = GetObjectName("GRAY", grayid);
  var compname = GetObjectParentId("GRAY", grayid, "COMPUTER");
  DoReactStr("DIALOG", "test", "CLOSE_ALL","");
  DoReactStr("DIALOG", "test", "RUN","Alarm in the '" + grayname + "' sensor connected to the '" + compname + "' 
server."); 
}
The GetObjectState method
The GetObjectState method returns the state of the object at the moment of method call.
Method call syntax
function  GetObjectState(objtype : String, id : String) : String
Method arguments:
objtype - Required argument. The type of the object whose state is to be returned. It takes the following values:  Type – String, range – existing object types.
id - Required argument. Identification number of the object of the type set in the objtype argument. It takes the following values:  Type – String, range – existing identification 
numbers of the objects of the specified type.
Usage examples
Problem. When Relay 1 activates (for example, on pressing the button connected to Relay 1), arm Sensor 1. The next time Relay 1 activates, disarm Sensor 1.
 if (Event.SourceType == "GRELE" && Event.SourceId == "1" && Event.Action == "ON")
{
  if(GetObjectState("GRAY", "1")=="DISARM")
  {
    SetObjectState("GRAY", "1", "ARM");
  }
  else
  {
    SetObjectState("GRAY", "1", "DISARM");
  }
}


15
1.  
2.  
3.  
1.  
2.  
3.  
The GetObjectParam method
The GetObjectParam method returns the value of the specified parameter of the object at the moment of method call.
Method call syntax
 function  GetObjectParam(objtype : String, id : String, param : String) : String
Method arguments:
objtype - Required argument. The type of the object whose parameter’s value is to be returned. It takes the following values:  Type – String, range – existing object types.
id - Required argument. Identification number of the object of the type set in the objtype argument. It takes the following values:  Type – String, range – existing identification 
numbers of the objects of the specified type.
param - Required argument. The name of the parameter whose value is to be returned. It takes the following values:  Type – String, range – available parameters of the 
object.
Usage examples
See the example for the SetObjectParam method.
The GetObjectParentId method
The GetObjectParentId method returns the identification number of the parent of the specified object.
Method call syntax
 function  GetObjectParentId(objtype : String, id : String, parent : String) : String
Method arguments:
objtype - Required argument. The type of the object whose parent’s identification number should be returned. It takes the following values:  Type – String, range – existing 
object types.
id - Required argument. Identification number of the object of the type set in the objtype argument. It takes the following values:  Type – String, range – existing identification 
numbers of the objects of the specified type.
parent - Required argument. The type of the object which is the parent of the object type specified by the objtype argument. It takes the following values:  Type – String, 
range – existing object types.
Usage examples
Problem. If a camera turns off or stops transmitting a video signal, send an e-mail message with the following subject: "Warning! Camera turned off" and, in the message body, the 
number of the camera and of the server it is connected to.


16
1.  
2.  
3.  
4.  
if (Event.SourceType == "CAM" && Event.Action == "DETACH")
{
    var cam_id = Event.SourceId;
    var parent_comp_id = GetObjectParentId("CAM", cam_id, "COMPUTER");
    DoReactStr("MAIL_MESSAGE","1","SETUP","from<***@mail.ru>,to<***@mail.ru>,bodythe Server"+parent_comp_id+">,parent_id<1>,subject,name,objname1>");
    DoReactStr("MAIL_MESSAGE", "1", "SEND", "");
}
The DoReactStr method
The DoReactStr method generates the response actions for the objects. It sends the action to the specified object. The action is transferred directly to the kernel where the object 
belongs, and not to the whole system. The action is specified as a group of String arguments.
Method call syntax
 function  DoReactStr(objtype : String,  id : String,  action : String,  param  [, param] : String)
Method arguments:
objtype - Required argument. The type of the object that the action should be generated for. It takes the following values:  Type – String, range – existing object types.
id - Required argument. Identification number of the object of the type set in the objtype argument. It takes the following values:  Type – String, range – existing identification 
numbers of the objects of the specified type.
action - Required argument. The action to be generated. It takes the following values:  Type – String, range – available actions for the objects of the specified type.
param - Required argument. Several arguments of this type can be specified. The parameters of the action.
One parameter has the following syntax:
"param", where
param – name of the parameter;
value – value of the parameter.
Several parameters have the following syntax:
Note
 The Short Messages Service is supposed to be installed and working properly


Yüklə 6,96 Mb.

Dostları ilə paylaş:
1   2   3   4   5   6   7   8   9   ...   22




Verilənlər bazası müəlliflik hüququ ilə müdafiə olunur ©genderi.org 2024
rəhbərliyinə müraciət

    Ana səhifə