Files
infineon_plc/PLC/LibraryCandidates/Scheduler/POUs/FB_BaseStation.TcPOU

249 lines
7.3 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<TcPlcObject Version="1.1.0.1">
<POU Name="FB_BaseStation" Id="{e987477c-14c3-4a7d-9e57-317d0837328f}" SpecialFunc="None">
<Declaration><![CDATA[FUNCTION_BLOCK FB_BaseStation IMPLEMENTS I_Station
VAR_INPUT
END_VAR
VAR_OUTPUT
END_VAR
VAR_IN_OUT
fbFlowRecHandler : FB_FlowRecHandler;
END_VAR
VAR
// Current loaded product flow recipe
// Index should also be used to access
// additional recipe parameters in designated pools
_iFlowRecIdx : INT := -1;
// Product available for pickup
_xProdAvail : BOOL;
// No product in station
_xEmpty : BOOL;
// Station busy
_xBusy : BOOL;
// Station done
_xDone : BOOL;
// Station has error
_xError : BOOL;
// Station id which was assigned by the scheduler
_uiStationID : UINT := 0;
// Station capabilities
_dwCapabilities : DWORD;
// Reserve token handle
_xReserved : BOOL;
_uiCurrHandle : UINT;
_uiHandleCounter : UINT := 1;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[]]></ST>
</Implementation>
<Method Name="M_HasCapabilty" Id="{d05e7240-ab9b-469b-8867-87a70dbef84e}">
<Declaration><![CDATA[METHOD M_HasCapabilty : BOOL
VAR_INPUT
dwReqCap : DWORD;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[IF (dwReqCap AND _dwCapabilities) = dwReqCap THEN
M_HasCapabilty := TRUE;
ELSE
M_HasCapabilty := FALSE;
END_IF]]></ST>
</Implementation>
</Method>
<Method Name="M_InsertProduct" Id="{d323f806-9a97-49f2-9986-a997415883bf}">
<Declaration><![CDATA[METHOD M_InsertProduct : BOOL;
VAR_INPUT
iFlowRecIdx : INT;
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[// Cant insert product if there is still one
// in the station, also dont insert invalid product index
IF (_iFlowRecIdx <> -1) OR (iFlowRecIdx = -1) THEN
M_InsertProduct := FALSE;
END_IF
// Save product index
_iFlowRecIdx := iFlowRecIdx;
// Advance one step in the node control flow
fbFlowRecHandler.M_AdvJob(iIdx := iFlowRecIdx);
// Report success
M_InsertProduct := TRUE;]]></ST>
</Implementation>
</Method>
<Method Name="M_Release" Id="{924bffc5-44cc-4d02-a67d-fb0f3ab51cc2}">
<Declaration><![CDATA[METHOD M_Release : BOOL
VAR_INPUT
uiHandle : UINT;
END_VAR]]></Declaration>
<Implementation>
<ST><![CDATA[// Check if we are reserved and the handle to release is corrcet
IF _xReserved AND (uiHandle = _uiCurrHandle) THEN
_xReserved := FALSE;
_uiCurrHandle := 0;
M_Release := TRUE;
ELSE
M_Release := FALSE;
END_IF]]></ST>
</Implementation>
</Method>
<Method Name="M_RemoveProduct" Id="{e5d01ee0-a885-4496-b522-46d093416622}">
<Declaration><![CDATA[METHOD M_RemoveProduct : INT
]]></Declaration>
<Implementation>
<ST><![CDATA[// Return index of product in machine
M_RemoveProduct := _iFlowRecIdx;
// Set product in machine invalid
_iFlowRecIdx := -1;
// There is no more a product to be ready for pickup
_xProdAvail := FALSE;
]]></ST>
</Implementation>
</Method>
<Method Name="M_Reserve" Id="{42a69458-4b78-4d35-bd61-3bb1ee3cafec}">
<Declaration><![CDATA[METHOD M_Reserve : UINT
]]></Declaration>
<Implementation>
<ST><![CDATA[// Check if we are not already reserved
IF (NOT _xReserved) THEN
_xReserved := TRUE;
_uiCurrHandle := _uiHandleCounter;
// Increment handle
_uiHandleCounter := _uiHandleCounter + 1;
// Prevent invalid token when overflowing
IF _uiHandleCounter = 0 THEN
_uiHandleCounter := 1;
END_IF
// Return handle
M_Reserve := _uiCurrHandle;
ELSE
M_Reserve := 0;
END_IF]]></ST>
</Implementation>
</Method>
<Property Name="P_Available" Id="{44abe6d9-f47e-47fa-8e00-c1822708d7bb}">
<Declaration><![CDATA[PROPERTY P_Available : BOOL
]]></Declaration>
<Get Name="Get" Id="{3bc760b0-1ae6-43b4-920e-8dd9987fe3f7}">
<Declaration><![CDATA[VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[P_Available := (NOT _xReserved) // Station not reserver
AND (_iFlowRecIdx = -1) // No product in station
AND (NOT _xBusy) // Station not busy
AND (NOT _xError); // Station no error]]></ST>
</Implementation>
</Get>
</Property>
<Property Name="P_Busy" Id="{5b025893-318c-4480-ab72-6ffb8bedb715}">
<Declaration><![CDATA[PROPERTY P_Busy : BOOL
]]></Declaration>
<Get Name="Get" Id="{596ebd24-6d36-4141-9b46-0ba6929a7256}">
<Declaration><![CDATA[VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[P_Busy := _xBusy;]]></ST>
</Implementation>
</Get>
</Property>
<Property Name="P_Capabilities" Id="{3e87d0bb-3b77-4aa6-bc89-587ee89028c2}">
<Declaration><![CDATA[PROPERTY P_Capabilities : DWORD
]]></Declaration>
<Get Name="Get" Id="{4acbb119-eda4-4b57-8a60-16f1e982c21f}">
<Declaration><![CDATA[VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[P_Capabilities := _dwCapabilities;]]></ST>
</Implementation>
</Get>
</Property>
<Property Name="P_CurrFlowRecIdx" Id="{d0f37c45-4a5c-4efc-a8ff-f73e6ce76964}">
<Declaration><![CDATA[PROPERTY P_CurrFlowRecIdx : INT
]]></Declaration>
<Get Name="Get" Id="{d05b9f0f-e7a4-4e88-83d5-c67bbca6f978}">
<Declaration><![CDATA[VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[P_CurrFlowRecIdx := _iFlowRecIdx;]]></ST>
</Implementation>
</Get>
</Property>
<Property Name="P_HasError" Id="{1126bae7-5dd1-4592-8f95-62ea6e252ed0}">
<Declaration><![CDATA[PROPERTY P_HasError : BOOL
]]></Declaration>
<Get Name="Get" Id="{3b3e65f8-9d92-48aa-9006-6a688edebb28}">
<Declaration><![CDATA[VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[P_HasError := _xError;]]></ST>
</Implementation>
</Get>
</Property>
<Property Name="P_HasProduct" Id="{8b974b49-9c67-4d5f-9d0f-defc53b608cd}">
<Declaration><![CDATA[PROPERTY P_HasProduct : BOOL]]></Declaration>
<Get Name="Get" Id="{b6ba2262-99e3-4626-8d27-178b09d53a84}">
<Declaration><![CDATA[VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[P_HasProduct := (_iFlowRecIdx <> -1);]]></ST>
</Implementation>
</Get>
</Property>
<Property Name="P_ProdAvail" Id="{47526379-0732-4031-8d2b-4380310ef64c}">
<Declaration><![CDATA[PROPERTY P_ProdAvail : BOOL
]]></Declaration>
<Get Name="Get" Id="{c498f522-3394-4950-acf2-2e6ab02869cd}">
<Declaration><![CDATA[VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[P_ProdAvail := _xProdAvail;]]></ST>
</Implementation>
</Get>
</Property>
<Property Name="P_StationID" Id="{6655f302-05b0-4a57-b6f3-aa70ddd6a9f3}">
<Declaration><![CDATA[PROPERTY P_StationID : UINT
]]></Declaration>
<Get Name="Get" Id="{06281909-79f6-4e9b-a8d9-9b210420e132}">
<Declaration><![CDATA[VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[P_StationID := _uiStationID;]]></ST>
</Implementation>
</Get>
<Set Name="Set" Id="{2aae20dc-be6d-4d77-adda-bb622f240eb6}">
<Declaration><![CDATA[VAR
END_VAR
]]></Declaration>
<Implementation>
<ST><![CDATA[_uiStationID := P_StationID;]]></ST>
</Implementation>
</Set>
</Property>
</POU>
</TcPlcObject>