Export/Import von SCL-Aufrufbausteinen - TIAPortal

TIA Portal Openness: API für die Automatisierung von Engineering-Workflows

ft:publication_title
TIA Portal Openness: API für die Automatisierung von Engineering-Workflows
Product
TIAPortal
Version
V20
Publication date
01/2025
Language
de-DE
Export/Import von SCL-Aufrufbausteinen

SCL-Aufrufbausteine mit XML-Tags für den Export

SCL-Aufrufparameter werden in XML durch das Tag Parameter dargestellt. Das Attribut informative dient zum Darstellen der nicht zugewiesenen Parameter und Rückgabewerte wie Zeitstempel, Merkerinformationen usw. Das XML-Format folgt der gleichen willkürlichen Reihenfolge wie im SCL-Baustein.

Nachstehend ein Beispiel für einen Bausteinaufruf:

SCL-Baustein

XML-Tag

#Callee_Instance(Input_1 := 5);

Format von XML nach Export mit Einstellung ExportOptions.None

<Access Scope="Call">

    <CallInfo BlockType="FB">

      <Instance Scope="LocalVariable">

        <Component Name="Callee_Instance" />

      </Instance>

 <Token text="(" />

    <Parameter Name="Input_1">

    <Blank />

    <Token text=":=" />

    <Blank />

    <Access Scope="LiteralConstant">

      <Constant>

        <ConstantType>Int</ConstantType>

        <ConstantValue>5</ConstantValue>

      </Constant>

    </Access>

  </Parameter>

 <Token text=")" />

     </CallInfo>

</Access>

 <Token text=";" />

Format von XML nach Export mit Einstellung ExportOptions.ReadOnly

<Access Scope="Call">

    <CallInfo BlockType="FB">

    <IntegerAttribute Name="BlockNumber" Informative="true">1</IntegerAttribute>

    <DateAttribute Name="ParameterModifiedTS" Informative="true">2016-10-24T08:27:34</DateAttribute>

      <Instance Scope="LocalVariable">

        <Component Name="Callee_Instance" />

      </Instance>

 <Token text="(" />

    <Parameter Name="Input_1">

<StringAttribute Name="InterfaceFlags" Informative="true">S7_Visible</StringAttribute>

    <Blank />

    <Token text=":=" />

    <Blank />

    <Access Scope="LiteralConstant">

      <Constant>

        <ConstantType>Int</ConstantType>

        <ConstantValue>5</ConstantValue>

      </Constant>

    </Access>

  </Parameter>

 <Token text=")" />

     </CallInfo>

</Access>

 <Token text=";" />

Beispiel für unverbundene Parameter

Der FB hat vier Parameter, wobei a, b, c sowie d. b und d nicht verbunden sind.

SCL-Baustein

XML-Tag

"Block_4_DB"(a:=TRUE,c:=TRUE);

<Access Scope="Call">

    <CallInfo Name="Block_4" BlockType="FB">

      <Instance Scope="GlobalVariable">

        <Component Name="Block_4_DB" />

      </Instance>

      <Token text="(" />

      <Parameter Name="a">

        <Token text=":=" />

        <Access Scope="LiteralConstant">

           <Constant>

             <ConstantType>Bool</ConstantType>

             <ConstantValue>TRUE</ConstantValue>

           </Constant>

        </Access>

      </Parameter>

      <Token text="," />

      <Parameter Name="b" Informative="true"/>

      <Parameter Name="c" >

         <Token text=":=" />

         <Access Scope="LiteralConstant">

         <Constant>

           <ConstantType>Bool</ConstantType>

           <ConstantValue>True</ConstantValue>

         </Constant>

         </Access>

      </Parameter>

     <Parameter Name="d" Informative="true"/>

     <Token text=")" />

     </CallInfo>

</Access>

Beispiel für "ein Parameter"

Der SCL-Baustein ermöglicht Ihnen das Weglassen des Parameternamens. Dieser Parameter wird durch das Tag NamelessParameter dargestellt. Das Tag NamelessParameter hat keine Attribute und gilt nur für SCL.

