Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
56 changes: 56 additions & 0 deletions plc4j/drivers/firmata/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,62 @@
<scope>test</scope>
</dependency>

<!-- Testcontainers for integration testing -->
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers</artifactId>
<version>2.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.testcontainers</groupId>
<artifactId>testcontainers-junit-jupiter</artifactId>
<version>2.0.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.github.pfichtner</groupId>
<artifactId>testcontainers-virtualavr</artifactId>
<version>0.0.2-SNAPSHOT</version>
<scope>test</scope>
</dependency>

<!-- serial communication -->
<dependency>
<groupId>io.github.java-native</groupId>
<artifactId>jssc</artifactId>
<version>2.10.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.27.6</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.awaitility</groupId>
<artifactId>awaitility</artifactId>
<version>4.3.0</version>
<scope>test</scope>
</dependency>

<!-- WebSocket client for controlling VirtualAVR pins -->
<dependency>
<groupId>org.java-websocket</groupId>
<artifactId>Java-WebSocket</artifactId>
<version>1.6.0</version>
<scope>test</scope>
</dependency>

<!-- JSON for WebSocket messages -->
<dependency>
<groupId>com.google.code.gson</groupId>
<artifactId>gson</artifactId>
<version>2.11.0</version>
<scope>test</scope>
</dependency>

<dependency>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4j-utils-test-utils</artifactId>
Expand Down
4 changes: 2 additions & 2 deletions plc4j/drivers/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
</properties>

<modules>
<module>ab-eth</module>
<!--module>ab-eth</module>
<module>ads</module>
<module>bacnet</module>
<module>c-bus</module>
Expand All @@ -58,7 +58,7 @@
<module>profinet-ng</module>
<module>s7</module>
<module>simulated</module>
<module>all</module>
<module>all</module-->
</modules>

</project>
25 changes: 22 additions & 3 deletions plc4j/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,15 @@
<goals>
<goal>report</goal>
</goals>
<configuration>
<!-- Exclude multi-release classes and generated code -->
<excludes>
<exclude>META-INF/versions/**</exclude>
<exclude>module-info.class</exclude>
<!-- Exclude generated protocol code packages (all readwrite packages are generated) -->
<exclude>**/readwrite/*.class</exclude>
</excludes>
</configuration>
</execution>
<!--
Check if the unit-test-coverage is at least a certain minimum.
Expand All @@ -171,8 +180,18 @@
<goal>check</goal>
</goals>
<configuration>
<!-- TODO: Turn this on as soon as possible. -->
<haltOnFailure>false</haltOnFailure>
<haltOnFailure>true</haltOnFailure>
<!-- Exclude multi-release classes, functional interfaces, and generated code -->
<excludes>
<exclude>META-INF/versions/**</exclude>
<exclude>module-info.class</exclude>
<!-- Exclude functional interfaces that can't be directly covered -->
<exclude>**/*$*Listener.class</exclude>
<!-- Exclude generated protocol code packages (all readwrite packages are generated) -->
<exclude>**/readwrite/*.class</exclude>
<!-- Exclude functional marker interfaces (hard to test directly) -->
<exclude>**/with*.class</exclude>
</excludes>
<rules>
<rule implementation="org.jacoco.maven.RuleConfiguration">
<element>BUNDLE</element>
Expand All @@ -181,7 +200,7 @@
<limit implementation="org.jacoco.report.check.Limit">
<counter>INSTRUCTION</counter>
<value>COVEREDRATIO</value>
<minimum>0.50</minimum>
<minimum>0.80</minimum>
</limit>
<!-- Fail the build if there are classes without any coverage. -->
<limit implementation="org.jacoco.report.check.Limit">
Expand Down
41 changes: 41 additions & 0 deletions plc4j/spi/buffers/api/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at

https://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.apache.plc4x</groupId>
<artifactId>plc4j-spi-buffers</artifactId>
<version>0.14.0-SNAPSHOT</version>
</parent>

<artifactId>plc4j-spi-buffers-api</artifactId>

<name>PLC4J: SPI: Buffers: API</name>

<properties>
<project.build.outputTimestamp>2024-02-16T14:53:02Z</project.build.outputTimestamp>
</properties>

<dependencies>
</dependencies>

</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.plc4x.java.spi.buffers.api;

import org.apache.plc4x.java.spi.buffers.api.exceptions.BufferException;

import java.util.HashMap;
import java.util.Map;
import java.util.Stack;

public abstract class AbstractBuffer implements Buffer {

protected final Stack<WithOption[]> context;

public AbstractBuffer(WithOption... options) {
context = new Stack<>();
context.push(options);
}

@Override
public void pushContext(WithOption... options) throws BufferException {
Map<Class<?>, WithOption> newOptions = new HashMap<>();

// Add all new options.
for (WithOption option : options) {
newOptions.put(option.getClass(), option);
}

// Add all inherited options.
if (!context.isEmpty()) {
for (WithOption option : context.peek()) {
if (option.isSticky() && !newOptions.containsKey(option.getClass())) {
newOptions.put(option.getClass(), option);
}
}
}

// Switch the context to the next one.
context.push(newOptions.values().toArray(new WithOption[0]));
}

@Override
public void popContext(WithOption... options) throws BufferException {
if (!context.isEmpty()) {
context.pop();
}
}

@Override
public WithOption[] getContext() {
if (!context.isEmpty()) {
return context.peek();
}
return new WithOption[0];
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,16 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.plc4x.java.spi.codegen.io;
package org.apache.plc4x.java.spi.buffers.api;

import org.apache.plc4x.java.api.value.PlcValue;
import org.apache.plc4x.java.spi.generation.SerializationException;
import org.apache.plc4x.java.spi.buffers.api.exceptions.BufferException;

@FunctionalInterface
public interface DataIoSerializerFunction<T> {
public interface Buffer {

void apply(T t, PlcValue value) throws SerializationException;
void pushContext(WithOption... options) throws BufferException;

void popContext(WithOption... options) throws BufferException;

WithOption[] getContext();

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.plc4x.java.spi.generation;

import org.apache.plc4x.java.spi.utils.Serializable;
package org.apache.plc4x.java.spi.buffers.api;

public interface Message extends Serializable {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.plc4x.java.spi.generation;
package org.apache.plc4x.java.spi.buffers.api;


import org.apache.plc4x.java.spi.buffers.api.exceptions.BufferException;

@FunctionalInterface
public interface MessageInput<PARSER_TYPE> {

PARSER_TYPE parse(ReadBuffer io) throws ParseException;
PARSER_TYPE parse(ReadBuffer io) throws BufferException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/
package org.apache.plc4x.java.spi.generation;
package org.apache.plc4x.java.spi.buffers.api;

public interface MessageOutput<SERIALIZER_TYPE> {

WriteBufferByteBased serialize(SERIALIZER_TYPE value) throws SerializationException;
import org.apache.plc4x.java.spi.buffers.api.exceptions.BufferException;

public interface MessageOutput<PARSER_TYPE, SERIALIZER_TYPE> {

PARSER_TYPE serialize(SERIALIZER_TYPE value) throws BufferException;

}
Loading