Пример #1
0
        private int ReviewStatus_AFElementSearch_CountOnAllTurbinesCDR(string attribute, string windFarmName)
        {
            AFStopwatch stopwatch = new AFStopwatch();

            var afElementSearch = new AFElementSearch(_afDatabase, "MyQuery", "Name:" + windFarmName + " CategoryName:WTG");

            var elements = afElementSearch.FindElements();

            //Console.WriteLine("Done : " + elements.Count() + ", " + stopwatch.ElapsedMilliseconds + "ms");

            AFElement.LoadAttributes(elements.ToList(), new List <AFAttributeTemplate> {
                _afDatabase.ElementTemplates["WtgBaseTemplate"].AttributeTemplates["WSLG.EvtCt"].AttributeTemplates[attribute]
            });

            var countDictionary = new Dictionary <string, int>();

            foreach (var afElement in elements)
            {
                var count = afElement.Attributes["WSLG.EvtCt"].Attributes[attribute].GetValue().ValueAsInt32();

                if (count > 0)
                {
                    countDictionary[afElement.Name] = count;
                }
            }

            //Console.WriteLine("Done2 : " + elements.Count() + ", " + stopwatch.ElapsedMilliseconds + "ms");
            return(stopwatch.ElapsedMilliseconds);
            //_log.Info($"Time:{stopwatch.Elapsed.TotalSeconds}, Element:{windFarmName}, Element Count: {countDictionary.Keys.Count}, EventFrame Count:{countDictionary.Sum(e => e.Value)}");

            //foreach (var counts in countDictionary)
            //{
            //    _log.Info($"{counts.Key}:{counts.Value}");
            //}
        }
        static void Main(string[] args)
        {
            // This factory method is new in 2.8.
            PISystem ps = PISystem.CreatePISystem("PISRV01");

            using (new AFProbe("PrintAttributeCounts", ps))
            {
                AFDatabase db = ps.Databases["Feeder Voltage Monitoring"];

                // Build search object
                AFSearchToken searchToken = new AFSearchToken(
                    filter: AFSearchFilter.Root,
                    searchOperator: AFSearchOperator.Equal,
                    value: db.Elements["Assets"].GetPath());

                AFElementSearch elementSearch = new AFElementSearch(db, "Feeders and Transformers", new[] { searchToken });

                Console.WriteLine("Feeders and Transformers");
                // Use full load: true to fully load the elements
                foreach (AFElement element in elementSearch.FindElements(fullLoad: true))
                {
                    Console.WriteLine("Element: {0}, # Attributes: {1}", element.Name, element.Attributes.Count);
                }
                Console.WriteLine();
            }

            Console.WriteLine();
            Console.WriteLine("Press any key to quit");
            Console.ReadKey();
        }
        static void CreateEventFrames(AFDatabase database, AFElementTemplate eventFrameTemplate)
        {
            string queryString = "Template:MeterBasic";

            {
                // This method returns the collection of AFBaseElement objects that were created with this template.
                using (AFElementSearch elementQuery = new AFElementSearch(database, "Meters", queryString))
                {
                    DateTime timeReference = DateTime.Today.AddDays(-7);
                    int      count         = 0;
                    foreach (AFElement meter in elementQuery.FindElements())
                    {
                        foreach (int day in Enumerable.Range(1, 7))
                        {
                            AFTime       startTime = new AFTime(timeReference.AddDays(day - 1));
                            AFTime       endTime   = new AFTime(startTime.LocalTime.AddDays(1));
                            AFEventFrame ef        = new AFEventFrame(database, "*", eventFrameTemplate);
                            ef.SetStartTime(startTime);
                            ef.SetEndTime(endTime);
                            ef.PrimaryReferencedElement = meter;
                            // It is good practice to periodically check in the database
                            if (++count % 500 == 0)
                            {
                                database.CheckIn();
                            }
                        }
                    }
                }
            }
            if (database.IsDirty)
            {
                database.CheckIn();
            }
        }
