|
|
Rank: Member Groups: Member
Joined: 1/23/2012 Posts: 10
|
Hi, can someone help me to create new PI point with given digital set? I'm using PI SDK in C# and I would like to create new PI point with type digital and I would like to set some digital set. I'm able to create PI point, but only with digital set SYSTEM.
Here is my code:
Server s = gSDK.Servers[serverName];
// get point type from input PointTypeConstants typeConstants = getPointType();
// get point class from input string pointClass = getPointClass(s);
// create new PI point NamedValues nv = new NamedValuesClass(); s.PIPoints.Add(tagName, pointClass, typeConstants, nv);
// Now, I would like to insert value
DateTime dateTime = DateTime.Now; PIAsynchStatus pias = new PIAsynchStatus();
StateSet digitalSet = s.StateSets[stateSet];
s.PIPoints[tagName].Data.UpdateValue(digitalSet[stateName], dateTime, DataMergeConstants.dmReplaceDuplicates, pias);
I have only trouble with this case, setting new digital value...
Any suggestions?
Thanks! Vlad
|
|
|
|
|
OSIsoft vCampus is a subscription-based, online offering that consists of providing everything people need to develop applications on the PI System. We invite you to take a "tour" of the OSIsoft Virtual Campus - also feel free to consult the FAQ or contact OSIsoft vCampus for more details.
|
|
|
Rank: Advanced Member
 Groups: Member
Joined: 11/13/2011 Posts: 77 Location: Middle East
|
I wrote some code, and it works: Code: PIPoint pt = _piServer.PIPoints["BA:ACTIVE.1"]; PointAttribute at = pt.PointAttributes["digitalset"]; StateSet st = _piServer.StateSets[at.Value]; pt.Data.UpdateValue(st["Inactive"], DateTime.Now, DataMergeConstants.dmReplaceDuplicates);
Here, i have digital point BA:ACTIVE.1 This point can have one of states: Active and Inactive The code change value Tell, what happens
|
|
|
Rank: Member Groups: Member
Joined: 1/23/2012 Posts: 10
|
Yes, it works. I'm able to change value for given point. But is it possible to create new point and set digital set to it? Fox example, I would like to create new PI point with digital value from digital set "Modes".
Another case of this issue is:
I have PI point with type digital and it has digital set "Phases". Is it possible to change this digital set for this point to for example "Modes"? Does it make sense?
Thanks!
|
|
|
Rank: Advanced Member
 Groups: Member
Joined: 11/13/2011 Posts: 77 Location: Middle East
|
aaaa, ok Now i understand the question, vkrejcirik Code: NamedValues vals = new NamedValues(); vals.Add("digitalset", "Phases"); _piServer.PIPoints.Add("MyNewDigitalPoint", "classic", PointTypeConstants.pttypDigital, vals);
Here you have: name of point to be created: MyNewDigitalPoint point class = classic point type = pttypDigital also, you have attribute that set digital set of point to Phases (one of my sets) Tell me, what happens
|
|
|
Rank: Member Groups: Member
Joined: 1/23/2012 Posts: 10
|
Thank you for you reply. Yes it works. Now I am able to create new digital point with given digital set. I'm still not able to set value from this set. If I try to set value with command below, it doesn't work.
// get value from selected digital set string stateName = getValueFromDigitalSet(s, stateSet);
object digitalSetName = s.StateSets[stateSet].Name; StateSet digitalSet = s.StateSets[stateSet];
nv.Add("digitalset", ref digitalSetName); // add new point s.PIPoints.Add(tagName, pointClass, typeConstants, nv);
// set value s.PIPoints[tagName].Data.UpdateValue(digitalSet[stateName], dateTime, DataMergeConstants.dmReplaceDuplicates, pias);
I see value "pt created". Any solution?
The second question is, if it is possible to change digital set by exisiting point. For example from "Phases" to "Modes".
Thank you!
Vlad
|
|
|
Rank: Advanced Member
 Groups: Member
