use of org.openmuc.jdlms.AttributeAddress in project open-smart-grid-platform by OSGP.
the class CosemObjectAccessor method writeAttribute.
public void writeAttribute(final AttributeClass attributeClass, final DataObject data) throws ProtocolAdapterException {
final AttributeAddress attributeAddress = this.createAttributeAddress(attributeClass);
final SetParameter setParameter = new SetParameter(attributeAddress, data);
final AccessResultCode accessResultCode;
try {
accessResultCode = this.connector.getConnection().set(setParameter);
} catch (final IOException e) {
throw new ProtocolAdapterException(String.format(EXCEPTION_MSG_WRITING_ATTRIBUTE, attributeClass, this.classId, this.obisCode), e);
}
if (accessResultCode != AccessResultCode.SUCCESS) {
throw new ProtocolAdapterException(String.format(EXCEPTION_MSG_ACCESS_RESULT_NOT_SUCCESS, accessResultCode.name(), attributeClass, this.classId, this.obisCode));
}
}
use of org.openmuc.jdlms.AttributeAddress in project open-smart-grid-platform by OSGP.
the class DlmsHelper method getWithList.
public List<GetResult> getWithList(final DlmsConnectionManager conn, final DlmsDevice device, final AttributeAddress... params) throws ProtocolAdapterException {
try {
if (device.isWithListSupported()) {
// Getting a too large list of attribute addresses in one get
// from the DlmsConnection
// might result in a SCOPE_OF_ACCESS_VIOLATED error
final List<GetResult> getResults = new ArrayList<>();
final List<AttributeAddress[]> maximizedSubsetsOfParams = this.getMaximizedSubsetsOfParams(params);
for (final AttributeAddress[] maximizedSubsetOfParams : maximizedSubsetsOfParams) {
getResults.addAll(conn.getConnection().get(Arrays.asList(maximizedSubsetOfParams)));
}
return getResults;
} else {
return this.getWithListWorkaround(conn, params);
}
} catch (final IOException | NullPointerException e) {
// JDlmsException).
throw new ConnectionException("Connection error retrieving values with-list for device: " + device.getDeviceIdentification(), e);
} catch (final Exception e) {
throw new ProtocolAdapterException("Error retrieving values with-list for device: " + device.getDeviceIdentification() + ", with-list: " + (device.isWithListSupported() ? "supported" : "not supported"), e);
}
}
Aggregations