; ================================================================
; skel_scl.cfg — SCL-Templates fuer create_skel.py (INI-Style)
;
; Jede [sektion] ist ein Template; der Inhalt wird VERBATIM
; uebernommen (Einrueckung und Leerzeilen gehoeren zum Template,
; auch Leerzeilen am Blockende!). Zeilen, die mit ';' beginnen,
; sind Kommentare und werden ueberall ignoriert.
; Platzhalter im str.format()-Stil: {inst}, {tro_no}, {stopper} ...
; geschweifte Klammern im SCL selbst als {{ }} doppeln.
; ================================================================
; --------------------------------------------------------------
[var_decl]
      {inst} : "{fbtype}";   // {comment}
; --------------------------------------------------------------
[call_1sep]
    REGION {inst} ({shorttype}) — {comment}
        #{inst}.stInSeparator1.Settings.nSeparatorNo := "cSep{tro_no}.1";
        #{inst}.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
        #{inst}.stInSeparator1.Settings.tTrailingTime := T#500ms;      // TODO Timing
        #{inst}.stInSeparator1.Settings.tHandlingTime := T#200ms;      // TODO Timing
        #{inst}.stInSeparator1.Settings.tJam := "TimeForSepJam";
        #{inst}.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cIn{sen_in_sep}"];
        #{inst}.stInSenJam2 := "DB_Inputs".Sensors["cIn{sen_jam}"];

        #{inst}.stInPriorityManager.xReleaseOk := TRUE;                // TODO Priority

        #{inst}(nInMainTroNo := "cMainTro{tro_no}",
                xInSftyOk := TRUE,                                     // TODO Safety
                xInAllRdyToStart := TRUE,
                xInCarouselRun := TRUE,                                // TODO Conveyor
                xInRelease := TRUE,                                    // TODO Release
                stInOutMachineState := #stInOutControlUnit,            // TODO ControlUnit
                arInOutJamEntr1 := "DB_JamArea{tro_no}".stJam{tro_no}_1.arCarrier,   // TODO Topologie
                stInOutJamEntr1 := "DB_JamArea{tro_no}".stJam{tro_no}_1.stData,
                arInOutJamExit2 := "DB_JamArea{tro_no}".stJam{tro_no}_2.arCarrier,   // TODO Topologie
                stInOutJamExit2 := "DB_JamArea{tro_no}".stJam{tro_no}_2.stData,
                xOutStopper1 => "{stopper}",
                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro{tro_no}"],
                stInOutHMI := "DB_Interface_HMI".stTRO.{inst});
    END_REGION

; --------------------------------------------------------------
[call_1sep1swi]
    REGION {inst} ({shorttype}) — {comment}
        #{inst}.stInSeparator1.Settings.nSeparatorNo := "cSep{tro_no}.1";
        #{inst}.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
        #{inst}.stInSeparator1.Settings.tTrailingTime := T#100ms;      // TODO Timing
        #{inst}.stInSeparator1.Settings.tHandlingTime := T#50ms;       // TODO Timing
        #{inst}.stInSeparator1.Settings.tJam := "TimeForSepJam";
        #{inst}.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cIn{sen_in_sep}"];
        #{inst}.stInSenJam2 := "DB_Inputs".Sensors["cIn{sen_jam}"];
        #{inst}.stInSwitch1.Settings.nSwitchNo := "cSwi{tro_no}.1";

        #{inst}(nInMainTroNo := "cMainTro{tro_no}",
                xInSftyOk := TRUE,                                     // TODO Safety
                xInAllRdyToStart := TRUE,
                xInCarouselRun1 := TRUE,                               // TODO Conveyor
                xInRelease := TRUE,                                    // TODO Release
                stInOutMachineState := #stInOutControlUnit,            // TODO ControlUnit
                arInOutJamEntr1 := "DB_JamArea{tro_no}".stJam{tro_no}_1.arCarrier,   // TODO Topologie
                stInOutJamEntr1 := "DB_JamArea{tro_no}".stJam{tro_no}_1.stData,
                arInOutJamExit2 := "DB_JamArea{tro_no}".stJam{tro_no}_2.arCarrier,   // TODO Topologie (Dir1)
                stInOutJamExit2 := "DB_JamArea{tro_no}".stJam{tro_no}_2.stData,
                arInOutJamExit3 := "DB_JamArea{tro_no}".stJam{tro_no}_3.arCarrier,   // TODO Topologie (Dir2)
                stInOutJamExit3 := "DB_JamArea{tro_no}".stJam{tro_no}_3.stData,
                xOutStopper1 => "{stopper}",
                xOutSw1ExTo3 => "{switch_out}",
                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro{tro_no}"],
                stInOutHMI := "DB_Interface_HMI".stTRO.{inst});
    END_REGION

