Versions Compared

Key

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

This script determines the current state of the relay on the Agent of Control side. Also, when the GET_OBJECT_STATE event is received, this script generates the OBJECT_STATE_INFO event (for details, see Configuring alarms for monitoring the object state on the Agent Of Control side). Using the card parameter from the Agent of Control, it is possible to transfer any additional information to the Server of Control. This information will be displayed in the Event Log (see Event log).

Code Block
languagejs
function GetReleStateMsg(type, id, action, card)
{
  var state = GetObjectState("GRELE","1");
  var msg = CreateMsg();
  msg.SourceType = type;
  msg.SourceId = id;
  msg.Action = action;
  msg.SetParam("state",(state=="OFF")?"DISARMED":"ARMED");
  msg.SetParam("card",card);
  return msg;
}

if(Event.SourceType=="VIDEOSRV_C" && Event.SourceId=="1" && Event.Action=="GET_OBJECT_STATE")
{
  NotifyEvent(GetReleStateMsg(Event.SourceType, Event.SourceId,"OBJECT_STATE_INFO",""));
}
else if(Event.SourceType=="GRELE" && (Event.Action=="ON" || Event.Action=="OFF"))
{
  NotifyEvent(GetReleStateMsg("VIDEOSRV_C", "1","OBJECT_STATE_INFO",""));
} 

...