4. Configuration
92
dbpDoublePointIO: DBP; // Variable mapped to the output module Xtorm
dbpDoublePointIEC104: DBP; // Variable mapped to IEC 104 Server
bSetup: BOOL:= TRUE; // Enables the initial setup of the Interceptor
END_VAR
IF bSetup THEN // Performs the function Setup in the first cycle
CRReceive.dwVariableAddr:=ADR(dbpDoublePointIEC104);
CRReceive.bExec:= TRUE;
CRReceive.eCommandResult:= COMMAND_RESULT.NONE;
CRReceive.dwTimeout:= 1000;
bSetup:= FALSE;
RETURN;
END_IF
IF CRReceive.bCommandAvailable THEN // If a command is captured:
CComamnd:= CRReceive.sCommand; // Save the command data
// Sending the command to the card for the function PulseCommand
IF CComamnd.sOperateParameters.sValue.sDoublePoint.bValue THEN
// Capture the value set for the pulse time
byPulseTimeON :=
DWORD_TO_BYTE(CComamnd.sOperateParameters.sValue.sDoublePoint.sPulse
Config.dwOnDuration/10);
// Performs the PulsedCommand function for the output module
byResult := PulsedCommand(bCommandType := 101, bRackNumber := 0,
bSlotNumber := 4, bPairIndex:= 0, bPulseTime := byPulseTimeON);
ELSE
// Capturing the value set for the pulse of time
byPulseTimeOFF :=
DWORD_TO_BYTE(CComamnd.sOperateParameters.sValue.sDoublePoint.sPulse
Config.dwOffDuration/10);
// Performs the PulsedCommand function for the output module
byResult := PulsedCommand(bCommandType := 102, bRackNumber := 0,
bSlotNumber := 4, bPairIndex:= 0, bPulseTime := byPulseTimeOFF);
END_IF
// Consist the result of the pulsed control function and generates the
response for the command intercepted
CASE byResult OF
0:// Command running
RETURN;
1: // Invalid command type
CRResult := COMMAND_RESULT.NOT_SUPPORTED;
CRReceive.eCommandResult:= CRResult;
CRReceive.bDone:= TRUE;
2, 3:// Invalid input parameters
CRResult := COMMAND_RESULT.INCONSISTENT_PARAMETERS;
CRReceive.eCommandResult:= CRResult;
CRReceive.bDone:= TRUE;
4: // Module did not respond to the command
CRResult := COMMAND_RESULT.TIME_LIMIT_OVER;
CRReceive.eCommandResult:= CRResult;
CRReceive.bDone:= TRUE;
6: // Another command was sent to this point and running
CRResult := COMMAND_RESULT.BLOCKED_BY_COMAND;
CRReceive.eCommandResult:= CRResult;
CRReceive.bDone:= TRUE;
7, 5:// Command completed successfully
CRResult := COMMAND_RESULT.SUCCESS;
CRReceive.eCommandResult:= CRResult;