Search in sources :

Example 1 with DlmsProfile

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsProfile in project open-smart-grid-platform by OSGP.

the class DlmsObjectConfigService method getAccessDescription.

private SelectiveAccessDescription getAccessDescription(final AddressRequest addressRequest, final List<DlmsCaptureObject> selectedObjects) {
    final DlmsObject object = addressRequest.getDlmsObject();
    final DateTime from = addressRequest.getFrom();
    final DateTime to = addressRequest.getTo();
    if (!(object instanceof DlmsProfile) || from == null || to == null) {
        return null;
    } else {
        final int accessSelector = 1;
        final DataObject selectedValues = this.getSelectedValues(addressRequest, selectedObjects);
        final DataObject accessParameter = this.dlmsHelper.getAccessSelectionTimeRangeParameter(from, to, selectedValues);
        return new SelectiveAccessDescription(accessSelector, accessParameter);
    }
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) SelectiveAccessDescription(org.openmuc.jdlms.SelectiveAccessDescription) DlmsProfile(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsProfile) DlmsObject(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject) DateTime(org.joda.time.DateTime)

Example 2 with DlmsProfile

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsProfile in project open-smart-grid-platform by OSGP.

the class DlmsObjectConfigService method getSelectedValues.

private DataObject getSelectedValues(final AddressRequest addressRequest, final List<DlmsCaptureObject> selectedObjects) {
    List<DataObject> objectDefinitions = new ArrayList<>();
    final DlmsObject object = addressRequest.getDlmsObject();
    final Protocol protocol = Protocol.forDevice(addressRequest.getDevice());
    if (object instanceof DlmsProfile && ((DlmsProfile) object).getCaptureObjects() != null) {
        final DlmsProfile profile = (DlmsProfile) object;
        objectDefinitions = this.getObjectDefinitions(addressRequest.getChannel(), addressRequest.getFilterMedium(), protocol, profile, selectedObjects);
    }
    return DataObject.newArrayData(objectDefinitions);
}
Also used : DataObject(org.openmuc.jdlms.datatypes.DataObject) DlmsProfile(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsProfile) ArrayList(java.util.ArrayList) Protocol(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.Protocol) DlmsObject(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject)

Example 3 with DlmsProfile

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsProfile in project open-smart-grid-platform by OSGP.

the class DlmsObjectConfigSmr50 method initObjects.

