Search in sources :

Example 21 with ChannelScanInfo

use of org.openmuc.framework.config.ChannelScanInfo in project OpenMUC by isc-konstanz.

the class FromJson method getChannelScanInfoList.

public List<ChannelScanInfo> getChannelScanInfoList() {
    List<ChannelScanInfo> returnValue = new ArrayList<>();
    // TODO: another name?
    JsonElement jse = jsonObject.get(Const.CHANNELS);
    JsonArray jsa;
    if (jse.isJsonArray()) {
        jsa = jse.getAsJsonArray();
        Iterator<JsonElement> jseIterator = jsa.iterator();
        while (jseIterator.hasNext()) {
            JsonObject jso = jseIterator.next().getAsJsonObject();
            String channelAddress = getString(jso.get(Const.ADDRESS));
            String channelSettings = getString(jso.get(Const.SETTINGS));
            ValueType valueType = ValueType.valueOf(getString(jso.get(Const.VALUE_TYPE)));
            int valueTypeLength = getInt(jso.get(Const.VALUE_TYPE_LENGTH));
            String description = getString(jso.get(Const.DESCRIPTION));
            boolean readable = getBoolean(jso.get(Const.READABLE));
            boolean writeable = getBoolean(jso.get(Const.WRITEABLE));
            String metadata = getString(jso.get(Const.METADATA));
            returnValue.add(new ChannelScanInfo(channelAddress, channelSettings, description, valueType, valueTypeLength, readable, writeable, metadata));
        }
    } else {
        returnValue = null;
    }
    return returnValue;
}
Also used : JsonArray(com.google.gson.JsonArray) ChannelScanInfo(org.openmuc.framework.config.ChannelScanInfo) ValueType(org.openmuc.framework.data.ValueType) JsonElement(com.google.gson.JsonElement) ArrayList(java.util.ArrayList) JsonObject(com.google.gson.JsonObject)

Aggregations

ChannelScanInfo (org.openmuc.framework.config.ChannelScanInfo)21 ArrayList (java.util.ArrayList)10 ValueType (org.openmuc.framework.data.ValueType)6 IOException (java.io.IOException)5 ConnectionException (org.openmuc.framework.driver.spi.ConnectionException)5 ScanException (org.openmuc.framework.config.ScanException)4 ServerModel (com.beanit.iec61850bean.ServerModel)3 Test (org.junit.jupiter.api.Test)3 JsonArray (com.google.gson.JsonArray)2 JsonObject (com.google.gson.JsonObject)2 LinkedList (java.util.LinkedList)2 Test (org.junit.Test)2 ArgumentSyntaxException (org.openmuc.framework.config.ArgumentSyntaxException)2 ChannelRecordContainer (org.openmuc.framework.driver.spi.ChannelRecordContainer)2 FromJson (org.openmuc.framework.lib.rest.FromJson)2 RestChannel (org.openmuc.framework.lib.rest.objects.RestChannel)2 DataObject (org.openmuc.jdlms.datatypes.DataObject)2 MBusConnection (org.openmuc.jmbus.MBusConnection)2 VariableDataStructure (org.openmuc.jmbus.VariableDataStructure)2 BasicDataAttribute (com.beanit.iec61850bean.BasicDataAttribute)1