Search in sources :

Example 1 with TracerModbusEnvironment

use of me.retrodaredevil.solarthing.actions.environment.TracerModbusEnvironment in project solarthing by wildmountainfarms.

the class TracerLoadActionNode method createAction.

@Override
public Action createAction(ActionEnvironment actionEnvironment) {
    TracerModbusEnvironment tracerModbusEnvironment = actionEnvironment.getInjectEnvironment().get(TracerModbusEnvironment.class);
    TracerWriteTable write = tracerModbusEnvironment.getWrite();
    return Actions.createRunOnce(() -> {
        try {
            write.setLoadControlMode(LoadControlMode.MANUAL_CONTROL);
            write.setManualLoadControlOn(on);
            LOGGER.info(SolarThingConstants.SUMMARY_MARKER, "Successfully executed tracer load command. on: " + on);
        } catch (ModbusRuntimeException e) {
            LOGGER.error("Unable to perform tracer write Modbus request", e);
        }
    });
}
Also used : TracerModbusEnvironment(me.retrodaredevil.solarthing.actions.environment.TracerModbusEnvironment) TracerWriteTable(me.retrodaredevil.solarthing.solar.tracer.TracerWriteTable) ModbusRuntimeException(me.retrodaredevil.io.modbus.ModbusRuntimeException)

Example 2 with TracerModbusEnvironment

use of me.retrodaredevil.solarthing.actions.environment.TracerModbusEnvironment in project solarthing by wildmountainfarms.

the class TracerModbusRequester method create.

@Override
public DataRequesterResult create(RequestObject requestObject, SuccessReporter successReporter, ModbusSlave modbus) {
    final TracerReadTable read;
    final Runnable reloadCache;
    if (bulkRequest) {
        ModbusCacheSlave modbusCacheSlave = new ModbusCacheSlave(modbus);
        read = new TracerModbusSlaveRead(modbusCacheSlave);
        reloadCache = () -> cacheRegisters(modbusCacheSlave);
    } else {
        read = new TracerModbusSlaveRead(modbus);
        reloadCache = () -> {
        };
    }
    TracerWriteTable write = new TracerModbusSlaveWrite(modbus);
    TracerModbusEnvironment tracerModbusEnvironment = new TracerModbusEnvironment(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 TracerPacketListUpdater(number, read, write, tracerClockOptions, netCatServerHandler == null ? null : new ConnectionHandler(netCatServerHandler), connectionHandlerHasFlushLogic), reloadCache, successReporter, sendErrorPackets, "tracer.error." + number), new AttachToCommandEnvironmentUpdater(Collections.singletonList(tracerModbusEnvironment), attachToCommands::contains));
}
Also used : NetCatServerHandler(me.retrodaredevil.solarthing.netcat.NetCatServerHandler) TracerWriteTable(me.retrodaredevil.solarthing.solar.tracer.TracerWriteTable) TracerPacketListUpdater(me.retrodaredevil.solarthing.program.receiver.TracerPacketListUpdater) ModbusCacheSlave(me.retrodaredevil.solarthing.program.modbus.ModbusCacheSlave) TracerModbusSlaveWrite(me.retrodaredevil.solarthing.solar.tracer.modbus.TracerModbusSlaveWrite) IOException(java.io.IOException) TracerModbusSlaveRead(me.retrodaredevil.solarthing.solar.tracer.modbus.TracerModbusSlaveRead) DataRequesterResult(me.retrodaredevil.solarthing.config.request.DataRequesterResult) TracerReadTable(me.retrodaredevil.solarthing.solar.tracer.TracerReadTable) ConnectionHandler(me.retrodaredevil.solarthing.netcat.ConnectionHandler) TracerModbusEnvironment(me.retrodaredevil.solarthing.actions.environment.TracerModbusEnvironment) ModbusListUpdaterWrapper(me.retrodaredevil.solarthing.program.receiver.ModbusListUpdaterWrapper)

Aggregations

TracerModbusEnvironment (me.retrodaredevil.solarthing.actions.environment.TracerModbusEnvironment)2 TracerWriteTable (me.retrodaredevil.solarthing.solar.tracer.TracerWriteTable)2 IOException (java.io.IOException)1 ModbusRuntimeException (me.retrodaredevil.io.modbus.ModbusRuntimeException)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 TracerPacketListUpdater (me.retrodaredevil.solarthing.program.receiver.TracerPacketListUpdater)1 TracerReadTable (me.retrodaredevil.solarthing.solar.tracer.TracerReadTable)1 TracerModbusSlaveRead (me.retrodaredevil.solarthing.solar.tracer.modbus.TracerModbusSlaveRead)1 TracerModbusSlaveWrite (me.retrodaredevil.solarthing.solar.tracer.modbus.TracerModbusSlaveWrite)1