// Program the error handler (FaultHandler_Insert) according to the device.
FaultHandler_Insert();
Operating_Insert := FALSE;
END_IF;
END_IF;
END_IF;
// ---------------------------------------------------------------------------------------------------------------------
// - Update the records in the DB Connection MyDB1 when the variable Trigger_Update changes to TRUE.
// Start the sequence when the variable Trigger_Update changes to TRUE.
IF ( (Trigger_Update=TRUE) AND (LastTrigger_Update=FALSE) ) THEN
OperatingStart_Update := TRUE;
Operating_Update := TRUE;
END_IF;
LastTrigger_Update := Trigger_Update;
// Sequence start processing
IF (OperatingStart_Update=TRUE) THEN
// Initialize the instance of the applicable DB Connection Instruction.
DB_Update_instance( Execute:=FALSE, MapVar:=MapVar_Update );
// Create production data to update.
MapVar_Update.Status := 'OK';
MapVar_Update.FinishTime := GetTime();
// Create the conditions for Where clause. ("LotNo" = XXXX AND "Status" = 'Busy')
WhereCond := CONCAT(
'"LotNo" = $'',
UINT_TO_STRING( LotNo ),
'$' AND "Status" = $'Busy$''
);
OperatingStart_Update := FALSE;
END_IF;
// Update production data in the DB Connection MyDB1. Set the timeout for instruction execution to 200 ms.
IF (Operating_Update=TRUE) THEN
// Update records
DB_Update_instance(
Execute := TRUE,
DBConnection := MyDB1,
MapVar := MapVar_Update,
Where := WhereCond,
TimeOut := T#200ms );
IF (DB_Update_instance.Done=TRUE) THEN
Operating_Update:=FALSE; // Normal end
END_IF;