use of org.openmuc.j60870.ie.InformationObject in project open-smart-grid-platform by OSGP.
the class SinglePointWithQualityAsduHandlerTest method createAsdu.
private ASdu createAsdu() {
final InformationObject ioLmd1 = this.createInformationObject(LMD_1_IOA, LMD_1_ON);
final InformationObject ioLmd2 = this.createInformationObject(LMD_2_IOA, LMD_2_ON);
return AsduBuilder.ofType(ASduType.M_SP_NA_1).withCauseOfTransmission(CauseOfTransmission.INTERROGATED_BY_STATION).withInformationObjects(ioLmd1, ioLmd2).build();
}
use of org.openmuc.j60870.ie.InformationObject in project open-smart-grid-platform by OSGP.
the class Iec60870InformationObjectConverterTest method testConvertInformationObjectToMeasurementGroupDto.
@Test
public void testConvertInformationObjectToMeasurementGroupDto() {
// Arrange
final MeasurementGroupDto expected = MEASUREMENT_GROUP_DTO;
final InformationObject source = INFORMATION_OBJECT;
// Act
final MeasurementGroupDto actual = this.mapper.map(source, MeasurementGroupDto.class);
// Assert
assertThat(actual).isEqualTo(expected);
}
use of org.openmuc.j60870.ie.InformationObject in project open-smart-grid-platform by OSGP.
the class LightMeasurementDeviceAsduFactory method createLightMeasurementEvent.
public ASdu createLightMeasurementEvent() {
final long timestamp = System.currentTimeMillis();
final InformationObject[] informationObjects = new InformationObject[1];
final int index = new Random().nextInt(this.ioa.length);
this.switchValue(index);
final String eventValue = this.iev[index] ? "DARK" : "LIGHT";
LOGGER.info("Creating Light Measurement event for IOA {} with value {} ({})", this.ioa[index], this.iev[index], eventValue);
informationObjects[0] = new InformationObject(this.ioa[index], this.createInformationElementWithTimetag(this.iev[index], timestamp));
return new Iec60870AsduBuilder().withAsduType(ASduType.M_SP_TB_1).withSequenceOfElements(false).withCauseOfTransmission(CauseOfTransmission.SPONTANEOUS).withInformationObjects(informationObjects).build();
}
use of org.openmuc.j60870.ie.InformationObject in project open-smart-grid-platform by OSGP.
the class LightMeasurementDeviceAsduFactoryTest method shouldCreateInterrogationCommandResponse.
@Test
void shouldCreateInterrogationCommandResponse() {
// Arrange
this.iec60870AsduFactory.initialize();
final InformationObject[] expectedInformationObjects = new InformationObject[4];
expectedInformationObjects[0] = new InformationObject(42, this.createInformationElement(false));
expectedInformationObjects[1] = new InformationObject(78, this.createInformationElement(false));
expectedInformationObjects[2] = new InformationObject(127, this.createInformationElement(true));
expectedInformationObjects[3] = new InformationObject(95, this.createInformationElement(false));
final ASdu expected = new ASdu(ASduType.M_SP_NA_1, false, CauseOfTransmission.INTERROGATED_BY_STATION, false, false, 0, 1, expectedInformationObjects);
// Act
final ASdu actual = this.iec60870AsduFactory.createInterrogationCommandResponseAsdu();
// Assert
assertThat(actual).usingRecursiveComparison().isEqualTo(expected);
}
use of org.openmuc.j60870.ie.InformationObject in project open-smart-grid-platform by OSGP.
the class DefaultControlledStationAsduFactory method createShortFloatingPointMeasurementAsdu.
public ASdu createShortFloatingPointMeasurementAsdu() {
final ZonedDateTime now = ZonedDateTime.now(ZoneOffset.UTC);
final long timestamp = now.toInstant().toEpochMilli();
final float hour = now.getHour();
final float minute = now.getMinute();
final InformationObject[] informationObjects = new InformationObject[this.ioa.length];
for (int index = 0; index < this.ioa.length; index++) {
final float value = (index == 0 ? hour : minute);
informationObjects[index] = new InformationObject(this.ioa[index], this.createInformationElementWithTimetag(value, timestamp));
}
return new Iec60870AsduBuilder().withAsduType(ASduType.M_ME_TF_1).withSequenceOfElements(false).withCauseOfTransmission(CauseOfTransmission.SPONTANEOUS).withInformationObjects(informationObjects).build();
}
Aggregations