Vai al contenuto

Error on using structured variable in a Method of an Interface

Home Forum Programmazione IEC 61131 (LogicLab) Error on using structured variable in a Method of an Interface

Stai visualizzando 4 post - dal 1 a 4 (di 4 totali)
  • Autore
    Post
  • #81769
    George
    Partecipante

    I have another question about using structure type variable in a Method of an Interface, when I use object-oriented features I get

    IDev.open.cfg – error A4109:  cfg => Invalid base object type

    METHOD open: BOOL
    
    VAR_INPUT
    cfg : sDevCfg;
    END_VAR

    The strange behavior is that in some cases the structure type variable in Method prototype specification in an Interface. Adding in a Function Block a Method with VAR_INPUT structure type variable  is accepted without errors.

    The problem is in interface definition.

    #81774
    Sergio Bertana
    Amministratore del forum

    Hi George I’ve tried to recreate the same behaviour you report in the TestInterface program (Download).

    In the screenshot you can see the program structure.

    Can you verify if the program I made recreate exactly your situation?

    #81777
    George
    Partecipante

    Yes I tested your program and compiles correctly.

    Now I gonna test this function in my program.

    #81787
    George
    Partecipante

    There an issue about memory allocation of a function block instance and assignment to an interface.

    In CODESY and TWINCAT there is the NEW operator that reserves dynamic memory to instantiate function blocks.

    I tried to something similar by using sysmalloc and pointer but I am not sure that is correct way.

    IF SysFirstLoop THEN
    pFbA:= SysMAlloc(SIZEOF(fbMyA));
    pFbB:= SysMAlloc(SIZEOF(fbMyB));
    END_IF;

    CASE select    OF
    0:
    itf:= @pFbA;
    select:=2;
    1:
    itf:= @pFbB;
    select:=2;
    ELSE
    END_CASE;

    itf4.mInit(myCfg);

Stai visualizzando 4 post - dal 1 a 4 (di 4 totali)
  • Devi essere connesso per rispondere a questo topic.