Calculate a value sine the BOM

Discussion created by Craig.McInnes on Sep 26, 2013
Latest reply on Sep 27, 2013 by RJKSolutions

Hi Experts,


I am fairly new to programming and I need to do a calc in ACE that will calculate the event weighted total of rainfall since the Beginning of the Month.
I have some code I use to perform a calc that give me the event weighted total for the last 24 hours. I have tried to modify it to do produce a running total since the BOM.


When I register the calc and it runs I get the following error message in the PI log


PI\cmm\values\PI: Unable to convert a Variant containing a time represention to a double.  The time is invalid. vPIBOM


My code is listed below.  Any help would be appreicated




Imports OSIsoft.PI.ACE
Imports PISDK
Imports OSIsoft.PI.ACE.MessageLevel
Imports OSIsoft.PI.ACE.PIACEBIFunctions


Public Class values


    Inherits PIACENetClassModule
    Private cmm_rain As PIACEPoint
    Private PI80XI398_PV As PIACEPoint


    ' Tag Name/VB Variable Name Correspondence Table
    ' Tag Name                                VB Variable Name
    ' ------------------------------------------------------------
' 80XI398.PV                              PI80XI398_PV
' cmm.rain                                 cmm_rain
    Public Overrides Sub ACECalculations()

        ' *************************************
        ' Calculations
        ' *************************************
        ' RAINFALL.DAILY - Rainfall total since begining of month
        ' UOM - mm
            Dim PISDK As PISDK.PISDK
            Dim srv As PISDK.Server
            Dim pt As PIPoint
            Dim vPIBOM As PITimeServer.PITime

            ' Get Current PI Hour value
            vPIBOM = OSIsoft.PI.ACE.PIACEBIFunctions.BOM(Now)

            'Set SDK and Server objects
            PISDK = New PISDK.PISDK
            srv = PISDK.Servers("PI")

            'Set Point
            pt = srv.PIPoints("80XI398.PV")
'Do an event weighted total and send it to an ACE point
            cmm_rain.Value = pt.Data.Summary("*", "vPIBOM", ArchiveSummaryTypeConstants.astTotal, CalculationBasisConstants.cbEventWeighted).Value
        Catch ex As Exception
            LogPIACEMessage(mlErrors, ex.Message, Me.Name)
        End Try
    End Sub

    Protected Overrides Sub InitializePIACEPoints()
PI80XI398_PV = GetPIACEPoint("PI80XI398_PV")
cmm_rain = GetPIACEPoint("cmm_rain")
    End Sub
    ' User-written module dependent initialization code
    Protected Overrides Sub ModuleDependentInitialization()
    End Sub
    ' User-written module dependent termination code
    Protected Overrides Sub ModuleDependentTermination()
    End Sub
End Class