Appendix A
A-31
A
NJ/NX-series Database Connection CPU Units User’s Manual (W527)
Operating_Connect := FALSE;
END_CASE;
END_IF;
// ---------------------------------------------------------------------------------------------------------------------
// - Insert production data to DB Connection MyDB1 when the variable Trigger_Insert changes to TRUE.
// Start the sequence when the variable Trigger_Insert changes to TRUE.
IF ( (Trigger_Insert=TRUE) AND (LastTrigger_Insert=FALSE) ) THEN
OperatingStart_Insert := TRUE;
Operating_Insert := TRUE;
END_IF;
LastTrigger_Insert := Trigger_Insert;
// Sequence start processing
IF (OperatingStart_Insert=TRUE) THEN
// Initialize the instance of the applicable DB Connection Instruction.
DB_Insert_instance( Execute:=FALSE, MapVar:=MapVar_Insert );
// Create production data to insert.
MapVar_Insert.Name := Name;
MapVar_Insert.LotNo := UINT_TO_STRING(LotNo);
MapVar_Insert.Status := 'Busy';
MapVar_Insert.ProductionDate := DT_TO_DATE(GetTime( ));
OperatingStart_Insert := FALSE;
END_IF;
// Insert production data to the DB Connection MyDB1. Set the timeout for instruction execution to 200 ms.
IF (Operating_Insert=TRUE) THEN
// Insert records
DB_Insert_instance(
Execute := TRUE,
DBConnection := MyDB1,
MapVar := MapVar_Insert,
TimeOut := T#200ms
);
IF (DB_Insert_instance.Done=TRUE) THEN
Operating_Insert:=FALSE; // Normal end
END_IF;
IF (DB_Insert_instance.Error=TRUE) THEN
// Go to the next step when the instruction is not completed within the specified time.
IF (DB_Insert_instance.ErrorID = 16#3012) THEN
Operating_Insert:=FALSE; // Normal end
ELSE
// Execute the error handler.