Search in sources :

Example 1 with Ets5Model

use of org.apache.plc4x.java.knxnetip.ets5.model.Ets5Model in project plc4x by apache.

the class Ets5Parser method parse.

public Ets5Model parse(File knxprojFile, String password) {
    try {
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_DTD, "");
        factory.setAttribute(XMLConstants.ACCESS_EXTERNAL_SCHEMA, "");
        DocumentBuilder builder = factory.newDocumentBuilder();
        XPathFactory xPathFactory = XPathFactory.newInstance();
        XPath xPath = xPathFactory.newXPath();
        try (ZipFile zipFile = new ZipFile(knxprojFile)) {
            // //////////////////////////////////////////////////////////////////////////////
            // File containing the information on the type of encoding used for group addresses.
            // //////////////////////////////////////////////////////////////////////////////
            Document projectHeaderDoc;
            Document projectDoc;
            String projectNumber = this.getProjectNumber(zipFile);
            FileHeader projectFileHeader = zipFile.getFileHeader(projectNumber + "/project.xml");
            if (projectFileHeader == null) {
                // This is the case of a knxproj file which is password-protected
                final FileHeader encryptedProjectFileHeader = zipFile.getFileHeader(projectNumber + ".zip");
                if (encryptedProjectFileHeader == null) {
                    throw new PlcRuntimeException(String.format("Error accessing project header file. Project file '%s/project.xml' and '%s.zip' don't exist.", projectNumber, projectNumber));
                }
                // Dump the encrypted zip to a temp file.
                Path tempDir = Files.createTempDirectory(null);
                zipFile.extractFile(projectNumber + ".zip", tempDir.toFile().getAbsolutePath());
                File tempFile = new File(tempDir.toFile(), projectNumber + ".zip");
                // Unzip the archive inside the archive.
                try (ZipFile projectZipFile = new ZipFile(tempFile, password.toCharArray())) {
                    final FileHeader compressedProjectFileHeader = projectZipFile.getFileHeader("project.xml");
                    if (compressedProjectFileHeader == null) {
                        throw new PlcRuntimeException(String.format("Error accessing project header file: Project file 'project.xml' inside '%s.zip'.", projectNumber));
                    }
                    projectHeaderDoc = builder.parse(projectZipFile.getInputStream(compressedProjectFileHeader));
                    FileHeader projectFileFileHeader = projectZipFile.getFileHeader("0.xml");
                    if (projectFileFileHeader == null) {
                        throw new PlcRuntimeException("Error accessing project file.");
                    }
                    projectDoc = builder.parse(projectZipFile.getInputStream(projectFileFileHeader));
                }
            } else {
                projectHeaderDoc = builder.parse(zipFile.getInputStream(projectFileHeader));
                FileHeader projectFileFileHeader = zipFile.getFileHeader(projectNumber + "/0.xml");
                if (projectFileFileHeader == null) {
                    throw new PlcRuntimeException("Error accessing project file.");
                }
                projectDoc = builder.parse(zipFile.getInputStream(projectFileFileHeader));
            }
            final XPathExpression xpathGroupAddressStyle = xPath.compile("/KNX/Project/ProjectInformation/@GroupAddressStyle");
            Attr groupAddressStyle = (Attr) xpathGroupAddressStyle.evaluate(projectHeaderDoc, XPathConstants.NODE);
            byte groupAddressStyleCode = getGroupAddressLevel(groupAddressStyle.getTextContent());
            // //////////////////////////////////////////////////////////////////////////////
            // General information on the type of encoding and the value ranges.
            // //////////////////////////////////////////////////////////////////////////////
            FileHeader knxMasterDataFileFileHeader = zipFile.getFileHeader("knx_master.xml");
            if (knxMasterDataFileFileHeader == null) {
                throw new PlcRuntimeException("Error accessing KNX master file.");
            }
            Document knxMasterDoc = builder.parse(zipFile.getInputStream(knxMasterDataFileFileHeader));
            final XPathExpression xpathDatapointSubtype = xPath.compile("//DatapointSubtype");
            NodeList datapointSubtypeNodes = (NodeList) xpathDatapointSubtype.evaluate(knxMasterDoc, XPathConstants.NODESET);
            // Build an index of the internal data-types.
            Map<String, KnxDatapointType> knxDatapointTypeMap = new TreeMap<>();
            for (KnxDatapointType value : KnxDatapointType.values()) {
                knxDatapointTypeMap.put(value.getDatapointMainType().getNumber() + "#" + value.getNumber(), value);
            }
            Map<String, AddressType> addressTypes = new HashMap<>();
            for (int i = 0; i < datapointSubtypeNodes.getLength(); i++) {
                final Element datapointSubtypeNode = (Element) datapointSubtypeNodes.item(i);
                final String id = datapointSubtypeNode.getAttribute("Id");
                final int subType = Integer.parseInt(datapointSubtypeNode.getAttribute("Number"));
                final int mainType = Integer.parseInt(((Element) datapointSubtypeNode.getParentNode().getParentNode()).getAttribute("Number"));
                final String name = datapointSubtypeNode.getAttribute("Text");
                addressTypes.put(id, new AddressType(id, mainType, subType, name));
            }
            // //////////////////////////////////////////////////////////////////////////////
            // File containing all the information about group addresses used, their names, types etc.
            // //////////////////////////////////////////////////////////////////////////////
            final Map<String, String> topologyNames = new HashMap<>();
            final XPathExpression topology = xPath.compile("//Topology");
            final Element topologyElement = (Element) topology.evaluate(projectDoc, XPathConstants.NODE);
            final NodeList areas = topologyElement.getElementsByTagName("Area");
            for (int a = 0; a < areas.getLength(); a++) {
                final Element areaNode = (Element) areas.item(a);
                final String curAreaAddress = areaNode.getAttribute("Address");
                topologyNames.put(curAreaAddress, areaNode.getAttribute("Name"));
                final NodeList lines = areaNode.getElementsByTagName("Line");
                for (int l = 0; l < lines.getLength(); l++) {
                    final Element lineNode = (Element) lines.item(l);
                    final String curLineAddress = curAreaAddress + "/" + lineNode.getAttribute("Address");
                    topologyNames.put(curLineAddress, lineNode.getAttribute("Name"));
                }
            }
            final Map<String, Function> groupAddressRefs = new HashMap<>();
            final XPathExpression xpathGroupAddressRef = xPath.compile("//GroupAddressRef");
            NodeList groupAddressRefNodes = (NodeList) xpathGroupAddressRef.evaluate(projectDoc, XPathConstants.NODESET);
            for (int i = 0; i < groupAddressRefNodes.getLength(); i++) {
                final Element groupAddressRefNode = (Element) groupAddressRefNodes.item(i);
                final String refId = groupAddressRefNode.getAttribute("RefId");
                final Element functionNode = (Element) groupAddressRefNode.getParentNode();
                final String functionName = functionNode.getAttribute("Name");
                // Function Type information is stored in knx_master.xml (//FunctionType[@id='functionTypeId']
                final String functionTypeId = functionNode.getAttribute("Type");
                final Element spaceNode = (Element) functionNode.getParentNode();
                final String spaceName = spaceNode.getAttribute("Name");
                final Function function = new Function(refId, functionName, functionTypeId, spaceName);
                groupAddressRefs.put(refId, function);
            }
            final XPathExpression xpathGroupAddresses = xPath.compile("//GroupAddress");
            NodeList groupAddressNodes = (NodeList) xpathGroupAddresses.evaluate(projectDoc, XPathConstants.NODESET);
            Map<String, GroupAddress> groupAddresses = new HashMap<>();
            for (int i = 0; i < groupAddressNodes.getLength(); i++) {
                final Element groupAddressNode = (Element) groupAddressNodes.item(i);
                final String id = groupAddressNode.getAttribute("Id");
                final Function function = groupAddressRefs.get(id);
                final int addressInt = Integer.parseInt(groupAddressNode.getAttribute("Address"));
                final String knxGroupAddress = Ets5Model.parseGroupAddress(groupAddressStyleCode, addressInt);
                final String name = groupAddressNode.getAttribute("Name");
                final String typeString = groupAddressNode.getAttribute("DatapointType");
                final AddressType addressType = addressTypes.get(typeString);
                if (addressType != null) {
                    // Lookup the driver internal data-type.
                    final KnxDatapointType datapointType = knxDatapointTypeMap.get(addressType.getMainType() + "#" + addressType.getSubType());
                    GroupAddress groupAddress = new GroupAddress(knxGroupAddress, name, datapointType, function);
                    groupAddresses.put(knxGroupAddress, groupAddress);
                }
            }
            return new Ets5Model(groupAddressStyleCode, groupAddresses, topologyNames);
        }
    } catch (IOException | ParserConfigurationException | SAXException | XPathExpressionException e) {
        // Zip and Xml Stuff
        throw new PlcRuntimeException(e);
    }
}
Also used : DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) HashMap(java.util.HashMap) Element(org.w3c.dom.Element) Document(org.w3c.dom.Document) Attr(org.w3c.dom.Attr) SAXException(org.xml.sax.SAXException) Function(org.apache.plc4x.java.knxnetip.ets5.model.Function) GroupAddress(org.apache.plc4x.java.knxnetip.ets5.model.GroupAddress) ParserConfigurationException(javax.xml.parsers.ParserConfigurationException) FileHeader(net.lingala.zip4j.model.FileHeader) Path(java.nio.file.Path) PlcRuntimeException(org.apache.plc4x.java.api.exceptions.PlcRuntimeException) KnxDatapointType(org.apache.plc4x.java.knxnetip.readwrite.KnxDatapointType) NodeList(org.w3c.dom.NodeList) IOException(java.io.IOException) TreeMap(java.util.TreeMap) Ets5Model(org.apache.plc4x.java.knxnetip.ets5.model.Ets5Model) ZipFile(net.lingala.zip4j.ZipFile) DocumentBuilder(javax.xml.parsers.DocumentBuilder) AddressType(org.apache.plc4x.java.knxnetip.ets5.model.AddressType) File(java.io.File) ZipFile(net.lingala.zip4j.ZipFile)

