diff --git a/RELEASE_NOTES b/RELEASE_NOTES
index a299b253540..9dc43e96d8c 100644
--- a/RELEASE_NOTES
+++ b/RELEASE_NOTES
@@ -29,6 +29,12 @@ Incompatible changes
efficient PlcRawByteArray type is used, that gives users
direct access to the bytes returned from the PLC instead of
a list of PlcValues.
+- The builders for read- and write-requests now process tags
+ and values on a per-field level. If one field has an invalid
+ address it will now only fail the one item related to that.
+ Same applies to values. Only the tag who's value was invalid
+ will be considered failed and no longer an exception should
+ be thrown.
Bug Fixes
---------
diff --git a/plc4go/assets/testing/protocols/ads/DriverTestsuite.xml b/plc4go/assets/testing/protocols/ads/DriverTestsuite.xml
index 73ddc897851..3770e9d267e 100644
--- a/plc4go/assets/testing/protocols/ads/DriverTestsuite.xml
+++ b/plc4go/assets/testing/protocols/ads/DriverTestsuite.xml
@@ -1150,9 +1150,13 @@
-
- MAIN.hurz_Struct
-
+
+
+
+ MAIN.hurz_Struct
+
+
+
@@ -1160,7 +1164,7 @@
-
+
OK
@@ -1232,7 +1236,7 @@
-
+
@@ -1580,12 +1584,12 @@
-
+
OK
true
-
+
@@ -1754,20 +1758,20 @@
-
+
OK
true
-
+
-
+
OK
true
-
+
@@ -2040,12 +2044,12 @@
-
+
OK
false
-
+
@@ -2319,12 +2323,12 @@
-
+
OK
false
-
+
@@ -2474,12 +2478,12 @@
-
+
OK
false
-
+
diff --git a/plc4go/assets/testing/protocols/eip/DriverTestsuite.xml b/plc4go/assets/testing/protocols/eip/DriverTestsuite.xml
index b18faac99d3..b6eca5cd50c 100644
--- a/plc4go/assets/testing/protocols/eip/DriverTestsuite.xml
+++ b/plc4go/assets/testing/protocols/eip/DriverTestsuite.xml
@@ -398,11 +398,15 @@
-
- %rate
- DINT
- 1
-
+
+
+
+ %rate
+ DINT
+ 1
+
+
+
@@ -410,12 +414,12 @@
-
+
OK
369229824
-
+
diff --git a/plc4go/assets/testing/protocols/modbus/tcp/DriverTestsuite.xml b/plc4go/assets/testing/protocols/modbus/tcp/DriverTestsuite.xml
index cad5d8eb6f7..b88fd463e35 100644
--- a/plc4go/assets/testing/protocols/modbus/tcp/DriverTestsuite.xml
+++ b/plc4go/assets/testing/protocols/modbus/tcp/DriverTestsuite.xml
@@ -109,12 +109,12 @@
-
+
OK
3.1415927410125732
-
+
@@ -202,7 +202,7 @@
-
+
OK
@@ -210,7 +210,7 @@
3.1415927410125732
-
+
@@ -357,20 +357,20 @@
-
+
OK
3.1415927410125732
-
+
-
+
OK
3.1415927410125732
-
+
diff --git a/plc4go/assets/testing/protocols/modbus/tcp/DriverTestsuiteOptimized.xml b/plc4go/assets/testing/protocols/modbus/tcp/DriverTestsuiteOptimized.xml
index ebd8db39865..ac935f38bee 100644
--- a/plc4go/assets/testing/protocols/modbus/tcp/DriverTestsuiteOptimized.xml
+++ b/plc4go/assets/testing/protocols/modbus/tcp/DriverTestsuiteOptimized.xml
@@ -97,11 +97,15 @@
-
- 0
- 1
- REAL
-
+
+
+
+ 0
+ 1
+ REAL
+
+
+
@@ -109,12 +113,12 @@
-
+
OK
3.1415927410125732
-
+
@@ -190,11 +194,15 @@
-
- 0
- 2
- REAL
-
+
+
+
+ 0
+ 2
+ REAL
+
+
+
@@ -202,7 +210,7 @@
-
+
OK
@@ -210,7 +218,7 @@
3.1415927410125732
-
+
@@ -290,18 +298,26 @@
-
- 0
- 1
- REAL
-
+
+
+
+ 0
+ 1
+ REAL
+
+
+
-
- 2
- 1
- REAL
-
+
+
+
+ 2
+ 1
+ REAL
+
+
+
@@ -309,20 +325,20 @@
-
+
OK
3.1415927410125732
-
+
-
+
OK
3.1415927410125732
-
+
@@ -401,19 +417,21 @@
-
- 0
- 1
- REAL
-
+
+
+
+ 0
+ 1
+ REAL
+
+
+
+ 3.1415927410125732
+
+
-
-
- 3.1415927410125732
-
-
@@ -498,22 +516,24 @@
-
- 0
- 2
- REAL
-
+
+
+
+ 0
+ 2
+ REAL
+
+
+
+
+ 3.1415927410125732
+ 3.1415927410125732
+
+
+
-
-
-
- 3.1415927410125732
- 3.1415927410125732
-
-
-
diff --git a/plc4go/assets/testing/protocols/modbus/tcp/Modbus-all-datatypes-little-endian.xml b/plc4go/assets/testing/protocols/modbus/tcp/Modbus-all-datatypes-little-endian.xml
index 1c01f468725..7e46dc7933f 100644
--- a/plc4go/assets/testing/protocols/modbus/tcp/Modbus-all-datatypes-little-endian.xml
+++ b/plc4go/assets/testing/protocols/modbus/tcp/Modbus-all-datatypes-little-endian.xml
@@ -101,11 +101,15 @@
-
- 0
- 1
- BOOL
-
+
+
+
+ 0
+ 1
+ BOOL
+
+
+
@@ -113,12 +117,12 @@
-
+
OK
true
-
+
@@ -197,19 +201,21 @@
-
- 0
- 1
- BOOL
-
+
+
+
+ 0
+ 1
+ BOOL
+
+
+
+ true
+
+
-
-
- true
-
-
@@ -290,11 +296,15 @@
-
- 1
- 1
- BYTE
-
+
+
+
+ 1
+ 1
+ BYTE
+
+
+
@@ -302,12 +312,12 @@
-
+
OK
42
-
+
@@ -386,19 +396,21 @@
-
- 1
- 1
- BYTE
-
+
+
+
+ 1
+ 1
+ BYTE
+
+
+
+ 42
+
+
-
-
- 42
-
-
@@ -479,11 +491,15 @@
-
- 2
- 1
- WORD
-
+
+
+
+ 2
+ 1
+ WORD
+
+
+
@@ -491,12 +507,12 @@
-
+
OK
42424
-
+
@@ -575,19 +591,21 @@
-
- 2
- 1
- WORD
-
+
+
+
+ 2
+ 1
+ WORD
+
+
+
+ 42424
+
+
-
-
- 42424
-
-
@@ -668,11 +686,15 @@
-
- 3
- 1
- DWORD
-
+
+
+
+ 3
+ 1
+ DWORD
+
+
+
@@ -680,12 +702,12 @@
-
+
OK
4242442424
-
+
@@ -764,19 +786,21 @@
-
- 3
- 1
- DWORD
-
+
+
+
+ 3
+ 1
+ DWORD
+
+
+
+ 4242442424
+
+
-
-
- 4242442424
-
-
@@ -857,11 +881,15 @@
-
- 9
- 1
- SINT
-
+
+
+
+ 9
+ 1
+ SINT
+
+
+
@@ -869,12 +897,12 @@
-
+
OK
-42
-
+
@@ -953,19 +981,21 @@
-
- 9
- 1
- SINT
-
+
+
+
+ 9
+ 1
+ SINT
+
+
+
+ -42
+
+
-
-
- -42
-
-
@@ -1046,11 +1076,15 @@
-
- 10
- 1
- USINT
-
+
+
+
+ 10
+ 1
+ USINT
+
+
+
@@ -1058,12 +1092,12 @@
-
+
OK
42
-
+
@@ -1142,19 +1176,21 @@
-
- 10
- 1
- USINT
-
+
+
+
+ 10
+ 1
+ USINT
+
+
+
+ 42
+
+
-
-
- 42
-
-
@@ -1235,11 +1271,15 @@
-
- 11
- 1
- INT
-
+
+
+
+ 11
+ 1
+ INT
+
+
+
@@ -1247,12 +1287,12 @@
-
+
OK
-2424
-
+
@@ -1331,19 +1371,21 @@
-
- 11
- 1
- INT
-
+
+
+
+ 11
+ 1
+ INT
+
+
+
+ -2424
+
+
-
-
- -2424
-
-
@@ -1424,11 +1466,15 @@
-
- 12
- 1
- UINT
-
+
+
+
+ 12
+ 1
+ UINT
+
+
+
@@ -1436,12 +1482,12 @@
-
+
OK
42424
-
+
@@ -1520,19 +1566,21 @@
-
- 12
- 1
- UINT
-
+
+
+
+ 12
+ 1
+ UINT
+
+
+
+ 42424
+
+
-
-
- 42424
-
-
@@ -1613,11 +1661,15 @@
-
- 13
- 1
- DINT
-
+
+
+
+ 13
+ 1
+ DINT
+
+
+
@@ -1625,12 +1677,12 @@
-
+
OK
-242442424
-
+
@@ -1709,19 +1761,21 @@
-
- 13
- 1
- DINT
-
+
+
+
+ 13
+ 1
+ DINT
+
+
+
+ -242442424
+
+
-
-
- -242442424
-
-
@@ -1802,11 +1856,15 @@
-
- 15
- 1
- UDINT
-
+
+
+
+ 15
+ 1
+ UDINT
+
+
+
@@ -1814,12 +1872,12 @@
-
+
OK
4242442424
-
+
@@ -1898,19 +1956,21 @@
-
- 15
- 1
- UDINT
-
+
+
+
+ 15
+ 1
+ UDINT
+
+
+
+ 4242442424
+
+
-
-
- 4242442424
-
-
@@ -1991,11 +2051,15 @@
-
- 17
- 1
- LINT
-
+
+
+
+ 17
+ 1
+ LINT
+
+
+
@@ -2003,12 +2067,12 @@
-
+
OK
-4242442424242424242
-
+
@@ -2087,19 +2151,21 @@
-
- 17
- 1
- LINT
-
+
+
+
+ 17
+ 1
+ LINT
+
+
+
+ -4242442424242424242
+
+
-
-
- -4242442424242424242
-
-
@@ -2180,11 +2246,15 @@
-
- 21
- 1
- ULINT
-
+
+
+
+ 21
+ 1
+ ULINT
+
+
+
@@ -2192,12 +2262,12 @@
-
+
OK
4242442424242424242
-
+
@@ -2276,19 +2346,21 @@
-
- 21
- 1
- ULINT
-
+
+
+
+ 21
+ 1
+ ULINT
+
+
+
+ 4242442424242424242
+
+
-
-
- 4242442424242424242
-
-
@@ -2369,11 +2441,15 @@
-
- 25
- 1
- REAL
-
+
+
+
+ 25
+ 1
+ REAL
+
+
+
@@ -2381,12 +2457,12 @@
-
+
OK
3.1415929794311523
-
+
@@ -2465,19 +2541,21 @@
-
- 25
- 1
- REAL
-
+
+
+
+ 25
+ 1
+ REAL
+
+
+
+ 3.1415929794311523
+
+
-
-
- 3.1415929794311523
-
-
@@ -2558,11 +2636,15 @@
-
- 27
- 1
- LREAL
-
+
+
+
+ 27
+ 1
+ LREAL
+
+
+
@@ -2570,12 +2652,12 @@
-
+
OK
2.71828182846
-
+
@@ -2654,19 +2736,21 @@
-
- 27
- 1
- LREAL
-
+
+
+
+ 27
+ 1
+ LREAL
+
+
+
+ 2.71828182846
+
+
-
-
- 2.71828182846
-
-
diff --git a/plc4go/assets/testing/protocols/modbus/tcp/Modbus-all-datatypes.xml b/plc4go/assets/testing/protocols/modbus/tcp/Modbus-all-datatypes.xml
index b3c7d9050c3..938027aff6f 100644
--- a/plc4go/assets/testing/protocols/modbus/tcp/Modbus-all-datatypes.xml
+++ b/plc4go/assets/testing/protocols/modbus/tcp/Modbus-all-datatypes.xml
@@ -95,11 +95,15 @@
-
- 0
- 1
- BOOL
-
+
+
+
+ 0
+ 1
+ BOOL
+
+
+
@@ -107,12 +111,12 @@
-
+
OK
true
-
+
@@ -191,19 +195,21 @@
-
- 0
- 1
- BOOL
-
+
+
+
+ 0
+ 1
+ BOOL
+
+
+
+ true
+
+
-
-
- true
-
-
@@ -284,11 +290,15 @@
-
- 1
- 1
- BYTE
-
+
+
+
+ 1
+ 1
+ BYTE
+
+
+
@@ -296,12 +306,12 @@
-
+
OK
42
-
+
@@ -380,19 +390,21 @@
-
- 1
- 1
- BYTE
-
+
+
+
+ 1
+ 1
+ BYTE
+
+
+
+ 42
+
+
-
-
- 42
-
-
@@ -473,11 +485,15 @@
-
- 2
- 1
- WORD
-
+
+
+
+ 2
+ 1
+ WORD
+
+
+
@@ -485,12 +501,12 @@
-
+
OK
42424
-
+
@@ -569,19 +585,21 @@
-
- 2
- 1
- WORD
-
+
+
+
+ 2
+ 1
+ WORD
+
+
+
+ 42424
+
+
-
-
- 42424
-
-
@@ -662,11 +680,15 @@
-
- 3
- 1
- DWORD
-
+
+
+
+ 3
+ 1
+ DWORD
+
+
+
@@ -674,12 +696,12 @@
-
+
OK
4242442424
-
+
@@ -758,19 +780,21 @@
-
- 3
- 1
- DWORD
-
+
+
+
+ 3
+ 1
+ DWORD
+
+
+
+ 4242442424
+
+
-
-
- 4242442424
-
-
@@ -851,11 +875,15 @@
-
- 9
- 1
- SINT
-
+
+
+
+ 9
+ 1
+ SINT
+
+
+
@@ -863,12 +891,12 @@
-
+
OK
-42
-
+
@@ -947,19 +975,21 @@
-
- 9
- 1
- SINT
-
+
+
+
+ 9
+ 1
+ SINT
+
+
+
+ -42
+
+
-
-
- -42
-
-
@@ -1040,11 +1070,15 @@
-
- 10
- 1
- USINT
-
+
+
+
+ 10
+ 1
+ USINT
+
+
+
@@ -1052,12 +1086,12 @@
-
+
OK
42
-
+
@@ -1136,19 +1170,21 @@
-
- 10
- 1
- USINT
-
+
+
+
+ 10
+ 1
+ USINT
+
+
+
+ 42
+
+
-
-
- 42
-
-
@@ -1229,11 +1265,15 @@
-
- 11
- 1
- INT
-
+
+
+
+ 11
+ 1
+ INT
+
+
+
@@ -1241,12 +1281,12 @@
-
+
OK
-2424
-
+
@@ -1325,19 +1365,21 @@
-
- 11
- 1
- INT
-
+
+
+
+ 11
+ 1
+ INT
+
+
+
+ -2424
+
+
-
-
- -2424
-
-
@@ -1418,11 +1460,15 @@
-
- 12
- 1
- UINT
-
+
+
+
+ 12
+ 1
+ UINT
+
+
+
@@ -1430,12 +1476,12 @@
-
+
OK
42424
-
+
@@ -1514,19 +1560,21 @@
-
- 12
- 1
- UINT
-
+
+
+
+ 12
+ 1
+ UINT
+
+
+
+ 42424
+
+
-
-
- 42424
-
-
@@ -1607,11 +1655,15 @@
-
- 13
- 1
- DINT
-
+
+
+
+ 13
+ 1
+ DINT
+
+
+
@@ -1619,12 +1671,12 @@
-
+
OK
-242442424
-
+
@@ -1703,19 +1755,21 @@
-
- 13
- 1
- DINT
-
+
+
+
+ 13
+ 1
+ DINT
+
+
+
+ -242442424
+
+
-
-
- -242442424
-
-
@@ -1796,11 +1850,15 @@
-
- 15
- 1
- UDINT
-
+
+
+
+ 15
+ 1
+ UDINT
+
+
+
@@ -1808,12 +1866,12 @@
-
+
OK
4242442424
-
+
@@ -1892,19 +1950,21 @@
-
- 15
- 1
- UDINT
-
+
+
+
+ 15
+ 1
+ UDINT
+
+
+
+ 4242442424
+
+
-
-
- 4242442424
-
-
@@ -1985,11 +2045,15 @@
-
- 17
- 1
- LINT
-
+
+
+
+ 17
+ 1
+ LINT
+
+
+
@@ -1997,12 +2061,12 @@
-
+
OK
-4242442424242424242
-
+
@@ -2081,19 +2145,21 @@
-
- 17
- 1
- LINT
-
+
+
+
+ 17
+ 1
+ LINT
+
+
+
+ -4242442424242424242
+
+
-
-
- -4242442424242424242
-
-
@@ -2174,11 +2240,15 @@
-
- 21
- 1
- ULINT
-
+
+
+
+ 21
+ 1
+ ULINT
+
+
+
@@ -2186,12 +2256,12 @@
-
+
OK
4242442424242424242
-
+
@@ -2270,19 +2340,21 @@
-
- 21
- 1
- ULINT
-
+
+
+
+ 21
+ 1
+ ULINT
+
+
+
+ 4242442424242424242
+
+
-
-
- 4242442424242424242
-
-
@@ -2363,11 +2435,15 @@
-
- 25
- 1
- REAL
-
+
+
+
+ 25
+ 1
+ REAL
+
+
+
@@ -2375,12 +2451,12 @@
-
+
OK
3.1415929794311523
-
+
@@ -2459,19 +2535,21 @@
-
- 25
- 1
- REAL
-
+
+
+
+ 25
+ 1
+ REAL
+
+
+
+ 3.1415929794311523
+
+
-
-
- 3.1415929794311523
-
-
@@ -2552,11 +2630,15 @@
-
- 27
- 1
- LREAL
-
+
+
+
+ 27
+ 1
+ LREAL
+
+
+
@@ -2564,12 +2646,12 @@
-
+
OK
2.71828182846
-
+
@@ -2648,19 +2730,21 @@
-
- 27
- 1
- LREAL
-
+
+
+
+ 27
+ 1
+ LREAL
+
+
+
+ 2.71828182846
+
+
-
-
- 2.71828182846
-
-
diff --git a/plc4go/assets/testing/protocols/s7/DriverTestsuite.xml b/plc4go/assets/testing/protocols/s7/DriverTestsuite.xml
index d870c8b0caa..a62da145862 100644
--- a/plc4go/assets/testing/protocols/s7/DriverTestsuite.xml
+++ b/plc4go/assets/testing/protocols/s7/DriverTestsuite.xml
@@ -582,12 +582,12 @@
-
+
OK
true
-
+
@@ -730,12 +730,12 @@
-
+
ACCESS_DENIED
-
+
diff --git a/plc4go/spi/model/DefaultPlcReadResponse.go b/plc4go/spi/model/DefaultPlcReadResponse.go
index db3172364aa..23bd17b768a 100644
--- a/plc4go/spi/model/DefaultPlcReadResponse.go
+++ b/plc4go/spi/model/DefaultPlcReadResponse.go
@@ -30,14 +30,14 @@ var _ apiModel.PlcReadResponse = &DefaultPlcReadResponse{}
//go:generate plc4xGenerator -type=DefaultPlcReadResponse
type DefaultPlcReadResponse struct {
request apiModel.PlcReadRequest
- values map[string]*ResponseItem
+ values map[string]*PlcResponseItem
}
func NewDefaultPlcReadResponse(request apiModel.PlcReadRequest, responseCodes map[string]apiModel.PlcResponseCode, values map[string]apiValues.PlcValue) apiModel.PlcReadResponse {
- valueMap := map[string]*ResponseItem{}
+ valueMap := map[string]*PlcResponseItem{}
for name, code := range responseCodes {
value := values[name]
- valueMap[name] = NewResponseItem(code, value)
+ valueMap[name] = NewPlcResponseItem(code, value)
}
return &DefaultPlcReadResponse{
request: request,
diff --git a/plc4go/spi/model/DefaultPlcReadResponse_test.go b/plc4go/spi/model/DefaultPlcReadResponse_test.go
index 8f3cd2ae2ee..693ba984c7c 100644
--- a/plc4go/spi/model/DefaultPlcReadResponse_test.go
+++ b/plc4go/spi/model/DefaultPlcReadResponse_test.go
@@ -32,7 +32,7 @@ import (
func TestDefaultPlcReadResponse_GetRequest(t *testing.T) {
type fields struct {
request apiModel.PlcReadRequest
- values map[string]*ResponseItem
+ values map[string]*PlcResponseItem
}
tests := []struct {
name string
@@ -57,7 +57,7 @@ func TestDefaultPlcReadResponse_GetRequest(t *testing.T) {
func TestDefaultPlcReadResponse_GetResponseCode(t *testing.T) {
type fields struct {
request apiModel.PlcReadRequest
- values map[string]*ResponseItem
+ values map[string]*PlcResponseItem
}
type args struct {
name string
@@ -75,7 +75,7 @@ func TestDefaultPlcReadResponse_GetResponseCode(t *testing.T) {
{
name: "get it",
fields: fields{
- values: map[string]*ResponseItem{
+ values: map[string]*PlcResponseItem{
"something": {
code: apiModel.PlcResponseCode_OK,
},
@@ -101,7 +101,7 @@ func TestDefaultPlcReadResponse_GetResponseCode(t *testing.T) {
func TestDefaultPlcReadResponse_GetTagNames(t *testing.T) {
type fields struct {
request apiModel.PlcReadRequest
- values map[string]*ResponseItem
+ values map[string]*PlcResponseItem
}
tests := []struct {
name string
@@ -112,7 +112,7 @@ func TestDefaultPlcReadResponse_GetTagNames(t *testing.T) {
name: "get it",
fields: fields{
request: NewDefaultPlcReadRequest(nil, []string{"tag1", "tag2"}, nil, nil),
- values: map[string]*ResponseItem{
+ values: map[string]*PlcResponseItem{
"tag1": nil,
"tag2": nil,
},
@@ -134,7 +134,7 @@ func TestDefaultPlcReadResponse_GetTagNames(t *testing.T) {
func TestDefaultPlcReadResponse_GetValue(t *testing.T) {
type fields struct {
request apiModel.PlcReadRequest
- values map[string]*ResponseItem
+ values map[string]*PlcResponseItem
}
type args struct {
name string
@@ -152,7 +152,7 @@ func TestDefaultPlcReadResponse_GetValue(t *testing.T) {
{
name: "get it",
fields: fields{
- values: map[string]*ResponseItem{
+ values: map[string]*PlcResponseItem{
"something": {
code: apiModel.PlcResponseCode_OK,
value: spiValues.NewPlcSTRING("yes"),
@@ -179,7 +179,7 @@ func TestDefaultPlcReadResponse_GetValue(t *testing.T) {
func TestDefaultPlcReadResponse_IsAPlcMessage(t *testing.T) {
type fields struct {
request apiModel.PlcReadRequest
- values map[string]*ResponseItem
+ values map[string]*PlcResponseItem
}
tests := []struct {
name string
@@ -215,7 +215,7 @@ func TestNewDefaultPlcReadResponse(t *testing.T) {
}{
{
name: "create it",
- want: &DefaultPlcReadResponse{values: map[string]*ResponseItem{}},
+ want: &DefaultPlcReadResponse{values: map[string]*PlcResponseItem{}},
},
}
for _, tt := range tests {
diff --git a/plc4go/spi/model/ResponseItem.go b/plc4go/spi/model/PlcResponseItem.go
similarity index 77%
rename from plc4go/spi/model/ResponseItem.go
rename to plc4go/spi/model/PlcResponseItem.go
index 4a08cfc3e4e..92217cca62f 100644
--- a/plc4go/spi/model/ResponseItem.go
+++ b/plc4go/spi/model/PlcResponseItem.go
@@ -24,23 +24,23 @@ import (
"github.com/apache/plc4x/plc4go/pkg/api/values"
)
-//go:generate plc4xGenerator -type=ResponseItem
-type ResponseItem struct {
+//go:generate plc4xGenerator -type=PlcResponseItem
+type PlcResponseItem struct {
code apiModel.PlcResponseCode `stringer:"true"`
value values.PlcValue
}
-func NewResponseItem(code apiModel.PlcResponseCode, value values.PlcValue) *ResponseItem {
- return &ResponseItem{
+func NewPlcResponseItem(code apiModel.PlcResponseCode, value values.PlcValue) *PlcResponseItem {
+ return &PlcResponseItem{
code: code,
value: value,
}
}
-func (r *ResponseItem) GetCode() apiModel.PlcResponseCode {
+func (r *PlcResponseItem) GetCode() apiModel.PlcResponseCode {
return r.code
}
-func (r *ResponseItem) GetValue() values.PlcValue {
+func (r *PlcResponseItem) GetValue() values.PlcValue {
return r.value
}
diff --git a/plc4go/spi/model/ResponseItem_plc4xgen.go b/plc4go/spi/model/PlcResponseItem_plc4xgen.go
similarity index 85%
rename from plc4go/spi/model/ResponseItem_plc4xgen.go
rename to plc4go/spi/model/PlcResponseItem_plc4xgen.go
index 636f712936e..de9d217a615 100644
--- a/plc4go/spi/model/ResponseItem_plc4xgen.go
+++ b/plc4go/spi/model/PlcResponseItem_plc4xgen.go
@@ -17,7 +17,7 @@
* under the License.
*/
-// Code generated by "plc4xGenerator -type=ResponseItem"; DO NOT EDIT.
+// Code generated by "plc4xGenerator -type=PlcResponseItem"; DO NOT EDIT.
package model
@@ -30,7 +30,7 @@ import (
var _ = fmt.Printf
-func (d *ResponseItem) Serialize() ([]byte, error) {
+func (d *PlcResponseItem) Serialize() ([]byte, error) {
if d == nil {
return nil, fmt.Errorf("(*DeviceInfoCache)(nil)")
}
@@ -41,11 +41,11 @@ func (d *ResponseItem) Serialize() ([]byte, error) {
return wb.GetBytes(), nil
}
-func (d *ResponseItem) SerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.WriteBuffer) error {
+func (d *PlcResponseItem) SerializeWithWriteBuffer(ctx context.Context, writeBuffer utils.WriteBuffer) error {
if d == nil {
return fmt.Errorf("(*DeviceInfoCache)(nil)")
}
- if err := writeBuffer.PushContext("ResponseItem"); err != nil {
+ if err := writeBuffer.PushContext("PlcResponseItem"); err != nil {
return err
}
@@ -71,13 +71,13 @@ func (d *ResponseItem) SerializeWithWriteBuffer(ctx context.Context, writeBuffer
}
}
}
- if err := writeBuffer.PopContext("ResponseItem"); err != nil {
+ if err := writeBuffer.PopContext("PlcResponseItem"); err != nil {
return err
}
return nil
}
-func (d *ResponseItem) String() string {
+func (d *PlcResponseItem) String() string {
if alternateStringer, ok := any(d).(utils.AlternateStringer); ok {
if alternateString, use := alternateStringer.AlternateString(); use {
return alternateString
diff --git a/plc4go/spi/model/render_test.go b/plc4go/spi/model/render_test.go
index a20556995b1..84e45c1f271 100644
--- a/plc4go/spi/model/render_test.go
+++ b/plc4go/spi/model/render_test.go
@@ -67,7 +67,7 @@ func TestRenderTest(t *testing.T) {
&DefaultPlcWriteRequest{DefaultPlcTagRequest: NewDefaultPlcTagRequest(nil, nil)},
&DefaultPlcWriteRequestResult{},
&DefaultPlcWriteResponse{},
- &ResponseItem{},
+ &PlcResponseItem{},
}
for _, sut := range suts {
t.Run(fmt.Sprintf("%T", sut), func(t *testing.T) {
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/PlcConnection.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/PlcConnection.java
index 560e29c9395..54cde7c211b 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/PlcConnection.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/PlcConnection.java
@@ -22,6 +22,7 @@
import org.apache.plc4x.java.api.messages.*;
import org.apache.plc4x.java.api.metadata.PlcConnectionMetadata;
import org.apache.plc4x.java.api.model.PlcTag;
+import org.apache.plc4x.java.api.value.PlcValue;
import java.util.Optional;
import java.util.concurrent.CompletableFuture;
@@ -63,6 +64,8 @@ public interface PlcConnection extends AutoCloseable {
*/
Optional parseTagAddress(String tagAddress);
+ Optional parseTagValue(PlcTag tag, Object... values);
+
/**
* Provides connection metadata.
*/
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/exceptions/PlcTagNotFoundException.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/exceptions/PlcTagNotFoundException.java
new file mode 100644
index 00000000000..e417d18b9c4
--- /dev/null
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/exceptions/PlcTagNotFoundException.java
@@ -0,0 +1,43 @@
+/*
+ * 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.api.exceptions;
+
+/**
+ * Indicates an invalid tag address.
+ */
+public class PlcTagNotFoundException extends PlcRuntimeException {
+
+ private static final long serialVersionUID = 1L;
+ private final String tagToBeParsed;
+
+ public PlcTagNotFoundException(String tagToBeParsed) {
+ super(tagToBeParsed + " not found");
+ this.tagToBeParsed = tagToBeParsed;
+ }
+
+ public PlcTagNotFoundException(String tagToBeParsed, Throwable cause) {
+ super(tagToBeParsed + " not found", cause);
+ this.tagToBeParsed = tagToBeParsed;
+ }
+
+ public String getTagToBeParsed() {
+ return tagToBeParsed;
+ }
+
+}
diff --git a/plc4j/api/src/main/java/org/apache/plc4x/java/api/messages/PlcTagRequest.java b/plc4j/api/src/main/java/org/apache/plc4x/java/api/messages/PlcTagRequest.java
index 3b98fdd01aa..b6a9f08e0e2 100644
--- a/plc4j/api/src/main/java/org/apache/plc4x/java/api/messages/PlcTagRequest.java
+++ b/plc4j/api/src/main/java/org/apache/plc4x/java/api/messages/PlcTagRequest.java
@@ -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;
@@ -33,7 +34,9 @@ public interface PlcTagRequest extends PlcRequest {
LinkedHashSet getTagNames();
- PlcTag getTag(String name);
+ PlcResponseCode getTagResponseCode(String tagName);
+
+ PlcTag getTag(String tagName);
List getTags();
diff --git a/plc4j/drivers/ab-eth/src/main/java/org/apache/plc4x/java/abeth/AbEthDriver.java b/plc4j/drivers/ab-eth/src/main/java/org/apache/plc4x/java/abeth/AbEthDriver.java
index c088dc74102..877d8b8274b 100644
--- a/plc4j/drivers/ab-eth/src/main/java/org/apache/plc4x/java/abeth/AbEthDriver.java
+++ b/plc4j/drivers/ab-eth/src/main/java/org/apache/plc4x/java/abeth/AbEthDriver.java
@@ -22,13 +22,11 @@
import org.apache.plc4x.java.abeth.configuration.AbEthConfiguration;
import org.apache.plc4x.java.abeth.configuration.AbEthTcpTransportConfiguration;
import org.apache.plc4x.java.abeth.tag.AbEthTag;
-import org.apache.plc4x.java.abeth.tag.AbEthTagHandler;
import org.apache.plc4x.java.abeth.protocol.AbEthProtocolLogic;
import org.apache.plc4x.java.abeth.readwrite.CIPEncapsulationPacket;
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;
@@ -77,16 +75,6 @@ protected List getSupportedTransportCodes() {
return Collections.singletonList("tcp");
}
- @Override
- 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
diff --git a/plc4j/drivers/ab-eth/src/main/java/org/apache/plc4x/java/abeth/protocol/AbEthProtocolLogic.java b/plc4j/drivers/ab-eth/src/main/java/org/apache/plc4x/java/abeth/protocol/AbEthProtocolLogic.java
index 35e0d93aa39..d5c25986a23 100644
--- a/plc4j/drivers/ab-eth/src/main/java/org/apache/plc4x/java/abeth/protocol/AbEthProtocolLogic.java
+++ b/plc4j/drivers/ab-eth/src/main/java/org/apache/plc4x/java/abeth/protocol/AbEthProtocolLogic.java
@@ -21,6 +21,7 @@
import org.apache.plc4x.java.abeth.configuration.AbEthConfiguration;
import org.apache.plc4x.java.abeth.readwrite.*;
import org.apache.plc4x.java.abeth.tag.AbEthTag;
+import org.apache.plc4x.java.abeth.tag.AbEthTagHandler;
import org.apache.plc4x.java.api.messages.PlcReadRequest;
import org.apache.plc4x.java.api.messages.PlcReadResponse;
import org.apache.plc4x.java.api.messages.PlcResponse;
@@ -30,11 +31,13 @@
import org.apache.plc4x.java.spi.ConversationContext;
import org.apache.plc4x.java.spi.Plc4xProtocolBase;
import org.apache.plc4x.java.spi.configuration.HasConfiguration;
+import org.apache.plc4x.java.spi.connection.PlcTagHandler;
import org.apache.plc4x.java.spi.messages.DefaultPlcReadResponse;
-import org.apache.plc4x.java.spi.messages.utils.ResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.DefaultPlcResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.PlcResponseItem;
import org.apache.plc4x.java.spi.transaction.RequestTransactionManager;
+import org.apache.plc4x.java.spi.values.DefaultPlcValueHandler;
import org.apache.plc4x.java.spi.values.PlcINT;
-import org.apache.plc4x.java.spi.values.PlcValueHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -67,6 +70,11 @@ public void setConfiguration(AbEthConfiguration configuration) {
this.tm = new RequestTransactionManager(1);
}
+ @Override
+ public PlcTagHandler getTagHandler() {
+ return new AbEthTagHandler();
+ }
+
@Override
public void close(ConversationContext context) {
tm.shutdown();
@@ -74,7 +82,7 @@ public void close(ConversationContext context) {
@Override
public void onConnect(ConversationContext context) {
- logger.debug("Sending COTP Connection Request");
+ logger.debug("Sending Connection Request");
CIPEncapsulationConnectionRequest connectionRequest =
new CIPEncapsulationConnectionRequest(0L, 0L, emptySenderContext, 0L);
context.sendRequest(connectionRequest)
@@ -89,7 +97,7 @@ public void onConnect(ConversationContext context) {
@Override
public CompletableFuture read(PlcReadRequest readRequest) {
- // TODO: Warning ... we are senging one request per tag ... the result has to be merged back together ...
+ // TODO: Warning ... we are sending one request per tag ... the result has to be merged back together ...
for (String tagName : readRequest.getTagNames()) {
PlcTag tag = readRequest.getTag(tagName);
if (!(tag instanceof AbEthTag)) {
@@ -115,7 +123,7 @@ public CompletableFuture read(PlcReadRequest readRequest) {
CompletableFuture future = new CompletableFuture<>();
RequestTransactionManager.RequestTransaction transaction = tm.startRequest();
- transaction.submit(() -> context.sendRequest(read)
+ transaction.submit(() -> conversationContext.sendRequest(read)
.expectResponse(CIPEncapsulationPacket.class, REQUEST_TIMEOUT)
.onTimeout(future::completeExceptionally)
.onError((p, e) -> future.completeExceptionally(e))
@@ -141,7 +149,7 @@ public CompletableFuture read(PlcReadRequest readRequest) {
private PlcResponse decodeReadResponse(
CIPEncapsulationReadResponse plcReadResponse, PlcReadRequest plcReadRequest) {
- Map> values = new HashMap<>();
+ Map> values = new HashMap<>();
for (String tagName : plcReadRequest.getTagNames()) {
AbEthTag tag = (AbEthTag) plcReadRequest.getTag(tagName);
PlcResponseCode responseCode = decodeResponseCode(plcReadResponse.getResponse().getStatus());
@@ -157,7 +165,7 @@ private PlcResponse decodeReadResponse(
if (data.size() == 1) {
plcValue = new PlcINT(data.get(0));
} else {
- plcValue = PlcValueHandler.of(data);
+ plcValue = DefaultPlcValueHandler.of(tag, data);
}
}
break;
@@ -166,9 +174,9 @@ private PlcResponse decodeReadResponse(
DF1CommandResponseMessageProtectedTypedLogicalRead df1PTLR = (DF1CommandResponseMessageProtectedTypedLogicalRead) plcReadResponse.getResponse();
List data = df1PTLR.getData();
if (((data.get(1) >> 7) & 1) == 0) {
- plcValue = PlcValueHandler.of((data.get(1) << 8) + data.get(0)); // positive number
+ plcValue = DefaultPlcValueHandler.of(tag, (data.get(1) << 8) + data.get(0)); // positive number
} else {
- plcValue = PlcValueHandler.of((((~data.get(1) & 0b01111111) << 8) + (-data.get(0) & 0b11111111)) * -1); // negative number
+ plcValue = DefaultPlcValueHandler.of(tag, (((~data.get(1) & 0b01111111) << 8) + (-data.get(0) & 0b11111111)) * -1); // negative number
}
}
break;
@@ -177,9 +185,9 @@ private PlcResponse decodeReadResponse(
DF1CommandResponseMessageProtectedTypedLogicalRead df1PTLR = (DF1CommandResponseMessageProtectedTypedLogicalRead) plcReadResponse.getResponse();
List data = df1PTLR.getData();
if (((data.get(3) >> 7) & 1) == 0) {
- plcValue = PlcValueHandler.of((data.get(3) << 24) + (data.get(2) << 16) + (data.get(1) << 8) + data.get(0)); // positive number
+ plcValue = DefaultPlcValueHandler.of(tag, (data.get(3) << 24) + (data.get(2) << 16) + (data.get(1) << 8) + data.get(0)); // positive number
} else {
- plcValue = PlcValueHandler.of((((~data.get(3) & 0b01111111) << 24) + ((-data.get(2) & 0b11111111) << 16) + ((-data.get(1) & 0b11111111) << 8) + (-data.get(0) & 0b11111111)) * -1); // negative number
+ plcValue = DefaultPlcValueHandler.of(tag, (((~data.get(3) & 0b01111111) << 24) + ((-data.get(2) & 0b11111111) << 16) + ((-data.get(1) & 0b11111111) << 8) + (-data.get(0) & 0b11111111)) * -1); // negative number
}
}
break;
@@ -188,9 +196,9 @@ private PlcResponse decodeReadResponse(
DF1CommandResponseMessageProtectedTypedLogicalRead df1PTLR = (DF1CommandResponseMessageProtectedTypedLogicalRead) plcReadResponse.getResponse();
List data = df1PTLR.getData();
if (tag.getBitNumber() < 8) {
- plcValue = PlcValueHandler.of((data.get(0) & (1 << tag.getBitNumber())) != 0); // read from first byte
+ plcValue = DefaultPlcValueHandler.of(tag, (data.get(0) & (1 << tag.getBitNumber())) != 0); // read from first byte
} else {
- plcValue = PlcValueHandler.of((data.get(1) & (1 << (tag.getBitNumber() - 8))) != 0); // read from second byte
+ plcValue = DefaultPlcValueHandler.of(tag, (data.get(1) & (1 << (tag.getBitNumber() - 8))) != 0); // read from second byte
}
}
break;
@@ -202,7 +210,7 @@ private PlcResponse decodeReadResponse(
logger.warn("Some other error occurred casting tag {}, TagInformation: {}", tagName, tag, e);
}
}
- ResponseItem result = new ResponseItem<>(responseCode, plcValue);
+ PlcResponseItem result = new DefaultPlcResponseItem<>(responseCode, plcValue);
values.put(tagName, result);
}
diff --git a/plc4j/drivers/ab-eth/src/main/java/org/apache/plc4x/java/abeth/protocol/Plc4xAbEthProtocol.java b/plc4j/drivers/ab-eth/src/main/java/org/apache/plc4x/java/abeth/protocol/Plc4xAbEthProtocol.java
index 6c00ce572f1..0d1b1e85b5e 100644
--- a/plc4j/drivers/ab-eth/src/main/java/org/apache/plc4x/java/abeth/protocol/Plc4xAbEthProtocol.java
+++ b/plc4j/drivers/ab-eth/src/main/java/org/apache/plc4x/java/abeth/protocol/Plc4xAbEthProtocol.java
@@ -34,9 +34,9 @@
import org.apache.plc4x.java.spi.events.ConnectedEvent;
import org.apache.plc4x.java.spi.messages.DefaultPlcReadResponse;
import org.apache.plc4x.java.spi.messages.PlcRequestContainer;
-import org.apache.plc4x.java.spi.messages.utils.ResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.DefaultPlcResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.PlcResponseItem;
import org.apache.plc4x.java.spi.values.*;
-import org.apache.plc4x.java.spi.values.PlcValueHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -163,7 +163,7 @@ private PlcResponse decodeReadResponse(
PlcReadRequest plcReadRequest = (PlcReadRequest) requestContainer.getRequest();
- Map> values = new HashMap<>();
+ Map> values = new HashMap<>();
for (String tagName : plcReadRequest.getTagNames()) {
AbEthTag tag = (AbEthTag) plcReadRequest.getTag(tagName);
PlcResponseCode responseCode = decodeResponseCode(plcReadResponse.getResponse().getStatus());
@@ -179,7 +179,7 @@ private PlcResponse decodeReadResponse(
if(data.size() == 1) {
plcValue = new PlcINT(data.get(0));
} else {
- plcValue = PlcValueHandler.of(data);
+ plcValue = DefaultPlcValueHandler.of(tag, data);
}
}
break;
@@ -188,9 +188,9 @@ private PlcResponse decodeReadResponse(
DF1CommandResponseMessageProtectedTypedLogicalRead df1PTLR = (DF1CommandResponseMessageProtectedTypedLogicalRead) plcReadResponse.getResponse();
List data = df1PTLR.getData();
if (((data.get(1)>> 7) & 1) == 0) {
- plcValue = PlcValueHandler.of((data.get(1) << 8) + data.get(0)); // positive number
+ plcValue = DefaultPlcValueHandler.of(tag, (data.get(1) << 8) + data.get(0)); // positive number
} else {
- plcValue = PlcValueHandler.of((((~data.get(1) & 0b01111111) << 8) + (-data.get(0) & 0b11111111)) * -1); // negative number
+ plcValue = DefaultPlcValueHandler.of(tag, (((~data.get(1) & 0b01111111) << 8) + (-data.get(0) & 0b11111111)) * -1); // negative number
}
}
break;
@@ -199,9 +199,9 @@ private PlcResponse decodeReadResponse(
DF1CommandResponseMessageProtectedTypedLogicalRead df1PTLR = (DF1CommandResponseMessageProtectedTypedLogicalRead) plcReadResponse.getResponse();
List data = df1PTLR.getData();
if (((data.get(3)>> 7) & 1) == 0) {
- plcValue = PlcValueHandler.of((data.get(3) << 24) + (data.get(2) << 16) + (data.get(1) << 8) + data.get(0)); // positive number
+ plcValue = DefaultPlcValueHandler.of(tag, (data.get(3) << 24) + (data.get(2) << 16) + (data.get(1) << 8) + data.get(0)); // positive number
} else {
- plcValue = PlcValueHandler.of((((~data.get(3) & 0b01111111) << 24) + ((-data.get(2) & 0b11111111) << 16)+ ((-data.get(1) & 0b11111111) << 8) + (-data.get(0) & 0b11111111)) * -1); // negative number
+ plcValue = DefaultPlcValueHandler.of(tag, (((~data.get(3) & 0b01111111) << 24) + ((-data.get(2) & 0b11111111) << 16)+ ((-data.get(1) & 0b11111111) << 8) + (-data.get(0) & 0b11111111)) * -1); // negative number
}
}
break;
@@ -210,9 +210,9 @@ private PlcResponse decodeReadResponse(
DF1CommandResponseMessageProtectedTypedLogicalRead df1PTLR = (DF1CommandResponseMessageProtectedTypedLogicalRead) plcReadResponse.getResponse();
List data = df1PTLR.getData();
if (tag.getBitNumber() < 8) {
- plcValue = PlcValueHandler.of((data.get(0) & (1 << tag.getBitNumber())) != 0); // read from first byte
+ plcValue = DefaultPlcValueHandler.of(tag, (data.get(0) & (1 << tag.getBitNumber())) != 0); // read from first byte
} else {
- plcValue = PlcValueHandler.of((data.get(1) & (1 << (tag.getBitNumber() - 8) )) != 0); // read from second byte
+ plcValue = DefaultPlcValueHandler.of(tag, (data.get(1) & (1 << (tag.getBitNumber() - 8) )) != 0); // read from second byte
}
}
break;
@@ -225,7 +225,7 @@ private PlcResponse decodeReadResponse(
logger.warn("Some other error occurred casting field {}, TagInformation: {}",tagName, tag,e);
}
}
- ResponseItem result = new ResponseItem<>(responseCode, plcValue);
+ PlcResponseItem result = new DefaultPlcResponseItem<>(responseCode, plcValue);
values.put(tagName, result);
}
diff --git a/plc4j/drivers/ab-eth/src/test/resources/logback-test.xml b/plc4j/drivers/ab-eth/src/test/resources/logback-test.xml
index 2b9cea25dc8..941f1546f84 100644
--- a/plc4j/drivers/ab-eth/src/test/resources/logback-test.xml
+++ b/plc4j/drivers/ab-eth/src/test/resources/logback-test.xml
@@ -29,7 +29,7 @@
-
+
diff --git a/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/AdsPlcDriver.java b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/AdsPlcDriver.java
index 5ea45433677..641bc781afb 100644
--- a/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/AdsPlcDriver.java
+++ b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/AdsPlcDriver.java
@@ -22,14 +22,12 @@
import org.apache.plc4x.java.ads.configuration.AdsConfiguration;
import org.apache.plc4x.java.ads.configuration.AdsTcpTransportConfiguration;
import org.apache.plc4x.java.ads.discovery.AdsPlcDiscoverer;
-import org.apache.plc4x.java.ads.tag.AdsTagHandler;
import org.apache.plc4x.java.ads.protocol.AdsProtocolLogic;
import org.apache.plc4x.java.ads.readwrite.AmsTCPPacket;
import org.apache.plc4x.java.spi.configuration.PlcConnectionConfiguration;
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;
@@ -116,16 +114,6 @@ protected List getSupportedTransportCodes() {
return Collections.singletonList("tcp");
}
- @Override
- 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
diff --git a/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/protocol/AdsProtocolLogic.java b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/protocol/AdsProtocolLogic.java
index bc4e3089286..5a7e9e47bc1 100644
--- a/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/protocol/AdsProtocolLogic.java
+++ b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/protocol/AdsProtocolLogic.java
@@ -24,6 +24,7 @@
import org.apache.plc4x.java.ads.model.AdsSubscriptionHandle;
import org.apache.plc4x.java.ads.readwrite.*;
import org.apache.plc4x.java.ads.tag.AdsTag;
+import org.apache.plc4x.java.ads.tag.AdsTagHandler;
import org.apache.plc4x.java.ads.tag.DirectAdsStringTag;
import org.apache.plc4x.java.ads.tag.DirectAdsTag;
import org.apache.plc4x.java.ads.tag.SymbolicAdsTag;
@@ -40,9 +41,11 @@
import org.apache.plc4x.java.spi.ConversationContext;
import org.apache.plc4x.java.spi.Plc4xProtocolBase;
import org.apache.plc4x.java.spi.configuration.HasConfiguration;
+import org.apache.plc4x.java.spi.connection.PlcTagHandler;
import org.apache.plc4x.java.spi.generation.*;
import org.apache.plc4x.java.spi.messages.*;
-import org.apache.plc4x.java.spi.messages.utils.ResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.DefaultPlcResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.PlcResponseItem;
import org.apache.plc4x.java.spi.model.DefaultArrayInfo;
import org.apache.plc4x.java.spi.model.DefaultPlcConsumerRegistration;
import org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionTag;
@@ -112,6 +115,11 @@ public void setConfiguration(AdsConfiguration configuration) {
this.configuration = configuration;
}
+ @Override
+ public PlcTagHandler getTagHandler() {
+ return new AdsTagHandler();
+ }
+
@Override
public void onConnect(ConversationContext context) {
@@ -247,7 +255,7 @@ protected CompletableFuture setupAmsRoute(PlcUsernamePasswordAuthenticatio
new Thread(() -> {
LOGGER.debug("Setting up remote AMS routes.");
- SocketAddress localSocketAddress = context.getChannel().localAddress();
+ SocketAddress localSocketAddress = conversationContext.getChannel().localAddress();
InetAddress localAddress = ((InetSocketAddress) localSocketAddress).getAddress();
// Prepare the request message.
@@ -274,7 +282,7 @@ protected CompletableFuture setupAmsRoute(PlcUsernamePasswordAuthenticatio
addOrUpdateRouteRequest.serialize(writeBuffer);
// Get the target IP from the connection
- SocketAddress remoteSocketAddress = context.getChannel().remoteAddress();
+ SocketAddress remoteSocketAddress = conversationContext.getChannel().remoteAddress();
InetAddress remoteAddress = ((InetSocketAddress) remoteSocketAddress).getAddress();
// Create the UDP packet to the broadcast address.
@@ -513,7 +521,7 @@ public CompletableFuture browseWithInterceptor(PlcBrowseReque
itemArrayInfo.add(new DefaultPlcBrowseItemArrayInfo(
adsDataTypeArrayInfo.getLowerBound(), adsDataTypeArrayInfo.getUpperBound()));
}
- DefaultListPlcBrowseItem item = new DefaultListPlcBrowseItem(new SymbolicAdsTag(symbol.getName(), plc4xPlcValueType, arrayInfo), symbol.getName(),
+ DefaultPlcBrowseItemList item = new DefaultPlcBrowseItemList(new SymbolicAdsTag(symbol.getName(), plc4xPlcValueType, arrayInfo), symbol.getName(),
true, !symbol.getFlagReadOnly(), true, false, childMap, options, itemArrayInfo);
// Check if this item should be added to the result
@@ -576,7 +584,7 @@ protected List getBrowseItems(String basePath, long baseGroupId,
adsDataTypeArrayInfo.getLowerBound(), adsDataTypeArrayInfo.getUpperBound()));
}
// Add the type itself.
- values.add(new DefaultListPlcBrowseItem(new SymbolicAdsTag(
+ values.add(new DefaultPlcBrowseItemList(new SymbolicAdsTag(
basePath + "." + child.getPropertyName(), plc4xPlcValueType, arrayInfo), child.getPropertyName(),
true, parentWritable, true, false, childMap, options, itemArrayInfo));
}
@@ -592,10 +600,10 @@ public CompletableFuture ping(PlcPingRequest pingRequest) {
configuration.getSourceAmsNetId(), 800, 0, getInvokeId());
RequestTransactionManager.RequestTransaction readDeviceInfoTx = tm.startRequest();
- readDeviceInfoTx.submit(() -> context.sendRequest(new AmsTCPPacket(readDeviceInfoRequest))
+ readDeviceInfoTx.submit(() -> conversationContext.sendRequest(new AmsTCPPacket(readDeviceInfoRequest))
.expectResponse(AmsTCPPacket.class, Duration.ofMillis(configuration.getTimeoutRequest()))
- .onTimeout(e -> context.getChannel().pipeline().fireExceptionCaught(e))
- .onError((p, e) -> context.getChannel().pipeline().fireExceptionCaught(e))
+ .onTimeout(e -> conversationContext.getChannel().pipeline().fireExceptionCaught(e))
+ .onError((p, e) -> conversationContext.getChannel().pipeline().fireExceptionCaught(e))
.unwrap(AmsTCPPacket::getUserdata)
.check(userdata -> userdata.getInvokeId() == readDeviceInfoRequest.getInvokeId())
.only(AdsReadDeviceInfoResponse.class)
@@ -672,7 +680,7 @@ protected CompletableFuture 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 DefaultPlcResponseItem<>(PlcResponseCode.NOT_FOUND, null))));
}
CompletableFuture future = new CompletableFuture<>();
@@ -693,7 +701,7 @@ protected CompletableFuture singleRead(PlcReadRequest readReque
// Start a new request-transaction (Is ended in the response-handler)
RequestTransactionManager.RequestTransaction transaction = tm.startRequest();
- transaction.submit(() -> context.sendRequest(amsTCPPacket)
+ transaction.submit(() -> conversationContext.sendRequest(amsTCPPacket)
.expectResponse(AmsTCPPacket.class, Duration.ofMillis(configuration.getTimeoutRequest()))
.onTimeout(future::completeExceptionally)
.onError((p, e) -> future.completeExceptionally(e))
@@ -766,7 +774,7 @@ protected CompletableFuture multiRead(PlcReadRequest readReques
// Start a new request-transaction (Is ended in the response-handler)
RequestTransactionManager.RequestTransaction transaction = tm.startRequest();
- transaction.submit(() -> context.sendRequest(amsTCPPacket)
+ transaction.submit(() -> conversationContext.sendRequest(amsTCPPacket)
.expectResponse(AmsTCPPacket.class, Duration.ofMillis(configuration.getTimeoutRequest()))
.onTimeout(future::completeExceptionally)
.onError((p, e) -> future.completeExceptionally(e))
@@ -822,11 +830,11 @@ protected PlcReadResponse convertToPlc4xReadResponse(PlcReadRequest readRequest,
// Read the values next
if (readBuffer != null) {
- Map> values = new HashMap<>();
+ Map> values = new HashMap<>();
for (String tagName : readRequest.getTagNames()) {
// If the response-code was anything but OK, we don't need to parse the payload.
if(responseCodes.get(tagName) != PlcResponseCode.OK) {
- values.put(tagName, new ResponseItem<>(responseCodes.get(tagName), null));
+ values.put(tagName, new DefaultPlcResponseItem<>(responseCodes.get(tagName), null));
}
// If the response-code was ok, parse the data returned.
else {
@@ -849,7 +857,7 @@ private PlcResponseCode parsePlcResponseCode(ReturnCode adsResult) {
}
}
- private ResponseItem parseResponseItem(DirectAdsTag tag, ReadBuffer readBuffer) {
+ private PlcResponseItem parseResponseItem(DirectAdsTag tag, ReadBuffer readBuffer) {
try {
String dataTypeName = tag.getPlcDataType();
AdsDataTypeTableEntry adsDataTypeTableEntry;
@@ -872,7 +880,7 @@ private ResponseItem parseResponseItem(DirectAdsTag tag, ReadBuffer re
// Sometimes the ADS device just sends shorter strings than we asked for.
int remainingBytes = readBufferByteBased.getTotalBytes() - readBufferByteBased.getPos();
final int singleStringLength = Math.min(remainingBytes - 1, stringLength);
- return new ResponseItem<>(PlcResponseCode.OK, parsePlcValue(plcValueType, adsDataTypeTableEntry, singleStringLength, readBuffer));
+ return new DefaultPlcResponseItem<>(PlcResponseCode.OK, parsePlcValue(plcValueType, adsDataTypeTableEntry, singleStringLength, readBuffer));
} else {
// Fetch all
final PlcValue[] resultItems = IntStream.range(0, tag.getNumberOfElements()).mapToObj(i -> {
@@ -883,11 +891,11 @@ private ResponseItem parseResponseItem(DirectAdsTag tag, ReadBuffer re
}
return null;
}).toArray(PlcValue[]::new);
- return new ResponseItem<>(PlcResponseCode.OK, PlcValueHandler.of(resultItems));
+ return new DefaultPlcResponseItem<>(PlcResponseCode.OK, DefaultPlcValueHandler.of(tag, resultItems));
}
} catch (Exception e) {
LOGGER.warn(String.format("Error parsing tag item of type: '%s'", tag.getPlcDataType()), e);
- return new ResponseItem<>(PlcResponseCode.INTERNAL_ERROR, null);
+ return new DefaultPlcResponseItem<>(PlcResponseCode.INTERNAL_ERROR, null);
}
}
@@ -1046,7 +1054,7 @@ protected CompletableFuture singleWrite(PlcWriteRequest writeR
// Start a new request-transaction (Is ended in the response-handler)
RequestTransactionManager.RequestTransaction transaction = tm.startRequest();
- transaction.submit(() -> context.sendRequest(amsTCPPacket)
+ transaction.submit(() -> conversationContext.sendRequest(amsTCPPacket)
.expectResponse(AmsTCPPacket.class, Duration.ofMillis(configuration.getTimeoutRequest()))
.onTimeout(future::completeExceptionally)
.onError((p, e) -> future.completeExceptionally(e))
@@ -1124,7 +1132,7 @@ protected CompletableFuture multiWrite(PlcWriteRequest writeRe
// Start a new request-transaction (Is ended in the response-handler)
RequestTransactionManager.RequestTransaction transaction = tm.startRequest();
- transaction.submit(() -> context.sendRequest(amsTCPPacket)
+ transaction.submit(() -> conversationContext.sendRequest(amsTCPPacket)
.expectResponse(AmsTCPPacket.class, Duration.ofMillis(configuration.getTimeoutRequest()))
.onTimeout(future::completeExceptionally)
.onError((p, e) -> future.completeExceptionally(e))
@@ -1329,7 +1337,7 @@ private CompletableFuture executeSubscribe(PlcSubscript
})
.collect(Collectors.toList());
- Map> responses = new HashMap<>();
+ Map> responses = new HashMap<>();
// Start the first request-transaction (it is ended in the response-handler).
RequestTransactionManager.RequestTransaction transaction = tm.startRequest();
@@ -1347,7 +1355,7 @@ private CompletableFuture executeSubscribe(PlcSubscript
private Runnable subscribeRecursively(PlcSubscriptionRequest subscriptionRequest,
Iterator tagNames,
Map resolvedTags,
- Map> responses,
+ Map> responses,
CompletableFuture future,
Iterator amsTCPPackets,
RequestTransactionManager.RequestTransaction transaction) {
@@ -1355,7 +1363,7 @@ private Runnable subscribeRecursively(PlcSubscriptionRequest subscriptionRequest
AmsTCPPacket packet = amsTCPPackets.next();
boolean hasMorePackets = amsTCPPackets.hasNext();
String tagName = tagNames.next();
- context.sendRequest(packet)
+ conversationContext.sendRequest(packet)
.expectResponse(AmsTCPPacket.class, Duration.ofMillis(configuration.getTimeoutRequest()))
.onTimeout(future::completeExceptionally)
.onError((p, e) -> future.completeExceptionally(e))
@@ -1368,7 +1376,7 @@ private Runnable subscribeRecursively(PlcSubscriptionRequest subscriptionRequest
AdsDataTypeTableEntry adsDataTypeTableEntry = dataTypeTable.get((resolvedTags.get((AdsTag) subscriptionTag.getTag())).getPlcDataType());
// Collect notification handle from individual response.
- responses.put(tagName, new ResponseItem<>(
+ responses.put(tagName, new DefaultPlcResponseItem<>(
parsePlcResponseCode(response.getResult()),
new AdsSubscriptionHandle(this,
tagName,
@@ -1436,7 +1444,7 @@ private Runnable unsubscribeRecursively(PlcUnsubscriptionRequest unsubscriptionR
return () -> {
AmsTCPPacket packet = amsTCPPackets.next();
boolean hasMorePackets = amsTCPPackets.hasNext();
- context.sendRequest(packet)
+ conversationContext.sendRequest(packet)
.expectResponse(AmsTCPPacket.class, Duration.ofMillis(configuration.getTimeoutRequest()))
.onTimeout(future::completeExceptionally)
.onError((p, e) -> future.completeExceptionally(e))
@@ -1498,11 +1506,11 @@ protected void decode(ConversationContext context, AmsTCPPacket ms
}
}
- private Map> convertSampleToPlc4XResult(AdsSubscriptionHandle subscriptionHandle, byte[] data) throws
+ private Map> convertSampleToPlc4XResult(AdsSubscriptionHandle subscriptionHandle, byte[] data) throws
ParseException {
- Map> values = new HashMap<>();
+ Map> values = new HashMap<>();
ReadBufferByteBased readBuffer = new ReadBufferByteBased(data, ByteOrder.LITTLE_ENDIAN);
- values.put(subscriptionHandle.getTagName(), new ResponseItem<>(PlcResponseCode.OK,
+ values.put(subscriptionHandle.getTagName(), new DefaultPlcResponseItem<>(PlcResponseCode.OK,
DataItem.staticParse(readBuffer, getPlcValueTypeForAdsDataType(subscriptionHandle.getAdsDataType()), data.length)));
return values;
}
@@ -1614,7 +1622,7 @@ protected CompletableFuture resolveSingleSymbolicAddress(SymbolicAdsTag sy
// Start a new request-transaction (Is ended in the response-handler)
RequestTransactionManager.RequestTransaction transaction = tm.startRequest();
- transaction.submit(() -> context.sendRequest(amsTCPPacket)
+ transaction.submit(() -> conversationContext.sendRequest(amsTCPPacket)
.expectResponse(AmsTCPPacket.class, Duration.ofMillis(configuration.getTimeoutRequest()))
.onTimeout(future::completeExceptionally)
.onError((p, e) -> future.completeExceptionally(e))
@@ -1665,7 +1673,7 @@ protected CompletableFuture resolveMultipleSymbolicAddresses(List context.sendRequest(amsTCPPacket)
+ transaction.submit(() -> conversationContext.sendRequest(amsTCPPacket)
.expectResponse(AmsTCPPacket.class, Duration.ofMillis(configuration.getTimeoutRequest()))
.onTimeout(future::completeExceptionally)
.onError((p, e) -> future.completeExceptionally(e))
diff --git a/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/tag/SymbolicAdsTag.java b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/tag/SymbolicAdsTag.java
index 8aa5c41cdee..a708ee97a94 100644
--- a/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/tag/SymbolicAdsTag.java
+++ b/plc4j/drivers/ads/src/main/java/org/apache/plc4x/java/ads/tag/SymbolicAdsTag.java
@@ -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("^(?.+)");
+ private static final Pattern SYMBOLIC_ADDRESS_PATTERN = Pattern.compile("^([\\w_]+)(\"[\"\\d*]\")*(\\.(\\w+)(\"[\"\\d*]\")*)*");
private final String symbolicAddress;
@@ -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) {
@@ -120,4 +117,5 @@ public void serialize(WriteBuffer writeBuffer) throws SerializationException {
writeBuffer.popContext(getClass().getSimpleName());
}
+
}
diff --git a/plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/tag/SymbolicAdsTagTest.java b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/tag/SymbolicAdsTagTest.java
new file mode 100644
index 00000000000..8ec9bc0038c
--- /dev/null
+++ b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/java/ads/tag/SymbolicAdsTagTest.java
@@ -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() {
+
+
+ }
+
+}
\ No newline at end of file
diff --git a/plc4j/drivers/ads/src/test/java/org/apache/plc4x/protocol/ads/AdsDriverIT.java b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/protocol/ads/AdsDriverIT.java
index 15a827b81fc..6f1f5c2c7d9 100644
--- a/plc4j/drivers/ads/src/test/java/org/apache/plc4x/protocol/ads/AdsDriverIT.java
+++ b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/protocol/ads/AdsDriverIT.java
@@ -24,7 +24,7 @@
public class AdsDriverIT extends DriverTestsuiteRunner {
public AdsDriverIT() {
- super("/protocols/ads/DriverTestsuite.xml");
+ super("/protocols/ads/DriverTestsuite.xml", true);
}
}
diff --git a/plc4j/drivers/ads/src/test/java/org/apache/plc4x/protocol/ads/ManualAdsBrowse.java b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/protocol/ads/ManualAdsBrowse.java
index f9240a3c871..5c850d372ea 100644
--- a/plc4j/drivers/ads/src/test/java/org/apache/plc4x/protocol/ads/ManualAdsBrowse.java
+++ b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/protocol/ads/ManualAdsBrowse.java
@@ -21,14 +21,15 @@
import org.apache.plc4x.java.api.PlcConnection;
import org.apache.plc4x.java.api.PlcDriverManager;
-import org.apache.plc4x.java.api.messages.PlcBrowseResponse;
public class ManualAdsBrowse {
public static void main(String[] args) throws Exception {
try (PlcConnection connection = PlcDriverManager.getDefault().getConnectionManager().getConnection("ads:tcp://192.168.23.20:48898?target-ams-port=851&source-ams-port=65534&source-ams-net-id=192.168.23.220.1.1&target-ams-net-id=192.168.23.20.1.1")){
- PlcBrowseResponse browseResponse = connection.browseRequestBuilder().addQuery("all", "*").build().execute().get();
- System.out.println(browseResponse);
+ connection.browseRequestBuilder().addQuery("all", "*").build().executeWithInterceptor(item -> {
+ System.out.printf("- %s%n", item.getTag().getAddressString());
+ return true;
+ }).get();
}
}
}
diff --git a/plc4j/drivers/ads/src/test/java/org/apache/plc4x/protocol/ads/ManualAdsDriverTest.java b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/protocol/ads/ManualAdsDriverTest.java
index b04acbbdf5e..d623a701c00 100644
--- a/plc4j/drivers/ads/src/test/java/org/apache/plc4x/protocol/ads/ManualAdsDriverTest.java
+++ b/plc4j/drivers/ads/src/test/java/org/apache/plc4x/protocol/ads/ManualAdsDriverTest.java
@@ -26,6 +26,7 @@
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
+import java.time.OffsetDateTime;
import java.util.HashMap;
import java.util.Map;
@@ -129,8 +130,12 @@ public static void main(String[] args) throws Exception {
children.put("hurz_LTIME", new PlcLTIME(Duration.parse("PT24015H23M12.034002044S")));
children.put("hurz_DATE", new PlcDATE(LocalDate.parse("1978-03-28")));
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")));
+ children.put("hurz_DATE_AND_TIME", new PlcDATE_AND_TIME(LocalDateTime.parse("1996-05-06T15:36:30").atOffset(OffsetDateTime.now().getOffset()).toLocalDateTime()));
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();
}
diff --git a/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/BacNetIpDriver.java b/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/BacNetIpDriver.java
index 28d1e9a2f12..ccffd6ddf5a 100644
--- a/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/BacNetIpDriver.java
+++ b/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/BacNetIpDriver.java
@@ -25,13 +25,11 @@
import org.apache.plc4x.java.bacnetip.configuration.BacNetPcapReplayTransportConfiguration;
import org.apache.plc4x.java.bacnetip.configuration.BacNetRawSocketTransportConfiguration;
import org.apache.plc4x.java.bacnetip.configuration.BacNetUdpTransportConfiguration;
-import org.apache.plc4x.java.bacnetip.tag.BacNetIpTagHandler;
import org.apache.plc4x.java.bacnetip.protocol.BacNetIpProtocolLogic;
import org.apache.plc4x.java.bacnetip.readwrite.BVLC;
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;
@@ -94,16 +92,6 @@ protected boolean canSubscribe() {
return true;
}
- @Override
- protected BacNetIpTagHandler getTagHandler() {
- return new BacNetIpTagHandler();
- }
-
- @Override
- protected org.apache.plc4x.java.api.value.PlcValueHandler getValueHandler() {
- return new PlcValueHandler();
- }
-
@Override
protected ProtocolStackConfigurer getStackConfigurer() {
return SingleProtocolStackConfigurer.builder(BVLC.class, BVLC::staticParse)
diff --git a/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/protocol/BacNetIpProtocolLogic.java b/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/protocol/BacNetIpProtocolLogic.java
index 2eddb897e5b..ecf8b79d403 100644
--- a/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/protocol/BacNetIpProtocolLogic.java
+++ b/plc4j/drivers/bacnet/src/main/java/org/apache/plc4x/java/bacnetip/protocol/BacNetIpProtocolLogic.java
@@ -32,17 +32,19 @@
import org.apache.plc4x.java.bacnetip.ede.model.EdeModel;
import org.apache.plc4x.java.bacnetip.tag.BacNetIpTag;
import org.apache.plc4x.java.bacnetip.readwrite.*;
+import org.apache.plc4x.java.bacnetip.tag.BacNetIpTagHandler;
import org.apache.plc4x.java.spi.ConversationContext;
import org.apache.plc4x.java.spi.Plc4xProtocolBase;
import org.apache.plc4x.java.spi.configuration.HasConfiguration;
+import org.apache.plc4x.java.spi.connection.PlcTagHandler;
import org.apache.plc4x.java.spi.messages.DefaultPlcSubscriptionEvent;
import org.apache.plc4x.java.spi.messages.DefaultPlcSubscriptionResponse;
import org.apache.plc4x.java.spi.messages.PlcSubscriber;
-import org.apache.plc4x.java.spi.messages.utils.ResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.DefaultPlcResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.PlcResponseItem;
import org.apache.plc4x.java.spi.model.DefaultPlcConsumerRegistration;
import org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionHandle;
import org.apache.plc4x.java.spi.values.*;
-import org.apache.plc4x.java.spi.values.PlcValueHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -85,6 +87,11 @@ public void setConfiguration(BacNetIpConfiguration configuration) {
}
}
+ @Override
+ public PlcTagHandler getTagHandler() {
+ return new BacNetIpTagHandler();
+ }
+
@Override
public void onConnect(ConversationContext context) {
if (context.isPassive()) {
@@ -163,8 +170,8 @@ private void decodeConfirmedRequest(APDUConfirmedRequest apduConfirmedRequest) {
enrichedPlcValue.put("address", new PlcSTRING(toString(curTag)));
// From the original BACNet tag
- enrichedPlcValue.put("tagNumber", PlcValueHandler.of(propertyValue.getPeekedTagHeader().getActualTagNumber()));
- enrichedPlcValue.put("lengthValueType", PlcValueHandler.of(propertyValue.getPeekedTagHeader().getActualLength()));
+ enrichedPlcValue.put("tagNumber", new PlcUSINT(propertyValue.getPeekedTagHeader().getActualTagNumber()));
+ enrichedPlcValue.put("lengthValueType", new PlcUSINT(propertyValue.getPeekedTagHeader().getActualLength()));
// Use the information in the edeModel to enrich the information.
if (edeModel != null) {
@@ -214,8 +221,8 @@ private void decodeUnconfirmedRequest(APDUUnconfirmedRequest unconfirmedRequest)
enrichedPlcValue.put("address", new PlcSTRING(toString(curTag)));
// From the original BACNet tag
- enrichedPlcValue.put("tagNumber", PlcValueHandler.of(baCnetTag.getActualTagNumber()));
- enrichedPlcValue.put("lengthValueType", PlcValueHandler.of(baCnetTag.getActualLength()));
+ enrichedPlcValue.put("tagNumber", new PlcUSINT(baCnetTag.getActualTagNumber()));
+ enrichedPlcValue.put("lengthValueType", new PlcUSINT(baCnetTag.getActualLength()));
// Use the information in the edeModel to enrich the information.
if (edeModel != null) {
@@ -244,9 +251,9 @@ private void decodeUnconfirmedRequest(APDUUnconfirmedRequest unconfirmedRequest)
@Override
public CompletableFuture subscribe(PlcSubscriptionRequest subscriptionRequest) {
- Map> values = new HashMap<>();
+ Map> values = new HashMap<>();
for (String tagName : subscriptionRequest.getTagNames()) {
- values.put(tagName, new ResponseItem<>(PlcResponseCode.OK, new DefaultPlcSubscriptionHandle(this)));
+ values.put(tagName, new DefaultPlcResponseItem<>(PlcResponseCode.OK, new DefaultPlcSubscriptionHandle(this)));
}
return CompletableFuture.completedFuture(new DefaultPlcSubscriptionResponse(subscriptionRequest, values));
}
@@ -268,7 +275,7 @@ public void unregister(PlcConsumerRegistration plcConsumerRegistration) {
protected void publishEvent(BacNetIpTag tag, PlcValue plcValue) {
// Create a subscription event from the input.
final PlcSubscriptionEvent event = new DefaultPlcSubscriptionEvent(Instant.now(),
- Collections.singletonMap("event", new ResponseItem<>(PlcResponseCode.OK, plcValue)));
+ Collections.singletonMap("event", new DefaultPlcResponseItem<>(PlcResponseCode.OK, plcValue)));
// Send the subscription event to all listeners.
for (Consumer consumer : consumerIdMap.values()) {
diff --git a/plc4j/drivers/bacnet/src/test/resources/logback-test.xml b/plc4j/drivers/bacnet/src/test/resources/logback-test.xml
index ad561b1796c..898c2820e6c 100644
--- a/plc4j/drivers/bacnet/src/test/resources/logback-test.xml
+++ b/plc4j/drivers/bacnet/src/test/resources/logback-test.xml
@@ -28,7 +28,7 @@
-
+
diff --git a/plc4j/drivers/c-bus/src/main/java/org/apache/plc4x/java/cbus/CBusDriver.java b/plc4j/drivers/c-bus/src/main/java/org/apache/plc4x/java/cbus/CBusDriver.java
index 300ffa9450f..1065a50c1bf 100644
--- a/plc4j/drivers/c-bus/src/main/java/org/apache/plc4x/java/cbus/CBusDriver.java
+++ b/plc4j/drivers/c-bus/src/main/java/org/apache/plc4x/java/cbus/CBusDriver.java
@@ -19,19 +19,15 @@
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;
import org.apache.plc4x.java.cbus.protocol.CBusProtocolLogic;
import org.apache.plc4x.java.cbus.readwrite.CBusCommand;
import org.apache.plc4x.java.spi.connection.GeneratedDriverBase;
-import org.apache.plc4x.java.spi.connection.PlcTagHandler;
import org.apache.plc4x.java.spi.connection.ProtocolStackConfigurer;
import org.apache.plc4x.java.spi.connection.SingleProtocolStackConfigurer;
@@ -83,16 +79,6 @@ protected List getSupportedTransportCodes() {
return Collections.singletonList("tcp");
}
- @Override
- protected PlcTagHandler getTagHandler() {
- return null;
- }
-
- @Override
- protected PlcValueHandler getValueHandler() {
- return null;
- }
-
@Override
protected ProtocolStackConfigurer getStackConfigurer() {
return SingleProtocolStackConfigurer.builder(CBusCommand.class, io ->
diff --git a/plc4j/drivers/c-bus/src/main/java/org/apache/plc4x/java/cbus/protocol/CBusProtocolLogic.java b/plc4j/drivers/c-bus/src/main/java/org/apache/plc4x/java/cbus/protocol/CBusProtocolLogic.java
index 7bed821a080..41d27fe5a6e 100644
--- a/plc4j/drivers/c-bus/src/main/java/org/apache/plc4x/java/cbus/protocol/CBusProtocolLogic.java
+++ b/plc4j/drivers/c-bus/src/main/java/org/apache/plc4x/java/cbus/protocol/CBusProtocolLogic.java
@@ -22,6 +22,7 @@
import org.apache.plc4x.java.cbus.readwrite.CBusCommand;
import org.apache.plc4x.java.spi.ConversationContext;
import org.apache.plc4x.java.spi.Plc4xProtocolBase;
+import org.apache.plc4x.java.spi.connection.PlcTagHandler;
import org.apache.plc4x.java.spi.context.DriverContext;
import org.apache.plc4x.java.spi.messages.*;
import org.apache.plc4x.java.spi.transaction.RequestTransactionManager;
@@ -48,6 +49,11 @@ public void setDriverContext(DriverContext driverContext) {
this.tm = new RequestTransactionManager(1);
}
+ @Override
+ public PlcTagHandler getTagHandler() {
+ return null;
+ }
+
@Override
public void close(ConversationContext context) {
tm.shutdown();
diff --git a/plc4j/drivers/c-bus/src/test/resources/logback-test.xml b/plc4j/drivers/c-bus/src/test/resources/logback-test.xml
index 264277d573f..37b5020ad53 100644
--- a/plc4j/drivers/c-bus/src/test/resources/logback-test.xml
+++ b/plc4j/drivers/c-bus/src/test/resources/logback-test.xml
@@ -25,7 +25,7 @@
-
+
diff --git a/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/adapter/CANDriverAdapter.java b/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/adapter/CANDriverAdapter.java
index 13eecb84536..bbffecdb60e 100644
--- a/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/adapter/CANDriverAdapter.java
+++ b/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/adapter/CANDriverAdapter.java
@@ -32,6 +32,7 @@
import org.apache.plc4x.java.can.adapter.conversation.ConversationContextWrapper;
import org.apache.plc4x.java.spi.ConversationContext;
import org.apache.plc4x.java.spi.Plc4xProtocolBase;
+import org.apache.plc4x.java.spi.connection.PlcTagHandler;
import org.apache.plc4x.java.spi.context.DriverContext;
import org.apache.plc4x.java.transport.can.CANTransport.FrameHandler;
import org.apache.plc4x.java.transport.can.FrameData;
@@ -42,12 +43,14 @@ public class CANDriverAdapter extends Plc4xProtocolBase {
private final Class wireType;
private final Function adapter;
private final FrameHandler frameHandler;
+ private final PlcTagHandler tagHandler;
- public CANDriverAdapter(Plc4xCANProtocolBase delegate, Class wireType, Function adapter, FrameHandler frameHandler) {
+ public CANDriverAdapter(Plc4xCANProtocolBase delegate, Class wireType, Function adapter, FrameHandler frameHandler, PlcTagHandler tagHandler) {
this.delegate = delegate;
this.wireType = wireType;
this.adapter = adapter;
this.frameHandler = frameHandler;
+ this.tagHandler = tagHandler;
}
@Override
@@ -61,8 +64,13 @@ public DriverContext getDriverContext() {
}
@Override
- public void setContext(ConversationContext context) {
- delegate.setContext(new ConversationContextWrapper<>(context, wireType, adapter, frameHandler, context.getAuthentication()));
+ public void setConversationContext(ConversationContext conversationContext) {
+ delegate.setConversationContext(new ConversationContextWrapper<>(conversationContext, wireType, adapter, frameHandler, conversationContext.getAuthentication()));
+ }
+
+ @Override
+ public PlcTagHandler getTagHandler() {
+ return tagHandler;
}
@Override
diff --git a/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/adapter/conversation/DeferredRequestContextWrapper.java b/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/adapter/conversation/DeferredRequestContextWrapper.java
index 0f75fd407a6..c7c31754268 100644
--- a/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/adapter/conversation/DeferredRequestContextWrapper.java
+++ b/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/adapter/conversation/DeferredRequestContextWrapper.java
@@ -19,6 +19,7 @@
package org.apache.plc4x.java.can.adapter.conversation;
import java.time.Duration;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeoutException;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
@@ -67,6 +68,13 @@ public ContextHandler handle(Consumer packetConsumer) {
return delegate.handle(packetConsumer);
}
+ @Override
+ public CompletableFuture toFuture() {
+ CompletableFuture future = new CompletableFuture<>();
+ handle(future::complete);
+ return future;
+ }
+
@Override
public SendRequestContext onTimeout(Consumer packetConsumer) {
return new DeferredRequestContextWrapper<>(name, delegate, completer, packetConsumer, errorConsumer);
diff --git a/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/adapter/conversation/ResolvedSendRequestContextWrapper.java b/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/adapter/conversation/ResolvedSendRequestContextWrapper.java
index fa2d7d60535..5fe07e33429 100644
--- a/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/adapter/conversation/ResolvedSendRequestContextWrapper.java
+++ b/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/adapter/conversation/ResolvedSendRequestContextWrapper.java
@@ -19,6 +19,7 @@
package org.apache.plc4x.java.can.adapter.conversation;
import java.time.Duration;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeoutException;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
@@ -65,6 +66,13 @@ public ContextHandler handle(Consumer packetConsumer) {
return delegate.handle(packetConsumer);
}
+ @Override
+ public CompletableFuture toFuture() {
+ CompletableFuture future = new CompletableFuture<>();
+ handle(future::complete);
+ return future;
+ }
+
@Override
public SendRequestContext onTimeout(Consumer packetConsumer) {
timeoutHandler.setHandler(packetConsumer);
diff --git a/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/adapter/conversation/SendRequestContextWrapper.java b/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/adapter/conversation/SendRequestContextWrapper.java
index d17e2c0f745..bba458ddabe 100644
--- a/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/adapter/conversation/SendRequestContextWrapper.java
+++ b/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/adapter/conversation/SendRequestContextWrapper.java
@@ -19,6 +19,7 @@
package org.apache.plc4x.java.can.adapter.conversation;
import java.time.Duration;
+import java.util.concurrent.CompletableFuture;
import java.util.concurrent.TimeoutException;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
@@ -77,6 +78,13 @@ public ContextHandler handle(Consumer packetConsumer) {
throw new IllegalStateException("Not implemented");
}
+ @Override
+ public CompletableFuture toFuture() {
+ CompletableFuture future = new CompletableFuture<>();
+ handle(future::complete);
+ return future;
+ }
+
@Override
public SendRequestContext onTimeout(Consumer packetConsumer) {
throw new IllegalStateException("Not implemented");
diff --git a/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/GenericCANDriver.java b/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/GenericCANDriver.java
index 4d31b799a08..2c7c1413f96 100644
--- a/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/GenericCANDriver.java
+++ b/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/GenericCANDriver.java
@@ -18,12 +18,12 @@
*/
package org.apache.plc4x.java.can.generic;
+import org.apache.plc4x.java.can.generic.tag.GenericCANTagHandler;
import org.apache.plc4x.java.spi.configuration.PlcConnectionConfiguration;
import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
import org.apache.plc4x.java.can.adapter.CANDriverAdapter;
import org.apache.plc4x.java.can.generic.configuration.GenericCANConfiguration;
import org.apache.plc4x.java.can.generic.context.GenericCANDriverContext;
-import org.apache.plc4x.java.can.generic.tag.GenericCANTagHandler;
import org.apache.plc4x.java.can.generic.protocol.GenericCANProtocolLogic;
import org.apache.plc4x.java.can.generic.transport.GenericCANFrameDataHandler;
import org.apache.plc4x.java.spi.configuration.ConfigurationFactory;
@@ -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;
@@ -80,16 +79,6 @@ protected boolean canWrite() {
return true;
}
- @Override
- 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
@@ -122,7 +111,8 @@ protected ProtocolStackConfigurer getStackConfigurer(Transport transpor
ConfigurationFactory.configure(cfg, protocolLogic);
return new CANDriverAdapter<>(protocolLogic,
canTransport.getMessageType(), canTransport.adapter(),
- new GenericCANFrameDataHandler(canTransport::getTransportFrameBuilder)
+ new GenericCANFrameDataHandler(canTransport::getTransportFrameBuilder),
+ new GenericCANTagHandler()
);
})
.withDriverContext(cfg -> new GenericCANDriverContext())
diff --git a/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/protocol/GenericCANProtocolLogic.java b/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/protocol/GenericCANProtocolLogic.java
index 6d36b2d7b21..f5704b3b6b2 100644
--- a/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/protocol/GenericCANProtocolLogic.java
+++ b/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/protocol/GenericCANProtocolLogic.java
@@ -29,16 +29,18 @@
import org.apache.plc4x.java.api.value.PlcValue;
import org.apache.plc4x.java.can.adapter.Plc4xCANProtocolBase;
import org.apache.plc4x.java.can.generic.tag.GenericCANTag;
+import org.apache.plc4x.java.can.generic.tag.GenericCANTagHandler;
import org.apache.plc4x.java.can.generic.transport.GenericFrame;
import org.apache.plc4x.java.genericcan.readwrite.DataItem;
import org.apache.plc4x.java.spi.ConversationContext;
+import org.apache.plc4x.java.spi.connection.PlcTagHandler;
import org.apache.plc4x.java.spi.context.DriverContext;
import org.apache.plc4x.java.spi.generation.*;
import org.apache.plc4x.java.spi.messages.*;
-import org.apache.plc4x.java.spi.messages.utils.ResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.DefaultPlcResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.PlcResponseItem;
import org.apache.plc4x.java.spi.model.DefaultPlcConsumerRegistration;
import org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionTag;
-import org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionHandle;
import org.apache.plc4x.java.spi.transaction.RequestTransactionManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -68,8 +70,13 @@ public void close(ConversationContext context) {
}
@Override
- public void setContext(ConversationContext context) {
- super.setContext(context);
+ public void setConversationContext(ConversationContext conversationContext) {
+ super.setConversationContext(conversationContext);
+ }
+
+ @Override
+ public PlcTagHandler getTagHandler() {
+ return new GenericCANTagHandler();
}
@Override
@@ -89,7 +96,7 @@ public void decode(ConversationContext context, GenericFrame msg)
Consumer consumer = entry.getValue();
for (PlcSubscriptionHandle handle : registration.getSubscriptionHandles()) {
GenericCANSubscriptionHandle subscription = (GenericCANSubscriptionHandle) handle;
- Map> tags = new LinkedHashMap<>();
+ Map> tags = new LinkedHashMap<>();
ReadBuffer buffer = new ReadBufferByteBased(msg.getData(), ByteOrder.LITTLE_ENDIAN);
buffer.pullContext("readTags");
if (subscription.matches(msg.getNodeId())) {
@@ -99,12 +106,12 @@ public void decode(ConversationContext context, GenericFrame msg)
try {
PlcValue value = read(readBuffer, tag.getValue(), data.length);
if (value == null) {
- tags.put(tag.getKey(), new ResponseItem<>(PlcResponseCode.INTERNAL_ERROR, null));
+ tags.put(tag.getKey(), new DefaultPlcResponseItem<>(PlcResponseCode.INTERNAL_ERROR, null));
} else {
- tags.put(tag.getKey(), new ResponseItem<>(PlcResponseCode.OK, value));
+ tags.put(tag.getKey(), new DefaultPlcResponseItem<>(PlcResponseCode.OK, value));
}
} catch (ParseException e) {
- tags.put(tag.getKey(), new ResponseItem<>(PlcResponseCode.INVALID_DATA, null));
+ tags.put(tag.getKey(), new DefaultPlcResponseItem<>(PlcResponseCode.INVALID_DATA, null));
}
}
consumer.accept(new DefaultPlcSubscriptionEvent(Instant.now(), tags));
@@ -177,7 +184,7 @@ public CompletableFuture write(PlcWriteRequest writeRequest) {
if (!discarded) {
byte[] data = message.getValue().getBytes();
logger.debug("Writing message with id {} and {} bytes of data", message.getKey(), data.length);
- context.sendToWire(new GenericFrame(message.getKey(), data));
+ conversationContext.sendToWire(new GenericFrame(message.getKey(), data));
}
}
@@ -192,23 +199,23 @@ public CompletableFuture write(PlcWriteRequest writeRequest) {
public CompletableFuture subscribe(PlcSubscriptionRequest request) {
DefaultPlcSubscriptionRequest rq = (DefaultPlcSubscriptionRequest) request;
- Map> answers = new LinkedHashMap<>();
+ Map> answers = new LinkedHashMap<>();
DefaultPlcSubscriptionResponse response = new DefaultPlcSubscriptionResponse(rq, answers);
Map handles = new LinkedHashMap<>();
for (String key : rq.getTagNames()) {
DefaultPlcSubscriptionTag subscription = (DefaultPlcSubscriptionTag) rq.getTag(key);
if (subscription.getPlcSubscriptionType() != PlcSubscriptionType.EVENT) {
- answers.put(key, new ResponseItem<>(PlcResponseCode.UNSUPPORTED, null));
+ answers.put(key, new DefaultPlcResponseItem<>(PlcResponseCode.UNSUPPORTED, null));
} else if (subscription.getTag() instanceof GenericCANTag) {
GenericCANTag canTag = (GenericCANTag) subscription.getTag();
GenericCANSubscriptionHandle subscriptionHandle = handles.computeIfAbsent(canTag.getNodeId(),
node -> new GenericCANSubscriptionHandle(this, node)
);
- answers.put(key, new ResponseItem<>(PlcResponseCode.OK, subscriptionHandle));
+ answers.put(key, new DefaultPlcResponseItem<>(PlcResponseCode.OK, subscriptionHandle));
subscriptionHandle.add(key, canTag);
} else {
- answers.put(key, new ResponseItem<>(PlcResponseCode.INVALID_ADDRESS, null));
+ answers.put(key, new DefaultPlcResponseItem<>(PlcResponseCode.INVALID_ADDRESS, null));
}
}
diff --git a/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/tag/GenericCANTag.java b/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/tag/GenericCANTag.java
index c21db4dfe10..ea8a2d34fef 100644
--- a/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/tag/GenericCANTag.java
+++ b/plc4j/drivers/can/src/main/java/org/apache/plc4x/java/can/generic/tag/GenericCANTag.java
@@ -65,7 +65,7 @@ public PlcValueType getPlcValueType() {
@Override
public List getArrayInfo() {
- if(arraySize != 1) {
+ if(arraySize > 1) {
return Collections.singletonList(new DefaultArrayInfo(0, arraySize));
}
return Collections.emptyList();
diff --git a/plc4j/drivers/can/src/test/java/org/apache/plc4x/java/can/generic/GenericCANDriverTest.java b/plc4j/drivers/can/src/test/java/org/apache/plc4x/java/can/generic/GenericCANDriverTest.java
index 9ac60d6d3ac..7abd581efe7 100644
--- a/plc4j/drivers/can/src/test/java/org/apache/plc4x/java/can/generic/GenericCANDriverTest.java
+++ b/plc4j/drivers/can/src/test/java/org/apache/plc4x/java/can/generic/GenericCANDriverTest.java
@@ -19,23 +19,11 @@
package org.apache.plc4x.java.can.generic;
import io.netty.buffer.ByteBuf;
-import io.netty.buffer.ByteBufAllocator;
-import io.netty.buffer.ByteBufUtil;
-import io.netty.buffer.Unpooled;
-import io.netty.buffer.UnpooledDirectByteBuf;
import io.netty.channel.Channel;
-import io.netty.channel.ChannelHandlerAdapter;
-import io.netty.channel.ChannelHandlerContext;
-import io.netty.channel.ChannelInboundHandlerAdapter;
-import io.netty.channel.ChannelOutboundHandlerAdapter;
-import io.netty.channel.ChannelPromise;
-import io.netty.channel.embedded.EmbeddedChannel;
import io.netty.channel.embedded.Plc4xEmbeddedChannel;
import java.lang.reflect.Array;
-import java.util.Arrays;
import java.util.Map;
import java.util.Map.Entry;
-import java.util.Optional;
import java.util.concurrent.CountDownLatch;
import java.util.concurrent.atomic.AtomicReference;
@@ -43,14 +31,12 @@
import org.apache.plc4x.java.api.PlcConnection;
import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
import org.apache.plc4x.java.api.messages.PlcSubscriptionEvent;
+import org.apache.plc4x.java.api.messages.PlcSubscriptionRequest;
import org.apache.plc4x.java.api.messages.PlcSubscriptionRequest.Builder;
import org.apache.plc4x.java.api.messages.PlcWriteRequest;
-import org.apache.plc4x.java.api.model.PlcTag;
import org.apache.plc4x.java.spi.connection.ChannelExposingConnection;
-import org.apache.plc4x.java.spi.values.PlcBYTE;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
-import org.mockito.internal.util.Primitives;
import static java.util.Map.entry;
import static org.junit.jupiter.api.Assertions.*;
@@ -134,7 +120,8 @@ void subscribeAndWrite(Map> entries) throws Except
subscriptionRequestBuilder.addEventTagAddress(k, v.getKey());
});
- subscriptionRequestBuilder.build().execute().whenComplete((reply, error) -> {
+ PlcSubscriptionRequest subscriptionRequest = subscriptionRequestBuilder.build();
+ subscriptionRequest.execute().whenComplete((reply, error) -> {
if (error != null) {
fail(error);
return;
@@ -150,7 +137,8 @@ void subscribeAndWrite(Map> entries) throws Except
entries.forEach((k, v) -> {
writeRequestBuilder.addTagAddress(k, v.getKey(), v.getValue());
});
- writeRequestBuilder.build().execute().whenComplete((reply, error) -> {
+ PlcWriteRequest writeRequest = writeRequestBuilder.build();
+ writeRequest.execute().whenComplete((reply, error) -> {
if (error != null) {
fail(error);
}
diff --git a/plc4j/drivers/can/src/test/resources/logback-test.xml b/plc4j/drivers/can/src/test/resources/logback-test.xml
index 2b9cea25dc8..941f1546f84 100644
--- a/plc4j/drivers/can/src/test/resources/logback-test.xml
+++ b/plc4j/drivers/can/src/test/resources/logback-test.xml
@@ -29,7 +29,7 @@
-
+
diff --git a/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/CANOpenPlcDriver.java b/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/CANOpenPlcDriver.java
index 39dce5bd6fa..6d7d6f08dea 100644
--- a/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/CANOpenPlcDriver.java
+++ b/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/CANOpenPlcDriver.java
@@ -18,6 +18,7 @@
*/
package org.apache.plc4x.java.canopen;
+import org.apache.plc4x.java.canopen.tag.CANOpenTagHandler;
import org.apache.plc4x.java.spi.configuration.PlcConnectionConfiguration;
import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
import org.apache.plc4x.java.api.model.PlcTag;
@@ -25,7 +26,6 @@
import org.apache.plc4x.java.can.adapter.CANDriverAdapter;
import org.apache.plc4x.java.canopen.configuration.CANOpenConfiguration;
import org.apache.plc4x.java.canopen.context.CANOpenDriverContext;
-import org.apache.plc4x.java.canopen.tag.CANOpenTagHandler;
import org.apache.plc4x.java.canopen.protocol.CANOpenProtocolLogic;
import org.apache.plc4x.java.canopen.transport.CANOpenFrameDataHandler;
import org.apache.plc4x.java.spi.configuration.ConfigurationFactory;
@@ -36,6 +36,7 @@
import org.apache.plc4x.java.spi.optimizer.BaseOptimizer;
import org.apache.plc4x.java.spi.optimizer.SingleTagOptimizer;
import org.apache.plc4x.java.spi.transport.Transport;
+import org.apache.plc4x.java.spi.values.DefaultPlcValueHandler;
import org.apache.plc4x.java.spi.values.PlcValueHandler;
import org.apache.plc4x.java.spi.values.PlcList;
import org.apache.plc4x.java.transport.can.CANTransport;
@@ -82,13 +83,8 @@ protected Optional getDefaultTransportCode() {
}
@Override
- protected CANOpenTagHandler getTagHandler() {
- return new CANOpenTagHandler();
- }
-
- @Override
- protected org.apache.plc4x.java.api.value.PlcValueHandler getValueHandler() {
- return new PlcValueHandler() {
+ protected PlcValueHandler getValueHandler() {
+ return new DefaultPlcValueHandler() {
@Override
public PlcValue newPlcValue(PlcTag tag, Object[] values) {
if (values[0] instanceof PlcList) {
@@ -131,7 +127,8 @@ protected ProtocolStackConfigurer getStackConfigurer(Transport transpor
ConfigurationFactory.configure(cfg, protocolLogic);
return new CANDriverAdapter<>(protocolLogic,
canTransport.getMessageType(), canTransport.adapter(),
- new CANOpenFrameDataHandler(canTransport::getTransportFrameBuilder)
+ new CANOpenFrameDataHandler(canTransport::getTransportFrameBuilder),
+ new CANOpenTagHandler()
);
})
.withDriverContext(cfg -> new CANOpenDriverContext())
diff --git a/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/protocol/CANOpenProtocolLogic.java b/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/protocol/CANOpenProtocolLogic.java
index 5caa22a3b50..9124cab003d 100644
--- a/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/protocol/CANOpenProtocolLogic.java
+++ b/plc4j/drivers/canopen/src/main/java/org/apache/plc4x/java/canopen/protocol/CANOpenProtocolLogic.java
@@ -56,6 +56,7 @@
import org.apache.plc4x.java.canopen.readwrite.NMTStateRequest;
import org.apache.plc4x.java.spi.ConversationContext;
import org.apache.plc4x.java.spi.configuration.HasConfiguration;
+import org.apache.plc4x.java.spi.connection.PlcTagHandler;
import org.apache.plc4x.java.spi.context.DriverContext;
import org.apache.plc4x.java.spi.generation.*;
import org.apache.plc4x.java.spi.messages.DefaultPlcReadResponse;
@@ -66,7 +67,8 @@
import org.apache.plc4x.java.spi.messages.DefaultPlcWriteRequest;
import org.apache.plc4x.java.spi.messages.DefaultPlcWriteResponse;
import org.apache.plc4x.java.spi.messages.PlcSubscriber;
-import org.apache.plc4x.java.spi.messages.utils.ResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.DefaultPlcResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.PlcResponseItem;
import org.apache.plc4x.java.spi.model.DefaultPlcConsumerRegistration;
import org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionTag;
import org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionHandle;
@@ -124,6 +126,11 @@ public void setDriverContext(DriverContext driverContext) {
this.tm = new RequestTransactionManager(1);
}
+ @Override
+ public PlcTagHandler getTagHandler() {
+ return new CANOpenTagHandler();
+ }
+
@Override
public void close(ConversationContext context) {
tm.shutdown();
@@ -154,9 +161,9 @@ public void run() {
}
@Override
- public void setContext(ConversationContext context) {
- super.setContext(context);
- this.conversation = new CANTransportConversation(configuration.getNodeId(), context, configuration.getRequestTimeout());
+ public void setConversationContext(ConversationContext conversationContext) {
+ super.setConversationContext(conversationContext);
+ this.conversation = new CANTransportConversation(configuration.getNodeId(), conversationContext, configuration.getRequestTimeout());
}
private CANOpenFrame createFrame(CANOpenHeartbeatPayload state) throws ParseException {
@@ -224,7 +231,7 @@ private void writeInternally(DefaultPlcWriteRequest writeRequest, CANOpenPDOTag
WriteBufferByteBased writeBuffer = new WriteBufferByteBased(DataItem.getLengthInBytes(writeValue, tag.getCanOpenDataType(), writeValue.getLength()), ByteOrder.LITTLE_ENDIAN);
DataItem.staticSerialize(writeBuffer, writeValue, tag.getCanOpenDataType(), writeValue.getLength(), ByteOrder.LITTLE_ENDIAN);
final CANOpenPDOPayload payload = new CANOpenPDOPayload(new CANOpenPDO(writeBuffer.getBytes()));
- context.sendToWire(new CANOpenFrame((short) tag.getNodeId(), tag.getService(), payload));
+ conversationContext.sendToWire(new CANOpenFrame((short) tag.getNodeId(), tag.getService(), payload));
response.complete(new DefaultPlcWriteResponse(writeRequest, Collections.singletonMap(tagName, PlcResponseCode.OK)));
} catch (Exception e) {
response.completeExceptionally(e);
@@ -257,27 +264,27 @@ public CompletableFuture read(PlcReadRequest readRequest) {
public CompletableFuture subscribe(PlcSubscriptionRequest request) {
DefaultPlcSubscriptionRequest rq = (DefaultPlcSubscriptionRequest) request;
- Map> answers = new LinkedHashMap<>();
+ Map> answers = new LinkedHashMap<>();
DefaultPlcSubscriptionResponse response = new DefaultPlcSubscriptionResponse(rq, answers);
for (String key : rq.getTagNames()) {
DefaultPlcSubscriptionTag subscription = (DefaultPlcSubscriptionTag) rq.getTag(key);
if (subscription.getPlcSubscriptionType() != PlcSubscriptionType.EVENT) {
- answers.put(key, new ResponseItem<>(PlcResponseCode.UNSUPPORTED, null));
+ answers.put(key, new DefaultPlcResponseItem<>(PlcResponseCode.UNSUPPORTED, null));
} else if ((subscription.getTag() instanceof CANOpenPDOTag)) {
- answers.put(key, new ResponseItem<>(PlcResponseCode.OK,
+ answers.put(key, new DefaultPlcResponseItem<>(PlcResponseCode.OK,
new CANOpenSubscriptionHandle(this, key, (CANOpenPDOTag) subscription.getTag())
));
} else if ((subscription.getTag() instanceof CANOpenNMTTag)) {
- answers.put(key, new ResponseItem<>(PlcResponseCode.OK,
+ answers.put(key, new DefaultPlcResponseItem<>(PlcResponseCode.OK,
new CANOpenSubscriptionHandle(this, key, (CANOpenNMTTag) subscription.getTag())
));
} else if ((subscription.getTag() instanceof CANOpenHeartbeatTag)) {
- answers.put(key, new ResponseItem<>(PlcResponseCode.OK,
+ answers.put(key, new DefaultPlcResponseItem<>(PlcResponseCode.OK,
new CANOpenSubscriptionHandle(this, key, (CANOpenHeartbeatTag) subscription.getTag())
));
} else {
- answers.put(key, new ResponseItem<>(PlcResponseCode.INVALID_ADDRESS, null));
+ answers.put(key, new DefaultPlcResponseItem<>(PlcResponseCode.INVALID_ADDRESS, null));
}
}
@@ -302,11 +309,11 @@ private void readInternally(PlcReadRequest readRequest, CANOpenSDOTag tag, Compl
CompletableFuture callback = new CompletableFuture<>();
callback.whenComplete((value, error) -> {
if (error != null) {
- Map> tags = new HashMap<>();
+ Map> tags = new HashMap<>();
if (error instanceof CANOpenAbortException) {
- tags.put(tagName, new ResponseItem<>(PlcResponseCode.REMOTE_ERROR, new PlcLINT(((CANOpenAbortException) error).getAbortCode())));
+ tags.put(tagName, new DefaultPlcResponseItem<>(PlcResponseCode.REMOTE_ERROR, new PlcLINT(((CANOpenAbortException) error).getAbortCode())));
} else {
- tags.put(tagName, new ResponseItem<>(PlcResponseCode.REMOTE_ERROR, null));
+ tags.put(tagName, new DefaultPlcResponseItem<>(PlcResponseCode.REMOTE_ERROR, null));
}
response.complete(new DefaultPlcReadResponse(readRequest, tags));
transaction.endRequest();
@@ -314,8 +321,8 @@ private void readInternally(PlcReadRequest readRequest, CANOpenSDOTag tag, Compl
return;
}
- Map> tags = new HashMap<>();
- tags.put(tagName, new ResponseItem<>(PlcResponseCode.OK, value));
+ Map> tags = new HashMap<>();
+ tags.put(tagName, new DefaultPlcResponseItem<>(PlcResponseCode.OK, value));
response.complete(new DefaultPlcReadResponse(readRequest, tags));
transaction.endRequest();
});
@@ -363,7 +370,7 @@ private void publishEvent(CANOpenService service, int nodeId, CANOpenPayload pay
Instant.now(),
Collections.singletonMap(
handle.getName(),
- new ResponseItem<>(PlcResponseCode.OK, value)
+ new DefaultPlcResponseItem<>(PlcResponseCode.OK, value)
)
);
consumer.accept(event);
@@ -373,7 +380,7 @@ private void publishEvent(CANOpenService service, int nodeId, CANOpenPayload pay
Instant.now(),
Collections.singletonMap(
handle.getName(),
- new ResponseItem<>(PlcResponseCode.INVALID_DATA, new PlcNull())
+ new DefaultPlcResponseItem<>(PlcResponseCode.INVALID_DATA, new PlcNull())
)
);
consumer.accept(event);
@@ -393,7 +400,7 @@ private void publishEvent(CANOpenService service, int nodeId, CANOpenPayload pay
Instant.now(),
Collections.singletonMap(
handle.getName(),
- new ResponseItem<>(PlcResponseCode.OK, struct)
+ new DefaultPlcResponseItem<>(PlcResponseCode.OK, struct)
)
);
consumer.accept(event);
@@ -412,7 +419,7 @@ private void publishEvent(CANOpenService service, int nodeId, CANOpenPayload pay
Instant.now(),
Collections.singletonMap(
handle.getName(),
- new ResponseItem<>(PlcResponseCode.OK, struct)
+ new DefaultPlcResponseItem<>(PlcResponseCode.OK, struct)
)
);
consumer.accept(event);
diff --git a/plc4j/drivers/canopen/src/test/resources/logback-test.xml b/plc4j/drivers/canopen/src/test/resources/logback-test.xml
index 2b9cea25dc8..941f1546f84 100644
--- a/plc4j/drivers/canopen/src/test/resources/logback-test.xml
+++ b/plc4j/drivers/canopen/src/test/resources/logback-test.xml
@@ -29,7 +29,7 @@
-
+
diff --git a/plc4j/drivers/ctrlx/src/main/java/org/apache/plc4x/java/ctrlx/readwrite/connection/CtrlXConnection.java b/plc4j/drivers/ctrlx/src/main/java/org/apache/plc4x/java/ctrlx/readwrite/connection/CtrlXConnection.java
index df09c0bb757..dfff73c39bc 100644
--- a/plc4j/drivers/ctrlx/src/main/java/org/apache/plc4x/java/ctrlx/readwrite/connection/CtrlXConnection.java
+++ b/plc4j/drivers/ctrlx/src/main/java/org/apache/plc4x/java/ctrlx/readwrite/connection/CtrlXConnection.java
@@ -19,18 +19,19 @@
package org.apache.plc4x.java.ctrlx.readwrite.connection;
-import com.hrakaroo.glob.GlobPattern;
import com.hrakaroo.glob.MatchingEngine;
import org.apache.plc4x.java.api.PlcConnection;
import org.apache.plc4x.java.api.exceptions.PlcConnectionException;
import org.apache.plc4x.java.api.exceptions.PlcInvalidTagException;
import org.apache.plc4x.java.api.exceptions.PlcProtocolException;
+import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
import org.apache.plc4x.java.api.messages.*;
import org.apache.plc4x.java.api.metadata.PlcConnectionMetadata;
import org.apache.plc4x.java.api.model.PlcQuery;
import org.apache.plc4x.java.api.model.PlcTag;
import org.apache.plc4x.java.api.types.PlcResponseCode;
import org.apache.plc4x.java.api.types.PlcValueType;
+import org.apache.plc4x.java.api.value.PlcValue;
import org.apache.plc4x.java.ctrlx.readwrite.rest.datalayer.ApiClient;
import org.apache.plc4x.java.ctrlx.readwrite.rest.datalayer.ApiException;
import org.apache.plc4x.java.ctrlx.readwrite.rest.datalayer.api.DataLayerInformationAndSettingsApi;
@@ -42,6 +43,8 @@
import org.apache.plc4x.java.ctrlx.readwrite.tag.CtrlXTagHandler;
import org.apache.plc4x.java.ctrlx.readwrite.utils.ApiClientFactory;
import org.apache.plc4x.java.spi.messages.*;
+import org.apache.plc4x.java.spi.values.DefaultPlcValueHandler;
+import org.apache.plc4x.java.spi.values.PlcValueHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -60,6 +63,7 @@ public class CtrlXConnection implements PlcConnection, PlcPinger, PlcBrowser {
private final String password;
private final ExecutorService executorService;
+ private PlcValueHandler valueHandler;
private ApiClient apiClient;
private NodesApi nodesApi;
@@ -72,6 +76,18 @@ public CtrlXConnection(String baseUrl, String username, String password) {
this.username = username;
this.password = password;
this.executorService = Executors.newFixedThreadPool(10);
+ this.valueHandler = new DefaultPlcValueHandler();
+ }
+
+ @Override
+ public Optional parseTagValue(PlcTag tag, Object... values) {
+ PlcValue plcValue;
+ try {
+ plcValue = valueHandler.newPlcValue(tag, values);
+ } catch (Exception e) {
+ throw new PlcRuntimeException("Error parsing tag value " + tag, e);
+ }
+ return Optional.of(plcValue);
}
@Override
@@ -258,7 +274,7 @@ public CompletableFuture browseWithInterceptor(PlcBrowseReque
e.printStackTrace();
}*/
matchingQueryNames.forEach(queryName -> responseItems.get(queryName).add(
- new DefaultListPlcBrowseItem(
+ new DefaultPlcBrowseItemList(
new CtrlXTag(curNode, PlcValueType.BOOL, Collections.emptyList()),
curNode, true, true, true, false,
Collections.emptyMap(), Collections.emptyMap(), Collections.emptyList())));
diff --git a/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/base/EIPDriver.java b/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/base/EIPDriver.java
index a6d731526bb..02f4be1d48a 100644
--- a/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/base/EIPDriver.java
+++ b/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/base/EIPDriver.java
@@ -29,7 +29,6 @@
import org.apache.plc4x.java.eip.base.configuration.EipTcpTransportConfiguration;
import org.apache.plc4x.java.eip.base.tag.EipTag;
import org.apache.plc4x.java.eip.base.protocol.EipProtocolLogic;
-import org.apache.plc4x.java.eip.base.tag.EipTagHandler;
import org.apache.plc4x.java.eip.readwrite.EipPacket;
import org.apache.plc4x.java.spi.configuration.ConfigurationFactory;
import org.apache.plc4x.java.spi.configuration.HasConfiguration;
@@ -38,8 +37,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;
@@ -92,16 +89,6 @@ protected List getSupportedTransportCodes() {
return Collections.singletonList("tcp");
}
- @Override
- 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());
@@ -222,7 +209,6 @@ public PlcConnection getConnection(String connectionString) throws PlcConnection
return new DefaultNettyPlcConnection(
canPing(), canRead(), canWrite(), canSubscribe(), canBrowse(),
- getTagHandler(),
getValueHandler(),
configuration,
channelFactory,
diff --git a/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/base/protocol/EipProtocolLogic.java b/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/base/protocol/EipProtocolLogic.java
index 1e75cf460e4..14b26360e72 100644
--- a/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/base/protocol/EipProtocolLogic.java
+++ b/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/base/protocol/EipProtocolLogic.java
@@ -30,11 +30,13 @@
import org.apache.plc4x.java.api.value.PlcValue;
import org.apache.plc4x.java.eip.base.configuration.EIPConfiguration;
import org.apache.plc4x.java.eip.base.tag.EipTag;
+import org.apache.plc4x.java.eip.base.tag.EipTagHandler;
import org.apache.plc4x.java.eip.logix.configuration.LogixConfiguration;
import org.apache.plc4x.java.eip.readwrite.*;
import org.apache.plc4x.java.spi.ConversationContext;
import org.apache.plc4x.java.spi.Plc4xProtocolBase;
import org.apache.plc4x.java.spi.configuration.HasConfiguration;
+import org.apache.plc4x.java.spi.connection.PlcTagHandler;
import org.apache.plc4x.java.spi.generation.ParseException;
import org.apache.plc4x.java.spi.generation.ReadBufferByteBased;
import org.apache.plc4x.java.spi.generation.SerializationException;
@@ -43,7 +45,8 @@
import org.apache.plc4x.java.spi.messages.DefaultPlcReadResponse;
import org.apache.plc4x.java.spi.messages.DefaultPlcWriteRequest;
import org.apache.plc4x.java.spi.messages.DefaultPlcWriteResponse;
-import org.apache.plc4x.java.spi.messages.utils.ResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.DefaultPlcResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.PlcResponseItem;
import org.apache.plc4x.java.spi.transaction.RequestTransactionManager;
import org.apache.plc4x.java.spi.values.*;
import org.slf4j.Logger;
@@ -146,6 +149,11 @@ public void setConfiguration(EIPConfiguration configuration) {
this.tm = new RequestTransactionManager(1);
}
+ @Override
+ public PlcTagHandler getTagHandler() {
+ return new EipTagHandler();
+ }
+
@Override
public void close(ConversationContext context) {
tm.shutdown();
@@ -445,7 +453,7 @@ public void onDisconnectUnregisterSession(ConversationContext context
private CompletableFuture readWithoutMessageRouter(PlcReadRequest readRequest) {
CompletableFuture future = new CompletableFuture<>();
- Map> values = new HashMap<>();
+ Map> values = new HashMap<>();
List> internalFutures = new ArrayList<>();
PathSegment classSegment = new LogicalSegment(new ClassID((byte) 0, (short) 6));
PathSegment instanceSegment = new LogicalSegment(new InstanceID((byte) 0, (short) 1));
@@ -482,7 +490,7 @@ private CompletableFuture readWithoutMessageRouter(PlcReadReque
typeIds);
RequestTransactionManager.RequestTransaction transaction = tm.startRequest();
- transaction.submit(() -> context.sendRequest(rrdata)
+ transaction.submit(() -> conversationContext.sendRequest(rrdata)
.expectResponse(EipPacket.class, REQUEST_TIMEOUT)
.onTimeout(internalFuture::completeExceptionally)
.onError((p, e) -> internalFuture.completeExceptionally(e))
@@ -494,11 +502,11 @@ private CompletableFuture readWithoutMessageRouter(PlcReadReque
UnConnectedDataItem dataItem = (UnConnectedDataItem) responseTypeIds.get(1);
// If the response indicates an error, handle this.
if((dataItem.getService() instanceof CipConnectedResponse) && (((CipConnectedResponse) dataItem.getService()).getStatus() == 0x03)) {
- values.put(tagName, new ResponseItem<>(PlcResponseCode.INVALID_ADDRESS, null));
+ values.put(tagName, new DefaultPlcResponseItem<>(PlcResponseCode.INVALID_ADDRESS, null));
}
// Otherwise process the response.
else {
- Map> readResponse = decodeSingleReadResponse(dataItem.getService(), tagName, eipTag);
+ Map> readResponse = decodeSingleReadResponse(dataItem.getService(), tagName, eipTag);
values.putAll(readResponse);
}
internalFuture.complete(null);
@@ -585,7 +593,7 @@ private CompletableFuture readWithoutConnectionManager(PlcReadR
typeIds
);
- transaction.submit(() -> context.sendRequest(pkt)
+ transaction.submit(() -> conversationContext.sendRequest(pkt)
.expectResponse(EipPacket.class, REQUEST_TIMEOUT)
.onTimeout(future::completeExceptionally)
.onError((p, e) -> future.completeExceptionally(e))
@@ -662,7 +670,7 @@ private CompletableFuture readWithConnectionManager(PlcReadRequ
this.sequenceCount += 1;
- transaction.submit(() -> context.sendRequest(pkt)
+ transaction.submit(() -> conversationContext.sendRequest(pkt)
.expectResponse(EipPacket.class, REQUEST_TIMEOUT)
.onTimeout(future::completeExceptionally)
.onError((p, e) -> future.completeExceptionally(e))
@@ -732,7 +740,7 @@ public static byte[] toAnsi(String tag) throws SerializationException {
}
private PlcReadResponse decodeReadResponse(CipService p, PlcReadRequest readRequest) {
- Map> values = new HashMap<>();
+ Map> values = new HashMap<>();
// only 1 field
if (p instanceof CipReadResponse) {
CipReadResponse resp = (CipReadResponse) p;
@@ -745,7 +753,7 @@ private PlcReadResponse decodeReadResponse(CipService p, PlcReadRequest readRequ
if (code == PlcResponseCode.OK) {
plcValue = parsePlcValue(tag, data, type);
}
- ResponseItem result = new ResponseItem<>(code, plcValue);
+ PlcResponseItem result = new DefaultPlcResponseItem<>(code, plcValue);
values.put(fieldName, result);
}
//Multiple response
@@ -790,7 +798,7 @@ else if (p instanceof MultipleServiceResponse) {
if (code == PlcResponseCode.OK) {
plcValue = parsePlcValue(tag, data, type);
}
- ResponseItem result = new ResponseItem<>(code, plcValue);
+ PlcResponseItem result = new DefaultPlcResponseItem<>(code, plcValue);
values.put(fieldName, result);
}
}
@@ -798,8 +806,8 @@ else if (p instanceof MultipleServiceResponse) {
return new DefaultPlcReadResponse(readRequest, values);
}
- private Map> decodeSingleReadResponse(CipService p, String tagName, PlcTag tag) {
- Map> values = new HashMap<>();
+ private Map> decodeSingleReadResponse(CipService p, String tagName, PlcTag tag) {
+ Map> values = new HashMap<>();
CipReadResponse resp = (CipReadResponse) p;
PlcResponseCode code = decodeResponseCode(resp.getStatus());
PlcValue plcValue = null;
@@ -808,7 +816,7 @@ private Map> decodeSingleReadResponse(CipService
if (code == PlcResponseCode.OK) {
plcValue = parsePlcValue((EipTag) tag, data, type);
}
- ResponseItem result = new ResponseItem<>(code, plcValue);
+ PlcResponseItem result = new DefaultPlcResponseItem<>(code, plcValue);
values.put(tagName, result);
return values;
}
@@ -967,7 +975,7 @@ public CompletableFuture writeWithoutMessageRouter(PlcWriteReq
typeIds);
RequestTransactionManager.RequestTransaction transaction = tm.startRequest();
- transaction.submit(() -> context.sendRequest(rrdata)
+ transaction.submit(() -> conversationContext.sendRequest(rrdata)
.expectResponse(EipPacket.class, REQUEST_TIMEOUT)
.onTimeout(internalFuture::completeExceptionally)
.onError((p, e) -> internalFuture.completeExceptionally(e))
@@ -1049,7 +1057,7 @@ public CompletableFuture writeWithoutConnectionManager(PlcWrit
0,
typeIds);
- transaction.submit(() -> context.sendRequest(rrdata)
+ transaction.submit(() -> conversationContext.sendRequest(rrdata)
.expectResponse(EipPacket.class, REQUEST_TIMEOUT)
.onTimeout(future::completeExceptionally)
.onError((p, e) -> future.completeExceptionally(e))
@@ -1104,7 +1112,7 @@ public CompletableFuture writeWithoutConnectionManager(PlcWrit
0,
typeIds);
- transaction.submit(() -> context.sendRequest(pkt)
+ transaction.submit(() -> conversationContext.sendRequest(pkt)
.expectResponse(EipPacket.class, REQUEST_TIMEOUT)
.onTimeout(future::completeExceptionally)
.onError((p, e) -> future.completeExceptionally(e))
@@ -1168,7 +1176,7 @@ public CompletableFuture writeWithConnectionManager(PlcWriteRe
0,
typeIds);
- transaction.submit(() -> context.sendRequest(rrdata)
+ transaction.submit(() -> conversationContext.sendRequest(rrdata)
.expectResponse(EipPacket.class, REQUEST_TIMEOUT)
.onTimeout(future::completeExceptionally)
.onError((p, e) -> future.completeExceptionally(e))
@@ -1214,7 +1222,7 @@ public CompletableFuture writeWithConnectionManager(PlcWriteRe
0,
typeIds);
- transaction.submit(() -> context.sendRequest(pkt)
+ transaction.submit(() -> conversationContext.sendRequest(pkt)
.expectResponse(EipPacket.class, REQUEST_TIMEOUT)
.onTimeout(future::completeExceptionally)
.onError((p, e) -> future.completeExceptionally(e))
diff --git a/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/logix/LogixDriver.java b/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/logix/LogixDriver.java
index b8bb251d2a9..3a1d971cc1b 100644
--- a/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/logix/LogixDriver.java
+++ b/plc4j/drivers/eip/src/main/java/org/apache/plc4x/java/eip/logix/LogixDriver.java
@@ -21,13 +21,11 @@
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;
import org.apache.plc4x.java.eip.logix.configuration.LogixTcpTransportConfiguration;
import org.apache.plc4x.java.eip.readwrite.EipPacket;
-import org.apache.plc4x.java.eip.base.tag.EipTagHandler;
import org.apache.plc4x.java.spi.connection.*;
import java.util.Collections;
@@ -72,16 +70,6 @@ protected List getSupportedTransportCodes() {
return Collections.singletonList("tcp");
}
- @Override
- 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;
diff --git a/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/EIPDriverIT.java b/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/EIPDriverIT.java
index dd18cc68597..0502fbba9b4 100644
--- a/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/EIPDriverIT.java
+++ b/plc4j/drivers/eip/src/test/java/org/apache/plc4x/java/eip/base/EIPDriverIT.java
@@ -23,7 +23,7 @@
public class EIPDriverIT extends DriverTestsuiteRunner {
public EIPDriverIT() {
- super("/protocols/eip/DriverTestsuite.xml");
+ super("/protocols/eip/DriverTestsuite.xml", false);
}
}
diff --git a/plc4j/drivers/eip/src/test/resources/logback-test.xml b/plc4j/drivers/eip/src/test/resources/logback-test.xml
index 2b9cea25dc8..941f1546f84 100644
--- a/plc4j/drivers/eip/src/test/resources/logback-test.xml
+++ b/plc4j/drivers/eip/src/test/resources/logback-test.xml
@@ -29,7 +29,7 @@
-
+
diff --git a/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/FirmataDriver.java b/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/FirmataDriver.java
index de494150400..8c38c2d8188 100644
--- a/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/FirmataDriver.java
+++ b/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/FirmataDriver.java
@@ -24,11 +24,8 @@
import org.apache.plc4x.java.firmata.readwrite.configuration.FirmataConfiguration;
import org.apache.plc4x.java.firmata.readwrite.context.FirmataDriverContext;
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;
import org.apache.plc4x.java.spi.connection.SingleProtocolStackConfigurer;
@@ -75,16 +72,6 @@ protected boolean canSubscribe() {
return true;
}
- @Override
- 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
diff --git a/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/protocol/FirmataProtocolLogic.java b/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/protocol/FirmataProtocolLogic.java
index 946414fd141..53179a5fef7 100644
--- a/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/protocol/FirmataProtocolLogic.java
+++ b/plc4j/drivers/firmata/src/main/java/org/apache/plc4x/java/firmata/readwrite/protocol/FirmataProtocolLogic.java
@@ -31,13 +31,16 @@
import org.apache.plc4x.java.firmata.readwrite.tag.FirmataTag;
import org.apache.plc4x.java.firmata.readwrite.tag.FirmataTagAnalog;
import org.apache.plc4x.java.firmata.readwrite.tag.FirmataTagDigital;
+import org.apache.plc4x.java.firmata.readwrite.tag.FirmataTagHandler;
import org.apache.plc4x.java.spi.ConversationContext;
import org.apache.plc4x.java.spi.Plc4xProtocolBase;
+import org.apache.plc4x.java.spi.connection.PlcTagHandler;
import org.apache.plc4x.java.spi.messages.DefaultPlcSubscriptionEvent;
import org.apache.plc4x.java.spi.messages.DefaultPlcSubscriptionResponse;
import org.apache.plc4x.java.spi.messages.DefaultPlcWriteResponse;
import org.apache.plc4x.java.spi.messages.PlcSubscriber;
-import org.apache.plc4x.java.spi.messages.utils.ResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.DefaultPlcResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.PlcResponseItem;
import org.apache.plc4x.java.spi.model.DefaultPlcConsumerRegistration;
import org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionTag;
import org.apache.plc4x.java.spi.values.PlcBOOL;
@@ -69,6 +72,11 @@ public class FirmataProtocolLogic extends Plc4xProtocolBase impl
private final Map> consumers = new ConcurrentHashMap<>();
+ @Override
+ public PlcTagHandler getTagHandler() {
+ return new FirmataTagHandler();
+ }
+
@Override
public void onConnect(ConversationContext context) {
LOGGER.debug("Sending Firmata Reset Command");
@@ -106,7 +114,7 @@ public CompletableFuture write(PlcWriteRequest writeRequest) {
final List firmataMessages =
((FirmataDriverContext) getDriverContext()).processWriteRequest(writeRequest);
for (FirmataMessage firmataMessage : firmataMessages) {
- context.sendToWire(firmataMessage);
+ conversationContext.sendToWire(firmataMessage);
}
// There's unfortunately no ack response :-(
Map result = new HashMap<>();
@@ -127,14 +135,14 @@ public CompletableFuture subscribe(PlcSubscriptionReque
final List firmataMessages =
((FirmataDriverContext) getDriverContext()).processSubscriptionRequest(subscriptionRequest);
for (FirmataMessage firmataMessage : firmataMessages) {
- context.sendToWire(firmataMessage);
+ conversationContext.sendToWire(firmataMessage);
}
- Map> result = new HashMap<>();
+ Map> result = new HashMap<>();
for (String tagName : subscriptionRequest.getTagNames()) {
DefaultPlcSubscriptionTag subscriptionTag =
(DefaultPlcSubscriptionTag) subscriptionRequest.getTag(tagName);
FirmataTag tag = (FirmataTag) subscriptionTag.getTag();
- result.put(tagName, new ResponseItem<>(PlcResponseCode.OK,
+ result.put(tagName, new DefaultPlcResponseItem<>(PlcResponseCode.OK,
new FirmataSubscriptionHandle(this, tagName, tag)));
}
future.complete(new DefaultPlcSubscriptionResponse(subscriptionRequest, result));
@@ -279,13 +287,13 @@ protected void sendUpdateEvents(Consumer consumer, String
// If it's just one element, return this as a direct PlcValue
if (values.size() == 1) {
final PlcSubscriptionEvent event = new DefaultPlcSubscriptionEvent(Instant.now(),
- Collections.singletonMap(tagName, new ResponseItem<>(PlcResponseCode.OK, values.get(0))));
+ Collections.singletonMap(tagName, new DefaultPlcResponseItem<>(PlcResponseCode.OK, values.get(0))));
consumer.accept(event);
}
// If it's more, return a PlcList instead.
else {
final PlcSubscriptionEvent event = new DefaultPlcSubscriptionEvent(Instant.now(),
- Collections.singletonMap(tagName, new ResponseItem<>(PlcResponseCode.OK, new PlcList(values))));
+ Collections.singletonMap(tagName, new DefaultPlcResponseItem<>(PlcResponseCode.OK, new PlcList(values))));
consumer.accept(event);
}
}
diff --git a/plc4j/drivers/iec-60870/src/main/java/org/apache/plc4x/java/iec608705104/readwrite/Iec60870514PlcDriver.java b/plc4j/drivers/iec-60870/src/main/java/org/apache/plc4x/java/iec608705104/readwrite/Iec60870514PlcDriver.java
index 559dde03160..bd0e5c80453 100644
--- a/plc4j/drivers/iec-60870/src/main/java/org/apache/plc4x/java/iec608705104/readwrite/Iec60870514PlcDriver.java
+++ b/plc4j/drivers/iec-60870/src/main/java/org/apache/plc4x/java/iec608705104/readwrite/Iec60870514PlcDriver.java
@@ -24,11 +24,9 @@
import org.apache.plc4x.java.iec608705104.readwrite.configuration.Iec608705014Configuration;
import org.apache.plc4x.java.iec608705104.readwrite.configuration.Iec608705014TcpTransportConfiguration;
import org.apache.plc4x.java.iec608705104.readwrite.protocol.Iec608705104Protocol;
-import org.apache.plc4x.java.iec608705104.readwrite.tag.Iec608705104TagHandler;
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;
@@ -83,16 +81,6 @@ protected List getSupportedTransportCodes() {
return Collections.singletonList("tcp");
}
- @Override
- 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
diff --git a/plc4j/drivers/iec-60870/src/main/java/org/apache/plc4x/java/iec608705104/readwrite/messages/Iec608705104PlcSubscriptionEvent.java b/plc4j/drivers/iec-60870/src/main/java/org/apache/plc4x/java/iec608705104/readwrite/messages/Iec608705104PlcSubscriptionEvent.java
index 25e732f9823..9c336c99ce3 100644
--- a/plc4j/drivers/iec-60870/src/main/java/org/apache/plc4x/java/iec608705104/readwrite/messages/Iec608705104PlcSubscriptionEvent.java
+++ b/plc4j/drivers/iec-60870/src/main/java/org/apache/plc4x/java/iec608705104/readwrite/messages/Iec608705104PlcSubscriptionEvent.java
@@ -22,7 +22,7 @@
import org.apache.plc4x.java.api.model.PlcTag;
import org.apache.plc4x.java.api.value.PlcValue;
import org.apache.plc4x.java.spi.messages.DefaultPlcSubscriptionEvent;
-import org.apache.plc4x.java.spi.messages.utils.ResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.PlcResponseItem;
import java.time.Instant;
import java.util.Map;
@@ -30,7 +30,7 @@
public class Iec608705104PlcSubscriptionEvent extends DefaultPlcSubscriptionEvent {
private final Map tags;
- public Iec608705104PlcSubscriptionEvent(Instant timestamp, Map tags, Map> values) {
+ public Iec608705104PlcSubscriptionEvent(Instant timestamp, Map tags, Map> values) {
super(timestamp, values);
this.tags = tags;
}
diff --git a/plc4j/drivers/iec-60870/src/main/java/org/apache/plc4x/java/iec608705104/readwrite/protocol/Iec608705104Protocol.java b/plc4j/drivers/iec-60870/src/main/java/org/apache/plc4x/java/iec608705104/readwrite/protocol/Iec608705104Protocol.java
index 12522494817..61e4a41e2cb 100644
--- a/plc4j/drivers/iec-60870/src/main/java/org/apache/plc4x/java/iec608705104/readwrite/protocol/Iec608705104Protocol.java
+++ b/plc4j/drivers/iec-60870/src/main/java/org/apache/plc4x/java/iec608705104/readwrite/protocol/Iec608705104Protocol.java
@@ -31,13 +31,16 @@
import org.apache.plc4x.java.iec608705104.readwrite.messages.Iec608705104PlcSubscriptionEvent;
import org.apache.plc4x.java.iec608705104.readwrite.model.Iec608705104SubscriptionHandle;
import org.apache.plc4x.java.iec608705104.readwrite.tag.Iec608705104Tag;
+import org.apache.plc4x.java.iec608705104.readwrite.tag.Iec608705104TagHandler;
import org.apache.plc4x.java.spi.ConversationContext;
import org.apache.plc4x.java.spi.Plc4xProtocolBase;
import org.apache.plc4x.java.spi.configuration.HasConfiguration;
+import org.apache.plc4x.java.spi.connection.PlcTagHandler;
import org.apache.plc4x.java.spi.messages.DefaultPlcSubscriptionResponse;
import org.apache.plc4x.java.spi.messages.PlcBrowser;
import org.apache.plc4x.java.spi.messages.PlcSubscriber;
-import org.apache.plc4x.java.spi.messages.utils.ResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.DefaultPlcResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.PlcResponseItem;
import org.apache.plc4x.java.spi.model.DefaultPlcConsumerRegistration;
import org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionTag;
import org.apache.plc4x.java.spi.transaction.RequestTransactionManager;
@@ -70,6 +73,11 @@ public void setConfiguration(Iec608705014Configuration configuration) {
this.configuration = configuration;
}
+ @Override
+ public PlcTagHandler getTagHandler() {
+ return new Iec608705104TagHandler();
+ }
+
@Override
public void close(ConversationContext context) {
tm.shutdown();
@@ -130,13 +138,13 @@ else if (msg instanceof APDUIFormat) {
@Override
public CompletableFuture subscribe(PlcSubscriptionRequest subscriptionRequest) {
- Map> values = new HashMap<>();
+ Map> values = new HashMap<>();
for (String tagName : subscriptionRequest.getTagNames()) {
final DefaultPlcSubscriptionTag tag = (DefaultPlcSubscriptionTag) subscriptionRequest.getTag(tagName);
if (!(tag.getTag() instanceof Iec608705104Tag)) {
- values.put(tagName, new ResponseItem<>(PlcResponseCode.INVALID_ADDRESS, null));
+ values.put(tagName, new DefaultPlcResponseItem<>(PlcResponseCode.INVALID_ADDRESS, null));
} else {
- values.put(tagName, new ResponseItem<>(PlcResponseCode.OK,
+ values.put(tagName, new DefaultPlcResponseItem<>(PlcResponseCode.OK,
new Iec608705104SubscriptionHandle(this, (Iec608705104Tag) tag.getTag())));
}
}
@@ -208,7 +216,7 @@ protected void publishEvent(LocalDateTime timeStamp, Iec608705104Tag tag, PlcVal
timeStamp.atZone(ZoneId.systemDefault()).toInstant(),
Collections.singletonMap(tag.toString(), tag),
Collections.singletonMap(tag.toString(),
- new ResponseItem<>(PlcResponseCode.OK, plcValue)));
+ new DefaultPlcResponseItem<>(PlcResponseCode.OK, plcValue)));
// Try sending the subscription event to all listeners.
for (Map.Entry> entry : consumers.entrySet()) {
diff --git a/plc4j/drivers/knxnetip/src/main/java/org/apache/plc4x/java/knxnetip/KnxNetIpDriver.java b/plc4j/drivers/knxnetip/src/main/java/org/apache/plc4x/java/knxnetip/KnxNetIpDriver.java
index fda82f4442d..5718f34b8cc 100644
--- a/plc4j/drivers/knxnetip/src/main/java/org/apache/plc4x/java/knxnetip/KnxNetIpDriver.java
+++ b/plc4j/drivers/knxnetip/src/main/java/org/apache/plc4x/java/knxnetip/KnxNetIpDriver.java
@@ -30,12 +30,9 @@
import org.apache.plc4x.java.knxnetip.context.KnxNetIpDriverContext;
import org.apache.plc4x.java.knxnetip.tag.KnxNetIpTag;
import org.apache.plc4x.java.knxnetip.readwrite.KnxNetIpMessage;
-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;
import org.apache.plc4x.java.spi.connection.SingleProtocolStackConfigurer;
import org.apache.plc4x.java.spi.optimizer.BaseOptimizer;
@@ -123,16 +120,6 @@ protected BaseOptimizer getOptimizer() {
return new SingleTagOptimizer();
}
- @Override
- 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; }
diff --git a/plc4j/drivers/knxnetip/src/main/java/org/apache/plc4x/java/knxnetip/protocol/KnxNetIpProtocolLogic.java b/plc4j/drivers/knxnetip/src/main/java/org/apache/plc4x/java/knxnetip/protocol/KnxNetIpProtocolLogic.java
index 962cbeb06d2..7b258a86ec6 100644
--- a/plc4j/drivers/knxnetip/src/main/java/org/apache/plc4x/java/knxnetip/protocol/KnxNetIpProtocolLogic.java
+++ b/plc4j/drivers/knxnetip/src/main/java/org/apache/plc4x/java/knxnetip/protocol/KnxNetIpProtocolLogic.java
@@ -32,12 +32,15 @@
import org.apache.plc4x.java.knxnetip.model.KnxNetIpSubscriptionHandle;
import org.apache.plc4x.java.knxnetip.readwrite.*;
import org.apache.plc4x.java.knxnetip.tag.KnxNetIpTag;
+import org.apache.plc4x.java.knxnetip.tag.KnxNetIpTagHandler;
import org.apache.plc4x.java.spi.ConversationContext;
import org.apache.plc4x.java.spi.Plc4xProtocolBase;
+import org.apache.plc4x.java.spi.connection.PlcTagHandler;
import org.apache.plc4x.java.spi.context.DriverContext;
import org.apache.plc4x.java.spi.generation.*;
import org.apache.plc4x.java.spi.messages.*;
-import org.apache.plc4x.java.spi.messages.utils.ResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.DefaultPlcResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.PlcResponseItem;
import org.apache.plc4x.java.spi.model.DefaultPlcConsumerRegistration;
import org.apache.plc4x.java.spi.model.DefaultPlcSubscriptionTag;
import org.apache.plc4x.java.spi.transaction.RequestTransactionManager;
@@ -80,6 +83,11 @@ public void setDriverContext(DriverContext driverContext) {
this.tm = new RequestTransactionManager(1);
}
+ @Override
+ public PlcTagHandler getTagHandler() {
+ return new KnxNetIpTagHandler();
+ }
+
@Override
public void close(ConversationContext context) {
tm.shutdown();
@@ -258,7 +266,7 @@ public CompletableFuture ping(PlcPingRequest pingRequest) {
new HPAIControlEndpoint(HostProtocolCode.IPV4_UDP,
knxNetIpDriverContext.getLocalIPAddress(),
knxNetIpDriverContext.getLocalPort()));
- context.sendRequest(connectionStateRequest)
+ conversationContext.sendRequest(connectionStateRequest)
.expectResponse(KnxNetIpMessage.class, Duration.ofMillis(1000))
.only(ConnectionStateResponse.class)
.handle(connectionStateResponse -> {
@@ -374,7 +382,7 @@ public CompletableFuture write(PlcWriteRequest writeRequest) {
// 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)
+ transaction.submit(() -> conversationContext.sendRequest(knxRequest)
.expectResponse(KnxNetIpMessage.class, REQUEST_TIMEOUT)
.onTimeout(future::completeExceptionally)
.onError((tr, e) -> future.completeExceptionally(e))
@@ -540,13 +548,13 @@ protected void processCemiData(KnxAddress sourceAddress, byte[] destinationGroup
@Override
public CompletableFuture subscribe(PlcSubscriptionRequest subscriptionRequest) {
- Map> values = new HashMap<>();
+ Map> values = new HashMap<>();
for (String tagName : subscriptionRequest.getTagNames()) {
final DefaultPlcSubscriptionTag tag = (DefaultPlcSubscriptionTag) subscriptionRequest.getTag(tagName);
if (!(tag.getTag() instanceof KnxNetIpTag)) {
- values.put(tagName, new ResponseItem<>(PlcResponseCode.INVALID_ADDRESS, null));
+ values.put(tagName, new DefaultPlcResponseItem<>(PlcResponseCode.INVALID_ADDRESS, null));
} else {
- values.put(tagName, new ResponseItem<>(PlcResponseCode.OK,
+ values.put(tagName, new DefaultPlcResponseItem<>(PlcResponseCode.OK,
new KnxNetIpSubscriptionHandle(this, (KnxNetIpTag) tag.getTag())));
}
}
@@ -572,7 +580,7 @@ protected void publishEvent(GroupAddress groupAddress, PlcValue plcValue) {
// Create a subscription event from the input.
// TODO: Check this ... this is sort of not really right ...
final PlcSubscriptionEvent event = new DefaultPlcSubscriptionEvent(Instant.now(),
- Collections.singletonMap("knxData", new ResponseItem<>(PlcResponseCode.OK, plcValue)));
+ Collections.singletonMap("knxData", new DefaultPlcResponseItem<>(PlcResponseCode.OK, plcValue)));
// Try sending the subscription event to all listeners.
for (Map.Entry> entry : consumers.entrySet()) {
diff --git a/plc4j/drivers/knxnetip/src/test/java/org/apache/plc4x/java/knxnetip/ManualKnxNetIp.java b/plc4j/drivers/knxnetip/src/test/java/org/apache/plc4x/java/knxnetip/ManualKnxNetIp.java
index 7e3a1b32eaa..9cadd0191d6 100644
--- a/plc4j/drivers/knxnetip/src/test/java/org/apache/plc4x/java/knxnetip/ManualKnxNetIp.java
+++ b/plc4j/drivers/knxnetip/src/test/java/org/apache/plc4x/java/knxnetip/ManualKnxNetIp.java
@@ -38,8 +38,8 @@ public class ManualKnxNetIp {
// */*/101: Power Line 1
public static void main(String[] args) throws Exception {
- //final PlcConnection connection = new PlcDriverManager().getConnection("knxnet-ip://192.168.42.11?knxproj-file-path=/Users/christofer.dutz/Projects/Apache/PLC4X-Documents/KNX/Stettiner%20Str.%2013/StettinerStr-Soll-Ist-Temperatur.knxproj");
- final PlcConnection connection = new DefaultPlcDriverManager().getConnection("knxnet-ip:pcap:///Users/christofer.dutz/Projects/Apache/PLC4X-Documents/KNX/Recording-01.03.2020-2.pcapng?knxproj-file-path=/Users/christofer.dutz/Projects/Apache/PLC4X-Documents/KNX/Stettiner%20Str.%2013/StettinerStr-Soll-Ist-Temperatur.knxproj");
+ final PlcConnection connection = new DefaultPlcDriverManager().getConnection("knxnet-ip://192.168.42.11?knxproj-file-path=/Users/christofer.dutz/Projects/Apache/PLC4X-Documents/KNX/Stettiner%20Str.%2013/StettinerStr-Soll-Ist-Temperatur.knxproj");
+ //final PlcConnection connection = new DefaultPlcDriverManager().getConnection("knxnet-ip:pcap:///Users/christofer.dutz/Projects/Apache/PLC4X-Documents/KNX/Recording-01.03.2020-2.pcapng?knxproj-file-path=/Users/christofer.dutz/Projects/Apache/PLC4X-Documents/KNX/Stettiner%20Str.%2013/StettinerStr-Soll-Ist-Temperatur.knxproj");
// Make sure we hang up correctly when terminating.
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
try {
diff --git a/plc4j/drivers/knxnetip/src/test/resources/logback-test.xml b/plc4j/drivers/knxnetip/src/test/resources/logback-test.xml
index 33ae65561c2..16b83b4882c 100644
--- a/plc4j/drivers/knxnetip/src/test/resources/logback-test.xml
+++ b/plc4j/drivers/knxnetip/src/test/resources/logback-test.xml
@@ -27,7 +27,7 @@
-
+
diff --git a/plc4j/drivers/mock/src/main/java/org/apache/plc4x/java/mock/connection/MockConnection.java b/plc4j/drivers/mock/src/main/java/org/apache/plc4x/java/mock/connection/MockConnection.java
index 0ad98b39e66..b3c4d3a3712 100644
--- a/plc4j/drivers/mock/src/main/java/org/apache/plc4x/java/mock/connection/MockConnection.java
+++ b/plc4j/drivers/mock/src/main/java/org/apache/plc4x/java/mock/connection/MockConnection.java
@@ -21,6 +21,7 @@
import org.apache.commons.lang3.Validate;
import org.apache.plc4x.java.api.PlcConnection;
import org.apache.plc4x.java.api.authentication.PlcAuthentication;
+import org.apache.plc4x.java.api.exceptions.PlcRuntimeException;
import org.apache.plc4x.java.api.messages.*;
import org.apache.plc4x.java.api.metadata.PlcConnectionMetadata;
import org.apache.plc4x.java.api.model.PlcConsumerRegistration;
@@ -30,7 +31,8 @@
import org.apache.plc4x.java.api.value.PlcValue;
import org.apache.plc4x.java.mock.tag.MockTagHandler;
import org.apache.plc4x.java.spi.messages.*;
-import org.apache.plc4x.java.spi.messages.utils.ResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.PlcResponseItem;
+import org.apache.plc4x.java.spi.values.DefaultPlcValueHandler;
import org.apache.plc4x.java.spi.values.PlcValueHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -48,6 +50,8 @@ public class MockConnection implements PlcConnection, PlcReader, PlcWriter, PlcS
private static final Logger LOGGER = LoggerFactory.getLogger(MockConnection.class);
+ private PlcValueHandler valueHandler;
+
private final PlcAuthentication authentication;
private MockDevice device;
@@ -63,9 +67,21 @@ public MockDevice getDevice() {
private final MockTagHandler mockTagHandler = new MockTagHandler();
public void setDevice(MockDevice device) {
LOGGER.info("Set Mock Device on Mock Connection {} with device {}", this, device);
+ this.valueHandler = new DefaultPlcValueHandler();
this.device = device;
}
+ @Override
+ public Optional parseTagValue(PlcTag tag, Object... values) {
+ PlcValue plcValue;
+ try {
+ plcValue = valueHandler.newPlcValue(tag, values);
+ } catch (Exception e) {
+ throw new PlcRuntimeException("Error parsing tag value " + tag, e);
+ }
+ return Optional.of(plcValue);
+ }
+
@Override
public void connect() {
// do nothing
@@ -145,7 +161,7 @@ public CompletableFuture read(PlcReadRequest readRequest) {
return CompletableFuture.supplyAsync(() -> {
Validate.notNull(device, "No device is set in the mock connection!");
LOGGER.debug("Sending read request to MockDevice");
- Map> response = readRequest.getTagNames().stream()
+ Map> response = readRequest.getTagNames().stream()
.collect(Collectors.toMap(
Function.identity(),
name -> device.read(readRequest.getTag(name).getAddressString())
@@ -175,7 +191,7 @@ public CompletableFuture subscribe(PlcSubscriptionReque
return CompletableFuture.supplyAsync(() -> {
Validate.notNull(device, "No device is set in the mock connection!");
LOGGER.debug("Sending subsribe request to MockDevice");
- Map> response = subscriptionRequest.getTagNames().stream()
+ Map> response = subscriptionRequest.getTagNames().stream()
.collect(Collectors.toMap(
Function.identity(),
name -> device.subscribe(subscriptionRequest.getTag(name).getAddressString())
@@ -207,7 +223,7 @@ public void unregister(PlcConsumerRegistration registration) {
@Override
public PlcWriteRequest.Builder writeRequestBuilder() {
- return new DefaultPlcWriteRequest.Builder(this, mockTagHandler, new PlcValueHandler());
+ return new DefaultPlcWriteRequest.Builder(this, mockTagHandler, new DefaultPlcValueHandler());
}
@Override
diff --git a/plc4j/drivers/mock/src/main/java/org/apache/plc4x/java/mock/connection/MockDevice.java b/plc4j/drivers/mock/src/main/java/org/apache/plc4x/java/mock/connection/MockDevice.java
index 7537a60fc21..da616037423 100644
--- a/plc4j/drivers/mock/src/main/java/org/apache/plc4x/java/mock/connection/MockDevice.java
+++ b/plc4j/drivers/mock/src/main/java/org/apache/plc4x/java/mock/connection/MockDevice.java
@@ -18,13 +18,12 @@
*/
package org.apache.plc4x.java.mock.connection;
-import org.apache.commons.lang3.tuple.Pair;
import org.apache.plc4x.java.api.messages.PlcSubscriptionEvent;
import org.apache.plc4x.java.api.model.PlcConsumerRegistration;
import org.apache.plc4x.java.api.model.PlcSubscriptionHandle;
import org.apache.plc4x.java.api.types.PlcResponseCode;
import org.apache.plc4x.java.api.value.PlcValue;
-import org.apache.plc4x.java.spi.messages.utils.ResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.PlcResponseItem;
import java.util.Collection;
import java.util.function.Consumer;
@@ -34,11 +33,11 @@
*/
public interface MockDevice {
- ResponseItem read(String tagQuery);
+ PlcResponseItem read(String tagQuery);
PlcResponseCode write(String tagQuery, Object value);
- ResponseItem subscribe(String tagQuery);
+ PlcResponseItem subscribe(String tagQuery);
void unsubscribe();
diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/ModbusAsciiDriver.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/ModbusAsciiDriver.java
index c698b342ff8..20006d99fc9 100644
--- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/ModbusAsciiDriver.java
+++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/ModbusAsciiDriver.java
@@ -22,14 +22,11 @@
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;
import org.apache.plc4x.java.modbus.ascii.protocol.ModbusAsciiProtocolLogic;
import org.apache.plc4x.java.modbus.base.tag.ModbusTag;
-import org.apache.plc4x.java.modbus.base.tag.ModbusTagHandler;
import org.apache.plc4x.java.modbus.readwrite.DriverType;
import org.apache.plc4x.java.modbus.readwrite.ModbusAsciiADU;
import org.apache.plc4x.java.modbus.tcp.config.ModbusTcpTransportConfiguration;
@@ -39,7 +36,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;
@@ -122,16 +118,6 @@ protected BaseOptimizer getOptimizer() {
return new SingleTagOptimizer();
}
- @Override
- protected ModbusTagHandler getTagHandler() {
- return new ModbusTagHandler();
- }
-
- @Override
- protected org.apache.plc4x.java.api.value.PlcValueHandler getValueHandler() {
- return new PlcValueHandler();
- }
-
@Override
protected ProtocolStackConfigurer getStackConfigurer() {
return SingleProtocolStackConfigurer.builder(ModbusAsciiADU.class, new ModbusAsciiInput(), new ModbusAsciiOutput())
diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/protocol/ModbusAsciiProtocolLogic.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/protocol/ModbusAsciiProtocolLogic.java
index 47b5a86da62..f3f9084eae8 100644
--- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/protocol/ModbusAsciiProtocolLogic.java
+++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/ascii/protocol/ModbusAsciiProtocolLogic.java
@@ -26,13 +26,15 @@
import org.apache.plc4x.java.modbus.ascii.config.ModbusAsciiConfiguration;
import org.apache.plc4x.java.modbus.base.tag.ModbusTag;
import org.apache.plc4x.java.modbus.base.protocol.ModbusProtocolLogic;
+import org.apache.plc4x.java.modbus.base.tag.ModbusTagHandler;
import org.apache.plc4x.java.modbus.readwrite.*;
import org.apache.plc4x.java.modbus.types.ModbusByteOrder;
import org.apache.plc4x.java.spi.ConversationContext;
import org.apache.plc4x.java.spi.configuration.HasConfiguration;
+import org.apache.plc4x.java.spi.connection.PlcTagHandler;
import org.apache.plc4x.java.spi.generation.ParseException;
import org.apache.plc4x.java.spi.messages.*;
-import org.apache.plc4x.java.spi.messages.utils.ResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.DefaultPlcResponseItem;
import org.apache.plc4x.java.spi.transaction.RequestTransactionManager;
import java.time.Duration;
@@ -53,6 +55,11 @@ public void setConfiguration(ModbusAsciiConfiguration configuration) {
this.tm = new RequestTransactionManager(1);
}
+ @Override
+ public PlcTagHandler getTagHandler() {
+ return new ModbusTagHandler();
+ }
+
@Override
public void close(ConversationContext context) {
tm.shutdown();
@@ -70,7 +77,7 @@ public CompletableFuture ping(PlcPingRequest pingRequest) {
ModbusAsciiADU modbusTcpADU = new ModbusAsciiADU(unitId, readRequestPdu);
RequestTransactionManager.RequestTransaction transaction = tm.startRequest();
- transaction.submit(() -> context.sendRequest(modbusTcpADU)
+ transaction.submit(() -> conversationContext.sendRequest(modbusTcpADU)
.expectResponse(ModbusAsciiADU.class, requestTimeout)
.onTimeout(future::completeExceptionally)
.onError((p, e) -> future.completeExceptionally(e))
@@ -106,7 +113,7 @@ public CompletableFuture read(PlcReadRequest readRequest) {
ModbusAsciiADU modbusAsciiADU = new ModbusAsciiADU(unitId, requestPdu);
RequestTransactionManager.RequestTransaction transaction = tm.startRequest();
- transaction.submit(() -> context.sendRequest(modbusAsciiADU)
+ transaction.submit(() -> conversationContext.sendRequest(modbusAsciiADU)
.expectResponse(ModbusAsciiADU.class, requestTimeout)
.onTimeout(future::completeExceptionally)
.onError((p, e) -> future.completeExceptionally(e))
@@ -135,7 +142,7 @@ public CompletableFuture read(PlcReadRequest readRequest) {
// Prepare the response.
PlcReadResponse response = new DefaultPlcReadResponse(request,
- Collections.singletonMap(tagName, new ResponseItem<>(responseCode, plcValue)));
+ Collections.singletonMap(tagName, new DefaultPlcResponseItem<>(responseCode, plcValue)));
// Pass the response back to the application.
future.complete(response);
@@ -169,7 +176,7 @@ public CompletableFuture write(PlcWriteRequest writeRequest) {
final short unitId = getUnitId(tag);
ModbusAsciiADU modbusAsciiADU = new ModbusAsciiADU(unitId, requestPdu);
RequestTransactionManager.RequestTransaction transaction = tm.startRequest();
- transaction.submit(() -> context.sendRequest(modbusAsciiADU)
+ transaction.submit(() -> conversationContext.sendRequest(modbusAsciiADU)
.expectResponse(ModbusAsciiADU.class, requestTimeout)
.onTimeout(future::completeExceptionally)
.onError((p, e) -> future.completeExceptionally(e))
diff --git a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/optimizer/ModbusOptimizer.java b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/optimizer/ModbusOptimizer.java
index d88998472b1..78b092282c7 100644
--- a/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/optimizer/ModbusOptimizer.java
+++ b/plc4j/drivers/modbus/src/main/java/org/apache/plc4x/java/modbus/base/optimizer/ModbusOptimizer.java
@@ -45,7 +45,10 @@
import org.apache.plc4x.java.spi.messages.DefaultPlcReadRequest;
import org.apache.plc4x.java.spi.messages.DefaultPlcReadResponse;
import org.apache.plc4x.java.spi.messages.PlcReader;
-import org.apache.plc4x.java.spi.messages.utils.ResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.DefaultPlcTagItem;
+import org.apache.plc4x.java.spi.messages.utils.DefaultPlcResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.PlcResponseItem;
+import org.apache.plc4x.java.spi.messages.utils.PlcTagItem;
import org.apache.plc4x.java.spi.optimizer.SingleTagOptimizer;
import org.apache.plc4x.java.spi.values.PlcBOOL;
import org.slf4j.Logger;
@@ -179,12 +182,12 @@ protected PlcReadResponse processReadResponses(PlcReadRequest readRequest, Map