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

...