use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class FindEventsCommandExecutorTest method generateDataObjectsExtendedPowerQuality.
private List<DataObject> generateDataObjectsExtendedPowerQuality() {
final List<DataObject> dataObjects = new ArrayList<>();
IntStream.rangeClosed(93, 98).forEach(code -> {
final DataObject eventCode = DataObject.newInteger16Data((short) code);
final DataObject eventTime = DataObject.newDateTimeData(new CosemDateTime(2018, 12, 31, 23, code - 60, 0, 0));
final DataObject magnitude = DataObject.newInteger32Data(5);
final DataObject duration = DataObject.newInteger32Data(6);
final DataObject struct = DataObject.newStructureData(eventTime, eventCode, magnitude, duration);
dataObjects.add(struct);
});
return dataObjects;
}
use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class FindEventsCommandExecutorTest method generateDataObjects.
private List<DataObject> generateDataObjects() {
final List<DataObject> dataObjects = new ArrayList<>();
IntStream.rangeClosed(77, 89).forEach(code -> {
final DataObject eventCode = DataObject.newInteger16Data((short) code);
final DataObject eventTime = DataObject.newDateTimeData(new CosemDateTime(2018, 12, 31, 23, code - 60, 0, 0));
final DataObject struct = DataObject.newStructureData(eventTime, eventCode);
dataObjects.add(struct);
});
return dataObjects;
}
use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class FindEventsCommandExecutorTest method before.
@BeforeEach
public void before() throws ProtocolAdapterException, IOException {
final DataObject fromDate = mock(DataObject.class);
final DataObject toDate = mock(DataObject.class);
this.messageMetadata = MessageMetadata.newBuilder().withCorrelationUid("123456").build();
this.findEventsRequestDto = new FindEventsRequestDto(EventLogCategoryDto.POWER_QUALITY_EVENT_LOG, DateTime.now().minusDays(70), DateTime.now());
final DataObjectToEventListConverter dataObjectToEventListConverter = new DataObjectToEventListConverter(this.dlmsHelper);
final DlmsObjectConfigService dlmsObjectConfigService = new DlmsObjectConfigService(this.dlmsHelper, new DlmsObjectConfigConfiguration().getDlmsObjectConfigs());
this.executor = new FindEventsCommandExecutor(this.dlmsHelper, dataObjectToEventListConverter, dlmsObjectConfigService);
when(this.dlmsHelper.asDataObject(this.findEventsRequestDto.getFrom())).thenReturn(fromDate);
when(this.dlmsHelper.asDataObject(this.findEventsRequestDto.getUntil())).thenReturn(toDate);
when(this.dlmsHelper.convertDataObjectToDateTime(any(DataObject.class))).thenReturn(new CosemDateTimeDto());
when(this.conn.getDlmsMessageListener()).thenReturn(this.dlmsMessageListener);
when(this.conn.getConnection()).thenReturn(this.dlmsConnection);
when(this.dlmsConnection.get(any(AttributeAddress.class))).thenReturn(this.getResult);
}
use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class SetConfigurationObjectServiceDsmr4Test method buildSetParameterDataGprsModeOnDevice.
@Test
public void buildSetParameterDataGprsModeOnDevice() throws ProtocolAdapterException {
// SETUP
when(this.configurationToSet.getGprsOperationMode()).thenReturn(null);
when(this.configurationOnDevice.getGprsOperationMode()).thenReturn(GPRS_OPERATION_MODE);
// CALL
final DataObject result = this.instance.buildSetParameterData(this.configurationToSet, this.configurationOnDevice);
// VERIFY
final List<DataObject> elements = result.getValue();
final int value = elements.get(0).getValue();
assertThat(value).isEqualTo(GPRS_OPERATION_MODE.getNumber());
}
use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class SetActivityCalendarCommandExecutorTest method verifySetParameterWeekProfiles.
private void verifySetParameterWeekProfiles(final SetParameter setParameter, final List<String> weekNames, final List<Short> dayIds) {
final AttributeAddress attributeAddress = setParameter.getAttributeAddress();
assertThat(attributeAddress.getClassId()).isEqualTo(CLASS_ID);
assertThat(attributeAddress.getInstanceId()).isEqualTo(OBIS_CODE);
assertThat(attributeAddress.getId()).isEqualTo(ATTRIBUTE_ID_WEEK_PROFILE_TABLE_PASSIVE);
final DataObject dataObject = setParameter.getData();
assertThat(dataObject.getType()).isEqualTo(Type.ARRAY);
final List<DataObject> weeks = dataObject.getValue();
this.verifyWeeks(weeks, weekNames, dayIds);
}
Aggregations