Documentation for Axxon PSIM 1.0.0-1.0.1.

Previous page Examples of scripts with detection tools  Example of script with Users Next page


Example 1. Sending a command to a camera using the camera HTTP API 

Camera IP address is 192.168.0.13.

The following command turns on the screen wiper on a camera:

192.168.10.101/httpapi/SendPTZ?action=sendptz&PTZ_PRESETSET=85

The following command turns off the screen wiper on a camera:

192.168.10.101/httpapi/SendPTZ?action=sendptz&PTZ_PRESETSET=86

These commands must be sent to a camera using the JScript script.

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");
}

Example 2. Sending e-mail with HTML markup

On macro 1, send a message with the attached detected.png and found.jpg files from the C:\\Pictures\\ folder to example@gmail.com. The message must be formatted as follows:

Face detected

Detected faceFace in DB
detected.png filefound.jpg file
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);
}


  • No labels