Search in sources :

Example 6 with CommandStatus

use of com.automatak.dnp3.enums.CommandStatus in project solarnetwork-node by SolarNetwork.

the class OutstationServceTests method handleAnalogInt32.

@Test
public void handleAnalogInt32() {
    // given
    TestOutstationService service = createOutstationService();
    final String controlId = "/foo/limiter";
    ControlConfig cConfig = new ControlConfig(null, controlId, ControlType.Analog);
    service.setControlConfigs(new ControlConfig[] { cConfig });
    Capture<Instruction> instrCaptor = Capture.newInstance();
    expect(instructionService.executeInstruction(capture(instrCaptor))).andAnswer(new IAnswer<InstructionStatus>() {

        @Override
        public InstructionStatus answer() throws Throwable {
            return createStatus(instrCaptor.getValue(), Completed);
        }
    });
    // when
    replayAll();
    AnalogOutputInt32 cmd = new AnalogOutputInt32(321456, CommandStatus.SUCCESS);
    CommandStatus status = service.getCommandHandler().operateAOI32(cmd, 0, OperateType.DirectOperate);
    // then
    assertThat("Command OK", status, equalTo(CommandStatus.SUCCESS));
    Instruction instr = instrCaptor.getValue();
    assertThat("Instruction", instr.getTopic(), equalTo(InstructionHandler.TOPIC_SET_CONTROL_PARAMETER));
    assertThat("Control ID param", instr.getParameterValue(controlId), equalTo(String.valueOf(cmd.value)));
}
Also used : ControlConfig(net.solarnetwork.node.io.dnp3.domain.ControlConfig) InstructionStatus(net.solarnetwork.node.reactor.InstructionStatus) AnalogOutputInt32(com.automatak.dnp3.AnalogOutputInt32) CommandStatus(com.automatak.dnp3.enums.CommandStatus) Instruction(net.solarnetwork.node.reactor.Instruction) Test(org.junit.Test)

Aggregations

CommandStatus (com.automatak.dnp3.enums.CommandStatus)6 ControlConfig (net.solarnetwork.node.io.dnp3.domain.ControlConfig)6 Test (org.junit.Test)6 Instruction (net.solarnetwork.node.reactor.Instruction)5 InstructionStatus (net.solarnetwork.node.reactor.InstructionStatus)5 ControlRelayOutputBlock (com.automatak.dnp3.ControlRelayOutputBlock)4 AnalogOutputInt32 (com.automatak.dnp3.AnalogOutputInt32)2 CapturingExecutorService (net.solarnetwork.node.test.CapturingExecutorService)2 TaskExecutorAdapter (org.springframework.core.task.support.TaskExecutorAdapter)2