5 Replies Latest reply on Apr 13, 2015 5:48 PM by Dan Fishman

    PI ACE and ModuleDependentInitialization

    Steve.Buckley

      Am I correct that each context runs ModuleDependentInitialization once upon first starting? Its name seems to imply the parent Module, but surely that cannot be correct...? And is there a good description of this in the PI ACE UsersGuide or ?  I failed to find anything very detailed on this topic, and I don't see how I can confirm this via debugging.

       

      Thanks!

        • Re: PI ACE and ModuleDependentInitialization
          dng

          Hi Steve,

           

          Yes, you are correct. ModuleDependentInitialization runs once when the module starts, for each context. It is used for module-level variables that do not change from calculation to calculation or whose values from one calculation are used in the next calculation should be declared as module-level variables.

           

          I agree that the user guide doesn't have much detailed information about this. So, to convince myself that the above is indeed true, I wrote the following test ACE calculation:

           

          Imports OSIsoft.PI.ACE
          
          Public Class Test
              Inherits PIACENetClassModule
              Private ChildName As PIACEPoint
              Private contextStr As String
              '
              '      Tag Name/VB Variable Name Correspondence Table
              ' Tag Name                                VB Variable Name
              ' ------------------------------------------------------------
              ' Name                                    Name
            ' ChildName                              ChildName
              '
              Public Overrides Sub ACECalculations()
                  ChildName.Value = contextStr
              End Sub
          
              Protected Overrides Sub InitializePIACEPoints()
                 ChildName = GetPIACEPoint("ChildName")
              End Sub
          
              '
              ' User-written module dependent initialization code
              '
              Protected Overrides Sub ModuleDependentInitialization()
                  contextStr = Context
              End Sub
          
              '
              ' User-written module dependent termination code
              '
              Protected Overrides Sub ModuleDependentTermination()
              End Sub
          End Class
          
          

           

          I have two contexts under the same module:

          2015-04-13 10_02_59-DNG-CODE - Remote Desktop Connection Manager v2.2.png

          The test simply outputs the context path and store that into an alias under the context. The results of the calculation shows the string value \\PIServer\Test\Child1 for the alias value in the Child1 context, and the string value \\PIServer\Test\Child2 for the alias value in the Child2 context. This confirms that ModuleDependentInitialization runs for each context.