public static void RunAnalysesParallel(AFElement element, List<AFTime> aftimes, int analysesThreadCount, ConcurrentQueue<List<AFValue>> dataQueue)
        {
            // for each analyse configured for our element
            Parallel.ForEach(element.Analyses, new ParallelOptions() { MaxDegreeOfParallelism = analysesThreadCount }, (afAnalysis) =>
            {
                TimeSpan evaluationTime;
                int evaluationErrorsCount;
                var analysisRunner = new AnalysisRunner(Configuration.EnableAnalysisErrorOutput);

                var results = analysisRunner.Run(afAnalysis, aftimes, out evaluationTime, out evaluationErrorsCount);

                string prettyElementName = element.Parent != null ? string.Format("{0}\\{1}", element.Parent.Name, element.Name) : element.Name;
                var stats = new StatisticsInfo()
                {
                    AnalyseName = afAnalysis.Name,
                    Duration = evaluationTime,
                    ElementName = prettyElementName,
                    EvaluationsCount = aftimes.Count,
                    EvaluationsErrorCount = evaluationErrorsCount

                };

                // we add statistics to the queue
                Statistics.StatisticsQueue.Add(stats);

                // send data to queue
                if (dataQueue != null)
                {
                    dataQueue.Enqueue(results);
                }

            });
        }
        /// <summary>
        /// After element selection within the Tree View - adjust the attribute selection checkboxes for exporting data
        /// </summary>
        private void afTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            AFElement afElement = afTreeView.AFSelection as AFElement;

            // clear existing checkbox attribute items
            cbParentAttributes.Items.Clear();
            cbChilrenAttributes.Items.Clear();

            if (afElement != null)
            {
                // parents are a single element so you can add attributes directly
                cbParentAttributes.Items.AddRange(afElement.Attributes.Cast <AFAttribute>().ToArray());
                if (afElement.HasChildren)
                {
                    List <string> attributeNames = new List <string>();

                    // Need to loop throught the children elements in case there are different attributes per element
                    // build a list of the attribtue names for later exporting needs
                    foreach (AFElement element in afElement.Elements)
                    {
                        foreach (AFAttribute attribute in element.Attributes)
                        {
                            if (!attributeNames.Contains(attribute.Name))
                            {
                                attributeNames.Add(attribute.Name);
                            }
                        }
                    }

                    // after getting the different attribute names - add these to the checkbox list
                    cbChilrenAttributes.Items.AddRange(attributeNames.ToArray());
                }
            }
        }
Example #3
0
        private static void CreateWeakReferences(AFDatabase database)
        {
            if (database == null)
            {
                return;
            }

            AFReferenceType   weakRefType  = database.ReferenceTypes["Weak Reference"];
            AFElement         meters       = database.Elements["Meters"];
            AFElement         locations    = database.Elements["Geographical Locations"];
            AFElementTemplate cityTemplate = database.ElementTemplates["City"];

            foreach (AFElement meter in meters.Elements)
            {
                string cityName = meter.Attributes["City"].GetValue().ToString();
                if (string.IsNullOrEmpty(cityName))
                {
                    continue;
                }
                AFElement city = locations.Elements[cityName];
                if (city == null)
                {
                    locations.Elements.Add(cityName, cityTemplate);
                }
                if (!city.Elements.Contains(meter.Name))
                {
                    city.Elements.Add(meter, weakRefType);
                }
            }
            if (database.IsDirty)
            {
                database.CheckIn();
            }
        }
Example #4
0
        /// <summary>
        ///  If it is a new search, the elements that fit the criteria are collected and the first is selected.
        ///  Else it iterates through the collection of elements and expands to the node.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void bSearchElements_Click(object sender, EventArgs e)
        {
            currentTreeSearchTimes++;
            if (currentTreeSearch == tbElementSearchName.Text)
            {
                if (currentSearchResults.Count == 0)     //No search results
                {
                    Status("Couldn't find Element Name");
                    return;
                }
                else if (currentTreeSearchTimes < currentSearchResults.Count)     // iterate through.
                {
                    findTreeNode(afTreeViewElements.Nodes[0], currentSearchResults[currentTreeSearchTimes]);
                }
                else     //restart iteration through.
                {
                    currentTreeSearchTimes = 0;
                    findTreeNode(afTreeViewElements.Nodes[0], currentSearchResults[currentTreeSearchTimes]);
                }
            }
            else     //Load Search Results
            {
                currentTreeSearchTimes = 0;
                currentTreeSearch      = tbElementSearchName.Text;
                AFDatabase afdb = control.getAFDatabase();
                currentSearchResults = AFElement.FindElements(afdb, null, "*" + tbElementSearchName.Text + "*", AFSearchField.Name, true, AFSortField.Name, AFSortOrder.Ascending, Int32.MaxValue);

                if (currentSearchResults.Count > 0)
                {
                    findTreeNode(afTreeViewElements.Nodes[0], currentSearchResults[currentTreeSearchTimes]);
                }
            }
        }
Example #5
0
        /// <summary>
        ///  Expands the TreeView along the element path. Iterative process that stops when node is found.
        /// </summary>
        /// <param name="node"> The starting node or node being evaluated. </param>
        /// <param name="element"> The element that is being searched for. </param>
        private bool findTreeNode(TreeNode node, AFElement element)
        {
            string path = element.GetPath();

            if (path.Contains(node.Text) || node.Text == "Elements")
            {
                node.Expand();
                string[] split = Regex.Split(path, node.Text);     //evaluate path string
                if (split.Length > 1 && split[1] == string.Empty)
                {
                    afTreeViewElements.AFSelect(element, element.Parent, path);
                    node.EnsureVisible();
                    node.ToolTipText = path;     // If not set here is null, because of dummy node.
                    AFTreeViewNode_Selected(this, null);
                    return(true);
                }
                else
                {
                    foreach (TreeNode child in node.Nodes)
                    {
                        if (findTreeNode(child, element))
                        {
                            return(true);
                        }
                    }
                }
            }
            return(false);
        }