Пример #4
0
        public static void FindBuildingInfo(AFDatabase database, string templateName)
        {
            if (database == null)
            {
                throw new ArgumentNullException(nameof(database));
            }
            Console.WriteLine("Find Building Info: {0}", templateName);

            AFCategory buildingInfoCat = database.AttributeCategories["Building Info"];
            AFNamedCollectionList <AFAttribute> foundAttributes = new AFNamedCollectionList <AFAttribute>();

            using (AFElementSearch elementQuery = new AFElementSearch(database, "AttributeCattegorySearch", string.Format("template:\"{0}\"", templateName)))
            {
                elementQuery.CacheTimeout = TimeSpan.FromMinutes(5);
                foreach (AFElement element in elementQuery.FindObjects())
                {
                    foreach (AFAttribute attr in element.Attributes)
                    {
                        if (attr.Categories.Contains(buildingInfoCat))
                        {
                            foundAttributes.Add(attr);
                        }
                    }
                }
            }

            Console.WriteLine("Found {0} attributes.", foundAttributes.Count);
            Console.WriteLine();
        }
Пример #5
0
        private List <AFElement> LoadElements()
        {
            try
            {
                if (m_server is null || !m_server.ConnectionInfo.IsConnected)
                {
                    ConnectPI();
                }

                // Pull AF Data - This is New
                AFDatabase m_database = m_server.Databases[m_settings.InstanceName];

                List <AFElement> pmus = new List <AFElement>();

                using (AFElementSearch elementquery = new AFElementSearch(m_database, "ElementSearch", m_settings.Filter))
                {
                    elementquery.CacheInterval = TimeSpan.FromMinutes(10);
                    foreach (AFElement item in elementquery.FindObjects(fullLoad: true))
                    {
                        pmus.Add(item);
                    }
                }

                return(pmus);
            }
            catch (Exception ex)
            {
                return(new List <AFElement>());
            }
        }
Пример #6
0
        static void Main(string[] args)
        {
            // This factory method is new in 2.8.
            PISystem ps = PISystem.CreatePISystem("PISRV01");

            using (new AFProbe("PrintAttributeCounts", ps))
            {
                AFDatabase db = ps.Databases["Feeder Voltage Monitoring"];

                // Build search object
                AFSearchToken searchToken = new AFSearchToken(
                    filter: AFSearchFilter.Root,
                    searchOperator: AFSearchOperator.Equal,
                    value: db.Elements["Assets"].GetPath());

                AFElementSearch elementSearch = new AFElementSearch(db, "Feeders and Transformers", new[] { searchToken });

                Console.WriteLine("Feeders and Transformers");
                // Use full load: true to fully load the elements
                foreach (AFElement element in elementSearch.FindElements(fullLoad: true))
                {
                    Console.WriteLine("Element: {0}, # Attributes: {1}", element.Name, element.Attributes.Count);
                }
                Console.WriteLine();
            }

            Console.WriteLine();
            Console.WriteLine("Press any key to quit");
            Console.ReadKey();
        }
Пример #7
0
        static void Main(string[] args)
        {
            NetworkCredential credential = new NetworkCredential(connectionInfo.user, connectionInfo.password);
            var piSystem = (new PISystems())[connectionInfo.AFServerName];

            piSystem.Connect(credential);
            var afdb = piSystem.Databases[connectionInfo.AFDatabaseName];

            var relayName    = "T001";
            var operatorName = "Scotty";
            var reason       = "Unplanned";
            //find element
            var relaySearch = new AFElementSearch(afdb, "Relay Search", $"Template: 'Antimatter Relay' Name: {relayName}");
            var relay       = relaySearch.FindElements().FirstOrDefault();

            if (relay != null)
            {
                CreateDowntimeEvent(afdb, relay, operatorName, reason);
            }

            //find open eventframes
            var events = FindDowntimeEvents(afdb, relayName, true);

            //close eventframes
            CloseDowntimeEvents(afdb, events);

            Console.ReadKey();
        }
Пример #8
0
 // Exercise 1: Find meters by template
 static void FindMetersBYTemplate(AFDatabase database, string templateName)
 {
     try
     {
         Console.WriteLine("Find Meters By Template: {0}", templateName);
         using (AFElementSearch elementQuery = new AFElementSearch(database, "TemplateSearch", string.Format("template:\"{0}\"", templateName)))
         {
             elementQuery.CacheTimeout = TimeSpan.FromMinutes(5);
             int countDerived = 0;
             foreach (AFElement element in elementQuery.FindElements())
             {
                 Console.WriteLine("Element: {0}, Template: {1}", element.Name, element.Template);
                 if (element.Template.Name != templateName)
                 {
                     countDerived++;
                 }
             }
             Console.WriteLine("Found {0} derived Templates", countDerived);
             Console.WriteLine();
         }
     }
     catch (Exception ex)
     {
         Logs Err = new Logs();
         Err.MyLogFile(ex);
         Console.WriteLine("An Error has occured for details please check the Log File: '" + ex.Message + "'");
         Console.ReadLine();
     }
 }
