use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class AbstractCommandExecutor method getValidatedResultData.
/**
* Retrieves connection, gets result data and validates it before returning.
*
* @param conn holds connection
* @param getParameter for attribute to retrieve result data from
* @return dataObject
*/
public DataObject getValidatedResultData(final DlmsConnectionManager conn, final AttributeAddress getParameter) throws ProtocolAdapterException {
final GetResult getResult;
try {
getResult = conn.getConnection().get(getParameter);
} catch (final IOException e) {
throw new ConnectionException(e);
}
if (getResult == null) {
throw new ProtocolAdapterException("No GetResult received while retrieving M-Bus encryption key status.");
}
final DataObject dataObject = getResult.getResultData();
if (!dataObject.isNumber()) {
throw new ProtocolAdapterException("Received unexpected result data.");
}
return dataObject;
}
use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class ClearAlarmRegisterCommandExecutor method executeForAlarmRegister.
public AccessResultCode executeForAlarmRegister(final DlmsConnectionManager conn, final AttributeAddress alarmRegisterAttributeAddress) {
log.info("Clear alarm register {}", JdlmsObjectToStringUtil.describeAttributes(alarmRegisterAttributeAddress));
final DataObject data = DataObject.newUInteger32Data(ALARM_CODE);
final SetParameter setParameter = new SetParameter(alarmRegisterAttributeAddress, data);
conn.getDlmsMessageListener().setDescription("ClearAlarmRegister, with alarm code = " + ALARM_CODE + JdlmsObjectToStringUtil.describeAttributes(alarmRegisterAttributeAddress));
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 GetConfigurationObjectServiceDsmr4 method getConfigurationObject.
private ConfigurationObjectDto getConfigurationObject(final List<DataObject> elements) throws ProtocolAdapterException {
final Optional<GprsOperationModeTypeDto> gprsMode = this.getGprsOperationMode(elements.get(INDEX_OF_GPRS_OPERATION_MODE));
final ConfigurationFlagsDto flags = this.getConfigurationFlags(elements.get(INDEX_OF_CONFIGURATION_FLAGS));
return gprsMode.map(c -> new ConfigurationObjectDto(c, flags)).orElseGet(() -> new ConfigurationObjectDto(flags));
}
use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class SetConfigurationObjectService method setConfigurationObject.
public AccessResultCode setConfigurationObject(final DlmsConnectionManager conn, final ConfigurationObjectDto configurationToSet, final ConfigurationObjectDto configurationOnDevice) throws ProtocolAdapterException {
final DataObject dataObject = this.buildSetParameterData(configurationToSet, configurationOnDevice);
LOGGER.info("ConfigurationObject SetParameter Data : {}", this.dlmsHelper.getDebugInfo(dataObject));
final AttributeAddress attributeAddress = AttributeAddressFactory.getConfigurationObjectAddress();
final SetParameter setParameter = new SetParameter(attributeAddress, dataObject);
conn.getDlmsMessageListener().setDescription("SetConfigurationObject AttributeAddress: " + JdlmsObjectToStringUtil.describeAttributes(attributeAddress));
return this.getAccessResultCode(conn, setParameter);
}
use of org.openmuc.jdlms.datatypes.DataObject in project open-smart-grid-platform by OSGP.
the class SetActivityCalendarCommandExecutor method getWeekProfileTableExecutor.
private DataObjectAttrExecutor getWeekProfileTableExecutor(final Set<WeekProfileDto> weekProfileSet) {
final AttributeAddress weekProfileTablePassive = new AttributeAddress(CLASS_ID, OBIS_CODE, ATTRIBUTE_ID_WEEK_PROFILE_TABLE_PASSIVE);
final DataObject weekArray = DataObject.newArrayData(this.configurationMapper.mapAsList(weekProfileSet, DataObject.class));
LOGGER.info("WeekProfileTablePassive to set is: {}", this.dlmsHelper.getDebugInfo(weekArray));
return new DataObjectAttrExecutor("WEEKS", weekProfileTablePassive, weekArray, CLASS_ID, OBIS_CODE, ATTRIBUTE_ID_WEEK_PROFILE_TABLE_PASSIVE);
}
Aggregations