@Override
List<DlmsObject> initObjects() {
    final List<DlmsObject> objectList = new ArrayList<>();
    // Abstract objects
    final DlmsObject clock = new DlmsClock("0.0.1.0.0.255");
    final DlmsObject amrStatusIntervalE = new DlmsData(AMR_STATUS, "0.0.96.10.2.255");
    final DlmsObject amrStatusIntervalG = new DlmsData(AMR_STATUS, "0.<c>.96.10.3.255");
    final DlmsObject amrStatusDailyE = new DlmsData(AMR_STATUS, "0.0.96.10.4.255");
    final DlmsObject amrStatusDailyG = new DlmsData(AMR_STATUS, "0.<c>.96.10.5.255");
    final DlmsObject amrStatusMonthlyE = new DlmsData(AMR_STATUS, "0.0.96.10.6.255");
    final DlmsObject amrStatusMonthlyG = new DlmsData(AMR_STATUS, "0.<c>.96.10.7.255");
    final DlmsObject alarmFilter1 = new DlmsData(ALARM_FILTER_1, "0.0.97.98.10.255");
    final DlmsObject alarmRegister1 = new DlmsData(ALARM_REGISTER_1, "0.0.97.98.0.255");
    final DlmsObject randomisationSettings = new DlmsData(RANDOMISATION_SETTINGS, "0.1.94.31.12.255");
    objectList.addAll(Arrays.asList(clock, amrStatusIntervalE, amrStatusIntervalG, amrStatusDailyE, amrStatusDailyG, amrStatusMonthlyE, amrStatusMonthlyG, alarmFilter1, alarmRegister1, randomisationSettings));
    final DlmsObject pushScheduler = new DlmsSingleActionSchedule(PUSH_SCHEDULER, "0.0.15.0.4.255");
    final DlmsObject pushSetupScheduler = new DlmsPushSetup(PUSH_SETUP_SCHEDULER, "0.0.25.9.0.255");
    final DlmsObject externalTriggerSmsOrCsd = new DlmsAutoAnswer(EXTERNAL_TRIGGER, "0.0.2.2.0.255");
    final DlmsObject internalTriggerAlarm = new DlmsRegisterMonitor(INTERNAL_TRIGGER_ALARM, "0.0.16.1.0.255");
    final DlmsObject pushSetupAlarm = new DlmsPushSetup(PUSH_SETUP_ALARM, "0.1.25.9.0.255");
    objectList.addAll(Arrays.asList(pushScheduler, pushSetupScheduler, externalTriggerSmsOrCsd, internalTriggerAlarm, pushSetupAlarm));
    final DlmsObject standardEventLogCode = new DlmsData(STANDARD_EVENT_CODE, "0.0.96.11.0.255");
    final DlmsObject fraudDetectionEventLogCode = new DlmsData(FRAUD_DETECTION_EVENT_CODE, "0.0.96.11.1.255");
    final DlmsObject mbusEventLogCode = new DlmsData(MBUS_EVENT_CODE, "0.0.96.11.3.255");
    final DlmsObject communicationSessionsEventLogCode = new DlmsData(COMMUNICATION_SESSIONS_EVENT_CODE, "0.0.96.11.4.255");
    final DlmsObject powerQualityEventLogCode = new DlmsData(POWER_QUALITY_EVENT_CODE, "0.0.96.11.5.255");
    objectList.addAll(Arrays.asList(standardEventLogCode, fraudDetectionEventLogCode, mbusEventLogCode, communicationSessionsEventLogCode, powerQualityEventLogCode));
    // Electricity objects
    final DlmsObject activeEnergyImport = new DlmsRegister(ACTIVE_ENERGY_IMPORT, "1.0.1.8.0.255", 0, WH, ELECTRICITY);
    final DlmsObject activeEnergyExport = new DlmsRegister(ACTIVE_ENERGY_EXPORT, "1.0.2.8.0.255", 0, WH, ELECTRICITY);
    final DlmsObject activeEnergyImportRate1 = new DlmsRegister(ACTIVE_ENERGY_IMPORT_RATE_1, "1.0.1.8.1.255", 0, WH, ELECTRICITY);
    final DlmsObject activeEnergyImportRate2 = new DlmsRegister(ACTIVE_ENERGY_IMPORT_RATE_2, "1.0.1.8.2.255", 0, WH, ELECTRICITY);
    final DlmsObject activeEnergyExportRate1 = new DlmsRegister(ACTIVE_ENERGY_EXPORT_RATE_1, "1.0.2.8.1.255", 0, WH, ELECTRICITY);
    final DlmsObject activeEnergyExportRate2 = new DlmsRegister(ACTIVE_ENERGY_EXPORT_RATE_2, "1.0.2.8.2.255", 0, WH, ELECTRICITY);
    objectList.addAll(Arrays.asList(activeEnergyImport, activeEnergyExport, activeEnergyImportRate1, activeEnergyImportRate2, activeEnergyExportRate1, activeEnergyExportRate2));
    // Gas objects
    final DlmsObject mbusMasterValue = new DlmsExtendedRegister(MBUS_MASTER_VALUE, "0.<c>.24.2.2.255", 0, M3, GAS);
    final DlmsObject mbusClientSetup = new DlmsMbusClientSetup(MBUS_CLIENT_SETUP, "0.<c>.24.1.0.255", VERSION_1);
    objectList.addAll(Arrays.asList(mbusMasterValue, mbusClientSetup));
    final List<DlmsCaptureObject> captureObjectsIntervalE = Arrays.asList(DlmsCaptureObject.create(clock), DlmsCaptureObject.create(amrStatusIntervalE), DlmsCaptureObject.create(activeEnergyImport), DlmsCaptureObject.create(activeEnergyExport));
    objectList.add(new DlmsProfile(INTERVAL_VALUES, "1.0.99.1.0.255", captureObjectsIntervalE, QUARTER_HOUR, ELECTRICITY));
    final List<DlmsCaptureObject> captureObjectsIntervalG = Arrays.asList(DlmsCaptureObject.create(clock), DlmsCaptureObject.create(amrStatusIntervalG), DlmsCaptureObject.create(mbusMasterValue), DlmsCaptureObject.create(mbusMasterValue, 5));
    objectList.add(new DlmsProfile(INTERVAL_VALUES, "0.<c>.24.3.0.255", captureObjectsIntervalG, HOUR, GAS));
    final List<DlmsCaptureObject> captureObjectsDailyE = Arrays.asList(DlmsCaptureObject.create(clock), DlmsCaptureObject.create(amrStatusDailyE), DlmsCaptureObject.create(activeEnergyImportRate1), DlmsCaptureObject.create(activeEnergyImportRate2), DlmsCaptureObject.create(activeEnergyExportRate1), DlmsCaptureObject.create(activeEnergyExportRate2));
    objectList.add(new DlmsProfile(DAILY_LOAD_PROFILE, "1.0.99.2.0.255", captureObjectsDailyE, DAY, ELECTRICITY));
    final List<DlmsCaptureObject> captureObjectsDailyG = Arrays.asList(DlmsCaptureObject.create(clock), DlmsCaptureObject.create(amrStatusDailyG), DlmsCaptureObject.create(mbusMasterValue), DlmsCaptureObject.create(mbusMasterValue, 5));
    objectList.add(new DlmsProfile(DAILY_LOAD_PROFILE, "0.<c>.24.3.1.255", captureObjectsDailyG, DAY, GAS));
    final List<DlmsCaptureObject> captureObjectsMonthly = Arrays.asList(DlmsCaptureObject.create(clock), DlmsCaptureObject.create(amrStatusMonthlyE), DlmsCaptureObject.create(activeEnergyImportRate1), DlmsCaptureObject.create(activeEnergyImportRate2), DlmsCaptureObject.create(activeEnergyExportRate1), DlmsCaptureObject.create(activeEnergyExportRate2));
    objectList.add(new DlmsProfile(MONTHLY_BILLING_VALUES, "1.0.98.1.0.255", captureObjectsMonthly, MONTH, ELECTRICITY));
    final List<DlmsCaptureObject> captureObjectsMonthlyG = Arrays.asList(DlmsCaptureObject.create(clock), DlmsCaptureObject.create(amrStatusMonthlyG), DlmsCaptureObject.create(mbusMasterValue), DlmsCaptureObject.create(mbusMasterValue, 5));
    objectList.add(new DlmsProfile(MONTHLY_BILLING_VALUES, "0.<c>.24.3.2.255", captureObjectsMonthlyG, MONTH, GAS));
    // Event logs
    final List<DlmsCaptureObject> captureObjectsStandardEvents = Arrays.asList(DlmsCaptureObject.create(clock), DlmsCaptureObject.create(standardEventLogCode));
    objectList.add(new DlmsProfile(STANDARD_EVENT_LOG, "0.0.99.98.0.255", captureObjectsStandardEvents, ASYNCHRONOUSLY, ABSTRACT));
    final List<DlmsCaptureObject> captureObjectsFraudDetectionEvents = Arrays.asList(DlmsCaptureObject.create(clock), DlmsCaptureObject.create(fraudDetectionEventLogCode));
    objectList.add(new DlmsProfile(FRAUD_DETECTION_EVENT_LOG, "0.0.99.98.1.255", captureObjectsFraudDetectionEvents, ASYNCHRONOUSLY, ABSTRACT));
    final List<DlmsCaptureObject> captureObjectsMBusEvents = Arrays.asList(DlmsCaptureObject.create(clock), DlmsCaptureObject.create(mbusEventLogCode));
    objectList.add(new DlmsProfile(MBUS_EVENT_LOG, "0.0.99.98.3.255", captureObjectsMBusEvents, ASYNCHRONOUSLY, ABSTRACT));
    final List<DlmsCaptureObject> captureObjectsCommunicationSessionsEvents = Arrays.asList(DlmsCaptureObject.create(clock), DlmsCaptureObject.create(communicationSessionsEventLogCode));
    objectList.add(new DlmsProfile(COMMUNICATION_SESSIONS_EVENT_LOG, "0.0.99.98.4.255", captureObjectsCommunicationSessionsEvents, ASYNCHRONOUSLY, ABSTRACT));
    final List<DlmsCaptureObject> captureObjectsPowerQualityEvents = Arrays.asList(DlmsCaptureObject.create(clock), DlmsCaptureObject.create(powerQualityEventLogCode));
    objectList.add(new DlmsProfile(POWER_QUALITY_EVENT_LOG, "0.0.99.98.5.255", captureObjectsPowerQualityEvents, ASYNCHRONOUSLY, ABSTRACT));
    // Additional read mbus status for SMR5.0
    final DlmsObject readMBusStatus = new DlmsObject(READ_MBUS_STATUS, InterfaceClass.EXTENDED_REGISTER.id(), "0.<c>.24.2.6.255");
    final DlmsObject clientSetupMBus = new DlmsObject(CLIENT_SETUP_MBUS, InterfaceClass.MBUS_CLIENT.id(), "0.<c>.24.1.0.255");
    objectList.addAll(Arrays.asList(readMBusStatus, clientSetupMBus));
    return objectList;
}
Also used : DlmsSingleActionSchedule(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsSingleActionSchedule) ArrayList(java.util.ArrayList) DlmsMbusClientSetup(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsMbusClientSetup) DlmsClock(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsClock) DlmsRegister(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsRegister) DlmsExtendedRegister(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsExtendedRegister) DlmsProfile(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsProfile) DlmsPushSetup(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsPushSetup) DlmsAutoAnswer(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsAutoAnswer) DlmsObject(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject) DlmsData(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsData) DlmsRegisterMonitor(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsRegisterMonitor)

