use of org.openmuc.jdlms.SetParameter 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.SetParameter 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.SetParameter 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);
}
}
use of org.openmuc.jdlms.SetParameter in project open-smart-grid-platform by OSGP.
the class SynchronizeTimeCommandExecutor method execute.
@Override
public AccessResultCode execute(final DlmsConnectionManager conn, final DlmsDevice device, final SynchronizeTimeRequestDto synchronizeTimeRequestDto, final MessageMetadata messageMetadata) throws ProtocolAdapterException {
final DateTime dt = DateTime.now();
final DataObject time = this.dlmsHelper.asDataObject(dt, synchronizeTimeRequestDto.getDeviation(), synchronizeTimeRequestDto.isDst());
final SetParameter setParameter = new SetParameter(ATTRIBUTE_TIME, time);
conn.getDlmsMessageListener().setDescription("SynchronizeTime to " + dt + ", set attribute: " + JdlmsObjectToStringUtil.describeAttributes(ATTRIBUTE_TIME));
try {
return conn.getConnection().set(setParameter);
} catch (final IOException e) {
throw new ConnectionException(e);
}
}
use of org.openmuc.jdlms.SetParameter in project open-smart-grid-platform by OSGP.
the class SetRandomisationSettingsCommandExecutor method writeRandomisationSettings.
private void writeRandomisationSettings(final DlmsConnectionManager conn, final DlmsDevice device, final int randomisationStartWindow, final int multiplicationFactor, final int numberOfRetries) throws ProtocolAdapterException {
final AttributeAddress randomisationSettingsAddress = this.dlmsObjectConfigService.getAttributeAddress(device, DlmsObjectType.RANDOMISATION_SETTINGS, null);
final DataObject randomisationStartWindowObject = DataObject.newUInteger32Data(randomisationStartWindow);
final DataObject multiplicationFactorObject = DataObject.newUInteger16Data(multiplicationFactor);
final DataObject numberOfRetriesObject = DataObject.newUInteger16Data(numberOfRetries);
final DataObject randomisationSettingsObject = DataObject.newStructureData(randomisationStartWindowObject, multiplicationFactorObject, numberOfRetriesObject);
final SetParameter setRandomisationSettings = new SetParameter(randomisationSettingsAddress, randomisationSettingsObject);
this.writeAttribute(conn, setRandomisationSettings);
}
Aggregations