RJKSolutions

Question on start/stop of a query based on AF configuration change

Discussion created by RJKSolutions on Jan 3, 2012
Latest reply on Jan 10, 2012 by MvanderVeeken

I'm still learning (rapidly) so I still have some obvious questions for you seasoned SI developers.

 

I've built a query for monitoring data quality (simple quality checks for now) and I store my configuration in AF.  I pull the configuration and define the adapters like so:

 

 

 
#region "Generate input tags from AF Configuration"

            // Get some configuration from AF, using defaults for now.
            PISystem af = new PISystems().DefaultPISystem;
            AFDatabase db = af.Databases.DefaultDatabase;
            AFElement rootElement = (AFElement)AFElement.FindObject("Systems\\Monitor\\StreamInsightTest",db);

            // Get Attributes to be monitored.
            var attributesToMonitor = from eachElement in rootElement.Elements
                                      where eachElement.Categories.Contains(db.ElementCategories["MonitoredElement"]) 
                                      group eachElement by eachElement into filteredElements
                                      from eachFilteredAttribute in filteredElements.SelectMany(e => e.Attributes.FilterBy(db.AttributeCategories["MonitoredAttribute"]))
                                      select eachFilteredAttribute;

            // Generate array of tag names
            string[] inputTags = (from eachAttribute in attributesToMonitor select TrimTag(eachAttribute.DataReference.ConfigString)).ToArray();
            // PI for SI Input Configuration
            var inputTagsConfig = new SnapshotInputConfig() { Server="localhost", StopOnCommunicationFailure = false, PointsQuery = inputTags };

            #endregion

            #region "Generate output tag from AF Configuration"

            // Output PI tag to receive the query result
            string outputTag = TrimTag(rootElement.Attributes["Badval Perc"].DataReference.ConfigString);
            // PI for SI Output Configuration
            var outputTagsConfig = new SnapshotOutputConfig() { Server = "localhost" };

            #endregion

 

 

 

 

 

 

I then obviously define my query, which I am using a 5 min window with a 1 minute hop.  Query is then started.  However, is it feasible to then have a background thread (or even a remote synchronisation service) checking for important updates to the AF configuration and then stop the query and start it up again as the start up would rebuild the input tags.  The query definition wouldn't change, just the inputs to the query.

 

 

Outcomes