The CreateMsg method creates objects based on the MsgObject prototype.
Method call syntax
function CreateMsg() : MsgObject |
Method arguments: no arguments.
Usage examples
Problem 1. When an alarm is received, send the “panic lock” event corresponding to the camera region. For camera identification numbers from 1 to 4, use region 1, for camera numbers from 5 to 10, use region 2.
if (Event.SourceType == "CAM" && Event.Action == "MD_START")
{
var msgevent = CreateMsg();
msgevent.SourceType = "REGION";
msgevent.Action = "PANIC_LOCK";
if (Event.SourceId <=4)
{
msgevent.SourceId = "1";
}
if ((Event.SourceId > 4) && (Event.SourceId < 10))
{
msgevent.SourceId = "2";
}
NotifyEvent(msgevent);
} |
Problem 2. When timer №1 starts, start macro №1 every 30 seconds.
To start this script create the Timer object with ID=1 beforehand. Set value=1 to the Second parameter of the Timer object, leave other parameters without changing («Any by default) |
if (Event.SourceType == "TIMER" && Event.SourceId == "1" && Event.Action == "TRIGGER")
{
var msg = CreateMsg();
msg.StringToMsg(GetObjectParams("TIMER", "1"));
if(msg.GetParam("s") == "1")
{
DoReactStr("MACRO", "1", "RUN", "");
SetObjectParam("TIMER","1","s","30");
DoReactStr("TIMER","1", "DISABLE", "");
DoReactStr("TIMER","1", "ENABLE", "");
}
if(msg.GetParam("s") == "30")
{
DoReactStr("MACRO", "1", "RUN", "");
SetObjectParam("TIMER","1","s","1");
DoReactStr("TIMER","1", "DISABLE", "");
DoReactStr("TIMER","1", "ENABLE", "");
}
} |