Zuweisungsversuch in ST

Syntax
interface_variable_1 ?= interface_variable_2; 
Bedeutung

Zuweisungsversuch einer Variable, die auf einem →Interface basiert, mit Hilfe des Operators "?=" auf eine andere Variable, die auf einem →Interface basiert, ob das Interface implementiert ist
Mehr Informationen über Variablen, die auf einem Interface basieren, finden Sie unter "Deklaration von Variablen, die auf einem Interface basieren".

Falls es sich bei der referenzierten Instanz um einen →Funktionsbaustein handelt, der das Interface implementiert, ist das Ergebnis eine gültige Referenz auf diese Instanz. Andernfalls ist das Ergebnis NULL.

Abweichung zur IEC-Norm

In Neuron Power Engineer werden Zuweisungsversuche für →Referenzen (mit REF_TO) nicht unterstützt.

 

Beispiel
INTERFACE IF1
END_INTERFACE
 
INTERFACE IF2
END_INTERFACE
 
INTERFACE IF3
END_INTERFACE
 
FUNCTION_BLOCK FB1 IMPLEMENTS IF1, IF2
  VAR
    Var1 : INT;
  END_VAR
END_FUNCTION_BLOCK
 
FUNCTION_BLOCK FB2
  VAR
    iFB1 : FB1;
    IF1Var1, IF1Var2 : IF1;
    IF2Var : IF2;
    IF3Var : IF3;
  END_VAR
 
   (* assignment *)
  IF1Var1 := iFB1;     // correct assignment: Variable IF1Var1 is based on the interface IF1, the function block type of iFB1 implements the same interface.
                       // Hence, IF1Var1 contains a valid reference.
  IF1Var2 := IF1Var1;  // correct assignment: Variable IF1Var2 is based on the interface IF1, the variable IF1Var1 is is based on the same interface.
                       // Hence, IF1Var2 contains a valid reference.
 
  (* assignment attempts *)
  IF1Var2 ?= IF1Var1;  // valid reference: The variables are based on the same interface.
                       // Is equal to this assignment: IF1Var2 := iFB1;
  IF2Var  ?= IF1Var1;  // valid reference: The variable IF1Var1 is based on the interface IF1, the variable IF2Var is based on the interface IF2.
                       // Both interfaces are implemented by FB1 and - due to the 1st assignment - IF1Var1 has the value of the instace iFB1 (this instance is of type FB1).
  IF1Var2 ?= IF2Var;   // valid reference: The variable IF2Var is based on the interface IF2, the variable IF1Var2 is based on the interface IF1.
                       // Both interfaces are implemented by FB1 and - due to the previos assignment attempt - IF2Var has the value of the instace iFB1 (this instance is of type FB1).
                       
  IF3Var  ?= IF1Var1;  // Due to the first assignment: IF1Var1 has the value of the instance iFB1 (this instance is of type FB1). The variable IF3Var is based on the interface IF3. FB1 does NOT implement the interface IF3.
                       // result of the assignment attempt: IF3Var is NULL.
  
END_FUNCTION_BLOCK