Files
HundM_Fortna/=A01+UH04-KF00/Programmbausteine/200_MFR/FC_Direction.scl
T
2026-06-23 10:21:32 +02:00

74 lines
2.6 KiB
Plaintext

FUNCTION "FC_Direction" : Void
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
VAR_INPUT
nInSwitchNo : USInt;
END_VAR
VAR_OUTPUT
nOutDirection : USInt; // Ziel für Switch-Baustein
END_VAR
VAR_IN_OUT
InOutCarrier : "stCarrier";
END_VAR
BEGIN
// Destination vom Carrier, immer unterschiedlich je nach Anlagenbereich, soll übertragen werden auf universale Switch Direction (1-4)
// TEST TEST TEST
REGION Vergabe Direction
CASE #nInSwitchNo OF
"cSwi405.1":
REGION Switch 405.1
IF (#InOutCarrier.nDestination = "cDestLeaveAmr") THEN // Verlasse AMR (empty carrier)
#nOutDirection := 1; // LINKS, 1->3
ELSE // Im AMR bleiben, alle anderen Fälle + Fallbackstrategie (?)
#nOutDirection := 2; // RECHTS, 1->4
END_IF;
END_REGION
"cSwi407.1":
REGION Switch 407.1
IF #InOutCarrier.nDestination = "cDestMps3" THEN // MPS 3
#nOutDirection := 1; // LINKS, 1->3
ELSIF #InOutCarrier.nDestination = "cDestStayAmr"
OR #InOutCarrier.nDestination = "cDestRecirc"
THEN // Auf Kreisel bleiben
#nOutDirection := 2; // RECHTS, 1->4
ELSE
#nOutDirection := 2; // Fallback, falls unerwartetes Ziel
END_IF;
END_REGION
"cSwi410.1":
REGION Switch 410.1
IF #InOutCarrier.nDestination = "cDestMps2" THEN // MPS 2
#nOutDirection := 1; // LINKS, 1->3
ELSIF #InOutCarrier.nDestination = "cDestStayAmr"
OR #InOutCarrier.nDestination = "cDestRecirc"
THEN // Auf Kreisel bleiben
#nOutDirection := 2; // RECHTS, 1->4
ELSE
#nOutDirection := 2; // Fallback, falls unerwartetes Ziel
END_IF;
END_REGION
"cSwi413.1":
REGION Switch 413.1
IF #InOutCarrier.nDestination = "cDestMps1" THEN // MPS 1
#nOutDirection := 1; // LINKS, 1->3
ELSIF #InOutCarrier.nDestination = "cDestStayAmr"
OR #InOutCarrier.nDestination = "cDestRecirc"
THEN // Auf Kreisel bleiben
#nOutDirection := 2; // RECHTS, 1->4
ELSE
#nOutDirection := 2; // Fallback, falls unerwartetes Ziel
END_IF;
END_REGION
END_CASE;
END_REGION
END_FUNCTION