SCL-Baustein

XML-Tag

"Block_4_DB"(TRUE);

<Access Scope="Call">

    <CallInfo Name="Block_4" BlockType="FB">

       <Instance Scope="GlobalVariable">

       <Component Name="Block_4_DB" />

       </Instance>

       <Token text="(" />

       <NamelessParameter>

          <Access Scope="LiteralConstant">

          <Constant>

            <ConstantType>Bool</ConstantType>

            <ConstantValue>TRUE</ConstantValue>

          </Constant>

          </Access>

       </NamelessParameter>

       <Token text=")" />

    </CallInfo>

</Access>

Ausdruck als Aktualparameter

SCL-Baustein

XML-Tag

#Callee_Instance(Input_1 := #a+3);

<Access Scope="Call">

    <CallInfo BlockType="FB">

      <Instance Scope="LocalVariable">

        <Component Name="Callee_Instance" />

      </Instance>

      <Token text="(" />

      <Parameter Name="Input_1">

        <Blank />

        <Token text=":=" />

        <Blank />

        <Access Scope="LocalVariable">

          <Symbol>

             <Component Name="a" />

          </Symbol >

        </Access>

        <Token text="+" />

        <Access Scope="LiteralConstant">

           <Constant>

           <ConstantType>Int</ConstantType>

           <ConstantValue>3</ConstantValue>

          </Constant>

       </Access>

      </Parameter>

      <Token text=")" />

   </CallInfo>

</Access>

<Token text=";" />

Ausdruck als Aktualparameter ohne Formalparameter

SCL-Baustein

XML-Tag

#Callee_Instance(#a+3);

<Access Scope="Call">

  <CallInfo BlockType="FB">

    <Instance Scope="LocalVariable">

      <Component Name="Callee_Instance" />

    </Instance>

    <Token text="(" />

    <NamelessParameter>

       <Access Scope="LocalVariable">

         <Symbol>

           <Component Name="a" />

        </Symbol >

       </Access>

       <Token text="+" />

       <Access Scope="LiteralConstant">

          <Constant>

             <ConstantType>Int</ConstantType>

             <ConstantValue>3</ConstantValue>

          </Constant>

       </Access>

     </NamelessParameter>

     <Token text=")" />

   </CallInfo>

</Access>

<Token text=";" />

Funktionsaufruf

SCL-Baustein

XML-Tag

#myInt := "MyFunction"(Param_1 := 1, Param_2 := 15, Param_3 := TRUE);

<Access Scope="LocalVariable">

    <Symbol>

       <Component Name="myInt" />

    </Symbol>

</Access>

<Blank />

<Token text=":=" />

<Blank />

<Access Scope="Call">

   <CallInfo Name="MyFunction" BlockType="FC">

      <Token text="(" />

      <Parameter Name="Param_1">

       ...

Absoluter Aufruf

In SCL kann der Aufruf über die absolute Adresse des DB initiiert werden. Wegen der absoluten Adresse ist das Attribut Name des Knotens CallInfo leer.

Eine wiederherstellbare Ausnahme wird durch den Import ausgelöst, wenn

  • Ein Knoten "Address" mit gültigem Wert des Attributs Name verfügbar ist.

  • Der Knoten "Address" nicht vorhanden ist und kein gültiger Wert des Attributs Name vorhanden ist.

SCL-Baustein

XML-Tag

%DB20(...);

<Access Scope="Call">

    <CallInfo Name="" BlockType="FB">

       <Instance Scope="GlobalVariable">

         <Address Area="DB" BlockNumber="20" />

       </Instance>

       <Token text="(" />

       <Parameter> 

        …   

       </Parameter>

      <Token text=")" /> 

 </CallInfo>

</Access>

Anweisung

Die Anweisung im SCL-Baustein wird während des Importvorgangs in der Systembibliothek geprüft, und die Anweisungsversionen werden beim Exportvorgang nicht exportiert.