Example 2 with Ets5Model

use of org.apache.plc4x.java.knxnetip.ets5.model.Ets5Model in project plc4x by apache.

the class KnxNetIpProtocolLogic method processCemiData.

protected void processCemiData(KnxAddress sourceAddress, byte[] destinationGroupAddress, byte firstByte, byte[] restBytes) throws ParseException {
    // The first byte is actually just 6 bit long, but we'll treat it as a full one.
    // So here we create a byte array containing the first and all the following bytes.
    byte[] payload = new byte[1 + restBytes.length];
    payload[0] = firstByte;
    System.arraycopy(restBytes, 0, payload, 1, restBytes.length);
    // Decode the group address depending on the project settings.
    ReadBuffer addressBuffer = new ReadBufferByteBased(destinationGroupAddress);
    final KnxGroupAddress knxGroupAddress = KnxGroupAddress.staticParse(addressBuffer, knxNetIpDriverContext.getGroupAddressType());
    final String destinationAddress = toString(knxGroupAddress);
    // If there is an ETS5 model provided, continue decoding the payload.
    if (knxNetIpDriverContext.getEts5Model() != null) {
        final Ets5Model ets5Model = knxNetIpDriverContext.getEts5Model();
        final GroupAddress groupAddress = ets5Model.getGroupAddresses().get(destinationAddress);
        final String areaName = ets5Model.getTopologyName(destinationAddress.substring(0, destinationAddress.indexOf('/')));
        final String lineName = ets5Model.getTopologyName(destinationAddress.substring(0, destinationAddress.indexOf('/', destinationAddress.indexOf('/') + 1)));
        if ((groupAddress != null) && (groupAddress.getType() != null)) {
            LOGGER.trace(String.format("Message from: '%s' to: '%s'", toString(sourceAddress), destinationAddress));
            // Parse the payload depending on the type of the group-address.
            ReadBuffer rawDataReader = new ReadBufferByteBased(payload);
            final PlcValue value = KnxDatapoint.staticParse(rawDataReader, groupAddress.getType());
            // Assemble the plc4x return data-structure.
            Map<String, PlcValue> dataPointMap = new HashMap<>();
            dataPointMap.put("sourceAddress", new PlcSTRING(toString(sourceAddress)));
            dataPointMap.put("targetAddress", new PlcSTRING(groupAddress.getGroupAddress()));
            if (groupAddress.getFunction() != null) {
                dataPointMap.put("location", new PlcSTRING(groupAddress.getFunction().getSpaceName()));
                dataPointMap.put("function", new PlcSTRING(groupAddress.getFunction().getName()));
            } else {
                dataPointMap.put("location", null);
                dataPointMap.put("function", null);
            }
            if (areaName != null) {
                dataPointMap.put("area", new PlcSTRING(areaName));
            }
            if (lineName != null) {
                dataPointMap.put("line", new PlcSTRING(lineName));
            }
            dataPointMap.put("description", new PlcSTRING(groupAddress.getName()));
            dataPointMap.put("unitOfMeasurement", new PlcSTRING(groupAddress.getType().getName()));
            dataPointMap.put("value", value);
            final PlcStruct dataPoint = new PlcStruct(dataPointMap);
            // Send the data-structure.
            publishEvent(groupAddress, dataPoint);
        } else {
            LOGGER.warn(String.format("Message from: '%s' to unknown group address: '%s'%n payload: '%s'", toString(sourceAddress), destinationAddress, Hex.encodeHexString(payload)));
        }
    } else // Else just output the raw payload.
    {
        LOGGER.info(String.format("Raw Message: '%s' to: '%s'%n payload: '%s'", KnxNetIpProtocolLogic.toString(sourceAddress), destinationAddress, Hex.encodeHexString(payload)));
    }
}
Also used : Ets5Model(org.apache.plc4x.java.knxnetip.ets5.model.Ets5Model) KnxGroupAddress(org.apache.plc4x.java.knxnetip.readwrite.KnxGroupAddress) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) PlcStruct(org.apache.plc4x.java.spi.values.PlcStruct) GroupAddress(org.apache.plc4x.java.knxnetip.ets5.model.GroupAddress) KnxGroupAddress(org.apache.plc4x.java.knxnetip.readwrite.KnxGroupAddress) PlcSTRING(org.apache.plc4x.java.spi.values.PlcSTRING)