Пример #9
0
        public static List <AFElement> FindRepositoryById(AFElement orgElement, PluginParams pluginParams, string repositoryId)
        {
            AFSearchToken   templateToken = new AFSearchToken(AFSearchFilter.Template, AFSearchOperator.Equal, pluginParams.RepositoryTemplate.GetPath());
            AFSearchToken   valueToken    = new AFSearchToken(AFSearchFilter.Value, AFSearchOperator.Equal, repositoryId, pluginParams.RepositoryTemplate.AttributeTemplates[RepositoryIdAttributeName].GetPath());
            AFElementSearch elementSearch = new AFElementSearch(orgElement.Database, "FindRepositoryById", new[] { templateToken, valueToken });

            elementSearch.Refresh();
            var searchResult = elementSearch.FindElements(0, true, 1).ToList();

            return(searchResult);
        }
Пример #10
0
        static void FindMetersAboveAverage(AFDatabase database, double AverageVal)
        {
            Console.WriteLine("Average limit is : {0}", AverageVal);
            string templateName  = "MeterBasic";
            string attributeName = "Energy Usage";


            AFElementSearch elesearch = new AFElementSearch(database, "Find Average Above Limit", string.Format("template:\"{0}\" \"|{1}\":>{2}", templateName, attributeName, AverageVal));

            foreach (AFElement ele in elesearch.FindElements())
            {
                Console.WriteLine("Element Name: {0}, Template: {1} , Categories: {2}", ele.Name, ele.Template, ele.CategoriesString);
            }
        }
Пример #11
0
        static void PrintSearchByTemplate(AFDatabase database, string SearchTemplate)
        {
            Console.WriteLine("Query String is : {0}", SearchTemplate);

            var QueryString = string.Format("TemplateName: {0}", SearchTemplate);

            //var QueryString = SearchString;

            using (AFElementSearch search = new AFElementSearch(database, "My Template Search", QueryString))
            {
                search.CacheTimeout = TimeSpan.FromMinutes(5);
                foreach (AFElement element in search.FindElements())
                {
                    Console.WriteLine("Element Name: {0}, Template: {1} , Categories: {2}", element.Name, element.Template, element.CategoriesString);
                }
            }
        }
        static void FindMetersByName(AFDatabase database, string elementNameFilter)
        {
            Console.WriteLine("Find Meters by Name: {0}", elementNameFilter);

            // Default search is as an element name string mask.
            string querystring = string.Format("{0}", elementNameFilter);
            AFElementSearch elementquery = new AFElementSearch(database, "ElementSearch", querystring);
            foreach (AFElement element in elementquery.FindElements())
            {
                Console.WriteLine("Element: {0}, Template: {1}, Categories: {2}",
                    element.Name,
                    element.Template.Name,
                    element.CategoriesString);
            }

            Console.WriteLine();
        }
        static void FindMetersBySubstation(AFDatabase database, string substationLocation)
        {
            Console.WriteLine("Find Meters by Substation: {0}", substationLocation);

            string templateName = "MeterBasic";
            string attributeName = "Substation";
            AFElementSearch elementquery = new AFElementSearch(database, "AttributeValueEQSearch",
                string.Format("template:\"{0}\" \"|{1}\":\"{2}\"", templateName, attributeName, substationLocation));

            int countNames = 0;
            foreach (AFElement element in elementquery.FindElements())
            {
                Console.Write("{0}{1}", countNames++ == 0 ? string.Empty : ", ", element.Name);
            }

            Console.WriteLine("\n");
        }