Example #6
0
        public static void CreateWeakReference(AFDatabase database)
        {
            if (database == null)
            {
                throw new ArgumentNullException(nameof(database));
            }

            Console.WriteLine("Adding a weak reference of the Feeder001 under London");
            AFReferenceType weakRefType = database.ReferenceTypes["Weak Reference"];

            AFElement london     = database.Elements["Geographical Locations"].Elements["London"];
            AFElement feeder0001 = database.Elements["Feeders"].Elements["Feeder001"];

            if (london == null || feeder0001 == null)
            {
                return;
            }

            if (!london.Elements.Contains(feeder0001))
            {
                london.Elements.Add(feeder0001, weakRefType);
            }
            if (database.IsDirty)
            {
                database.CheckIn();
            }
        }
Example #7
0
        static void CreateFeederElements(AFDatabase database)
        {
            AFElementTemplate template = database.ElementTemplates["FeederTemplate"];

            AFElement feeders = database.Elements["Feeders"];

            if (template == null || feeders == null)
            {
                return;
            }

            if (feeders.Elements.Contains("Feeder001"))
            {
                return;
            }
            AFElement feeder001 = feeders.Elements.Add("Feeder001", template);

            AFAttribute district = feeder001.Attributes["District"];

            if (district != null)
            {
                district.SetValue(new AFValue("Hogwarts"));
            }

            AFAttribute power = feeder001.Attributes["Power"];

            power.ConfigString = @"\\PISRV01\SINUSOID";

            database.CheckIn();
        }
Example #8
0
        // Constructor requires an AFElement and 2 strings for start and end time.
        public NotificationsForm(AFElement element, string startTime, string endTime)
        {
            Element = element;

            InitializeComponent();

            tbStartTime.Text = startTime;
            tbEndTime.Text   = endTime;

            TimeBoxValidate(tbStartTime);
            TimeBoxValidate(tbEndTime);

            if (Element != null)
            {
                Text += $" - {Element.Name}";
                var rules = Element.NotificationRules;
                lboxNotificationRules.Items.AddRange(rules.ToArray());
                if (lboxNotificationRules.Items.Count > 0)
                {
                    lboxNotificationRules.SelectedIndex = 0;
                }
            }

            CheckAllButtons();
            FindNotificationInstances();
        }
        static void FindBuildingInfo(AFDatabase database, string templateName)
        {
            Console.WriteLine("Find Building Info: {0}", templateName);

            AFElementTemplate elemTemp        = database.ElementTemplates[templateName];
            AFCategory        buildingInfoCat = database.AttributeCategories["Building Info"];

            AFElement root = database.Elements["Wizarding World"];

            AFNamedCollectionList <AFAttribute> foundAttributes = AFAttribute.FindElementAttributes(
                database: database,
                searchRoot: root,
                nameFilter: "*",
                elemCategory: null,
                elemTemplate: elemTemp,
                elemType: AFElementType.Any,
                attrNameFilter: "*",
                attrCategory: buildingInfoCat,
                attrType: TypeCode.Empty,
                searchFullHierarchy: true,
                sortField: AFSortField.Name,
                sortOrder: AFSortOrder.Ascending,
                maxCount: 100);

            Console.WriteLine("Found {0} attributes.", foundAttributes.Count);
            Console.WriteLine();
        }
Example #10
0
        public void CreateAttributeTest()
        {
            string      path      = Constants.AF_ELEMENT_PATH;
            PIAttribute attribute = new PIAttribute()
            {
                Name                = "Water1",
                Description         = "2008 Water Use",
                Type                = "Int32",
                TypeQualifier       = "",
                DataReferencePlugIn = "Table Lookup",
                ConfigString        = "SELECT [Water Use] FROM [Energy Use 2008] WHERE [Asset ID] = '%Element%'",
                IsConfigurationItem = false,
                IsHidden            = false,
                IsManualDataEntry   = false,
            };

            instance.CreateAttribute(webId, attribute);

            AFElement myElement = AFObject.FindObject(path) as AFElement;

            myElement.Refresh();

            if (myElement != null)
            {
                Assert.IsNotNull(myElement.Attributes["Water1"]);
            }
        }
Example #11
0
        public static PluginParams GetAFSettings(AFElement orgElement)
        {
            try
            {
                //getting repository settings from the element:
                var gitHubOwner           = AFSDKHelpers.GetAttributeValue <string>(orgElement, "Owner");
                var gitHubCredentialToken = AFSDKHelpers.GetAttributeValue <string>(orgElement, "GitHubCredentialToken");
                var gitHubProductName     = AFSDKHelpers.GetAttributeValue <string>(orgElement, "GitHubProductName");

                var settings = new PluginParams()
                {
                    GitHubOwner           = gitHubOwner,
                    GitHubProductName     = gitHubProductName,
                    GithubCredentialToken = gitHubCredentialToken,
                    RepositoryTemplate    = orgElement.Database.ElementTemplates["Repository"]
                };

                ValidateParameters(settings);
                return(settings);
            }
            catch (Exception e)
            {
                throw new CouldNotInitializeSettingsFromAFException(e);
            }
        }
Example #12
0
        // Import to AF
        /// <summary>
        ///  Gets value from Matlab and writes it to AF.
        /// </summary>
        /// <remarks> Will not write, if the Attribute is read-only. A Matlab Variable Name must be input.</remarks>
        /// <param name="path"> The path to the Element to search with.</param>
        /// <param name="workspaceVariableName">The variable name in Matlab being used.</param>
        /// <param name="AFName">The attribute name in AF being written to.</param>
        public void ImportToAF(string path, string workspaceVariableName, string AFName)
        {
            object val = null;
            double dbVal;

            //LOGIC: A variable name must be entered.
            try
            {
                MatlabAccess.GetWorkspaceData(workspaceVariableName, "base", out val);
            }
            catch
            {
                mainForm.Status("Couldn't find the variable in the Matlab Workspace");
            }

            List <string> searchPaths = new List <string>()
            {
                path
            };
            AFKeyedResults <string, AFElement> results = AFElement.FindElementsByPath(searchPaths, null);
            AFElement   Element   = results[path];
            AFAttribute Attribute = Element.Attributes[AFName];

            double.TryParse(val.ToString(), out dbVal);
            try
            {
                AFAccess.writeToAF(Element, Attribute, dbVal);
            }
            catch
            {
                mainForm.Status("Cannot Write to this Attribute");
            }
        }
