Programming Guide (JScript)



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

6
1.  
2.  
3.  
Example. When Macro 1 starts, check if Cameras 1 to 4 are set to broadcast color video. If a camera is set for black-and-white video broadcast, then switch it to the color mode 
(setting the true (“1”) value to the “Color” parameter – (“color”)).
if (Event.SourceType == "MACRO" && Event.SourceId == "1"  && Event.Action == "RUN")
{
  var i;
  for(i=1; i<=4; i=i+1)
  {
    if (GetObjectParam("CAM", i , "color") == "0")
    {
      SetObjectParam("CAM", i, "color", "1");
    }
  }
}
The SetObjectState method
The SetObjectState method changes the state of objects.
Method call syntax
function  SetObjectState(objtype : String, id : String, state : String)
Method arguments:
objtype - Required argument. The type of the object whose state is to be changed. 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 parameter. It takes the following values:  Type – String, range – existing object 
identification numbers of the specified type.
state - Required argument. The state to switch the object to. It takes the following values:  Type – String, range – available states of the object.
Usage examples
Note
If the object is active when the script is started (i.e. the setting panel of this object is open), then object parameters can not be changed by the SetObjectParam method. For 
instance, if the setting panel for the Camera 1 object is open and the aforecited script is started, the operation mode of Camera 1 will not be changed for the color one.


7
Example. Check if Camera 1 is armed every hour. If Camera 1 is disarmed, arm it.
if (Event.SourceType == "TIMER" && Event.SourceId == "1" && Event.Action == "TRIGGER")
{
  if (GetObjectState("CAM", "1") == "DISARMED")
  {
    SetObjectState("CAM", "1", "ARMED");
  }
}
The DebugLogString method
The DebugLogString method outputs the user messages into the debug windows of the Editor-Debugger utility.
Method call syntax
function  DebugLogString(output : String)
Method arguments:
output - Required argument. The text message to be displayed in the debug window of the Editor-Debugger utility. It takes the following values:  Type – String.
Usage examples
Problem. Output to the debugger window all microphone events registered by the system.
if (Event.SourceType == "OLXA_LINE")
{
  var msgstr = Event.MsgToString();
  DebugLogString("Event from the microphone " + msgstr);
}
Note
The Timer object with identification number 1 should be created beforehand. Set the Minutes parameter of the Timer object to 30.The timer would go off every hour at half 
past the hour - 09:30, 10:30, 11:30, etc.


8
1.  
2.  
The Base64Decode method
The Base64Decode method is used for decoding the lines that are coded by Base64 scheme.
Method call syntax
function Base64Decode(data_in: String, WideChar: Boolean)
Method arguments:
data_in - required argument. Set a line that should be decoded in Base64;
WideChar - required argument. Determines coding type. Can take 0 or 1 values. If coding type is Unicode, argument value is 1, otherwise 0.
Usage examples
Decode the line that is set in Base64 by starting macro №1. Output the decoding result into the debug windows of the Editor-Debugger utility. (Result is « Intellect JAVA SCRIPT» line).
if (Event.SourceType == "MACRO" && Event.SourceId == "1" && Event.Action == "RUN")
{
                var str = Base64Decode("SW50ZWxsZWN0IEpTY3JpcHQ= ", 0);
                DebugLogString(str);
}
The Sleep method
The Sleep method pauses the execution of the script for a specified period of time.
Method call syntax
function  Sleep(milliseconds : int)
Method arguments:
milliseconds - Required argument. The length of time that the script will be inactive for. Set in milliseconds. It takes the following values:  Type – int.
Usage examples
Problem 1. When Macro 1 starts, play the following audio files one by one: cam_alarm_1.wav, cam_alarm_2.wav, cam_alarm_3.wav from the …\Intellect\Wav\ folder. Set a 5 seconds 
(5000 milliseconds) delay before starting each subsequent file.


9
if (Event.SourceType == "MACRO" && Event.SourceId == "1" && Event.Action == "RUN")
{
var i;
 for(i=1; i<=3; i=i+1)
  {
    DoReactStr("PLAYER", "1", "PLAY_WAV", " file<\cam_alarm_"  + i + ".wav>");
    Sleep(5000);
  } 
}
Problem 2. When macro №2 starts, timer №1, that triggers every 10 seconds in a minute after macro №2 starting, starts.
if (Event.SourceType == "MACRO" && Event.SourceId == "2" && Event.Action == "RUN")
{
for(i=0; i<=5; i=i+1)
{
DoReactStr("TIMER","1", "DISABLE", "");
Sleep(10000);
DoReactStr("TIMER","1", "ENABLE", "");
NotifyEventStr("TIMER","1", "TRIGGER", "");
}
DoReactStr("TIMER","1", "DISABLE", "");
}
The Itv_var method
The Itv_var method sets and returns the values of global variables.
Method call syntax
Note
To start this script create the 
 object with ID=1 beforehand. Leave object parameters set by default (
). The
 object can be disabled
Timer
Any
 Timer 1


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ə