/// <summary> Initialize and start the agent /// </summary> /// <param name="args">Command-line arguments (run with no arguments to display help) /// </param> public virtual void StartAgent(string[] args) { Console.WriteLine("Initializing agent..."); // Read the configuration file fCfg = new AgentConfig(); Console.Out.WriteLine("Reading configuration file..."); fCfg.Read("agent.cfg", false); // Override the SourceId passed to the constructor with the SourceId // specified in the configuration file Id = fCfg.SourceId; // Inform the ADK of the version of SIF specified in the sifVersion= // attribute of the <agent> element SifVersion version = fCfg.Version; Adk.SifVersion = version; // Now call the superclass initialize once the configuration file has been read base.Initialize(); // Ask the AgentConfig instance to "apply" all configuration settings // to this Agent; for example, all <property> elements that are children // of the root <agent> node are parsed and applied to this Agent's // AgentProperties object; all <zone> elements are parsed and registered // with the Agent's ZoneFactory, and so on. // fCfg.Apply(this, true); // Create the logging object fLogger = new ObjectLogger(this); // Now, connect to all zones and just get the zone status foreach (IZone zone in ZoneFactory.GetAllZones()) { if (getChameleonProperty(zone, "logRaw", false)) { zone.Properties.KeepMessageContent = true; zone.AddMessagingListener(fLogger); // Set this class as the recipient of all SIF_ZoneStatus // query results zone.SetQueryResults(this, InfraDTD.SIF_ZONESTATUS); } // Provision the logger class to log all QueryResults zone.Connect(ProvisioningFlags.Register); } // On a seperate thread, go through the exercise of getting the // SIF_ZoneStatus object from all zones AsyncUtils.QueueTaskToThreadPool(new SimpleMethod(GetZoneStatus)); }
public void OnQueryResults(IDataObjectInputStream data, SIF_Error error, IZone zone, IMessageInfo info) { SifMessageInfo smi = (SifMessageInfo)info; if (!(fRequestState.Equals(smi.SIFRequestInfo.UserData))) { // This is a SIF_ZoneStatus response from a previous invocation of the agent return; } if (data.Available) { SIF_ZoneStatus zoneStatus = data.ReadDataObject() as SIF_ZoneStatus; AsyncUtils.QueueTaskToThreadPool(new zsDelegate(_processSIF_ZoneStatus), zoneStatus, zone); } }