{#- _macros.scl.j2 - gemeinsame Bausteine der FB-Templates (doc/SCL_Templates.md §5.2) Jede Zeile ist eine der Klassen aus §6: L (Layout, aus dem Kontext), N (Name, heute Platzhalter + TODO), R (Referenzwert aus der realen Aufrufstelle), E (E-Planung, Platzhalter + TODO), C (Bedingung). Makros liefern ihre Zeilen OHNE abschliessenden Zeilenumbruch; der Aufrufer setzt ihn. Globale Variable: TODO (Marker "TODO(E-Planung)"). -#} {#- TODO-Kommentar hinter einer Zeile, wenn der Name noch offen ist -#} {% macro todo(name, abstand=" ") -%} {% if name.todo %}{{ abstand }}// {{ TODO }}{% endif %} {%- endmacro %} {#- TODO an einen schon vorhandenen Kommentar anhaengen ("// MT in Pos - TODO(E-Planung)") -#} {% macro todo_mehr(name) -%} {% if name.todo %} - {{ TODO }}{% endif %} {%- endmacro %} {#- Kommentartext fuer eine Parameterzeile des Aufrufs -#} {% macro note(name, text="") -%} {% if name.todo %}{{ TODO }}{% if text %} - {{ text }}{% endif %}{% else %}{{ text }}{% endif %} {%- endmacro %} {#- Kommentarkopf der REGION: Lage und Nachbarn im Layout (L) -#} {% macro kopf(t) %} {% if t.position %} // Anlagenkoordinate x/y: {{ "%.0f"|format(t.position[0]) }} / {{ "%.0f"|format(t.position[1]) }} mm {% endif %} // Vorgaenger: {{ t.predecessors|join(", ") or "-" }} // Nachfolger: {{ t.successors|join(", ") or "-" }} {% if t.confidence %} // Einstufung: {{ t.confidence }} {% endif %} // Aufbau nach Template {{ t.fb }}.scl.j2 (Referenz: doc/TRO_Katalog/scl_templates) {%- endmacro %} {#- stInSeparator: Zeiten R aus der Referenz (TRO107), Nummer N, Sensor E -#} {% macro separator(t, s) %} // Separator {{ s.n }} = Bauteil {{ s.layout }} aus dem Layout #{{ t.id }}.stInSeparator{{ s.n }}.Settings.nSeparatorNo := "{{ s.no.value }}";{{ todo(s.no) }} #{{ t.id }}.stInSeparator{{ s.n }}.Settings.tDelayToNextItem := "TimeForSepWaiting_Short"; #{{ t.id }}.stInSeparator{{ s.n }}.Settings.tTrailingTime := t#100ms; // {{ TODO }}: pruefen #{{ t.id }}.stInSeparator{{ s.n }}.Settings.tHandlingTime := t#50ms; // {{ TODO }}: pruefen #{{ t.id }}.stInSeparator{{ s.n }}.Settings.tJam := "TimeForSepJam"; #{{ t.id }}.stInSeparator{{ s.n }}.Settings.xPluggedJam := TRUE; #{{ t.id }}.stInSeparator{{ s.n }}.Settings.xPluggedPart := FALSE; #{{ t.id }}.stInSeparator{{ s.n }}.Settings.xPluggedScanner := {{ "TRUE" if t.has_scanner else "FALSE" }}; #{{ t.id }}.stInSeparator{{ s.n }}.stSenInSep := "DB_Inputs".Sensors["{{ s.sensor.value }}"];{{ todo(s.sensor) }} {%- endmacro %} {#- stInSenJam: ein Stausensor je Ausgang (E) -#} {% macro jam_sensors(t) %} {% for j in t.jam_exits %} #{{ t.id }}.stInSenJam{{ j.n }} := "DB_Inputs".Sensors["{{ j.sensor.value }}"];{{ todo(j.sensor) }} {% endfor %} {%- endmacro %} {#- stInSwitch: Nummer N; nTo1Destinations L, aber Bedeutung noch zu klaeren -#} {% macro switch(t, w) %} #{{ t.id }}.stInSwitch{{ w.n }}.Settings.nSwitchNo := "{{ w.no.value }}";{{ todo(w.no) }} #{{ t.id }}.stInSwitch{{ w.n }}.Settings.xPluggedExSen3 := FALSE; #{{ t.id }}.stInSwitch{{ w.n }}.Settings.xPluggedExSen4 := FALSE; {% if w.to1_destinations is not none %} #{{ t.id }}.stInSwitch{{ w.n }}.Settings.nTo1Destinations := {{ w.to1_destinations }}; // Abgaenge laut Topologie - {{ TODO }}: pruefen (Info fuer HMI; Referenz TRO107 hat 3 bei 2 Abgaengen) {% else %} #{{ t.id }}.stInSwitch{{ w.n }}.Settings.nTo1Destinations := _; // {{ TODO }}: {{ t.successors|length }} Abgaenge auf {{ t.switches|length }} Weichen - Aufteilung festlegen {% endif %} {%- endmacro %} {#- Zielliste je Weichenabgang (L, nur Kommentar) -#} {% macro ziele(t) %} // Zielliste je Abgang (aus dem TRO-Graphen berechnet) - // Grundlage fuer die Zuordnung Ziel -> Richtung in FC_Direction: {% for e in t.switch_exits %} // ueber {{ e.via }}: {{ e.targets|join(", ") or "-" }} {% endfor %} {%- endmacro %} {#- Instanzaufruf aus einer Liste von (Code, Kommentar). Das Komma wird hier gesetzt und steht damit VOR dem Kommentar - sonst waere es Teil des Kommentars und die Parameterliste uebersetzt nicht. -#} {% macro call(t, zeilen) %} {% set einzug = " " * (6 + t.id|length) %} {% for code, kommentar in zeilen %} {{ (" #" ~ t.id ~ "(") if loop.first else einzug }}{{ code }}{{ ");" if loop.last else "," }}{% if kommentar %} // {{ kommentar }}{% endif %} {% endfor %} {%- endmacro %} {#- Cognex-Kamera: Eingaenge der Schnittstelle (E). ziel = "#arCognexInterface[...]" oder eine eigene Struktur -#} {% macro cognex_in(ziel, sc, einzug=" ") %} {{ einzug }}{{ ziel }}.xInCamTriggerReady := "{{ sc.tag.value }}-TriggerReady";{{ todo(sc.tag) }} {{ einzug }}{{ ziel }}.xInCamTriggerAck := "{{ sc.tag.value }}-TriggerAck";{{ todo(sc.tag) }} {{ einzug }}{{ ziel }}.xInCamResultsAvailable := "{{ sc.tag.value }}-Results Available";{{ todo(sc.tag) }} {{ einzug }}{{ ziel }}.xInCamGeneralFault := "{{ sc.tag.value }}-General Fault";{{ todo(sc.tag) }} {{ einzug }}{{ ziel }}.hwInCamInspectionResults := "{{ sc.hw_results.value }}";{{ todo(sc.hw_results) }} {%- endmacro %} {#- Cognex-Kamera: Ausgaenge zurueck auf die Hardware-Symbole (E) -#} {% macro cognex_out(ziel, sc, einzug=" ") %} {{ einzug }}"{{ sc.tag.value }}-TriggerEnable" := {{ ziel }}.xOutCamTriggerEnable;{{ todo(sc.tag) }} {{ einzug }}"{{ sc.tag.value }}-Trigger" := {{ ziel }}.xOutCamTrigger;{{ todo(sc.tag) }} {{ einzug }}"{{ sc.tag.value }}-ResultsAck" := {{ ziel }}.xOutCamResultsAck;{{ todo(sc.tag) }} {%- endmacro %} {#- Schluessel einer Kamera in #arCognexInterface -#} {% macro cognex(sc) -%} #arCognexInterface["{{ sc.interface.value }}"] {%- endmacro %} {#- Traegerkorrektur nach dem Scan (FC_CARR_GLOB_CORRECTION); Traeger am Eingang -#} {% macro correction(t, titel, einzug=" ") %} {{ einzug }}REGION {{ titel }} {{ einzug }} "FC_CARR_GLOB_CORRECTION"(xInStart := #{{ t.id }}.xOutCorrection, {{ einzug }} nInBarcodeScan := #{{ t.id }}.nBarcodeResult, {{ einzug }} nInStation := {{ t.correction_station.value }},{{ todo(t.correction_station) }} {{ einzug }} arOutEventLogInfo => #arDummyEventCorrectionInfo, {{ einzug }} InOutCarrierExpect := {{ t.jam_in.carriers.value }}[1]);{{ todo(t.jam_in.carriers) }} {{ einzug }}END_REGION {%- endmacro %} {#- REGION Direction: je Weiche ein FC_Direction-Aufruf -#} {% macro direction(t) %} REGION Direction {% for w in t.switches %} "FC_Direction"(nInSwitchNo := "{{ w.no.value }}",{{ todo(w.no) }} nOutDirection => {{ w.direction_target }}, InOutCarrier := {{ w.jam_db.value }}.arCarrier[1]);{{ todo(w.jam_db) }} {% if not loop.last %} {% endif %} {% endfor %} END_REGION {%- endmacro %}