Example #13
0
        private void configurationTreeView_AfterSelect(object sender, TreeViewEventArgs e)
        {
            AFTreeNode node = (AFTreeNode)e.Node;
            AFElement  selectedCalculation = (AFElement)node.AFObject;

            if (!selectedCalculation.IsRoot)
            {
                calculationName.Text = selectedCalculation.Name;
                CalculationPreference preference = CalculationPreference.CalculationPreferenceFromJSON((string)selectedCalculation.Attributes["configuration"].GetValue().Value);
                queryTextBox.Text = preference.eventFrameQuery;
                Dictionary <AFAttributeTrait, string> limitCalculations = preference.getTraitDictionary();
                foreach (AFAttributeTrait trait in AFAttributeTrait.AllLimits)
                {
                    ComboBox comboBox = (ComboBox)panel1.Controls[trait.Name];
                    comboBox.Text = "None";
                }
                foreach (KeyValuePair <AFAttributeTrait, string> pair in limitCalculations)
                {
                    ComboBox comboBox = (ComboBox)panel1.Controls[pair.Key.Name];
                    comboBox.Text = pair.Value;
                }
                offsetSetting.Text = preference.offset.ToString();
                AFAttribute sensor = AFAttribute.FindAttribute(preference.sensorPath, db);
                afDatabasePicker.AFDatabase = sensor.Database;
                afTreeView.AFRoot           = sensor.Database.Elements;

                afTreeView.AFSelect(sensor, db, preference.sensorPath);
                afTreeView.SelectedNode.EnsureVisible();
                afTreeView.Focus();
            }
        }
Example #14
0
        static void CreateFeederElements(AFDatabase database)
        {
            AFElementTemplate template = database.ElementTemplates["FeederTemplate"];

            AFElement feeders = database.Elements["Feeders"];

            if (template == null || feeders == null)
            {
                return;
            }

            if (feeders.Elements.Contains("Feeder001"))
            {
                return;
            }
            AFElement feeder001 = feeders.Elements.Add("Feeder001", template);

            AFAttribute city = feeder001.Attributes["City"];

            if (city != null)
            {
                city.SetValue(new AFValue("London"));
            }

            AFAttribute power = feeder001.Attributes["Power"];

            power.ConfigString = @"%@\Configuration|PIDataArchiveName%\SINUSOID";

            if (database.IsDirty)
            {
                database.CheckIn();
            }
        }
        /// <summary>
        /// Recursively sum up children's values and store the results at the parent element's output attribute
        /// </summary>
        /// <param name="level">the level of element in the hierarchy (leaf level = 0)</param>
        /// <param name="element">the element to process</param>
        /// <param name="times">the list of timestamps to calculate</param>
        /// <param name="elementToTotals">the dictionary holding total AFValues</param>
        /// <returns>the rollup results at times</returns>
        private AFValues CalculateRollupRecursively(uint level, AFElement element, IList<AFTime> times, Dictionary<AFBaseElement, AFValues> elementToTotals)
        {
            try
            {
                if (level > 0) // Recursively add from the lower level elements
                {
                    List<AFValues> valuesToSum = new List<AFValues>();
                    foreach (var child in element.Elements)
                    {
                        var values = CalculateRollupRecursively(level - 1, child, times, elementToTotals);
                        valuesToSum.Add(values);
                    }

                    return UpdateTotalValues(element, times, valuesToSum);
                }
                else // child is a leaf
                {
                    return elementToTotals[element];
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Exception reported at CalculateRollupRecursively : {0}", ex);
                throw;
            }
        }
Example #16
0
        public DREditor(Geolocation dr, bool isReadOnly)
        {
            InitializeComponent();

            myDR = dr;

            int    pathIndex     = dr.Path.IndexOf('|');
            String elemetPath    = dr.Path.Substring(0, pathIndex);
            String attributePath = dr.Path.Substring(pathIndex + 1, dr.Path.Length - pathIndex - 1);

            AFElement currElement = dr.Database.Elements[elemetPath];

            //Populates the attribute list in the ListBox. This data reference supports only the first level of child attributes
            foreach (AFAttribute attr in currElement.Attributes)
            {
                if (attributePath != attr.ToString())
                {
                    cbLatitude.Items.Add(attr.ToString());
                    cbLongitude.Items.Add(attr.ToString());
                }
                foreach (AFAttribute subAttr in attr.Attributes)
                {
                    if (attributePath != attr.ToString() + '|' + subAttr.ToString())
                    {
                        cbLatitude.Items.Add(attr.ToString() + '|' + subAttr.ToString());
                        cbLongitude.Items.Add(attr.ToString() + '|' + subAttr.ToString());
                    }
                }
            }
        }
Example #17
0
        private void CreateAttributewithoutTagButton_Click(object sender, EventArgs e)
        {
            String AttributeName = Attribute_TextBox.Text.Trim();

            if (AttributeName == "")
            {
                MessageBox.Show("No Attribute Name defined");
            }
            else
            {
                if (afTreeView1.AFSelectedPath == afTreeView1.AFRootPath)
                {
                    MessageBox.Show("Exception:", "You did not select an element");
                }
                else
                {
                    try
                    {
                        //Don't use Selected tag
                        myElement = myAFDatabase.Elements[afTreeView1.AFSelectedPath];
                        myElement.Attributes.Add(AttributeName);
                        myElement.CheckIn();
                    }
                    catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }
                }
            }
        }
