Documentation for Axxon PSIM 1.0.0-1.0.1.

Previous page Examples of scripts in the embedded language  Examples of scripts with Computer and Display Next page


Formats and functions

Format of events procedure for the Video capture device:

OnEvent("GRABBER","_id_","_event_")

Operator format to describe actions with the Video capture device:

DoReact("GRABBER","_id_","_command_" [,"_parameters_"]);

Format of the event procedure for the Camera object:

OnEvent("CAM","_id_","_event_")

Operator format to describe actions with the Camera:

DoReact("CAM","_id_","_command_" [,"_parameters_"]);

Function to check the state of the Camera object:

CheckState("CAM","number","state")

Format of event procedure for the Monitor object:

OnEvent("MONITOR","_id_","_event_")

Operator format to describe actions with the Monitor:

DoReact("MONITOR","_id_","_command_"[,"_parameters_"]);

Examples

Examples of using events and reactions of the Video capture device object:

  1. It is required to set the first channel for the first video capture device, maximum speed of digitizing, resolution is half-frame and PAL format when starting the first macro.

    OnEvent("MACRO","1","RUN") // start macro 1
    {
        DoReact("GRABBER","1", "SETUP", "chan<1>,mode<0>,resolution<1>,format<PAL>");
        //set channel 1 for the first video capture device, speed of digitizing is maximum, resolution is half-frame, format is PAL
    }
  2. Set disks D:\ and F:\ for recording video archive when starting the third macro.

    OnEvent("MACRO","3","RUN") //start macro 3
    {
        DoReact("GRABBER","1","SET_DRIVES","drives<D:\,F:\>"); //record the video archive on disks D:\ and F:\
    }
  3. It is required to display the first camera on the first analog output and disable the first analog outputs of the first and second cards when there is an error of connection to the second video capture device.

    OnEvent("GRABBER","2"," UPS_FATAL_ERROR") //error of connection to the video capture device 2
    {
        DoReact("CAM","1","MUX1"); //display camera 1 on the 1-st analog output of card
        Wait(5);
        DoReact("GRABBER","1","MUX1_OFF"); //disable 1-st analog output of the first card
        DoReact("GRABBER","2","MUX1_OFF"); //disable 1-st analog output of the second card
    }

    Note

    If analog outputs of two or more cards are connected in parallel and, for example, camera 1 belongs to the first grabber and camera 2 belongs to the second grabber, then when running the «DoReact("CAM","1","MUX1");» command, it is required to run the «DoReact("GRABBER","2","MUX1_OFF");» command first. And correspondingly when running the «DoReact("CAM","2","MUX1");» command, it is required to run the «DoReact("GRABBER","1","MUX1_OFF");» command first. Otherwise signal overlaying will happen.
  4. It is required to disable the second analog output of the video capture device when restoring the mains supply.

    OnEvent("GRABBER","1","UPS_ONLINE")         //restoring the mains supply
    {
        DoReact("GRABBER","1","MUX2_OFF");      //disable analog output 2
    }