Example 3 with Ets5Model

use of org.apache.plc4x.java.knxnetip.ets5.model.Ets5Model in project plc4x by apache.

the class KnxNetIpProtocolLogic method write.

@Override
public CompletableFuture<PlcWriteResponse> write(PlcWriteRequest writeRequest) {
    CompletableFuture<PlcWriteResponse> future = new CompletableFuture<>();
    DefaultPlcWriteRequest request = (DefaultPlcWriteRequest) writeRequest;
    // As the KNX driver is using the SingleFieldOptimizer, each request here will have
    // only one item.
    final Optional<String> first = request.getFieldNames().stream().findFirst();
    if (first.isPresent()) {
        String fieldName = first.get();
        final KnxNetIpField field = (KnxNetIpField) request.getField(fieldName);
        byte[] destinationAddress = toKnxAddressData(field);
        if (sequenceCounter.get() == Short.MAX_VALUE) {
            sequenceCounter.set(0);
        }
        // Convert the PlcValue to byte data.
        final PlcValue value = request.getPlcValue(fieldName);
        byte dataFirstByte = 0;
        byte[] data = null;
        final Ets5Model ets5Model = knxNetIpDriverContext.getEts5Model();
        if (ets5Model != null) {
            final String destinationAddressString = ets5Model.parseGroupAddress(destinationAddress);
            final GroupAddress groupAddress = ets5Model.getGroupAddresses().get(destinationAddressString);
            if ((groupAddress == null) || (groupAddress.getType() == null)) {
                future.completeExceptionally(new PlcRuntimeException("ETS5 model didn't specify group address '" + destinationAddressString + "' or didn't define a type for it."));
                return future;
            }
            // Use the data in the ets5 model to correctly check and serialize the PlcValue
            try {
                final WriteBufferByteBased writeBuffer = new WriteBufferByteBased(KnxDatapoint.getLengthInBytes(value, groupAddress.getType()));
                KnxDatapoint.staticSerialize(writeBuffer, value, groupAddress.getType());
                final byte[] serialized = writeBuffer.getData();
                dataFirstByte = serialized[0];
                data = new byte[serialized.length - 1];
                System.arraycopy(serialized, 1, data, 0, serialized.length - 1);
            } catch (SerializationException e) {
                future.completeExceptionally(new PlcRuntimeException("Error serializing PlcValue.", e));
                return future;
            }
        } else {
            if (value.isByte()) {
                if ((value.getByte() > 63) || (value.getByte() < 0)) {
                    future.completeExceptionally(new PlcRuntimeException("If no ETS5 model is provided, value of the first byte must be between 0 and 63."));
                    return future;
                }
                dataFirstByte = value.getByte();
            } else if (value.isList()) {
                // Check each item of the list, if it's also a byte.
                List<? extends PlcValue> list = value.getList();
                // TODO: This could cause an exception.
                data = new byte[list.size() - 1];
                boolean allValuesAreBytes = !list.isEmpty();
                int numByte = 0;
                for (PlcValue plcValue : list) {
                    if (numByte == 0) {
                        if (!plcValue.isByte() && (plcValue.getByte() > 63) || (plcValue.getByte() < 0)) {
                            allValuesAreBytes = false;
                            break;
                        }
                        dataFirstByte = plcValue.getByte();
                    } else {
                        if (!plcValue.isByte()) {
                            allValuesAreBytes = false;
                            break;
                        }
                        data[numByte - 1] = plcValue.getByte();
                    }
                    numByte++;
                }
                if (!allValuesAreBytes) {
                    future.completeExceptionally(new PlcRuntimeException("If no ETS5 model is provided, the only supported type for writing data is writing of single byte or list of bytes and the value of the first byte must be between 0 and 63."));
                    return future;
                }
            } else {
                future.completeExceptionally(new PlcRuntimeException("If no ETS5 model is provided, the only supported type for writing data is writing of single byte or list of bytes."));
                return future;
            }
        }
        final short communicationChannelId = knxNetIpDriverContext.getCommunicationChannelId();
        // Prepare the knx request message.
        TunnelingRequest knxRequest = new TunnelingRequest(new TunnelingRequestDataBlock(communicationChannelId, (short) sequenceCounter.getAndIncrement()), new LDataReq((short) 0, new ArrayList<>(0), new LDataExtended(false, false, CEMIPriority.LOW, false, false, true, (byte) 6, (byte) 0, knxNetIpDriverContext.getClientKnxAddress(), destinationAddress, new ApduDataContainer(true, (byte) 0, new ApduDataGroupValueWrite(dataFirstByte, data, (short) -1), (short) -1)), -1), -1);
        // Start a new request-transaction (Is ended in the response-handler)
        RequestTransactionManager.RequestTransaction transaction = tm.startRequest();
        // Start a new request-transaction (Is ended in the response-handler)
        transaction.submit(() -> context.sendRequest(knxRequest).expectResponse(KnxNetIpMessage.class, REQUEST_TIMEOUT).onTimeout(future::completeExceptionally).onError((tr, e) -> future.completeExceptionally(e)).check(tr -> tr instanceof TunnelingResponse).unwrap(tr -> ((TunnelingResponse) tr)).check(tr -> tr.getTunnelingResponseDataBlock().getCommunicationChannelId() == knxRequest.getTunnelingRequestDataBlock().getCommunicationChannelId()).check(tr -> tr.getTunnelingResponseDataBlock().getSequenceCounter() == knxRequest.getTunnelingRequestDataBlock().getSequenceCounter()).handle(tr -> {
            PlcResponseCode responseCode;
            // In this case all went well.
            if (tr.getTunnelingResponseDataBlock().getStatus() == Status.NO_ERROR) {
                responseCode = PlcResponseCode.OK;
            } else // TODO: Should probably differentiate a bit on this and not treat everything as internal error.
            {
                responseCode = PlcResponseCode.INTERNAL_ERROR;
            }
            // Prepare the response.
            PlcWriteResponse response = new DefaultPlcWriteResponse(request, Collections.singletonMap(fieldName, responseCode));
            future.complete(response);
            // Finish the request-transaction.
            transaction.endRequest();
        }));
    }
    return future;
}
Also used : org.apache.plc4x.java.api.value(org.apache.plc4x.java.api.value) PlcStruct(org.apache.plc4x.java.spi.values.PlcStruct) java.util(java.util) GroupAddress(org.apache.plc4x.java.knxnetip.ets5.model.GroupAddress) DriverContext(org.apache.plc4x.java.spi.context.DriverContext) LoggerFactory(org.slf4j.LoggerFactory) KnxGroupAddress3Level(org.apache.plc4x.java.knxnetip.readwrite.KnxGroupAddress3Level) DefaultPlcConsumerRegistration(org.apache.plc4x.java.spi.model.DefaultPlcConsumerRegistration) CompletableFuture(java.util.concurrent.CompletableFuture) Hex(org.apache.commons.codec.binary.Hex) PlcConsumerRegistration(org.apache.plc4x.java.api.model.PlcConsumerRegistration) KnxNetIpDriverContext(org.apache.plc4x.java.knxnetip.context.KnxNetIpDriverContext) KnxNetIpSubscriptionHandle(org.apache.plc4x.java.knxnetip.model.KnxNetIpSubscriptionHandle) RequestTransactionManager(org.apache.plc4x.java.spi.transaction.RequestTransactionManager) DatagramChannel(io.netty.channel.socket.DatagramChannel) PlcSTRING(org.apache.plc4x.java.spi.values.PlcSTRING) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ConversationContext(org.apache.plc4x.java.spi.ConversationContext) DefaultPlcSubscriptionField(org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionField) Duration(java.time.Duration) PlcResponseCode(org.apache.plc4x.java.api.types.PlcResponseCode) KnxDatapoint(org.apache.plc4x.java.knxnetip.readwrite.KnxDatapoint) Plc4xProtocolBase(org.apache.plc4x.java.spi.Plc4xProtocolBase) Logger(org.slf4j.Logger) KnxGroupAddress2Level(org.apache.plc4x.java.knxnetip.readwrite.KnxGroupAddress2Level) PlcSubscriptionHandle(org.apache.plc4x.java.api.model.PlcSubscriptionHandle) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) KnxGroupAddressFreeLevel(org.apache.plc4x.java.knxnetip.readwrite.KnxGroupAddressFreeLevel) org.apache.plc4x.java.spi.messages(org.apache.plc4x.java.spi.messages) Instant(java.time.Instant) KnxNetIpField(org.apache.plc4x.java.knxnetip.field.KnxNetIpField) InetSocketAddress(java.net.InetSocketAddress) Ets5Model(org.apache.plc4x.java.knxnetip.ets5.model.Ets5Model) org.apache.plc4x.java.spi.generation(org.apache.plc4x.java.spi.generation) Consumer(java.util.function.Consumer) KnxGroupAddress(org.apache.plc4x.java.knxnetip.readwrite.KnxGroupAddress) PlcRuntimeException(org.apache.plc4x.java.api.exceptions.PlcRuntimeException) org.apache.plc4x.java.knxnetip.readwrite(org.apache.plc4x.java.knxnetip.readwrite) ResponseItem(org.apache.plc4x.java.spi.messages.utils.ResponseItem) org.apache.plc4x.java.api.messages(org.apache.plc4x.java.api.messages) KnxNetIpField(org.apache.plc4x.java.knxnetip.field.KnxNetIpField) CompletableFuture(java.util.concurrent.CompletableFuture) GroupAddress(org.apache.plc4x.java.knxnetip.ets5.model.GroupAddress) KnxGroupAddress(org.apache.plc4x.java.knxnetip.readwrite.KnxGroupAddress) PlcRuntimeException(org.apache.plc4x.java.api.exceptions.PlcRuntimeException) RequestTransactionManager(org.apache.plc4x.java.spi.transaction.RequestTransactionManager) PlcResponseCode(org.apache.plc4x.java.api.types.PlcResponseCode) Ets5Model(org.apache.plc4x.java.knxnetip.ets5.model.Ets5Model)