Example #18
0
        static void Main(string[] args)
        {
            PISystems myPISystems = new PISystems();
            PISystem  myPISystem  = myPISystems.DefaultPISystem;

            if (myPISystem == null)
            {
                throw new InvalidOperationException("Default PISystem was not found.");
            }
            AFDatabase myDB = myPISystem.Databases["PE"];

            if (myDB == null)
            {
                throw new InvalidOperationException("Database was not found.");
            }
            AFElement element = myDB.Elements["El"];
            int       count;

            using (var search = new AFAnalysisSearch(myDB, "MyAnalysisSearch", string.Format(@"Target:'{0}'", element.GetPath())))
            {
                search.CacheTimeout = TimeSpan.FromMinutes(10);
                count = search.GetTotalCount();
                Console.WriteLine("Found {0} Analyses", count);
                foreach (var item in search.FindObjects(fullLoad: true))
                {
                    Console.Write("Analysis Name = {0},", item.Name);
                    Console.Write("Analysis Description = {0},", item.Description);
                    Console.Write("Analysis Target = {0}", item.Target);
                    Console.WriteLine();
                }
            }
        }
        public void Ex4Sln()
        {
            var standardOutput = new StreamWriter(Console.OpenStandardOutput())
            {
                AutoFlush = true,
            };

            Console.SetOut(standardOutput);

            // note this method either creates or ensures it was created.  That is what we will test
            Ex4BuildingAnAFHierarchySln.Program4.CreateElementTemplate(Database);
            Assert.True(Database.ElementTemplates.Contains("FeederTemplate"));

            // note this method either creates or ensures it was created.  That is what we will test
            Ex4BuildingAnAFHierarchySln.Program4.CreateFeedersRootElement(Database);
            Assert.True(Database.Elements.Contains("Feeders"));

            // note this method either creates or ensures it was created.  That is what we will test
            Ex4BuildingAnAFHierarchySln.Program4.CreateFeederElements(Database);
            Assert.True(Database.Elements["Feeders"].Elements.Contains("Feeder001"));

            Ex4BuildingAnAFHierarchySln.Program4.CreateWeakReference(Database);

            AFElement feeder0001 = Database.Elements["Feeders"].Elements["Feeder001"];
            var       reftype    = Database.Elements["Geographical Locations"].Elements["London"].GetReferenceTypes(feeder0001);

            Assert.Equal("Weak Reference", reftype[0].Name);
        }
Example #20
0
        public void ObserveGarbageCollectorBehavior()
        {
            #region Case One
            AFGlobalSettings.CacheMaxObjects = 100;

            PISystems systems               = new PISystems(true);
            AFElement myElement             = systems.Find <AFElement>(elementPath);
            WeakReference <AFElement> myRef = new WeakReference <AFElement>(myElement);
            myElement = null;

            GC.Collect();
            Assert.True(myRef.TryGetTarget(out myElement));
            #endregion

            #region Case Two
            AFGlobalSettings.CacheMaxObjects = 0;

            systems   = new PISystems(true);
            myElement = systems.Find <AFElement>(elementPath);
            myRef     = new WeakReference <AFElement>(myElement);
            myElement = null;

            GC.Collect();
            Assert.False(myRef.TryGetTarget(out myElement));
            #endregion
        }
Example #21
0
        public void CreateAnalysisTest()
        {
            string     path     = Constants.AF_ELEMENT_PATH;
            PIAnalysis analysis = new PIAnalysis()
            {
                Name                   = "MyNewAnalysis",
                Description            = "",
                AnalysisRulePlugInName = "PerformanceEquation",
                GroupId                = 0,
                MaximumQueueSize       = 0,
                OutputTime             = "",
                Priority               = "High",
                PublishResults         = false,
                Status                 = "Disabled",
                TemplateName           = "",
                TimeRulePlugInName     = "Periodic"
            };

            instance.CreateAnalysis(webId, analysis);

            AFElement myElement = AFObject.FindObject(path) as AFElement;

            myElement.Refresh();

            if (myElement != null)
            {
                Assert.IsNotNull(myElement.Analyses[analysis.Name]);
            }
        }
Example #22
0
        private static void CreateWeakReferences(AFDatabase database)
        {
            if (database == null)
            {
                return;
            }

            AFReferenceType weakRefType = database.ReferenceTypes["Weak Reference"];

            AFElement meters = database.Elements["Meters"];

            AFElement hogwarts = database.Elements["Wizarding World"].Elements["Hogwarts"];

            hogwarts.Elements.Add(meters.Elements["Meter001"], weakRefType);
            hogwarts.Elements.Add(meters.Elements["Meter002"], weakRefType);
            hogwarts.Elements.Add(meters.Elements["Meter003"], weakRefType);
            hogwarts.Elements.Add(meters.Elements["Meter004"], weakRefType);

            AFElement diagonAlley = database.Elements["Wizarding World"].Elements["Diagon Alley"];

            diagonAlley.Elements.Add(meters.Elements["Meter005"], weakRefType);
            diagonAlley.Elements.Add(meters.Elements["Meter006"], weakRefType);
            diagonAlley.Elements.Add(meters.Elements["Meter007"], weakRefType);
            diagonAlley.Elements.Add(meters.Elements["Meter008"], weakRefType);

            AFElement hogsmeade = database.Elements["Wizarding World"].Elements["Hogsmeade"];

            hogsmeade.Elements.Add(meters.Elements["Meter009"], weakRefType);
            hogsmeade.Elements.Add(meters.Elements["Meter010"], weakRefType);
            hogsmeade.Elements.Add(meters.Elements["Meter011"], weakRefType);
            hogsmeade.Elements.Add(meters.Elements["Meter012"], weakRefType);

            database.CheckIn();
        }
Example #23
0
        /// <summary>
        /// Create or update PI point data reference for one AF element
        /// </summary>
        /// <param name="elementToProcess"></param>
        public static void CreateorUpdatePIPointDataReference(AFElement elementToProcess)
        {
            IList <AFElement> listElem = new List <AFElement>();

            listElem.Add(elementToProcess);
            CreateorUpdatePIPointDataReference(listElem);
        }
Example #24
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}");
            //}
        }
Example #25
0
        private static void CreateElements(AFDatabase database)
        {
            if (database == null)
            {
                return;
            }

            AFElement meters;

            if (!database.Elements.Contains("Meters"))
            {
                meters = database.Elements.Add("Meters");
            }
            else
            {
                meters = database.Elements["Meters"];
            }

            AFElementTemplate basic    = database.ElementTemplates["MeterBasic"];
            AFElementTemplate advanced = database.ElementTemplates["MeterAdvanced"];

            foreach (int i in Enumerable.Range(1, 12))
            {
                string name = "Meter" + i.ToString("D3");
                if (!meters.Elements.Contains(name))
                {
                    AFElementTemplate eTemp = i <= 8 ? basic : advanced;
                    AFElement         e     = meters.Elements.Add(name, eTemp);
                }
            }

            database.CheckIn();
        }
