2 Replies Latest reply on Sep 13, 2012 5:05 AM by inform2prabhat

    The latest value cannot be retrieved from MDB unless we restart the program in ACE scheduler

    cw.ng

      Hi,

       

      Our Users want to edit the property value in the MDB when the proram is running. I found that the property value cannot be retrieved from the ACE program after our users change the values. In addition, we disabled the caching in the ACE scheduler.

       

      For the Context, we put the code in ModuleDependentInitialization. Also, We did try to put in the ACECalculation, it seemed to work but it causes insufficient memory problem.  Since our users cannot have access on the ACE scheduler, is there any workaround so that program can retrieve the values immediately without restarting the ACE program?

       

      Protected Overrides Sub ModuleDependentInitialization()
              sContext = GetPIModuleFromPath(Context)
              sModule = sContext.ParentList(1)
      End Sub

       

      Protected Overrides Sub ModuleDependentTermination()
              sContext = Nothing
              sModule = Nothing
      End Sub

       

      Regards

       

       

       

       

       

       

       

       

        • Re: The latest value cannot be retrieved from MDB unless we restart the program in ACE scheduler
          mhamel

          @Chung: The answer to your question is yes you can!

           

          If the property value you are talking about is changed not so frequently, I mean weekly or monthly, you can implement a routine within the ACECalculations method to verify if the value has changed or not. Otherwise, if the value is changed regularly, I strongly suggest you use a PI Point to store that information. PI Module Database is not meant to store information that changes regularly but instead occasionally. A value that changes many times in a week will be considered as a process value than a set or control point, and should be stored within a PI Point.

           

          As an option, you can create multiple versions of your value, using the obsolete and effective date property of PI Module, and make use of them within the PI ACE Module. This technique is interesting if you want to perform accurate past calculations.

           

          Generally, the routine can validate once a day or once every hour that the property value has changed or not. You don't want to validate every time the calculation is triggered because it will put pressure on PI Module Database especially if you have multiple contexts using the same information.

           

          I have added an excerpt of code to validate/read the value against PI Module Database minimally once an hour or more if your trigger is based on events.

           
          'Class-level objects
          Const _ValidationHour As Int16 = 1
          Dim _LastValue As Single
          Dim _LastTimeStamp As Date
          
          Private MyPoint1 As PIACEPoint
          Private MyPoint2 As PIACEPoint
          Private MyPoint3 As PIACEPoint
          '...
          
          '
          '      Tag Name/VB Variable Name Correspondence Table
          ' Tag Name                                VB Variable Name
          ' ------------------------------------------------------------
          ' sinusoid                                sinusoid
          '
          Public Overrides Sub ACECalculations()
               'Calculate time elapsed since last validation.
               Dim Delta As TimeSpan = Date.Now.Subtract(_LastTimeStamp)
               If Delta.TotalHours >= _ValidationHour Then
          
                    'Read the value against PI Module Database.
                    ReadMyValue(_LastValue)
          
                    'Store last timestamp.
                    _LastTimeStamp = Date.Now()
               End If
          
               'Execute your calculation
               '...
               'For example, your equation can be like...
               MyPoint3.Value = MyPoint2.Value + (MyPoint1.Value * _LastValue)
          End Sub
          
          Protected Overrides Sub InitializePIACEPoints()
               MyPoint1 = GetPIACEPoint("tag1...")
               MyPoint2 = GetPIACEPoint("tag2...")
               MyPoint3 = GetPIACEPoint("tag3...")
          End Sub
          
          '
          ' User-written module dependent initialization code
          '
          Protected Overrides Sub ModuleDependentInitialization()
               'Initialize counters and flags.
               _LastTimeStamp = Date.Now()
          
               'Read the value against PI Module Database for the first time
               ReadMyValue(_LastValue)
          End Sub
          
          '
          ' User-written module dependent termination code
          '
          Protected Overrides Sub ModuleDependentTermination()
          End Sub
          
          Public Sub ReadMyValue(ByRef Value As Single)
               'Put your instructions here on how to read PI Module Database.
               '...
          End Sub
          

           

           

          Let me know if that helped.

            • Re: The latest value cannot be retrieved from MDB unless we restart the program in ACE scheduler
              inform2prabhat

              Hi Chung,

               

              You can use the IRefresh interface for updating the MDB. Your properties will be still on the

               

              ModuleDependentInitialization() sub routine. Check below code. Hope that helps.

               

              --------------------------------------------------------

               

              Imports OSIsoft.PI.ACE

               

              Imports OSIsoft.PI.ACE.PIACEBIFunctions

               

              Imports PISDK

               

              Public Class Irefresh_MDB_Test

               

                 Inherits PIACENetClassModule

               

                 Private outputtag1 As PIACEPoint

               

                 Private Inputtag1 As PIACEPoint

               

                 '

               

                 '      Tag Name/VB Variable Name Correspondence Table

               

                 ' Tag Name                                VB Variable Name

               

                 ' ------------------------------------------------------------

               

                   ' Inputtag1                               Inputtag1

               

                   ' outputtag1                              outputtag1

               

                 '

               

                 Dim piContext As PISDK.PIModule

               

                 Dim Property1 As PISDK.PIProperty

               

                 Dim iRefr As PISDKCommon.IRefresh

               

                 Public Overrides Sub ACECalculations()

               

                     iRefr.Refresh()

               

                     outputtag1.Value = Inputtag1.Value * Property1.Value

               

                 End Sub

               

                 Protected Overrides Sub InitializePIACEPoints()

               

                        Inputtag1 = GetPIACEPoint("Inputtag1")

               

                        outputtag1 = GetPIACEPoint("outputtag1")

               

                 End Sub

               

                 '

               

                 ' User-written module dependent initialization code

               

                 '

               

                 Protected Overrides Sub ModuleDependentInitialization()

               

                     piContext = OSIsoft.PI.ACE.PIACEBIFunctions.GetPIModuleFromPath(Context)

               

                     iRefr = piContext

               

                     Property1 = piContext.PIProperties("Property1")

               

                 End Sub