use of org.openmuc.jdlms.datatypes.DataObject.Type 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;
}
use of org.openmuc.jdlms.datatypes.DataObject.Type in project OpenMUC by isc-konstanz.
the class ReadHandle method getType.
@SuppressWarnings("unused")
private static ValueType getType(DataObject dataObject) {
final ValueType valueType;
final Type type = dataObject.getType();
switch(type) {
case BOOLEAN:
valueType = ValueType.BOOLEAN;
break;
case FLOAT32:
valueType = ValueType.FLOAT;
break;
case FLOAT64:
valueType = ValueType.DOUBLE;
break;
case BCD:
case INTEGER:
valueType = ValueType.BYTE;
break;
case LONG_INTEGER:
case UNSIGNED:
valueType = ValueType.SHORT;
break;
case ENUMERATE:
case DOUBLE_LONG:
case LONG_UNSIGNED:
valueType = ValueType.INTEGER;
break;
case DOUBLE_LONG_UNSIGNED:
case LONG64:
case // Long is to small for Long unsigned
LONG64_UNSIGNED:
valueType = ValueType.LONG;
break;
case OCTET_STRING:
valueType = ValueType.BYTE_ARRAY;
break;
case VISIBLE_STRING:
valueType = ValueType.STRING;
break;
case NULL_DATA:
// TODO
valueType = null;
break;
case ARRAY:
case BIT_STRING:
case COMPACT_ARRAY:
case DONT_CARE:
case DATE:
case DATE_TIME:
case STRUCTURE:
case TIME:
default:
valueType = null;
break;
}
return valueType;
}
Aggregations