Search in sources :

Example 1 with Device

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.Device in project open-smart-grid-platform by OSGP.

the class DeviceMappingTest method createDevice.

/**
 * Method to create an instance of Device.
 */
private Device createDevice() {
    final Device device = new Device();
    device.setDeviceIdentification(DEVICE_IDENTIFICATION);
    device.setDeviceType(DEVICE_TYPE);
    device.setCommunicationMethod(COMMUNICATION_METHOD);
    device.setCommunicationProvider(COMMUNICATION_PROVIDER);
    device.setIccId(ICC_ID);
    device.setProtocolName(PROTOCOL_NAME);
    device.setProtocolVersion(PROTOCOL_VERSION);
    device.setSupplier(SUPPLIER);
    device.setHls3Active(IS_ACTIVE);
    device.setHls4Active(IS_ACTIVE);
    device.setHls5Active(IS_ACTIVE);
    device.setMasterKey(KEY);
    device.setGlobalEncryptionUnicastKey(KEY);
    device.setAuthenticationKey(KEY);
    device.setDeliveryDate(this.deliveryDateDevice);
    return device;
}
Also used : SmartMeteringDevice(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice) Device(org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.Device)

Example 2 with Device

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.Device in project open-smart-grid-platform by OSGP.

the class DeviceMappingTest method testSmartMeteringDeviceMapping.

/**
 * Test to see if a SmartMeteringDevice can be mapped to a Device
 */
@Test
public void testSmartMeteringDeviceMapping() {
    // build test data
    final SmartMeteringDevice smartMeteringDevice = this.createSmartMeteringDevice();
    // actual mapping
    final Device device = this.installationMapper.map(smartMeteringDevice, Device.class);
    // check mapping
    this.checkSmartMeteringDeviceToDeviceMapping(device);
}
Also used : SmartMeteringDevice(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice) Device(org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.Device) SmartMeteringDevice(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice) Test(org.junit.jupiter.api.Test)

Example 3 with Device

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.Device in project open-smart-grid-platform by OSGP.

the class DeviceMappingTest method testDeviceMapping.

/**
 * Test to see if a Device object can be mapped to a SmartMeteringDevice object
 */
@Test
public void testDeviceMapping() {
    // build test data
    final Device device = this.createDevice();
    // actual mapping
    final SmartMeteringDevice smartMeteringDevice = this.installationMapper.map(device, SmartMeteringDevice.class);
    // check mapping
    this.checkDeviceToSmartMeteringDeviceMapping(smartMeteringDevice);
}
Also used : SmartMeteringDevice(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice) Device(org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.Device) SmartMeteringDevice(org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice) Test(org.junit.jupiter.api.Test)

Example 4 with Device

use of org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.Device in project open-smart-grid-platform by OSGP.

the class DeviceFactory method fromParameterMap.

public static Device fromParameterMap(final Map<String, String> requestParameters) {
    Map<String, String> settings = SettingsHelper.addDefault(requestParameters, PlatformKeys.KEY_DEVICE_DELIVERY_DATE, PlatformDefaults.DLMS_DEFAULT_DEVICE_DELIVERY_DATE);
    settings = SettingsHelper.addDefault(settings, PlatformKeys.KEY_DEVICE_PROTOCOL_NAME, PlatformDefaults.DEFAULT_DEVICE_PROTOCOL_NAME);
    final Device device = new Device();
    device.setDeviceIdentification(getString(settings, PlatformKeys.KEY_DEVICE_IDENTIFICATION, PlatformDefaults.DEFAULT_DEVICE_IDENTIFICATION));
    device.setDeviceType(getString(settings, PlatformKeys.KEY_DEVICE_TYPE, PlatformDefaults.DEFAULT_DEVICE_TYPE));
    device.setCommunicationMethod(settings.get(PlatformKeys.KEY_DEVICE_COMMUNICATIONMETHOD));
    device.setCommunicationProvider(settings.get(PlatformKeys.KEY_DEVICE_COMMUNICATIONPROVIDER));
    device.setIccId(settings.get(PlatformKeys.KEY_DEVICE_ICCID));
    device.setProtocolName(settings.get(PlatformKeys.KEY_DEVICE_PROTOCOL_NAME));
    device.setProtocolVersion(settings.get(PlatformKeys.KEY_DEVICE_PROTOCOL_VERSION));
    device.setSupplier(settings.get(PlatformKeys.KEY_DEVICE_SUPPLIER));
    device.setHls3Active(getBoolean(settings, PlatformKeys.KEY_DEVICE_HLS3ACTIVE, PlatformDefaults.DLMS_DEFAULT_HSL3_ACTIVE));
    device.setHls4Active(getBoolean(settings, PlatformKeys.KEY_DEVICE_HLS4ACTIVE, PlatformDefaults.DLMS_DEFAULT_HSL4_ACTIVE));
    device.setHls5Active(getBoolean(settings, PlatformKeys.KEY_DEVICE_HLS5ACTIVE, PlatformDefaults.DLMS_DEFAULT_HSL5_ACTIVE));
    device.setMasterKey(RequestFactoryHelper.hexDecodeDeviceKey(getHexDecodeDeviceKey(settings, PlatformKeys.KEY_DEVICE_MASTERKEY), PlatformKeys.KEY_DEVICE_MASTERKEY));
    device.setAuthenticationKey(RequestFactoryHelper.hexDecodeDeviceKey(getHexDecodeDeviceKey(settings, PlatformKeys.KEY_DEVICE_AUTHENTICATIONKEY), PlatformKeys.KEY_DEVICE_AUTHENTICATIONKEY));
    device.setGlobalEncryptionUnicastKey(RequestFactoryHelper.hexDecodeDeviceKey(getHexDecodeDeviceKey(settings, PlatformKeys.KEY_DEVICE_ENCRYPTIONKEY), PlatformKeys.KEY_DEVICE_ENCRYPTIONKEY));
    device.setDeliveryDate(SettingsHelper.getXmlGregorianCalendarValue(settings, PlatformKeys.KEY_DEVICE_DELIVERY_DATE));
    device.setMbusIdentificationNumber(getString(settings, PlatformSmartmeteringKeys.MBUS_IDENTIFICATION_NUMBER));
    device.setMbusManufacturerIdentification(getString(settings, PlatformSmartmeteringKeys.MBUS_MANUFACTURER_IDENTIFICATION));
    device.setMbusVersion(getShort(settings, PlatformSmartmeteringKeys.MBUS_VERSION, null));
    device.setMbusDeviceTypeIdentification(getShort(settings, PlatformSmartmeteringKeys.MBUS_DEVICE_TYPE_IDENTIFICATION, null));
    device.setMbusDefaultKey(RequestFactoryHelper.hexDecodeDeviceKey(getHexDecodeDeviceKey(settings, PlatformSmartmeteringKeys.MBUS_DEFAULT_KEY), PlatformSmartmeteringKeys.MBUS_DEFAULT_KEY));
    return device;
}
Also used : Device(org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.Device) ReadSettingsHelper.getString(org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)

Aggregations

Device (org.opensmartgridplatform.adapter.ws.schema.smartmetering.installation.Device)4 SmartMeteringDevice (org.opensmartgridplatform.domain.core.valueobjects.smartmetering.SmartMeteringDevice)3 Test (org.junit.jupiter.api.Test)2 ReadSettingsHelper.getString (org.opensmartgridplatform.cucumber.core.ReadSettingsHelper.getString)1