Go to documentation repository
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 of using events and reactions of the Video capture device object:
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 }
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:\ }
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
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:
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 }
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 }
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 cameras—with 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 }
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.
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. }
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 }
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 }
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>"); }
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); }
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:
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>"); }
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>"); } }
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>"); }
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>"); }
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"); }
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>"); }
OnEvent ("MONITOR","1","ACTIVATE_CAM") { DoReact ("CAM",cam,"MUX1"); }
OnEvent ("CAM",N,"MD_START") { DoReact ("MONITOR","1","ACTIVATE_CAM","cam<"+N+">"); DoReact ("MONITOR","1","KEY_PRESSED","key<SCREEN.1>"); }
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+">"); } }
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",""); }