Search in sources :

Example 1 with RoverPacketListUpdater

use of me.retrodaredevil.solarthing.program.receiver.RoverPacketListUpdater in project solarthing by wildmountainfarms.

the class RoverModbusRequester method create.

@Override
public DataRequesterResult create(RequestObject requestObject, SuccessReporter successReporter, ModbusSlave modbus) {
    final RoverReadTable read;
    final Runnable reloadCache;
    if (bulkRequest) {
        ModbusCacheSlave modbusCacheSlave = new ModbusCacheSlave(modbus);
        read = new RoverModbusSlaveRead(modbusCacheSlave);
        reloadCache = () -> cacheRegisters(modbusCacheSlave);
    } else {
        read = new RoverModbusSlaveRead(modbus);
        reloadCache = () -> {
        };
    }
    RoverWriteTable write = new RoverModbusSlaveWrite(modbus);
    RoverModbusEnvironment roverModbusEnvironment = new RoverModbusEnvironment(read, write);
    final NetCatServerHandler netCatServerHandler;
    if (configurationServerConfig == null) {
        netCatServerHandler = null;
    } else {
        try {
            netCatServerHandler = new NetCatServerHandler(configurationServerConfig.getBindAddress(), configurationServerConfig.getPort());
        } catch (IOException e) {
            throw new RuntimeException("Could not create NetCatServerHandler", e);
        }
    }
    return new DataRequesterResult(new ModbusListUpdaterWrapper(new RoverPacketListUpdater(number, read, write, netCatServerHandler == null ? null : new ConnectionHandler(netCatServerHandler)), reloadCache, successReporter, sendErrorPackets, "rover.error." + number), new AttachToCommandEnvironmentUpdater(Collections.singletonList(roverModbusEnvironment), attachToCommands::contains));
}
Also used : RoverModbusSlaveRead(me.retrodaredevil.solarthing.solar.renogy.rover.modbus.RoverModbusSlaveRead) NetCatServerHandler(me.retrodaredevil.solarthing.netcat.NetCatServerHandler) ModbusCacheSlave(me.retrodaredevil.solarthing.program.modbus.ModbusCacheSlave) IOException(java.io.IOException) RoverReadTable(me.retrodaredevil.solarthing.solar.renogy.rover.RoverReadTable) RoverPacketListUpdater(me.retrodaredevil.solarthing.program.receiver.RoverPacketListUpdater) DataRequesterResult(me.retrodaredevil.solarthing.config.request.DataRequesterResult) RoverModbusEnvironment(me.retrodaredevil.solarthing.actions.environment.RoverModbusEnvironment) ConnectionHandler(me.retrodaredevil.solarthing.netcat.ConnectionHandler) ModbusListUpdaterWrapper(me.retrodaredevil.solarthing.program.receiver.ModbusListUpdaterWrapper) RoverModbusSlaveWrite(me.retrodaredevil.solarthing.solar.renogy.rover.modbus.RoverModbusSlaveWrite) RoverWriteTable(me.retrodaredevil.solarthing.solar.renogy.rover.RoverWriteTable)

Aggregations

IOException (java.io.IOException)1 RoverModbusEnvironment (me.retrodaredevil.solarthing.actions.environment.RoverModbusEnvironment)1 DataRequesterResult (me.retrodaredevil.solarthing.config.request.DataRequesterResult)1 ConnectionHandler (me.retrodaredevil.solarthing.netcat.ConnectionHandler)1 NetCatServerHandler (me.retrodaredevil.solarthing.netcat.NetCatServerHandler)1 ModbusCacheSlave (me.retrodaredevil.solarthing.program.modbus.ModbusCacheSlave)1 ModbusListUpdaterWrapper (me.retrodaredevil.solarthing.program.receiver.ModbusListUpdaterWrapper)1 RoverPacketListUpdater (me.retrodaredevil.solarthing.program.receiver.RoverPacketListUpdater)1 RoverReadTable (me.retrodaredevil.solarthing.solar.renogy.rover.RoverReadTable)1 RoverWriteTable (me.retrodaredevil.solarthing.solar.renogy.rover.RoverWriteTable)1 RoverModbusSlaveRead (me.retrodaredevil.solarthing.solar.renogy.rover.modbus.RoverModbusSlaveRead)1 RoverModbusSlaveWrite (me.retrodaredevil.solarthing.solar.renogy.rover.modbus.RoverModbusSlaveWrite)1