Example #26
0
        public void Update()
        {
            Console.WriteLine("Test updating element settings.");

            string    name = "Updated element", desc = "Updated description";
            AFElement element = GenerateElement();

            Console.WriteLine("Test element creation.");
            Assert.IsTrue(_db.CreateElement(element), "Assert creation passed");

            AFElement elem = AFElement.Find(_conn, name);

            Assert.Equals(elem.Name, name);
            Random ran = new Random();

            elem.Name        = name;
            elem.Description = desc;
            Assert.IsTrue(elem.IsDirty);
            elem.CheckIn();

            elem = AFElement.Find(_conn, name);
            Assert.Equals(elem.Name, name);
            Assert.Equals(elem.Description, desc);

            elem.Delete();
            elem.CheckIn();
        }
Example #27
0
        public void ObserveAFCache()
        {
            AFElement element1 = AFObject.FindObject(elementPath) as AFElement;
            AFElement element2 = AFObject.FindObject(elementPath) as AFElement;

            Assert.Same(element1, element2);
        }
Example #28
0
        public static void RunAnalysesParallel(AFElement element, List <AFTime> aftimes, int analysesThreadCount, ConcurrentQueue <List <AFValue> > dataQueue)
        {
            // for each analyse configured for our element
            Parallel.ForEach(element.Analyses, new ParallelOptions()
            {
                MaxDegreeOfParallelism = analysesThreadCount
            }, (afAnalysis) =>
            {
                TimeSpan evaluationTime;
                int evaluationErrorsCount;
                var analysisRunner = new AnalysisRunner(Configuration.EnableAnalysisErrorOutput);

                var results = analysisRunner.Run(afAnalysis, aftimes, out evaluationTime, out evaluationErrorsCount);

                string prettyElementName = element.Parent != null ? string.Format("{0}\\{1}", element.Parent.Name, element.Name) : element.Name;
                var stats = new StatisticsInfo()
                {
                    AnalyseName           = afAnalysis.Name,
                    Duration              = evaluationTime,
                    ElementName           = prettyElementName,
                    EvaluationsCount      = aftimes.Count,
                    EvaluationsErrorCount = evaluationErrorsCount
                };

                // we add statistics to the queue
                Statistics.StatisticsQueue.Add(stats);

                // send data to queue
                if (dataQueue != null)
                {
                    dataQueue.Enqueue(results);
                }
            });
        }
Example #29
0
        private void CreateElement(AFDatabase afDatabase, string name, string path, string template)
        {
            // check if we have a parent element, if yes we get it, if not we set parent to database level
            Logger.InfoFormat("Parsing parameters");
            dynamic parent          = !string.IsNullOrEmpty(path)?(object)AFElement.FindObject(path, afDatabase):afDatabase;
            var     elementTemplate = !string.IsNullOrEmpty(template) ? GetTemplate(afDatabase, template):null;

            //if parent is null, the passed string did not resolve to a parent
            if (parent == null)
            {
                throw new NoNullAllowedException(string.Format("The parent path passed {0} could not resolve to an AF object in the Database", path));
            }

            // here we check if the FindObject method has returned a Element, if not an exception will be thrown
            if (!(parent is AFElement || parent is AFDatabase))
            {
                throw new InvalidAFObjectException();
            }

            // create the element
            Logger.InfoFormat("Creating the element");
            parent.Elements.Add(name, elementTemplate);
            parent.CheckIn();

            Logger.InfoFormat("Element {0} created.", name);
        }
Example #30
0
        private static bool ElementHasValidAttribute(AFElement element, string attributeName)
        {
            var propertyAttribute = element.Attributes[attributeName];

            if (propertyAttribute != null)
            {
                var propertyValue = propertyAttribute.GetValue();
                if (propertyValue != null)
                {
                    if (propertyValue.Value == null)
                    {
                        return(false);
                    }
                    if (propertyValue.Value is Exception)
                    {
                        return(false);
                    }
                    if (propertyValue.Value is string stringValue && string.IsNullOrWhiteSpace(stringValue))
                    {
                        return(false);
                    }
                    return(true);
                }
            }

            return(false);
        }
Example #31
0
        private bool CreateAFTree()
        {
            bool result = true;
            int  i      = 1;

            foreach (Network network in networks)
            {
                AFElement cityElement = piSystemManager.CreateCity(network);
                log.Info($"Create City Element() Processing {i++}/{networks.Count}: {network.Name} {cityElement.Name}");
            }

            piSystemManager.Save();
            foreach (Network network in networks)
            {
                List <BikeStation> bikeStations = bikeStationsDic[network];
                AFElement          cityElement  = piSystemManager.CreateCity(network);
                log.Info($"Create City Station Elements() Processing {i++}/{networks.Count}: {network.Name} {cityElement.Name}");
                foreach (BikeStation bikeStation in bikeStations)
                {
                    bool r = piSystemManager.CreateBikeStation(bikeStation, cityElement);
                    if (r == false)
                    {
                        result = false;
                    }
                }
            }
            piSystemManager.Save();
            return(result);
        }
        public FitBitDataReader(AFElement device)
        {
            _deviceElement = device;

            // load keys from settings
            consumerKey = Settings.General.Default.AppConsumerKey;
            consumerSecret = Settings.General.Default.AppConsumerSecret;
        }
        public static bool IsAnyAttributeDataReferenceDefinedByTemplate(AFElement elm)
        {
            foreach (var item in elm.Attributes)
            {
                if (item.IsDataReferenceDefinedByTemplate)
                    return true;
            }

            return false;
        }
        public override List<AFValue> ReadValues(AFElement element)
        {
            var attribute = element.Attributes["Value"];
            var min= (int)element.Attributes["LowValue"].GetValue().Value;
            var max = (int)element.Attributes["HighValue"].GetValue().Value;

            var newValue = _randomGenerator.Next(min,max);
            var afValue=new AFValue(attribute,newValue,AFTime.Now);

            return new List<AFValue>() {afValue};
        }
