Search in sources :

Example 1 with DeviceStatusMapped

use of org.opensmartgridplatform.domain.core.valueobjects.DeviceStatusMapped in project open-smart-grid-platform by OSGP.

the class DeviceInstallationServiceTest method testHandleGetStatusResponseOkLmdStatusNotNull.

@Test
public void testHandleGetStatusResponseOkLmdStatusNotNull() throws FunctionalException, ValidationException {
    final TariffValue editedTariffValue = new TariffValue();
    editedTariffValue.setHigh(true);
    editedTariffValue.setIndex(10);
    final DeviceStatusMapped deviceStatus = new DeviceStatusMapped(null, Arrays.asList(new LightValue(0, true, 50), new LightValue(MESSAGE_PRIORITY, true, 75), new LightValue(2, false, 0)), LinkType.ETHERNET, LinkType.GPRS, LightType.ONE_TO_TEN_VOLT, 0);
    when(this.domainCoreMapper.map(null, DeviceStatus.class)).thenReturn(deviceStatus);
    final Device mockedDevice = Mockito.mock(Device.class);
    when(mockedDevice.getDeviceType()).thenReturn(LightMeasurementDevice.LMD_TYPE);
    when(this.deviceDomainService.searchDevice(TEST_DEVICE)).thenReturn(mockedDevice);
    this.deviceInstallationService.handleGetStatusResponse(null, CORRELATION_IDS, TEST_MESSAGE_TYPE, MESSAGE_PRIORITY, ResponseMessageResultType.OK, null);
    verify(this.webServiceResponseMessageSender).send(this.argumentResponseMessage.capture());
    assertThat(this.argumentResponseMessage.getValue()).usingRecursiveComparison().isEqualTo(this.createNewResponseMessage(ResponseMessageResultType.OK, null, deviceStatus));
}
Also used : LightMeasurementDevice(org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice) Device(org.opensmartgridplatform.domain.core.entities.Device) DeviceStatusMapped(org.opensmartgridplatform.domain.core.valueobjects.DeviceStatusMapped) LightValue(org.opensmartgridplatform.domain.core.valueobjects.LightValue) TariffValue(org.opensmartgridplatform.domain.core.valueobjects.TariffValue) Test(org.junit.jupiter.api.Test)

Example 2 with DeviceStatusMapped

use of org.opensmartgridplatform.domain.core.valueobjects.DeviceStatusMapped in project open-smart-grid-platform by OSGP.

the class AdHocManagementService method handleLmd.

private void handleLmd(final DeviceStatus status, final GetStatusResponse response) {
    if (status != null) {
        final DeviceStatusMapped deviceStatusMapped = new DeviceStatusMapped(null, status.getLightValues(), status.getPreferredLinkType(), status.getActualLinkType(), status.getLightType(), status.getEventNotificationsMask());
        // 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_PUBLIC_LIGHTING, "Light measurement device was not able to report light sensor status", new NoDeviceResponseException()));
        response.setResult(ResponseMessageResultType.NOT_OK);
    }
}
Also used : TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) NoDeviceResponseException(org.opensmartgridplatform.shared.exceptionhandling.NoDeviceResponseException) DeviceStatusMapped(org.opensmartgridplatform.domain.core.valueobjects.DeviceStatusMapped)

Example 3 with DeviceStatusMapped

use of org.opensmartgridplatform.domain.core.valueobjects.DeviceStatusMapped in project open-smart-grid-platform by OSGP.

the class StatusMappingTest method properlyMapsDeviceStatusMapped.

@Test
void properlyMapsDeviceStatusMapped() {
    final TariffValue tv1 = new TariffValue();
    tv1.setHigh(true);
    final List<TariffValue> tariffValues = Arrays.asList(tv1);
    final Status domainStatus = new DeviceStatusMapped(tariffValues, LIGHT_VALUES, PREFERRED_LINK_TYPE, ACTUAL_LINK_TYPE, LIGHT_TYPE, EVENT_NOTIFICATIONS_MASK);
    final org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.Status wsStatus = this.adHocManagementMapper.map(domainStatus, org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.Status.class);
    final org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.DeviceStatus expected = expectedDeviceStatus();
    assertThat(wsStatus).isInstanceOf(org.opensmartgridplatform.adapter.ws.schema.publiclighting.adhocmanagement.DeviceStatus.class).usingRecursiveComparison().isEqualTo(expected);
}
Also used : Status(org.opensmartgridplatform.domain.core.valueobjects.Status) DeviceStatus(org.opensmartgridplatform.domain.core.valueobjects.DeviceStatus) LightSensorStatus(org.opensmartgridplatform.domain.core.valueobjects.LightSensorStatus) DeviceStatusMapped(org.opensmartgridplatform.domain.core.valueobjects.DeviceStatusMapped) TariffValue(org.opensmartgridplatform.domain.core.valueobjects.TariffValue) Test(org.junit.jupiter.api.Test)