Пример #14
0
        static void FindMetersByName(AFDatabase database, string elementNameFilter)
        {
            Console.WriteLine("Find Meters by Name: {0}", elementNameFilter);

            // Default search is as an element name string mask.
            string          querystring  = string.Format("{0}", elementNameFilter);
            AFElementSearch elementquery = new AFElementSearch(database, "ElementSearch", querystring);

            foreach (AFElement element in elementquery.FindElements())
            {
                Console.WriteLine("Element: {0}, Template: {1}, Categories: {2}",
                                  element.Name,
                                  element.Template.Name,
                                  element.CategoriesString);
            }

            Console.WriteLine();
        }
        static void FindMetersAboveUsage(AFDatabase database, double val)
        {
            Console.WriteLine("Find Meters above Usage: {0}", val);

            string          templateName  = "MeterBasic";
            string          attributeName = "Energy Usage";
            AFElementSearch elementquery  = new AFElementSearch(database, "AttributeValueGTSearch",
                                                                string.Format("template:\"{0}\" \"|{1}\":>{2}", templateName, attributeName, val));

            int countNames = 0;

            foreach (AFElement element in elementquery.FindElements())
            {
                Console.Write("{0}{1}", countNames++ == 0 ? string.Empty : ", ", element.Name);
            }

            Console.WriteLine("\n");
        }
        static void FindMetersByTemplate(AFDatabase database, string templateName)
        {
            Console.WriteLine("Find Meters by Template: {0}", templateName);

            AFElementSearch elementquery = new AFElementSearch(database, "TemplateSearch", string.Format("template:\"{0}\"", templateName));
            AFElementSearch templatefilter = new AFElementSearch(database, "DerivedTemplates", "templateName:\"MeterAdvanced\"");
            int countderived = 0;
            foreach (AFElement element in elementquery.FindElements())
            {
                Console.WriteLine("Element: {0}, Template: {1}", element.Name, element.Template.Name);
                if (templatefilter.IsMatch(element))
                    countderived++;
            }

            Console.WriteLine("   Found {0} derived templates", countderived);

            Console.WriteLine();
        }
        static void FindMetersBySubstation(AFDatabase database, string substationLocation)
        {
            Console.WriteLine("Find Meters by Substation: {0}", substationLocation);

            string          templateName  = "MeterBasic";
            string          attributeName = "Substation";
            AFElementSearch elementquery  = new AFElementSearch(database, "AttributeValueEQSearch",
                                                                string.Format("template:\"{0}\" \"|{1}\":\"{2}\"", templateName, attributeName, substationLocation));

            int countNames = 0;

            foreach (AFElement element in elementquery.FindElements())
            {
                Console.Write("{0}{1}", countNames++ == 0 ? string.Empty : ", ", element.Name);
            }

            Console.WriteLine("\n");
        }
Пример #18
0
        protected override List <Action> GetActions()
        {
            var           attribute = "WSLG.CtVibMxVibEvtStNew";
            List <Action> actions   = Constants.WindFarms.Select(windFarm => (Action)(() =>
            {
                var actionStopwatch = new AFStopwatch();
                actionStopwatch.Start();

                var afElementSearch = new AFElementSearch(AfDatabase, "MyQuery",
                                                          "Name:" + windFarm + " CategoryName:WTG");

                var elements = afElementSearch.FindElements().ToList();

                //Console.WriteLine("Done : " + elements.Count() + ", " + stopwatch.ElapsedMilliseconds + "ms");

                AFElement.LoadAttributes(elements,
                                         new List <AFAttributeTemplate>
                {
                    AfDatabase.ElementTemplates["WtgBaseTemplate"].AttributeTemplates["WSLG.EvtCt"]
                    .AttributeTemplates[attribute]
                });

                //var countDictionary = new Dictionary<string, int>();

                //foreach (var afElement in elements)
                //{
                //    var count = afElement.Attributes["WSLG.EvtCt"].Attributes[attribute].GetValue().ValueAsInt32();

                //    if (count > 0)
                //    {
                //        countDictionary[afElement.Name] = count;
                //    }
                //}

                TestOutput.AddActionResult(
                    new ActionPerformanceResult
                {
                    ActionMillis = actionStopwatch.ElapsedMilliseconds,
                    ResultCount = elements.Count
                });
            })).ToList();

            return(actions);
        }
Пример #19
0
        static void Main(string[] args)
        {
            NetworkCredential credential = new NetworkCredential(connectionInfo.user, connectionInfo.password);
            var piSystem = (new PISystems())[connectionInfo.AFServerName];

            Console.WriteLine($"connecting to : {connectionInfo.AFServerName} - {connectionInfo.AFDatabaseName}");
            piSystem.Connect(credential);
            var afdb = piSystem.Databases[connectionInfo.AFDatabaseName];

            Console.WriteLine("connected");

            //element search
            var query  = "Template:'Antimatter Relay'";
            var search = new AFElementSearch(afdb, "Relay Search", query);

            var results  = search.FindElements(0, true, 1000);
            var attrList = new AFAttributeList();

            foreach (var element in results)
            {
                Console.WriteLine($"{element.Name}");
                foreach (var attribute in element.Attributes)
                {
                    //not optimized
                    //var snapShot = attribute.GetValue();
                    //Console.WriteLine($"{attribute.Name}: {snapShot.Value.ToString()} {snapShot.UOM}");

                    //optimized
                    attrList.Add(attribute);
                }
            }

            //one call to get values
            var snapShots = attrList.GetValue();

            foreach (var snapShot in snapShots)
            {
                Console.WriteLine($"Element: {snapShot.Attribute.Element.Name} - {snapShot.Attribute.Name}: {snapShot.Value.ToString()} {snapShot.UOM}");
            }

            Console.WriteLine("completed execution");
            //Console.ReadKey();
        }
