use of org.openmuc.jdlms.AttributeAddress in project open-smart-grid-platform by OSGP.
the class ClearMBusStatusOnAllChannelsCommandExecutor method clearStatusMaskForChannel.
private void clearStatusMaskForChannel(final DlmsConnectionManager conn, final int channel, final DlmsDevice device) throws IOException, ProtocolAdapterException {
final AttributeAddress readMBusStatusAttributeAddress = this.dlmsObjectConfigService.getAttributeAddress(device, DlmsObjectType.READ_MBUS_STATUS, channel);
final AttributeAddress clearMBusStatusAttributeAddress = this.dlmsObjectConfigService.getAttributeAddress(device, DlmsObjectType.CLEAR_MBUS_STATUS, channel);
final AttributeAddress clientSetupMbus = this.dlmsObjectConfigService.getAttributeAddress(device, DlmsObjectType.CLIENT_SETUP_MBUS, channel);
final long statusMask = this.readStatus(conn, channel, readMBusStatusAttributeAddress);
if (statusMask == 0L) {
return;
}
final AccessResultCode resultCode = this.setClearStatusMask(statusMask, conn, channel, clearMBusStatusAttributeAddress);
if (resultCode != AccessResultCode.SUCCESS) {
throw new ProtocolAdapterException("Unable to set clear status mask for M-Bus channel " + channel + ", AccessResultCode=" + resultCode + ".");
}
final MethodResult methodResult = this.resetAlarm(conn, channel, clientSetupMbus.getInstanceId());
if (methodResult.getResultCode() != MethodResultCode.SUCCESS) {
throw new ProtocolAdapterException("Call for RESET_ALARM was unsuccessful for M-Bus channel " + channel + ", MethodResultCode=" + methodResult.getResultCode() + ".");
}
}
use of org.openmuc.jdlms.AttributeAddress in project open-smart-grid-platform by OSGP.
the class SetAlarmNotificationsCommandExecutor method execute.
@Override
public AccessResultCode execute(final DlmsConnectionManager conn, final DlmsDevice device, final AlarmNotificationsDto alarmNotifications, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
final AttributeAddress alarmFilter1AttributeAddress = this.dlmsObjectConfigService.getAttributeAddress(device, DlmsObjectType.ALARM_FILTER_1, null);
final AccessResultCode resultCodeAlarmFilter1 = this.setAlarmNotifications(conn, alarmNotifications, alarmFilter1AttributeAddress, DlmsObjectType.ALARM_REGISTER_1);
final Optional<AttributeAddress> alarmFilter2AttributeAddress = this.dlmsObjectConfigService.findAttributeAddress(device, DlmsObjectType.ALARM_FILTER_2, null);
if (!alarmFilter2AttributeAddress.isPresent()) {
return resultCodeAlarmFilter1;
} else {
return this.setAlarmNotifications(conn, alarmNotifications, alarmFilter2AttributeAddress.get(), DlmsObjectType.ALARM_REGISTER_2);
}
}
use of org.openmuc.jdlms.AttributeAddress 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.AttributeAddress 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);
}
use of org.openmuc.jdlms.AttributeAddress in project open-smart-grid-platform by OSGP.
the class SetSpecialDaysCommandExecutor method execute.
@Override
public AccessResultCode execute(final DlmsConnectionManager conn, final DlmsDevice device, final List<SpecialDayDto> specialDays, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
final StringBuilder specialDayData = new StringBuilder();
final List<DataObject> specialDayEntries = new ArrayList<>();
int i = 0;
for (final SpecialDayDto specialDay : specialDays) {
specialDayData.append(", ").append(specialDay.getDayId()).append(" => ").append(specialDay.getSpecialDayDate());
final List<DataObject> specDayEntry = new ArrayList<>();
specDayEntry.add(DataObject.newUInteger16Data(i));
specDayEntry.add(this.dlmsHelper.asDataObject(specialDay.getSpecialDayDate()));
specDayEntry.add(DataObject.newUInteger8Data((short) specialDay.getDayId()));
final DataObject dayStruct = DataObject.newStructureData(specDayEntry);
specialDayEntries.add(dayStruct);
i += 1;
}
final AttributeAddress specialDaysTableEntries = new AttributeAddress(CLASS_ID, OBIS_CODE, ATTRIBUTE_ID);
final DataObject entries = DataObject.newArrayData(specialDayEntries);
final SetParameter request = new SetParameter(specialDaysTableEntries, entries);
final String specialDayValues;
if (specialDayData.length() == 0) {
specialDayValues = "";
} else {
specialDayValues = ", values [" + specialDayData.substring(2) + "]";
}
conn.getDlmsMessageListener().setDescription("SetSpecialDays" + specialDayValues + ", set attribute: " + JdlmsObjectToStringUtil.describeAttributes(specialDaysTableEntries));
try {
return conn.getConnection().set(request);
} catch (final IOException e) {
throw new ConnectionException(e);
}
}
Aggregations