20 Replies Latest reply on Dec 8, 2011 8:19 AM by TelventDMS

    Server.GetPoints method

    sandeep.narang

      Hi team

       

       

       

      I am using Server.GetPoints method to fetch the tags from PI SDK. Suppose if there are large number of tags on the server, is there any way to implement paging using GetPoint method or any other method.

       

       

       

      Thanks and regards

       

      Sachin

        • Re: Server.GetPoints method
          sandeep.narang

          Any alternative ?

            • Re: Server.GetPoints method
              ken

              Sachin,

               

              The Server.GetPoints call supports asynchronous access. Your application can monitor the asynch object you pass as an argument.

               

              It will fire events when tags have been added to the returned point list. It will return partial results and keep going ("paging") unless your application cancels the call via the asynch object.

               

              Look for the PIAsynchStatus object in the help file for information about how it works.

               

              Ken Coates

                • Re: Server.GetPoints method
                  sandeep.narang

                  Hi Ken

                   

                  Thats right, but what if I dont want to make asynch calls.

                   

                  will GetPoints support the call in such a way that I should fetch top 100( or watever number) records only?

                   

                  Thanks

                   

                  Sachin

                    • Re: Server.GetPoints method
                      andreas

                      Sachin, any particular reason why you don't want to use async calls? You can call GetPoints asynchronously - and instead of waiting for events you check the size of the pointlist until it reaches 100. than you cancel the call and use your pointlist of 100 tags.

                        • Re: Server.GetPoints method
                          sandeep.narang

                          Andreas

                           

                          Actually this implementaion is on a WCF service which is consumed by a Java client. It means that we also need to change the behavior of Java client at this moment ( like a callback function). Hence I am stressing more if PI SDK has such kind of resolution in API itself.

                           

                          Sachin

                            • Re: Server.GetPoints method
                              ken

                              Sachin,

                               

                              You can't limit the results to the first "X" number of records without using asynch.

                               

                              Sorry,

                               

                              Ken Coates

                                • Re: Server.GetPoints method
                                  sandeep.narang

                                  Ken

                                   

                                  I tried with using asynch. I have nearly 15000 tags in my system. But when i used Asynch call, only two times StatusChange eevent was hit, first time, list count was 0 and second time it was 15000.

                                   

                                  It means i had no way to stop the asynch call when count reaches 0.

                                    • Re: Server.GetPoints method
                                      andreas

                                      You may check  PointList.Count and cancel the call whenever you reach the # of tags you like.

                                       
                                      PISDKCommon.PIAsynchStatus mPIAsync = new PISDKCommon.PIAsynchStatus();
                                                      PISDK.PointList mPointList = mServer.GetPoints("Tag='*'", mPIAsync);
                                      
                                                      while ((mPointList.Count < 1000) && (mPIAsync.ProgressPercent < 100))
                                                      {
                                                          System.Threading.Thread.Sleep(1);
                                                      }
                                                      mPIAsync.Cancel();
                                      

                                       

                                        • Re: Server.GetPoints method
                                          proberts

                                          Hello  - I have a slightly different question on server.GetPoints.  I have built a tag, name is "65FC410.comp" (case is the important bit, and the 0 is a zero). and when I make the call points=server.GetPoints("tag = '65FC410.comp'") I'm returned a value of points.Count = zero, suggesting that the tag doesn't exist.  How can I make this call find this tag??

                                            • Re: Server.GetPoints method
                                              proberts

                                              I've just tried "improving" my VB code using the answer above as a template - it still doesn't find the tag. Code snippet is: -

                                               
                                              Dim tag as string
                                              Dim target as date
                                              Dim tagPoints As PISDK.PointList            
                                              Dim mPIAsync As New PISDKCommon.PIAsynchStatus
                                              tag="65FC410.comp"
                                              target = Now
                                              target = DateAdd("s", 5, target) ' 5 seconds into the future
                                              tagPoints = gServer.GetPoints("tag = '" & tag & "'", mPIAsync)
                                              Do While ((Now < target) And (mPIAsync.ProgressPercent < 100))
                                                    System.Threading.Thread.Sleep(100)
                                              Loop
                                              mPIAsync.Cancel()
                                              msgBox ("Count=" & tagPoints.Count)
                                              

                                               

                                                • Re: Server.GetPoints method
                                                  proberts

                                                  Hmmm... might have another issue, because for some reason my server time was a day in the future, last synchronised with a time server on nov 1st, but now errors looking for time.windows.com.  Fixed that (by choosing a different internet time server), removed the PtCreated event for Nov 5th using archive editor, added an event for now, but still server.GetPoints can't find the tags...  I'm about to try deleting and re-creating these tags...

                                                    • Re: Server.GetPoints method
                                                      MichaelvdV@Atos

                                                      I have created a float32 point called '65FC410.comp' with SMT, and used the following code (C#) to search for it:

                                                       
                                                       var pointName = "65FC410.comp";
                                                                  var server = new PISDK.PISDK().Servers.DefaultServer;
                                                                  var points = server.GetPoints("tag = '" + pointName + "'");
                                                      
                                                                  foreach (PISDK.PIPoint point in points)
                                                                      Console.WriteLine("Found {0}", point.Name);
                                                                  Console.ReadLine();
                                                      

                                                       

                                                       

                                                      That does work without any issue.

                                                       

                                                      You can try to use the sync method, as your code is using the async method to create something synchronous (with the loop and the sleep statement), it doesn't add anything but complexity at this point.

                                                       

                                                      I'm not sure about the 'Cancel' at the end, why did you add that?

                                                        • Re: Server.GetPoints method
                                                          proberts

                                                          Ok.  I've Set my PiServer to the correct time, deleted the tag and re-created it.  Now the GetPoints method works.  I've resumed my original code (which was synchronous) snippet as below: -

                                                           
                                                          Dim tag as string
                                                          Dim tagPoints As PISDK.PointList
                                                          tag = "65FC410.comp"
                                                          tagPoints = gServer.GetPoints("tag = '" & tag & "'")
                                                          msgBox tagPoints.Count
                                                          

                                                           The cancel was to stop the asynch process I think - code was copied from Andreas' example and converted to VB.

                                                           

                                                           

                                                            • Re: Server.GetPoints method
                                                              andreas

                                                              Yes, the cancel was to stop the call prior to finish. The initial question on that thread was stopping the GetPoints when you have the first 100 tags.

                                                               

                                                              If you are looking for a tag and you are interested in the result you should not cancel :-).

                                                                • Re: Server.GetPoints method
                                                                  TelventDMS

                                                                  Hello everyone,

                                                                   

                                                                  I am not sure if this is the right thread to post my question, but I hope it is OK since topic name is pretty general.

                                                                   

                                                                  We are having large amount of data in MSSQL server and periodically transfer portion of the data of interest into PI Server. Which portion of the data needs to be transferred to PI Server resides in mapping table which have identifiers of interest in our System matched to PI Point Names.

                                                                   

                                                                   

                                                                   

                                                                  What we have in the moment when we need to perform insertion into PI Server is PI Point Name, Value and Timestamp. We would normally retrieve PI Point using it's name and then perform UpdateValue.

                                                                   

                                                                  The question is: having 100 or even 1000 PI Point Names (strings) what is the best way to retrieve PI Points List? Of course, we could iterate through list of PI Point Names and perform one call to PI Server for every PI Point Name in list. However, we hope there is some more efficient way of doing this.

                                                                   

                                                                  Thanks in advance,

                                                                   

                                                                  Branko

                                                                    • Re: Server.GetPoints method

                                                                      I'm not sure whether you need help building the PointList collection or querying for data on that PointList - can you clarify?

                                                                       

                                                                      Also, have you looked at options such as the PI RDBMS Interface? It is a product we provide to do specifically what you seem to want: periodically transfer data from a database such as SQL Server, into PI. With zero line of code.

                                                                       

                                                                      Unfortunately that would mean we wouldn't read from you anymore on this forum about this particular project, but chances are you will achieve your goals in a must faster and cheaper way ;)

                                                                        • Re: Server.GetPoints method

                                                                          Branko,

                                                                           

                                                                          Try IPointList2.AddItems().  Pass in a string array of tags each in the format \\servername\tagname.  Only one network call will be made.

                                                                           

                                                                          I would not recommend more than10k tags at a time!

                                                                            • Re: Server.GetPoints method
                                                                              TelventDMS

                                                                              Thank you both Steve and Charles for good and informational answers, but unfortunately these cannot help me regarding this problem. 

                                                                               

                                                                              Steve, I was asked to implement custom PI Adapter where replication of mapping (our points matched to PI Tag Names) will be performed and also hot - standby pair (warm backup) and also additional disaster recovery site (another pair of hot - standby). We need flexibility and many conditional operations so we wanted to have fine control the execution.

                                                                               

                                                                              To be honest I haven't explored PI RDBMS interface deeply. I will give it a shot in upcoming weeks and let you know the opinion. It will surely have some impacts, whether configuring issues of desired business flow or licensing.

                                                                               

                                                                              Back to Server.GetPoints. We have performed various tests regarding fast read/insert within PI Server because we had demanding requirements, so we have tried PI SDK, PI OLEDB and also PI API 64bit which performed best. We have even been thinking of implementing our interface based on UniInt framework.

                                                                               

                                                                              Since PI SDK is recommended by OSI Soft and considering the fact that PI OLE DB actually makes PI SDK calls, we used PI SDK. We explored many solutions (e.g those "2" -> newer and better interfaces). What was embarrassing is that PI OLE DB performed better for a long time. After many research, tweaking and tuning of the how something was performed at the end we got better results with PI SDK. I made it because i watched how PI OLEDB calls are being translated to PI SDK.

                                                                               

                                                                              Then we slow things down for a while due some other requests and deadlines and now we are back to PI with this relatively simple solution when we speak about what it does but very unpleasant to configure and implement all details of required functionality.

                                                                               

                                                                              So actually what I was asking is not to create PI tags nor to retrieve its data. What bothers me is:

                                                                               

                                                                              1) I have array of strings => PI Tag Names (100 or 1000 items) and have for all of the items one or more actions to perform (insert, update or delete). One actions consists of inserting, removing or updating the value and quality at particular point in time (timestamp).

                                                                               

                                                                              2) I need to retrieve these 100 (1000) PI Points and perfrome UpdateValues or RemoveValues on each of these.

                                                                               

                                                                              At this moment i have chosen to get all the points from Server (Sever.PIPoints) and for every item in my list perform retrieving PIPoint with PIPoints[PointName] and then performing desired operation.

                                                                               

                                                                              This way i made manyserver calls. What I was asking is can I make it in a more efficient manner? I remember that PI API had some methods to send multiple points with multiple values at one call and that PI SDK not. However, PI SDK have plans to be enriched with methods that would send multiple points updated at one call. If i remember well, PI SDK has already had a method to send multiple updates of single PI Point at once.

                                                                               

                                                                              I hope that this answer is detailed enough but not too much.

                                                                               

                                                                              Branko

                                                                                • Re: Server.GetPoints method

                                                                                  If you wish to get all PIPoints in a PI Server, I suggest you use GetPoints2 because it allows you to specify a list of additional Point attributes returned with your array of PIPoint objects.  One network call for the returned PointList.  The query tag='*' may return a large result.

                                                                                   

                                                                                  I suggest you look into organizing points on the PI Server by PointSource.  Each PS could be defined by domain of interest (we do this for our interfaces).  There are optimizations in the PI Server to make the query pointsource='calc', for instance, perform well.