use of org.opensmartgridplatform.oslp.Oslp.LightValue.Builder in project open-smart-grid-platform by OSGP.
the class OslpChannelHandler method createGetStatusResponse.
private Message createGetStatusResponse(final Device device) {
final List<LightValue> outputValues = new ArrayList<>();
for (final DeviceOutputSetting dos : device.getOutputSettings()) {
final Builder lightValue = this.getLightValueForDeviceOutputSetting(device, dos);
outputValues.add(lightValue.build());
}
// Fallback in case output settings are not yet defined.
if (outputValues.isEmpty()) {
final Builder lightValue = this.getDefaultLightValue(device);
outputValues.add(lightValue.build());
}
final Oslp.GetStatusResponse.Builder builder = GetStatusResponse.newBuilder();
builder.setStatus(Oslp.Status.OK);
builder.addAllValue(outputValues);
builder.setPreferredLinktype(Enum.valueOf(Oslp.LinkType.class, device.getPreferredLinkType().name()));
builder.setActualLinktype(Enum.valueOf(Oslp.LinkType.class, device.getActualLinkType().name()));
builder.setLightType(Enum.valueOf(Oslp.LightType.class, device.getLightType().name()));
builder.setEventNotificationMask(device.getEventNotificationMask());
LOGGER.info("device.getProtocol(): {}", device.getProtocol());
LOGGER.info("ProtocolType.OSLP_ELSTER.name(): {}", ProtocolType.OSLP_ELSTER);
if (device.getProtocol().equals(ProtocolType.OSLP_ELSTER.toString())) {
builder.setNumberOfOutputs(4);
builder.setDcOutputVoltageMaximum(24000);
builder.setDcOutputVoltageCurrent(24000);
builder.setMaximumOutputPowerOnDcOutput(15000);
builder.setSerialNumber(ByteString.copyFrom(new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 1, 2, 3, 4, 5, 6, 7, 8, 9 }));
builder.setMacAddress(ByteString.copyFrom(new byte[] { 1, 2, 3, 4, 5, 6 }));
builder.setHardwareId("Hardware ID").setInternalFlashMemSize(1024);
builder.setExternalFlashMemSize(2048).setLastInternalTestResultCode(0).setStartupCounter(42);
builder.setBootLoaderVersion("1.1.1").setFirmwareVersion("2.8.5");
builder.setCurrentConfigurationBackUsed(ByteString.copyFrom(new byte[] { 0 }));
builder.setName("ELS_DEV-SIM-DEVICE").setCurrentTime("20251231155959");
builder.setCurrentIp(this.statusInternalIpAddress);
}
return Oslp.Message.newBuilder().setGetStatusResponse(builder.build()).build();
}
Aggregations