Пример #20
0
        public static void FindMetersAboveUsage(AFDatabase database, double val)
        {
            Console.WriteLine("Find Meters above Usage: {0}", val);

            string templateName  = "MeterBasic";
            string attributeName = "Energy Usage";

            using (AFElementSearch elementQuery = new AFElementSearch(database, "AttributeValueGTSearch",
                                                                      string.Format("template:\"{0}\" \"|{1}\":>{2}", templateName, attributeName, val)))
            {
                elementQuery.CacheTimeout = TimeSpan.FromMinutes(5);
                int countNames = 0;
                foreach (AFElement element in elementQuery.FindObjects())
                {
                    Console.Write("{0}{1}", countNames++ == 0 ? string.Empty : ", ", element.Name);
                }

                Console.WriteLine(String.Empty);
            }
        }
Пример #21
0
        public static void FindMetersBySubstation(AFDatabase database, string substationLocation)
        {
            Console.WriteLine("Find Meters by Substation: {0}", substationLocation);

            string templateName  = "MeterBasic";
            string attributeName = "Substation";

            using (AFElementSearch elementQuery = new AFElementSearch(database, "AttributeValueEQSearch",
                                                                      string.Format("template:\"{0}\" \"|{1}\":\"{2}\"", templateName, attributeName, substationLocation)))
            {
                elementQuery.CacheTimeout = TimeSpan.FromMinutes(5);
                int countNames = 0;
                foreach (AFElement element in elementQuery.FindObjects())
                {
                    Console.Write("{0}{1}", countNames++ == 0 ? string.Empty : ", ", element.Name);
                }

                Console.WriteLine(String.Empty);
            }
        }
        static void FindMetersByName(AFDatabase database, string elementNameFilter)
        {
            Console.WriteLine("Find Meters by Name: {0}", elementNameFilter);

            // Default search is as an element name string mask.
            var queryString = $"\"{elementNameFilter}\"";

            using (AFElementSearch elementQuery = new AFElementSearch(database, "ElementSearch", queryString))
            {
                elementQuery.CacheTimeout = TimeSpan.FromMinutes(5);
                foreach (AFElement element in elementQuery.FindElements())
                {
                    Console.WriteLine("Element: {0}, Template: {1}, Categories: {2}",
                                      element.Name,
                                      element.Template.Name,
                                      element.CategoriesString);
                }
            }
            Console.WriteLine();
        }
Пример #23
0
        // Helper method used in PrintEnergyUsageAtTime() and PrintDailyAverageEnergyUseage
        // Note that this is an optional method, it is used in the solutions, but it is possible
        // to get a valid solution without using this method
        static AFAttributeList GetAttributes(AFDatabase database, string templateName, string attributeName)
        {
            AFAttributeList attrList = new AFAttributeList();

            using (AFElementSearch elementQuery = new AFElementSearch(database, "AttributeSearch", string.Format("template:\"{0}\"", templateName)))
            {
                elementQuery.CacheTimeout = TimeSpan.FromMinutes(5);
                foreach (AFElement element in elementQuery.FindElements())
                {
                    foreach (AFAttribute attr in element.Attributes)
                    {
                        if (attr.Name.Equals(attributeName))
                        {
                            attrList.Add(attr);
                        }
                    }
                }
            }

            return(attrList);
        }