Joined: 11/13/2011 Posts: 77 Location: Middle East
|
My code : Code: PIPoint pt = _piServer.PIPoints["BA:ACTIVE.1"]; PointAttribute at = pt.PointAttributes["digitalset"]; StateSet st = _piServer.StateSets[at.Value]; pt.Data.UpdateValue(st["Inactive"], DateTime.Now, DataMergeConstants.dmReplaceDuplicates);
changes the value without problems... And my point value is not "pt created", the point get the value "Inactive" that i set Second question: Code: PIPoint pt = _piServer.PIPoints["BA:ACTIVE.1"]; PointAttribute at = pt.PointAttributes["digitalset"]; pt.PointAttributes.ReadOnly = false; pt.PointAttributes["digitalset"].Value = "Modes"; pt.PointAttributes.ReadOnly = true;
Vlad, i hope it will help you Tell what is going on
|
|
|
Rank: Member Groups: Member
Joined: 1/23/2012 Posts: 10
|
Thank you !! It works great !
I have one more question. Could you explain me, what does it mean "point source"? Can I set this value when I create new PI point?
Thanks for help!
|
|
|
Rank: Advanced Member
 Groups: Member
Joined: 11/13/2011 Posts: 77 Location: Middle East
|
vkrejcirik wrote:Thank you !! It works great !
I have one more question. Could you explain me, what does it mean "point source"? Can I set this value when I create new PI point?
Thanks for help! Hi Vlad Point Source it is some "group" that point belongs to. From "PI SMT user guide.chm": "Point sources are unique single or multi-character strings used to identify the source of data for a PI point. Each PI Point contains a PointSource attribute to enable PI Interfaces or other scanning software to provide data to that point. For example, when a PI Random Interface starts up, it searches the PI Point Database for every PI point that is configured with a PointSource R. The interface then typically examines other PI Point attributes before it loads the points, to ensure the points are valid for its use..." You are welcome! Always it is desire to me to help to someone
|
|
|
Rank: Member Groups: Member
Joined: 1/23/2012 Posts: 10
|
Thanks for you help ! Ok, now I understand what does it mean. So, is it possible to set this point source property when I create new PI point?
Thanks!
|
|
|
Rank: Advanced Member
 Groups: Member
Joined: 11/13/2011 Posts: 77 Location: Middle East
|
vkrejcirik wrote:Thanks for you help ! Ok, now I understand what does it mean. So, is it possible to set this point source property when I create new PI point?
Thanks! Yes, of course For example, you have point source B and you create classic point with type Int16 and name NewPoint_B_1 Code: NamedValues vals = new NamedValues(); vals.Add("pointsource", "B"); _piServer.PIPoints.Add("NewPoint_B_1", "classic", PointTypeConstants.pttypInt16, vals);
Or you can create point and after this change attribute pointsource, as i show above Good luck, Vlad.
|
|
|
Rank: Member Groups: Member
Joined: 1/23/2012 Posts: 10
|
Sounds great! Thanks! It works for me. I see there is property for PI Server : piserver.pointSources. I hope it is possible to print out all point sources on the PI server.
Something like this:
foreach (string pointsource in server.pointsources) { .... }
Right?
I got similar code for point types yet...
Thanks for all your help!
|
|
|
Rank: Advanced Member
 Groups: Member
Joined: 11/13/2011 Posts: 77 Location: Middle East
|
vkrejcirik wrote:
Something like this:
foreach (string pointsource in server.pointsources) { .... }
Right?
Hi Vlad! First, you can not work with PointSources properties, because of it not implemented. Second,you can do: Code: SortedSet<string> pointSources = new SortedSet<string>(); PointList pointList = _piServer.GetPoints("tag='*'");
foreach (PIPoint point in pointList) { string pointSource = point.PointAttributes["pointsource"].Value; if (!pointSources.Contains(pointSource)) { pointSources.Add(pointSource); } }
but it works very slow. Extremely slow, Vlad. You can use parallelism instead of foreach, but maybe it will not work faster. If some one will find other way, i will glad to get it.
|
|
|
Rank: Member Groups: Member
Joined: 1/23/2012 Posts: 10
|
Sounds great ! Thanks a lot !
|
|
|
Rank: Advanced Member
 Groups: Member
Joined: 11/13/2011 Posts: 77 Location: Middle East
|
vkrejcirik wrote:Sounds great ! Thanks a lot ! U r welcome, Vlad, but remember - it is a huge time-penalty operation!
|
|
|
Rank: Member Groups: Member
Joined: 1/23/2012 Posts: 10
|
Ok. I will keep it in mind ! thanks !
|
|
|
Rank: Advanced Member
 Groups: Member
Joined: 11/13/2011 Posts: 77 Location: Middle East
|
vkrejcirik wrote:Ok. I will keep it in mind ! thanks ! I posted some useful information about. here
|
|
|
|
Guest
|