use of org.opensmartgridplatform.domain.core.valueobjects.RelayType in project open-smart-grid-platform by OSGP.
the class RelayMapConverter method convertIndexAddressMapToRelayMap.
/**
* Converts an IndexAddressMap received from an OSLP device to a RelayMap
*
* @param indexAddressMap the IndexAddressMap to convert.
* @return the created RelayMap.
*/
private static RelayMap convertIndexAddressMapToRelayMap(final IndexAddressMap indexAddressMap) {
final RelayType relayType = RelayType.valueOf(indexAddressMap.getRelayType().toString());
final Integer relayIndex = OslpUtils.byteStringToInteger(indexAddressMap.getIndex());
final Integer relayAddress = OslpUtils.byteStringToInteger(indexAddressMap.getAddress());
return new RelayMap(relayIndex, relayAddress, relayType, null);
}
use of org.opensmartgridplatform.domain.core.valueobjects.RelayType in project open-smart-grid-platform by OSGP.
the class SsldDeviceSteps method createAnSsldDevice.
private Ssld createAnSsldDevice(final Map<String, String> settings) {
// Set the required stuff
final String deviceIdentification = getString(settings, PlatformKeys.KEY_DEVICE_IDENTIFICATION);
final Ssld ssld = new Ssld(deviceIdentification);
ssld.setPublicKeyPresent(getBoolean(settings, PlatformKeys.KEY_PUBLICKEYPRESENT, PlatformDefaults.DEFAULT_PUBLICKEYPRESENT));
ssld.setHasSchedule(getBoolean(settings, PlatformKeys.KEY_HAS_SCHEDULE, PlatformDefaults.DEFAULT_HASSCHEDULE));
if (settings.containsKey(PlatformKeys.KEY_INTERNALID) || settings.containsKey(PlatformKeys.KEY_EXTERNALID) || settings.containsKey(PlatformKeys.KEY_RELAY_TYPE)) {
final List<DeviceOutputSetting> dosList = new ArrayList<>();
final int internalId = getInteger(settings, PlatformKeys.KEY_INTERNALID, PlatformDefaults.DEFAULT_INTERNALID), externalId = getInteger(settings, PlatformKeys.KEY_EXTERNALID, PlatformDefaults.DEFAULT_EXTERNALID);
final RelayType relayType = getEnum(settings, PlatformKeys.KEY_RELAY_TYPE, RelayType.class, RelayType.LIGHT);
if (relayType != null) {
dosList.add(new DeviceOutputSetting(internalId, externalId, relayType));
ssld.updateOutputSettings(dosList);
}
}
ssld.updateInMaintenance(getBoolean(settings, PlatformKeys.DEVICE_IN_MAINTENANCE, PlatformDefaults.DEVICE_IN_MAINTENANCE));
ssld.setFailedConnectionCount(getInteger(settings, PlatformKeys.KEY_FAILED_CONNECTION_COUNT, PlatformDefaults.DEFAULT_FAILED_CONNECTION_COUNT));
final DateTime lastSuccessfulConnectionTimestamp = getDate(settings, PlatformKeys.KEY_LAST_COMMUNICATION_TIME, DateTime.now());
ssld.setLastSuccessfulConnectionTimestamp(lastSuccessfulConnectionTimestamp.toDate());
if (settings.containsKey(PlatformKeys.KEY_LIGHTMEASUREMENT_DEVICE_IDENTIFICATION)) {
final LightMeasurementDevice lmd = this.lmdRepository.findByDeviceIdentification(settings.get(PlatformKeys.KEY_LIGHTMEASUREMENT_DEVICE_IDENTIFICATION));
ssld.setLightMeasurementDevice(lmd);
}
this.ssldRepository.save(ssld);
// now update the common stuff of the SSLD device.
this.updateDevice(deviceIdentification, settings);
// Return the updated ssld device.
return this.ssldRepository.findByDeviceIdentification(deviceIdentification);
}
Aggregations