AnsweredAssumed Answered

[PISDK] PIPoint.PointAttributes.ModifyAttributes() doesn't save the changes to the PIPoint or server

Question asked by nstudanski on Nov 14, 2017
Latest reply on Nov 15, 2017 by nstudanski

Running into a problem with the ModifyAttributes method. Have a custom point with name and attributes and custom Historian object storing a PISDK server. Goal is to read PIPoints from the server and compare to the points set up on local PLC. I'm accessing the PIPoints by IHistorian2.GetPoints2() with * for tags and NamedValues, then accessing that with direct path. Wrote a function that will compare each <key, value> attribute from the custom point and PIPoint to compile a dictionary to turn into NamedValues for the <key, value> of the attributes that differ. This should be more efficient than just writing every attribute individually to the Server. Problem is that my ModifyAttributes call with a list of several NamedValues to change will not show up when importing all the points from PI-SMT excel add-in, and they also have not changed when I debug and write what should be the updated calls. I have not been able to find a save or checkin or any similar method that might be necessary. Is there another call I need to be making to save the changes or anything else to make it work, or will I need to find a different solution? Appreciate any help.



Snippet comes from my Historian class, findDifferences simply compares the two dictionaries from the PI and custom point attributes to return the ones that should be updated. First set of debugs works correctly, so if custom had <Location1, 1> and PI had <Location1, 2> it will have (Location1, 1) pair in it. I would expect that the second debug would then show that it was changed to <Location1, 1> from the PIPoint, but it stays as <Location1, 2>


Dictionary<string, object> needToBeUpdated = utility.FindDifferences(point, pointAttributesDictionary);

            if(needToBeUpdated.Count > 0)
                var changes = new NamedValues();
                NamedValues outErrors;

                foreach (var attribute in needToBeUpdated)
                    changes.Add(attribute.Key, attribute.Value);

                foreach (NamedValue nv in changes)
                    Debug.WriteLine($"{nv.Name} change to {nv.Value}");
                piPoint.PointAttributes.ReadOnly = false;
                piPoint.PointAttributes.ModifyAttributes(changes, out outErrors);
                piPoint.PointAttributes.ReadOnly = true;
                NamedValues newAttributes = piPoint.PointAttributes.GetAttributes();
                foreach (NamedValue attribute in newAttributes)
                    Debug.WriteLine($"{attribute.Name}: {attribute.Value}");