6 Replies Latest reply on Jul 31, 2012 5:22 PM by dthompson

    COM Connector is returning random errors

    ped1@pge.com

      I have a COM connector that is returning erroneous data when I query it. I used Visual Studio 2010 to create a .net 3.5 console application that queries the COM connector for archive data for a single point. The nature of the errors is that when I request archive data from say date A to date B, the returned data will have, at random, timestamps that are not between A and B. This occurs more and more if I run two or more instances of my program simultaneously. No two runs of the program have produced the same errors. Typical errors look like

       

      2/6/2011 12:23:00 AM bogus timestamp in source data. 7/1/2011 to 10/1/2011

       

      For discussion, I have pared down my code to do just this:

       

       Private        m_StartDate as Date = #7/1/2010#
       Private        m_EndDate as Date = #2/15/2012#

       Private Sub SimpleSinglePointTest()

              Dim my_pisdk As New PISDK.PISDK
              Dim piserver As PISDK.Server= my_pisdk.Servers.Item("DHODNPISQA01")     ' COM connector
              piserver.Open()

              Dim src_pipoints As PISDK.PointList
              src_pipoints = piserver.GetPoints("tag = 'MY_TAG'")

              Dim src_pipoint As PISDK.PIPoint = src_pipoints(1)
              System.Console.Out.WriteLine(src_pipoint.Name)

              Try
                  GetCOMConnectorData(src_pipoint)
              Catch ex As Exception
                  System.Console.Out.WriteLine(" error: " & ex.Message)
              End Try

              piserver.Close()

          End Sub

       

       

       
       Private Sub GetCOMConnectorData(ByVal srcPoint As PISDK.PIPoint)
      
              Dim StartDate As Date, EndDate As Date
              Dim DateAddIncrement As Microsoft.VisualBasic.DateInterval = Microsoft.VisualBasic.DateInterval.Quarter
              StartDate = m_StartDate
              EndDate = DateAdd(DateAddIncrement, 1, StartDate)
      
              Dim PiStartDate As New PITimeServer.PITime
              Dim PiEndDate As New PITimeServer.PITime
              Dim valueIndex As Integer
      
              Do While True
                  PiStartDate.LocalDate = StartDate
                  PiEndDate.LocalDate = EndDate
      
                  srcPoint.Server.MessageLog.PutString("GetCOMConnectorData [" & PiStartDate.LocalDate & " - " & PiEndDate.LocalDate & "].")
      
                  Dim Values As PISDK.PIValues = srcPoint.Data.RecordedValues(PiStartDate, PiEndDate, PISDK.BoundaryTypeConstants.btInside)
                  System.Console.Out.WriteLine(StartDate & " to " & EndDate & " PiUTC[" & PiStartDate.UTCSeconds & " to " & PiEndDate.UTCSeconds & "] & PiRecords: " & Values.Count)
      
                  For valueIndex = 1 To Values.Count
                      ' Have tried PiTimeServer.PiTime.LocalTime,Ticks to be sure time range is valid 
                      If Values.Item(valueIndex).TimeStamp.UTCSeconds < PiStartDate.UTCSeconds Or Values.Item(valueIndex).TimeStamp.UTCSeconds > PiEndDate.UTCSeconds Then
      
                          System.Console.Out.WriteLine(Values.Item(valueIndex).TimeStamp.LocalDate & " bogus timestamp in source data. " & PiStartDate.LocaDate & " to " & PiEndDate.LocalDate)
      
                      End If
      
                  Next
      
                  Values = Nothing
      
                  ' move start/end dates one DateIncrement forward.
                  StartDate = EndDate
                  EndDate = DateAdd(DateAddIncrement, 1, EndDate)
      
                  If EndDate > m_EndDate Then EndDate = m_EndDate
      
                  If StartDate >= m_EndDate Then
                      Exit Do
                  End If
              Loop
      
          End Sub
      

       

       

       

       

       

        • Re: COM Connector is returning random errors
          andreas

          Paul, from your point of view there should be no difference between a COM connector tag or a tag in the PI Archive. Can you request that data via PI DataLink? Does that show the same behavior?

            • Re: COM Connector is returning random errors
              ped1@pge.com

              I agree. And I am able to request the data via DataLink. But it is not possible to see the same behavior using data link because the error shows up only a few times for points with say, 500,000 archive entries. Is there a way to determine what the com connector returned

               

              I have tested the back end of the Com connector, an Oracle database, and the record count is equal to the number of records returned. Order by Timestamp would help find the bogus timestamps, but I've yet to see one.

                • Re: COM Connector is returning random errors
                  andreas

                  Paul

                  Is there a way to determine what the com connector returned

                   

                  this is probably something techsupport can help you better. From the manual it looks like Debug level 4 could output that.

                   

                  Manual

                  Debug Level

                  In order to gain more information for troubleshooting and configuration purposes, the COMCtr prints out messages to the standard debug output.

                   

                  Note: The DbgView application needs to be downloaded from www.microsoft.com/sysinternals

                  To activate the print-out, the following section needs to be added to the .INI file:

                   

                  [Debug]

                   

                  level=n

                   

                   

                   

                  n can be the following:

                   

                  1 print out the internal function names, showing what type of snapshot or archive call have been issued (for the given TagName)

                   

                  2 print out of the elapsed time (in ms) the individual calls (to the relational system) took

                   

                  4 print out of the actual data (time, value [,status]); values of the defined placeholders as well as the actual query

                   

                  The individual debug levels can be combined; that means, if someone wants to know how long a query execution took, as well as to see how the data and placeholders looked like, the defined level will be ( bitwise OR ):

                   

                  level=3

                   

                  The maximum amount of information, which can be printed, occurs with:

                   

                  level=7

                   

                  The default is:

                   

                  level=0

                   

                  See section Debugging INI File Commands for more details about how to visualize the debug print-out.

                   

                   

                  • Re: COM Connector is returning random errors
                    andreas

                    Paul

                    But it is not possible to see the same behavior using data link because the error shows up only a few times for points with say, 500,000 archive entries.e.

                     

                     

                    Paul - is it 500k events per quarter? If so, is it possible to use smaller time chunks to get to a lower event count?