Go to documentation repository
...
To illustrate available fields of application of scripts in JScript see the following examples which can be used to create additional functions in the system on the basis of the Script object.
The Queue length detection object (part of the DetectorPack package), Camera and Captioner objects (instead of N, M, L symbols set the corresponding numbers of the Queue length detection, Camera and Captioner objects) are to be created and configured for correct script working in the Axxon PSIM software.
...
| Info | ||
|---|---|---|
| ||
When page<BEGIN> and page<END> parameters are in use, the corresponding fields of the subtitles database are filled in. This enables data search using the Search by titles interface object. |
The People Counter Detection object (part of the DetectorPack package), Camera, Captioner and Macro objects (instead of N, M, L, P symbols set the corresponding numbers of the People counter detection, Camera, Captioner and Macro objects) are to be created and configured for correct script working in Axxon PSIM.
...
Macro of setting to zero can be run manually by main menu of Axxon PSIM or automatically in any specified time (use the Events table on the settings panel of the Macro object where the previously configured Time zone object is to be specified). Detailed information about using the Macro and Time zone objects is given in the Administrator’s Guide document).
It is possible to select the type of Text displaying while attaching object to the map (see Attaching objects to the layers of interactive map). Also the script on the JScript language can be used for changing the displayed text.
...
| Code Block | ||
|---|---|---|
| ||
if(Event.SourceType == "MACRO" && Event.Action == "RUN")
{
var result = parseInt(ReadIni("MyVar","C:\\test.ini"));
result += 2;
NotifyEventStr("CAM","1","ANALOG_PARAMS","text<Variable value = \n" + result + ">, blink_state<1>");
DebugLogString(result);
}
|
The following example is valid only for cameras in configuration of which there is PTZ control panel. When configuring Video surveillance monitor select the Go to preset action with 1,2,3...,0 parameters for ten joystick buttons (see Assigning commands to joystick buttons using the Monitor section of Installing and configuring security system components guide).
...
| Code Block | ||
|---|---|---|
| ||
if (Event.SourceType=="TIMER" && Event.SourceId=="1" && Event.Action=="TRIGGER")
{
mon="1";
DebugLogString("on monitor "+ Itv_var("cam"));
DoReactStr("MONITOR",mon,"ACTIVATE_CAM","cam<"+Itv_var("cam")+">");
Itv_var("cam")="";
}
if (Event.GetParam("source_type")=="TELEMETRY" && Event.GetParam("action")=="GO_PRESET")
{
DoReactStr("TIMER","1","START","bound<2>");
var key=Event.GetParam("param4_val");
DebugLogString("Key:"+key);
Itv_var("cam")=Itv_var("cam")+key;
DebugLogString(Itv_var("cam"));
}
|
Example. Camera IP address is 192.168.0.13.
...
| Code Block | ||
|---|---|---|
| ||
function DoPreset(preset)
{
xmlhttp=new ActiveXObject("MSXML2.XMLHTTP");
if(xmlhttp == null)
{
return;
}
xmlhttp.open("GET", "http://192.168.0.13/httpapi/SendPTZ?action=sendptz&PTZ_PRESETSET="+preset, false,"admin","1234");
xmlhttp.send();
DebugLogString(xmlhttp.status);
}
if (Event.SourceType == "MACRO" && Event.SourceId == "6" && Event.Action == "RUN")
{
DoPreset("85");
}
if (Event.SourceType == "MACRO" && Event.SourceId == "7" && Event.Action == "RUN")
{
DoPreset("86");
}
|
If the object tracking function is in use (see Creating and configuring the Timer object), then detected objects will be framed in video when viewing the archive. To frame abandoned objects in live video use the script aimed to frame an abandoned object when receiving alarm from VMDA detection tool:
| Code Block | ||
|---|---|---|
| ||
if (Event.SourceType=="CAM_VMDA_DETECTOR")
{
cam=GetObjectParentId("CAM_VMDA_DETECTOR",Event.SourceId,"CAM");
if (Event.Action=="ALARM")
{
var x1,x2,y1,y2;
x1=Event.GetParam("x");
x2=Event.GetParam("w");
y1=Event.GetParam("y");
y2=Event.GetParam("h");
x2=parseInt(x1)+parseInt(x2);
y2=parseInt(y1)+parseInt(y2);
DoReactStr("MONITOR","","SET_MARKRECT","cam<"+cam+">,color<255>,id<"+cam+">,x1<"+x1+">,x2<"+x2+">,y1<"+y1+">,y2<"+y2+">");
DebugLogString("x1:"+x1+" x2:"+x2+" y1:"+y1+" y2:"+y2);
}
else
{
DoReactStr("MONITOR","","DEL_MARKRECT","cam<"+cam+">,id<"+cam+">");
}
}
|
Objects from more than one main Server are not to be moved to the Backup Server. For this when moving objects from some main Server to the Backup Server all other Failover objects are to be disabled on this Backup Server.
| Code Block | ||
|---|---|---|
| ||
if (Event.SourceType == "FAILOVER" )
{
if (Event.Action == "START") {action="DISABLE";}
if (Event.Action == "STOP") {action="ENABLE";}
id=Event.SourceId;
msg=CreateMsg();
msg.StringToMsg(GetObjectIds("FAILOVER"));
var
objCount=msg.GetParam("id.count");
for (i=0;i<objCount;i++)
{
pid=msg.GetParam("id."+i);
if (!(id==pid)) {
DoReactStr("FAILOVER",pid,action,"");
}
}
} |
Upon reaching the number of visitors equal to 20 on the embedded visitors counter of the Bosch FLEXIDOME IP dynamic 7000 VR IP camera (with ID 1), call the macro 1.
| Code Block | ||
|---|---|---|
| ||
n=20;
if(Event.SourceType == "CAM_IP_DETECTOR" && Event.SourceId=="1" && Event.Action == "DETECTED")
{
v=Event.GetParam("param0").split(";")[1];
if (parseInt(v.split(":")[1])==n)
{
DoReactStr("MACRO","1","RUN","");
}
} |
By macro 1, send a message with the attached files detected.png and found.jpg from the folder C:\\Pictures\\ to example@gmail.com. The message should be formatted as follows:
...
| Code Block | ||
|---|---|---|
| ||
if(Event.SourceType == "MACRO" && Event.SourceId=="1" &&Event.Action=="RUN")
{
var file1 = "detected.png";
var file2 = "found.jpg";
var file_folder = "C:\\Pictures\\";
var test_event = CreateMsg();
test_event.StringToMsg("MAIL_MESSAGE|1|SEND_RAW|cc<>,to<daniel@AxxonSoft.com>,objname<Mail message 1>,subject<>,parent_id<1>,flags<>,pack<>,name<Mail message 1>,from<example@gmail.com>,_marker<>");
test_event.SetParam("body","<html><body>\r\n<h3>Face found</h3>\r\n<table><tr>\r\n<td>Detected</td><td>Found in DB</td>\r\n</tr><tr>\r\n<td><img width='200' alt='image1' src='cid:"
+
file1
+
"'/></td>\r\n<td><img width='200' alt='image2' src='cid:"
+
file2
+
"'/></td>\r\n</tr><tr>\r\n<td>E-mail sent from Axxon PSIM</td>\r\n</tr></table>\r\n</body></html>");
test_event.SetParam("attachments",file_folder+file1+";" + file_folder+file2);
test_event.SetParam("is_body_html", 1);
DoReact(test_event);
} |
Using macro 101, create 50 users in Axxon PSIM with IDs from 100 to 150, assigning them an access level with ID 1 (provided that the AL is assigned to the department to which the users are added and users inherit the department AL) and linking an access card with a number, equal to the user ID. The card number must be in HEX format. The department should have no more than 30 users (to speed up the adding process).
...
| Code Block | ||
|---|---|---|
| ||
dep=10; // department ID
start=100;// first user ID
last=150; // last user ID
acc_lev=1; // access level ID
dep_count=30; // max number of users in the department
if( Event.SourceType == "MACRO" && Event.Action == "RUN" && Event.SourceId=="101")
{
kol=0;
card_count=0;
NotifyEventStr("CORE","","UPDATE_OBJECT","objtype<DEPARTMENT>,objid<"+dep+">");
for (i=start;i<=last;i++)
{
kol++;
card_count++;
card=decToHex(card_count);
if (card[card.length-1]==0)
{
card_count++;
card=decToHex(card_count);
}
if (kol==dep_count)
{
NotifyEventStr("CORE","","UPDATE_OBJECT", "objtype<PERSON>,objid<"+i+">,name<user"+i+">,parent_id<"+dep+">, level_id<"+acc_lev+">, facility_code<0>, card<"+card+">");
kol=0;
dep++;
NotifyEventStr("CORE","","UPDATE_OBJECT","objtype<DEPARTMENT>,objid<"+dep+">");
}
else
{
NotifyEventStr("CORE","","UPDATE_OBJECT", "objtype<PERSON>,objid<"+i+">,name<user"+i+">,parent_id<"+dep+">,level_id<"+acc_lev+">, facility_code<0>,card<"+card+">");
}
Sleep(10);
}
}
function decToHex(n)
{
return Number(n).toString(16);
} |
When working with objects in the Incident manager, it is possible to change the event status of an object (see Processing events). To change the event status of an object, you can use a JScript script.
...