Daniel Takara

reusing ACE calculation code to other aliases in the same context

Discussion created by Daniel Takara on Jul 26, 2009
Latest reply on Jul 29, 2009 by Daniel Takara

Hi,

 

I've been taking advantage of the quite popular ACE feature that defines automatically VB variables with the same name as the input aliases and/or output aliases of the PIModule of the context where the ACE calculation will be running, so that the same calculation can be executed on the context of other PIModules that contain the same aliases.

 

However, I've been having quite often to run the same calculation on different sets of aliases in the same PIModule. As an example, suppose I have developed an ACE calculation referencing 3 aliases (tags) of a PIModule named PIMod1: xxA and xxB as input PIACEPoints and xxC as output PIACEPoint:

Public Class MyPIACENetClassModule_xx
    Inherits PIACENetClassModule
    Private xxA As PIACEPoint
    Private xxB As PIACEPoint
    Private xxC As PIACEPoint
    '
    '      Tag Name/VB Variable Name Correspondence Table
    ' Tag Name                                VB Variable Name
    ' ------------------------------------------------------------
 ' xxA  xxA
 ' xxB  xxB
 ' xxC  xxC
    '
    Public Overrides Sub ACECalculations()
    ' Complex code involving xxA and xxB
    xxC.Value = result of complex calculation involving xxA and xxB
    Exit Sub
'(...)
End Sub

In order to reuse the code above and apply it other 3 aliases (tags) in PIMod1, I am doing the following steps (let's call it procedure #1):

 

1. create a new PIACENetClassModule named MyPIACENetClassModule_yy with the ACE Wizard defining yyA and yyB as input PIACEPoints and yyC as output PIACEPoint
2. copy the source code above to notepad and replace "xxA" by "yyA", "xxB" by "yyB" and "xxC" by "yyC"
3. paste the source code obtained on step 2 as the code of MyPIACENetClassModule_yy in Visual Studio
4. debug, test and register MyPIACENetClassModule_yy

I am repeating the procedure above for other sets of aliases in PIMod1.

One alternative procedure I imagined (let's call it procedure #2) is:

1. create a dummy PIModule elder to PIMod1 (named PIMod2, for instance)
2. define aliases named xxA, xxB and xxC on PIMod2, pointing to the same tags as xxA, xxB and xxC on PIMod1, respectively
3. register MyPIACENetClassModule_xx to the context of PIMod2

Procedure #2 has the drawback of requiring the creation of dummy PIModules though. Also, such "virtual contexts" can be confusing to manage later.

Does anyone have other suggestions to apply the code of a PIACENetClassModule to other sets of aliases within the same PIModule, not having to go through procedures #1 and #2?

Outcomes