Programming Guide (JScript)



Yüklə 6,96 Mb.
Pdf görüntüsü
səhifə12/22
tarix07.11.2018
ölçüsü6,96 Mb.
#78683
1   ...   8   9   10   11   12   13   14   15   ...   22

38
 if(Event.GetSourceType() == "MACRO" && Event.GetAction() == "RUN")
{
  var k;
  //Switching the cameras to the Day mode by arming the *.1 detection zones
  if(Event.GetSourceId() == "1")
  {
for (k = 1;  k<= 4;  k = k+1)
    {
      DoReactStr("CAM_ZONE", k + ".1", "ARM", "");
      DoReactStr("CAM_ZONE", k + ".2", "DISARM", "");
      DoReactStr("CAM_ZONE", k + ".3", "DISARM", "");
    }
  }
 
  //Switching the cameras to the Nigh mode by arming the *.2 detection zones
  if(Event.GetSourceId() == "2")
  {
    for (k = 1;  k<= 4;  k = k+1)
    {
      DoReactStr("CAM_ZONE", k + ".1", "DISARM", "");
      DoReactStr("CAM_ZONE", k + ".2", "ARM", "");
      DoReactStr("CAM_ZONE", k + ".3", "DISARM", "");
    }
  }
 
  //Switching the cameras to the Rain mode by arming the *.3 detection zones
  if(Event.GetSourceId() == "3")
  {
    for (k = 1;  k<= 4;  k = k+1)
    {
      DoReactStr("CAM_ZONE", k + ".1", "DISARM", "");
      DoReactStr("CAM_ZONE", k + ".2", "DISARM", "");
      DoReactStr("CAM_ZONE", k + ".3", "ARM", "");
    }
  }
}


39
MsgObject_Event_Method_call_syntax__function_SetParam(param_:_String,_value_:_String)_Method_arguments:_param'>MsgObject_Method_call_syntax__function_GetAction()_:_String_Method_arguments:_no_arguments_Usage_examples'>MsgObject_Event_object_Method_call_syntax'>The GetSourceId method
The GetSourceId method returns the identification number of the 
 or 
.
MsgObject
Event object
Method call syntax
 function  GetSourceId() : String
Method arguments: no arguments.
Usage examples
See the example for the GetSourceType method.
The GetAction method
The GetAction method returns the event received as an Event object or specified for a 
 object.
MsgObject
Method call syntax
 function  GetAction() : String
Method arguments: no arguments
Usage examples
See the example for the GetSourceType method.
The GetParam method
The GetParam method returns the value of the specified parameter of the 
 or 
 object.
MsgObject
Event
Method call syntax
 function  GetParam(param: String) : String
Method arguments:
param  
 - required argument. The name of the parameter of the object created using 
 (or of the 
 object). It takes the following values:  type – String, range – 
MsgObject
Event
available parameters for the objects of the specified type.


40
1.  
2.  
Example. When any event from any camera is registered, check from which computer the event comes. If the computer has “WS3” name, create the event copy where the computer’s 
name is “Computer”.
 if (Event.SourceType == "CAM")
{
var msg = Event.Clone();
if (msg.GetParam("slave_id") == "WS3")
{
msg.SetParam("slave_id", "Computer");
NotifyEvent(msg);
}
}
The SetParam method
The SetParam method assigns a value to the specified parameter of the 
 or 
 object. It changes only the specified parameters, leaving other parameters intact.
MsgObject
Event
Method call syntax
 function  SetParam(param : String,  value : String)
Method arguments:
param - Required argument. The name of the parameter of the object created using 
 (or of the 
 object). It takes the following values:  Type – String, range – 
MsgObject
Event
available parameters for the objects of the specified type.
value - Required argument. The value to be assigned to the parameter specified in the param argument. It takes the following values:  Type – String, range – depends on the 
parameter.
Usage examples
See the example for the 
.
GetParam method
The MsgToString method
The MsgToString method transforms 
 objects (including the static 
 object) into a String variable.
MsgObject
Event
Method call syntax
Note
 If the object has no parameter with this name, then the method restores an empty string


41
 function  MsgToString() : String
Method arguments: no arguments.
Usage examples
Problem. Send the messages about all events registered for Microphone 1, to a specified e-mail address.
 if (Event.SourceType == "OLXA_LINE" && Event.SourceId == "1")
{
  var msgstr = Event.MsgToString();
DoReactStr("MAIL_MESSAGE", "1", "SEND", "subject,body<" + msgstr + ">");
DoReactStr("MAIL_MESSAGE", "1", "SEND", "");
}
The StringToMsg method
The StringToMsg method transforms a String variable into an 
 object.
MsgObject
Method call syntax
StringToMsg(msg : String) : MsgObject
Method arguments:
msg - Required argument. A String type variable to be transformed into an 
 object. It takes the following values:  Type – String; range – character string that matches the 
MsgObject
syntax for 
 representation:
MsgObject
"objtype|id|action|param1,param2…", where
objtype – object type;
id – object identification number;
action – event or action for the object;
Note
The 
 is supposed to be installed and working properly.
Short Messages Service


42
param1,param2 - list of parameters and their values. Elements of the list are separated by commas with no white space. If no parameters need to be specified, 
an empty string is used after the vertical line (|), for example:
"CAM|1|MD_START|"
Usage examples
Problem. Upon an alarm in Sensor 1 or 3, start recording audio from Microphone 1. Upon an alarm in Sensor 2 or 4, start recording audio from Microphone 2.
 if (Event.SourceType == "GRAY" && Event.Action == "ALARM")
{
  var audioid;
  if (Event.SourceId == "1" || Event.SourceId == "3")
  {
    audioid = "1";
  }
  if (Event.SourceId == "2" || Event.SourceId == "4")
  {
    audioid = "2";
  }
  var str = "OLXA_LINE|"+audioid+"|ARM|";
  var msg = CreateMsg();
  msg.StringToMsg(str);
  NotifyEvent(msg);
}
The StringToParams method
The StringToParams method transforms a String variable into the list of parameters and overwrites the existing parameter list of the
 object.
 MsgObject
Method call syntax
 StringToParams(String params)
Method arguments:
params - Required argument. A String type variable to be transformed into a list of parameters for the 
 object. It takes the following values:  String variables matching the 
MsgObject
syntax for 
 parameter list representation:
MsgObject


Yüklə 6,96 Mb.

Dostları ilə paylaş:
1   ...   8   9   10   11   12   13   14   15   ...   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ə