/// <summary> /// Set AF Attribute's ConfigString based on existing PI points /// </summary> /// <param name="attributes"></param> private static void SetConfigStrings(IList <AFAttribute> attributes) { AFAttributeList attrList = new AFAttributeList(attributes); var points = attrList.GetPIPoint(); IList <string> configStrings = new List <string>(attrList.Count); foreach (var attrPoint in points.Results) { AFAttribute attribute = attrPoint.Key; string configString = attrPoint.Value.GetPath(AFEncodeType.NameThenID).Replace(";{", "?").Replace("}", "").Replace(";?", "?"); configStrings.Add(configString); } AFAttribute.SetConfigStrings(attrList, configStrings); }
/// <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); }