Search in sources :

Example 1 with Parser

use of org.openhab.binding.modbus.e3dc.internal.modbus.Parser in project openhab-addons by openhab.

the class InfoTest method testInvalidBlockSize.

@Test
public void testInvalidBlockSize() {
    byte[] infoBlock = new byte[] { -29, -36, 1, 2, 0, -120, 69, 51, 47, 68, 67, 32, 71, 109, 98, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 49, 48, 32, 69, 32, 65, 73, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 78, 73, 78, 73, 84, 73, 65, 76, 73, 90, 69, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 49, 48, 95, 50, 48, 50, 48, 95, 48 };
    Parser mc = new Parser(DataType.INFO);
    mc.setArray(infoBlock);
    Optional<Data> infoOpt = mc.parse(DataType.INFO);
    InfoBlock b = (InfoBlock) infoOpt.get();
    // block still valid but data maybe corrupted => logged in warnings
    assertTrue(infoOpt.isPresent());
    assertNotNull(b);
}
Also used : InfoBlock(org.openhab.binding.modbus.e3dc.internal.dto.InfoBlock) Data(org.openhab.binding.modbus.e3dc.internal.modbus.Data) Parser(org.openhab.binding.modbus.e3dc.internal.modbus.Parser) Test(org.junit.jupiter.api.Test)

Example 2 with Parser

use of org.openhab.binding.modbus.e3dc.internal.modbus.Parser in project openhab-addons by openhab.

the class InfoTest method setup.

@BeforeEach
public void setup() {
    byte[] infoBlock = new byte[] { -29, -36, 1, 2, 0, -120, 69, 51, 47, 68, 67, 32, 71, 109, 98, 72, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 49, 48, 32, 69, 32, 65, 73, 79, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 85, 78, 73, 78, 73, 84, 73, 65, 76, 73, 90, 69, 68, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 83, 49, 48, 95, 50, 48, 50, 48, 95, 48, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };
    mc = new Parser(DataType.INFO);
    mc.setArray(infoBlock);
}
Also used : Parser(org.openhab.binding.modbus.e3dc.internal.modbus.Parser) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 3 with Parser

use of org.openhab.binding.modbus.e3dc.internal.modbus.Parser in project openhab-addons by openhab.

the class ParserNameTest method testDebugNames.

@Test
public void testDebugNames() {
    Parser mcInfo = new Parser(DataType.INFO);
    assertEquals("org.openhab.binding.modbus.e3dc.internal.modbus.Parser:INFO", mcInfo.toString(), "Debug Name Info");
    Parser mcPower = new Parser(DataType.DATA);
    assertEquals("org.openhab.binding.modbus.e3dc.internal.modbus.Parser:DATA", mcPower.toString(), "Debug Name Power");
}
Also used : Parser(org.openhab.binding.modbus.e3dc.internal.modbus.Parser) Test(org.junit.jupiter.api.Test)

Aggregations

Parser (org.openhab.binding.modbus.e3dc.internal.modbus.Parser)3 Test (org.junit.jupiter.api.Test)2 BeforeEach (org.junit.jupiter.api.BeforeEach)1 InfoBlock (org.openhab.binding.modbus.e3dc.internal.dto.InfoBlock)1 Data (org.openhab.binding.modbus.e3dc.internal.modbus.Data)1