use of org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleData in project open-smart-grid-platform by OSGP.
the class DeviceFirmwareModuleSteps method getFirmwareModuleVersions.
public Map<FirmwareModule, String> getFirmwareModuleVersions(final Map<String, String> settings, final boolean isForSmartMeters) {
final String comm;
if (isForSmartMeters && settings.containsKey(FirmwareModuleData.MODULE_DESCRIPTION_COMM)) {
comm = getNullOrNonEmptyString(settings, FirmwareModuleData.MODULE_DESCRIPTION_COMM, null);
} else {
comm = getNullOrNonEmptyString(settings, PlatformKeys.FIRMWARE_MODULE_VERSION_COMM, null);
}
final String func;
if (isForSmartMeters && settings.containsKey(FirmwareModuleData.MODULE_DESCRIPTION_FUNC_SMART_METERING)) {
func = getNullOrNonEmptyString(settings, FirmwareModuleData.MODULE_DESCRIPTION_FUNC_SMART_METERING, null);
} else {
func = getNullOrNonEmptyString(settings, PlatformKeys.FIRMWARE_MODULE_VERSION_FUNC, null);
}
final String ma;
if (isForSmartMeters && settings.containsKey(FirmwareModuleData.MODULE_DESCRIPTION_MA)) {
ma = getNullOrNonEmptyString(settings, FirmwareModuleData.MODULE_DESCRIPTION_MA, null);
} else {
ma = getNullOrNonEmptyString(settings, PlatformKeys.FIRMWARE_MODULE_VERSION_MA, null);
}
final String mbus = getNullOrNonEmptyString(settings, PlatformKeys.FIRMWARE_MODULE_VERSION_MBUS, null);
final String sec = getNullOrNonEmptyString(settings, PlatformKeys.FIRMWARE_MODULE_VERSION_SEC, null);
final String mBusDriverActive = getNullOrNonEmptyString(settings, PlatformKeys.FIRMWARE_MODULE_VERSION_M_BUS_DRIVER_ACTIVE, null);
final String simpleVersionInfo = getNullOrNonEmptyString(settings, PlatformKeys.SIMPLE_VERSION_INFO, null);
final FirmwareModuleData firmwareModuleData = new FirmwareModuleData(comm, func, ma, mbus, sec, mBusDriverActive, simpleVersionInfo);
return firmwareModuleData.getVersionsByModule(this.firmwareModuleRepository, isForSmartMeters);
}
use of org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleData in project open-smart-grid-platform by OSGP.
the class ScheduledTaskSteps method createUpdateFirmwareScheduledTask.
private static ScheduledTask createUpdateFirmwareScheduledTask(final Map<String, String> settings) {
final String deviceIdentification = ReadSettingsHelper.getString(settings, KEY_DEVICE_IDENTIFICATION, DEFAULT_DEVICE_IDENTIFICATION);
final String organisationIdentification = ReadSettingsHelper.getString(settings, KEY_ORGANIZATION_IDENTIFICATION, DEFAULT_ORGANIZATION_IDENTIFICATION);
final String correlationUid = ReadSettingsHelper.getString(settings, KEY_CORRELATION_UID, DEFAULT_CORRELATION_UID);
final String messageType = MessageType.UPDATE_FIRMWARE.toString();
final int messagePriority = 4;
final Long scheduleTime = DateTimeHelper.getDateTime(ReadSettingsHelper.getString(settings, KEY_SCHEDULED_TIME, DEFAULT_SCHEDULED_TIME)).getMillis();
final MessageMetadata messageMetadata = new MessageMetadata.Builder().withDeviceIdentification(deviceIdentification).withOrganisationIdentification(organisationIdentification).withCorrelationUid(correlationUid).withMessageType(messageType).withMessagePriority(messagePriority).withScheduleTime(scheduleTime).build();
final FirmwareModuleData firmwareModuleData = new FirmwareModuleData(null, "FW-01", null, null, null, null, null);
final String firmwareUrl = "firmware-url";
final Serializable messageData = new FirmwareUpdateMessageDataContainer(firmwareModuleData, firmwareUrl);
return new ScheduledTask(messageMetadata, "CORE", "1.0", messageData, new Timestamp(scheduleTime));
}
use of org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleData in project open-smart-grid-platform by OSGP.
the class FirmwareManagementMapperTest method mapsFirmwareModuleData.
@Test
public void mapsFirmwareModuleData() {
final org.opensmartgridplatform.adapter.ws.schema.core.firmwaremanagement.FirmwareModuleData source = new FirmwareModuleDataBuilder().build();
final FirmwareModuleData mappedValue = this.map(source);
assertThat(this.mapper.map(source, FirmwareModuleData.class)).usingRecursiveComparison().isEqualTo(mappedValue);
}
use of org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleData in project open-smart-grid-platform by OSGP.
the class FirmwareFileBuilder method build.
public FirmwareFile build(final FirmwareModuleRepository firmwareModuleRepository, final boolean isForSmartMeters) {
final FirmwareFile.Builder firmwareFileBuilder = new FirmwareFile.Builder();
firmwareFileBuilder.withFilename(this.filename).withDescription(this.description).withPushToNewDevices(this.pushToNewDevices).withFile(this.file).withHash(this.hash);
final FirmwareFile firmwareFile = firmwareFileBuilder.build();
if (this.deviceModel != null) {
firmwareFile.addDeviceModel(this.deviceModel);
}
firmwareFile.updateFirmwareModuleData(new FirmwareModuleData(this.moduleVersionComm, this.moduleVersionFunc, this.moduleVersionMa, this.moduleVersionMbus, this.moduleVersionSec, this.moduleVersionMBusDriverActive, this.moduleVersionSimple).getVersionsByModule(firmwareModuleRepository, isForSmartMeters));
return firmwareFile;
}
use of org.opensmartgridplatform.domain.core.valueobjects.FirmwareModuleData in project open-smart-grid-platform by OSGP.
the class FirmwareManagementEndpoint method mapFirmwareModuleTypes.
private FirmwareUpdateMessageDataContainer mapFirmwareModuleTypes(final String firmwareIndentification, final List<FirmwareModuleType> firmwareModuleTypes) {
String moduleVersionComm = null;
String moduleVersionFunc = null;
String moduleVersionMa = null;
String moduleVersionMbus = null;
String moduleVersionSec = null;
String moduleVersionMBusDriverActive = null;
String moduleVersionSimple = null;
for (final FirmwareModuleType firmwareModuleType : firmwareModuleTypes) {
final String firmwareModuleTypeString = firmwareModuleType.toString();
if (FirmwareModuleType.COMMUNICATION.equals(firmwareModuleType)) {
moduleVersionComm = firmwareModuleTypeString;
} else if (FirmwareModuleType.FUNCTIONAL.equals(firmwareModuleType)) {
moduleVersionFunc = firmwareModuleTypeString;
} else if (FirmwareModuleType.MODULE_ACTIVE.equals(firmwareModuleType)) {
moduleVersionMa = firmwareModuleTypeString;
} else if (FirmwareModuleType.M_BUS.equals(firmwareModuleType)) {
moduleVersionMbus = firmwareModuleTypeString;
} else if (FirmwareModuleType.SECURITY.equals(firmwareModuleType)) {
moduleVersionSec = firmwareModuleTypeString;
} else if (FirmwareModuleType.M_BUS_DRIVER_ACTIVE.equals(firmwareModuleType)) {
moduleVersionMBusDriverActive = firmwareModuleTypeString;
} else if (FirmwareModuleType.SIMPLE_VERSION_INFO.equals(firmwareModuleType)) {
moduleVersionSimple = firmwareModuleTypeString;
}
}
final FirmwareModuleData firmwareModuleData = new FirmwareModuleData(moduleVersionComm, moduleVersionFunc, moduleVersionMa, moduleVersionMbus, moduleVersionSec, moduleVersionMBusDriverActive, moduleVersionSimple);
return new FirmwareUpdateMessageDataContainer(firmwareModuleData, firmwareIndentification);
}
Aggregations