use of org.opensmartgridplatform.domain.core.entities.Ssld in project open-smart-grid-platform by OSGP.
the class SsldDeviceSteps method theSsldDeviceContains.
@Then("^theSsldDeviceContains$")
public void theSsldDeviceContains(final Map<String, String> expectedEntity) {
Wait.until(() -> {
final Ssld ssld = this.ssldRepository.findByDeviceIdentification(getString(expectedEntity, PlatformKeys.KEY_DEVICE_IDENTIFICATION));
assertThat(ssld.getHasSchedule()).isEqualTo(getBoolean(expectedEntity, PlatformKeys.KEY_HAS_SCHEDULE));
});
this.deviceSteps.theDeviceContains(expectedEntity);
}
use of org.opensmartgridplatform.domain.core.entities.Ssld in project open-smart-grid-platform by OSGP.
the class SsldDeviceSteps method aSwitchingEventRelayStatus.
@Given("^a switching event relay status$")
@Transactional("txMgrCore")
public void aSwitchingEventRelayStatus(final Map<String, String> settings) {
final Ssld ssld = this.ssldRepository.findByDeviceIdentification(getString(settings, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformDefaults.DEFAULT_DEVICE_IDENTIFICATION));
final String[] deviceOutputSettings = getString(settings, PlatformKeys.DEVICE_OUTPUT_SETTINGS, PlatformDefaults.DEVICE_OUTPUT_SETTINGS).replaceAll(" ", "").split(PlatformKeys.SEPARATOR_SEMICOLON);
final String[] relayStatuses = getString(settings, PlatformKeys.RELAY_STATUSES, PlatformDefaults.RELAY_STATUSES).replaceAll(" ", "").split(PlatformKeys.SEPARATOR_SEMICOLON);
final List<DeviceOutputSetting> dosList = new ArrayList<>();
for (final String dos : deviceOutputSettings) {
final String[] deviceOutputSetting = dos.split(PlatformKeys.SEPARATOR_COMMA);
dosList.add(new DeviceOutputSetting(Integer.parseInt(deviceOutputSetting[0]), Integer.parseInt(deviceOutputSetting[1]), RelayType.valueOf(deviceOutputSetting[2]), deviceOutputSetting[3]));
}
ssld.updateOutputSettings(dosList);
for (final String rs : relayStatuses) {
final String[] relayStatus = rs.split(PlatformKeys.SEPARATOR_COMMA);
final int index = Integer.parseInt(relayStatus[0]);
final boolean lastSwitchingEventState = Boolean.parseBoolean(relayStatus[1]);
final Date lastSwitchingEventTime = getDateTime2(relayStatus[2], DateTime.now()).toDate();
final RelayStatus currentRelayStatus = ssld.getRelayStatusByIndex(index);
if (currentRelayStatus == null) {
this.relayStatusRepository.save(new RelayStatus.Builder(ssld, index).withLastSwitchingEventState(lastSwitchingEventState, lastSwitchingEventTime).build());
} else {
currentRelayStatus.updateLastSwitchingEventState(lastSwitchingEventState, lastSwitchingEventTime);
this.relayStatusRepository.save(currentRelayStatus);
}
}
}
use of org.opensmartgridplatform.domain.core.entities.Ssld in project open-smart-grid-platform by OSGP.
the class DeviceConfigurationSteps method aDeviceOutputSetting.
@Given("^a device configuration$")
public void aDeviceOutputSetting(final Map<String, String> settings) throws Throwable {
final String deviceIdentification = getString(settings, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformDefaults.DEFAULT_DEVICE_IDENTIFICATION);
final Ssld device = this.ssldRepository.findByDeviceIdentification(deviceIdentification);
final List<DeviceOutputSetting> outputSettings = new ArrayList<>();
final DeviceOutputSetting deviceOutputSetting = new DeviceOutputSetting(getInteger(settings, PlatformKeys.KEY_INTERNALID, PlatformDefaults.DEFAULT_DEVICE_OUTPUT_SETTING_INTERNALID), getInteger(settings, PlatformKeys.KEY_EXTERNALID, PlatformDefaults.DEFAULT_DEVICE_OUTPUT_SETTING_EXTERNALID), getEnum(settings, PlatformKeys.KEY_RELAY_TYPE, RelayType.class, PlatformDefaults.DEFAULT_DEVICE_OUTPUT_SETTING_RELAY_TYPE), getString(settings, PlatformKeys.ALIAS, PlatformDefaults.DEFAULT_DEVICE_OUTPUT_SETTING_ALIAS));
outputSettings.add(deviceOutputSetting);
device.updateOutputSettings(outputSettings);
this.ssldRepository.save(device);
}
use of org.opensmartgridplatform.domain.core.entities.Ssld in project open-smart-grid-platform by OSGP.
the class DeviceConfigurationSteps method deviceOutputSettingsForLightValues.
@Given("^device configuration for lightvalues$")
public void deviceOutputSettingsForLightValues(final Map<String, String> settings) throws Throwable {
final String deviceIdentification = getString(settings, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformDefaults.DEFAULT_DEVICE_IDENTIFICATION);
final Ssld device = this.ssldRepository.findByDeviceIdentification(deviceIdentification);
final String[] lightValues = getString(settings, PlatformKeys.KEY_LIGHTVALUES, PlatformDefaults.DEFAULT_DEVICE_IDENTIFICATION).split(PlatformKeys.SEPARATOR_SEMICOLON);
final String[] deviceOutputSettings = getString(settings, PlatformKeys.DEVICE_OUTPUT_SETTINGS, "").split(PlatformKeys.SEPARATOR_SEMICOLON);
final List<DeviceOutputSetting> outputSettings = new ArrayList<>();
for (int i = 0; i < lightValues.length; i++) {
final String[] lightValueParts = lightValues[i].split(PlatformKeys.SEPARATOR_COMMA);
final String[] deviceOutputSettingsPart = deviceOutputSettings[i].split(PlatformKeys.SEPARATOR_COMMA);
final DeviceOutputSetting deviceOutputSettingsForLightValue = new DeviceOutputSetting(Integer.parseInt(deviceOutputSettingsPart[0]), Integer.parseInt(lightValueParts[0]), Enum.valueOf(RelayType.class, deviceOutputSettingsPart[1]), deviceOutputSettingsPart[2]);
outputSettings.add(deviceOutputSettingsForLightValue);
}
device.updateOutputSettings(outputSettings);
this.ssldRepository.save(device);
}
use of org.opensmartgridplatform.domain.core.entities.Ssld in project open-smart-grid-platform by OSGP.
the class FirmwareFileSteps method anInstalledFirmwareFileForAnSsld.
@Given("^an installed firmware file for an ssld$")
@Transactional("txMgrCore")
public void anInstalledFirmwareFileForAnSsld(final Map<String, String> settings) {
final Ssld ssld = this.ssldRepository.findByDeviceIdentification(getString(settings, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformDefaults.DEFAULT_DEVICE_IDENTIFICATION));
final FirmwareFile firmware = this.firmwareFileRepository.findByIdentification(getString(settings, PlatformKeys.FIRMWARE_FILE_FILENAME, PlatformDefaults.FIRMWARE_FILENAME));
final Date installationDate = new Date();
final String installedByUser = "installed by test code";
final DeviceFirmwareFile deviceFirmwareFile = new DeviceFirmwareFile(ssld, firmware, installationDate, installedByUser);
this.deviceFirmwareFileRepository.save(deviceFirmwareFile);
}
Aggregations