use of org.openmuc.framework.config.ChannelScanInfo in project OpenMUC by isc-konstanz.
the class ToJson method addChannelScanInfoList.
public void addChannelScanInfoList(List<ChannelScanInfo> channelScanInfoList) {
JsonArray jsa = new JsonArray();
for (ChannelScanInfo channelScanInfo : channelScanInfoList) {
JsonObject jso = new JsonObject();
jso.addProperty(Const.ADDRESS, channelScanInfo.getChannelAddress());
jso.addProperty(Const.SETTINGS, channelScanInfo.getChannelSettings());
jso.addProperty(Const.VALUE_TYPE, channelScanInfo.getValueType().name());
jso.addProperty(Const.VALUE_TYPE_LENGTH, channelScanInfo.getValueTypeLength());
jso.addProperty(Const.DESCRIPTION, channelScanInfo.getDescription());
jso.addProperty(Const.METADATA, channelScanInfo.getMetaData());
jso.addProperty(Const.UNIT, channelScanInfo.getUnit());
jsa.add(jso);
}
jsonObject.add(Const.CHANNELS, jsa);
}
use of org.openmuc.framework.config.ChannelScanInfo in project OpenMUC by isc-konstanz.
the class DriverConnection method fillDataRecordInChannelScanInfo.
private void fillDataRecordInChannelScanInfo(List<ChannelScanInfo> channelScanInfo, DataRecord dataRecord) {
String vib = Helper.bytesToHex(dataRecord.getVib());
String dib = Helper.bytesToHex(dataRecord.getDib());
ValueType valueType;
Integer valueLength;
switch(dataRecord.getDataValueType()) {
case STRING:
valueType = ValueType.STRING;
valueLength = 25;
break;
case LONG:
if (dataRecord.getMultiplierExponent() == 0) {
valueType = ValueType.LONG;
} else {
valueType = ValueType.DOUBLE;
}
valueLength = null;
break;
case DOUBLE:
case DATE:
valueType = ValueType.DOUBLE;
valueLength = null;
break;
case BCD:
if (dataRecord.getMultiplierExponent() == 0) {
valueType = ValueType.DOUBLE;
} else {
valueType = ValueType.LONG;
}
valueLength = null;
break;
case NONE:
default:
valueType = ValueType.BYTE_ARRAY;
valueLength = 100;
break;
}
String unit = "";
if (dataRecord.getUnit() != null) {
unit = dataRecord.getUnit().getUnit();
}
channelScanInfo.add(new ChannelScanInfo(dib + ':' + vib, getDescription(dataRecord), valueType, valueLength, true, true, "", unit));
}
use of org.openmuc.framework.config.ChannelScanInfo in project OpenMUC by isc-konstanz.
the class RestChannelScanner method scan.
@Override
public void scan(List<ChannelScanInfo> channelScanInfos) throws ArgumentSyntaxException, ScanException, ConnectionException {
try (RestConnection connection = new RestConnection((RestConfigs) getContext())) {
FromJson json = new FromJson(connection.get(""));
List<RestChannel> channels = json.getRestChannelList();
for (RestChannel channel : channels) {
// TODO: get channel config list with valueTypeLength, description, ...
ChannelScanInfo channelScanInfo = new ChannelScanInfo(channel.getId(), "", channel.getValueType(), 0);
channelScanInfos.add(channelScanInfo);
}
} catch (IOException e) {
throw new ConnectionException(e.getMessage());
}
}
use of org.openmuc.framework.config.ChannelScanInfo in project OpenMUC by isc-konstanz.
the class Iec61850Connection method scanForChannels.
@Override
public List<ChannelScanInfo> scanForChannels(String settings) throws UnsupportedOperationException, ConnectionException {
List<BasicDataAttribute> bdas = serverModel.getBasicDataAttributes();
List<ChannelScanInfo> scanInfos = new ArrayList<>(bdas.size());
for (BasicDataAttribute bda : bdas) {
scanInfos.add(createScanInfo(bda));
}
return scanInfos;
}
use of org.openmuc.framework.config.ChannelScanInfo in project OpenMUC by isc-konstanz.
the class IecConnection method scanForChannels.
@Override
public List<ChannelScanInfo> scanForChannels(int timeout) {
List<ChannelScanInfo> channelInfos = new LinkedList<>();
logger.debug("scanning channels");
try {
byte[] frame = receiver.receiveMessage(timeout);
ModeDMessage message = ModeDMessage.parse(frame);
List<String> dataSets = message.getDataSets();
for (String data : dataSets) {
DataSet dataSet = new DataSet(data);
String channelAddress = dataSet.getAddress();
String description = "Current value: " + dataSet.parseValueAsDouble() + dataSet.getUnit();
ValueType valueType = ValueType.DOUBLE;
Integer valueTypeLength = null;
Boolean readable = true;
Boolean writable = false;
ChannelScanInfo channelInfo = new ChannelScanInfo(channelAddress, description, valueType, valueTypeLength, readable, writable);
channelInfos.add(channelInfo);
}
} catch (ParseException | IOException e) {
logger.warn("read failed", e);
}
return channelInfos;
}
Aggregations