use of com.ghgande.j2mod.modbus.facade.ModbusTCPMaster in project openems by OpenEMS.
the class ModbusMaster method main.
public static void main(String[] args) {
ModbusTCPMaster master = new ModbusTCPMaster("10.0.10.230", 502, 10000, true);
try {
master.connect();
Register[] registers = master.readMultipleRegisters(40000, 1);
for (Register register : registers) {
System.out.println(register);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
master.disconnect();
}
}
use of com.ghgande.j2mod.modbus.facade.ModbusTCPMaster in project openems by OpenEMS.
the class StreetscooterTest method main.
public static void main(String[] args) {
ModbusTCPMaster master = new ModbusTCPMaster("localhost", 502, 10000, true);
try {
master.connect();
// Register[] registers = master.readMultipleRegisters(30011, 2);
InputRegister[] registers = master.readInputRegisters(100, 6, 4);
for (InputRegister register : registers) {
System.out.println(register);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
master.disconnect();
}
}
use of com.ghgande.j2mod.modbus.facade.ModbusTCPMaster in project energy by nielsbasjes.
the class TestRealDeviceSolarEdge method verifyTheValues.
@Test
public void verifyTheValues() throws ModbusException, MissingMandatoryFieldException {
try (SunSpecModbusDataReader dataReader = new SunSpecModbusDataReader(new ModbusTCPMaster(getHost(), getTestport()))) {
SunSpecFetcher fetcher = new SunSpecFetcher(dataReader).useAllModels();
fetcher.refresh();
assertEquals("SolarEdge ", fetcher.model_1.getManufacturer());
assertEquals("SE3000H-RW000BNN4", fetcher.model_1.getModel());
assertEquals(509.20, fetcher.model_101.getWatts(), 0.0001);
assertEquals(38.14, fetcher.model_101.getHeatSinkTemperature(), 0.0001);
}
}
use of com.ghgande.j2mod.modbus.facade.ModbusTCPMaster in project energy by nielsbasjes.
the class TestSunSpecFetcher method getBlockListTest.
@Test
public void getBlockListTest() throws Exception {
try (SunSpecModbusDataReader dataReader = new SunSpecModbusDataReader(new ModbusTCPMaster(getHost(), getTestport()))) {
dataReader.connect();
final Map<Integer, SunSpecModbusDataReader.ModelLocation> blockLocations = dataReader.getModelLocations(SUNSPEC_STANDARD_STARTBASE);
int[][] expected = { { 1, 40004, 65 }, { 101, 40071, 50 }, { 120, 40123, 26 }, { 121, 40151, 30 }, { 122, 40183, 44 }, { 123, 40229, 24 }, { 126, 40255, 226 }, { 131, 40483, 226 }, { 132, 40711, 226 } };
int exp = 0;
for (Map.Entry<Integer, ModelLocation> entry : blockLocations.entrySet()) {
Integer i = entry.getKey();
SunSpecModbusDataReader.ModelLocation b = entry.getValue();
assertEquals((int) i, b.id);
assertEquals(expected[exp][0], b.id);
assertEquals(expected[exp][1], b.registerBase);
assertEquals(expected[exp][2], b.len);
exp++;
}
}
}
use of com.ghgande.j2mod.modbus.facade.ModbusTCPMaster in project energy by nielsbasjes.
the class TestSunSpecFetcher method requestNonExistendModel.
@Test(expected = UnsupportedOperationException.class)
public void requestNonExistendModel() throws Exception {
SunSpecModbusDataReader dataReader = new SunSpecModbusDataReader(new ModbusTCPMaster(getHost(), getTestport()));
new SunSpecFetcher(dataReader).useModel(1).useModel(123456);
}
Aggregations