Search in sources :

Example 1 with Configuration

use of de.avanux.smartapplianceenabler.configuration.Configuration in project SmartApplianceEnabler by camueller.

the class SaeController method setSettings.

@RequestMapping(value = SETTINGS_URL, method = RequestMethod.PUT, consumes = "application/json")
@CrossOrigin(origins = CROSS_ORIGIN_URL)
public void setSettings(@RequestBody Settings settings) {
    logger.debug("Received request to set " + settings);
    List<PulseReceiver> pulseReceivers = null;
    if (settings.isPulseReceiverEnabled()) {
        PulseReceiver pulseReceiver = new PulseReceiver();
        pulseReceiver.setId(PulseReceiver.DEFAULT_ID);
        pulseReceiver.setPort(settings.getPulseReceiverPort());
        pulseReceivers = Collections.singletonList(pulseReceiver);
    }
    List<ModbusTcp> modbusTCPs = null;
    if (settings.isModbusEnabled()) {
        ModbusTcp modbusTcp = new ModbusTcp();
        modbusTcp.setId(ModbusTcp.DEFAULT_ID);
        modbusTcp.setHost(settings.getModbusTcpHost());
        modbusTcp.setPort(settings.getModbusTcpPort());
        modbusTCPs = Collections.singletonList(modbusTcp);
    }
    Connectivity connectivity = null;
    if (pulseReceivers != null || modbusTCPs != null) {
        connectivity = new Connectivity();
        connectivity.setPulseReceivers(pulseReceivers);
        connectivity.setModbusTCPs(modbusTCPs);
    }
    ApplianceManager.getInstance().setConnectivity(connectivity);
    List<Configuration> configurations = null;
    if (settings.isHolidaysEnabled()) {
        Configuration configuration = new Configuration();
        configuration.setParam(HolidaysDownloader.urlConfigurationParamName);
        configuration.setValue(settings.getHolidaysUrl());
        configurations = Collections.singletonList(configuration);
    }
    ApplianceManager.getInstance().setConfiguration(configurations);
}
Also used : Configuration(de.avanux.smartapplianceenabler.configuration.Configuration) Connectivity(de.avanux.smartapplianceenabler.configuration.Connectivity) ModbusTcp(de.avanux.smartapplianceenabler.modbus.ModbusTcp)

Aggregations

Configuration (de.avanux.smartapplianceenabler.configuration.Configuration)1 Connectivity (de.avanux.smartapplianceenabler.configuration.Connectivity)1 ModbusTcp (de.avanux.smartapplianceenabler.modbus.ModbusTcp)1