Search in sources :

Example 1 with DlmsObject

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject 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 DlmsObject

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

the class DlmsObjectConfigService method getDlmsObjectForCommunicationMethod.

public DlmsObject getDlmsObjectForCommunicationMethod(final DlmsDevice device, final DlmsObjectType type) throws ProtocolAdapterException {
    final Protocol protocol = Protocol.forDevice(device);
    final CommunicationMethod method = CommunicationMethod.getCommunicationMethod(device.getCommunicationMethod());
    return this.dlmsObjectConfigs.stream().filter(config -> config.contains(protocol)).findAny().flatMap(dlmsObjectConfig -> dlmsObjectConfig.findObjectForCommunicationMethod(type, method)).orElseThrow(() -> new ProtocolAdapterException("Did not find " + type.name() + " object with communication method " + method.getMethodName() + " for device " + device.getDeviceId()));
}
Also used : CommunicationMethod(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.CommunicationMethod) DlmsProfile(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsProfile) Arrays(java.util.Arrays) DlmsHelper(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.utils.DlmsHelper) DateTime(org.joda.time.DateTime) DataObject(org.openmuc.jdlms.datatypes.DataObject) Autowired(org.springframework.beans.factory.annotation.Autowired) DlmsObject(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject) ArrayList(java.util.ArrayList) AttributeAddress(org.openmuc.jdlms.AttributeAddress) List(java.util.List) DlmsRegister(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsRegister) ObisCode(org.openmuc.jdlms.ObisCode) CommunicationMethod(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.CommunicationMethod) Medium(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.Medium) SelectiveAccessDescription(org.openmuc.jdlms.SelectiveAccessDescription) Service(org.springframework.stereotype.Service) Optional(java.util.Optional) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) DlmsDevice(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.DlmsDevice) Protocol(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.Protocol) ProtocolAdapterException(org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException) Protocol(org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.Protocol)

Example 3 with DlmsObject

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject 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 4 with DlmsObject

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

the class DlmsObjectConfigService method getAttributeAddressForProfile.

private AttributeAddressForProfile getAttributeAddressForProfile(final AddressRequest addressRequest) {
    final List<DlmsCaptureObject> selectedObjects = new ArrayList<>();
    final SelectiveAccessDescription access = this.getAccessDescription(addressRequest, selectedObjects);
    final DlmsObject dlmsObject = addressRequest.getDlmsObject();
    final ObisCode obisCode = this.replaceChannel(dlmsObject.getObisCodeAsString(), addressRequest.getChannel());
    return new AttributeAddressForProfile(new AttributeAddress(dlmsObject.getClassId(), obisCode, dlmsObject.getDefaultAttributeId(), access), selectedObjects);
}
Also used : SelectiveAccessDescription(org.openmuc.jdlms.SelectiveAccessDescription) ArrayList(java.util.ArrayList) AttributeAddress(org.openmuc.jdlms.AttributeAddress) ObisCode(org.openmuc.jdlms.ObisCode) DlmsObject(org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject)

Example 5 with DlmsObject

use of org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject 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)

Aggregations

DlmsObject (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsObject)23 DataObject (org.openmuc.jdlms.datatypes.DataObject)11 DlmsProfile (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsProfile)10 ArrayList (java.util.ArrayList)7 AttributeAddress (org.openmuc.jdlms.AttributeAddress)7 GetResult (org.openmuc.jdlms.GetResult)7 Test (org.junit.jupiter.api.Test)6 ObisCode (org.openmuc.jdlms.ObisCode)6 SelectiveAccessDescription (org.openmuc.jdlms.SelectiveAccessDescription)5 DateTime (org.joda.time.DateTime)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 Protocol (org.opensmartgridplatform.adapter.protocol.dlms.domain.entities.Protocol)4 ProtocolAdapterException (org.opensmartgridplatform.adapter.protocol.dlms.exceptions.ProtocolAdapterException)4 DlmsObjectType (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.DlmsObjectType)3 DlmsExtendedRegister (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsExtendedRegister)3 DlmsRegister (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.DlmsRegister)3 Medium (org.opensmartgridplatform.adapter.protocol.dlms.domain.commands.dlmsobjectconfig.model.Medium)3 CosemDateTimeDto (org.opensmartgridplatform.dto.valueobjects.smartmetering.CosemDateTimeDto)3 Date (java.util.Date)2