Example #35
0
 public FitbitUser(string consumerKey,
                   string consumerSecret,
                   string authToken,
                   string authTokenSecret,
                   AFElement element,
                   bool isNew)
 {
     ApiClient = new FitbitClient(consumerKey, consumerSecret, authToken, authTokenSecret);
     UserElement = element;
     IsNew = isNew;
 }
        public ElementContainer(AFElementTemplate elementTemplate, AFElement containerElement, Boolean isLeaf)
        {
            ElementTemplate = elementTemplate;
            ContainerElement = containerElement;
            _isLeaf = isLeaf;

            if (!isLeaf)
            {
                foreach (var item in ContainerElement.Elements)
                {
                    _elements.Add(item.Name, item);
                }
            }
        } 
        private void GetEventFrames_Click(object sender, EventArgs e)
        {
            if (afTreeView1.AFSelectedPath == afTreeView1.AFRootPath)
            {
                MessageBox.Show("Please Select Element from ElementTree");
            }
            else
            {
                //Clear ListBoxes
                EFListView.Items.Clear();
                EFAttrView.Items.Clear();

                myElement = myAFDatabase.Elements[afTreeView1.AFSelectedPath];
                AFAttributes myAFAttributes = myElement.Attributes;
                if (myAFAttributes.Count == 0)
                {
                    //MessageBox.Show("No Attribute Found");
                }
                else
                {
                    AFNamedCollectionList<AFEventFrame> EFs;
                    String SearchString = "ElementName:"+myElement.Name;
                    //Use EventFrameTemplate for searching
                    myElementTemplate = myAFDatabase.ElementTemplates[EventFrameTemplateComboBox.SelectedItem.ToString()];
                    EFs = myElement.GetEventFrames(AFSearchMode.Overlapped,StartTimeTextBox.Text,EndTimeTextBox.Text,"",null,myElementTemplate,AFSortField.StartTime,AFSortOrder.Descending,0,1000);
                    foreach (AFEventFrame EF in EFs)
                    {
                        string[] displayvalues = new string[5];
                        displayvalues[0] = EF.Name;
                        TimeSpan EFDuration = EF.EndTime - EF.StartTime;
                        //Not ending eventframe returns 9999 year.
                        if (EFDuration.TotalSeconds < 5000000)
                        {
                            displayvalues[1] = EFDuration.TotalSeconds.ToString();
                        }
                        else
                        {
                            displayvalues[1] = "-";
                        }
                        displayvalues[2] = EF.StartTime.LocalTime.ToString();
                        displayvalues[3] = EF.EndTime.LocalTime.ToString();
                        displayvalues[4] = EF.UniqueID;
                        ListViewItem lvi = new ListViewItem(displayvalues);
                        EFListView.Items.Add(lvi);
                    }
                }
            }
        }
        public bool CheckEventFrameExists(AFElement element, string name, AFElementTemplate efTemplate)
        {
            AFNamedCollectionList<AFEventFrame> listEF = element.GetEventFrames(new AFTime("*"), 0, 1, 
                AFEventFrameSearchMode.BackwardFromStartTime, name, null, efTemplate);

            if (listEF.Count > 0)
            {
                PIFitnessLog.Write(TraceEventType.Information, 0, string.Format("Event frame already exists: {0}", name));
                return true;
            }
            else
            {
                return false;
            }

        }
        public bool CreateEventFrame(string name, AFTime start, AFTime end, AFElement primaryReferencedElement, AFElementTemplate efTemplate)
        {
            try
            {
                AFEventFrame newEF = new AFEventFrame(_db, name, efTemplate);
                newEF.SetStartTime(start);
                newEF.SetEndTime(end);
                newEF.PrimaryReferencedElement = primaryReferencedElement;
                newEF.CheckIn();

                _db.CheckIn(AFCheckedOutMode.ObjectsCheckedOutThisThread);
                _db.Refresh();
              
                return true;
            }
            catch
            {
                return false;
            }

        }
        /// <summary>
        /// Converts FitFibt Time Series Data to AF Time Series Data
        /// </summary>
        /// <param name="tsDataList">FitBit Time Series data</param>
        /// <param name="type">Type of fit Bit data - this will determine the attribute name to write into. It can also influence the conversion logic.</param>
        /// <param name="element">The element that contains the attribute to write into</param>
        /// <param name="attributeName">Name of the AF Attribute in which time series data will be written into.</param>
        /// <returns></returns>
        public static AFValues ConvertToAFValues(TimeSeriesDataList tsDataList, TimeSeriesResourceType type, AFElement element, string attributeName)
        {
            // creates the list of values
            AFValues values = new AFValues();
            foreach (var result in tsDataList.DataList)
            {
                AFValue val = null;
                if (type != TimeSeriesResourceType.TimeEnteredBed)
                {
                    val = new AFValue(Convert.ToSingle(result.Value), new AFTime(result.DateTime));
                }
                else
                {
                    val = new AFValue(result.Value, new AFTime(result.DateTime));
                }
                values.Add(val);

            }

            values.Attribute = element.Attributes[attributeName];

            return values;
        }
Example #41
0
 private void afTreeView1_AfterSelect(object sender, TreeViewEventArgs e)
 {
     if (afTreeView1.AFSelectedPath == afTreeView1.AFRootPath)
     {
         //MessageBox.Show("Please Select Element from ElementTree");
     }
     else
     {
         myElement = myAFDatabase.Elements[afTreeView1.AFSelectedPath];
         AFAttributes myAFAttributes = myElement.Attributes;
         AttributeList.Items.Clear();
         if (myAFAttributes.Count == 0)
         {
             //MessageBox.Show("No Attribute Found");
         }
         else
         {
             foreach (AFAttribute at in myAFAttributes)
             {
                 try
                 {
                     string[] displayvalues = new string[2];
                     displayvalues[0] = at.Name;
                     displayvalues[1] = at.GetValue().Value.ToString();
                     ListViewItem lvi = new ListViewItem(displayvalues);
                     lvi.Text = at.Name;
                     AttributeList.Items.Add(lvi);
                 }
                 catch
                 {
                     MessageBox.Show("Error");
                 }
             }
         }
     }
 }
        /// <summary>
        /// Update the config strings by appending random values for location2.
        /// Do this without requiring a checkout.
        /// </summary>
        /// <param name="leaf"></param>
        /// <param name="leafID"></param>
        private void UpdateConfigStrings(AFElement leaf, int leafID)
        {
            // Add Location2 point attributes to the ConfigString.
            // This is used later during PI Point creation to set the point attributes.
            // We choose semi-random numbers for Location2 so there is variability in data
            // generated by the Random Interface.

            Random rnd = new Random(leafID);

            int loc2 = rnd.Next(1, 100);
            string modeString = leaf.Attributes[Constants.LEAF_MODE].ConfigString + string.Format(";location2={0}", loc2);

            string valueString = null;
            if (leaf.Template == _afContext.RandomLeafTemplate)
            {
                loc2 = rnd.Next(2, 10);
                valueString = leaf.Attributes[Constants.LEAF_VALUE].ConfigString + string.Format(";location2={0}", loc2);
            }

            if (leaf.Template == _afContext.SinusoidLeafTemplate)
            {
                loc2 = rnd.Next(0, 100);
                valueString = leaf.Attributes[Constants.LEAF_VALUE].ConfigString + string.Format(";location2={0}", loc2);
            }

            IList<AFAttribute> listAttr = new List<AFAttribute> {
                leaf.Attributes[Constants.LEAF_MODE],
                leaf.Attributes[Constants.LEAF_VALUE]
            };

            IList<string> listConfigStrings = new List<string>
            {
                modeString,
                valueString
            };

            AFAttribute.SetConfigStrings(listAttr, listConfigStrings);
        }