Example 4 with Ets5Model

use of org.apache.plc4x.java.knxnetip.ets5.model.Ets5Model in project plc4x by apache.

the class KnxNetIpDriverContext method setConfiguration.

@Override
public void setConfiguration(KnxNetIpConfiguration configuration) {
    if (configuration.knxprojFilePath != null) {
        File knxprojFile = new File(configuration.knxprojFilePath);
        if (knxprojFile.exists() && knxprojFile.isFile()) {
            ets5Model = new Ets5Parser().parse(knxprojFile, configuration.knxprojPassword);
            groupAddressType = ets5Model.getGroupAddressType();
        } else {
            throw new PlcRuntimeException(String.format("File specified with 'knxproj-file-path' does not exist or is not a file: '%s'", configuration.knxprojFilePath));
        }
    } else {
        groupAddressType = (byte) configuration.groupAddressNumLevels;
    }
    tunnelConnectionType = KnxLayer.valueOf("TUNNEL_" + configuration.getConnectionType());
}
Also used : PlcRuntimeException(org.apache.plc4x.java.api.exceptions.PlcRuntimeException) File(java.io.File) Ets5Parser(org.apache.plc4x.java.knxnetip.ets5.Ets5Parser)

Aggregations

PlcRuntimeException (org.apache.plc4x.java.api.exceptions.PlcRuntimeException)3 Ets5Model (org.apache.plc4x.java.knxnetip.ets5.model.Ets5Model)3 GroupAddress (org.apache.plc4x.java.knxnetip.ets5.model.GroupAddress)3 File (java.io.File)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 KnxGroupAddress (org.apache.plc4x.java.knxnetip.readwrite.KnxGroupAddress)2 PlcSTRING (org.apache.plc4x.java.spi.values.PlcSTRING)2 PlcStruct (org.apache.plc4x.java.spi.values.PlcStruct)2 DatagramChannel (io.netty.channel.socket.DatagramChannel)1 IOException (java.io.IOException)1 InetSocketAddress (java.net.InetSocketAddress)1 Path (java.nio.file.Path)1 Duration (java.time.Duration)1 Instant (java.time.Instant)1 java.util (java.util)1 HashMap (java.util.HashMap)1 TreeMap (java.util.TreeMap)1 CompletableFuture (java.util.concurrent.CompletableFuture)1 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 Consumer (java.util.function.Consumer)1