Search in sources :

Example 1 with ModbusSlave

use of de.avanux.smartapplianceenabler.modbus.ModbusSlave in project SmartApplianceEnabler by camueller.

the class Appliance method start.

public void start(Timer timer, GpioController gpioController, Map<String, PulseReceiver> pulseReceiverIdWithPulseReceiver, Map<String, ModbusTcp> modbusIdWithModbusTcp) {
    if (runningTimeMonitor != null) {
        runningTimeMonitor.setTimer(timer);
    }
    for (GpioControllable gpioControllable : getGpioControllables()) {
        logger.info("{}: Starting {}", id, gpioControllable.getClass().getSimpleName());
        gpioControllable.setGpioController(gpioController);
        gpioControllable.start();
    }
    if (meter != null && meter instanceof S0ElectricityMeterNetworked) {
        S0ElectricityMeterNetworked s0ElectricityMeterNetworked = (S0ElectricityMeterNetworked) meter;
        logger.info("{}: Starting {}", id, S0ElectricityMeterNetworked.class.getSimpleName());
        String pulseReceiverId = s0ElectricityMeterNetworked.getIdref();
        PulseReceiver pulseReceiver = pulseReceiverIdWithPulseReceiver.get(pulseReceiverId);
        s0ElectricityMeterNetworked.setPulseReceiver(pulseReceiver);
        s0ElectricityMeterNetworked.start();
    }
    if (meter != null && meter instanceof HttpElectricityMeter) {
        ((HttpElectricityMeter) meter).start(timer);
    }
    for (ModbusSlave modbusSlave : getModbusSlaves()) {
        logger.info("{}: Starting {}", id, modbusSlave.getClass().getSimpleName());
        modbusSlave.setApplianceId(id);
        String modbusId = modbusSlave.getIdref();
        ModbusTcp modbusTcp = modbusIdWithModbusTcp.get(modbusId);
        modbusSlave.setModbusTcp(modbusTcp);
    }
    if (meter != null && meter instanceof ModbusElectricityMeter) {
        ((ModbusElectricityMeter) meter).start(timer);
    }
    if (control != null && control instanceof StartingCurrentSwitch) {
        logger.info("{}: Starting {}", id, StartingCurrentSwitch.class.getSimpleName());
        ((StartingCurrentSwitch) control).start(new LocalDateTime(), getMeter(), timer);
    }
}
Also used : LocalDateTime(org.joda.time.LocalDateTime) ModbusSlave(de.avanux.smartapplianceenabler.modbus.ModbusSlave) ModbusTcp(de.avanux.smartapplianceenabler.modbus.ModbusTcp)

Aggregations

ModbusSlave (de.avanux.smartapplianceenabler.modbus.ModbusSlave)1 ModbusTcp (de.avanux.smartapplianceenabler.modbus.ModbusTcp)1 LocalDateTime (org.joda.time.LocalDateTime)1