; --------------------------------------------------------------
[call_vario]
    REGION {inst} ({shorttype}) — {comment}
        #{inst}.stInSeparator1.Settings.nSeparatorNo := "cSep{tro_no}.1";
        #{inst}.stInSeparator1.Settings.tDelayToNextItem := "TimeForSepWaiting_Short";
        #{inst}.stInSeparator1.stSenInSep := "DB_Inputs".Sensors["cIn{sen_in_sep}"];
        #{inst}.stInVario.stSenCarrInPos := "DB_Inputs".Sensors["cIn{sen_carr_in_pos}"];
        #{inst}.stInVario.stSenFinger := "DB_Inputs".Sensors["cIn{sen_finger}"];
        #{inst}.stInVario.stSenJam := "DB_Inputs".Sensors["cIn{sen_jam}"];

        #{inst}(nInMainTroNo := "cMainTro{tro_no}",
                xInSftyOk := TRUE,                                     // TODO Safety
                xInAllRdyToStart := TRUE,
                xInRelease := TRUE,                                    // TODO Release
                stInOutMachineState := #stInOutControlUnit,            // TODO ControlUnit
                arInOutJamEntr1 := "DB_JamArea{tro_no}".stJam{tro_no}_1.arCarrier,   // TODO Topologie
                stInOutJamEntr1 := "DB_JamArea{tro_no}".stJam{tro_no}_1.stData,
                arInOutJamFinger := "DB_JamArea{tro_no}".stJam{tro_no}_2.arCarrier,  // TODO Topologie
                xOutStopper => "{stopper}",
                xOutVarioMotor => "{motor}",
                nOutStateLast => "DB_GLOB_TroState".arTroState["cMainTro{tro_no}"],
                stInOutHMI := "DB_Interface_HMI".stTRO.{inst});
    END_REGION

; --------------------------------------------------------------
[call_conveyor]
    REGION {inst} — {comment}
        #{inst}.Settings.tEnergySafeTime := "cTimeEnergySafe";
        #{inst}.Settings.xGridActive := FALSE;                         // TODO Grid
        #{inst}.Settings.sMotorProtectName := '{motor_protection}';

        #{inst}(xInEnabled := TRUE,                                    // TODO Enable
                xInMotorProtection := "{motor_protection}",
                xInPowerContactor := "{motor}",
                stInOutHMI := "DB_Interface_HMI".stConveyors.{inst});
    END_REGION

; --------------------------------------------------------------
[call_sensor]
    // {comment}
    #fbSensorInput(stInSensorHW := "{bmk}",
                   nInSensorNo := "cIn{bmk}",
                   stInOutSensor := "DB_Inputs".Sensors["cIn{bmk}"]);
; --------------------------------------------------------------
[fb_main_frame]
FUNCTION_BLOCK "FB_Main_skel_{uh}"
{{ S7_Optimized_Access := 'TRUE' }}
VERSION : 0.1
// ============================================================
// AUTOMATISCH GENERIERTES GRUNDGERUEST — create_skel.py
// Quelle: E/A-Listen {uh} (data/)
// TODO-Marken kennzeichnen manuell zu ergaenzende Stellen
// (Timings, Topologie/JamAreas, Safety, Release, Priority).
// ============================================================
   VAR
{var_block}   END_VAR

BEGIN
{call_block}END_FUNCTION_BLOCK
; --------------------------------------------------------------
[fb_sensors_frame]
FUNCTION_BLOCK "FB_CallSensors_skel_{uh}"
{{ S7_Optimized_Access := 'TRUE' }}
VERSION : 0.1
// AUTOMATISCH GENERIERT — create_skel.py ({count} Sensoren)
   VAR
      fbSensorInput : "FB_SensorInput";
   END_VAR

BEGIN
{call_block}END_FUNCTION_BLOCK
