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);
}
}
Aggregations