use of org.opensmartgridplatform.domain.core.entities.Ssld in project open-smart-grid-platform by OSGP.
the class DeviceMappingTest method coreSsld.
private Ssld coreSsld() {
final Ssld ssld = new Ssld(DEVICE_IDENTIFICATION, null, this.address(), this.gpsCoordinates(), null);
ssld.updateRegistrationData(null, DEVICE_TYPE);
ssld.setHasSchedule(false);
ssld.setPublicKeyPresent(false);
return ssld;
}
use of org.opensmartgridplatform.domain.core.entities.Ssld in project open-smart-grid-platform by OSGP.
the class DeviceMappingTest method testConvertSsldToCore.
@Test
void testConvertSsldToCore() {
final Ssld ssld = mapper.map(this.adhocManagementSsld(), Ssld.class);
assertThat(ssld).usingRecursiveComparison().ignoringFields("creationTime", "modificationTime").isEqualTo(this.coreSsld());
}
use of org.opensmartgridplatform.domain.core.entities.Ssld in project open-smart-grid-platform by OSGP.
the class DeviceInstallationService method handleSsld.
private void handleSsld(final String deviceIdentification, final DeviceStatus status, final GetStatusResponse response) {
// Find device and output settings.
final Ssld ssld = this.ssldRepository.findByDeviceIdentification(deviceIdentification);
final List<DeviceOutputSetting> deviceOutputSettings = ssld.getOutputSettings();
// Create map with external relay number as key set.
final Map<Integer, DeviceOutputSetting> dosMap = new HashMap<>();
for (final DeviceOutputSetting dos : deviceOutputSettings) {
dosMap.put(dos.getExternalId(), dos);
}
if (status != null) {
// Map the DeviceStatus for SSLD.
final DeviceStatusMapped deviceStatusMapped = new DeviceStatusMapped(FilterLightAndTariffValuesHelper.filterTariffValues(status.getLightValues(), dosMap, DomainType.TARIFF_SWITCHING), FilterLightAndTariffValuesHelper.filterLightValues(status.getLightValues(), dosMap, DomainType.PUBLIC_LIGHTING), status.getPreferredLinkType(), status.getActualLinkType(), status.getLightType(), status.getEventNotificationsMask());
deviceStatusMapped.setBootLoaderVersion(status.getBootLoaderVersion());
deviceStatusMapped.setCurrentConfigurationBackUsed(status.getCurrentConfigurationBackUsed());
deviceStatusMapped.setCurrentIp(status.getCurrentIp());
deviceStatusMapped.setCurrentTime(status.getCurrentTime());
deviceStatusMapped.setDcOutputVoltageCurrent(status.getDcOutputVoltageCurrent());
deviceStatusMapped.setDcOutputVoltageMaximum(status.getDcOutputVoltageMaximum());
deviceStatusMapped.setEventNotificationsMask(status.getEventNotificationsMask());
deviceStatusMapped.setExternalFlashMemSize(status.getExternalFlashMemSize());
deviceStatusMapped.setFirmwareVersion(status.getFirmwareVersion());
deviceStatusMapped.setHardwareId(status.getHardwareId());
deviceStatusMapped.setInternalFlashMemSize(status.getInternalFlashMemSize());
deviceStatusMapped.setLastInternalTestResultCode(status.getLastInternalTestResultCode());
deviceStatusMapped.setMacAddress(status.getMacAddress());
deviceStatusMapped.setMaximumOutputPowerOnDcOutput(status.getMaximumOutputPowerOnDcOutput());
deviceStatusMapped.setName(status.getName());
deviceStatusMapped.setNumberOfOutputs(status.getNumberOfOutputs());
deviceStatusMapped.setSerialNumber(status.getSerialNumber());
deviceStatusMapped.setStartupCounter(status.getStartupCounter());
// Return mapped status using GetStatusResponse instance.
response.setDeviceStatusMapped(deviceStatusMapped);
} else {
// No status received, create bad response.
response.setDeviceStatusMapped(null);
response.setOsgpException(new TechnicalException(ComponentType.DOMAIN_CORE, "SSLD was not able to report relay status", new NoDeviceResponseException()));
response.setResult(ResponseMessageResultType.NOT_OK);
}
}
use of org.opensmartgridplatform.domain.core.entities.Ssld in project open-smart-grid-platform by OSGP.
the class RelayStatusSteps method aDeviceRelayStatus.
@Given("^a device relay status$")
public void aDeviceRelayStatus(final Map<String, String> settings) {
final Ssld ssld = this.ssldDeviceSteps.findByDeviceIdentification(settings);
final RelayStatus relayStatus = this.relayStatusFactory.fromMap(ssld, settings);
ssld.addOrUpdateRelayStatus(relayStatus);
this.ssldDeviceSteps.saveSsld(ssld);
}
use of org.opensmartgridplatform.domain.core.entities.Ssld 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