Пример #24
0
        public static void FindMetersByTemplate(AFDatabase database, string templateName)
        {
            Console.WriteLine("Find Meters by Template: {0}", templateName);

            using (AFElementSearch elementQuery = new AFElementSearch(database, "TemplateSearch", string.Format("template:\"{0}\"", templateName)))
            {
                elementQuery.CacheTimeout = TimeSpan.FromMinutes(5);
                int countDerived = 0;
                foreach (AFElement element in elementQuery.FindObjects())
                {
                    Console.WriteLine("Element: {0}, Template: {1}", element.Name, element.Template.Name);
                    if (element.Template.Name != templateName)
                    {
                        countDerived++;
                    }
                }

                Console.WriteLine("   Found {0} derived templates", countDerived);
                Console.WriteLine();
            }
        }
        static void FindMetersByTemplate(AFDatabase database, string templateName)
        {
            Console.WriteLine("Find Meters by Template: {0}", templateName);

            AFElementSearch elementquery   = new AFElementSearch(database, "TemplateSearch", string.Format("template:\"{0}\"", templateName));
            AFElementSearch templatefilter = new AFElementSearch(database, "DerivedTemplates", "templateName:\"MeterAdvanced\"");
            int             countderived   = 0;

            foreach (AFElement element in elementquery.FindElements())
            {
                Console.WriteLine("Element: {0}, Template: {1}", element.Name, element.Template.Name);
                if (templatefilter.IsMatch(element))
                {
                    countderived++;
                }
            }

            Console.WriteLine("   Found {0} derived templates", countderived);

            Console.WriteLine();
        }
Пример #26
0
        // Exercise 3: Find meters with above-average usage:

        static void FindMetersAboveUsage(AFDatabase database, double val)
        {
            try
            {
                Console.WriteLine("Find Meters Above Usuage: {0}", val);
                string          templateName  = "MeterBasic";
                string          attributeName = "Energy Usage";
                AFElementSearch elementQuery  = new AFElementSearch(database, " AttributeValueGTSearch", string.Format("template:\"{0}\" \"|{1}\":>{2}", templateName, attributeName, val));
                int             countNames    = 0;
                foreach (AFElement element in elementQuery.FindElements())
                {
                    Console.WriteLine("{0}{1}", countNames++ == 0 ? string.Empty : ", ", element.Name);
                }
                Console.WriteLine();
            }
            catch (Exception ex)
            {
                Logs Err = new Logs();
                Err.MyLogFile(ex);
                Console.WriteLine("An Error has occured for details please check the Log File: '" + ex.Message + "'");
                Console.ReadLine();
            }
        }
        static void Main(string[] args)
        {
            NetworkCredential credential = new NetworkCredential(connectionInfo.user, connectionInfo.password);
            var piSystem = (new PISystems())[connectionInfo.AFServerName];

            Console.WriteLine($"connecting to : {connectionInfo.AFServerName} - {connectionInfo.AFDatabaseName}");
            piSystem.Connect(credential);
            var afdb = piSystem.Databases[connectionInfo.AFDatabaseName];

            Console.WriteLine("connected");

            var query  = "Template:'Antimatter Relay' Name:T001";
            var search = new AFElementSearch(afdb, "Relay Search", query);
            var relay  = search.FindElements(0, true, 1).FirstOrDefault();

            if (relay != null)
            {
                var now = DateTime.Now;

                //this will not work, the kind propery is not set and it treated as UTC
                //var end = new DateTime(now.Year, now.Month, now.Day, now.Hour, 0, 0);

                //the correct way to do it
                var end   = new DateTime(now.Year, now.Month, now.Day, now.Hour, 0, 0, DateTimeKind.Local);
                var start = end.AddDays(-1);

                AFTimeRange range  = new AFTimeRange(start, end);
                AFTimeSpan  span   = AFTimeSpan.Parse("1h");
                var         values = relay.Attributes["Ion Charge"].Data.InterpolatedValues(range, span, null, "", false);
                foreach (var value in values)
                {
                    Console.WriteLine($"value: {value.ValueAsDouble()} time: {value.Timestamp.ToString()}");
                }
            }
            Console.WriteLine("completed execution");
            Console.ReadKey();
        }
        public static List <AFElement> FindAllElements(AFDatabase database)
        {
            AFElementSearch search = new AFElementSearch(database, "mySearch", "*");

            return(search.FindElements(fullLoad: true).ToList());
        }
        static void FindMetersAboveUsage(AFDatabase database, double val)
        {
            Console.WriteLine("Find Meters above Usage: {0}", val);

            string templateName = "MeterBasic";
            string attributeName = "Energy Usage";
            AFElementSearch elementquery = new AFElementSearch(database, "AttributeValueGTSearch",
                string.Format("template:\"{0}\" \"|{1}\":>{2}", templateName, attributeName, val));

            int countNames = 0;
            foreach (AFElement element in elementquery.FindElements())
            {
                Console.Write("{0}{1}", countNames++ == 0 ? string.Empty : ", ", element.Name);
            }

            Console.WriteLine("\n");
        }