5. CONFIGURATION
fbPulsedCmd: PulsedCommandNexto; // Pulsed Command Instance
byResult: BYTE; // Pulsed command result
dbpIEC104: DBP; // Variable mapped in the IEC 104
bSetup: BOOL:= TRUE; // Interceptor initial setup
END_VAR
// Executes the function configuration in the first cycle
IF bSetup THEN
CmdReceive.dwVariableAddr:= ADR(dbpIEC104);
CmdReceive.bExec:= TRUE;
CmdReceive.eCommandResult:= COMMAND_RESULT.NONE;
CmdReceive.dwTimeout:= 256
*
10;
bSetup:= FALSE;
END_IF
// In case a command is captured:
IF CmdReceive.bCommandAvailable THEN
// Treats each one of the possible commands
CASE CmdReceive.sCommand.eCommand OF
COMMAND_TYPE.NO_COMMAND:
// Inform that there is an invalid command.
// Does nothing and must move on by time-out.
COMMAND_TYPE.SELECT:
// Treats only commands for double points
IF CmdReceive.sCommand.sSelectParameters.sValue.eParamType =
DOUBLE_POINT_COMMAND THEN
// Returns command finished with success
// (controlled by IEC104 protocol)
byResult:= 7;
ELSE
// Returns command not supported
byResult:= 1;
END_IF
COMMAND_TYPE.OPERATE:
// Treats only commands for double points
IF CmdReceive.sCommand.sOperateParameters.sValue.eParamType =
DOUBLE_POINT_COMMAND THEN
// Pulse generation in outputs
IF CmdReceive.sCommand.sOperateParameters.sValue.sDoublePoint.bValue THEN
// Executes TRIP function
fbPulsedCmd(
byCmdType:= 101,
byPulseTime:= DWORD_TO_BYTE(CmdReceive.sCommand.sOperateParameters.
sValue.sDoublePoint.sPulseConfig.dwOnDuration/10),
ptDbpVarAdr:= ADR(dbpIEC104),
stQuality:= IOQualities.QUALITY_NX2020[4],
byStatus=> byResult);
ELSE
// Executes CLOSE function
201