Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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

...

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

...

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

Example 8. Using the embedded visitors counter on Bosch FLEXIDOME IP dynamic 7000 VR IP camera

...

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

...

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

...