4. Configuration
164
The example code below, POU CmdRcv, treats pulsed commands received from clients for a digital
double point, mapped in a NX2020 module. Besides the following ST code it is need to map a DBP
point in Nexto’s IEC 60870-5-104 server.
Figure 4-75. Server IEC 60870-5-104 Mappings Screen
PROGRAM CmdRcv
VAR
CmdReceive: CommandReceiver; // Interceptor Instance
fbPulsedCmd: PulsedCommandNexto; // Pulsed Command Instance
byResult: BYTE; // Pulsed command result
dbpIEC104: DBP; // Variable mapped in the IEC 104
bSetup: BOOL:= TRUE; // Interceptor’s 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 timeout.
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.dwOnDur
ation/10),
ptDbpVarAdr:= ADR(dbpIEC104),
stQuality:= IOQualities.QUALITY_NX2020[4],
byStatus=> byResult);
ELSE
// Executes CLOSE function
fbPulsedCmd(