Der allgemeine Anweisungstyp ist unten angegeben.

SCL-Baustein

XML-Tag

#myInt := ATTACH(OB_NR := 1, EVENT := 15, ADD := TRUE);

Format von XML nach Export mit Einstellung ExportOptions.ReadOnly

<Access Scope="LocalVariable">

   <Symbol>

     <Component Name="myInt" />

   </Symbol>

</Access>

<Blank />

<Token text=":=" />

<Blank />

<Access Scope="Call">

  <Instruction Name="ATTACH">

  <Token text="(" />

  <Parameter Name="OB_NR">

    <Blank />

    <Token text=":=" />

    <Blank />

    <Access Scope="LiteralConstant">

      <Constant>

        <ConstantType>OB_ATT</ConstantType>

        <ConstantValue>1</ConstantValue>

     </Constant>

    </Access>

  </Parameter>

   <Token text="," />

   <Blank />

   <Parameter Name="EVENT">

   <Blank />

   <Token text=":=" />

   <Blank />

   <Access Scope="LiteralConstant">

      <Constant>

        <ConstantType>EVENT_ATT</ConstantType>

        <ConstantValue>15</ConstantValue>

      </Constant>

   </Access>

  </Parameter>

  <Token text="," />

  <Blank />

<Parameter Name="ADD">

   <Blank />

   <Token text=":=" />

   <Blank />

   <Access Scope="LiteralConstant">

      <Constant>

        <ConstantType>Bool</ConstantType>

        <ConstantValue>TRUE</ConstantValue>

      </Constant>

   </Access>

   </Parameter>

   <Parameter Name="RET_VAL" Informative="true" />

     <Token text=")" />

   </Instruction>

   </Access>

<Token text=";" />

Anweisung mit Vorlage

Wenn der Vorlagenparameter den Anweisungsnamen ergänzt, ist der Export des Vorlagenparameters notwendig. Wenn ein "TemplateValue" -Tag mit Attribut Type="Type" auf das Instruction-Tag folgt, verkettet der Importvorgang den Vorlagenwert mit dem Anweisungsnamen.

SCL-Baustein

XML-Tag

"tag_4" := MIN_DINT( IN1:="Tag_1", IN2:="Tag_2", IN3:="Tag_3" );

<Access Scope="GlobalVariable">

  <Symbol>

    <Component Name="Tag_4" />

  </Symbol>

</Access>

...

<Access Scope="Call">

   <Instruction Name="MIN">

     <TemplateValue Name="value_type" Type="Type">DInt</TemplateValue>

     ...

   <Parameter Name="IN1">

    ...

    <Access Scope="GlobalVariable">

      <Symbol>

        <Component Name="Tag_1" />

      </Symbol>

    </Access>

   </Parameter>

...

   <Parameter Name="IN2">...

     <Access Scope="GlobalVariable">

       <Symbol>

         <Component Name="Tag_2" />

       </Symbol>

     </Access>

   </Parameter>

...

   <Parameter Name="IN3">

...

   <Access Scope="GlobalVariable">

   <Symbol>

      <Component Name="Tag_3" />

   </Symbol>

   </Access>

    </Parameter>

...

   </Instruction>

</Access>

...

Umwandlung

Bei Umwandlungsfunktionen werden der reale Anweisungsname und seine Vorlage nicht exportiert. Stattdessen wird der im SCL-Baustein verwendete Name exportiert.

SCL-Baustein

XML-Tag

#output_1 := TIME_TO_S5TIME(#input_1);

<Access Scope="LocalVariable">

   <Symbol>

     <Component Name="output_1" />

   </Symbol>

</Access>

...

<Access Scope="Call">

   <Instruction Name="TIME_TO_S5TIME">

    <Token text="(" />

    <NamelessParameter>

      <Access Scope="LocalVariable">

        <Symbol>

          <Component Name="input_1" />

        </Symbol>

     </Access>

   </NamelessParameter>

  <Token text=")" />

   </Instruction>

 </Access>

