Interfaces - Manual - AX2TIA - This package contains the documentation for ax2tia - Converting SIMATIC AX libraries to TIA Portal libraries,

AX2TIA CLI Tool (ax2tia)

Portfolio
SIMATIC AX
Product
AX2TIA
Software version
9.1.8
Edition
11/2024
Language
English (original)
Package Name
@ax/ax2tia-docs

INTERFACE can only be used in the AX library. Interfaces are not supported in the TIA Portal and are no longer visible once the AX library has been exported. Their names do not appear because they are purely abstract types that have no representation in TIA.

Interfaces can though still be used in the AX library. They can be used in the wrapper function block like class instances and they can of course also be used as parameters, but the initialization of an interface variable usually takes place in the wrapper FB.

The following example shows the use of interfaces in a wrapper FB.

NAMESPACE ExampleClassLib
   INTERFACE Conveyor
      METHOD Run END_METHOD
      METHOD Stop END_METHOD
   END_INTERFACE

   CLASS OneBeltConveyor IMPLEMENTS Conveyor
      VAR PUBLIC
         belt : Belt;
      END_VAR

      METHOD PUBLIC Run
        belt.RunForward();
      END_METHOD

      METHOD PUBLIC Stop
         belt.Stop();
      END_METHOD
   END_CLASS

   INTERFACE Belt
      METHOD RunForward END_METHOD
      METHOD RunBackward END_METHOD
      METHOD Stop END_METHOD
   END_INTERFACE
END_NAMESPACE

NAMESPACE ExampleClassLib.Entry

   // Wrapper FB
   FUNCTION_BLOCK EquipmentModule1 // Wrapper FB
      VAR_INPUT
         start : BOOL;
         stop : BOOL;
      END_VAR
      VAR // OK, interfaces can be declared in VAR
         beltInst : BeltImpl;
         belt     : Belt;
         feed     : OneBeltConveyor;
         init     : BOOL := TRUE;
      END_VAR

      IF init THEN
         init := FALSE;
         belt := beltInst;  // initialize interface
         feed.belt := belt; // use interface
      END_IF;

      IF start AND NOT stop THEN
         feed.Run();
      ELSIF stop THEN
         feed.Stop();
      END_IF;
   END_FUNCTION_BLOCK

   CLASS BeltImpl IMPLEMENTS Belt
      METHOD PUBLIC RunForward ; END_METHOD
      METHOD PUBLIC RunBackward ; END_METHOD
      METHOD PUBLIC Stop ; END_METHOD
   END_CLASS
END_NAMESPACE

Note

Function blocks that represent classes and functions that represent methods are displayed in the project tree in the "Program blocks" folder, but they cannot be instantiated or called in the TIA Portal program.

This also applies to all other program elements that are created during the import of object-oriented programs. An error message will appear if you still try to use such an element.