paulip

Calc fail on schedule but successful on manual re-calc

Discussion created by paulip on Apr 20, 2012
Latest reply on Apr 24, 2012 by Ahmad Fattahi

We have an ACE calculation that fails to write the output to tag when calcualting on schedule.  However on manual recalcuation, it is able to write the output.  Anyone has any idea?

 
Dim datExeTime As New PITimeServer.PITime
        Dim datPrev As Date
        Dim datStart As Date
        Dim datEnd As Date
        Dim PIVals As PISDK.PIValues
        Dim MaxValue As Single
        Dim datMax As New PITimeServer.PITime

        Try
            MyBase.SendDataToPI = True
            OUTPUT_TAG.SendDataToPI = True

            ' Get execution time
            datExeTime.UTCSeconds = MyBase.ExeTime

            ' Calculate start date and end date based on execution time
            datPrev = DateAdd(DateInterval.Day, -1, datExeTime.LocalDate)
            datStart = New Date(datPrev.Year, datPrev.Month, datPrev.Day, 0, 0, 0)
            datEnd = New Date(datPrev.Year, datPrev.Month, datPrev.Day, 23, 59, 59)

            ' Get all values within the date range
            PIVals = INPUT_TAG.Values(datStart, datEnd, PISDK.BoundaryTypeConstants.btInside)

            For Each PIVal As PISDK.PIValue In PIVals
                If IsNumeric(PIVal.Value) Then
                    If (datMax.UTCSeconds = 0 Or CSng(PIVal.Value) >= MaxValue) Then
                        MaxValue = CSng(PIVal.Value)
                        datMax = PIVal.TimeStamp
                    End If
                End If
            Next

            If datMax.UTCSeconds > 0 Then
                OUTPUT_TAG.Value(datMax) = MaxValue
                OUTPUT_TAG.PutValue()
            Else
                OUTPUT_TAG.Value(Format(datStart, "dd-MMM-yy 23:59:59")) = 0
                OUTPUT_TAG.PutValue()
            End If

            strModule.PIProperties("Status").Value = "Last Run at " & System.DateTime.Now.ToString("dd-MMM-yyyy HH:mm:ss")

        Catch ex As Exception
            PIACEBIFunctions.LogPIACEMessage(OSIsoft.PI.ACE.MessageLevel.mlErrors, _
                "DAILY PEAK Calculation error at " & _
                Format(Now, "dd-MMM-yyyy HH:mm:ss") & ": " & ex.Message, MyBase.Name)
        End Try

 

Outcomes