1 Reply Latest reply on Jul 15, 2011 10:16 PM by Ahmad Fattahi

    PIACEModuleDBFunctions exception


      I have developed an ACE calculation that increments an output "Mode"  tag dependent on the state of a number of discrete output tags. The calculation is triggered naturally whenever there is a write event to any of the input tags. The calculation reads from an AF table to determine he conditions required for the next "Mode" tag increment. Currently, this calculation works flawlessly, but I would like to incorporate dynamic triggering into my code. The idea being that  if a codition evaluates true and my "Mode" tag increments, that it will read the next condition in the AF Table, and determine if the next condition is an analog tag or a discrete tag. If  the next condition is an analog tag the code will change the scheduler to a Clocked trigger dependent on the analog tag or back to a Natural trigger dependent on a list of descrete tags. I have investigated writing to the Module DB directly from my code using PIACEModuleDBFunctions and I have tried testing it to no avail. I get a "COM error : 80040154" when I try to debug the code. Here is my code:

      Imports OSIsoft.PI.ACE
      Imports PIACECommon
      Public Class TestMDB1
          Inherits PIACENetClassModule
          Private BA_LEVEL_1 As PIACEPoint
          Private BA_ACTIVE_1 As PIACEPoint
          Private ACEOutTest As PIACEPoint
          '      Tag Name/VB Variable Name Correspondence Table
          ' Tag Name                                VB Variable Name
          ' ------------------------------------------------------------
           ' ACEOutTest                              ACEOutTest
           ' BA:ACTIVE.1                             BA_ACTIVE_1
           ' BA:LEVEL.1                              BA_LEVEL_1
          Public Overrides Sub ACECalculations()
              Dim MyMDB As New PIACEModuleDBFunctions
              MyMDB.SetACENet = True
              Dim MySchedule As New PISDKCommon.NamedValues
              Dim MyContext As String = MyBase.Context
              Dim MyName As String = MyBase.Name
              'Console.WriteLine("My Name is " & MyName)
              MySchedule.Add("Priority", enuPriorityCode.pcNormal)
              MySchedule.Add("Type", enuScheduleType.stClockScheduled)
              MySchedule.Add("Offset", 5)
              MySchedule.Add("Tag1", BA_LEVEL_1)
              MyMDB.AddPIACEContextSchedule(MyContext, MySchedule)



      This is strictly development code to try and figure out how all this works. My questions:


      1) Is my plan even possible, do I have to restart the scheduler every time I write to it?


      2) Why do I get the COM error? I believe the correct resources are sited, the project compiles. All PI components are installed using the default file paths. The registry should not have a problem locating the DLL's????


      3) I may be trying to attack this in the wrong way. Any suggestions?