use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class GetPeriodicMeterReadsGasCommandExecutorIntegrationTest method setResponsesForScalerUnit.
private void setResponsesForScalerUnit(final List<AttributeAddress> attributeAddressesForScalerUnit) {
final int DLMS_ENUM_VALUE_M3 = 14;
final DataObject responseDataObject = DataObject.newStructureData(DataObject.newInteger8Data((byte) 0), DataObject.newEnumerateData(DLMS_ENUM_VALUE_M3));
for (final AttributeAddress attributeAddress : attributeAddressesForScalerUnit) {
this.connectionStub.addReturnValue(attributeAddress, responseDataObject);
}
}
use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class GetPeriodicMeterReadsGasCommandExecutorIntegrationTest method setResponseForProfile.
private void setResponseForProfile(final AttributeAddress attributeAddressForProfile, final Protocol protocol, final PeriodTypeDto type, final boolean useNullData) {
// PERIOD 1
final DataObject period1Clock = this.PERIOD_1_CLOCK;
final DataObject period1Status = DataObject.newUInteger8Data(this.PERIOD1_AMR_STATUS_VALUE);
final DataObject period1Value = DataObject.newUInteger32Data(this.PERIOD_1_LONG_VALUE);
final DataObject period1CaptureTime = DataObject.newDateTimeData(this.PERIOD_1_CAPTURE_TIME);
final DataObject periodItem1;
if (type == PeriodTypeDto.MONTHLY && protocol == Protocol.DSMR_4_2_2) {
periodItem1 = DataObject.newStructureData(Arrays.asList(period1Clock, period1Value, period1CaptureTime));
} else {
periodItem1 = DataObject.newStructureData(Arrays.asList(period1Clock, period1Status, period1Value, period1CaptureTime));
}
// PERIOD 2
final DataObject period2Clock;
final DataObject period2CaptureTime;
if (useNullData) {
period2Clock = DataObject.newNullData();
period2CaptureTime = DataObject.newNullData();
} else {
period2Clock = this.PERIOD_2_CLOCK;
period2CaptureTime = DataObject.newDateTimeData(this.PERIOD_2_CAPTURE_TIME);
}
final DataObject period2Status = DataObject.newUInteger8Data(this.PERIOD2_AMR_STATUS_VALUE);
final DataObject period2Value = DataObject.newUInteger32Data(this.PERIOD_2_LONG_VALUE);
final DataObject periodItem2;
if (type == PeriodTypeDto.MONTHLY && protocol == Protocol.DSMR_4_2_2) {
// No status for Monthly values in DSMR4.2.2
periodItem2 = DataObject.newStructureData(Arrays.asList(period2Clock, period2Value, period2CaptureTime));
} else {
periodItem2 = DataObject.newStructureData(Arrays.asList(period2Clock, period2Status, period2Value, period2CaptureTime));
}
// Create returnvalue and set in stub
final DataObject responseDataObject = DataObject.newArrayData(Arrays.asList(periodItem1, periodItem2));
this.connectionStub.addReturnValue(attributeAddressForProfile, responseDataObject);
}
use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class GetPeriodicMeterReadsGasCommandExecutorIntegrationTest method createSelectiveAccessDescriptionSmr5.
private SelectiveAccessDescription createSelectiveAccessDescriptionSmr5(final DataObject from, final DataObject to) {
final DataObject selectedValues = DataObject.newArrayData(Collections.emptyList());
final DataObject expectedAccessParam = DataObject.newStructureData(Arrays.asList(this.CLOCK, from, to, selectedValues));
return new SelectiveAccessDescription(1, expectedAccessParam);
}
use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class DlmsObjectConfigServiceTest method testProfileWithOneMedium.
@Test
void testProfileWithOneMedium() {
// SETUP
final Integer channel = null;
final Medium filterMedium = Medium.ELECTRICITY;
final DataObject selectedValues = DataObject.newArrayData(Collections.emptyList());
final DataObject accessParams = this.getAccessParams(selectedValues);
final SelectiveAccessDescription access = new SelectiveAccessDescription(1, accessParams);
final AttributeAddress expectedAddress = new AttributeAddress(this.profileE.getClassId(), this.profileE.getObisCodeAsString(), this.profileE.getDefaultAttributeId(), access);
// CALL
final Optional<AttributeAddressForProfile> attributeAddressForProfile = this.service.findAttributeAddressForProfile(this.device422, DlmsObjectType.INTERVAL_VALUES, channel, this.from, this.to, filterMedium);
// VERIFY
assertThat(attributeAddressForProfile).isPresent();
AttributeAddressAssert.is(attributeAddressForProfile.get().getAttributeAddress(), expectedAddress);
assertThat(attributeAddressForProfile.get().getSelectedObjects()).isEqualTo(this.captureObjectsE);
}
use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class DlmsObjectConfigServiceTest method testProfileWithMediumCombinedAndNoFilterMedium.
@Test
void testProfileWithMediumCombinedAndNoFilterMedium() {
// SETUP
final Integer channel = 1;
final Medium filterMedium = null;
final DataObject selectedValues = DataObject.newArrayData(Collections.emptyList());
final DataObject accessParams = this.getAccessParams(selectedValues);
final SelectiveAccessDescription access = new SelectiveAccessDescription(1, accessParams);
final AttributeAddress expectedAddress = new AttributeAddress(this.profileCombined.getClassId(), this.profileCombined.getObisCodeAsString(), this.profileCombined.getDefaultAttributeId(), access);
// CALL
final Optional<AttributeAddressForProfile> attributeAddressForProfile = this.service.findAttributeAddressForProfile(this.device422, DlmsObjectType.DAILY_LOAD_PROFILE, channel, this.from, this.to, filterMedium);
// VERIFY
assertThat(attributeAddressForProfile).isPresent();
AttributeAddressAssert.is(attributeAddressForProfile.get().getAttributeAddress(), expectedAddress);
assertThat(attributeAddressForProfile.get().getSelectedObjects()).isEqualTo(this.captureObjectsCombined);
}
Aggregations