use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class GetGsmDiagnosticCommandExecutor method getCellInfo.
private CellInfoDto getCellInfo(final List<GetResult> getResultList) {
final GetResult result = getResultList.get(RESULT_CELL_INFO_INDEX);
if (result.getResultCode() != AccessResultCode.SUCCESS) {
return null;
}
final List<DataObject> cellInfoDataObjects = result.getResultData().getValue();
if (cellInfoDataObjects != null) {
return new CellInfoDto(cellInfoDataObjects.get(CELL_INFO_CELL_ID_INDEX).getValue(), cellInfoDataObjects.get(CELL_INFO_LOCATION_ID_INDEX).getValue(), SignalQualityDto.fromIndexValue((short) cellInfoDataObjects.get(CELL_INFO_SIGNAL_QUALITY_INDEX).getValue()), BitErrorRateDto.fromIndexValue((short) cellInfoDataObjects.get(CELL_INFO_BIT_ERROR_RATE_INDEX).getValue()), cellInfoDataObjects.get(CELL_INFO_MOBILE_COUNTRY_CODE_INDEX).getValue(), cellInfoDataObjects.get(CELL_INFO_MOBILE_NETWORK_CODE_INDEX).getValue(), cellInfoDataObjects.get(CELL_INFO_CHANNEL_NUMBER_INDEX).getValue());
} else {
return null;
}
}
use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class GetGsmDiagnosticCommandExecutor method getAdjacentCells.
private List<AdjacentCellInfoDto> getAdjacentCells(final List<GetResult> getResultList) {
final GetResult result = getResultList.get(RESULT_ADJACENT_CELLS_INDEX);
if (result.getResultCode() != AccessResultCode.SUCCESS) {
return Collections.emptyList();
}
final List<DataObject> adjacentCellsDataObjects = result.getResultData().getValue();
if (adjacentCellsDataObjects == null) {
return Collections.emptyList();
} else {
return adjacentCellsDataObjects.stream().map(cellInfo -> {
final List<DataObject> adjacentCell = cellInfo.getValue();
return new AdjacentCellInfoDto(adjacentCell.get(ADJACENT_CELLS_CELL_ID_INDEX).getValue(), SignalQualityDto.fromIndexValue((short) adjacentCell.get(ADJACENT_CELLS_SIGNAL_QUALITY_INDEX).getValue()));
}).collect(Collectors.toList());
}
}
use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class GetOutagesCommandExecutor method execute.
@Override
public List<OutageDto> execute(final DlmsConnectionManager conn, final DlmsDevice device, final GetOutagesRequestDto getOutagesRequestDto, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
final AttributeAddress eventLogBuffer = new AttributeAddress(CLASS_ID, new ObisCode(OBIS_CODE), ATTRIBUTE_ID);
conn.getDlmsMessageListener().setDescription("RetrieveOutages, retrieve attribute: " + JdlmsObjectToStringUtil.describeAttributes(eventLogBuffer));
final GetResult getResult;
try {
getResult = conn.getConnection().get(eventLogBuffer);
} catch (final IOException e) {
throw new ConnectionException(e);
}
if (getResult == null) {
throw new ProtocolAdapterException("No GetResult received while retrieving event register POWER_FAILURE_EVENT_LOG");
}
if (!AccessResultCode.SUCCESS.equals(getResult.getResultCode())) {
log.info("Result of getting events for POWER_FAILURE_EVENT_LOG is {}", getResult.getResultCode());
throw new ProtocolAdapterException("Getting the outages from POWER_FAILURE_EVENT_LOG from the meter resulted in: " + getResult.getResultCode());
}
final DataObject resultData = getResult.getResultData();
return this.dataObjectToOutageListConverter.convert(resultData);
}
use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class SetAdministrativeStatusCommandExecutor method execute.
@Override
public AccessResultCode execute(final DlmsConnectionManager conn, final DlmsDevice device, final AdministrativeStatusTypeDto administrativeStatusType, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
LOGGER.info("Set administrative status by issuing get request for class id: {}, obis code: {}, attribute id: {}", CLASS_ID, OBIS_CODE, ATTRIBUTE_ID);
final AttributeAddress attributeAddress = new AttributeAddress(CLASS_ID, OBIS_CODE, ATTRIBUTE_ID);
final DataObject value = DataObject.newEnumerateData(this.configurationMapper.map(administrativeStatusType, Integer.class));
final SetParameter setParameter = new SetParameter(attributeAddress, value);
conn.getDlmsMessageListener().setDescription("SetAdminstrativeStatus to " + administrativeStatusType + ", set attribute: " + JdlmsObjectToStringUtil.describeAttributes(attributeAddress));
try {
return conn.getConnection().set(setParameter);
} catch (final IOException e) {
throw new ConnectionException(e);
}
}
use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class AbstractGetPowerQualityProfileHandler method createScalerUnitInfo.
private ScalerUnitInfo createScalerUnitInfo(final DlmsConnectionManager conn, final DlmsDevice device, final CaptureObjectDefinitionDto captureObjectDefinitionDto) throws ProtocolAdapterException {
final int classId = captureObjectDefinitionDto.getClassId();
final String logicalName = captureObjectDefinitionDto.getLogicalName().toString();
if (this.hasScalerUnit(classId)) {
final AttributeAddress addr = new AttributeAddress(classId, logicalName, SCALER_UNITS_MAP.get(classId));
final List<GetResult> scalerUnitResult = this.dlmsHelper.getAndCheck(conn, device, "retrieve scaler unit for capture object", addr);
final DataObject scalerUnitDataObject = scalerUnitResult.get(0).getResultData();
return new ScalerUnitInfo(logicalName, classId, scalerUnitDataObject);
} else {
return new ScalerUnitInfo(logicalName, classId, null);
}
}
Aggregations