Programming Guide (JScript)



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

34
3.  
1.  
2.  
1.  
2.  
1.  
2.  
path – required argument.   Sets full path to the ini-file in which variable is to be stored. Storage of variables can be replaced on the network resource. Enter the network path 
in the argument for it.
Example. Write the MyVar variable to the \\fs\temp\test.ini file and specify the «Helloworld!” value to it. Then read the written value and display it on the script debug window.
WriteIni("MyVar", "Hello world", "\\\\fs\\temp\\test.ini");
var result = ReadIni("MyVar","\\\\fs\\temp\\test.ini");
DebugLogString(result);
The ReadIni method
The ReadInimethod is used to read values of string variablein the ini-file.
Method call syntax:
function ReadIni (varName: String, path: String): String
Method call syntax:
varName – required argument. Sets name of the variable storing in the file.
path – required argument. Sets the full path to the ini-file in which variable is storing.
See example in 
 section.
The WriteIni method
The AddIni method
The AddIni method is used to write, change and read integer variable from the ini-file. The method returns the value of variable after its changing.
Method call syntax:
function AddIni(varName: String, varValue: int, path: String): int
varName – required argument. Sets the name of variable in the file.
varValue – required argument. Sets the value of variable or value which should be added to the existing value of variable:
The varValue value will be assigned to the variable if there is a file with the varName name and string value in the file.
 If there is no variable with the varName name in the file then such variable will be created and the varValue value will be assigned to it.


35
2.  
3.  
3.  
1.  
2.  
 If there is a variable with the varName name in the file and it has integer value or its value is indicated to the integer type, then value will be indicated and the varValue 
value will be added to it.
path – required argument. Sets the full path to the ini-file in which variable it to be stored. Storage of variables can be placed on the network resource. Enter the network path 
in the for it.
Example. There is no the "MyVar" variable in the "C:\\test.ini". Write such variable with the -1 value to the file, then add 1 to it and display the result value on the script debug window.
var result = AddIni("MyVar", -1, "C:\\test.ini");
result = AddIni("MyVar", 1, "C:\\test.ini");
DebugLogString(result);
The SetTimer method
The SetTimer method is used to start the timer.
The syntax for accessing the method is:
function SetTimer (id : int, milliseconds : int)
Method arguments:
id is a required argument. It specifies the timer ID. Allowed values are int or string type.
milliseconds is a required argument. It specifies the period with which the timer will trigger if it is not stopped by 
. It is specified in milliseconds. Allowed 
the KillTimer method
values are int type.
Example. 2 seconds after the macro 1 is executed, start recording on camera 1.
if(Event.SourceType=="LOCAL_TIMER" && Event.Action=="TRIGGERED" && Event.SourceId==333) //it is possible to use 
Event.SourceId == "333", i.e. string ID 
{
  var actuallyKilled = KillTimer(333); 
  if(actuallyKilled == 1)
  {
     DoReactStr("CAM","1","REC",""); 
  }
}
 


36
1.  
1.  
2.  
3.  
if(Event.SourceType=="MACRO"&& Event.SourceId == "1" && Event.Action == "RUN")
{
  SetTimer(333,2000); //333 - id, 2000 msec = 2 sec - period
}
The KillTimer method
The KillTimer method is used to stop the timer. Returns 1 if timer was stopped as a result of function executed.
The syntax for accessing the method is:
function KillTimer (id : int) : int
Method arguments:
id is a required argument. It specifies the timer ID. Allowed values are int or string type.
Example. See in the 
 section.
The SetTimer method
The GetObjectChildIds method
The GetObjectChildIds method returns IDs of child objects of specified type created under given object.
Method call syntax
function  GetObjectParentId(parent : String, id : String, objtype : String) : String[]
Method arguments:
parent - Required argument. The type of the object for which you want to find out child objects . 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 
argument. It takes the following values:  Type – String, range – existing identification 
parent
numbers of the objects of the specified type.
objtype - Required argument. The type of the child objects whose identification numbers should be returned. It takes the following values:  Type – String, range – existing 
object types.
Example. Arm all cameras on WS2 computer on Macro 1.
if (Event.SourceType == "MACRO" && Event.Action == "RUN" && Event.SourceId == "1")
{
   var children = GetObjectChildIds("SLAVE","DESKTOP-UBOS6BK","CAM");


37
   ch=children.split(",");
   for (i=0;i   {
     DoReactStr("CAM",ch[i],"ARM","");
   }
}
The MsgObject and Event objects and their built-in methods and properties
The MsgObject and Event objects
MsgObject is a prototype (template) used to create objects with methods and properties for handling events. The methods and properties of 
 allow receiving the 
MsgObject
information about objects that send or receive events, generating actions, changing object states, etc.
The methods and properties of the
 prototype can be called via its instance objects or the 
 static object.
 MsgObject
Event
Event is a static object used to call events in Intellect. The 
 object represents the system event that launched the script. All MsgObject methods and properties are available for 
Event
the 
 object.
Event
The CreateMsg method of the Core object is used to create instances based on the 
 prototype.
MsgObject
The GetSourceType method
The GetSourceType method returns the type of the 
t or 
 object.
MsgObjec
Event
Method call syntax
 function  GetSourceType() : String
Method arguments: no arguments.
Usage examples
Problem. When Macro 1 starts, arm Detection Zones *.1 in the Day mode for Cameras № 1 – 4.  When Macro 2 starts, arm Detection Zones *.2 in the Night mode for Cameras № 1 – 
4. When Macro 3 starts, arm Detection Zones *.3 in the Rain mode for Cameras № 1 – 4. 
Note
 Symbol "*" corresponds to identification number of a camera in the system (from  1 to 4)


Yüklə 6,96 Mb.

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