ped1@pge.com

COM Connector is returning random errors

Discussion created by ped1@pge.com on Jul 18, 2012
Latest reply on Jul 31, 2012 by dthompson

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

 

 

 

 

 

Outcomes