Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Fine tuning of the API and SPI #1786

Merged
merged 32 commits into from
Oct 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
5236450
refactor: Fine tuning of the API and SPI to allow ILLEGAL_ADDRESS res…
chrisdutz Sep 24, 2024
2d25409
refactor: Major cleanup of the PlcValueHandler
chrisdutz Sep 25, 2024
7b55736
refactor: Major cleanup of the PlcValueHandler
chrisdutz Sep 25, 2024
3884549
refactor: Added more testcases to the PlcValueHandler tests
chrisdutz Sep 25, 2024
f7638e5
Merge remote-tracking branch 'origin/develop' into refactor/api-fine-…
chrisdutz Sep 26, 2024
1c5ffaf
refactor: Added more testcases to the PlcValueHandler tests (Refactor…
chrisdutz Sep 26, 2024
69e78c6
refactor: Added more testcases to the PlcValueHandler tests
chrisdutz Sep 26, 2024
3c0e4ea
refactor: Added more testcases to the PlcValueHandler tests
chrisdutz Sep 26, 2024
8182800
refactor: Added more testcases to the PlcValueHandler tests
chrisdutz Sep 26, 2024
7924a67
refactor: Finished updating the PlcValue types and the single item te…
chrisdutz Sep 27, 2024
b0bdbfe
Merge remote-tracking branch 'origin/develop' into refactor/api-fine-…
chrisdutz Sep 27, 2024
76e6ef3
refactor: Moved the PlcTagHandler from the driver to the PlcConnectio…
chrisdutz Sep 29, 2024
fad287d
fix: Hopefully fixed the time-zone issue in the tests.
chrisdutz Sep 29, 2024
097c9f8
fix: Added back a LegacyPlcValueHandler and made the OPC-UA Driver us…
chrisdutz Sep 29, 2024
16feb76
chore: sync xml
sruehl Sep 30, 2024
afa1765
refactor: Changed the names of the new items when serialized in xml t…
chrisdutz Sep 30, 2024
99018e6
refactor: Changed the names of the new items when serialized in xml t…
chrisdutz Sep 30, 2024
3a99cea
refactor: Changed the names of the new items when serialized in xml t…
chrisdutz Sep 30, 2024
0fd2d9c
fix: Disabled another OPC-UA test, which seems to be randomly failing…
chrisdutz Sep 30, 2024
7c6660c
doc: Updated the RELEASE_NOTES
chrisdutz Sep 30, 2024
5e43fcf
refactor: Renamed some of the variables in the Plc4xProtocolBase class
chrisdutz Sep 30, 2024
af7c030
refactor: Added support to a "toFuture()" method to return a future i…
chrisdutz Oct 1, 2024
42769a3
Merge remote-tracking branch 'origin/develop' into refactor/api-fine-…
chrisdutz Oct 1, 2024
1c2ca38
refactor: Added support to a "toFuture()" method to return a future i…
chrisdutz Oct 1, 2024
6317d31
chore: Updated some generated code.
chrisdutz Oct 1, 2024
aa4f965
refactor: Changed the structure of how to process requests in the ads…
chrisdutz Oct 1, 2024
cdcddcc
fix: Fixed a small bug in the size calculation of an ArrayInfo
chrisdutz Oct 1, 2024
24c9392
Merge remote-tracking branch 'refs/remotes/origin/develop' into refac…
chrisdutz Oct 2, 2024
4de3701
fix: Fixed how Modbus tags produce their array-info
chrisdutz Oct 2, 2024
6de3088
fix: Fixed how Modbus tags produce their array-info
chrisdutz Oct 2, 2024
198e42d
Merge remote-tracking branch 'origin/refactor/api-fine-tuning' into r…
chrisdutz Oct 2, 2024
69ee185
fix: Undid our future-chaining-experiment
chrisdutz Oct 2, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.apache.plc4x.java.api.messages;

import org.apache.plc4x.java.api.model.PlcTag;
import org.apache.plc4x.java.api.types.PlcResponseCode;

import java.util.LinkedHashSet;
import java.util.List;
Expand All @@ -33,7 +34,9 @@ public interface PlcTagRequest extends PlcRequest {

LinkedHashSet<String> getTagNames();

PlcTag getTag(String name);
PlcResponseCode getTagResponseCode(String tagName);

PlcTag getTag(String tagName);

List<PlcTag> getTags();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.apache.plc4x.java.spi.configuration.PlcConnectionConfiguration;
import org.apache.plc4x.java.spi.configuration.PlcTransportConfiguration;
import org.apache.plc4x.java.api.model.PlcTag;
import org.apache.plc4x.java.spi.values.PlcValueHandler;
import org.apache.plc4x.java.spi.connection.GeneratedDriverBase;
import org.apache.plc4x.java.spi.connection.ProtocolStackConfigurer;
import org.apache.plc4x.java.spi.connection.SingleProtocolStackConfigurer;
Expand Down Expand Up @@ -82,11 +81,6 @@ protected AbEthTagHandler getTagHandler() {
return new AbEthTagHandler();
}

@Override
protected org.apache.plc4x.java.api.value.PlcValueHandler getValueHandler() {
return new PlcValueHandler();
}

/**
* This protocol doesn't have a disconnect procedure, so there is no need to wait for a login to finish.
* @return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.apache.plc4x.java.spi.configuration.PlcTransportConfiguration;
import org.apache.plc4x.java.api.messages.PlcDiscoveryRequest;
import org.apache.plc4x.java.spi.messages.DefaultPlcDiscoveryRequest;
import org.apache.plc4x.java.spi.values.PlcValueHandler;
import org.apache.plc4x.java.spi.connection.GeneratedDriverBase;
import org.apache.plc4x.java.spi.connection.ProtocolStackConfigurer;
import org.apache.plc4x.java.spi.connection.SingleProtocolStackConfigurer;
Expand Down Expand Up @@ -121,11 +120,6 @@ protected AdsTagHandler getTagHandler() {
return new AdsTagHandler();
}

@Override
protected org.apache.plc4x.java.api.value.PlcValueHandler getValueHandler() {
return new PlcValueHandler();
}

/**
* This protocol doesn't have a disconnect procedure, so there is no need to wait for a login to finish.
* @return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -672,7 +672,7 @@ protected CompletableFuture<PlcReadResponse> singleRead(PlcReadRequest readReque
if(directAdsTag == null) {
return CompletableFuture.completedFuture(new DefaultPlcReadResponse(readRequest, Collections.singletonMap(
readRequest.getTagNames().stream().findFirst().orElseThrow(),
new ResponseItem<>(PlcResponseCode.INVALID_ADDRESS, null))));
new ResponseItem<>(PlcResponseCode.NOT_FOUND, null))));
}

CompletableFuture<PlcReadResponse> future = new CompletableFuture<>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@
*/
public class SymbolicAdsTag implements AdsTag {

// TODO: Model the end of this address to allow usage of multi-dimensional arrays.
private static final Pattern SYMBOLIC_ADDRESS_PATTERN = Pattern.compile("^(?<symbolicAddress>.+)");
private static final Pattern SYMBOLIC_ADDRESS_PATTERN = Pattern.compile("^([\\w_]+)(\"[\"\\d*]\")*(\\.(\\w+)(\"[\"\\d*]\")*)*");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why did you remove the symbolicAddress reference?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still working on this.... It's all still WIP.


private final String symbolicAddress;

Expand All @@ -57,9 +56,7 @@ public static SymbolicAdsTag of(String address) {
if (!matcher.matches()) {
throw new PlcInvalidTagException(address, SYMBOLIC_ADDRESS_PATTERN, "{address}");
}
String symbolicAddress = matcher.group("symbolicAddress");

return new SymbolicAdsTag(symbolicAddress, null, Collections.emptyList());
return new SymbolicAdsTag(address, null, Collections.emptyList());
}

public static boolean matches(String address) {
Expand Down Expand Up @@ -120,4 +117,5 @@ public void serialize(WriteBuffer writeBuffer) throws SerializationException {

writeBuffer.popContext(getClass().getSimpleName());
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* 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
*
* http://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.ads.tag;

import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

class SymbolicAdsTagTest {

@Test
void of() {


}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
*/
package org.apache.plc4x.protocol.ads;

import org.apache.plc4x.java.api.types.PlcResponseCode;
import org.apache.plc4x.java.api.value.PlcValue;
import org.apache.plc4x.java.spi.values.*;
import org.apache.plc4x.test.manual.ManualTest;
Expand Down Expand Up @@ -131,6 +132,10 @@ public static void main(String[] args) throws Exception {
children.put("hurz_TIME_OF_DAY", new PlcTIME_OF_DAY(LocalTime.parse("15:36:30.123")));
children.put("hurz_DATE_AND_TIME", new PlcDATE_AND_TIME(LocalDateTime.parse("1996-05-06T15:36:30")));
test.addTestCase("MAIN.hurz_Struct", new PlcStruct(children));
test.addTestCase("MAIN.thisVariableDoesntExist", PlcResponseCode.NOT_FOUND);
// TODO: Add some complex array path
test.addTestCase("...3323(/987", PlcResponseCode.INVALID_ADDRESS);
test.addTestCase("MAIN.hurz_UDT_array[4].hurz_INT_array[2].someProperty", PlcResponseCode.NOT_FOUND);
test.run();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
import org.apache.plc4x.java.spi.connection.GeneratedDriverBase;
import org.apache.plc4x.java.spi.connection.ProtocolStackConfigurer;
import org.apache.plc4x.java.spi.connection.SingleProtocolStackConfigurer;
import org.apache.plc4x.java.spi.values.PlcValueHandler;

import java.util.Arrays;
import java.util.List;
Expand Down Expand Up @@ -99,11 +98,6 @@ protected BacNetIpTagHandler getTagHandler() {
return new BacNetIpTagHandler();
}

@Override
protected org.apache.plc4x.java.api.value.PlcValueHandler getValueHandler() {
return new PlcValueHandler();
}

@Override
protected ProtocolStackConfigurer<BVLC> getStackConfigurer() {
return SingleProtocolStackConfigurer.builder(BVLC.class, BVLC::staticParse)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,9 @@
package org.apache.plc4x.java.cbus;

import io.netty.buffer.ByteBuf;
import org.apache.plc4x.java.cbus.readwrite.CBusMessage;
import org.apache.plc4x.java.cbus.readwrite.CBusOptions;
import org.apache.plc4x.java.cbus.readwrite.RequestContext;
import org.apache.plc4x.java.spi.configuration.PlcConnectionConfiguration;
import org.apache.plc4x.java.spi.configuration.PlcTransportConfiguration;
import org.apache.plc4x.java.api.value.PlcValueHandler;
import org.apache.plc4x.java.cbus.configuration.CBusConfiguration;
import org.apache.plc4x.java.cbus.configuration.CBusTcpTransportConfiguration;
import org.apache.plc4x.java.cbus.context.CBusDriverContext;
Expand Down Expand Up @@ -88,11 +85,6 @@ protected PlcTagHandler getTagHandler() {
return null;
}

@Override
protected PlcValueHandler getValueHandler() {
return null;
}

@Override
protected ProtocolStackConfigurer<CBusCommand> getStackConfigurer() {
return SingleProtocolStackConfigurer.builder(CBusCommand.class, io ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.apache.plc4x.java.spi.generation.Message;
import org.apache.plc4x.java.spi.optimizer.BaseOptimizer;
import org.apache.plc4x.java.spi.transport.Transport;
import org.apache.plc4x.java.spi.values.PlcValueHandler;
import org.apache.plc4x.java.transport.can.CANTransport;

import java.util.Optional;
Expand Down Expand Up @@ -85,11 +84,6 @@ protected GenericCANTagHandler getTagHandler() {
return new GenericCANTagHandler();
}

@Override
protected org.apache.plc4x.java.api.value.PlcValueHandler getValueHandler() {
return new PlcValueHandler();
}

/**
* This protocol doesn't have a disconnect procedure, so there is no need to wait for a login to finish.
* @return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ protected CANOpenTagHandler getTagHandler() {
}

@Override
protected org.apache.plc4x.java.api.value.PlcValueHandler getValueHandler() {
protected PlcValueHandler getValueHandler() {
return new PlcValueHandler() {
@Override
public PlcValue newPlcValue(PlcTag tag, Object[] values) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,6 @@
import org.apache.plc4x.java.spi.messages.DefaultPlcDiscoveryRequest;
import org.apache.plc4x.java.spi.transport.Transport;

import org.apache.plc4x.java.api.value.PlcValueHandler;

import java.util.Collections;
import java.util.List;
import java.util.Optional;
Expand Down Expand Up @@ -97,11 +95,6 @@ protected PlcTagHandler getTagHandler() {
return new EipTagHandler();
}

@Override
protected PlcValueHandler getValueHandler() {
return new org.apache.plc4x.java.spi.values.PlcValueHandler();
}

@Override
public PlcDiscoveryRequest.Builder discoveryRequestBuilder() {
return new DefaultPlcDiscoveryRequest.Builder(new EipPlcDiscoverer());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import io.netty.buffer.ByteBuf;
import org.apache.plc4x.java.spi.configuration.PlcConnectionConfiguration;
import org.apache.plc4x.java.spi.configuration.PlcTransportConfiguration;
import org.apache.plc4x.java.api.value.PlcValueHandler;
import org.apache.plc4x.java.eip.base.tag.EipTag;
import org.apache.plc4x.java.eip.base.protocol.EipProtocolLogic;
import org.apache.plc4x.java.eip.logix.configuration.LogixConfiguration;
Expand Down Expand Up @@ -77,11 +76,6 @@ protected PlcTagHandler getTagHandler() {
return new EipTagHandler();
}

@Override
protected PlcValueHandler getValueHandler() {
return new org.apache.plc4x.java.spi.values.PlcValueHandler();
}

@Override
protected boolean awaitDisconnectComplete() {
return true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.apache.plc4x.java.firmata.readwrite.tag.FirmataTag;
import org.apache.plc4x.java.firmata.readwrite.tag.FirmataTagHandler;
import org.apache.plc4x.java.firmata.readwrite.protocol.FirmataProtocolLogic;
import org.apache.plc4x.java.spi.values.PlcValueHandler;
import org.apache.plc4x.java.spi.connection.GeneratedDriverBase;
import org.apache.plc4x.java.spi.connection.PlcTagHandler;
import org.apache.plc4x.java.spi.connection.ProtocolStackConfigurer;
Expand Down Expand Up @@ -80,11 +79,6 @@ protected PlcTagHandler getTagHandler() {
return new FirmataTagHandler();
}

@Override
protected org.apache.plc4x.java.api.value.PlcValueHandler getValueHandler() {
return new PlcValueHandler();
}

/**
* This protocol doesn't have a disconnect procedure, so there is no need to wait for a login to finish.
* @return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import org.apache.plc4x.java.spi.connection.GeneratedDriverBase;
import org.apache.plc4x.java.spi.connection.ProtocolStackConfigurer;
import org.apache.plc4x.java.spi.connection.SingleProtocolStackConfigurer;
import org.apache.plc4x.java.spi.values.PlcValueHandler;

import java.util.Collections;
import java.util.List;
Expand Down Expand Up @@ -88,11 +87,6 @@ protected Iec608705104TagHandler getTagHandler() {
return new Iec608705104TagHandler();
}

@Override
protected org.apache.plc4x.java.api.value.PlcValueHandler getValueHandler() {
return new PlcValueHandler();
}

/**
* This protocol doesn't have a disconnect procedure, so there is no need to wait for a login to finish.
* @return false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import org.apache.plc4x.java.knxnetip.tag.KnxNetIpTagHandler;
import org.apache.plc4x.java.knxnetip.protocol.KnxNetIpProtocolLogic;
import org.apache.plc4x.java.spi.messages.DefaultPlcDiscoveryRequest;
import org.apache.plc4x.java.spi.values.PlcValueHandler;
import org.apache.plc4x.java.spi.connection.GeneratedDriverBase;
import org.apache.plc4x.java.spi.connection.PlcTagHandler;
import org.apache.plc4x.java.spi.connection.ProtocolStackConfigurer;
Expand Down Expand Up @@ -128,11 +127,6 @@ protected PlcTagHandler getTagHandler() {
return new KnxNetIpTagHandler();
}

@Override
protected org.apache.plc4x.java.api.value.PlcValueHandler getValueHandler() {
return new PlcValueHandler();
}

@Override
protected boolean awaitDisconnectComplete() { return true; }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
import org.apache.commons.codec.DecoderException;
import org.apache.commons.codec.binary.Hex;
import org.apache.plc4x.java.modbus.ascii.context.ModbusAsciiContext;
import org.apache.plc4x.java.modbus.readwrite.ModbusADU;
import org.apache.plc4x.java.modbus.readwrite.ModbusRtuADU;
import org.apache.plc4x.java.spi.configuration.PlcConnectionConfiguration;
import org.apache.plc4x.java.spi.configuration.PlcTransportConfiguration;
import org.apache.plc4x.java.modbus.ascii.config.ModbusAsciiConfiguration;
Expand All @@ -39,7 +37,6 @@
import org.apache.plc4x.java.spi.generation.*;
import org.apache.plc4x.java.spi.optimizer.BaseOptimizer;
import org.apache.plc4x.java.spi.optimizer.SingleTagOptimizer;
import org.apache.plc4x.java.spi.values.PlcValueHandler;

import java.nio.charset.StandardCharsets;
import java.util.Arrays;
Expand Down Expand Up @@ -127,11 +124,6 @@ protected ModbusTagHandler getTagHandler() {
return new ModbusTagHandler();
}

@Override
protected org.apache.plc4x.java.api.value.PlcValueHandler getValueHandler() {
return new PlcValueHandler();
}

@Override
protected ProtocolStackConfigurer<ModbusAsciiADU> getStackConfigurer() {
return SingleProtocolStackConfigurer.builder(ModbusAsciiADU.class, new ModbusAsciiInput(), new ModbusAsciiOutput())
Expand Down
Loading
Loading