Example 4 with DlmsProfile

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsProfile in project open-smart-grid-platform by OSGP.

the class GetPeriodicMeterReadsCommandExecutorTest method testHappy.

@Test
void testHappy() throws Exception {
    // SETUP
    final PeriodTypeDto periodType = PeriodTypeDto.DAILY;
    final PeriodicMeterReadsRequestDto request = new PeriodicMeterReadsRequestDto(periodType, new Date(this.from), new Date(this.to));
    // SETUP - dlms objects
    final DlmsObject dlmsClock = new DlmsClock("0.0.1.0.0.255");
    final DlmsCaptureObject captureObject1 = new DlmsCaptureObject(dlmsClock, 2);
    final DlmsObject activeEnergyImportRate1 = new DlmsObject(DlmsObjectType.ACTIVE_ENERGY_IMPORT_RATE_1, 0, "1.0.1.8.1.255");
    final DlmsCaptureObject captureObject2 = new DlmsCaptureObject(activeEnergyImportRate1, 2);
    final DlmsObject activeEnergyImportRate2 = new DlmsObject(DlmsObjectType.ACTIVE_ENERGY_IMPORT_RATE_2, 0, "1.0.1.8.2.255");
    final DlmsCaptureObject captureObject3 = new DlmsCaptureObject(activeEnergyImportRate2, 2);
    final DlmsObject activeEnergyExportRate1 = new DlmsObject(DlmsObjectType.ACTIVE_ENERGY_EXPORT_RATE_1, 0, "1.0.2.8.1.255");
    final DlmsCaptureObject captureObject4 = new DlmsCaptureObject(activeEnergyExportRate1, 2);
    final DlmsObject activeEnergyExportRate2 = new DlmsObject(DlmsObjectType.ACTIVE_ENERGY_EXPORT_RATE_2, 0, "1.0.2.8.2.255");
    final DlmsCaptureObject captureObject5 = new DlmsCaptureObject(activeEnergyExportRate2, 2);
    final List<DlmsCaptureObject> captureObjects = Arrays.asList(captureObject1, captureObject2, captureObject3, captureObject4, captureObject5);
    final DlmsProfile dlmsProfile = new DlmsProfile(DlmsObjectType.DAILY_LOAD_PROFILE, "1.0.99.2.0.255", captureObjects, ProfileCaptureTime.DAY, Medium.ELECTRICITY);
    // SETUP - mock dlms object config to return attribute addresses
    final AttributeAddressForProfile attributeAddressForProfile = this.createAttributeAddressForProfile(dlmsProfile, captureObjects);
    final AttributeAddress attributeAddress = this.createAttributeAddress(dlmsProfile);
    when(this.dlmsObjectConfigService.findAttributeAddressForProfile(this.device, DlmsObjectType.DAILY_LOAD_PROFILE, 0, this.fromDateTime, this.toDateTime, Medium.ELECTRICITY)).thenReturn(Optional.of(attributeAddressForProfile));
    final DlmsObject intervalTime = mock(DlmsObject.class);
    when(this.dlmsObjectConfigService.findDlmsObject(any(Protocol.class), any(DlmsObjectType.class), any(Medium.class))).thenReturn(Optional.of(intervalTime));
    // SETUP - mock dlms helper to return data objects on request
    final DataObject data0 = mock(DataObject.class);
    // make sure to set logTime on first dataObject
    final List<DataObject> bufferedObjectValue = new ArrayList<>();
    when(data0.getValue()).thenReturn(bufferedObjectValue);
    final DataObject data1 = mock(DataObject.class);
    when(data1.isNumber()).thenReturn(true);
    final DataObject data2 = mock(DataObject.class);
    final DataObject data3 = mock(DataObject.class);
    final DataObject data4 = mock(DataObject.class);
    final DataObject data5 = mock(DataObject.class);
    final DataObject bufferedObject1 = mock(DataObject.class);
    when(bufferedObject1.getValue()).thenReturn(asList(data0, data1, data2, data3, data4, data5));
    final DataObject bufferedObject2 = mock(DataObject.class);
    when(bufferedObject2.getValue()).thenReturn(asList(data0, data1, data2, data3, data4, data5));
    final DataObject resultData = mock(DataObject.class);
    when(resultData.getValue()).thenReturn(Arrays.asList(bufferedObject1, bufferedObject2));
    final String expectedDescription = "retrieve periodic meter reads for " + periodType;
    final GetResult result0 = mock(GetResult.class);
    final GetResult result1 = mock(GetResult.class);
    final GetResult result2 = mock(GetResult.class);
    final GetResult result3 = mock(GetResult.class);
    final GetResult result4 = mock(GetResult.class);
    final GetResult result5 = mock(GetResult.class);
    final GetResult getResult = mock(GetResult.class);
    when(this.dlmsHelper.getAndCheck(this.connectionManager, this.device, expectedDescription, attributeAddress)).thenReturn(asList(result0, result1, result2, result3, result4, result5));
    when(this.dlmsHelper.readDataObject(result0, PERIODIC_E_METER_READS)).thenReturn(resultData);
    when(this.dlmsHelper.getAndCheck(this.connectionManager, this.device, expectedDescription, attributeAddressForProfile.getAttributeAddress())).thenReturn(Collections.singletonList(getResult));
    when(this.dlmsHelper.getAndCheck(this.connectionManager, this.device, expectedDescription, attributeAddress)).thenReturn(Collections.singletonList(getResult));
    when(this.dlmsHelper.readDataObject(eq(getResult), any(String.class))).thenReturn(resultData);
    final CosemDateTimeDto cosemDateTime = mock(CosemDateTimeDto.class);
    final String expectedDateTimeDescription = String.format("Clock from %s buffer", periodType);
    when(this.dlmsHelper.readDateTime(data0, expectedDateTimeDescription)).thenReturn(cosemDateTime);
    final DateTime bufferedDateTime = DateTime.now();
    when(cosemDateTime.asDateTime()).thenReturn(bufferedDateTime);
    // CALL
    final PeriodicMeterReadsResponseDto result = this.executor.execute(this.connectionManager, this.device, request, this.messageMetadata);
    // VERIFY calls to mocks
    verify(this.dlmsMessageListener).setDescription(String.format("GetPeriodicMeterReads DAILY from %s until %s, retrieve attribute: {%s,%s,%s}", new DateTime(this.from), new DateTime(this.to), dlmsProfile.getClassId(), dlmsProfile.getObisCode(), dlmsProfile.getDefaultAttributeId()));
    verify(this.dlmsHelper, times(2)).validateBufferedDateTime(same(bufferedDateTime), argThat(new DateTimeMatcher(this.from)), argThat(new DateTimeMatcher(this.to)));
    verify(this.dlmsObjectConfigService).findDlmsObject(any(Protocol.class), any(DlmsObjectType.class), any(Medium.class));
    // ASSERT - the result should contain 2 values
    final List<PeriodicMeterReadsResponseItemDto> periodicMeterReads = result.getPeriodicMeterReads();
    assertThat(periodicMeterReads.size()).isEqualTo(2);
    periodicMeterReads.forEach(p -> assertThat(p.getLogTime()).isNotNull());
}
Also used : AttributeAddressForProfile(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.AttributeAddressForProfile) PeriodicMeterReadsResponseItemDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodicMeterReadsResponseItemDto) PeriodTypeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodTypeDto) GetResult(org.openmuc.jdlms.GetResult) AttributeAddress(org.openmuc.jdlms.AttributeAddress) ArrayList(java.util.ArrayList) PeriodicMeterReadsResponseDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodicMeterReadsResponseDto) Date(java.util.Date) DateTime(org.joda.time.DateTime) CosemDateTimeDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateTimeDto) DlmsClock(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsClock) DataObject(org.openmuc.jdlms.datatypes.DataObject) Medium(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.Medium) DlmsProfile(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsProfile) DlmsCaptureObject(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsCaptureObject) Protocol(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.Protocol) PeriodicMeterReadsRequestDto(org.opensmartgridplatform.dto.valueobjects.smartmetering.PeriodicMeterReadsRequestDto) DlmsObject(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject) DlmsObjectType(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectType) Test(org.junit.jupiter.api.Test)