Example #43
0
 private void CreateAttributewithoutTagButton_Click(object sender, EventArgs e)
 {
     String AttributeName = Attribute_TextBox.Text.Trim();
     if (AttributeName == "")
     {
         MessageBox.Show("No Attribute Name defined");
     }
     else
     {
         if (afTreeView1.AFSelectedPath == afTreeView1.AFRootPath)
         {
             MessageBox.Show("Exception:", "You did not select an element");
         }
         else
         {
             try
             {
                     //Don't use Selected tag
                 myElement = myAFDatabase.Elements[afTreeView1.AFSelectedPath];
                 myElement.Attributes.Add(AttributeName);
                 myElement.CheckIn();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
     }
 }
Example #44
0
 private void CreateAttribute_Button_Click(object sender, EventArgs e)
 {
     String AttributeName = Attribute_TextBox.Text.Trim();
     if (AttributeName == "")
     {
         MessageBox.Show("No Attribute Name defined");
     }
     else
     {
         if (afTreeView1.AFSelectedPath == afTreeView1.AFRootPath)
         {
             MessageBox.Show("You have not selected an element", "Exception");
         }
         else
         {
             try
             {
                 if (TagList.SelectedIndices.Count < 1)
                 {
                     //tag is not selected
                     MessageBox.Show("There is no selected tag");
                     //myElement = myAFDatabase.Elements[afTreeView1.AFSelectedPath];
                     //myElement.Attributes.Add(AttributeName);
                 }
                 else
                 {
                     //one or more tag is selected
                     myElement = myAFDatabase.Elements[afTreeView1.AFSelectedPath];
                     AFAttribute myAttribute = myElement.Attributes.Add(AttributeName);
                     AFPlugIn PI_Point = myAFDatabase.PISystem.DataReferencePlugIns["PI Point"];
                     myAttribute.DataReferencePlugIn = PI_Point;
                     myAttribute.ConfigString = @"\\" + myPIServer.Name + @"\" + TagList.SelectedItems[0].Text;
                 }
                 myElement.CheckIn();
             }
             catch (Exception ex)
             {
                 MessageBox.Show(ex.Message);
             }
         }
     }
 }
 private void CollectAndSaveData(FitbitClient fitBitClient,DateTime startTime,DateTime endTime, AFElement deviceElement, TimeSeriesResourceType type,string attributeName)
 {
     var fitBitData = fitBitClient.GetTimeSeries(type, startTime, endTime);
     AFValues values = Helpers.FitBitHelpers.ConvertToAFValues(fitBitData, type, deviceElement, attributeName);
     SharedData.DataQueue.Enqueue(values);
     valuesCount += values.Count;
 }
 /// <summary>
 /// Create or update PI point data reference for one AF element
 /// </summary>
 /// <param name="elementToProcess"></param>
 public static void CreateorUpdatePIPointDataReference(AFElement elementToProcess)
 {
     IList<AFElement> listElem = new List<AFElement>();
     listElem.Add(elementToProcess);
     CreateorUpdatePIPointDataReference(listElem);
 }
Example #47
0
 /// <summary>
 ///  Expands the TreeView along the element path. Iterative process that stops when node is found.
 /// </summary>
 /// <param name="node"> The starting node or node being evaluated. </param>
 /// <param name="element"> The element that is being searched for. </param>
 private bool findTreeNode(TreeNode node, AFElement element)
 {
     string path = element.GetPath();
         if (path.Contains(node.Text) || node.Text == "Elements")
         {
             node.Expand();
             string[] split = Regex.Split(path, node.Text); //evaluate path string
             if (split.Length > 1 && split[1] == string.Empty)
             {
                 afTreeViewElements.AFSelect(element, element.Parent, path);
                 node.EnsureVisible();
                 node.ToolTipText = path; // If not set here is null, because of dummy node.
                 AFTreeViewNode_Selected(this, null);
                 return true;
             }
             else
             {
                 foreach (TreeNode child in node.Nodes)
                 {
                     if (findTreeNode(child, element))
                         return true;
                 }
             }
         }
         return false;
 }
 /// <summary>
 /// This method should be implemented and contain the logic for specific for the web service and to the asset
 /// 
 /// </summary>
 /// <returns>The list of values to be written back to the PI System</returns>
 public abstract List<AFValue> ReadValues(AFElement element);
        private RouteInfo GetRouteInfo(AFElement element, List<TrackPoint> wayPoints, string activityName)
        { 
            if (element == null)
            {
                PIFitnessLog.Write(TraceEventType.Warning, 0, "AF Element is null");
                return null;
            }
            try
            { 
                //update latitude, longitude, and elevation

                AFAttribute elevationAttribute = element.Elements["Routes"].Attributes["Elevation"];
                AFAttribute latitudeAttribute = element.Elements["Routes"].Attributes["Latitude"];
                AFAttribute longitudeAttribute = element.Elements["Routes"].Attributes["Longitude"];

                AFValues listElevationValues = new AFValues();
                AFValues listLatitudeValues = new AFValues();
                AFValues listLongitudeValues = new AFValues();

                foreach (TrackPoint point in wayPoints)
                {
                    AFTime timestamp = new AFTime(point.Time);
                    listElevationValues.Add(new AFValue(elevationAttribute, point.Elevation, timestamp));
                    listLatitudeValues.Add(new AFValue(latitudeAttribute, point.Latitude, timestamp));
                    listLongitudeValues.Add(new AFValue(longitudeAttribute, point.Longitude, timestamp));
                }

                //now update the activity tag

                AFAttribute rkActivityAttribute = element.Elements["Routes"].Attributes["Activity"];

                DateTime temp_time = (from pt in wayPoints
                                      orderby pt.Time ascending
                                      select pt.Time).FirstOrDefault();

                AFValues listActivityValues = new AFValues();
                listActivityValues.Add(new AFValue(rkActivityAttribute, activityName, temp_time));

                temp_time = (from pt in wayPoints
                             orderby pt.Time descending
                             select pt.Time).FirstOrDefault();

                temp_time = temp_time.AddSeconds((double)1.0); //increment by one second
                listActivityValues.Add(new AFValue(rkActivityAttribute, "Idle", temp_time));

                //package all the results

                IList<AFValues> listAFValues = new List<AFValues>();
                listAFValues.Add(listElevationValues);
                listAFValues.Add(listLatitudeValues);
                listAFValues.Add(listLongitudeValues);
                listAFValues.Add(listActivityValues);

                // get the EF info

                AFTime start = listLatitudeValues[0].Timestamp;
                AFTime end = listLatitudeValues[listLatitudeValues.Count - 1].Timestamp;

                string displayedTime = start.UtcTime.ToString();

                string efName = string.Format("{0} - {1} - {2}", element.Name, activityName, displayedTime);

                return new RouteInfo { Element = element,
                                       Values = listAFValues,
                                       ActivityName = activityName,
                                       UniqueName = efName,
                                       UserName = element.Name,
                                       StartTime = start,
                                       EndTime = end };
            }
            catch (Exception ex)
            {
                PIFitnessLog.Write(TraceEventType.Error, 0, ex);
                return null;
            }


        }
Example #50
0
 // Writing Data to the AFServer
 /// <summary>
 /// Writes to AF, and checks in the element.
 /// </summary>
 /// <param name="element"> AFElement being written to.</param>
 /// <param name="attribute"> AFAttribute being changed.</param>
 /// <param name="value"> The new value being imported.</param>
 public static void writeToAF(AFElement element, AFAttribute attribute, double value)
 {
     AFValue input = new AFValue(attribute, value, AFTime.Now);
     attribute.SetValue(input);
     element.CheckIn();
 }
        private void PrintNode(AFElement node, int level)
        {
            Console.WriteLine(string.Format("{0}{1}", "".PadRight(level, '\t'), node.Name));

            foreach (AFElement child in node.Elements)
            {
                PrintNode(child, level + 1); //<-- recursive
            }
        }
        private void PrintHierarchy(AFElement node)
        {
            // this call loads all the hierarchy on the client.  This saves network calls.
            // you should use the full load option if you will be using attributes. this example does not.
            // you can also use partial loading instead, by using AFElement.Loadattributes after this call to
            // load only the attributes you need.  This will be the fastest.
            AFElement.LoadElementsToDepth(new []{node},false, 10, 10000);

            PrintNode(node, 0);
        }
        /// <summary>
        /// Method that creates an AF Attribute on an AF Element
        /// </summary>
        /// <param name="element">AFElement object</param>
        /// <param name="type">Type of attribute to create</param>
        /// <param name="name">name of the new attribute that will be created</param>
        /// <param name="value">Depending on the type of attribute created, the value can be either a scalar value or the ConfigString Value</param>
        public void CreateAttribute(AFElement element, AttributeTypeEnum type, string name, string value)
        {
            var piSystem = element.PISystem;
            var attribute = element.Attributes.Add(name);
            Logger.InfoFormat("Creating attribute {0}", (name));

            switch (type)
            {

                // AFCreateAttribute -e \\tst-srv\db1\AFSDKExamples\CreateAttributes -n Attribute1 -v 10 -t AttDouble
                case AttributeTypeEnum.AttDouble:
                    attribute.Type = typeof(double);
                    attribute.SetValue(new AFValue(double.Parse(value)));
                    break;

                // AFCreateAttribute -e \\tst-srv\db1\AFSDKExamples\CreateAttributes -n Attribute2 -v \\tst-srv\sinusoid -t AttPIPoint
                case AttributeTypeEnum.AttPIPoint:
                    attribute.DataReferencePlugIn = AFDataReference.GetPIPointDataReference(piSystem);
                    attribute.ConfigString = value;
                    break;

                // AFCreateAttribute -e \\tst-srv\db1\AFSDKExamples\CreateAttributes -n Attribute2 -v "SELECT Name FROM Info WHERE Version = 1.5" -t AttTableLookup
                case AttributeTypeEnum.AttTableLookup:
                    attribute.DataReferencePlugIn = piSystem.DataReferencePlugIns["Table Lookup"];
                    attribute.Type = typeof (string); // if a specific type is needed, you'll need to pass it and set it here.
                    attribute.ConfigString = value;
                    break;

                // AFCreateAttribute -e \\tst-srv\db1\AFSDKExamples\CreateAttributes -n Attribute2 -v "\\optimus\CDT158|sinusoid" -t AttPIPointArray
                case AttributeTypeEnum.AttPIPointArray:
                    attribute.DataReferencePlugIn = piSystem.DataReferencePlugIns["PI Point Array"];
                    attribute.ConfigString = value;
                    break;

                // AFCreateAttribute -e \\tst-srv\db1\AFSDKExamples\CreateAttributes -n Attribute2 -v "B=double;[B*10]" -t AttFormula
                case AttributeTypeEnum.AttFormula:
                    attribute.DataReferencePlugIn = piSystem.DataReferencePlugIns["Formula"];
                    attribute.ConfigString = value;
                    break;

                // AFCreateAttribute -e \\tst-srv\db1\AFSDKExamples\CreateAttributes -n Attribute2 -v "Hello ;World" -t AttStringBuilder
                case AttributeTypeEnum.AttStringBuilder:
                    attribute.DataReferencePlugIn = piSystem.DataReferencePlugIns["String Builder"];
                    attribute.ConfigString = value;
                    break;

            }

            Logger.Info("Checking in the changes");

            element.CheckIn();

            Logger.Info("Attibute Created");
        }
Example #54
0
		public string setElement(string elemName)
		{
			try
			{
				m_Element = m_afDb.Elements[elemName];
				return (m_Element.Name);
			}
			catch (Exception)
			{
				return ("");
			}
		}