...

Anweisung mit Instanz

Instanz und Anweisung werden durch Leerzeichen getrennt. Leerzeichen sind optional, und sie können durch neue Zeilen und Kommentare dargestellt werden. Die Anweisung TON wird durch das Attribut Name des Tags Instruction dargestellt.

SCL-Baustein

XML-Tag

IEC_Timer_0_DB . TON (IN:="Tag_1", PT:="Tag_2");

<Access Scope="GlobalAccess">

   <Symbol>

     <Component Name="IEC_Timer_0_DB" />

   </Symbol >

</Access>

<Blank />

<Token text="." />

<Blank />

<Access Scope="Call">

   <Instruction Name="TON">

     <Blank />

     <Token text="(" />

     <Parameter Name="IN">

     <Access Scope="GlobalVariable">

        <Symbol>

           <Component Name="Tag_1" />

        </Symbol>

      </Access>

      </Parameter>

...

      <Token text=")" />

   </Instruction>

</Access>

<Token text=";" />

Alarmkonstante

Die Alarmkonstanten werden nur in S7 400-PLCs verwendet, und der exportierte XML-Code hat Ähnlichkeit mit anderen Sprachen.

SCL-Baustein

XML-Tag

"Block_1_DB"(16#0000_0001);

Format von XML nach Export mit Einstellung ExportOptions.None

<Access Scope="Call">

  <CallInfo Name="Block_1" BlockType="FB">

    <Instance Scope="GlobalVariable">

      <Component Name="Block_1_DB" />

    </Instance>

    <NamelessParameter>

      <Access Scope="AlarmConstant">

        <Constant>

          <ConstantType>C_Alarm_8</ConstantType>

          <ConstantValue>16#0000_0001</ConstantValue>

        </Constant>

      </Access>

    </NamelessParameter >

  </CallInfo>

</Access>

Format von XML nach Export mit Einstellung ExportOptions.ReadOnly

<Access Scope="Call">

  <CallInfo Name="Block_1" BlockType="FB">

    <Instance Scope="GlobalVariable">

      <Component Name="Block_1_DB" />

    </Instance>

    <NamelessParameter>

      <Access Scope="AlarmConstant" >

        <Constant>

         <ConstantValue>16#00000001</ConstantValue>

         <ConstantType>C_Alarm</ConstantType>

        <StringAttribute Name="Format" Informative="true">Hex</StringAttribute>

        </Constant>

      </Access>

    </NamelessParameter>

  </CallInfo>

</Access>

ENO (Freigabeausgang)

Um den Freigabeausgang ENO im SCL-Baustein zu unterstützen, wird im Tag "Access" das Attribut "Scope" mit dem Wert "PredefinedVariable" verwendet. Es enthält auch das Tag "PredefinedVariable" als untergeordnetes Element des Tags Access.

  • Das Tag "PredefinedVariable" hat ein obligatorisches Attribut "Name".

  • Der Umfang "PredefinedVariable" und das Tag "PredefinedVariable" sind nur für SCL zulässig.

SCL-Baustein

XML-Tag

Call(…, ENO => ENO);

<Access Scope="Call">

<CallInfo BlockType="FC">

   <Token text="(" />

   <Token text="," />

   <Blank />

   <Parameter Name="ENO">

      <Blank />

      <Token text="=>" />

      <Blank />

      <Access Scope="PredefinedVariable">

        <PredefinedVariable Name="ENO" />

      </Access>

   </Parameter>

  <Token text=")" />

</CallInfo>

</Access>

<Token text=";" />

IF ENO = #c THEN …

<Token text="IF" />

<Blank />

<Access Scope="PredefinedVariable">

   <PredefinedVariable Name="ENO" />

</Access>

<Blank />

<Token Text="=" />

<Blank />

<Access Scope="LocalVariable">

    <Symbol>

       <Component Name="c" />

    </Symbol>

</Access>

<Blank />

<Token Text="THEN" />