46 Replies Latest reply on May 15, 2017 9:21 PM by DElliott

    Automatic Tag Search

    dupuism

      Hello,

       

           I am tryin to perform a tag search using VB. Is there a way to do this without using the tag search object and having the user input the search criteria? I will be connecting to each individual server and using the "*" wildcard in the "tag mask" and "poinit source" fields. I will be placing this information into an excel spreadsheet, along with all of the information attached to each tag.

       

      Thank you

        • Re: Automatic Tag Search
          cescamilla

          There is a way to do this via PI Datalink,

           

           

           

          Do you have any particular reason for wanting to reinvent the wheel?

            • Re: Automatic Tag Search
              dupuism

              No I do not. However, I am using PI SDK for this project. I am essentially automatting a PI-SMT add-in from excel and then putting the spreadsheet on a website.

               

              I will look into the PI Datalink option.

                • Re: Automatic Tag Search

                  Hi Mike,

                   

                  You can also use the PI-SMT addin within Excel to perform tag imports/exports. 

                   

                  From SDK code you can use the GetPoints or GetPointsSQL methods on a PISDK.Server object to retrieve the PI Points (some additional tricks to make it more efficient) but I would have to question whether you would want to allow every single PI Point to be loaded with all attributes - considering I have been working with systems > 300k points recently.  Surely if this is an end user tool they wouldn't be able to make sense of all Points with all Attributes in one go - maybe stagger the Point retrieval using some additional logic..?

                   

                   

                    • Re: Automatic Tag Search
                      dupuism

                      Rhys,

                       

                           Thank you for suggestion GetPoints I have just begun to read more details about how it it used.

                       

                           I am trying to import approximately 10,000 tags into excel. Showing things such as Tag name, archiving, date it was last changed and by whon, compression, creation date, descriptor, and a few others. The reason I am doing so is for the convience of other people that use the information. I will up uploading the sheets to an FTP page. The desired out come is to have the FTP page uploaded with new spreadsheets everyday at midnight with the new information about each PI tag. If I could figure out how to get the code from the PI-SMT add-in or somehow reight code to call the PI-SMT add-in that would probably be the easiest way to do this.

                       

                           I am new to PI so anything suggested I will be looking into, it will be a great leaner opportunity if nothing else.

                       

                      Thank you

                       

                           

                        • Re: Automatic Tag Search

                          You can specify what attributes are loaded when you fetch PI Points, so if you only require specific attributes then you should look in to that to make your code as efficient as possible (basically what PI-SMT does when you only specify certain attributes to import).  There have been a few recent posts on this, seatch for GetPoints.

                           

                          Are your tags tied down to a PointSource or do they belong to multiple point sources?  One option you might have is to just do a search for tags that have changed since your last dump of the tags was completed.  That way you don't repeat data requests to the PI server for the same information.

                           

                          Example:

                          "01-Feb-10 00:00" - Full download of PI Points.  (1st time hit)
                          "02-Feb-10 00:00" - Same search criteria as 01-Feb-10 00:00 with additional criteria of changedate > '01-Feb-10 00:00'. 
                          ...
                          "15-Feb-10 00:00" - Problem with cached data, full download of PI Points again.

                           

                          Obviously this may pose a problem with picking up tags that have been deleted.

                            • Re: Automatic Tag Search
                              MichaelvdV@Atos

                              Another option could be to have a PI OLEDB data import in Excel. You could just SQL syntax to select the specific points and attributes you need. This is very easy to set up and maintain.

                                • Re: Automatic Tag Search

                                  @Michael: I think you should add -- PI OLEDB Fan #1 -- to the -- vCampus Cloaking Device Evangelist -- in your signature

                                    • Re: Automatic Tag Search
                                      MichaelvdV@Atos

                                      Steve Pilon

                                      @Michael: I think you should add -- PI OLEDB Fan #1 -- to the -- vCampus Cloaking Device Evangelist -- in your signature

                                       

                                       

                                       

                                      Yeah, I should! Before returning back to this topic I thought by myself 'Wow, almost every answer I give on vCampus lately involves glorifying PI OLEDB

                                    • Re: Automatic Tag Search
                                      andreas

                                      As one of the victims of the vCampus Cloaking Device I'll have to say that I thought about PIOLEDB as well.

                                       

                                      Mike, is there any particular reason you need an Excel Spreadsheet? You might use PIOLEDB and show the data as a web page. Another option using PIOLEDB could be MYPISQL command line tool:

                                       

                                      C:\PIPC\OLEDB\Tools\MyPISQL>MyPISQL.exe -s <servername> -q "select Tag,descriptor,changedate,changer from PIPOINT"
                                      for example dumps all tags. You simply redirect the output to a file.

                                       

                                      Regards,

                                        • Re: Automatic Tag Search
                                          dupuism

                                          I am just automating the process of using the PI-SMT add-in's import tags operation. The reason I need to put them into an Excel Spreadsheet is because when the files are uploaded to the FTP directory they are linked as .xls files and open in Excel. I will look into the MYPISQL command line tool more. I will also be looking into the other options presented here. Instead of taking the time to do this manually I want to make it auotmated so that I can schedule it to happen at the same time each day.

                                           

                                          Thank you for all of the help.

                                            • Re: Automatic Tag Search
                                              MichaelvdV@Atos

                                              I've written this tiny piece of code for you, which should do (almost) exactly what you need. It now converts to CSV, but you can adapt it easily to use Excel automation or JET.OLEDB.

                                               

                                              I've tested it, and it seems to work :)

                                               

                                              Usage: PiToCsv <piserver> <csvpath> "select * from pipoint"

                                              
                                              

                                              using System;
                                              using System.Collections.Generic;
                                              using System.Linq;
                                              using System.Text;
                                              using System.Data.OleDb;
                                              using System.Data;
                                              using System.IO;

                                              namespace PIOleDbExcelApp
                                              {
                                                  class Program
                                                  {
                                                      static void Main(string[] args)
                                                      {
                                                          if (args.Length < 3)
                                                          {
                                                              Console.WriteLine("Usage: PiToCsv <piserver> <csvpath> <query>");
                                                          }
                                                          Console.WriteLine("Executing SQL on {0} to {1} (SQL:  {2})", args);
                                                          PIOleDbExcel converter = new PIOleDbExcel(args[0], args[1]);
                                                          converter.WriteExcel(args[2]);
                                                          Console.WriteLine("Done");
                                                          Console.ReadKey();
                                                      }


                                                  }

                                                  public class PIOleDbExcel
                                                  {
                                                      public string PiServerName { get; set; }
                                                      public string XlsPath { get; set; }

                                                      public PIOleDbExcel (string piServer, string xlsPath)
                                                   {
                                                          PiServerName = piServer;
                                                          XlsPath = xlsPath;
                                                   }

                                                      public void WriteExcel(string query)
                                                      {
                                                          OleDbConnection piConn = new OleDbConnection(string.Format("Provider = PIOLEDB; Data Source = {0}; Integrated Security = SSPI;",
                                                                                                      PiServerName));
                                                        
                                                          DataTable piRes = new DataTable();
                                                          new OleDbDataAdapter(query, piConn).Fill(piRes);

                                                          var lines = new List<string>();
                                                          foreach (DataRow r in piRes.Rows)
                                                          {
                                                              List<string> line = new List<string>();
                                                              for (int i = 0; i < piRes.Columns.Count; i++)
                                                              {
                                                                  line.Add("\"" + r[+ i].ToString() + "\"");
                                                              }
                                                              lines.Add(string.Join(",", line));
                                                          }

                                                          File.WriteAllLines(XlsPath, lines.ToArray());

                                                      }

                                                  }
                                              }

                                                • Re: Automatic Tag Search
                                                  dupuism

                                                  Michael,

                                                   

                                                  Thanks for the piece of code, it has been helpful. What program did you write and test the program in?

                                                    • Re: Automatic Tag Search
                                                      MichaelvdV@Atos

                                                      Visual Studio 2010 (but runs in 2008). It's C# 4.0, but should be compatible with C# 3.0

                                                       

                                                       

                                                        • Re: Automatic Tag Search
                                                          dupuism

                                                          I am getting a unable to cast object of type System.String to PISDK.PIPoint error on this line of my code:

                                                          pList2.Add(pAtt.Name & ": " & CStr(pAtt.Value))

                                                          the variables are dim as follows:

                                                          Dim pList2 As PointList
                                                          Dim pAtt As PISDKCommon.NamedValue

                                                          Is there a different way to do this same thing. I have been using the Programmers reference to try and fix the error but when I looked at IGetPoints2 Example it looked similar to what I have and I even tried exactly what they had there and it still gave me the same error.

                                                            • Re: Automatic Tag Search

                                                              That's because the PointList object's Add method expected a PISDK.PIPoint object as its argument - in other words, the actual PI Point object rather than just its name.

                                                               

                                                              You'll have to do something like this:

                                                              Dim myPoint As PISDK.PIPoint
                                                              myPoint = myServer.PIPoints(strName)
                                                              pList2.Add(myPoint)
                                                                • Re: Automatic Tag Search
                                                                  dupuism

                                                                  Thanks for the help Steve. However, on the myPoint = myServer.PIPoints(strName) line I am still getting the error. Referencing the Object Browser strName should be defines as a string, which I did but still receive the cannot cast errorr. If I use a varible declared as a PIPoint I also get a cast error. I have included two pieces from the code hopefully they help.

                                                                  myPoint = myServer.PIPoints(Strname)
                                                                  pAttrs = piPoint.PointAttributes.GetAttributes

                                                                  For Each pAtt In pAttrs
                                                                      pList2.Add(myPoint)
                                                                      pList = getEx.GetPoints2("tag='" & " * " & "'", nvs, GetPointsRetrievalTypes.useGetPoints)

                                                                      For Each piPoint In pList
                                                                          pList.Add(piPoint.Name)
                                                                      Next

                                                                    • Re: Automatic Tag Search
                                                                      cescamilla

                                                                      I don't quite grasp what you are trying to do, I can see that is VB... have you tried using pAtt instead of myPoint in the first for each loop? it seems to me you are trying to cast to a stirng a group of points.

                                                                       

                                                                       

                                                                       

                                                                      Also... I would not rely that much on "default" properties, so, just for a sanity check, define which property you want to pass to the .Add method on the pList Object.

                                                                        • Re: Automatic Tag Search
                                                                          dupuism

                                                                          Sorry I didn't make it clear enough. The error actually occurs in the following line of the code:

                                                                          myPoint = myServer.PIPoints(piPoint)

                                                                          I have tried replacing piPoint with varibles of type string and PIPoints but the error still happens. Mayne returning the pointlist is an option. But I am not sure right now because I have not been looking at returning the pointlist.

                                                                            • Re: Automatic Tag Search

                                                                              Hi Mike,

                                                                               


                                                                              When accessing the server's PIPoints collection you need to pass the name of a PI tag.  You will get an error if the PI tag name you supply doesn't exist for the server.

                                                                               

                                                                              Have you tried something as simple as...

                                                                              Dim myPoint As PISDK.PIPoint = myServer.PIPoints("sinusoid")
                                                                                • Re: Automatic Tag Search
                                                                                  dupuism

                                                                                  I had not tried that. I just did and it seems as though the exceptions just keep moving down. How would I do a wildcard PITag search? Is there something "sinusoid" can be replaced with such as the "*"? If I replace myPoint in that line with "sinusoid" an error still occurs. the initial message box that appears still says is is a casting error but the exception listed after clicking ok changes. When it is pList2.Add(myPoint) the error is COMException unhandled. The details state that "Cannot Add Duplicate name to the Collection".

                                                                                   

                                                                                  The exceptionCOM error now occurs in the line: pList2.Add(myPoint)

                                                                                   

                                                                                  Thanks for all of the help. You guys are great.

                                                                                   

                                                                                  Here is the entire section of code incase seeing that will help. The green line is currently commented out and just something I tried to do to fix the problem.

                                                                                  myPoint = myServer.PIPoints("sinusoid")
                                                                                  pAttrs = piPoint.PointAttributes.GetAttributes
                                                                                  For Each pAtt In pAttrs
                                                                                      pList2.Add(myPoint)
                                                                                      'pList2.Add(pAtt.Name & ": " & CStr(pAtt.Value))
                                                                                  Next
                                                                                    • Re: Automatic Tag Search

                                                                                      OK Mike, here is your problem.

                                                                                       

                                                                                      You are adding the same PI tag over again for each "PointAttribute" that exists for the PI tag.  So programmatically "pList2.Add(myPoint)" is correct but you have it within a loop that doesn't change the "myPoint" variable so you are adding a duplicate (as the error indicates).

                                                                                       

                                                                                      I suspect you want to search for a list of tags, then the following would suffice:

                                                                                      
                                                                                      

                                                                                      Dim pList as PISDK.PointList = myServer.GetPoints("Tag='Sinuso*'")

                                                                                      ' Add another tag to the Point List
                                                                                      pList.Add(myserver.PIPoints("BA:Active.1"))

                                                                                      ' Now loop through them

                                                                                      Dim piTag as PISDK.PIPoint
                                                                                      Dim piTagAtt as PISDK.Pointattribute

                                                                                      For Each piTag In pList

                                                                                        ' Do what you need with the piTag object
                                                                                        ' e.g. loop Attributes for the Point
                                                                                        For Each piTagAtt In piTag.PointAttributes
                                                                                          ' piTagAtt.Name & " = " & piTagAtt.Value
                                                                                        Next

                                                                                      Next

                                                                                       

                                                                                      Once you have a point list object you can query data etc.

                                                                                       

                                                                                      Out of curiosity, why do you have a loop for the PointAttributes?

                                                                                        • Re: Automatic Tag Search
                                                                                          dupuism

                                                                                          Thanks for the help. I had a lopp for the point attributes because I was going to enter the specific attributes I wanted into an array and have the program loop through the array and find those attributes for each tag.

                                                                                            • Re: Automatic Tag Search
                                                                                              dupuism

                                                                                              I was finally able to get the PITags to import into an excel sheet. Thanks for all of the help.

                                                                                               

                                                                                              I am now trying to get the attributes for each tag to be put into the same excel sheet.

                                                                                               

                                                                                              I am trying to use .GetAttributes() or .GetSelectedAttributes(PISDKCommon.NamedValues):

                                                                                              Dim piTag As PISDK.PIPoint

                                                                                              Dim pList As PISDK.PointList

                                                                                              Dim piTagAtt As PISDK.PointAttributes

                                                                                              Dim nvs As Named.Values

                                                                                              For Each pitag In pList

                                                                                              objxloutsheet.Cells(I, 1).Value = piTag.Name

                                                                                              objxloutsheet.Cellse(I,2).Value = piTagAtt.GetAttributes()

                                                                                              What would go in the () after GetAttributes or how can I use GetSelectedAttributes to get the attributes I need? That is if what Ithe code will even operate with no errors. Some of the attributes I need are such things as, "archiving", "changedate", and "changer".

                                                                                                • Re: Automatic Tag Search
                                                                                                  andreas

                                                                                                  Hi Mike,

                                                                                                   

                                                                                                  not sure if all your effort is reasonbable to rebuild PI SMT and PI Datalink functions with the PI SDK, but here is some code:

                                                                                                  Dim _PIServer As PISDK.Server
                                                                                                  _PIServer = MyPISDK.Servers(Me.ServPickList1.SelectedServer.Name)
                                                                                                   
                                                                                                  Dim _PIPointList As PISDK.PointList
                                                                                                  _PIPointList = _PIServer.GetPoints("Tag='" & Me.TextBox1.Text & "'")

                                                                                                  ForEach _PIPoint As PISDK.PIPoint In _PIPointList
                                                                                                      Dim _strMessage AsString
                                                                                                      _strMessage = "Name: " + _PIPoint.Name
                                                                                                      Dim _nvs As PISDKCommon.NamedValues
                                                                                                      _nvs = _PIPoint.PointAttributes.GetAttributes()
                                                                                                      ForEach _nv As PISDKCommon.NamedValue In _nvs
                                                                                                          _strMessage += Environment.NewLine
                                                                                                          _strMessage += _nv.Name.ToString() + ": " + _nv.Value.ToString()
                                                                                                      Next
                                                                                                      MessageBox.Show(_strMessage, "GetAttibutes")
                                                                                                  Next

                                                                                                  ForEach _PIPoint As PISDK.PIPoint In _PIPointList
                                                                                                      Dim _strMessage AsString
                                                                                                     
                                                                                                  _strMessage = "Name: " + _PIPoint.Name
                                                                                                      Dim _nvs As PISDKCommon.NamedValues
                                                                                                      _nvs = New PISDKCommon.NamedValues
                                                                                                      _nvs.Add("archiving", "archiving")
                                                                                                      _nvs.Add("changedate", "changedate")
                                                                                                      _nvs.Add("changer", "changer")
                                                                                                      _nvs.Add("datasecurity", "datasecurity")
                                                                                                      _nvs = _PIPoint.PointAttributes.GetSelectedAttributes(_nvs)
                                                                                                      ForEach _nv As PISDKCommon.NamedValue In _nvs
                                                                                                          _strMessage += Environment.NewLine
                                                                                                          _strMessage += _nv.Name.ToString() + ": " + _nv.Value.ToString()
                                                                                                      Next
                                                                                                     
                                                                                                  MessageBox.Show(_strMessage, "GetSelectedAttributes")
                                                                                                  Next

                                                                                                  Note that you can retrieve the Point Attributes as an PI Datalink formula.

                                                                                                   

                                                                                                  Hope this helps,

                                                                                                    • Re: Automatic Tag Search
                                                                                                      dupuism

                                                                                                      Thanks for the help Andreas. I have everything working up to uploading it to an FTP page. However, the attribute "pointtype" is not showing up correctly in my excel spreadsheet. It is showing up as 12 instead of float32 for the few tags I am testing with right now. Would I need to convert this attribute into a string? The following code is what I cam using to list all of the attributes, for one of the rows.

                                                                                                      For Each nv As PISDKCommon.NamedValue In nvs
                                                                                                          objxloutsheet.Cells(I, K).Value = nv.Value
                                                                                                          K += 1
                                                                                                      Next
                                                                                                        • Re: Automatic Tag Search
                                                                                                          andreas

                                                                                                          Mike,

                                                                                                           

                                                                                                          You will need to convert this. To make it easier for you, you should use the point type constants from the PISDK, for example PISDK.PointTypeConstants.pttypFloat32.

                                                                                                           

                                                                                                           

                                                                                                            • Re: Automatic Tag Search
                                                                                                              dupuism

                                                                                                              Ok, I tried that and it is still showing up as 12. However, another question I have. i that not all of the "pointtypes" are Float32 some are int16, etc.

                                                                                                               

                                                                                                              I am thinking I will have to do some sort of check to see which it is then convert it to say what it is somehow. Does this sound correct?

                                                                                                               

                                                                                                              For example:

                                                                                                               

                                                                                                              If pointtype = 12, it would convert to Float32

                                                                                                               

                                                                                                              If pointtype = 6, it would convert to Int16

                                                                                                                • Re: Automatic Tag Search
                                                                                                                  andreas

                                                                                                                  Sorry, I was not clear in my response - yes, you will have to do some check and convert to string by yourself. The constants are just for replacing the 12 for example.

                                                                                                                   

                                                                                                                  Here are some lines from the PISDK help which could help you get started:

                                                                                                                  Private Function PointTypeString(ptType As PointTypeConstants) As String
                                                                                                                    Select Case ptType
                                                                                                                      Case pttypBlob
                                                                                                                        PointTypeString = "Blob"
                                                                                                                      Case pttypDigital
                                                                                                                        PointTypeString = "Digital"
                                                                                                                      Case pttypFloat16
                                                                                                                        PointTypeString = "16-bit float"
                                                                                                                      Case pttypFloat32
                                                                                                                        PointTypeString = "32-bit float"
                                                                                                                      Case pttypFloat64
                                                                                                                        PointTypeString = "64-bit float"
                                                                                                                      Case pttypInt16
                                                                                                                        PointTypeString = "16-bit integer"
                                                                                                                      Case pttypInt32
                                                                                                                        PointTypeString = "32-bit integer"
                                                                                                                      Case pttypString
                                                                                                                        PointTypeString = "String"
                                                                                                                      Case pttypNull
                                                                                                                        PointTypeString = "Unknown point type"
                                                                                                                    End Select
                                                                                                                  Exit Function

                                                                                                                  So in your case you would say:

                                                                                                                   

                                                                                                                  if pointtype = PISDK.PointTypeConstants.pttypFloat32, you convert to "Float32"

                                                                                                                   

                                                                                                                  if pointtype = PISDK.PointTypeConstants.pttypInt16, you convert to "Int16" and so on.

                                                                                                                    • Re: Automatic Tag Search
                                                                                                                      dupuism

                                                                                                                      Thank you. I am looking at doing a check for the nv of "pointtype" but I think I will be a cast error. but as of right now this is what I am thinking of doing.

                                                                                                                      For Each nv As PISDKCommon.NamedValue In nvs
                                                                                                                          If nv = "pointtype"Then
                                                                                                                              Call PointTypeString(nv.Value)
                                                                                                                          End If
                                                                                                                          objxloutsheet.Cells(I, K).Value = nv.Value
                                                                                                                          K += 1
                                                                                                                      Next
                                                                                                                        • Re: Automatic Tag Search
                                                                                                                          dupuism

                                                                                                                          As I expected i am getting the Cast Exception. I will continue to work on it. If anyone has any ideas, I would appreciate it.

                                                                                                                            • Re: Automatic Tag Search

                                                                                                                              The "nv" variable is of type PISDKCommon.NamedValue not a string, so you need to check the Name property:

                                                                                                                              If nv.Name.ToLower = "pointtype" then
                                                                                                                              ...
                                                                                                                              End If
                                                                                                                              • Re: Automatic Tag Search
                                                                                                                                dupuism

                                                                                                                                Ok I have something that works but it is probably not that most effiecent way to write it. It is a series of If statements for each possibility of PointType. And it writes the correct string directly to the cell.

                                                                                                                                If objxloutsheet.Cells(I, 35).Value = "12" Then

                                                                                                                                objxloutsheet.Cells(I, 35).Value = "Float32"

                                                                                                                                End If

                                                                                                                                If objxloutsheet.Cells(I, 35).Value = "102" Then

                                                                                                                                objxloutsheet.Cells(I, 35).Value = "Blob"

                                                                                                                                End If

                                                                                                                                If ETC.......... For all of the possible cases. It seems like this is very inefficent and could be slowing down the program significantly. I will continue to look for a better solution but this is all I could think of to do. 

                                                                                                                                 

                                                                                                                                I also tried using Rhys suggestion:

                                                                                                                                If nv.Name.toLower = "pointtype" Then
                                                                                                                                       Call PointTypeString(ptType)
                                                                                                                                End If

                                                                                                                                Function PointTypeString (ByRef ptType As PointTypeConstants) As String
                                                                                                                                    Select Case ptType
                                                                                                                                        Case PointTypeConstants.pttypBlob
                                                                                                                                            objxloutsheet.Cells(I, 35) = "Blob"
                                                                                                                                        Case PointTypeConstants.pttypDigital
                                                                                                                                ETC.....

                                                                                                                                But it never seemed to call the function. I appreciate  the help. It is probably because of how how have the function parameters defined, so I will continue to work on why this does not work.

                                                                                                                                 

                                                                                                                                Thanks again for the help

                                                                                                                                  • Re: Automatic Tag Search
                                                                                                                                    andreas

                                                                                                                                    Mike,

                                                                                                                                     

                                                                                                                                    the following is done in VB.NET - so i hope it will work in VBA as well:

                                                                                                                                     

                                                                                                                                    getting the attributes:

                                                                                                                                    ForEach _PIPoint As PISDK.PIPoint In _PIPointList
                                                                                                                                            Dim _strMessage AsString
                                                                                                                                            _strMessage = "Name: " + _PIPoint.Name
                                                                                                                                            Dim _nvs As PISDKCommon.NamedValues
                                                                                                                                            _nvs = New PISDKCommon.NamedValues
                                                                                                                                            _nvs.Add("archiving", "archiving")
                                                                                                                                            _nvs.Add("changedate", "changedate")
                                                                                                                                            _nvs.Add("changer", "changer")
                                                                                                                                            _nvs.Add("datasecurity", "datasecurity")
                                                                                                                                            _nvs.Add("pointtype", "pointtype")
                                                                                                                                            _nvs = _PIPoint.PointAttributes.GetSelectedAttributes(_nvs)
                                                                                                                                            ForEach _nv As PISDKCommon.NamedValue In _nvs
                                                                                                                                                If (_nv.Name.ToLower() = "pointtype") Then
                                                                                                                                                    _strMessage += Environment.NewLine
                                                                                                                                                    _strMessage += _nv.Name.ToString() + ": " + PointType2String(_nv.Value)
                                                                                                                                                Else
                                                                                                                                                    _strMessage += Environment.NewLine
                                                                                                                                                    _strMessage += _nv.Name.ToString() + ": " + _nv.Value.ToString()
                                                                                                                                                EndIf
                                                                                                                                            Next
                                                                                                                                            MessageBox.Show(_strMessage, "GetSelectedAttributes")
                                                                                                                                        Next

                                                                                                                                    Here the translation from pointtype to string


                                                                                                                                    Function PointType2String(ByRef ptType As PISDK.PointTypeConstants) AsString
                                                                                                                                         SelectCase ptType
                                                                                                                                             Case PISDK.PointTypeConstants.pttypBlob
                                                                                                                                                 Return"Blob"
                                                                                                                                             Case PISDK.PointTypeConstants.pttypDigital
                                                                                                                                                 Return"Digital"
                                                                                                                                             Case PISDK.PointTypeConstants.pttypFloat16
                                                                                                                                                 Return"Float16"
                                                                                                                                             Case PISDK.PointTypeConstants.pttypFloat32
                                                                                                                                                 Return"Float32"
                                                                                                                                             Case PISDK.PointTypeConstants.pttypFloat64
                                                                                                                                                 Return"Float64"
                                                                                                                                             Case PISDK.PointTypeConstants.pttypInt16
                                                                                                                                                 Return"Integer16"
                                                                                                                                             Case PISDK.PointTypeConstants.pttypInt32
                                                                                                                                                 Return"Integer32"
                                                                                                                                             Case PISDK.PointTypeConstants.pttypNull
                                                                                                                                                 Return"Unknown"
                                                                                                                                             Case PISDK.PointTypeConstants.pttypString
                                                                                                                                                 Return"String"
                                                                                                                                             Case PISDK.PointTypeConstants.pttypTimestamp
                                                                                                                                                 Return"Timestamp"
                                                                                                                                         EndSelect
                                                                                                                                         Return"Unknown"
                                                                                                                                    EndFunction

                                                                                                                                     

                                                                                                                                    hope this helps.

                                                                                          • Re: Automatic Tag Search

                                                                                            Mike Dupuis

                                                                                            I need to put them into an Excel Spreadsheet is because when the files are uploaded to the FTP directory they are linked as .xls files and open in Excel
                                                                                            Another way around, which does not involve programming, is to schedule a .bat file with a PIConfig script to run every day. This PIConfig script could list all the points and their attributes, and export all that to .CSV; these .CSV files can be open with Excel no problem.

                                                                                             

                                                                                            As much as enjoy programming, there are cases where the simpler the better...
                                                                                            Hope this helps!

                                                                                        • Re: Automatic Tag Search
                                                                                          Rick Davin

                                                                                          While this won't help the original poster, Mike, I do want to rally around Michael's call for OLEDB if all you want is the tag names and especially if you have lots of tags in your PI server.  For me to use a PISDK GetPoints to filter out 9,000 points on a server with 1.7 million tags takes 3-minutes.  For me to use PI OLEDB to return the same 9,000 tag names on the same server takes 15-seconds.

                                                                                           

                                                                                           

                                                                                            • Re: Automatic Tag Search

                                                                                              Rick Davin

                                                                                              For me to use a PISDK GetPoints to filter out 9,000 points on a server with 1.7 million tags takes 3-minutes.  For me to use PI OLEDB to return the same 9,000 tag names on the same server takes 15-seconds.
                                                                                              Well the PI OLEDB Provider does use the PI SDK under the hood, so in theory you should be able to achieve very similar results. You may very well be using a different method than the one used by PI OLEDB; you could confirm by enabling logging (with at least level 1) where you run the PI OLEDB query, and check the log file to see what PI SDK call(s) are being made.

                                                                                               

                                                                                              Out of curiosity, have you tried using the GetPoints2 method out of the IGetPoints2 interface (a secondary interface supported by the Server object)?

                                                                                               

                                                                                               

                                                                                                • Re: Automatic Tag Search

                                                                                                  Won't the PI server cache the query for Points..?  i.e. Run the PISDK first & it takes 3 minutes.  Run the OLEDB query and the server returns the cached results thus 15 seconds?

                                                                                                    • Re: Automatic Tag Search

                                                                                                      Rhys @ RJK Solutions

                                                                                                      Won't the PI server cache the query for Points..?
                                                                                                      As far as I know, there is no such thing as a "recent PI Points" cache on the PI Server.

                                                                                                       

                                                                                                      On the other hand, there is a local cache managed by the PI SDK on the client machine. However, this cache is not cross-applications - actually, it's not even cross-thread: each top-level PI SDK object creates and manages its own cache.

                                                                                                      • Re: Automatic Tag Search
                                                                                                        MichaelvdV@Atos

                                                                                                        From what I learned, PI OLEDB has some heavy optimization, threading and parallel call execution. Basically, if you want the same performance with a PISDK implementation as PI OLEDB has, you would basically be reinventing the wheel.

                                                                                                         

                                                                                                        Just my 2 cents, but that's what I learned from Bodo :)

                                                                                              • Re: Automatic Tag Search

                                                                                                Just to make sure we are on the same page, this is the PI TagConfigurator add-in, which shows up under a menu labeled "PI-SMT". This same menu also hosts other add-ins such as the PI Module Database Builder add-in.

                                                                                                 

                                                                                                That said, I would definitely look into Cristobal's suggestion of using PI DataLink:

                                                                                                • First use the "Attribute Mask to Tag" function to populate column A with all your tags
                                                                                                • Then use "Tag Attributes" function to populate columns B, C, etc. with the desired PI Point attributes
                                                                                            • Re: Automatic Tag Search
                                                                                              cescamilla

                                                                                              We do have a PI-SMT add-in that just needs you to input values on the cells...

                                                                                               

                                                                                               

                                                                                               

                                                                                              I'll look for a reference around here, but this is already provided and may work way better too!