Search in sources :

Example 1 with ChannelAddress

use of org.openmuc.framework.driver.dlms.settings.ChannelAddress in project OpenMUC by isc-konstanz.

the class WriteHandle method createSetParamsFor.

private static List<SetParameter> createSetParamsFor(List<ChannelValueContainer> writeList) throws ConnectionException {
    List<SetParameter> setParams = new ArrayList<>(writeList.size());
    for (ChannelValueContainer channelContainer : writeList) {
        try {
            ChannelAddress channelAddress = new ChannelAddress(channelContainer.getChannelAddress());
            Type type = channelAddress.getType();
            if (type == null) {
                String msg = MessageFormat.format("Can not set attribute with address {0} where the type is unknown.", channelAddress);
                throw new ConnectionException(msg);
            }
            DataObject newValue = createDoFor(channelContainer, type);
            AttributeAddress address = channelAddress.getAttributeAddress();
            SetParameter setParameter = new SetParameter(address, newValue);
            setParams.add(setParameter);
        } catch (ArgumentSyntaxException e) {
            throw new ConnectionException(e);
        }
    }
    return setParams;
}
Also used : Type(org.openmuc.jdlms.datatypes.DataObject.Type) DataObject(org.openmuc.jdlms.datatypes.DataObject) ArrayList(java.util.ArrayList) AttributeAddress(org.openmuc.jdlms.AttributeAddress) ChannelAddress(org.openmuc.framework.driver.dlms.settings.ChannelAddress) SetParameter(org.openmuc.jdlms.SetParameter) ConnectionException(org.openmuc.framework.driver.spi.ConnectionException) ChannelValueContainer(org.openmuc.framework.driver.spi.ChannelValueContainer) ArgumentSyntaxException(org.openmuc.framework.config.ArgumentSyntaxException)

Example 2 with ChannelAddress

use of org.openmuc.framework.driver.dlms.settings.ChannelAddress in project OpenMUC by isc-konstanz.

the class ReadHandle method createAttributeAddresFor.

private List<AttributeAddress> createAttributeAddresFor(List<ChannelRecordContainer> readList) throws ConnectionException {
    List<AttributeAddress> getParams = new ArrayList<>(readList.size());
    for (ChannelRecordContainer recordContainer : readList) {
        try {
            ChannelAddress channelAddress = new ChannelAddress(recordContainer.getChannelAddress());
            getParams.add(channelAddress.getAttributeAddress());
        } catch (ArgumentSyntaxException e) {
            throw new ConnectionException(e);
        }
    }
    return getParams;
}
Also used : ChannelRecordContainer(org.openmuc.framework.driver.spi.ChannelRecordContainer) AttributeAddress(org.openmuc.jdlms.AttributeAddress) ArrayList(java.util.ArrayList) ChannelAddress(org.openmuc.framework.driver.dlms.settings.ChannelAddress) ConnectionException(org.openmuc.framework.driver.spi.ConnectionException) ArgumentSyntaxException(org.openmuc.framework.config.ArgumentSyntaxException)

Aggregations

ArrayList (java.util.ArrayList)2 ArgumentSyntaxException (org.openmuc.framework.config.ArgumentSyntaxException)2 ChannelAddress (org.openmuc.framework.driver.dlms.settings.ChannelAddress)2 ConnectionException (org.openmuc.framework.driver.spi.ConnectionException)2 AttributeAddress (org.openmuc.jdlms.AttributeAddress)2 ChannelRecordContainer (org.openmuc.framework.driver.spi.ChannelRecordContainer)1 ChannelValueContainer (org.openmuc.framework.driver.spi.ChannelValueContainer)1 SetParameter (org.openmuc.jdlms.SetParameter)1 DataObject (org.openmuc.jdlms.datatypes.DataObject)1 Type (org.openmuc.jdlms.datatypes.DataObject.Type)1