use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class GetPeriodicMeterReadsGasCommandExecutorIntegrationTest method createAttributeAddress.
private AttributeAddress createAttributeAddress(final Protocol protocol, final PeriodTypeDto type, final Date timeFrom, final Date timeTo) throws Exception {
final DataObject from = this.dlmsHelper.asDataObject(new DateTime(timeFrom));
final DataObject to = this.dlmsHelper.asDataObject(new DateTime(timeTo));
if (protocol == Protocol.DSMR_4_2_2) {
if (type == PeriodTypeDto.DAILY) {
return this.createAttributeAddressDsmr4Daily(from, to);
} else if (type == PeriodTypeDto.MONTHLY) {
return this.createAttributeAddressDsmr4Monthly(from, to);
} else if (type == PeriodTypeDto.INTERVAL) {
return this.createAttributeAddressDsmr4Interval(from, to);
}
} else if (protocol == Protocol.SMR_5_0_0 || protocol == Protocol.SMR_5_1) {
if (type == PeriodTypeDto.DAILY) {
return this.createAttributeAddressSmr5Daily(from, to);
} else if (type == PeriodTypeDto.MONTHLY) {
return this.createAttributeAddressSmr5Monthly(from, to);
} else if (type == PeriodTypeDto.INTERVAL) {
return this.createAttributeAddressSmr5Interval(from, to);
}
}
throw new Exception("Invalid combination of protocol " + protocol.getName() + " and version " + protocol.getVersion());
}
use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class GetPeriodicMeterReadsGasCommandExecutorIntegrationTest method createSelectiveAccessDescriptionDsmr4Interval.
private SelectiveAccessDescription createSelectiveAccessDescriptionDsmr4Interval(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 SetPushSetupAlarmCommandExecutorTest method verifyPushObjectListParameter.
private void verifyPushObjectListParameter(final SetParameter setParameter) {
final AttributeAddress attributeAddress = setParameter.getAttributeAddress();
assertThat(attributeAddress.getClassId()).isEqualTo(CLASS_ID);
assertThat(attributeAddress.getInstanceId()).isEqualTo(OBIS_CODE);
assertThat(attributeAddress.getId()).isEqualTo(ATTRIBUTE_ID_PUSH_OBJECT_LIST);
final DataObject dataObject = setParameter.getData();
assertThat(dataObject.getType()).isEqualTo(Type.ARRAY);
final List<DataObject> values = dataObject.getValue();
assertThat(values).hasSize(PUSH_OBJECT_LIST.size());
this.verifyPushObject(values.get(0), PUSH_OBJECT_1_CLASS_ID, PUSH_OBJECT_1_OBIS_CODE.toByteArray(), (byte) PUSH_OBJECT_1_ATTRIBUTE_ID, PUSH_OBJECT_1_DATA_INDEX);
this.verifyPushObject(values.get(1), PUSH_OBJECT_2_CLASS_ID, PUSH_OBJECT_2_OBIS_CODE.toByteArray(), (byte) PUSH_OBJECT_2_ATTRIBUTE_ID, PUSH_OBJECT_2_DATA_INDEX);
}
use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class AttributeAddressAssert method assertThatArrayIs.
private static void assertThatArrayIs(final DataObject actual, final DataObject expected) {
final List<DataObject> actualList = actual.getValue();
final List<DataObject> expectedList = expected.getValue();
assertThat(actualList.size()).isEqualTo(expectedList.size());
int index = 0;
for (final DataObject actualObject : actualList) {
assertThatDataObjectIs(actualObject, expectedList.get(index));
index++;
}
}
use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class DlmsHelperTest method testDateTimeWinterTimeWithDeviationAndDstFromOtherTimeZone.
@Test
public void testDateTimeWinterTimeWithDeviationAndDstFromOtherTimeZone() {
/*
* The date and time on the device should be set according to the
* deviation and daylight savings information provided as parameters.
* The time of the server can be given in another time zone than the
* device is in, but the instant in time should remain the same.
*
* This test has a time input as if a server in the New York time zone
* would be synchronizing time on a device in the Amsterdam time zone.
*/
final DataObject dateInWinterTimeDataObject = this.dlmsHelper.asDataObject(this.dateTimeWinterTimeNewYork(), -60, false);
assertThat(dateInWinterTimeDataObject.isCosemDateFormat()).isTrue();
assertThat(dateInWinterTimeDataObject.getValue() instanceof CosemDateTime).isTrue();
final CosemDateTime cosemDateTime = dateInWinterTimeDataObject.getValue();
assertThat(cosemDateTime.encode()).isEqualTo(this.byteArrayWinterTime());
}
Aggregations