Example 5 with DlmsProfile

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsProfile in project open-smart-grid-platform by OSGP.

the class AbstractPeriodicMeterReadsCommandExecutor method getProfileCaptureTime.

/**
 * Get the interval time for given device and medium.
 *
 * @param device the device for which the interval should be determined
 * @param dlmsObjectConfigService service which holds the configuration for this device
 * @param medium the type of device
 * @return the derived ProfileCaptureTime for this device, or null if it cannot be determined
 */
Optional<ProfileCaptureTime> getProfileCaptureTime(final DlmsDevice device, final DlmsObjectConfigService dlmsObjectConfigService, final Medium medium) {
    final DlmsObject dlmsObject = dlmsObjectConfigService.findDlmsObject(Protocol.forDevice(device), DlmsObjectType.INTERVAL_VALUES, medium).orElse(null);
    if (dlmsObject instanceof DlmsProfile) {
        final DlmsProfile profile = (DlmsProfile) dlmsObject;
        this.getLogger().info("Capture time of this device is {} ", profile.getCaptureTime());
        return Optional.of(profile.getCaptureTime());
    }
    return Optional.empty();
}
Also used : DlmsProfile(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsProfile) DlmsObject(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject)

Aggregations

DlmsObject (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject)9 DlmsProfile (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsProfile)9 ArrayList (java.util.ArrayList)4 DataObject (org.openmuc.jdlms.datatypes.DataObject)4 DlmsClock (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsClock)4 DlmsData (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsData)4 DateTime (org.joda.time.DateTime)3 DlmsExtendedRegister (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsExtendedRegister)3 Protocol (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.Protocol)3 Test (org.junit.jupiter.api.Test)2 AttributeAddress (org.openmuc.jdlms.AttributeAddress)2 GetResult (org.openmuc.jdlms.GetResult)2 AttributeAddressForProfile (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.AttributeAddressForProfile)2 DlmsCaptureObject (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsCaptureObject)2 DlmsObjectType (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectType)2 DlmsAutoAnswer (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsAutoAnswer)2 DlmsMbusClientSetup (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsMbusClientSetup)2 DlmsPushSetup (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsPushSetup)2 DlmsRegister (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsRegister)2 DlmsRegisterMonitor (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsRegisterMonitor)2