44
if (Event.SourceType == "GRELE" && Event.SourceId == "1")
{
var msgevent = Event.Clone();
if(Event.Action == "ON")
{
msgevent.SourceId = "2";
DoReact(msgevent);
DoReactStr("CAM","1","REC","");
DoReactStr("GRELE","2","ON","");
}
if(Event.Action == "OFF")
{
msgevent.SourceId = "2";
DoReact(msgevent);
DoReactStr("CAM","2","REC","");
DoReactStr("GRELE","2","OFF","");
}
}
The GetObjectIds method
GetObjectIds method is responsible for receiving identifiers from all the objects of a specified type.
Method call syntax:
function GetObjectIds(objectType : String)
A line is replied :
CAM||COUNT|id.3<5>,id.count<4>,id.0<2>,id.1<3>,id.2<4>
where
– number of ID objects,
id.count<>
– ID object.
id.[count]<>
Method’s arguments:
45
1.
2.
objectType required argument. Set the type of the system object, for which the value of the given parameter should be given back ("CAM","GRAY","GRABBER" e.t.c.).Accepted
–
values: type String, range is restricted by object types registered in the system.
Example. All the cameras should be armed upon the start of Macros№1.
if (Event.SourceType == "MACRO" && Event.SourceId && Event.Action == "RUN")
{
var msg = CreateMsg();
msg.StringToMsg(GetObjectIds("CAM"));
var objCount = msg.GetParam("id.count");
var i;
for(i = 0; i < objCount; i++)
{
DoReactStr("CAM", msg.GetParam("id." + i), "ARM", "");
}
}
The GetObjectParams method
GetObjectParams method is designed for getting the object’s parameters.
Method call syntax:
function GetObjectParams(objectType : String, objectId : String)
Method arguments:
objectType – required argument. Set the type of the system object ("CAM", "GRAY", "GRABBER" e.t.c.), for which the type of a parent object should be given back. Accepted
values: type String, range is restricted by object types registered in the system.
objectId – object’s identifier. Accepted values: String type.
Example. It is necessary to check the color control of camera №2 upon the start of Macros№1. If camera 2 is a color one, set it to recording.
if (Event.SourceType == "MACRO" && Event.SourceId && Event.Action == "RUN")
{
var msg = CreateMsg();
msg.StringToMsg(GetObjectParams("CAM", "2"));
46
if(msg.GetParam("color") == "1")
{
DoReactStr("CAM", "2", "REC", "");
}
}
The SourceType property
The SourceType property stores the system type of the
or
object.
MsgObject
Event
Property call syntax
SourceType : String
Usage examples
Problem. When Relay 1 closes (for example, the button connected to the relay is pressed), print the frames from Cameras 1 and 2.
if (Event.SourceType == "GRELE" && Event.SourceId == "1" && Event.Action == "ON")
{
//activating the Camera 1 window
DoReactStr("MONITOR","1","ACTIVATE_CAM", "cam<1>");
//printing the frame from Camera 1
DoReactStr("MONITOR","1","KEY_PRESSED","key
");
//activating the Camera 2 window
DoReactStr("MONITOR","1","ACTIVATE_CAM", "cam<2>");
//printing the frame from Camera 2
DoReactStr("MONITOR","1","KEY_PRESSED","key
");
}
The SourceId property
The SourceType property stores the identification number of the
or
object.
MsgObject
Event
Property call syntax
47
SourceId : String
Usage examples
See the example for the
.
SourceType
property
The Action property
The Action property stores the action or event of the
or
object.
MsgObject
Event
Property call syntax
SourceId : String
Usage examples
See the example for the
.
SourceType property
Programming tools
The Script object
The
object is designed for initializing and setting the parameters of JScript scripts in Intellect system.
Script
Figure shows the settings panel for the
object.
Script