use of org.opensmartgridplatform.simulator.protocol.iec60870.domain.Iec60870AsduBuilder 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.opensmartgridplatform.simulator.protocol.iec60870.domain.Iec60870AsduBuilder 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