Examples of using events and reactions of the Camera object:

  1. Switch camera to the color mode and start recording from it when arming the first camera.

    OnEvent("CAM","1","ARM") //first camera is armed
    {
        DoReact("CAM","1","SETUP","color<1>"); // set color mode of camera
        DoReact("CAM","1","REC"); //record from the first camera
    }
  2. Arm the first camera when disabling the fifth camera.

    OnEvent("CAM","5","DETACH") // fifth camera is disabled
    {
        DoReact("CAM","1","ARM"); //first camera is armed
    }
  3. Use half of resources when recording from the first camera (it means, if four cameras are connected through the first video capture device than the first camera will record with speed of 6 FPS, and other three cameraswith speed of 2-2.5 FPS) if it is in the alarm state.

    OnEvent("CAM","1","MD_START") //first camera is in alarm state
    {
        DoReact("CAM","1","SETUP","rec_priority<2>"); // use half of resources when recording
    }
  4. Set maximum compression synchronously with the fourth microphone of audio card on the first camera when recording on disk from the first camera.

    OnEvent("CAM","1","REC") //first camera recording on disk
    {
        DoReact("CAM","1", "SETUP", "compression<5>, audio_type<OLXA_LINE>, audio_id<4>"); //first camera, maximum compression, synchronously with the forth microphone of audio card.
  5. Start recording from the first camera with minimum quality in black and white mode when it isn't alarmed.

    OnEvent("CAM","1","MD_STOP") // first camera stopped to be in alarm state
    {
        value = 5;
        DoReact("CAM", "1", "SETUP", "compression<" + value + ">,color<0>");
        //start recording from the first camera with minimum quality in the black and white mode.
    }
  6. Start recording from the first camera in the “rollback” mode when it is disarmed.

    OnEvent("CAM","1","DISARM")  //first camera is disarmed
    {
        DoReact("CAM","1","REC","rollback<1>");  // Start recording from the first camera in the "rollback" mode
    }
  7. Set new parameters of video signal when connecting the first camera.

    OnEvent("CAM","1","ATTACH") //first camera is connected
    {
        VIDEO_CANAL_ID = GETOBJECTPARAM("CAM","1","PARENT_ID"); // define ID of video channel to which the first camera belongs
        DoReact("GRABBER",VIDEO_CANAL_ID,"SETUP","chan<0>,mode<0>,resolution<1>,format<pal>"); //set new parameters of video channel
    }
  8. Start auto cruising on Camera 1 when Macro 2 is run.

    OnEvent ("MACRO","2","RUN")
    {
        DoReact("CAM","1","CRUISE_START","cruise_id<1>,action<CRUISE_START>,cam_id<1>");
    }
  9. There is a certain number of cameras (num). It is necessary to check the operation of motion detection on all cameras (can be used to check the performance of security sensors).
    To solve the problem, you can use the emulation of a linear character array (string), it means, the array of characters is filled in (in the example, it is the "N" character). Then, when the camera’s motion detection is triggered, the corresponding (to the camera ID) element of the array is changed (changed to "Y"). Thus, the output is a character array of "N" (the camera didn’t trigger) and "Y" (the camera triggered). The number of detections is counted and a message with the total number of cameras and the number of cameras that triggered is displayed. Start the check on Macro 1. Stop on Macro 2.
    OnInit()
    {
        run=0;
    }
     
    OnEvent("MACRO","1","RUN")
    {
        run=1; flag=""; num=8;
        for(i=1;i<str(num+1);i=str(i+1))
        {
            DoReact("CAM",i,"DISARM");
            DoReact("CAM",i,"REC_STOP");
            DoReact("CAM",i,"ARM");
            flag=flag+"N";
            if(i<num) {flag=flag+"|";}
        }
    }
     
    OnEvent("CAM",N,"MD_START")
    {
        if(run)
        {
            nn=str((N*2)-1);
            flag=strleft(flag,str(nn-1))+"Y"+strright(flag,str(((num*2)-1)-nn));
        }
    }
     
    OnEvent("MACRO","2","RUN")
    {
        run=0; fin=0;
        for(i=1;i<str(num+1);i=str(i+1))
        {
            tmp=extract_substr(flag,"|",str(i-1));
            if(strequal(tmp,"Y")) {fin=str(fin+1);}
            DoReact("CAM",i,"DISARM");
        }
        tmp="All:"+str(num)+" Worked:"+str(fin);
        rez=MessageBox("",tmp,0);
    }

  10. When an alarm occurs on camera 1, captions must be overlaid on the video image from this camera. When the alarm ends, captions about the end of the alarm must be overlaid on the video image.
    OnEvent("CAM","1","MD_START")
    {
        DoReact("CAM","1","CLEAR_SUBTITLES","title_id<1>"); //delete all captions from video image
        DoReact("CAM","1","ADD_SUBTITLES","command<Camera 1 Alarm " + time + "\r>,page<BEGIN>,title_id<1>");
        //the time parameter allows you to include the time of event registration in captions
    }
     
    OnEvent("CAM","1","MD_STOP")
    {
        DoReact("CAM","1","ADD_SUBTITLES","command<Camera 1 End of alarm " + time + "\r>,page<END>,title_id<1>");
    }

    Note

    When you use the page<BEGIN> and page<END> parameters, the corresponding fields in the captions database will be filled in, which will make it possible to search for data using the Captions search interface object.

Examples of using events and reactions of the Monitor object:

  1. Play record from camera 1 on the monitor 4 with the specified date and time when running the first macro.

    OnEvent("MACRO","1","RUN")
    {
        DoReact("MONITOR","4","ARCH_FRAME_TIME","cam<1>,date<"+date+">,time<11:00:00>");
        DoReact("MONITOR","4","KEY_PRESSED","key<PLAY>");
    }
  2. Switch to the mode of video archive viewing on the first camera of monitor 4 when printing the frame from the first camera and then go on 10 frames further starting from the specified date and time.

    OnEvent("CAM", "1", "PRINT")
    {
        DoReact("MONITOR","4","ARCH_FRAME_TIME","cam<1>,date<"+date+">,time <11:00:00>");
        for(i=0;i<10;i=i+1)
        {
            DoReact ("MONITOR","4","KEY_PRESSED","key<FF>");
        }
    }
  3. Zoom in the video image on the monitor screen if camera is in the alarm state and reset it when alarm is finished.

    OnEvent("CAM","1","MD_START")
    {
        DoReact("MONITOR","1","KEY_PRESSED","key<ZOOM_IN>");
    }
     
    OnEvent("CAM", "1", "MD_STOP");
    {
        DoReact("MONITOR","1","KEY_PRESSED","key<ZOOM_OUT>");
    }
  4. Display the layout number one on the monitor screen when running a macro.

    OnEvent("MACRO","1","RUN")
    {
        DoReact("MONITOR","1","KEY_PRESSED","key<SELECT_LAYOUT>,number<1>");
    }
  5. Command of starting the video export from Camera 1 in the Monitor 1, starting from 24-10-14 17:10:38 and to 24-10-14 17:10:80 to the c:\aaa.avi file.
    Examples of export starting in three ways: using the IIDK (port 900 and 1030) and using script:
    1. IIDK (port 900)
      MONITOR|1|START_AVI_EXPORT|start<24-10-14 17:10:38>,finish<24-10-14 17:10:50>,avi_path<c:\aaa.avi>,cam<1>
    2. IIDK (port 1030)
      CORE||DO_REACT|source_type<MONITOR>,source_id<1>,action<START_AVI_EXPORT>,params<4>,param0_name<avi_path>,param0_val<c:\aaa.avi>,param1_name<cam>,param1_val<1>,param2_name<finish>,param2_val<24-10-14 17:10:50>,param3_name<start>,param3_val<24-10-14 17:10:38>
    3. Script (start on Macro 1)

      OnEvent("MACRO","1","RUN")
      {
          DoReact("CORE","","DO_REACT","source_type<MONITOR>,source_id<1>,action<START_AVI_EXPORT>,params<4>,param0_name<avi_path>,param0_val<c:\aaa.avi>,param1_name<cam>,param1_val<1>,param2_name<finish>,param2_val<24-10-14
       17:10:50>,param3_name<start>,param3_val<24-10-14 17:10:38");
      }
  6. When macro 1 is run, enable mouse PTZ control on Camera 4 at Monitor 10. Disable it on Macro 2.

    OnEvent("MACRO","1","RUN")
    {
        DoReact("MONITOR","10","CONTROL_TELEMETRY","cam<4>,on<1>");
    }
     
    OnEvent("MACRO","2","RUN")
    {
        DoReact("MONITOR","10","CONTROL_TELEMETRY","cam<4>,on<0>");
    }
  7. Display an active camera on an analog monitor.
    OnEvent ("MONITOR","1","ACTIVATE_CAM")
    {
        DoReact ("CAM",cam,"MUX1");
    }

  8. Display an alarmed camera in the one-fold mode.
    OnEvent ("CAM",N,"MD_START")
    {
        DoReact ("MONITOR","1","ACTIVATE_CAM","cam<"+N+">");
        DoReact ("MONITOR","1","KEY_PRESSED","key<SCREEN.1>");
    }

  9. An alarm monitor that always displays a video from the last alarmed camera.
    OnInit()
    {
        counter=0;
    }
     
    OnEvent("CAM",T,"MD_START")
    {
        if(strequal(counter,"0"))
        {
            DoReact("MONITOR","2","REMOVE_ALL");
            DoReact("MONITOR","2","ADD_SHOW","cam<"+T+">");
        }
        counter=str(counter+1);
    }
     
     
    OnEvent("CAM",M,"MD_STOP")
    {
        counter=str(counter-1);
        if(strequal(counter,"0"))
        {
            DoReact("MONITOR","2","ADD_SHOW","cam<"+M+">");
        }
    }
    
  10. When macro 1 is run, enable layout scrolling on all servers in the Video surveillance monitor (Monitor 1). When macro 2 is run, disable layout scrolling on all servers.
    if(Event.SourceType == "MACRO" && Event.SourceId=="1" && Event.Action=="RUN")
    {
        DoReactStr("MONITOR", "1","START_PAGING_LAYOUTS","");
    }
     
    if (Event.SourceType == "MACRO" && Event.SourceId == "2" && Event.Action == "RUN")
    {
        DoReactStr("MONITOR", "1", "STOP_PAGING_LAYOUTS","");
    }
  • No labels