dpConnect callback in derived classes

Discussions about product bugs & problems!
Note: This is no replacement for the Official ETM Support!
Search

Post Reply
1 post • Page 1 of 1
moto3101
Posts: 37
Joined: Tue Aug 22, 2017 2:04 pm

dpConnect callback in derived classes

Post by moto3101 »

Hello together,
please consider the following example:

Code: Select all

class BaseClass
{

  public BaseClass()
  {
    //default constructor
  }
  public void init()
  {
    setupConnect();
  }
  protected void setupConnect()
  {
    dpConnect(this, cbTestMethod, true, "Pump1.State"); //works
    dpConnect(this, "cbTestMethod", true, "Pump1.State"); //does not work
  }

};

class ExtendedClass : BaseClass
{

  public ExtendedClass()
  {
    //Default constructor
  }

  public void cbTestMethod(string s, anytype a)
  {
    DebugTN("callback triggered");
  }

};


public void main()
{
  ExtendedClass logic;
  logic.init();
  dpConnect("cbTest", false, "Pump1.State"); //just to prevent the ctrl manager from exiting
}

public void cbTest(string dp, string state)
{


}
The first dpConnect works as expected, the second doesnt. Is there a reason why? Is there a way to still use the second dpConnect approach with the function name provided as string?

Background info:
The connect(s) are intended to be setup in the base class from a string configuration with callback function names (all callback functions follow the same name pattern).

Thanks in advance for your help!

Post Reply
1 post • Page 1 of 1