Example 4 with DeviceStatusMapped

use of org.opensmartgridplatform.domain.core.valueobjects.DeviceStatusMapped 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);
    }
}
Also used : TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) NoDeviceResponseException(org.opensmartgridplatform.shared.exceptionhandling.NoDeviceResponseException) HashMap(java.util.HashMap) DeviceStatusMapped(org.opensmartgridplatform.domain.core.valueobjects.DeviceStatusMapped) DeviceOutputSetting(org.opensmartgridplatform.domain.core.entities.DeviceOutputSetting) Ssld(org.opensmartgridplatform.domain.core.entities.Ssld)

Example 5 with DeviceStatusMapped

use of org.opensmartgridplatform.domain.core.valueobjects.DeviceStatusMapped in project open-smart-grid-platform by OSGP.

the class DeviceInstallationService method handleLmd.

private void handleLmd(final DeviceStatus status, final GetStatusResponse response) {
    if (status != null) {
        final DeviceStatusMapped deviceStatusMapped = new DeviceStatusMapped(null, status.getLightValues(), status.getPreferredLinkType(), status.getActualLinkType(), status.getLightType(), status.getEventNotificationsMask());
        // 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, "Light measurement device was not able to report light sensor status", new NoDeviceResponseException()));
        response.setResult(ResponseMessageResultType.NOT_OK);
    }
}
Also used : TechnicalException(org.opensmartgridplatform.shared.exceptionhandling.TechnicalException) NoDeviceResponseException(org.opensmartgridplatform.shared.exceptionhandling.NoDeviceResponseException) DeviceStatusMapped(org.opensmartgridplatform.domain.core.valueobjects.DeviceStatusMapped)

Aggregations

DeviceStatusMapped (org.opensmartgridplatform.domain.core.valueobjects.DeviceStatusMapped)8 TechnicalException (org.opensmartgridplatform.shared.exceptionhandling.TechnicalException)6 NoDeviceResponseException (org.opensmartgridplatform.shared.exceptionhandling.NoDeviceResponseException)5 HashMap (java.util.HashMap)3 DeviceOutputSetting (org.opensmartgridplatform.domain.core.entities.DeviceOutputSetting)3 Ssld (org.opensmartgridplatform.domain.core.entities.Ssld)3 Test (org.junit.jupiter.api.Test)2 DeviceStatus (org.opensmartgridplatform.domain.core.valueobjects.DeviceStatus)2 TariffValue (org.opensmartgridplatform.domain.core.valueobjects.TariffValue)2 OsgpException (org.opensmartgridplatform.shared.exceptionhandling.OsgpException)2 ResponseMessage (org.opensmartgridplatform.shared.infra.jms.ResponseMessage)2 ConstraintViolationException (javax.validation.ConstraintViolationException)1 GetStatusResponse (org.opensmartgridplatform.adapter.ws.schema.tariffswitching.adhocmanagement.GetStatusResponse)1 Device (org.opensmartgridplatform.domain.core.entities.Device)1 LightMeasurementDevice (org.opensmartgridplatform.domain.core.entities.LightMeasurementDevice)1 ValidationException (org.opensmartgridplatform.domain.core.exceptions.ValidationException)1 LightSensorStatus (org.opensmartgridplatform.domain.core.valueobjects.LightSensorStatus)1 LightValue (org.opensmartgridplatform.domain.core.valueobjects.LightValue)1 Status (org.opensmartgridplatform.domain.core.valueobjects.Status)1 FunctionalException (org.opensmartgridplatform.shared.exceptionhandling.FunctionalException)1