diff --git a/code-generation/language-go/src/main/resources/templates/go/complex-type-template.go.ftlh b/code-generation/language-go/src/main/resources/templates/go/complex-type-template.go.ftlh index 3a2db77fe66..d03ecbe5299 100644 --- a/code-generation/language-go/src/main/resources/templates/go/complex-type-template.go.ftlh +++ b/code-generation/language-go/src/main/resources/templates/go/complex-type-template.go.ftlh @@ -837,13 +837,13 @@ func ${type.name}ParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffe <#-- If this is a count array, we can directly initialize an array with the given size --> <#if field.isCountArrayField()> // Count array - ${arrayField.name} := make(${helper.getLanguageTypeNameForField(field)}, ${helper.toIntegerParseExpression(arrayField, 16, arrayField.loopExpression, parserArguments)}) + ${arrayField.name} := make(${helper.getLanguageTypeNameForField(field)}, utils.Max(${helper.toIntegerParseExpression(arrayField, 16, arrayField.loopExpression, parserArguments)}, 0)) // This happens when the size is set conditional to 0 if len(${arrayField.name}) == 0 { ${arrayField.name} = nil } { - _numItems := uint16(${helper.toIntegerParseExpression(arrayField, 16, arrayField.loopExpression, parserArguments)}) + _numItems := uint16(utils.Max(${helper.toIntegerParseExpression(arrayField, 16, arrayField.loopExpression, parserArguments)}, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) <#-- TODO: find a way to do this nicer --> diff --git a/plc4go/go.mod b/plc4go/go.mod index 60e531b8619..b1fd1e24fbd 100644 --- a/plc4go/go.mod +++ b/plc4go/go.mod @@ -44,8 +44,8 @@ require ( github.com/subchen/go-xmldom v1.1.2 github.com/viney-shih/go-lock v1.1.2 golang.org/x/exp v0.0.0-20230213192124-5e25df0256eb - golang.org/x/net v0.13.0 - golang.org/x/tools v0.11.1 + golang.org/x/net v0.14.0 + golang.org/x/tools v0.12.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -74,8 +74,8 @@ require ( github.com/subosito/gotenv v1.4.2 // indirect golang.org/x/mod v0.12.0 // indirect golang.org/x/sync v0.3.0 // indirect - golang.org/x/sys v0.10.0 // indirect - golang.org/x/term v0.10.0 // indirect - golang.org/x/text v0.11.0 // indirect + golang.org/x/sys v0.11.0 // indirect + golang.org/x/term v0.11.0 // indirect + golang.org/x/text v0.12.0 // indirect gopkg.in/ini.v1 v1.67.0 // indirect ) diff --git a/plc4go/go.sum b/plc4go/go.sum index dd06c899726..4a94bccca0b 100644 --- a/plc4go/go.sum +++ b/plc4go/go.sum @@ -329,8 +329,8 @@ golang.org/x/net v0.0.0-20201224014010-6772e930b67b/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.13.0 h1:Nvo8UFsZ8X3BhAC9699Z1j7XQ3rsZnUUm7jfBEk1ueY= -golang.org/x/net v0.13.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= +golang.org/x/net v0.14.0 h1:BONx9s002vGdD9umnlX1Po8vOZmrgH34qlHcD1MfK14= +golang.org/x/net v0.14.0/go.mod h1:PpSgVXXLK0OxS0F31C1/tv6XNguvCrnXIDrFMspZIUI= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -396,14 +396,14 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= -golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.11.0 h1:eG7RXZHdqOJ1i+0lgLgCpSXAp6M3LYlAo6osgSi0xOM= +golang.org/x/sys v0.11.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.6.0/go.mod h1:m6U89DPEgQRMq3DNkDClhWw02AUbt2daBVO4cn4Hv9U= -golang.org/x/term v0.10.0 h1:3R7pNqamzBraeqj/Tj8qt1aQ2HpmlC+Cx/qL/7hn4/c= -golang.org/x/term v0.10.0/go.mod h1:lpqdcUyK/oCiQxvxVrppt5ggO2KCZ5QblwqPnfZ6d5o= +golang.org/x/term v0.11.0 h1:F9tnn/DA/Im8nCwm+fX+1/eBwi4qFjRT++MhtVC4ZX0= +golang.org/x/term v0.11.0/go.mod h1:zC9APTIj3jG3FdV/Ons+XE1riIZXG4aZ4GTHiPZJPIU= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -413,8 +413,8 @@ golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= -golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/text v0.12.0 h1:k+n5B8goJNdU7hSvEtMUz3d1Q6D/XW4COJSJR6fN0mc= +golang.org/x/text v0.12.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= @@ -466,8 +466,8 @@ golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4f golang.org/x/tools v0.0.0-20210108195828-e2f9c7f1fc8e/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.11.1 h1:ojD5zOW8+7dOGzdnNgersm8aPfcDjhMp12UfG93NIMc= -golang.org/x/tools v0.11.1/go.mod h1:anzJrxPjNtfgiYQYirP2CPGzGLxrH2u2QBhn6Bf3qY8= +golang.org/x/tools v0.12.0 h1:YW6HUoUmYBpwSgyaGaZq1fHjrBjX1rlpZ54T6mu2kss= +golang.org/x/tools v0.12.0/go.mod h1:Sc0INKfu04TlqNoRA1hgpFZbhYXHPr4V5DzpSBTPqQM= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/plc4go/internal/ads/mock_SymbolicPlcQuery_test.go b/plc4go/internal/ads/mock_SymbolicPlcQuery_test.go index 66192213b79..736e1b9a1f1 100644 --- a/plc4go/internal/ads/mock_SymbolicPlcQuery_test.go +++ b/plc4go/internal/ads/mock_SymbolicPlcQuery_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package ads diff --git a/plc4go/internal/bacnetip/mock_BacNetPlcTag_test.go b/plc4go/internal/bacnetip/mock_BacNetPlcTag_test.go index 66cfb88e6f7..da6ee646bf4 100644 --- a/plc4go/internal/bacnetip/mock_BacNetPlcTag_test.go +++ b/plc4go/internal/bacnetip/mock_BacNetPlcTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package bacnetip diff --git a/plc4go/internal/bacnetip/mock_OneShotTaskRequirements_test.go b/plc4go/internal/bacnetip/mock_OneShotTaskRequirements_test.go index ed9b75d06c5..ce49121ccfe 100644 --- a/plc4go/internal/bacnetip/mock_OneShotTaskRequirements_test.go +++ b/plc4go/internal/bacnetip/mock_OneShotTaskRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package bacnetip diff --git a/plc4go/internal/bacnetip/mock_PDUOption_test.go b/plc4go/internal/bacnetip/mock_PDUOption_test.go index cea4174eb22..c9e8b8453da 100644 --- a/plc4go/internal/bacnetip/mock_PDUOption_test.go +++ b/plc4go/internal/bacnetip/mock_PDUOption_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package bacnetip diff --git a/plc4go/internal/bacnetip/mock_RecurringTaskRequirements_test.go b/plc4go/internal/bacnetip/mock_RecurringTaskRequirements_test.go index 0741b5c62f6..6a4cb9c15b6 100644 --- a/plc4go/internal/bacnetip/mock_RecurringTaskRequirements_test.go +++ b/plc4go/internal/bacnetip/mock_RecurringTaskRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package bacnetip diff --git a/plc4go/internal/bacnetip/mock_SSMProcessingRequirements_test.go b/plc4go/internal/bacnetip/mock_SSMProcessingRequirements_test.go index 1a1e256e1cb..ad45a0d204e 100644 --- a/plc4go/internal/bacnetip/mock_SSMProcessingRequirements_test.go +++ b/plc4go/internal/bacnetip/mock_SSMProcessingRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package bacnetip diff --git a/plc4go/internal/bacnetip/mock_SSMSAPRequirements_test.go b/plc4go/internal/bacnetip/mock_SSMSAPRequirements_test.go index 549bab9ee3e..910de48508e 100644 --- a/plc4go/internal/bacnetip/mock_SSMSAPRequirements_test.go +++ b/plc4go/internal/bacnetip/mock_SSMSAPRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package bacnetip diff --git a/plc4go/internal/bacnetip/mock_WhoIsIAmServicesRequirements_test.go b/plc4go/internal/bacnetip/mock_WhoIsIAmServicesRequirements_test.go index 37c723dd51a..ef71ffa5630 100644 --- a/plc4go/internal/bacnetip/mock_WhoIsIAmServicesRequirements_test.go +++ b/plc4go/internal/bacnetip/mock_WhoIsIAmServicesRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package bacnetip diff --git a/plc4go/internal/bacnetip/mock__ApplicationServiceElement_test.go b/plc4go/internal/bacnetip/mock__ApplicationServiceElement_test.go index 662bd90c8ba..9e50feee03a 100644 --- a/plc4go/internal/bacnetip/mock__ApplicationServiceElement_test.go +++ b/plc4go/internal/bacnetip/mock__ApplicationServiceElement_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package bacnetip diff --git a/plc4go/internal/bacnetip/mock__BIPSAP_test.go b/plc4go/internal/bacnetip/mock__BIPSAP_test.go index ec9d69c01f0..2085205a4bc 100644 --- a/plc4go/internal/bacnetip/mock__BIPSAP_test.go +++ b/plc4go/internal/bacnetip/mock__BIPSAP_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package bacnetip diff --git a/plc4go/internal/bacnetip/mock__Client_test.go b/plc4go/internal/bacnetip/mock__Client_test.go index bf57fc86dfe..ad625ef089e 100644 --- a/plc4go/internal/bacnetip/mock__Client_test.go +++ b/plc4go/internal/bacnetip/mock__Client_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package bacnetip diff --git a/plc4go/internal/bacnetip/mock__IOCB_test.go b/plc4go/internal/bacnetip/mock__IOCB_test.go index 486a976059b..e1869a3e3d5 100644 --- a/plc4go/internal/bacnetip/mock__IOCB_test.go +++ b/plc4go/internal/bacnetip/mock__IOCB_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package bacnetip diff --git a/plc4go/internal/bacnetip/mock__IOController_test.go b/plc4go/internal/bacnetip/mock__IOController_test.go index 549363fefb7..98aa6366d96 100644 --- a/plc4go/internal/bacnetip/mock__IOController_test.go +++ b/plc4go/internal/bacnetip/mock__IOController_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package bacnetip diff --git a/plc4go/internal/bacnetip/mock__IOQController_test.go b/plc4go/internal/bacnetip/mock__IOQController_test.go index c6b9d5c7142..dc9954ee971 100644 --- a/plc4go/internal/bacnetip/mock__IOQController_test.go +++ b/plc4go/internal/bacnetip/mock__IOQController_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package bacnetip diff --git a/plc4go/internal/bacnetip/mock__PDU_test.go b/plc4go/internal/bacnetip/mock__PDU_test.go index c6207756fb0..fabe507c5c0 100644 --- a/plc4go/internal/bacnetip/mock__PDU_test.go +++ b/plc4go/internal/bacnetip/mock__PDU_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package bacnetip diff --git a/plc4go/internal/bacnetip/mock__Server_test.go b/plc4go/internal/bacnetip/mock__Server_test.go index 8b5c82cd6a6..54ea6809300 100644 --- a/plc4go/internal/bacnetip/mock__Server_test.go +++ b/plc4go/internal/bacnetip/mock__Server_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package bacnetip diff --git a/plc4go/internal/bacnetip/mock__ServiceAccessPoint_test.go b/plc4go/internal/bacnetip/mock__ServiceAccessPoint_test.go index 023f326702f..7dfc4ba9571 100644 --- a/plc4go/internal/bacnetip/mock__ServiceAccessPoint_test.go +++ b/plc4go/internal/bacnetip/mock__ServiceAccessPoint_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package bacnetip diff --git a/plc4go/internal/bacnetip/mock__TaskRequirements_test.go b/plc4go/internal/bacnetip/mock__TaskRequirements_test.go index 12717db1309..73382a9b095 100644 --- a/plc4go/internal/bacnetip/mock__TaskRequirements_test.go +++ b/plc4go/internal/bacnetip/mock__TaskRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package bacnetip diff --git a/plc4go/internal/bacnetip/mock_option_test.go b/plc4go/internal/bacnetip/mock_option_test.go index 9954e175669..0f314841afb 100644 --- a/plc4go/internal/bacnetip/mock_option_test.go +++ b/plc4go/internal/bacnetip/mock_option_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package bacnetip diff --git a/plc4go/internal/cbus/Browser.go b/plc4go/internal/cbus/Browser.go index 7c03690e12a..ee6e3f79f2c 100644 --- a/plc4go/internal/cbus/Browser.go +++ b/plc4go/internal/cbus/Browser.go @@ -96,11 +96,11 @@ unitLoop: Uint8("unitAddress", unitAddress). Msg("Querying all attributes of unit") } - event := m.log.Info() + level := zerolog.InfoLevel if allUnits { - event = m.log.Debug() + level = zerolog.DebugLevel } - event.Uint8("unitAddress", unitAddress).Msg("Query unit") + m.log.WithLevel(level).Uint8("unitAddress", unitAddress).Msg("Query unit") for _, attribute := range attributes { if err := ctx.Err(); err != nil { unitLog.Info().Err(err).Msg("Aborting scan at unit") @@ -112,7 +112,7 @@ unitLoop: Stringer("attribute", attribute). Msg("Querying attribute of unit") } else { - event.Uint8("unitAddress", unitAddress). + m.log.WithLevel(level).Uint8("unitAddress", unitAddress). Stringer("attribute", attribute). Msg("unit unitAddress: Query attribute") } @@ -132,9 +132,9 @@ unitLoop: timeoutCancel() if err := requestResult.GetErr(); err != nil { if allUnits || allAttributes { - event = m.log.Trace() + level = zerolog.TraceLevel } - event.Err(err). + m.log.WithLevel(level).Err(err). Uint8("unitAddress", unitAddress). Stringer("attribute", attribute). Msg("unit unitAddress: Can't read attribute attribute") @@ -142,7 +142,7 @@ unitLoop: } response := requestResult.GetResponse() if code := response.GetResponseCode(readTagName); code != apiModel.PlcResponseCode_OK { - event. + m.log.WithLevel(level). Uint8("unitAddress", unitAddress). Stringer("attribute", attribute). Stringer("code", code). diff --git a/plc4go/internal/cbus/mock_CALGetStatusTag_test.go b/plc4go/internal/cbus/mock_CALGetStatusTag_test.go index 9f306a5666f..55897f8da87 100644 --- a/plc4go/internal/cbus/mock_CALGetStatusTag_test.go +++ b/plc4go/internal/cbus/mock_CALGetStatusTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package cbus diff --git a/plc4go/internal/cbus/mock_CALIdentifyTag_test.go b/plc4go/internal/cbus/mock_CALIdentifyTag_test.go index ef53dccf05b..f1c238f91b7 100644 --- a/plc4go/internal/cbus/mock_CALIdentifyTag_test.go +++ b/plc4go/internal/cbus/mock_CALIdentifyTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package cbus diff --git a/plc4go/internal/cbus/mock_CALRecallTag_test.go b/plc4go/internal/cbus/mock_CALRecallTag_test.go index 3650b5ad830..70237f4a24a 100644 --- a/plc4go/internal/cbus/mock_CALRecallTag_test.go +++ b/plc4go/internal/cbus/mock_CALRecallTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package cbus diff --git a/plc4go/internal/cbus/mock_CalTag_test.go b/plc4go/internal/cbus/mock_CalTag_test.go index 6cc00c96c4d..cb1f3f4ac8c 100644 --- a/plc4go/internal/cbus/mock_CalTag_test.go +++ b/plc4go/internal/cbus/mock_CalTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package cbus diff --git a/plc4go/internal/cbus/mock_CommandAndArgumentsCount_test.go b/plc4go/internal/cbus/mock_CommandAndArgumentsCount_test.go index c1163c96957..0c2a7197131 100644 --- a/plc4go/internal/cbus/mock_CommandAndArgumentsCount_test.go +++ b/plc4go/internal/cbus/mock_CommandAndArgumentsCount_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package cbus diff --git a/plc4go/internal/cbus/mock_MMIMonitorTag_test.go b/plc4go/internal/cbus/mock_MMIMonitorTag_test.go index 3d05c6eb1c5..26e52bef4de 100644 --- a/plc4go/internal/cbus/mock_MMIMonitorTag_test.go +++ b/plc4go/internal/cbus/mock_MMIMonitorTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package cbus diff --git a/plc4go/internal/cbus/mock_RequestTransaction_test.go b/plc4go/internal/cbus/mock_RequestTransaction_test.go index 2aa422d1d0c..ddf9d3bcfea 100644 --- a/plc4go/internal/cbus/mock_RequestTransaction_test.go +++ b/plc4go/internal/cbus/mock_RequestTransaction_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package cbus diff --git a/plc4go/internal/cbus/mock_SALMonitorTag_test.go b/plc4go/internal/cbus/mock_SALMonitorTag_test.go index 2d1d2738144..aefd0f57a88 100644 --- a/plc4go/internal/cbus/mock_SALMonitorTag_test.go +++ b/plc4go/internal/cbus/mock_SALMonitorTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package cbus diff --git a/plc4go/internal/cbus/mock_SALTag_test.go b/plc4go/internal/cbus/mock_SALTag_test.go index 4cb78edc241..fba5e3e41d4 100644 --- a/plc4go/internal/cbus/mock_SALTag_test.go +++ b/plc4go/internal/cbus/mock_SALTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package cbus diff --git a/plc4go/internal/cbus/mock_StatusTag_test.go b/plc4go/internal/cbus/mock_StatusTag_test.go index 8a5b874a966..f294b0a64e6 100644 --- a/plc4go/internal/cbus/mock_StatusTag_test.go +++ b/plc4go/internal/cbus/mock_StatusTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package cbus diff --git a/plc4go/internal/cbus/mock_SubscriptionTag_test.go b/plc4go/internal/cbus/mock_SubscriptionTag_test.go index f142c679585..497f834d7ec 100644 --- a/plc4go/internal/cbus/mock_SubscriptionTag_test.go +++ b/plc4go/internal/cbus/mock_SubscriptionTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package cbus diff --git a/plc4go/internal/cbus/mock_Tag_test.go b/plc4go/internal/cbus/mock_Tag_test.go index 5f388433512..556338f4bba 100644 --- a/plc4go/internal/cbus/mock_Tag_test.go +++ b/plc4go/internal/cbus/mock_Tag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package cbus diff --git a/plc4go/internal/cbus/mock_UnitInfoQuery_test.go b/plc4go/internal/cbus/mock_UnitInfoQuery_test.go index 24516cdcd9e..30a69f6f5d1 100644 --- a/plc4go/internal/cbus/mock_UnitInfoQuery_test.go +++ b/plc4go/internal/cbus/mock_UnitInfoQuery_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package cbus diff --git a/plc4go/internal/cbus/mock_addressProvider_test.go b/plc4go/internal/cbus/mock_addressProvider_test.go index fd92cfacacd..61a37e7b89b 100644 --- a/plc4go/internal/cbus/mock_addressProvider_test.go +++ b/plc4go/internal/cbus/mock_addressProvider_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package cbus diff --git a/plc4go/internal/eip/mock_PlcTag_test.go b/plc4go/internal/eip/mock_PlcTag_test.go index 95ca856b6fc..562aef895fb 100644 --- a/plc4go/internal/eip/mock_PlcTag_test.go +++ b/plc4go/internal/eip/mock_PlcTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package eip diff --git a/plc4go/internal/knxnetip/mock_DeviceTag_test.go b/plc4go/internal/knxnetip/mock_DeviceTag_test.go index 2e87b14aff0..790056eaf29 100644 --- a/plc4go/internal/knxnetip/mock_DeviceTag_test.go +++ b/plc4go/internal/knxnetip/mock_DeviceTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package knxnetip diff --git a/plc4go/internal/knxnetip/mock_GroupAddressTag_test.go b/plc4go/internal/knxnetip/mock_GroupAddressTag_test.go index d0cb62f8a1e..3ebe0300a9f 100644 --- a/plc4go/internal/knxnetip/mock_GroupAddressTag_test.go +++ b/plc4go/internal/knxnetip/mock_GroupAddressTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package knxnetip diff --git a/plc4go/internal/knxnetip/mock_Tag_test.go b/plc4go/internal/knxnetip/mock_Tag_test.go index 776276a74bd..84be5353d3a 100644 --- a/plc4go/internal/knxnetip/mock_Tag_test.go +++ b/plc4go/internal/knxnetip/mock_Tag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package knxnetip diff --git a/plc4go/internal/opcua/Connection.go b/plc4go/internal/opcua/Connection.go index 9555967dd9c..5552ba32942 100644 --- a/plc4go/internal/opcua/Connection.go +++ b/plc4go/internal/opcua/Connection.go @@ -116,11 +116,19 @@ func (c *Connection) ConnectWithContext(ctx context.Context) <-chan plc4go.PlcCo c.fireConnectionError(errors.Errorf("panic-ed %v. Stack:\n%s", err, debug.Stack()), ch) } }() + c.log.Trace().Msg("connecting codec") if err := c.messageCodec.ConnectWithContext(ctx); err != nil { c.fireConnectionError(errors.Wrap(err, "Error connecting codec"), ch) return } + if c.driverContext.fireDiscoverEvent { + c.log.Trace().Msg("calling onDiscover") + c.channel.onDiscover(ctx, c.messageCodec) + } else { + c.log.Trace().Msg("we don't wait for session discover") + } + // For testing purposes we can skip the waiting for a complete connection if !c.driverContext.awaitSetupComplete { go c.setupConnection(ctx, ch) diff --git a/plc4go/internal/opcua/DriverContext.go b/plc4go/internal/opcua/DriverContext.go index 29748f233df..bf0fcc2c461 100644 --- a/plc4go/internal/opcua/DriverContext.go +++ b/plc4go/internal/opcua/DriverContext.go @@ -21,13 +21,17 @@ package opcua //go:generate go run ../../tools/plc4xgenerator/gen.go -type=DriverContext type DriverContext struct { - awaitSetupComplete bool - awaitDisconnectComplete bool + fireDiscoverEvent bool + awaitSetupComplete bool + awaitDisconnectComplete bool + awaitSessionDiscoverComplete bool } -func NewDriverContext(_ Configuration) DriverContext { +func NewDriverContext(configuration Configuration) DriverContext { return DriverContext{ - awaitSetupComplete: true, - awaitDisconnectComplete: true, + fireDiscoverEvent: configuration.isEncrypted, + awaitSetupComplete: true, + awaitDisconnectComplete: true, + awaitSessionDiscoverComplete: true, } } diff --git a/plc4go/internal/opcua/DriverContext_plc4xgen.go b/plc4go/internal/opcua/DriverContext_plc4xgen.go index ee23b924236..e6c003c10ed 100644 --- a/plc4go/internal/opcua/DriverContext_plc4xgen.go +++ b/plc4go/internal/opcua/DriverContext_plc4xgen.go @@ -43,6 +43,10 @@ func (d *DriverContext) SerializeWithWriteBuffer(ctx context.Context, writeBuffe return err } + if err := writeBuffer.WriteBit("fireDiscoverEvent", d.fireDiscoverEvent); err != nil { + return err + } + if err := writeBuffer.WriteBit("awaitSetupComplete", d.awaitSetupComplete); err != nil { return err } @@ -50,6 +54,10 @@ func (d *DriverContext) SerializeWithWriteBuffer(ctx context.Context, writeBuffe if err := writeBuffer.WriteBit("awaitDisconnectComplete", d.awaitDisconnectComplete); err != nil { return err } + + if err := writeBuffer.WriteBit("awaitSessionDiscoverComplete", d.awaitSessionDiscoverComplete); err != nil { + return err + } if err := writeBuffer.PopContext("DriverContext"); err != nil { return err } diff --git a/plc4go/internal/opcua/EncryptionHandler.go b/plc4go/internal/opcua/EncryptionHandler.go index ed32ea43702..fb897da09a2 100644 --- a/plc4go/internal/opcua/EncryptionHandler.go +++ b/plc4go/internal/opcua/EncryptionHandler.go @@ -135,6 +135,7 @@ func (h *EncryptionHandler) decodeMessage(ctx context.Context, pdu readWriteMode case readWriteModel.OpcuaMessageResponseExactly: message = pduMessage.GetMessage() default: + h.log.Trace().Type("pdu", pdu).Msg("unhandled type") return pdu, nil } encryptedLength := int(pdu.GetLengthInBytes(ctx)) @@ -168,8 +169,10 @@ func (h *EncryptionHandler) decodeMessage(ctx context.Context, pdu readWriteMode readBuffer := utils.NewReadBufferByteBased(buf.GetBytes(), utils.WithByteOrderForReadBufferByteBased(binary.LittleEndian)) return readWriteModel.OpcuaAPUParseWithBuffer(ctx, readBuffer, true) + default: + h.log.Trace().Msg("unmapped security policy") + return pdu, nil } - return pdu, nil } func (h *EncryptionHandler) decryptBlock(buf utils.WriteBufferByteBased, data []byte) error { diff --git a/plc4go/internal/opcua/MessageCodec.go b/plc4go/internal/opcua/MessageCodec.go index 28cb83189a7..29a5c689143 100644 --- a/plc4go/internal/opcua/MessageCodec.go +++ b/plc4go/internal/opcua/MessageCodec.go @@ -66,14 +66,18 @@ func (m *MessageCodec) Connect() error { func (m *MessageCodec) Send(message spi.Message) error { m.log.Trace().Stringer("message", message).Msg("Sending message") // Cast the message to the correct type of struct - messagePdu, ok := message.(readWriteModel.MessagePDU) + opcuaApu, ok := message.(readWriteModel.OpcuaAPU) if !ok { - return errors.Errorf("Invalid message type %T", message) + if message, ok := message.(readWriteModel.MessagePDU); ok { + opcuaApu = readWriteModel.NewOpcuaAPU(message, false) + } else { + return errors.Errorf("Invalid message type %T", message) + } } // Serialize the request wbbb := utils.NewWriteBufferByteBased(utils.WithByteOrderForByteBasedBuffer(binary.LittleEndian)) - if err := messagePdu.SerializeWithWriteBuffer(context.Background(), wbbb); err != nil { + if err := opcuaApu.SerializeWithWriteBuffer(context.Background(), wbbb); err != nil { return errors.Wrap(err, "error serializing request") } theBytes := wbbb.GetBytes() @@ -82,6 +86,7 @@ func (m *MessageCodec) Send(message spi.Message) error { if err := m.GetTransportInstance().Write(theBytes); err != nil { return errors.Wrap(err, "error sending request") } + m.log.Trace().Msg("bytes written to transport instance") return nil } @@ -118,10 +123,10 @@ func (m *MessageCodec) Receive() (spi.Message, error) { } ctxForModel := options.GetLoggerContextForModel(context.Background(), m.log, options.WithPassLoggerToModel(m.passLogToModel)) rbbb := utils.NewReadBufferByteBased(readBytes, utils.WithByteOrderForReadBufferByteBased(binary.LittleEndian)) - messagePdu, err := readWriteModel.MessagePDUParseWithBuffer(ctxForModel, rbbb, true) + opcuaAPU, err := readWriteModel.OpcuaAPUParseWithBuffer(ctxForModel, rbbb, true) if err != nil { return nil, errors.New("Could not parse pdu") } - - return messagePdu, nil + m.log.Debug().Stringer("opcuaAPU", opcuaAPU).Msg("got message") + return opcuaAPU, nil } diff --git a/plc4go/internal/opcua/Reader.go b/plc4go/internal/opcua/Reader.go index ad02ba73307..03d0f3936b7 100644 --- a/plc4go/internal/opcua/Reader.go +++ b/plc4go/internal/opcua/Reader.go @@ -126,15 +126,16 @@ func (m *Reader) readSync(ctx context.Context, readRequest apiModel.PlcReadReque result <- spiModel.NewDefaultPlcReadRequestResult(readRequest, nil, errors.Wrapf(err, "Unable to read the reply")) return } - if _readResponse, ok := reply.(readWriteModel.ReadResponseExactly); ok { + extensionObjectDefinition := reply.GetBody() + if _readResponse, ok := extensionObjectDefinition.(readWriteModel.ReadResponseExactly); ok { result <- spiModel.NewDefaultPlcReadRequestResult(readRequest, spiModel.NewDefaultPlcReadResponse(readResponse(m.log, readRequest, readRequest.GetTagNames(), _readResponse.GetResults())), nil) return } else { - if serviceFault, ok := reply.(readWriteModel.ServiceFaultExactly); ok { + if serviceFault, ok := extensionObjectDefinition.(readWriteModel.ServiceFaultExactly); ok { header := serviceFault.GetResponseHeader() m.log.Error().Stringer("header", header).Msg("Read request ended up with ServiceFault") } else { - m.log.Error().Stringer("reply", reply).Msg("Remote party returned an error") + m.log.Error().Stringer("extensionObjectDefinition", extensionObjectDefinition).Msg("Remote party returned an error") } responseCodes := map[string]apiModel.PlcResponseCode{} diff --git a/plc4go/internal/opcua/SecureChannel.go b/plc4go/internal/opcua/SecureChannel.go index 2eb817daea8..a2239e6948e 100644 --- a/plc4go/internal/opcua/SecureChannel.go +++ b/plc4go/internal/opcua/SecureChannel.go @@ -75,14 +75,9 @@ var ( readWriteModel.NewNullExtension(), false) // Body - INET_ADDRESS_PATTERN = regexp.MustCompile(`(.(?Ptcp))?://` + - `(?P[\\w.-]+)(:` + - `(?P\\d*))?`) + INET_ADDRESS_PATTERN = regexp.MustCompile(`(.(?Ptcp))?://(?P[\w.-]+)(:(?P\d*))?`) - URI_PATTERN = regexp.MustCompile(`^(?Popc)` + - INET_ADDRESS_PATTERN.String() + - `(?P[\\w/=]*)[\\?]?`, - ) + URI_PATTERN = regexp.MustCompile(`^(?Popc)` + INET_ADDRESS_PATTERN.String() + `(?P[\w/=]*)[?]?`) APPLICATION_URI = readWriteModel.NewPascalString("urn:apache:plc4x:client") PRODUCT_URI = readWriteModel.NewPascalString("urn:apache:plc4x:client") APPLICATION_TEXT = readWriteModel.NewPascalString("OPCUA client for the Apache PLC4X:PLC4J project") @@ -138,6 +133,7 @@ func NewSecureChannel(log zerolog.Logger, ctx DriverContext, configuration Confi password: configuration.password, securityPolicy: "http://opcfoundation.org/UA/SecurityPolicy#" + configuration.securityPolicy, sessionName: "UaSession:" + APPLICATION_TEXT.GetStringValue() + ":" + uniuri.NewLen(20), + authenticationToken: readWriteModel.NewNodeIdTwoByte(0), clientNonce: []byte(uniuri.NewLen(40)), keyStoreFile: configuration.keyStoreFile, channelTransactionManager: NewSecureChannelTransactionManager(log), @@ -165,15 +161,22 @@ func NewSecureChannel(log zerolog.Logger, ctx DriverContext, configuration Confi } // Generate a list of endpoints we can use. - if address, err := url.Parse("none:" + configuration.host); err != nil { - if names, err := net.LookupAddr(address.Host); err != nil { - s.endpoints = append(s.endpoints, names[rand.Intn(len(names))]) + { + var err error + address, err := url.Parse("none://" + configuration.host) + if err == nil { + if names, lookupErr := net.LookupHost(address.Host); lookupErr == nil { + s.endpoints = append(s.endpoints, names[rand.Intn(len(names))]) + s.endpoints = append(s.endpoints, address.Host) + //s.endpoints = append(s.endpoints, address.Host)//TODO: not sure if golang can do + } else { + err = lookupErr + } + } + if err != nil { + s.log.Warn().Err(err).Msg("Unable to resolve host name. Using original host from connection string which may cause issues connecting to server") + s.endpoints = append(s.endpoints, address.Host) } - s.endpoints = append(s.endpoints, address.Host) - //s.endpoints = append(s.endpoints, address.Host)//TODO: not sure if golang can do - } else { - s.log.Warn().Msg("Unable to resolve host name. Using original host from connection string which may cause issues connecting to server") - s.endpoints = append(s.endpoints, address.Host) } s.channelId.Store(1) @@ -225,6 +228,7 @@ func (s *SecureChannel) submit(ctx context.Context, codec *MessageCodec, errorDi opcuaAPU = decodedOpcuaAPU.(readWriteModel.OpcuaAPUExactly) } messagePDU := opcuaAPU.GetMessage() + s.log.Trace().Stringer("messagePDU", messagePDU).Msg("looking at messagePDU") opcuaResponse, ok := messagePDU.(readWriteModel.OpcuaMessageResponseExactly) if !ok { s.log.Debug().Type("type", message).Msg("Not relevant") @@ -249,12 +253,15 @@ func (s *SecureChannel) submit(ctx context.Context, codec *MessageCodec, errorDi opcuaAPU := message.(readWriteModel.OpcuaAPU) opcuaAPU, _ = s.encryptionHandler.decodeMessage(ctx, opcuaAPU) messagePDU := opcuaAPU.GetMessage() + s.log.Trace().Stringer("messagePDU", messagePDU).Msg("looking at messagePDU") opcuaResponse := messagePDU.(readWriteModel.OpcuaMessageResponse) if opcuaResponse.GetChunk() == (FINAL_CHUNK) { s.tokenId.Store(opcuaResponse.GetSecureTokenId()) s.channelId.Store(opcuaResponse.GetSecureChannelId()) consumer(messageBuffer) + } else { + s.log.Warn().Str("chunk", opcuaResponse.GetChunk()).Msg("Message discarded") } return nil }, @@ -312,7 +319,7 @@ func (s *SecureChannel) onConnect(ctx context.Context, connection *Connection, c opcuaAPU := message.(readWriteModel.OpcuaAPU) messagePDU := opcuaAPU.GetMessage() opcuaAcknowledgeResponse := messagePDU.(readWriteModel.OpcuaAcknowledgeResponse) - s.onConnectOpenSecureChannel(ctx, connection, ch, opcuaAcknowledgeResponse) + go s.onConnectOpenSecureChannel(ctx, connection, ch, opcuaAcknowledgeResponse) return nil }, func(err error) error { @@ -332,9 +339,6 @@ func (s *SecureChannel) onConnect(ctx context.Context, connection *Connection, c func (s *SecureChannel) onConnectOpenSecureChannel(ctx context.Context, connection *Connection, ch chan plc4go.PlcConnectionConnectResult, response readWriteModel.OpcuaAcknowledgeResponse) { transactionId := s.channelTransactionManager.getTransactionIdentifier() - if s.authenticationToken == nil { - panic("authenticationToken should be set at this point") - } requestHeader := readWriteModel.NewRequestHeader( s.getAuthenticationToken(), s.getCurrentDateTime(), @@ -458,13 +462,14 @@ func (s *SecureChannel) onConnectOpenSecureChannel(ctx context.Context, connecti Uint32("statusCode", statusCode). Stringer("statusCodeByValue", statusCodeByValue). Msg("Failed to connect to opc ua server for the following reason") - } else { - s.log.Debug().Msg("Got Secure Response Connection Response") - openSecureChannelResponse := extensionObject.GetBody().(readWriteModel.OpenSecureChannelResponse) - s.tokenId.Store(int32(openSecureChannelResponse.GetSecurityToken().(readWriteModel.ChannelSecurityToken).GetTokenId())) // TODO: strange that int32 and uint32 missmatch - s.channelId.Store(int32(openSecureChannelResponse.GetSecurityToken().(readWriteModel.ChannelSecurityToken).GetChannelId())) - s.onConnectCreateSessionRequest(ctx, connection, ch) + connection.fireConnectionError(errors.New("service fault received"), ch) + return nil } + s.log.Debug().Msg("Got Secure Response Connection Response") + openSecureChannelResponse := extensionObject.GetBody().(readWriteModel.OpenSecureChannelResponse) + s.tokenId.Store(int32(openSecureChannelResponse.GetSecurityToken().(readWriteModel.ChannelSecurityToken).GetTokenId())) // TODO: strange that int32 and uint32 missmatch + s.channelId.Store(int32(openSecureChannelResponse.GetSecurityToken().(readWriteModel.ChannelSecurityToken).GetChannelId())) + go s.onConnectCreateSessionRequest(ctx, connection, ch) return nil }, func(err error) error { @@ -486,9 +491,6 @@ func (s *SecureChannel) onConnectOpenSecureChannel(ctx context.Context, connecti } func (s *SecureChannel) onConnectCreateSessionRequest(ctx context.Context, connection *Connection, ch chan plc4go.PlcConnectionConnectResult) { - if s.authenticationToken == nil { - panic("authenticationToken should be set at this point") - } requestHeader := readWriteModel.NewRequestHeader( s.getAuthenticationToken(), s.getCurrentDateTime(), @@ -556,39 +558,36 @@ func (s *SecureChannel) onConnectCreateSessionRequest(ctx context.Context, conne } consumer := func(opcuaResponse []byte) { - message, err := readWriteModel.ExtensionObjectParseWithBuffer(ctx, utils.NewReadBufferByteBased(opcuaResponse, utils.WithByteOrderForReadBufferByteBased(binary.LittleEndian)), false) + extensionObject, err := readWriteModel.ExtensionObjectParseWithBuffer(ctx, utils.NewReadBufferByteBased(opcuaResponse, utils.WithByteOrderForReadBufferByteBased(binary.LittleEndian)), false) if err != nil { s.log.Error().Err(err).Msg("error parsing") connection.fireConnectionError(err, ch) return } - if fault, ok := message.GetBody().(readWriteModel.ServiceFaultExactly); ok { + s.log.Trace().Stringer("extensionObject", extensionObject).Msg("looking at message") + if fault, ok := extensionObject.GetBody().(readWriteModel.ServiceFaultExactly); ok { statusCode := fault.GetResponseHeader().(readWriteModel.ResponseHeader).GetServiceResult().GetStatusCode() statusCodeByValue, _ := readWriteModel.OpcuaStatusCodeByValue(statusCode) s.log.Error(). Uint32("statusCode", statusCode). Stringer("statusCodeByValue", statusCodeByValue). Msg("Failed to connect to opc ua server for the following reason") - } else { - s.log.Debug().Msg("Got Create Session Response Connection Response") + connection.fireConnectionError(errors.New("service fault received"), ch) + return + } + s.log.Debug().Msg("Got Create Session Response Connection Response") - extensionObject, err := readWriteModel.ExtensionObjectParseWithBuffer(ctx, utils.NewReadBufferByteBased(opcuaResponse, utils.WithByteOrderForReadBufferByteBased(binary.LittleEndian)), false) - if err != nil { - s.log.Error().Err(err).Msg("error parsing") - return - } - unknownExtensionObject := extensionObject.GetBody() - if responseMessage, ok := unknownExtensionObject.(readWriteModel.CreateSessionResponseExactly); ok { - s.authenticationToken = responseMessage.GetAuthenticationToken().GetNodeId() + unknownExtensionObject := extensionObject.GetBody() + if responseMessage, ok := unknownExtensionObject.(readWriteModel.CreateSessionResponseExactly); ok { + s.authenticationToken = responseMessage.GetAuthenticationToken().GetNodeId() - s.onConnectActivateSessionRequest(ctx, connection, ch, responseMessage, message.GetBody().(readWriteModel.CreateSessionResponse)) - } else { - serviceFault := unknownExtensionObject.(readWriteModel.ServiceFault) - header := serviceFault.GetResponseHeader().(readWriteModel.ResponseHeader) - s.log.Error(). - Stringer("serviceResult", header.GetServiceResult()). - Msg("Subscription ServiceFault returned from server with error code, '%s'") - } + go s.onConnectActivateSessionRequest(ctx, connection, ch, responseMessage, responseMessage) + } else { + serviceFault := unknownExtensionObject.(readWriteModel.ServiceFault) + header := serviceFault.GetResponseHeader().(readWriteModel.ResponseHeader) + s.log.Error(). + Stringer("serviceResult", header.GetServiceResult()). + Msg("Subscription ServiceFault returned from server with error code, '%s'") } } @@ -608,6 +607,7 @@ func (s *SecureChannel) onConnectActivateSessionRequest(ctx context.Context, con connection.fireConnectionError(err, ch) return } + s.log.Debug().Interface("senderCertificate", certificate).Msg("working with senderCertificate") s.encryptionHandler.setServerCertificate(certificate) s.senderNonce = sessionResponse.GetServerNonce().GetStringValue() endpoints := make([]string, 3) @@ -631,9 +631,6 @@ func (s *SecureChannel) onConnectActivateSessionRequest(ctx context.Context, con requestHandle := s.getRequestHandle() - if s.authenticationToken == nil { - panic("authenticationToken should be set at this point") - } requestHeader := readWriteModel.NewRequestHeader( s.getAuthenticationToken(), s.getCurrentDateTime(), @@ -653,7 +650,8 @@ func (s *SecureChannel) onConnectActivateSessionRequest(ctx context.Context, con 0, nil, userIdentityToken, - clientSignature) + clientSignature, + ) identifier, err := strconv.ParseUint(activateSessionRequest.GetIdentifier(), 10, 16) if err != nil { @@ -688,6 +686,7 @@ func (s *SecureChannel) onConnectActivateSessionRequest(ctx context.Context, con s.log.Error().Err(err).Msg("error parsing") return } + s.log.Trace().Stringer("message", message).Msg("looking at message") if fault, ok := message.GetBody().(readWriteModel.ServiceFaultExactly); ok { statusCode := fault.GetResponseHeader().(readWriteModel.ResponseHeader).GetServiceResult().GetStatusCode() statusCodeByValue, _ := readWriteModel.OpcuaStatusCodeByValue(statusCode) @@ -695,34 +694,35 @@ func (s *SecureChannel) onConnectActivateSessionRequest(ctx context.Context, con Uint32("statusCode", statusCode). Stringer("statusCodeByValue", statusCodeByValue). Msg("Failed to connect to opc ua server for the following reason") - } else { - s.log.Debug().Msg("Got Activate Session Response Connection Response") - - extensionObject, err := readWriteModel.ExtensionObjectParseWithBuffer(ctx, utils.NewReadBufferByteBased(opcuaResponse, utils.WithByteOrderForReadBufferByteBased(binary.LittleEndian)), false) - if err != nil { - s.log.Error().Err(err).Msg("error parsing") - return - } - unknownExtensionObject := extensionObject.GetBody() - if responseMessage, ok := unknownExtensionObject.(readWriteModel.ActivateSessionResponseExactly); ok { - returnedRequestHandle := responseMessage.GetResponseHeader().(readWriteModel.ResponseHeader).GetRequestHandle() - if !(requestHandle == returnedRequestHandle) { - s.log.Error(). - Uint32("requestHandle", requestHandle). - Uint32("returnedRequestHandle", returnedRequestHandle). - Msg("Request handle isn't as expected, we might have missed a packet. requestHandle != returnedRequestHandle") - } + connection.fireConnectionError(errors.New("service fault received"), ch) + return + } + s.log.Debug().Msg("Got Activate Session Response Connection Response") - // Send an event that connection setup is complete. - s.keepAlive() - connection.fireConnected(ch) - } else { - serviceFault := unknownExtensionObject.(readWriteModel.ServiceFault) - header := serviceFault.GetResponseHeader().(readWriteModel.ResponseHeader) + extensionObject, err := readWriteModel.ExtensionObjectParseWithBuffer(ctx, utils.NewReadBufferByteBased(opcuaResponse, utils.WithByteOrderForReadBufferByteBased(binary.LittleEndian)), false) + if err != nil { + s.log.Error().Err(err).Msg("error parsing") + return + } + unknownExtensionObject := extensionObject.GetBody() + if responseMessage, ok := unknownExtensionObject.(readWriteModel.ActivateSessionResponseExactly); ok { + returnedRequestHandle := responseMessage.GetResponseHeader().(readWriteModel.ResponseHeader).GetRequestHandle() + if !(requestHandle == returnedRequestHandle) { s.log.Error(). - Stringer("serviceResult", header.GetServiceResult()). - Msg("Subscription ServiceFault returned from server with error code") + Uint32("requestHandle", requestHandle). + Uint32("returnedRequestHandle", returnedRequestHandle). + Msg("Request handle isn't as expected, we might have missed a packet. requestHandle != returnedRequestHandle") } + + // Send an event that connection setup is complete. + s.keepAlive() + connection.fireConnected(ch) + } else { + serviceFault := unknownExtensionObject.(readWriteModel.ServiceFault) + header := serviceFault.GetResponseHeader().(readWriteModel.ResponseHeader) + s.log.Error(). + Stringer("serviceResult", header.GetServiceResult()). + Msg("Subscription ServiceFault returned from server with error code") } } @@ -783,6 +783,7 @@ func (s *SecureChannel) onDisconnect(ctx context.Context, connection *Connection s.log.Error().Err(err).Msg("error parsing") return } + s.log.Trace().Stringer("message", message).Msg("looking at message") if fault, ok := message.GetBody().(readWriteModel.ServiceFaultExactly); ok { statusCode := fault.GetResponseHeader().(readWriteModel.ResponseHeader).GetServiceResult().GetStatusCode() statusCodeByValue, _ := readWriteModel.OpcuaStatusCodeByValue(statusCode) @@ -790,24 +791,24 @@ func (s *SecureChannel) onDisconnect(ctx context.Context, connection *Connection Uint32("statusCode", statusCode). Stringer("statusCodeByValue", statusCodeByValue). Msg("Failed to connect to opc ua server for the following reason") - } else { - s.log.Debug().Msg("Got Close Session Response Connection Response") + return + } + s.log.Debug().Msg("Got Close Session Response Connection Response") - extensionObject, err := readWriteModel.ExtensionObjectParseWithBuffer(ctx, utils.NewReadBufferByteBased(opcuaResponse, utils.WithByteOrderForReadBufferByteBased(binary.LittleEndian)), false) - if err != nil { - s.log.Error().Err(err).Msg("error parsing") - return - } - unknownExtensionObject := extensionObject.GetBody() - if responseMessage, ok := unknownExtensionObject.(readWriteModel.CloseSessionResponseExactly); ok { - s.onDisconnectCloseSecureChannel(ctx, connection, responseMessage, message.GetBody().(readWriteModel.CloseSessionResponse)) - } else { - serviceFault := unknownExtensionObject.(readWriteModel.ServiceFault) - header := serviceFault.GetResponseHeader().(readWriteModel.ResponseHeader) - s.log.Error(). - Stringer("serviceResult", header.GetServiceResult()). - Msg("Subscription ServiceFault returned from server with error code") - } + extensionObject, err := readWriteModel.ExtensionObjectParseWithBuffer(ctx, utils.NewReadBufferByteBased(opcuaResponse, utils.WithByteOrderForReadBufferByteBased(binary.LittleEndian)), false) + if err != nil { + s.log.Error().Err(err).Msg("error parsing") + return + } + unknownExtensionObject := extensionObject.GetBody() + if responseMessage, ok := unknownExtensionObject.(readWriteModel.CloseSessionResponseExactly); ok { + go s.onDisconnectCloseSecureChannel(ctx, connection, responseMessage, message.GetBody().(readWriteModel.CloseSessionResponse)) + } else { + serviceFault := unknownExtensionObject.(readWriteModel.ServiceFault) + header := serviceFault.GetResponseHeader().(readWriteModel.ResponseHeader) + s.log.Error(). + Stringer("serviceResult", header.GetServiceResult()). + Msg("Subscription ServiceFault returned from server with error code") } } @@ -821,9 +822,6 @@ func (s *SecureChannel) onDisconnect(ctx context.Context, connection *Connection func (s *SecureChannel) onDisconnectCloseSecureChannel(ctx context.Context, connection *Connection, message readWriteModel.CloseSessionResponseExactly, response readWriteModel.CloseSessionResponse) { transactionId := s.channelTransactionManager.getTransactionIdentifier() - if s.authenticationToken == nil { - panic("authenticationToken should be set at this point") - } requestHeader := readWriteModel.NewRequestHeader( s.getAuthenticationToken(), s.getCurrentDateTime(), @@ -904,6 +902,7 @@ func (s *SecureChannel) onDisconnectCloseSecureChannel(ctx context.Context, conn } func (s *SecureChannel) onDiscover(ctx context.Context, codec *MessageCodec) { + s.log.Trace().Msg("onDiscover") // Only the TCP transport supports login. s.log.Debug().Msg("Opcua Driver running in ACTIVE mode, discovering endpoints") @@ -941,7 +940,7 @@ func (s *SecureChannel) onDiscover(ctx context.Context, codec *MessageCodec) { messagePDU := opcuaAPU.GetMessage() opcuaAcknowledgeResponse := messagePDU.(readWriteModel.OpcuaAcknowledgeResponse) s.log.Trace().Stringer("opcuaAcknowledgeResponse", opcuaAcknowledgeResponse).Msg("Got Hello Response Connection Response") - s.onDiscoverOpenSecureChannel(ctx, codec, opcuaAcknowledgeResponse) + go s.onDiscoverOpenSecureChannel(ctx, codec, opcuaAcknowledgeResponse) return nil }, func(err error) error { @@ -959,11 +958,9 @@ func (s *SecureChannel) onDiscover(ctx context.Context, codec *MessageCodec) { } func (s *SecureChannel) onDiscoverOpenSecureChannel(ctx context.Context, codec *MessageCodec, opcuaAcknowledgeResponse readWriteModel.OpcuaAcknowledgeResponse) { + s.log.Trace().Msg("onDiscoverOpenSecureChannel") transactionId := s.channelTransactionManager.getTransactionIdentifier() - if s.authenticationToken == nil { - panic("authenticationToken should be set at this point") - } requestHeader := readWriteModel.NewRequestHeader( s.getAuthenticationToken(), s.getCurrentDateTime(), @@ -1056,11 +1053,11 @@ func (s *SecureChannel) onDiscoverOpenSecureChannel(ctx context.Context, codec * Uint32("statusCode", statusCode). Stringer("statusCodeByValue", statusCodeByValue). Msg("Failed to connect to opc ua server for the following reason") - } else { - s.log.Debug().Msg("Got Secure Response Connection Response") - openSecureChannelResponse := extensionObject.GetBody().(readWriteModel.OpenSecureChannelResponse) - s.onDiscoverGetEndpointsRequest(ctx, codec, opcuaOpenResponse, openSecureChannelResponse) + return nil } + s.log.Debug().Msg("Got Secure Response Connection Response") + openSecureChannelResponse := extensionObject.GetBody().(readWriteModel.OpenSecureChannelResponse) + go s.onDiscoverGetEndpointsRequest(ctx, codec, opcuaOpenResponse, openSecureChannelResponse) return nil }, func(err error) error { @@ -1078,6 +1075,7 @@ func (s *SecureChannel) onDiscoverOpenSecureChannel(ctx context.Context, codec * } func (s *SecureChannel) onDiscoverGetEndpointsRequest(ctx context.Context, codec *MessageCodec, opcuaOpenResponse readWriteModel.OpcuaOpenResponse, openSecureChannelResponse readWriteModel.OpenSecureChannelResponse) { + s.log.Trace().Msg("onDiscoverGetEndpointsRequest") s.tokenId.Store(int32(openSecureChannelResponse.GetSecurityToken().(readWriteModel.ChannelSecurityToken).GetTokenId())) s.channelId.Store(int32(openSecureChannelResponse.GetSecurityToken().(readWriteModel.ChannelSecurityToken).GetChannelId())) @@ -1094,9 +1092,6 @@ func (s *SecureChannel) onDiscoverGetEndpointsRequest(ctx context.Context, codec return } - if s.authenticationToken == nil { - panic("authenticationToken should be set at this point") - } requestHeader := readWriteModel.NewRequestHeader( s.getAuthenticationToken(), s.getCurrentDateTime(), @@ -1202,7 +1197,7 @@ func (s *SecureChannel) onDiscoverGetEndpointsRequest(ctx context.Context, codec digest := sha1.Sum(s.configuration.senderCertificate) s.thumbprint = readWriteModel.NewPascalByteString(int32(len(digest)), digest[:]) - s.onDiscoverCloseSecureChannel(ctx, codec, response) + go s.onDiscoverCloseSecureChannel(ctx, codec, response) } return nil }, @@ -1221,11 +1216,9 @@ func (s *SecureChannel) onDiscoverGetEndpointsRequest(ctx context.Context, codec } func (s *SecureChannel) onDiscoverCloseSecureChannel(ctx context.Context, codec *MessageCodec, response readWriteModel.GetEndpointsResponse) { + s.log.Trace().Msg("onDiscoverCloseSecureChannel") transactionId := s.channelTransactionManager.getTransactionIdentifier() - if s.authenticationToken == nil { - panic("authenticationToken should be set at this point") - } requestHeader := readWriteModel.NewRequestHeader( s.getAuthenticationToken(), s.getCurrentDateTime(), @@ -1326,9 +1319,6 @@ func (s *SecureChannel) keepAlive() { transactionId := s.channelTransactionManager.getTransactionIdentifier() - if s.authenticationToken == nil { - panic("authenticationToken should be set at this point") - } requestHeader := readWriteModel.NewRequestHeader( s.getAuthenticationToken(), s.getCurrentDateTime(), @@ -1539,7 +1529,7 @@ func (s *SecureChannel) isEndpoint(endpoint readWriteModel.EndpointDescription) // Split up the connection string into its individual segments. matches := utils.GetSubgroupMatches(URI_PATTERN, endpoint.GetEndpointUrl().GetStringValue()) if len(matches) == 0 { - s.log.Error().Msg("Endpoint returned from the server doesn't match the format '{protocol-code}:({transport-code})?//{transport-host}(:{transport-port})(/{transport-endpoint})'") + s.log.Error().Stringer("endpoint", endpoint).Msg("Endpoint returned from the server doesn't match the format '{protocol-code}:({transport-code})?//{transport-host}(:{transport-port})(/{transport-endpoint})'") return false } s.log.Trace(). @@ -1584,9 +1574,9 @@ func (s *SecureChannel) hasIdentity(policies []readWriteModel.UserTokenPolicy) { // getIdentityToken creates an IdentityToken to authenticate with a server. // - @param tokenType the token type -// - @param securityPolicy the security policy +// - @param policyId the policy id // - @return returns an ExtensionObject with an IdentityToken. -func (s *SecureChannel) getIdentityToken(tokenType readWriteModel.UserTokenType, value string) readWriteModel.ExtensionObject { +func (s *SecureChannel) getIdentityToken(tokenType readWriteModel.UserTokenType, policyId string) readWriteModel.ExtensionObject { switch tokenType { case readWriteModel.UserTokenType_userTokenTypeAnonymous: //If we aren't using authentication tell the server we would like to log in anonymously @@ -1602,7 +1592,7 @@ func (s *SecureChannel) getIdentityToken(tokenType readWriteModel.UserTokenType, return readWriteModel.NewExtensionObject( extExpandedNodeId, readWriteModel.NewExtensionObjectEncodingMask(false, false, true), - readWriteModel.NewUserIdentityToken(readWriteModel.NewPascalString(s.securityPolicy), anonymousIdentityToken), + readWriteModel.NewUserIdentityToken(readWriteModel.NewPascalString(policyId), anonymousIdentityToken), false, ) case readWriteModel.UserTokenType_userTokenTypeUserName: @@ -1638,7 +1628,7 @@ func (s *SecureChannel) getIdentityToken(tokenType readWriteModel.UserTokenType, return readWriteModel.NewExtensionObject( extExpandedNodeId, readWriteModel.NewExtensionObjectEncodingMask(false, false, true), - readWriteModel.NewUserIdentityToken(readWriteModel.NewPascalString(s.securityPolicy), userNameIdentityToken), + readWriteModel.NewUserIdentityToken(readWriteModel.NewPascalString(policyId), userNameIdentityToken), false, ) } diff --git a/plc4go/internal/opcua/TagHandler.go b/plc4go/internal/opcua/TagHandler.go index 1d8b298ad02..2b3611017b3 100644 --- a/plc4go/internal/opcua/TagHandler.go +++ b/plc4go/internal/opcua/TagHandler.go @@ -37,7 +37,7 @@ type TagHandler struct { func NewTagHandler() TagHandler { return TagHandler{ - tagAddress: regexp.MustCompile(`^ns=(?P\d+);(?P[isgb])=(?P[^;]+)?(;(?P[a-zA-Z_]+))?`), + tagAddress: regexp.MustCompile(`^ns=(?P\d+);(?P[isgb])=(?P[^;]+)?(;(?P[a-zA-Z_]+))?$`), } } diff --git a/plc4go/internal/opcua/TagHandler_test.go b/plc4go/internal/opcua/TagHandler_test.go new file mode 100644 index 00000000000..38878fd90c5 --- /dev/null +++ b/plc4go/internal/opcua/TagHandler_test.go @@ -0,0 +1,199 @@ +/* + * 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 opcua + +import ( + "github.com/apache/plc4x/plc4go/pkg/api/model" + "github.com/stretchr/testify/assert" + "reflect" + "regexp" + "testing" +) + +func TestNewTagHandler(t *testing.T) { + tests := []struct { + name string + want TagHandler + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + if got := NewTagHandler(); !reflect.DeepEqual(got, tt.want) { + t.Errorf("NewTagHandler() = %v, want %v", got, tt.want) + } + }) + } +} + +func TestOPCUAAddressPatterns(t *testing.T) { + addressPattern := NewTagHandler().tagAddress + t.Run("Address", func(t *testing.T) { + addresses := []string{ + //standard integer based param + "ns=2;i=10846", + //string based address values + "ns=2;s=test.variable.name.inspect", + "ns=2;s=::AsGlobalPV:ProductionOrder", + "ns=2;s=::AsGlobalPV:ProductionOrder;BOOL", + "ns=2;s=key param with some spaces", + "ns=2;s=\"aweired\".\"siemens\".\"param\".\"submodule\".\"param", + "ns=2;s=Weee314Waannaaa\\somenice=ext=a234a*#+1455!§$%&/()tttraaaaSymbols-:.,,", + // GUID address tests + "ns=2;g=09087e75-8e5e-499b-954f-f2a8624db28a", + // binary encoded addresses + "ns=2;b=asvaewavarahreb==", + } + for _, address := range addresses { + t.Run(address, func(t *testing.T) { + assert.True(t, addressPattern.MatchString(address)) + }) + } + }) + t.Run("AddressDataType", func(t *testing.T) { + addresses := []string{ + //standard integer based param + "ns=2;i=10846;BOOL", + //string based address values + "ns=2;s=test.variable.name.inspect;DINT", + "ns=2;s=key param with some spaces;ULINT", + "ns=2;s=\"aweired\".\"siemens\".\"param\".\"submodule\".\"param;LREAL", + //REGEX Valid, additional checks need to be done later + "ns=2;s=Weee314Waannaaa\\somenice=ext=a234a*#+1455!§$%&/()tttraaaaSymbols-.,,;JIBBERISH", + } + for _, address := range addresses { + t.Run(address, func(t *testing.T) { + assert.True(t, addressPattern.MatchString(address)) + }) + } + }) + t.Run("AddressDataType that don't match", func(t *testing.T) { + addresses := []string{ + // GUID address tests + "ns=2;g=09087e75-8e5e-499b-954f-f2a8624db28a;*&#%^*$(*)", + // binary encoded addresses + "ns=2;b=asvae;wavarahreb==", + } + for _, address := range addresses { + t.Run(address, func(t *testing.T) { + assert.False(t, addressPattern.MatchString(address)) + }) + } + }) +} + +func TestTagHandler_ParseQuery(t *testing.T) { + type fields struct { + tagAddress *regexp.Regexp + } + type args struct { + in0 string + } + tests := []struct { + name string + fields fields + args args + want model.PlcQuery + wantErr bool + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + m := TagHandler{ + tagAddress: tt.fields.tagAddress, + } + got, err := m.ParseQuery(tt.args.in0) + if (err != nil) != tt.wantErr { + t.Errorf("ParseQuery() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("ParseQuery() got = %v, want %v", got, tt.want) + } + }) + } +} + +func TestTagHandler_ParseTag(t *testing.T) { + type fields struct { + tagAddress *regexp.Regexp + } + type args struct { + tagAddress string + } + tests := []struct { + name string + fields fields + args args + want model.PlcTag + wantErr bool + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + m := TagHandler{ + tagAddress: tt.fields.tagAddress, + } + got, err := m.ParseTag(tt.args.tagAddress) + if (err != nil) != tt.wantErr { + t.Errorf("ParseTag() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("ParseTag() got = %v, want %v", got, tt.want) + } + }) + } +} + +func TestTagHandler_handleTagAddress(t *testing.T) { + type fields struct { + tagAddress *regexp.Regexp + } + type args struct { + match map[string]string + } + tests := []struct { + name string + fields fields + args args + want model.PlcTag + wantErr bool + }{ + // TODO: Add test cases. + } + for _, tt := range tests { + t.Run(tt.name, func(t *testing.T) { + m := TagHandler{ + tagAddress: tt.fields.tagAddress, + } + got, err := m.handleTagAddress(tt.args.match) + if (err != nil) != tt.wantErr { + t.Errorf("handleTagAddress() error = %v, wantErr %v", err, tt.wantErr) + return + } + if !reflect.DeepEqual(got, tt.want) { + t.Errorf("handleTagAddress() got = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/plc4go/internal/opcua/mock_CommandAndArgumentsCount_test.go b/plc4go/internal/opcua/mock_CommandAndArgumentsCount_test.go index 2a4f7ae4265..3b6db5e2d87 100644 --- a/plc4go/internal/opcua/mock_CommandAndArgumentsCount_test.go +++ b/plc4go/internal/opcua/mock_CommandAndArgumentsCount_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package opcua diff --git a/plc4go/internal/opcua/mock_Tag_test.go b/plc4go/internal/opcua/mock_Tag_test.go index f99a54e4629..7b6b31779e8 100644 --- a/plc4go/internal/opcua/mock_Tag_test.go +++ b/plc4go/internal/opcua/mock_Tag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package opcua diff --git a/plc4go/internal/s7/mock_PlcTag_test.go b/plc4go/internal/s7/mock_PlcTag_test.go index 5fc7dc72533..dcee3a781f8 100644 --- a/plc4go/internal/s7/mock_PlcTag_test.go +++ b/plc4go/internal/s7/mock_PlcTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package s7 diff --git a/plc4go/internal/simulated/mock_Tag_test.go b/plc4go/internal/simulated/mock_Tag_test.go index 968a8165d31..6fe76e7672c 100644 --- a/plc4go/internal/simulated/mock_Tag_test.go +++ b/plc4go/internal/simulated/mock_Tag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package simulated diff --git a/plc4go/pkg/api/cache/mock_PlcConnectionCacheCloseResult_test.go b/plc4go/pkg/api/cache/mock_PlcConnectionCacheCloseResult_test.go index 919cfa20906..521caaa9acc 100644 --- a/plc4go/pkg/api/cache/mock_PlcConnectionCacheCloseResult_test.go +++ b/plc4go/pkg/api/cache/mock_PlcConnectionCacheCloseResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package cache diff --git a/plc4go/pkg/api/cache/mock_PlcConnectionCache_test.go b/plc4go/pkg/api/cache/mock_PlcConnectionCache_test.go index 2f0257207c0..111b10462e9 100644 --- a/plc4go/pkg/api/cache/mock_PlcConnectionCache_test.go +++ b/plc4go/pkg/api/cache/mock_PlcConnectionCache_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package cache diff --git a/plc4go/pkg/api/cache/mock_WithConnectionCacheOption_test.go b/plc4go/pkg/api/cache/mock_WithConnectionCacheOption_test.go index e58ad7b563b..c8589a09a5b 100644 --- a/plc4go/pkg/api/cache/mock_WithConnectionCacheOption_test.go +++ b/plc4go/pkg/api/cache/mock_WithConnectionCacheOption_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package cache diff --git a/plc4go/pkg/api/cache/mock_connectionEvent_test.go b/plc4go/pkg/api/cache/mock_connectionEvent_test.go index 127a3bffa2b..9b2bd7a7ec3 100644 --- a/plc4go/pkg/api/cache/mock_connectionEvent_test.go +++ b/plc4go/pkg/api/cache/mock_connectionEvent_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package cache diff --git a/plc4go/pkg/api/cache/mock_connectionListener_test.go b/plc4go/pkg/api/cache/mock_connectionListener_test.go index 3795b5d1331..5bdbf4c4770 100644 --- a/plc4go/pkg/api/cache/mock_connectionListener_test.go +++ b/plc4go/pkg/api/cache/mock_connectionListener_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package cache diff --git a/plc4go/pkg/api/cache/mock_tracedPlcConnection_test.go b/plc4go/pkg/api/cache/mock_tracedPlcConnection_test.go index 83a393b4f17..975dc67fc6e 100644 --- a/plc4go/pkg/api/cache/mock_tracedPlcConnection_test.go +++ b/plc4go/pkg/api/cache/mock_tracedPlcConnection_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package cache diff --git a/plc4go/pkg/api/config/mock_WithOption_test.go b/plc4go/pkg/api/config/mock_WithOption_test.go index 0a642b306c6..0cc0ef1b9a8 100644 --- a/plc4go/pkg/api/config/mock_WithOption_test.go +++ b/plc4go/pkg/api/config/mock_WithOption_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package config diff --git a/plc4go/pkg/api/drivers/drivers.go b/plc4go/pkg/api/drivers/drivers.go index 8fc164b5405..f0e72cc46b4 100644 --- a/plc4go/pkg/api/drivers/drivers.go +++ b/plc4go/pkg/api/drivers/drivers.go @@ -26,6 +26,7 @@ import ( "github.com/apache/plc4x/plc4go/internal/eip" "github.com/apache/plc4x/plc4go/internal/knxnetip" modbus2 "github.com/apache/plc4x/plc4go/internal/modbus" + "github.com/apache/plc4x/plc4go/internal/opcua" "github.com/apache/plc4x/plc4go/internal/s7" "github.com/apache/plc4x/plc4go/pkg/api" "github.com/apache/plc4x/plc4go/pkg/api/config" @@ -75,6 +76,11 @@ func RegisterModbusAsciiDriver(driverManager plc4go.PlcDriverManager, _options . transports.RegisterTcpTransport(driverManager) } +func RegisterOpcuaDriver(driverManager plc4go.PlcDriverManager, _options ...config.WithOption) { + driverManager.RegisterDriver(opcua.NewDriver(converter.WithOptionToInternal(_options...)...)) + transports.RegisterTcpTransport(driverManager) +} + func RegisterS7Driver(driverManager plc4go.PlcDriverManager, _options ...config.WithOption) { driverManager.RegisterDriver(s7.NewDriver(converter.WithOptionToInternal(_options...)...)) transports.RegisterTcpTransport(driverManager) diff --git a/plc4go/pkg/api/mock_PlcConnectionCloseResult_test.go b/plc4go/pkg/api/mock_PlcConnectionCloseResult_test.go index fedb216a61f..3ada189632c 100644 --- a/plc4go/pkg/api/mock_PlcConnectionCloseResult_test.go +++ b/plc4go/pkg/api/mock_PlcConnectionCloseResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package plc4go diff --git a/plc4go/pkg/api/mock_PlcConnectionConnectResult_test.go b/plc4go/pkg/api/mock_PlcConnectionConnectResult_test.go index 935f34fdbef..a59388bfd92 100644 --- a/plc4go/pkg/api/mock_PlcConnectionConnectResult_test.go +++ b/plc4go/pkg/api/mock_PlcConnectionConnectResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package plc4go diff --git a/plc4go/pkg/api/mock_PlcConnectionPingResult_test.go b/plc4go/pkg/api/mock_PlcConnectionPingResult_test.go index e00f87d16b1..b3673aa807c 100644 --- a/plc4go/pkg/api/mock_PlcConnectionPingResult_test.go +++ b/plc4go/pkg/api/mock_PlcConnectionPingResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package plc4go diff --git a/plc4go/pkg/api/mock_PlcConnection_test.go b/plc4go/pkg/api/mock_PlcConnection_test.go index 46a774fbcbd..ea6a65ff484 100644 --- a/plc4go/pkg/api/mock_PlcConnection_test.go +++ b/plc4go/pkg/api/mock_PlcConnection_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package plc4go diff --git a/plc4go/pkg/api/mock_PlcDriverManager_test.go b/plc4go/pkg/api/mock_PlcDriverManager_test.go index 2c6c2cf3f25..d1443dd8d9e 100644 --- a/plc4go/pkg/api/mock_PlcDriverManager_test.go +++ b/plc4go/pkg/api/mock_PlcDriverManager_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package plc4go diff --git a/plc4go/pkg/api/mock_PlcDriver_test.go b/plc4go/pkg/api/mock_PlcDriver_test.go index c034246b6c7..bed07b032ea 100644 --- a/plc4go/pkg/api/mock_PlcDriver_test.go +++ b/plc4go/pkg/api/mock_PlcDriver_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package plc4go diff --git a/plc4go/pkg/api/mock_Transport_test.go b/plc4go/pkg/api/mock_Transport_test.go index 7c8b1015b0c..50c000f5ec6 100644 --- a/plc4go/pkg/api/mock_Transport_test.go +++ b/plc4go/pkg/api/mock_Transport_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package plc4go diff --git a/plc4go/pkg/api/mock_WithDiscoveryOption_test.go b/plc4go/pkg/api/mock_WithDiscoveryOption_test.go index 4cedb797e96..4f13c9d2c77 100644 --- a/plc4go/pkg/api/mock_WithDiscoveryOption_test.go +++ b/plc4go/pkg/api/mock_WithDiscoveryOption_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package plc4go diff --git a/plc4go/pkg/api/model/mock_ArrayInfo_test.go b/plc4go/pkg/api/model/mock_ArrayInfo_test.go index d6330d76d1d..358e6de260c 100644 --- a/plc4go/pkg/api/model/mock_ArrayInfo_test.go +++ b/plc4go/pkg/api/model/mock_ArrayInfo_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcBrowseItem_test.go b/plc4go/pkg/api/model/mock_PlcBrowseItem_test.go index f8620faf062..4dadade412f 100644 --- a/plc4go/pkg/api/model/mock_PlcBrowseItem_test.go +++ b/plc4go/pkg/api/model/mock_PlcBrowseItem_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcBrowseRequestBuilder_test.go b/plc4go/pkg/api/model/mock_PlcBrowseRequestBuilder_test.go index 19589b7300a..42ed6d46ed2 100644 --- a/plc4go/pkg/api/model/mock_PlcBrowseRequestBuilder_test.go +++ b/plc4go/pkg/api/model/mock_PlcBrowseRequestBuilder_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcBrowseRequestResult_test.go b/plc4go/pkg/api/model/mock_PlcBrowseRequestResult_test.go index 3dd282b66b2..df4b07b8803 100644 --- a/plc4go/pkg/api/model/mock_PlcBrowseRequestResult_test.go +++ b/plc4go/pkg/api/model/mock_PlcBrowseRequestResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcBrowseRequest_test.go b/plc4go/pkg/api/model/mock_PlcBrowseRequest_test.go index c52bee77f57..b61276c89f6 100644 --- a/plc4go/pkg/api/model/mock_PlcBrowseRequest_test.go +++ b/plc4go/pkg/api/model/mock_PlcBrowseRequest_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcBrowseResponse_test.go b/plc4go/pkg/api/model/mock_PlcBrowseResponse_test.go index 69aff8810f3..688964c7fce 100644 --- a/plc4go/pkg/api/model/mock_PlcBrowseResponse_test.go +++ b/plc4go/pkg/api/model/mock_PlcBrowseResponse_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcConnectionMetadata_test.go b/plc4go/pkg/api/model/mock_PlcConnectionMetadata_test.go index 4b10473ba13..d38563452fd 100644 --- a/plc4go/pkg/api/model/mock_PlcConnectionMetadata_test.go +++ b/plc4go/pkg/api/model/mock_PlcConnectionMetadata_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcConsumerRegistration_test.go b/plc4go/pkg/api/model/mock_PlcConsumerRegistration_test.go index f0db8e928b5..ed3133d3fa5 100644 --- a/plc4go/pkg/api/model/mock_PlcConsumerRegistration_test.go +++ b/plc4go/pkg/api/model/mock_PlcConsumerRegistration_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcDiscoveryItem_test.go b/plc4go/pkg/api/model/mock_PlcDiscoveryItem_test.go index f2171968866..90e21a13ecf 100644 --- a/plc4go/pkg/api/model/mock_PlcDiscoveryItem_test.go +++ b/plc4go/pkg/api/model/mock_PlcDiscoveryItem_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcMessage_test.go b/plc4go/pkg/api/model/mock_PlcMessage_test.go index 3f8acf556c7..50e69527f38 100644 --- a/plc4go/pkg/api/model/mock_PlcMessage_test.go +++ b/plc4go/pkg/api/model/mock_PlcMessage_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcQuery_test.go b/plc4go/pkg/api/model/mock_PlcQuery_test.go index 206f2373366..225ff5575db 100644 --- a/plc4go/pkg/api/model/mock_PlcQuery_test.go +++ b/plc4go/pkg/api/model/mock_PlcQuery_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcReadRequestBuilder_test.go b/plc4go/pkg/api/model/mock_PlcReadRequestBuilder_test.go index 083c493c5f9..b96c63d8e8b 100644 --- a/plc4go/pkg/api/model/mock_PlcReadRequestBuilder_test.go +++ b/plc4go/pkg/api/model/mock_PlcReadRequestBuilder_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcReadRequestResult_test.go b/plc4go/pkg/api/model/mock_PlcReadRequestResult_test.go index 8c58e70a81b..6fc9d0c2b7a 100644 --- a/plc4go/pkg/api/model/mock_PlcReadRequestResult_test.go +++ b/plc4go/pkg/api/model/mock_PlcReadRequestResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcReadRequest_test.go b/plc4go/pkg/api/model/mock_PlcReadRequest_test.go index 20073b16c2f..895ea09cb03 100644 --- a/plc4go/pkg/api/model/mock_PlcReadRequest_test.go +++ b/plc4go/pkg/api/model/mock_PlcReadRequest_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcReadResponse_test.go b/plc4go/pkg/api/model/mock_PlcReadResponse_test.go index 1c2944f0c23..250b8eb05c3 100644 --- a/plc4go/pkg/api/model/mock_PlcReadResponse_test.go +++ b/plc4go/pkg/api/model/mock_PlcReadResponse_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcRequest_test.go b/plc4go/pkg/api/model/mock_PlcRequest_test.go index d6f588abfd1..db0df6cb512 100644 --- a/plc4go/pkg/api/model/mock_PlcRequest_test.go +++ b/plc4go/pkg/api/model/mock_PlcRequest_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcResponse_test.go b/plc4go/pkg/api/model/mock_PlcResponse_test.go index 4d4a3057850..b9151c63fc9 100644 --- a/plc4go/pkg/api/model/mock_PlcResponse_test.go +++ b/plc4go/pkg/api/model/mock_PlcResponse_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcSubscriptionEventConsumer_test.go b/plc4go/pkg/api/model/mock_PlcSubscriptionEventConsumer_test.go index 642e582edd2..876923a8c7a 100644 --- a/plc4go/pkg/api/model/mock_PlcSubscriptionEventConsumer_test.go +++ b/plc4go/pkg/api/model/mock_PlcSubscriptionEventConsumer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcSubscriptionEvent_test.go b/plc4go/pkg/api/model/mock_PlcSubscriptionEvent_test.go index 5493094141e..9fdc7de4958 100644 --- a/plc4go/pkg/api/model/mock_PlcSubscriptionEvent_test.go +++ b/plc4go/pkg/api/model/mock_PlcSubscriptionEvent_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcSubscriptionHandle_test.go b/plc4go/pkg/api/model/mock_PlcSubscriptionHandle_test.go index a7c7ef87ce1..1ad98b766b8 100644 --- a/plc4go/pkg/api/model/mock_PlcSubscriptionHandle_test.go +++ b/plc4go/pkg/api/model/mock_PlcSubscriptionHandle_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcSubscriptionRequestBuilder_test.go b/plc4go/pkg/api/model/mock_PlcSubscriptionRequestBuilder_test.go index 0080d6d5d7b..51dbac2b31f 100644 --- a/plc4go/pkg/api/model/mock_PlcSubscriptionRequestBuilder_test.go +++ b/plc4go/pkg/api/model/mock_PlcSubscriptionRequestBuilder_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcSubscriptionRequestResult_test.go b/plc4go/pkg/api/model/mock_PlcSubscriptionRequestResult_test.go index fb4d03ef06f..222f8126f18 100644 --- a/plc4go/pkg/api/model/mock_PlcSubscriptionRequestResult_test.go +++ b/plc4go/pkg/api/model/mock_PlcSubscriptionRequestResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcSubscriptionRequest_test.go b/plc4go/pkg/api/model/mock_PlcSubscriptionRequest_test.go index 19d1ff9b29c..e47f01f3eb3 100644 --- a/plc4go/pkg/api/model/mock_PlcSubscriptionRequest_test.go +++ b/plc4go/pkg/api/model/mock_PlcSubscriptionRequest_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcSubscriptionResponse_test.go b/plc4go/pkg/api/model/mock_PlcSubscriptionResponse_test.go index 4d130cb9c95..cf9fbdb35e6 100644 --- a/plc4go/pkg/api/model/mock_PlcSubscriptionResponse_test.go +++ b/plc4go/pkg/api/model/mock_PlcSubscriptionResponse_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcSubscriptionTag_test.go b/plc4go/pkg/api/model/mock_PlcSubscriptionTag_test.go index dba46acf1fe..f4e8522466d 100644 --- a/plc4go/pkg/api/model/mock_PlcSubscriptionTag_test.go +++ b/plc4go/pkg/api/model/mock_PlcSubscriptionTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcTag_test.go b/plc4go/pkg/api/model/mock_PlcTag_test.go index 0470a7a0059..df4f8605a68 100644 --- a/plc4go/pkg/api/model/mock_PlcTag_test.go +++ b/plc4go/pkg/api/model/mock_PlcTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequestBuilder_test.go b/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequestBuilder_test.go index 8533001c2b1..5eaf3c6929e 100644 --- a/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequestBuilder_test.go +++ b/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequestBuilder_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequestResult_test.go b/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequestResult_test.go index 2556ccd8c1f..f1edb9b192a 100644 --- a/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequestResult_test.go +++ b/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequestResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequest_test.go b/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequest_test.go index 256a73f5a02..18698ab725d 100644 --- a/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequest_test.go +++ b/plc4go/pkg/api/model/mock_PlcUnsubscriptionRequest_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcUnsubscriptionResponse_test.go b/plc4go/pkg/api/model/mock_PlcUnsubscriptionResponse_test.go index d3ce1116bd9..4b0f22fcf57 100644 --- a/plc4go/pkg/api/model/mock_PlcUnsubscriptionResponse_test.go +++ b/plc4go/pkg/api/model/mock_PlcUnsubscriptionResponse_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcWriteRequestBuilder_test.go b/plc4go/pkg/api/model/mock_PlcWriteRequestBuilder_test.go index fa9c7159931..baa7309d977 100644 --- a/plc4go/pkg/api/model/mock_PlcWriteRequestBuilder_test.go +++ b/plc4go/pkg/api/model/mock_PlcWriteRequestBuilder_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcWriteRequestResult_test.go b/plc4go/pkg/api/model/mock_PlcWriteRequestResult_test.go index cf6771cb5c5..1e3295634e5 100644 --- a/plc4go/pkg/api/model/mock_PlcWriteRequestResult_test.go +++ b/plc4go/pkg/api/model/mock_PlcWriteRequestResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcWriteRequest_test.go b/plc4go/pkg/api/model/mock_PlcWriteRequest_test.go index 35724227b6b..1e1b50ebc55 100644 --- a/plc4go/pkg/api/model/mock_PlcWriteRequest_test.go +++ b/plc4go/pkg/api/model/mock_PlcWriteRequest_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/model/mock_PlcWriteResponse_test.go b/plc4go/pkg/api/model/mock_PlcWriteResponse_test.go index 082a269a897..dce25eb717f 100644 --- a/plc4go/pkg/api/model/mock_PlcWriteResponse_test.go +++ b/plc4go/pkg/api/model/mock_PlcWriteResponse_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/pkg/api/values/mock_PlcValue_test.go b/plc4go/pkg/api/values/mock_PlcValue_test.go index fe6c92b5f17..8d8c1874543 100644 --- a/plc4go/pkg/api/values/mock_PlcValue_test.go +++ b/plc4go/pkg/api/values/mock_PlcValue_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package values diff --git a/plc4go/pkg/api/values/mock_RawPlcValue_test.go b/plc4go/pkg/api/values/mock_RawPlcValue_test.go index ae4035e2d91..ca6ba747533 100644 --- a/plc4go/pkg/api/values/mock_RawPlcValue_test.go +++ b/plc4go/pkg/api/values/mock_RawPlcValue_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package values diff --git a/plc4go/pom.xml b/plc4go/pom.xml index c6ca6c1065a..897d7385e78 100644 --- a/plc4go/pom.xml +++ b/plc4go/pom.xml @@ -54,6 +54,11 @@ -coverprofile=target/coverage.out + + v0.11.1 + v2.0.1 + v1.10.1 + v2.32.4 @@ -382,7 +387,7 @@ - golang.org/x/tools/cmd/stringer@v0.11.1 + golang.org/x/tools/cmd/stringer@${go.stringer.version} @@ -395,7 +400,7 @@ - github.com/sruehl/go-junit-report/v2@latest + github.com/sruehl/go-junit-report/v2@${go.junit-report.version} @@ -407,7 +412,7 @@ - gotest.tools/gotestsum@v1.10.1 + gotest.tools/gotestsum@${go.gotestsum.version} @@ -419,7 +424,7 @@ - github.com/vektra/mockery/v2@v2.23.4 + github.com/vektra/mockery/v2@${go.mockery.version} @@ -710,4 +715,22 @@ + + + os-windows + + + windows + + + + + -v + + + + \ No newline at end of file diff --git a/plc4go/protocols/abeth/readwrite/model/CIPEncapsulationPacket.go b/plc4go/protocols/abeth/readwrite/model/CIPEncapsulationPacket.go index ad55008a227..0063bd7f475 100644 --- a/plc4go/protocols/abeth/readwrite/model/CIPEncapsulationPacket.go +++ b/plc4go/protocols/abeth/readwrite/model/CIPEncapsulationPacket.go @@ -210,13 +210,13 @@ func CIPEncapsulationPacketParseWithBuffer(ctx context.Context, readBuffer utils return nil, errors.Wrap(pullErr, "Error pulling for senderContext") } // Count array - senderContext := make([]uint8, uint16(8)) + senderContext := make([]uint8, utils.Max(uint16(8), 0)) // This happens when the size is set conditional to 0 if len(senderContext) == 0 { senderContext = nil } { - _numItems := uint16(uint16(8)) + _numItems := uint16(utils.Max(uint16(8), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/ads/discovery/readwrite/model/AdsDiscovery.go b/plc4go/protocols/ads/discovery/readwrite/model/AdsDiscovery.go index a308ef07fdf..fa97fc34153 100644 --- a/plc4go/protocols/ads/discovery/readwrite/model/AdsDiscovery.go +++ b/plc4go/protocols/ads/discovery/readwrite/model/AdsDiscovery.go @@ -249,13 +249,13 @@ func AdsDiscoveryParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffe return nil, errors.Wrap(pullErr, "Error pulling for blocks") } // Count array - blocks := make([]AdsDiscoveryBlock, numBlocks) + blocks := make([]AdsDiscoveryBlock, utils.Max(numBlocks, 0)) // This happens when the size is set conditional to 0 if len(blocks) == 0 { blocks = nil } { - _numItems := uint16(numBlocks) + _numItems := uint16(utils.Max(numBlocks, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/ads/readwrite/model/AdsDataTypeTableChildEntry.go b/plc4go/protocols/ads/readwrite/model/AdsDataTypeTableChildEntry.go index 9cd8ef48d27..52347df328d 100644 --- a/plc4go/protocols/ads/readwrite/model/AdsDataTypeTableChildEntry.go +++ b/plc4go/protocols/ads/readwrite/model/AdsDataTypeTableChildEntry.go @@ -469,13 +469,13 @@ func AdsDataTypeTableChildEntryParseWithBuffer(ctx context.Context, readBuffer u return nil, errors.Wrap(pullErr, "Error pulling for arrayInfo") } // Count array - arrayInfo := make([]AdsDataTypeArrayInfo, arrayDimensions) + arrayInfo := make([]AdsDataTypeArrayInfo, utils.Max(arrayDimensions, 0)) // This happens when the size is set conditional to 0 if len(arrayInfo) == 0 { arrayInfo = nil } { - _numItems := uint16(arrayDimensions) + _numItems := uint16(utils.Max(arrayDimensions, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -496,13 +496,13 @@ func AdsDataTypeTableChildEntryParseWithBuffer(ctx context.Context, readBuffer u return nil, errors.Wrap(pullErr, "Error pulling for children") } // Count array - children := make([]AdsDataTypeTableEntry, numChildren) + children := make([]AdsDataTypeTableEntry, utils.Max(numChildren, 0)) // This happens when the size is set conditional to 0 if len(children) == 0 { children = nil } { - _numItems := uint16(numChildren) + _numItems := uint16(utils.Max(numChildren, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/ads/readwrite/model/AdsDataTypeTableEntry.go b/plc4go/protocols/ads/readwrite/model/AdsDataTypeTableEntry.go index ff8e819755e..08795a4c35c 100644 --- a/plc4go/protocols/ads/readwrite/model/AdsDataTypeTableEntry.go +++ b/plc4go/protocols/ads/readwrite/model/AdsDataTypeTableEntry.go @@ -469,13 +469,13 @@ func AdsDataTypeTableEntryParseWithBuffer(ctx context.Context, readBuffer utils. return nil, errors.Wrap(pullErr, "Error pulling for arrayInfo") } // Count array - arrayInfo := make([]AdsDataTypeArrayInfo, arrayDimensions) + arrayInfo := make([]AdsDataTypeArrayInfo, utils.Max(arrayDimensions, 0)) // This happens when the size is set conditional to 0 if len(arrayInfo) == 0 { arrayInfo = nil } { - _numItems := uint16(arrayDimensions) + _numItems := uint16(utils.Max(arrayDimensions, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -496,13 +496,13 @@ func AdsDataTypeTableEntryParseWithBuffer(ctx context.Context, readBuffer utils. return nil, errors.Wrap(pullErr, "Error pulling for children") } // Count array - children := make([]AdsDataTypeTableChildEntry, numChildren) + children := make([]AdsDataTypeTableChildEntry, utils.Max(numChildren, 0)) // This happens when the size is set conditional to 0 if len(children) == 0 { children = nil } { - _numItems := uint16(numChildren) + _numItems := uint16(utils.Max(numChildren, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/ads/readwrite/model/AdsDeviceNotificationRequest.go b/plc4go/protocols/ads/readwrite/model/AdsDeviceNotificationRequest.go index 65c91d4785c..0612228fe57 100644 --- a/plc4go/protocols/ads/readwrite/model/AdsDeviceNotificationRequest.go +++ b/plc4go/protocols/ads/readwrite/model/AdsDeviceNotificationRequest.go @@ -198,13 +198,13 @@ func AdsDeviceNotificationRequestParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for adsStampHeaders") } // Count array - adsStampHeaders := make([]AdsStampHeader, stamps) + adsStampHeaders := make([]AdsStampHeader, utils.Max(stamps, 0)) // This happens when the size is set conditional to 0 if len(adsStampHeaders) == 0 { adsStampHeaders = nil } { - _numItems := uint16(stamps) + _numItems := uint16(utils.Max(stamps, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/ads/readwrite/model/AdsReadWriteRequest.go b/plc4go/protocols/ads/readwrite/model/AdsReadWriteRequest.go index e332d4b31fb..807daa857ab 100644 --- a/plc4go/protocols/ads/readwrite/model/AdsReadWriteRequest.go +++ b/plc4go/protocols/ads/readwrite/model/AdsReadWriteRequest.go @@ -239,13 +239,13 @@ func AdsReadWriteRequestParseWithBuffer(ctx context.Context, readBuffer utils.Re return nil, errors.Wrap(pullErr, "Error pulling for items") } // Count array - items := make([]AdsMultiRequestItem, utils.InlineIf((bool(bool((bool((indexGroup) == (61568)))) || bool((bool((indexGroup) == (61569))))) || bool((bool((indexGroup) == (61570))))), func() any { return uint16(indexOffset) }, func() any { return uint16(uint16(0)) }).(uint16)) + items := make([]AdsMultiRequestItem, utils.Max(utils.InlineIf((bool(bool((bool((indexGroup) == (61568)))) || bool((bool((indexGroup) == (61569))))) || bool((bool((indexGroup) == (61570))))), func() any { return uint16(indexOffset) }, func() any { return uint16(uint16(0)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(items) == 0 { items = nil } { - _numItems := uint16(utils.InlineIf((bool(bool((bool((indexGroup) == (61568)))) || bool((bool((indexGroup) == (61569))))) || bool((bool((indexGroup) == (61570))))), func() any { return uint16(indexOffset) }, func() any { return uint16(uint16(0)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf((bool(bool((bool((indexGroup) == (61568)))) || bool((bool((indexGroup) == (61569))))) || bool((bool((indexGroup) == (61570))))), func() any { return uint16(indexOffset) }, func() any { return uint16(uint16(0)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/ads/readwrite/model/AdsStampHeader.go b/plc4go/protocols/ads/readwrite/model/AdsStampHeader.go index 8a1ae401f37..e5e0ae8781f 100644 --- a/plc4go/protocols/ads/readwrite/model/AdsStampHeader.go +++ b/plc4go/protocols/ads/readwrite/model/AdsStampHeader.go @@ -158,13 +158,13 @@ func AdsStampHeaderParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuf return nil, errors.Wrap(pullErr, "Error pulling for adsNotificationSamples") } // Count array - adsNotificationSamples := make([]AdsNotificationSample, samples) + adsNotificationSamples := make([]AdsNotificationSample, utils.Max(samples, 0)) // This happens when the size is set conditional to 0 if len(adsNotificationSamples) == 0 { adsNotificationSamples = nil } { - _numItems := uint16(samples) + _numItems := uint16(utils.Max(samples, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/bacnetip/readwrite/model/BACnetServiceAckAtomicReadFileRecord.go b/plc4go/protocols/bacnetip/readwrite/model/BACnetServiceAckAtomicReadFileRecord.go index d3ea2019b84..bd40b23974d 100644 --- a/plc4go/protocols/bacnetip/readwrite/model/BACnetServiceAckAtomicReadFileRecord.go +++ b/plc4go/protocols/bacnetip/readwrite/model/BACnetServiceAckAtomicReadFileRecord.go @@ -199,13 +199,13 @@ func BACnetServiceAckAtomicReadFileRecordParseWithBuffer(ctx context.Context, re return nil, errors.Wrap(pullErr, "Error pulling for fileRecordData") } // Count array - fileRecordData := make([]BACnetApplicationTagOctetString, returnedRecordCount.GetPayload().GetActualValue()) + fileRecordData := make([]BACnetApplicationTagOctetString, utils.Max(returnedRecordCount.GetPayload().GetActualValue(), 0)) // This happens when the size is set conditional to 0 if len(fileRecordData) == 0 { fileRecordData = nil } { - _numItems := uint16(returnedRecordCount.GetPayload().GetActualValue()) + _numItems := uint16(utils.Max(returnedRecordCount.GetPayload().GetActualValue(), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/bacnetip/readwrite/model/BACnetTagPayloadBitString.go b/plc4go/protocols/bacnetip/readwrite/model/BACnetTagPayloadBitString.go index 7f537f05cbf..5ea4b0616dd 100644 --- a/plc4go/protocols/bacnetip/readwrite/model/BACnetTagPayloadBitString.go +++ b/plc4go/protocols/bacnetip/readwrite/model/BACnetTagPayloadBitString.go @@ -151,13 +151,13 @@ func BACnetTagPayloadBitStringParseWithBuffer(ctx context.Context, readBuffer ut return nil, errors.Wrap(pullErr, "Error pulling for data") } // Count array - data := make([]bool, uint16((uint16((uint16(actualLength)-uint16(uint16(1))))*uint16(uint16(8))))-uint16(unusedBits)) + data := make([]bool, utils.Max(uint16((uint16((uint16(actualLength)-uint16(uint16(1))))*uint16(uint16(8))))-uint16(unusedBits), 0)) // This happens when the size is set conditional to 0 if len(data) == 0 { data = nil } { - _numItems := uint16(uint16((uint16((uint16(actualLength) - uint16(uint16(1)))) * uint16(uint16(8)))) - uint16(unusedBits)) + _numItems := uint16(utils.Max(uint16((uint16((uint16(actualLength)-uint16(uint16(1))))*uint16(uint16(8))))-uint16(unusedBits), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -178,13 +178,13 @@ func BACnetTagPayloadBitStringParseWithBuffer(ctx context.Context, readBuffer ut return nil, errors.Wrap(pullErr, "Error pulling for unused") } // Count array - unused := make([]bool, unusedBits) + unused := make([]bool, utils.Max(unusedBits, 0)) // This happens when the size is set conditional to 0 if len(unused) == 0 { unused = nil } { - _numItems := uint16(unusedBits) + _numItems := uint16(utils.Max(unusedBits, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/bacnetip/readwrite/model/BVLCBroadcastDistributionTableEntry.go b/plc4go/protocols/bacnetip/readwrite/model/BVLCBroadcastDistributionTableEntry.go index c683ca551ed..699be43e3bd 100644 --- a/plc4go/protocols/bacnetip/readwrite/model/BVLCBroadcastDistributionTableEntry.go +++ b/plc4go/protocols/bacnetip/readwrite/model/BVLCBroadcastDistributionTableEntry.go @@ -141,13 +141,13 @@ func BVLCBroadcastDistributionTableEntryParseWithBuffer(ctx context.Context, rea return nil, errors.Wrap(pullErr, "Error pulling for ip") } // Count array - ip := make([]uint8, uint16(4)) + ip := make([]uint8, utils.Max(uint16(4), 0)) // This happens when the size is set conditional to 0 if len(ip) == 0 { ip = nil } { - _numItems := uint16(uint16(4)) + _numItems := uint16(utils.Max(uint16(4), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -175,13 +175,13 @@ func BVLCBroadcastDistributionTableEntryParseWithBuffer(ctx context.Context, rea return nil, errors.Wrap(pullErr, "Error pulling for broadcastDistributionMap") } // Count array - broadcastDistributionMap := make([]uint8, uint16(4)) + broadcastDistributionMap := make([]uint8, utils.Max(uint16(4), 0)) // This happens when the size is set conditional to 0 if len(broadcastDistributionMap) == 0 { broadcastDistributionMap = nil } { - _numItems := uint16(uint16(4)) + _numItems := uint16(utils.Max(uint16(4), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/bacnetip/readwrite/model/BVLCDeleteForeignDeviceTableEntry.go b/plc4go/protocols/bacnetip/readwrite/model/BVLCDeleteForeignDeviceTableEntry.go index 4efeead489b..a21763939fd 100644 --- a/plc4go/protocols/bacnetip/readwrite/model/BVLCDeleteForeignDeviceTableEntry.go +++ b/plc4go/protocols/bacnetip/readwrite/model/BVLCDeleteForeignDeviceTableEntry.go @@ -158,13 +158,13 @@ func BVLCDeleteForeignDeviceTableEntryParseWithBuffer(ctx context.Context, readB return nil, errors.Wrap(pullErr, "Error pulling for ip") } // Count array - ip := make([]uint8, uint16(4)) + ip := make([]uint8, utils.Max(uint16(4), 0)) // This happens when the size is set conditional to 0 if len(ip) == 0 { ip = nil } { - _numItems := uint16(uint16(4)) + _numItems := uint16(utils.Max(uint16(4), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/bacnetip/readwrite/model/BVLCForeignDeviceTableEntry.go b/plc4go/protocols/bacnetip/readwrite/model/BVLCForeignDeviceTableEntry.go index 114772894d3..ef4889fb5d4 100644 --- a/plc4go/protocols/bacnetip/readwrite/model/BVLCForeignDeviceTableEntry.go +++ b/plc4go/protocols/bacnetip/readwrite/model/BVLCForeignDeviceTableEntry.go @@ -149,13 +149,13 @@ func BVLCForeignDeviceTableEntryParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for ip") } // Count array - ip := make([]uint8, uint16(4)) + ip := make([]uint8, utils.Max(uint16(4), 0)) // This happens when the size is set conditional to 0 if len(ip) == 0 { ip = nil } { - _numItems := uint16(uint16(4)) + _numItems := uint16(utils.Max(uint16(4), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/bacnetip/readwrite/model/BVLCForwardedNPDU.go b/plc4go/protocols/bacnetip/readwrite/model/BVLCForwardedNPDU.go index 4d8f500f137..f84ef804164 100644 --- a/plc4go/protocols/bacnetip/readwrite/model/BVLCForwardedNPDU.go +++ b/plc4go/protocols/bacnetip/readwrite/model/BVLCForwardedNPDU.go @@ -172,13 +172,13 @@ func BVLCForwardedNPDUParseWithBuffer(ctx context.Context, readBuffer utils.Read return nil, errors.Wrap(pullErr, "Error pulling for ip") } // Count array - ip := make([]uint8, uint16(4)) + ip := make([]uint8, utils.Max(uint16(4), 0)) // This happens when the size is set conditional to 0 if len(ip) == 0 { ip = nil } { - _numItems := uint16(uint16(4)) + _numItems := uint16(utils.Max(uint16(4), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/bacnetip/readwrite/model/NLMInitalizeRoutingTable.go b/plc4go/protocols/bacnetip/readwrite/model/NLMInitalizeRoutingTable.go index 46aa660ecce..a8e8c21e4ca 100644 --- a/plc4go/protocols/bacnetip/readwrite/model/NLMInitalizeRoutingTable.go +++ b/plc4go/protocols/bacnetip/readwrite/model/NLMInitalizeRoutingTable.go @@ -169,13 +169,13 @@ func NLMInitalizeRoutingTableParseWithBuffer(ctx context.Context, readBuffer uti return nil, errors.Wrap(pullErr, "Error pulling for portMappings") } // Count array - portMappings := make([]NLMInitalizeRoutingTablePortMapping, numberOfPorts) + portMappings := make([]NLMInitalizeRoutingTablePortMapping, utils.Max(numberOfPorts, 0)) // This happens when the size is set conditional to 0 if len(portMappings) == 0 { portMappings = nil } { - _numItems := uint16(numberOfPorts) + _numItems := uint16(utils.Max(numberOfPorts, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/bacnetip/readwrite/model/NLMInitalizeRoutingTableAck.go b/plc4go/protocols/bacnetip/readwrite/model/NLMInitalizeRoutingTableAck.go index e14fc509452..970ea2102bb 100644 --- a/plc4go/protocols/bacnetip/readwrite/model/NLMInitalizeRoutingTableAck.go +++ b/plc4go/protocols/bacnetip/readwrite/model/NLMInitalizeRoutingTableAck.go @@ -169,13 +169,13 @@ func NLMInitalizeRoutingTableAckParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for portMappings") } // Count array - portMappings := make([]NLMInitalizeRoutingTablePortMapping, numberOfPorts) + portMappings := make([]NLMInitalizeRoutingTablePortMapping, utils.Max(numberOfPorts, 0)) // This happens when the size is set conditional to 0 if len(portMappings) == 0 { portMappings = nil } { - _numItems := uint16(numberOfPorts) + _numItems := uint16(utils.Max(numberOfPorts, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/bacnetip/readwrite/model/NLMUpdateKeyUpdate.go b/plc4go/protocols/bacnetip/readwrite/model/NLMUpdateKeyUpdate.go index b551cc926d9..2cd8176ac0c 100644 --- a/plc4go/protocols/bacnetip/readwrite/model/NLMUpdateKeyUpdate.go +++ b/plc4go/protocols/bacnetip/readwrite/model/NLMUpdateKeyUpdate.go @@ -337,13 +337,13 @@ func NLMUpdateKeyUpdateParseWithBuffer(ctx context.Context, readBuffer utils.Rea return nil, errors.Wrap(pullErr, "Error pulling for set1Keys") } // Count array - set1Keys := make([]NLMUpdateKeyUpdateKeyEntry, utils.InlineIf(bool((set1KeyCount) != (nil)), func() any { return uint16((*set1KeyCount)) }, func() any { return uint16(uint16(0)) }).(uint16)) + set1Keys := make([]NLMUpdateKeyUpdateKeyEntry, utils.Max(utils.InlineIf(bool((set1KeyCount) != (nil)), func() any { return uint16((*set1KeyCount)) }, func() any { return uint16(uint16(0)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(set1Keys) == 0 { set1Keys = nil } { - _numItems := uint16(utils.InlineIf(bool((set1KeyCount) != (nil)), func() any { return uint16((*set1KeyCount)) }, func() any { return uint16(uint16(0)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((set1KeyCount) != (nil)), func() any { return uint16((*set1KeyCount)) }, func() any { return uint16(uint16(0)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -404,13 +404,13 @@ func NLMUpdateKeyUpdateParseWithBuffer(ctx context.Context, readBuffer utils.Rea return nil, errors.Wrap(pullErr, "Error pulling for set2Keys") } // Count array - set2Keys := make([]NLMUpdateKeyUpdateKeyEntry, utils.InlineIf(bool((set1KeyCount) != (nil)), func() any { return uint16((*set1KeyCount)) }, func() any { return uint16(uint16(0)) }).(uint16)) + set2Keys := make([]NLMUpdateKeyUpdateKeyEntry, utils.Max(utils.InlineIf(bool((set1KeyCount) != (nil)), func() any { return uint16((*set1KeyCount)) }, func() any { return uint16(uint16(0)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(set2Keys) == 0 { set2Keys = nil } { - _numItems := uint16(utils.InlineIf(bool((set1KeyCount) != (nil)), func() any { return uint16((*set1KeyCount)) }, func() any { return uint16(uint16(0)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((set1KeyCount) != (nil)), func() any { return uint16((*set1KeyCount)) }, func() any { return uint16(uint16(0)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/bacnetip/readwrite/model/NPDU.go b/plc4go/protocols/bacnetip/readwrite/model/NPDU.go index 090afeafc0e..8263166811a 100644 --- a/plc4go/protocols/bacnetip/readwrite/model/NPDU.go +++ b/plc4go/protocols/bacnetip/readwrite/model/NPDU.go @@ -360,13 +360,13 @@ func NPDUParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer, npduL return nil, errors.Wrap(pullErr, "Error pulling for destinationAddress") } // Count array - destinationAddress := make([]uint8, utils.InlineIf(control.GetDestinationSpecified(), func() any { return uint16((*destinationLength)) }, func() any { return uint16(uint16(0)) }).(uint16)) + destinationAddress := make([]uint8, utils.Max(utils.InlineIf(control.GetDestinationSpecified(), func() any { return uint16((*destinationLength)) }, func() any { return uint16(uint16(0)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(destinationAddress) == 0 { destinationAddress = nil } { - _numItems := uint16(utils.InlineIf(control.GetDestinationSpecified(), func() any { return uint16((*destinationLength)) }, func() any { return uint16(uint16(0)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(control.GetDestinationSpecified(), func() any { return uint16((*destinationLength)) }, func() any { return uint16(uint16(0)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -412,13 +412,13 @@ func NPDUParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer, npduL return nil, errors.Wrap(pullErr, "Error pulling for sourceAddress") } // Count array - sourceAddress := make([]uint8, utils.InlineIf(control.GetSourceSpecified(), func() any { return uint16((*sourceLength)) }, func() any { return uint16(uint16(0)) }).(uint16)) + sourceAddress := make([]uint8, utils.Max(utils.InlineIf(control.GetSourceSpecified(), func() any { return uint16((*sourceLength)) }, func() any { return uint16(uint16(0)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(sourceAddress) == 0 { sourceAddress = nil } { - _numItems := uint16(utils.InlineIf(control.GetSourceSpecified(), func() any { return uint16((*sourceLength)) }, func() any { return uint16(uint16(0)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(control.GetSourceSpecified(), func() any { return uint16((*sourceLength)) }, func() any { return uint16(uint16(0)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/cbus/readwrite/model/CALDataStatus.go b/plc4go/protocols/cbus/readwrite/model/CALDataStatus.go index 364cec0939d..545895c1ef6 100644 --- a/plc4go/protocols/cbus/readwrite/model/CALDataStatus.go +++ b/plc4go/protocols/cbus/readwrite/model/CALDataStatus.go @@ -192,13 +192,13 @@ func CALDataStatusParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuff return nil, errors.Wrap(pullErr, "Error pulling for statusBytes") } // Count array - statusBytes := make([]StatusByte, uint16(commandTypeContainer.NumBytes())-uint16(uint16(2))) + statusBytes := make([]StatusByte, utils.Max(uint16(commandTypeContainer.NumBytes())-uint16(uint16(2)), 0)) // This happens when the size is set conditional to 0 if len(statusBytes) == 0 { statusBytes = nil } { - _numItems := uint16(uint16(commandTypeContainer.NumBytes()) - uint16(uint16(2))) + _numItems := uint16(utils.Max(uint16(commandTypeContainer.NumBytes())-uint16(uint16(2)), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/cbus/readwrite/model/CALDataStatusExtended.go b/plc4go/protocols/cbus/readwrite/model/CALDataStatusExtended.go index 22ee5feaf08..4a94462137d 100644 --- a/plc4go/protocols/cbus/readwrite/model/CALDataStatusExtended.go +++ b/plc4go/protocols/cbus/readwrite/model/CALDataStatusExtended.go @@ -277,13 +277,13 @@ func CALDataStatusExtendedParseWithBuffer(ctx context.Context, readBuffer utils. return nil, errors.Wrap(pullErr, "Error pulling for statusBytes") } // Count array - statusBytes := make([]StatusByte, numberOfStatusBytes) + statusBytes := make([]StatusByte, utils.Max(numberOfStatusBytes, 0)) // This happens when the size is set conditional to 0 if len(statusBytes) == 0 { statusBytes = nil } { - _numItems := uint16(numberOfStatusBytes) + _numItems := uint16(utils.Max(numberOfStatusBytes, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -304,13 +304,13 @@ func CALDataStatusExtendedParseWithBuffer(ctx context.Context, readBuffer utils. return nil, errors.Wrap(pullErr, "Error pulling for levelInformation") } // Count array - levelInformation := make([]LevelInformation, numberOfLevelInformation) + levelInformation := make([]LevelInformation, utils.Max(numberOfLevelInformation, 0)) // This happens when the size is set conditional to 0 if len(levelInformation) == 0 { levelInformation = nil } { - _numItems := uint16(numberOfLevelInformation) + _numItems := uint16(utils.Max(numberOfLevelInformation, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/cbus/readwrite/model/IdentifyReplyCommandLogicalAssignment.go b/plc4go/protocols/cbus/readwrite/model/IdentifyReplyCommandLogicalAssignment.go index 726a5e8e062..55ebba2dbbf 100644 --- a/plc4go/protocols/cbus/readwrite/model/IdentifyReplyCommandLogicalAssignment.go +++ b/plc4go/protocols/cbus/readwrite/model/IdentifyReplyCommandLogicalAssignment.go @@ -151,13 +151,13 @@ func IdentifyReplyCommandLogicalAssignmentParseWithBuffer(ctx context.Context, r return nil, errors.Wrap(pullErr, "Error pulling for logicAssigment") } // Count array - logicAssigment := make([]LogicAssignment, numBytes) + logicAssigment := make([]LogicAssignment, utils.Max(numBytes, 0)) // This happens when the size is set conditional to 0 if len(logicAssigment) == 0 { logicAssigment = nil } { - _numItems := uint16(numBytes) + _numItems := uint16(utils.Max(numBytes, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/cbus/readwrite/model/NetworkRoute.go b/plc4go/protocols/cbus/readwrite/model/NetworkRoute.go index 266f7f784ef..98480aacc54 100644 --- a/plc4go/protocols/cbus/readwrite/model/NetworkRoute.go +++ b/plc4go/protocols/cbus/readwrite/model/NetworkRoute.go @@ -147,13 +147,13 @@ func NetworkRouteParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffe return nil, errors.Wrap(pullErr, "Error pulling for additionalBridgeAddresses") } // Count array - additionalBridgeAddresses := make([]BridgeAddress, uint16(networkPCI.GetStackDepth())-uint16(uint16(1))) + additionalBridgeAddresses := make([]BridgeAddress, utils.Max(uint16(networkPCI.GetStackDepth())-uint16(uint16(1)), 0)) // This happens when the size is set conditional to 0 if len(additionalBridgeAddresses) == 0 { additionalBridgeAddresses = nil } { - _numItems := uint16(uint16(networkPCI.GetStackDepth()) - uint16(uint16(1))) + _numItems := uint16(utils.Max(uint16(networkPCI.GetStackDepth())-uint16(uint16(1)), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/cbus/readwrite/model/SecurityDataStatusReport1.go b/plc4go/protocols/cbus/readwrite/model/SecurityDataStatusReport1.go index f00ae269b9c..b8c05b8d6c5 100644 --- a/plc4go/protocols/cbus/readwrite/model/SecurityDataStatusReport1.go +++ b/plc4go/protocols/cbus/readwrite/model/SecurityDataStatusReport1.go @@ -222,13 +222,13 @@ func SecurityDataStatusReport1ParseWithBuffer(ctx context.Context, readBuffer ut return nil, errors.Wrap(pullErr, "Error pulling for zoneStatus") } // Count array - zoneStatus := make([]ZoneStatus, uint16(32)) + zoneStatus := make([]ZoneStatus, utils.Max(uint16(32), 0)) // This happens when the size is set conditional to 0 if len(zoneStatus) == 0 { zoneStatus = nil } { - _numItems := uint16(uint16(32)) + _numItems := uint16(utils.Max(uint16(32), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/cbus/readwrite/model/SecurityDataStatusReport2.go b/plc4go/protocols/cbus/readwrite/model/SecurityDataStatusReport2.go index a3eb518a3ea..a757e11e778 100644 --- a/plc4go/protocols/cbus/readwrite/model/SecurityDataStatusReport2.go +++ b/plc4go/protocols/cbus/readwrite/model/SecurityDataStatusReport2.go @@ -150,13 +150,13 @@ func SecurityDataStatusReport2ParseWithBuffer(ctx context.Context, readBuffer ut return nil, errors.Wrap(pullErr, "Error pulling for zoneStatus") } // Count array - zoneStatus := make([]ZoneStatus, uint16(48)) + zoneStatus := make([]ZoneStatus, utils.Max(uint16(48), 0)) // This happens when the size is set conditional to 0 if len(zoneStatus) == 0 { zoneStatus = nil } { - _numItems := uint16(uint16(48)) + _numItems := uint16(utils.Max(uint16(48), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/cbus/readwrite/model/StaticHelper.go b/plc4go/protocols/cbus/readwrite/model/StaticHelper.go index 5e5d0b191f8..8c7400e7c64 100644 --- a/plc4go/protocols/cbus/readwrite/model/StaticHelper.go +++ b/plc4go/protocols/cbus/readwrite/model/StaticHelper.go @@ -144,7 +144,7 @@ func readBytesFromHex(ctx context.Context, logicalName string, readBuffer utils. readBuffer.Reset(readBuffer.GetPos() - 2) rawBytes = rawBytes[:len(rawBytes)-1] } - log.Trace().Int("n", n).Msg("%d bytes decoded") + log.Trace().Int("n", n).Msg("n bytes decoded") return rawBytes, nil } @@ -195,7 +195,7 @@ func encodeHexUpperCase(dst, src []byte) int { return len(src) * 2 } -func KnowsCALCommandTypeContainer(ctx context.Context, readBuffer utils.ReadBuffer) bool { +func KnowsCALCommandTypeContainer(_ context.Context, readBuffer utils.ReadBuffer) bool { oldPos := readBuffer.GetPos() defer readBuffer.Reset(oldPos) readUint8, err := readBuffer.ReadUint8("", 8) @@ -205,7 +205,7 @@ func KnowsCALCommandTypeContainer(ctx context.Context, readBuffer utils.ReadBuff return CALCommandTypeContainerKnows(readUint8) } -func KnowsLightingCommandTypeContainer(ctx context.Context, readBuffer utils.ReadBuffer) bool { +func KnowsLightingCommandTypeContainer(_ context.Context, readBuffer utils.ReadBuffer) bool { oldPos := readBuffer.GetPos() defer readBuffer.Reset(oldPos) readUint8, err := readBuffer.ReadUint8("", 8) @@ -215,7 +215,7 @@ func KnowsLightingCommandTypeContainer(ctx context.Context, readBuffer utils.Rea return LightingCommandTypeContainerKnows(readUint8) } -func KnowsSecurityCommandTypeContainer(ctx context.Context, readBuffer utils.ReadBuffer) bool { +func KnowsSecurityCommandTypeContainer(_ context.Context, readBuffer utils.ReadBuffer) bool { oldPos := readBuffer.GetPos() defer readBuffer.Reset(oldPos) readUint8, err := readBuffer.ReadUint8("", 8) @@ -225,7 +225,7 @@ func KnowsSecurityCommandTypeContainer(ctx context.Context, readBuffer utils.Rea return SecurityCommandTypeContainerKnows(readUint8) } -func KnowsMeteringCommandTypeContainer(ctx context.Context, readBuffer utils.ReadBuffer) bool { +func KnowsMeteringCommandTypeContainer(_ context.Context, readBuffer utils.ReadBuffer) bool { oldPos := readBuffer.GetPos() defer readBuffer.Reset(oldPos) readUint8, err := readBuffer.ReadUint8("", 8) @@ -235,7 +235,7 @@ func KnowsMeteringCommandTypeContainer(ctx context.Context, readBuffer utils.Rea return MeteringCommandTypeContainerKnows(readUint8) } -func KnowsTriggerControlCommandTypeContainer(ctx context.Context, readBuffer utils.ReadBuffer) bool { +func KnowsTriggerControlCommandTypeContainer(_ context.Context, readBuffer utils.ReadBuffer) bool { oldPos := readBuffer.GetPos() defer readBuffer.Reset(oldPos) readUint8, err := readBuffer.ReadUint8("", 8) @@ -245,7 +245,7 @@ func KnowsTriggerControlCommandTypeContainer(ctx context.Context, readBuffer uti return TriggerControlCommandTypeContainerKnows(readUint8) } -func KnowsEnableControlCommandTypeContainer(ctx context.Context, readBuffer utils.ReadBuffer) bool { +func KnowsEnableControlCommandTypeContainer(_ context.Context, readBuffer utils.ReadBuffer) bool { oldPos := readBuffer.GetPos() defer readBuffer.Reset(oldPos) readUint8, err := readBuffer.ReadUint8("", 8) @@ -255,7 +255,7 @@ func KnowsEnableControlCommandTypeContainer(ctx context.Context, readBuffer util return EnableControlCommandTypeContainerKnows(readUint8) } -func KnowsTemperatureBroadcastCommandTypeContainer(ctx context.Context, readBuffer utils.ReadBuffer) bool { +func KnowsTemperatureBroadcastCommandTypeContainer(_ context.Context, readBuffer utils.ReadBuffer) bool { oldPos := readBuffer.GetPos() defer readBuffer.Reset(oldPos) readUint8, err := readBuffer.ReadUint8("", 8) @@ -265,7 +265,7 @@ func KnowsTemperatureBroadcastCommandTypeContainer(ctx context.Context, readBuff return TemperatureBroadcastCommandTypeContainerKnows(readUint8) } -func KnowsAccessControlCommandTypeContainer(ctx context.Context, readBuffer utils.ReadBuffer) bool { +func KnowsAccessControlCommandTypeContainer(_ context.Context, readBuffer utils.ReadBuffer) bool { oldPos := readBuffer.GetPos() defer readBuffer.Reset(oldPos) readUint8, err := readBuffer.ReadUint8("", 8) @@ -275,7 +275,7 @@ func KnowsAccessControlCommandTypeContainer(ctx context.Context, readBuffer util return AccessControlCommandTypeContainerKnows(readUint8) } -func KnowsMediaTransportControlCommandTypeContainer(ctx context.Context, readBuffer utils.ReadBuffer) bool { +func KnowsMediaTransportControlCommandTypeContainer(_ context.Context, readBuffer utils.ReadBuffer) bool { oldPos := readBuffer.GetPos() defer readBuffer.Reset(oldPos) readUint8, err := readBuffer.ReadUint8("", 8) @@ -285,7 +285,7 @@ func KnowsMediaTransportControlCommandTypeContainer(ctx context.Context, readBuf return MediaTransportControlCommandTypeContainerKnows(readUint8) } -func KnowsClockAndTimekeepingCommandTypeContainer(ctx context.Context, readBuffer utils.ReadBuffer) bool { +func KnowsClockAndTimekeepingCommandTypeContainer(_ context.Context, readBuffer utils.ReadBuffer) bool { oldPos := readBuffer.GetPos() defer readBuffer.Reset(oldPos) readUint8, err := readBuffer.ReadUint8("", 8) @@ -295,7 +295,7 @@ func KnowsClockAndTimekeepingCommandTypeContainer(ctx context.Context, readBuffe return ClockAndTimekeepingCommandTypeContainerKnows(readUint8) } -func KnowsTelephonyCommandTypeContainer(ctx context.Context, readBuffer utils.ReadBuffer) bool { +func KnowsTelephonyCommandTypeContainer(_ context.Context, readBuffer utils.ReadBuffer) bool { oldPos := readBuffer.GetPos() defer readBuffer.Reset(oldPos) readUint8, err := readBuffer.ReadUint8("", 8) @@ -305,7 +305,7 @@ func KnowsTelephonyCommandTypeContainer(ctx context.Context, readBuffer utils.Re return TelephonyCommandTypeContainerKnows(readUint8) } -func KnowsAirConditioningCommandTypeContainer(ctx context.Context, readBuffer utils.ReadBuffer) bool { +func KnowsAirConditioningCommandTypeContainer(_ context.Context, readBuffer utils.ReadBuffer) bool { oldPos := readBuffer.GetPos() defer readBuffer.Reset(oldPos) readUint8, err := readBuffer.ReadUint8("", 8) @@ -315,7 +315,7 @@ func KnowsAirConditioningCommandTypeContainer(ctx context.Context, readBuffer ut return AirConditioningCommandTypeContainerKnows(readUint8) } -func KnowsMeasurementCommandTypeContainer(ctx context.Context, readBuffer utils.ReadBuffer) bool { +func KnowsMeasurementCommandTypeContainer(_ context.Context, readBuffer utils.ReadBuffer) bool { oldPos := readBuffer.GetPos() defer readBuffer.Reset(oldPos) readUint8, err := readBuffer.ReadUint8("", 8) @@ -325,7 +325,7 @@ func KnowsMeasurementCommandTypeContainer(ctx context.Context, readBuffer utils. return MeasurementCommandTypeContainerKnows(readUint8) } -func KnowsErrorReportingCommandTypeContainer(ctx context.Context, readBuffer utils.ReadBuffer) bool { +func KnowsErrorReportingCommandTypeContainer(_ context.Context, readBuffer utils.ReadBuffer) bool { oldPos := readBuffer.GetPos() defer readBuffer.Reset(oldPos) readUint8, err := readBuffer.ReadUint8("", 8) diff --git a/plc4go/protocols/eip/readwrite/model/CIPAttributes.go b/plc4go/protocols/eip/readwrite/model/CIPAttributes.go index 536e0860fa0..5b251f9cd91 100644 --- a/plc4go/protocols/eip/readwrite/model/CIPAttributes.go +++ b/plc4go/protocols/eip/readwrite/model/CIPAttributes.go @@ -168,13 +168,13 @@ func CIPAttributesParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuff return nil, errors.Wrap(pullErr, "Error pulling for classId") } // Count array - classId := make([]uint16, numberOfClasses) + classId := make([]uint16, utils.Max(numberOfClasses, 0)) // This happens when the size is set conditional to 0 if len(classId) == 0 { classId = nil } { - _numItems := uint16(numberOfClasses) + _numItems := uint16(utils.Max(numberOfClasses, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/eip/readwrite/model/CipIdentity.go b/plc4go/protocols/eip/readwrite/model/CipIdentity.go index 41618ed7d90..6201ec89dfd 100644 --- a/plc4go/protocols/eip/readwrite/model/CipIdentity.go +++ b/plc4go/protocols/eip/readwrite/model/CipIdentity.go @@ -339,13 +339,13 @@ func CipIdentityParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer return nil, errors.Wrap(pullErr, "Error pulling for socketAddressAddress") } // Count array - socketAddressAddress := make([]uint8, uint16(4)) + socketAddressAddress := make([]uint8, utils.Max(uint16(4), 0)) // This happens when the size is set conditional to 0 if len(socketAddressAddress) == 0 { socketAddressAddress = nil } { - _numItems := uint16(uint16(4)) + _numItems := uint16(utils.Max(uint16(4), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/eip/readwrite/model/CipRRData.go b/plc4go/protocols/eip/readwrite/model/CipRRData.go index 7d254395cc5..80f059c0464 100644 --- a/plc4go/protocols/eip/readwrite/model/CipRRData.go +++ b/plc4go/protocols/eip/readwrite/model/CipRRData.go @@ -210,13 +210,13 @@ func CipRRDataParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer, return nil, errors.Wrap(pullErr, "Error pulling for typeIds") } // Count array - typeIds := make([]TypeId, typeIdCount) + typeIds := make([]TypeId, utils.Max(typeIdCount, 0)) // This happens when the size is set conditional to 0 if len(typeIds) == 0 { typeIds = nil } { - _numItems := uint16(typeIdCount) + _numItems := uint16(utils.Max(typeIdCount, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/eip/readwrite/model/CipSecurityInformation.go b/plc4go/protocols/eip/readwrite/model/CipSecurityInformation.go index d95aa47dfd6..c48b5a7adfe 100644 --- a/plc4go/protocols/eip/readwrite/model/CipSecurityInformation.go +++ b/plc4go/protocols/eip/readwrite/model/CipSecurityInformation.go @@ -156,13 +156,13 @@ func CipSecurityInformationParseWithBuffer(ctx context.Context, readBuffer utils return nil, errors.Wrap(pullErr, "Error pulling for todoImplement") } // Count array - todoImplement := make([]uint8, itemLength) + todoImplement := make([]uint8, utils.Max(itemLength, 0)) // This happens when the size is set conditional to 0 if len(todoImplement) == 0 { todoImplement = nil } { - _numItems := uint16(itemLength) + _numItems := uint16(utils.Max(itemLength, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/eip/readwrite/model/EipListIdentityResponse.go b/plc4go/protocols/eip/readwrite/model/EipListIdentityResponse.go index efdc3e86897..7622174fbb9 100644 --- a/plc4go/protocols/eip/readwrite/model/EipListIdentityResponse.go +++ b/plc4go/protocols/eip/readwrite/model/EipListIdentityResponse.go @@ -174,13 +174,13 @@ func EipListIdentityResponseParseWithBuffer(ctx context.Context, readBuffer util return nil, errors.Wrap(pullErr, "Error pulling for items") } // Count array - items := make([]CommandSpecificDataItem, itemCount) + items := make([]CommandSpecificDataItem, utils.Max(itemCount, 0)) // This happens when the size is set conditional to 0 if len(items) == 0 { items = nil } { - _numItems := uint16(itemCount) + _numItems := uint16(utils.Max(itemCount, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/eip/readwrite/model/ListServicesResponse.go b/plc4go/protocols/eip/readwrite/model/ListServicesResponse.go index 3f8658ec397..adeef4cde58 100644 --- a/plc4go/protocols/eip/readwrite/model/ListServicesResponse.go +++ b/plc4go/protocols/eip/readwrite/model/ListServicesResponse.go @@ -174,13 +174,13 @@ func ListServicesResponseParseWithBuffer(ctx context.Context, readBuffer utils.R return nil, errors.Wrap(pullErr, "Error pulling for typeIds") } // Count array - typeIds := make([]TypeId, typeIdCount) + typeIds := make([]TypeId, utils.Max(typeIdCount, 0)) // This happens when the size is set conditional to 0 if len(typeIds) == 0 { typeIds = nil } { - _numItems := uint16(typeIdCount) + _numItems := uint16(utils.Max(typeIdCount, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/eip/readwrite/model/MultipleServiceResponse.go b/plc4go/protocols/eip/readwrite/model/MultipleServiceResponse.go index 95f5afd3f65..6a8b1eb10d7 100644 --- a/plc4go/protocols/eip/readwrite/model/MultipleServiceResponse.go +++ b/plc4go/protocols/eip/readwrite/model/MultipleServiceResponse.go @@ -243,13 +243,13 @@ func MultipleServiceResponseParseWithBuffer(ctx context.Context, readBuffer util return nil, errors.Wrap(pullErr, "Error pulling for offsets") } // Count array - offsets := make([]uint16, serviceNb) + offsets := make([]uint16, utils.Max(serviceNb, 0)) // This happens when the size is set conditional to 0 if len(offsets) == 0 { offsets = nil } { - _numItems := uint16(serviceNb) + _numItems := uint16(utils.Max(serviceNb, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/eip/readwrite/model/SendUnitData.go b/plc4go/protocols/eip/readwrite/model/SendUnitData.go index b3bb67672e8..d1624ab68b1 100644 --- a/plc4go/protocols/eip/readwrite/model/SendUnitData.go +++ b/plc4go/protocols/eip/readwrite/model/SendUnitData.go @@ -220,13 +220,13 @@ func SendUnitDataParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffe return nil, errors.Wrap(pullErr, "Error pulling for typeIds") } // Count array - typeIds := make([]TypeId, typeIdCount) + typeIds := make([]TypeId, utils.Max(typeIdCount, 0)) // This happens when the size is set conditional to 0 if len(typeIds) == 0 { typeIds = nil } { - _numItems := uint16(typeIdCount) + _numItems := uint16(utils.Max(typeIdCount, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/eip/readwrite/model/Services.go b/plc4go/protocols/eip/readwrite/model/Services.go index d3009b1ced3..2644b5c7af7 100644 --- a/plc4go/protocols/eip/readwrite/model/Services.go +++ b/plc4go/protocols/eip/readwrite/model/Services.go @@ -149,13 +149,13 @@ func ServicesParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer, s return nil, errors.Wrap(pullErr, "Error pulling for offsets") } // Count array - offsets := make([]uint16, serviceNb) + offsets := make([]uint16, utils.Max(serviceNb, 0)) // This happens when the size is set conditional to 0 if len(offsets) == 0 { offsets = nil } { - _numItems := uint16(serviceNb) + _numItems := uint16(utils.Max(serviceNb, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -176,13 +176,13 @@ func ServicesParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer, s return nil, errors.Wrap(pullErr, "Error pulling for services") } // Count array - services := make([]CipService, serviceNb) + services := make([]CipService, utils.Max(serviceNb, 0)) // This happens when the size is set conditional to 0 if len(services) == 0 { services = nil } { - _numItems := uint16(serviceNb) + _numItems := uint16(utils.Max(serviceNb, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/firmata/readwrite/model/FirmataMessageAnalogIO.go b/plc4go/protocols/firmata/readwrite/model/FirmataMessageAnalogIO.go index a548a332385..f158a34e31f 100644 --- a/plc4go/protocols/firmata/readwrite/model/FirmataMessageAnalogIO.go +++ b/plc4go/protocols/firmata/readwrite/model/FirmataMessageAnalogIO.go @@ -165,13 +165,13 @@ func FirmataMessageAnalogIOParseWithBuffer(ctx context.Context, readBuffer utils return nil, errors.Wrap(pullErr, "Error pulling for data") } // Count array - data := make([]int8, uint16(2)) + data := make([]int8, utils.Max(uint16(2), 0)) // This happens when the size is set conditional to 0 if len(data) == 0 { data = nil } { - _numItems := uint16(uint16(2)) + _numItems := uint16(utils.Max(uint16(2), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/firmata/readwrite/model/FirmataMessageDigitalIO.go b/plc4go/protocols/firmata/readwrite/model/FirmataMessageDigitalIO.go index 0157acd9bfd..83f561dc2d7 100644 --- a/plc4go/protocols/firmata/readwrite/model/FirmataMessageDigitalIO.go +++ b/plc4go/protocols/firmata/readwrite/model/FirmataMessageDigitalIO.go @@ -165,13 +165,13 @@ func FirmataMessageDigitalIOParseWithBuffer(ctx context.Context, readBuffer util return nil, errors.Wrap(pullErr, "Error pulling for data") } // Count array - data := make([]int8, uint16(2)) + data := make([]int8, utils.Max(uint16(2), 0)) // This happens when the size is set conditional to 0 if len(data) == 0 { data = nil } { - _numItems := uint16(uint16(2)) + _numItems := uint16(utils.Max(uint16(2), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/firmata/readwrite/model/SysexCommandExtendedId.go b/plc4go/protocols/firmata/readwrite/model/SysexCommandExtendedId.go index f098d11a206..85866d84536 100644 --- a/plc4go/protocols/firmata/readwrite/model/SysexCommandExtendedId.go +++ b/plc4go/protocols/firmata/readwrite/model/SysexCommandExtendedId.go @@ -150,13 +150,13 @@ func SysexCommandExtendedIdParseWithBuffer(ctx context.Context, readBuffer utils return nil, errors.Wrap(pullErr, "Error pulling for id") } // Count array - id := make([]int8, uint16(2)) + id := make([]int8, utils.Max(uint16(2), 0)) // This happens when the size is set conditional to 0 if len(id) == 0 { id = nil } { - _numItems := uint16(uint16(2)) + _numItems := uint16(utils.Max(uint16(2), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/knxnetip/readwrite/model/ComObjectTableRealisationType1.go b/plc4go/protocols/knxnetip/readwrite/model/ComObjectTableRealisationType1.go index e57e2e52933..b9222fd8c03 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/ComObjectTableRealisationType1.go +++ b/plc4go/protocols/knxnetip/readwrite/model/ComObjectTableRealisationType1.go @@ -187,13 +187,13 @@ func ComObjectTableRealisationType1ParseWithBuffer(ctx context.Context, readBuff return nil, errors.Wrap(pullErr, "Error pulling for comObjectDescriptors") } // Count array - comObjectDescriptors := make([]GroupObjectDescriptorRealisationType1, numEntries) + comObjectDescriptors := make([]GroupObjectDescriptorRealisationType1, utils.Max(numEntries, 0)) // This happens when the size is set conditional to 0 if len(comObjectDescriptors) == 0 { comObjectDescriptors = nil } { - _numItems := uint16(numEntries) + _numItems := uint16(utils.Max(numEntries, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/knxnetip/readwrite/model/ComObjectTableRealisationType2.go b/plc4go/protocols/knxnetip/readwrite/model/ComObjectTableRealisationType2.go index 3093eb24320..753afc43759 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/ComObjectTableRealisationType2.go +++ b/plc4go/protocols/knxnetip/readwrite/model/ComObjectTableRealisationType2.go @@ -187,13 +187,13 @@ func ComObjectTableRealisationType2ParseWithBuffer(ctx context.Context, readBuff return nil, errors.Wrap(pullErr, "Error pulling for comObjectDescriptors") } // Count array - comObjectDescriptors := make([]GroupObjectDescriptorRealisationType2, numEntries) + comObjectDescriptors := make([]GroupObjectDescriptorRealisationType2, utils.Max(numEntries, 0)) // This happens when the size is set conditional to 0 if len(comObjectDescriptors) == 0 { comObjectDescriptors = nil } { - _numItems := uint16(numEntries) + _numItems := uint16(utils.Max(numEntries, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go b/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go index 9d949319c37..384ce5fb616 100644 --- a/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go +++ b/plc4go/protocols/knxnetip/readwrite/model/KnxManufacturer.go @@ -683,8 +683,9 @@ const ( KnxManufacturer_M_SBR_SYSTEM_TECHNICAL KnxManufacturer = 637 KnxManufacturer_M_SHENZHEN_EASTKAME_TECHNOLOGY_CO___LTD_ KnxManufacturer = 638 KnxManufacturer_M_BOLATU KnxManufacturer = 639 - KnxManufacturer_M_ABB___RESERVED KnxManufacturer = 640 - KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED KnxManufacturer = 641 + KnxManufacturer_M_RECBER_KABLO_A_S_ KnxManufacturer = 640 + KnxManufacturer_M_ABB___RESERVED KnxManufacturer = 641 + KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED KnxManufacturer = 642 ) var KnxManufacturerValues []KnxManufacturer @@ -1332,6 +1333,7 @@ func init() { KnxManufacturer_M_SBR_SYSTEM_TECHNICAL, KnxManufacturer_M_SHENZHEN_EASTKAME_TECHNOLOGY_CO___LTD_, KnxManufacturer_M_BOLATU, + KnxManufacturer_M_RECBER_KABLO_A_S_, KnxManufacturer_M_ABB___RESERVED, KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED, } @@ -3749,10 +3751,14 @@ func (e KnxManufacturer) Number() uint16 { } case 640: { /* '640' */ - return 43954 + return 698 } case 641: { /* '641' */ + return 43954 + } + case 642: + { /* '642' */ return 43959 } case 65: @@ -6335,10 +6341,14 @@ func (e KnxManufacturer) Name() string { } case 640: { /* '640' */ - return "ABB - reserved" + return "RECBER KABLO A.S." } case 641: { /* '641' */ + return "ABB - reserved" + } + case 642: + { /* '642' */ return "Busch-Jaeger Elektro - reserved" } case 65: @@ -7715,8 +7725,10 @@ func KnxManufacturerByValue(value uint16) (enum KnxManufacturer, ok bool) { case 64: return KnxManufacturer_M_BISCHOFF_ELEKTRONIK, true case 640: - return KnxManufacturer_M_ABB___RESERVED, true + return KnxManufacturer_M_RECBER_KABLO_A_S_, true case 641: + return KnxManufacturer_M_ABB___RESERVED, true + case 642: return KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED, true case 65: return KnxManufacturer_M_JEPAZ, true @@ -9004,6 +9016,8 @@ func KnxManufacturerByName(value string) (enum KnxManufacturer, ok bool) { return KnxManufacturer_M_BOLATU, true case "M_BISCHOFF_ELEKTRONIK": return KnxManufacturer_M_BISCHOFF_ELEKTRONIK, true + case "M_RECBER_KABLO_A_S_": + return KnxManufacturer_M_RECBER_KABLO_A_S_, true case "M_ABB___RESERVED": return KnxManufacturer_M_ABB___RESERVED, true case "M_BUSCH_JAEGER_ELEKTRO___RESERVED": @@ -10355,6 +10369,8 @@ func (e KnxManufacturer) PLC4XEnumName() string { return "M_BOLATU" case KnxManufacturer_M_BISCHOFF_ELEKTRONIK: return "M_BISCHOFF_ELEKTRONIK" + case KnxManufacturer_M_RECBER_KABLO_A_S_: + return "M_RECBER_KABLO_A_S_" case KnxManufacturer_M_ABB___RESERVED: return "M_ABB___RESERVED" case KnxManufacturer_M_BUSCH_JAEGER_ELEKTRO___RESERVED: diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadDeviceIdentificationResponse.go b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadDeviceIdentificationResponse.go index b21a0d27d74..862c82748e4 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadDeviceIdentificationResponse.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadDeviceIdentificationResponse.go @@ -305,13 +305,13 @@ func ModbusPDUReadDeviceIdentificationResponseParseWithBuffer(ctx context.Contex return nil, errors.Wrap(pullErr, "Error pulling for objects") } // Count array - objects := make([]ModbusDeviceInformationObject, numberOfObjects) + objects := make([]ModbusDeviceInformationObject, utils.Max(numberOfObjects, 0)) // This happens when the size is set conditional to 0 if len(objects) == 0 { objects = nil } { - _numItems := uint16(numberOfObjects) + _numItems := uint16(utils.Max(numberOfObjects, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadFifoQueueResponse.go b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadFifoQueueResponse.go index 19deb72dd52..7e5fd053109 100644 --- a/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadFifoQueueResponse.go +++ b/plc4go/protocols/modbus/readwrite/model/ModbusPDUReadFifoQueueResponse.go @@ -174,13 +174,13 @@ func ModbusPDUReadFifoQueueResponseParseWithBuffer(ctx context.Context, readBuff return nil, errors.Wrap(pullErr, "Error pulling for fifoValue") } // Count array - fifoValue := make([]uint16, fifoCount) + fifoValue := make([]uint16, utils.Max(fifoCount, 0)) // This happens when the size is set conditional to 0 if len(fifoValue) == 0 { fifoValue = nil } { - _numItems := uint16(fifoCount) + _numItems := uint16(utils.Max(fifoCount, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/ActivateSessionRequest.go b/plc4go/protocols/opcua/readwrite/model/ActivateSessionRequest.go index 5f4cf050c03..5a21b500876 100644 --- a/plc4go/protocols/opcua/readwrite/model/ActivateSessionRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/ActivateSessionRequest.go @@ -268,13 +268,13 @@ func ActivateSessionRequestParseWithBuffer(ctx context.Context, readBuffer utils return nil, errors.Wrap(pullErr, "Error pulling for clientSoftwareCertificates") } // Count array - clientSoftwareCertificates := make([]ExtensionObjectDefinition, noOfClientSoftwareCertificates) + clientSoftwareCertificates := make([]ExtensionObjectDefinition, utils.Max(noOfClientSoftwareCertificates, 0)) // This happens when the size is set conditional to 0 if len(clientSoftwareCertificates) == 0 { clientSoftwareCertificates = nil } { - _numItems := uint16(noOfClientSoftwareCertificates) + _numItems := uint16(utils.Max(noOfClientSoftwareCertificates, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -302,13 +302,13 @@ func ActivateSessionRequestParseWithBuffer(ctx context.Context, readBuffer utils return nil, errors.Wrap(pullErr, "Error pulling for localeIds") } // Count array - localeIds := make([]PascalString, noOfLocaleIds) + localeIds := make([]PascalString, utils.Max(noOfLocaleIds, 0)) // This happens when the size is set conditional to 0 if len(localeIds) == 0 { localeIds = nil } { - _numItems := uint16(noOfLocaleIds) + _numItems := uint16(utils.Max(noOfLocaleIds, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/ActivateSessionResponse.go b/plc4go/protocols/opcua/readwrite/model/ActivateSessionResponse.go index 0f0114982b6..95d57ead926 100644 --- a/plc4go/protocols/opcua/readwrite/model/ActivateSessionResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/ActivateSessionResponse.go @@ -246,13 +246,13 @@ func ActivateSessionResponseParseWithBuffer(ctx context.Context, readBuffer util return nil, errors.Wrap(pullErr, "Error pulling for results") } // Count array - results := make([]StatusCode, noOfResults) + results := make([]StatusCode, utils.Max(noOfResults, 0)) // This happens when the size is set conditional to 0 if len(results) == 0 { results = nil } { - _numItems := uint16(noOfResults) + _numItems := uint16(utils.Max(noOfResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -280,13 +280,13 @@ func ActivateSessionResponseParseWithBuffer(ctx context.Context, readBuffer util return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/AddNodesRequest.go b/plc4go/protocols/opcua/readwrite/model/AddNodesRequest.go index 3075df1139a..b4ba7a9a99f 100644 --- a/plc4go/protocols/opcua/readwrite/model/AddNodesRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/AddNodesRequest.go @@ -193,13 +193,13 @@ func AddNodesRequestParseWithBuffer(ctx context.Context, readBuffer utils.ReadBu return nil, errors.Wrap(pullErr, "Error pulling for nodesToAdd") } // Count array - nodesToAdd := make([]ExtensionObjectDefinition, noOfNodesToAdd) + nodesToAdd := make([]ExtensionObjectDefinition, utils.Max(noOfNodesToAdd, 0)) // This happens when the size is set conditional to 0 if len(nodesToAdd) == 0 { nodesToAdd = nil } { - _numItems := uint16(noOfNodesToAdd) + _numItems := uint16(utils.Max(noOfNodesToAdd, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/AddNodesResponse.go b/plc4go/protocols/opcua/readwrite/model/AddNodesResponse.go index 74cf3eb81b0..7d015b2df1a 100644 --- a/plc4go/protocols/opcua/readwrite/model/AddNodesResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/AddNodesResponse.go @@ -222,13 +222,13 @@ func AddNodesResponseParseWithBuffer(ctx context.Context, readBuffer utils.ReadB return nil, errors.Wrap(pullErr, "Error pulling for results") } // Count array - results := make([]ExtensionObjectDefinition, noOfResults) + results := make([]ExtensionObjectDefinition, utils.Max(noOfResults, 0)) // This happens when the size is set conditional to 0 if len(results) == 0 { results = nil } { - _numItems := uint16(noOfResults) + _numItems := uint16(utils.Max(noOfResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func AddNodesResponseParseWithBuffer(ctx context.Context, readBuffer utils.ReadB return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/AddReferencesRequest.go b/plc4go/protocols/opcua/readwrite/model/AddReferencesRequest.go index 2697f0d7d21..9f4c85e1b5d 100644 --- a/plc4go/protocols/opcua/readwrite/model/AddReferencesRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/AddReferencesRequest.go @@ -193,13 +193,13 @@ func AddReferencesRequestParseWithBuffer(ctx context.Context, readBuffer utils.R return nil, errors.Wrap(pullErr, "Error pulling for referencesToAdd") } // Count array - referencesToAdd := make([]ExtensionObjectDefinition, noOfReferencesToAdd) + referencesToAdd := make([]ExtensionObjectDefinition, utils.Max(noOfReferencesToAdd, 0)) // This happens when the size is set conditional to 0 if len(referencesToAdd) == 0 { referencesToAdd = nil } { - _numItems := uint16(noOfReferencesToAdd) + _numItems := uint16(utils.Max(noOfReferencesToAdd, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/AddReferencesResponse.go b/plc4go/protocols/opcua/readwrite/model/AddReferencesResponse.go index 0ffb134d86b..9b790606da2 100644 --- a/plc4go/protocols/opcua/readwrite/model/AddReferencesResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/AddReferencesResponse.go @@ -222,13 +222,13 @@ func AddReferencesResponseParseWithBuffer(ctx context.Context, readBuffer utils. return nil, errors.Wrap(pullErr, "Error pulling for results") } // Count array - results := make([]StatusCode, noOfResults) + results := make([]StatusCode, utils.Max(noOfResults, 0)) // This happens when the size is set conditional to 0 if len(results) == 0 { results = nil } { - _numItems := uint16(noOfResults) + _numItems := uint16(utils.Max(noOfResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func AddReferencesResponseParseWithBuffer(ctx context.Context, readBuffer utils. return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/AdditionalParametersType.go b/plc4go/protocols/opcua/readwrite/model/AdditionalParametersType.go index 994354fb7ca..ef7ddace0a3 100644 --- a/plc4go/protocols/opcua/readwrite/model/AdditionalParametersType.go +++ b/plc4go/protocols/opcua/readwrite/model/AdditionalParametersType.go @@ -169,13 +169,13 @@ func AdditionalParametersTypeParseWithBuffer(ctx context.Context, readBuffer uti return nil, errors.Wrap(pullErr, "Error pulling for parameters") } // Count array - parameters := make([]ExtensionObjectDefinition, noOfParameters) + parameters := make([]ExtensionObjectDefinition, utils.Max(noOfParameters, 0)) // This happens when the size is set conditional to 0 if len(parameters) == 0 { parameters = nil } { - _numItems := uint16(noOfParameters) + _numItems := uint16(utils.Max(noOfParameters, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/AliasNameDataType.go b/plc4go/protocols/opcua/readwrite/model/AliasNameDataType.go index 6097e7f4907..4acbf01b5d7 100644 --- a/plc4go/protocols/opcua/readwrite/model/AliasNameDataType.go +++ b/plc4go/protocols/opcua/readwrite/model/AliasNameDataType.go @@ -193,13 +193,13 @@ func AliasNameDataTypeParseWithBuffer(ctx context.Context, readBuffer utils.Read return nil, errors.Wrap(pullErr, "Error pulling for referencedNodes") } // Count array - referencedNodes := make([]ExpandedNodeId, noOfReferencedNodes) + referencedNodes := make([]ExpandedNodeId, utils.Max(noOfReferencedNodes, 0)) // This happens when the size is set conditional to 0 if len(referencedNodes) == 0 { referencedNodes = nil } { - _numItems := uint16(noOfReferencedNodes) + _numItems := uint16(utils.Max(noOfReferencedNodes, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/ApplicationDescription.go b/plc4go/protocols/opcua/readwrite/model/ApplicationDescription.go index 7a03ae2efa7..e19d6297ea8 100644 --- a/plc4go/protocols/opcua/readwrite/model/ApplicationDescription.go +++ b/plc4go/protocols/opcua/readwrite/model/ApplicationDescription.go @@ -313,13 +313,13 @@ func ApplicationDescriptionParseWithBuffer(ctx context.Context, readBuffer utils return nil, errors.Wrap(pullErr, "Error pulling for discoveryUrls") } // Count array - discoveryUrls := make([]PascalString, noOfDiscoveryUrls) + discoveryUrls := make([]PascalString, utils.Max(noOfDiscoveryUrls, 0)) // This happens when the size is set conditional to 0 if len(discoveryUrls) == 0 { discoveryUrls = nil } { - _numItems := uint16(noOfDiscoveryUrls) + _numItems := uint16(utils.Max(noOfDiscoveryUrls, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/Argument.go b/plc4go/protocols/opcua/readwrite/model/Argument.go index d8485b4c907..a368b19951a 100644 --- a/plc4go/protocols/opcua/readwrite/model/Argument.go +++ b/plc4go/protocols/opcua/readwrite/model/Argument.go @@ -241,13 +241,13 @@ func ArgumentParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer, i return nil, errors.Wrap(pullErr, "Error pulling for arrayDimensions") } // Count array - arrayDimensions := make([]uint32, noOfArrayDimensions) + arrayDimensions := make([]uint32, utils.Max(noOfArrayDimensions, 0)) // This happens when the size is set conditional to 0 if len(arrayDimensions) == 0 { arrayDimensions = nil } { - _numItems := uint16(noOfArrayDimensions) + _numItems := uint16(utils.Max(noOfArrayDimensions, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/AxisInformation.go b/plc4go/protocols/opcua/readwrite/model/AxisInformation.go index 9128fd5b6b9..382505b8313 100644 --- a/plc4go/protocols/opcua/readwrite/model/AxisInformation.go +++ b/plc4go/protocols/opcua/readwrite/model/AxisInformation.go @@ -260,13 +260,13 @@ func AxisInformationParseWithBuffer(ctx context.Context, readBuffer utils.ReadBu return nil, errors.Wrap(pullErr, "Error pulling for axisSteps") } // Count array - axisSteps := make([]float64, noOfAxisSteps) + axisSteps := make([]float64, utils.Max(noOfAxisSteps, 0)) // This happens when the size is set conditional to 0 if len(axisSteps) == 0 { axisSteps = nil } { - _numItems := uint16(noOfAxisSteps) + _numItems := uint16(utils.Max(noOfAxisSteps, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/BrowseNextRequest.go b/plc4go/protocols/opcua/readwrite/model/BrowseNextRequest.go index 51f170c7003..eaca088b599 100644 --- a/plc4go/protocols/opcua/readwrite/model/BrowseNextRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/BrowseNextRequest.go @@ -233,13 +233,13 @@ func BrowseNextRequestParseWithBuffer(ctx context.Context, readBuffer utils.Read return nil, errors.Wrap(pullErr, "Error pulling for continuationPoints") } // Count array - continuationPoints := make([]PascalByteString, noOfContinuationPoints) + continuationPoints := make([]PascalByteString, utils.Max(noOfContinuationPoints, 0)) // This happens when the size is set conditional to 0 if len(continuationPoints) == 0 { continuationPoints = nil } { - _numItems := uint16(noOfContinuationPoints) + _numItems := uint16(utils.Max(noOfContinuationPoints, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/BrowseNextResponse.go b/plc4go/protocols/opcua/readwrite/model/BrowseNextResponse.go index bb8b3391b11..325cb644d93 100644 --- a/plc4go/protocols/opcua/readwrite/model/BrowseNextResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/BrowseNextResponse.go @@ -222,13 +222,13 @@ func BrowseNextResponseParseWithBuffer(ctx context.Context, readBuffer utils.Rea return nil, errors.Wrap(pullErr, "Error pulling for results") } // Count array - results := make([]ExtensionObjectDefinition, noOfResults) + results := make([]ExtensionObjectDefinition, utils.Max(noOfResults, 0)) // This happens when the size is set conditional to 0 if len(results) == 0 { results = nil } { - _numItems := uint16(noOfResults) + _numItems := uint16(utils.Max(noOfResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func BrowseNextResponseParseWithBuffer(ctx context.Context, readBuffer utils.Rea return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/BrowsePathResult.go b/plc4go/protocols/opcua/readwrite/model/BrowsePathResult.go index 730263debbc..695fca7782b 100644 --- a/plc4go/protocols/opcua/readwrite/model/BrowsePathResult.go +++ b/plc4go/protocols/opcua/readwrite/model/BrowsePathResult.go @@ -193,13 +193,13 @@ func BrowsePathResultParseWithBuffer(ctx context.Context, readBuffer utils.ReadB return nil, errors.Wrap(pullErr, "Error pulling for targets") } // Count array - targets := make([]ExtensionObjectDefinition, noOfTargets) + targets := make([]ExtensionObjectDefinition, utils.Max(noOfTargets, 0)) // This happens when the size is set conditional to 0 if len(targets) == 0 { targets = nil } { - _numItems := uint16(noOfTargets) + _numItems := uint16(utils.Max(noOfTargets, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/BrowseRequest.go b/plc4go/protocols/opcua/readwrite/model/BrowseRequest.go index f2e55489f54..2b3e2aa49e2 100644 --- a/plc4go/protocols/opcua/readwrite/model/BrowseRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/BrowseRequest.go @@ -235,13 +235,13 @@ func BrowseRequestParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuff return nil, errors.Wrap(pullErr, "Error pulling for nodesToBrowse") } // Count array - nodesToBrowse := make([]ExtensionObjectDefinition, noOfNodesToBrowse) + nodesToBrowse := make([]ExtensionObjectDefinition, utils.Max(noOfNodesToBrowse, 0)) // This happens when the size is set conditional to 0 if len(nodesToBrowse) == 0 { nodesToBrowse = nil } { - _numItems := uint16(noOfNodesToBrowse) + _numItems := uint16(utils.Max(noOfNodesToBrowse, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/BrowseResponse.go b/plc4go/protocols/opcua/readwrite/model/BrowseResponse.go index b39709a73bb..409911fa94f 100644 --- a/plc4go/protocols/opcua/readwrite/model/BrowseResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/BrowseResponse.go @@ -222,13 +222,13 @@ func BrowseResponseParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuf return nil, errors.Wrap(pullErr, "Error pulling for results") } // Count array - results := make([]ExtensionObjectDefinition, noOfResults) + results := make([]ExtensionObjectDefinition, utils.Max(noOfResults, 0)) // This happens when the size is set conditional to 0 if len(results) == 0 { results = nil } { - _numItems := uint16(noOfResults) + _numItems := uint16(utils.Max(noOfResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func BrowseResponseParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuf return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/BrowseResult.go b/plc4go/protocols/opcua/readwrite/model/BrowseResult.go index 991436fe5e8..b50cf010218 100644 --- a/plc4go/protocols/opcua/readwrite/model/BrowseResult.go +++ b/plc4go/protocols/opcua/readwrite/model/BrowseResult.go @@ -217,13 +217,13 @@ func BrowseResultParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffe return nil, errors.Wrap(pullErr, "Error pulling for references") } // Count array - references := make([]ExtensionObjectDefinition, noOfReferences) + references := make([]ExtensionObjectDefinition, utils.Max(noOfReferences, 0)) // This happens when the size is set conditional to 0 if len(references) == 0 { references = nil } { - _numItems := uint16(noOfReferences) + _numItems := uint16(utils.Max(noOfReferences, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/ByteStringArray.go b/plc4go/protocols/opcua/readwrite/model/ByteStringArray.go index 1251cb7352d..9ab27115a78 100644 --- a/plc4go/protocols/opcua/readwrite/model/ByteStringArray.go +++ b/plc4go/protocols/opcua/readwrite/model/ByteStringArray.go @@ -136,13 +136,13 @@ func ByteStringArrayParseWithBuffer(ctx context.Context, readBuffer utils.ReadBu return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]uint8, arrayLength) + value := make([]uint8, utils.Max(arrayLength, 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(arrayLength) + _numItems := uint16(utils.Max(arrayLength, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/CallMethodRequest.go b/plc4go/protocols/opcua/readwrite/model/CallMethodRequest.go index 62a86237c83..7f3092e6b76 100644 --- a/plc4go/protocols/opcua/readwrite/model/CallMethodRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/CallMethodRequest.go @@ -217,13 +217,13 @@ func CallMethodRequestParseWithBuffer(ctx context.Context, readBuffer utils.Read return nil, errors.Wrap(pullErr, "Error pulling for inputArguments") } // Count array - inputArguments := make([]Variant, noOfInputArguments) + inputArguments := make([]Variant, utils.Max(noOfInputArguments, 0)) // This happens when the size is set conditional to 0 if len(inputArguments) == 0 { inputArguments = nil } { - _numItems := uint16(noOfInputArguments) + _numItems := uint16(utils.Max(noOfInputArguments, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/CallMethodResult.go b/plc4go/protocols/opcua/readwrite/model/CallMethodResult.go index 768d5d676dd..3a067cdfad8 100644 --- a/plc4go/protocols/opcua/readwrite/model/CallMethodResult.go +++ b/plc4go/protocols/opcua/readwrite/model/CallMethodResult.go @@ -251,13 +251,13 @@ func CallMethodResultParseWithBuffer(ctx context.Context, readBuffer utils.ReadB return nil, errors.Wrap(pullErr, "Error pulling for inputArgumentResults") } // Count array - inputArgumentResults := make([]StatusCode, noOfInputArgumentResults) + inputArgumentResults := make([]StatusCode, utils.Max(noOfInputArgumentResults, 0)) // This happens when the size is set conditional to 0 if len(inputArgumentResults) == 0 { inputArgumentResults = nil } { - _numItems := uint16(noOfInputArgumentResults) + _numItems := uint16(utils.Max(noOfInputArgumentResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -285,13 +285,13 @@ func CallMethodResultParseWithBuffer(ctx context.Context, readBuffer utils.ReadB return nil, errors.Wrap(pullErr, "Error pulling for inputArgumentDiagnosticInfos") } // Count array - inputArgumentDiagnosticInfos := make([]DiagnosticInfo, noOfInputArgumentDiagnosticInfos) + inputArgumentDiagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfInputArgumentDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(inputArgumentDiagnosticInfos) == 0 { inputArgumentDiagnosticInfos = nil } { - _numItems := uint16(noOfInputArgumentDiagnosticInfos) + _numItems := uint16(utils.Max(noOfInputArgumentDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -319,13 +319,13 @@ func CallMethodResultParseWithBuffer(ctx context.Context, readBuffer utils.ReadB return nil, errors.Wrap(pullErr, "Error pulling for outputArguments") } // Count array - outputArguments := make([]Variant, noOfOutputArguments) + outputArguments := make([]Variant, utils.Max(noOfOutputArguments, 0)) // This happens when the size is set conditional to 0 if len(outputArguments) == 0 { outputArguments = nil } { - _numItems := uint16(noOfOutputArguments) + _numItems := uint16(utils.Max(noOfOutputArguments, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/CallRequest.go b/plc4go/protocols/opcua/readwrite/model/CallRequest.go index 1628d395687..27a13500b54 100644 --- a/plc4go/protocols/opcua/readwrite/model/CallRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/CallRequest.go @@ -193,13 +193,13 @@ func CallRequestParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer return nil, errors.Wrap(pullErr, "Error pulling for methodsToCall") } // Count array - methodsToCall := make([]ExtensionObjectDefinition, noOfMethodsToCall) + methodsToCall := make([]ExtensionObjectDefinition, utils.Max(noOfMethodsToCall, 0)) // This happens when the size is set conditional to 0 if len(methodsToCall) == 0 { methodsToCall = nil } { - _numItems := uint16(noOfMethodsToCall) + _numItems := uint16(utils.Max(noOfMethodsToCall, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/CallResponse.go b/plc4go/protocols/opcua/readwrite/model/CallResponse.go index bc11e3725d2..edeac78625a 100644 --- a/plc4go/protocols/opcua/readwrite/model/CallResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/CallResponse.go @@ -222,13 +222,13 @@ func CallResponseParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffe return nil, errors.Wrap(pullErr, "Error pulling for results") } // Count array - results := make([]ExtensionObjectDefinition, noOfResults) + results := make([]ExtensionObjectDefinition, utils.Max(noOfResults, 0)) // This happens when the size is set conditional to 0 if len(results) == 0 { results = nil } { - _numItems := uint16(noOfResults) + _numItems := uint16(utils.Max(noOfResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func CallResponseParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffe return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/ContentFilter.go b/plc4go/protocols/opcua/readwrite/model/ContentFilter.go index 9cfd9924804..4bc69f3b9c5 100644 --- a/plc4go/protocols/opcua/readwrite/model/ContentFilter.go +++ b/plc4go/protocols/opcua/readwrite/model/ContentFilter.go @@ -169,13 +169,13 @@ func ContentFilterParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuff return nil, errors.Wrap(pullErr, "Error pulling for elements") } // Count array - elements := make([]ExtensionObjectDefinition, noOfElements) + elements := make([]ExtensionObjectDefinition, utils.Max(noOfElements, 0)) // This happens when the size is set conditional to 0 if len(elements) == 0 { elements = nil } { - _numItems := uint16(noOfElements) + _numItems := uint16(utils.Max(noOfElements, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/ContentFilterElement.go b/plc4go/protocols/opcua/readwrite/model/ContentFilterElement.go index caab57db97c..4f0086e2db9 100644 --- a/plc4go/protocols/opcua/readwrite/model/ContentFilterElement.go +++ b/plc4go/protocols/opcua/readwrite/model/ContentFilterElement.go @@ -193,13 +193,13 @@ func ContentFilterElementParseWithBuffer(ctx context.Context, readBuffer utils.R return nil, errors.Wrap(pullErr, "Error pulling for filterOperands") } // Count array - filterOperands := make([]ExtensionObject, noOfFilterOperands) + filterOperands := make([]ExtensionObject, utils.Max(noOfFilterOperands, 0)) // This happens when the size is set conditional to 0 if len(filterOperands) == 0 { filterOperands = nil } { - _numItems := uint16(noOfFilterOperands) + _numItems := uint16(utils.Max(noOfFilterOperands, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/ContentFilterElementResult.go b/plc4go/protocols/opcua/readwrite/model/ContentFilterElementResult.go index b1b7606566b..3c1afbd75b4 100644 --- a/plc4go/protocols/opcua/readwrite/model/ContentFilterElementResult.go +++ b/plc4go/protocols/opcua/readwrite/model/ContentFilterElementResult.go @@ -222,13 +222,13 @@ func ContentFilterElementResultParseWithBuffer(ctx context.Context, readBuffer u return nil, errors.Wrap(pullErr, "Error pulling for operandStatusCodes") } // Count array - operandStatusCodes := make([]StatusCode, noOfOperandStatusCodes) + operandStatusCodes := make([]StatusCode, utils.Max(noOfOperandStatusCodes, 0)) // This happens when the size is set conditional to 0 if len(operandStatusCodes) == 0 { operandStatusCodes = nil } { - _numItems := uint16(noOfOperandStatusCodes) + _numItems := uint16(utils.Max(noOfOperandStatusCodes, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func ContentFilterElementResultParseWithBuffer(ctx context.Context, readBuffer u return nil, errors.Wrap(pullErr, "Error pulling for operandDiagnosticInfos") } // Count array - operandDiagnosticInfos := make([]DiagnosticInfo, noOfOperandDiagnosticInfos) + operandDiagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfOperandDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(operandDiagnosticInfos) == 0 { operandDiagnosticInfos = nil } { - _numItems := uint16(noOfOperandDiagnosticInfos) + _numItems := uint16(utils.Max(noOfOperandDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/ContentFilterResult.go b/plc4go/protocols/opcua/readwrite/model/ContentFilterResult.go index 64b57608bb4..fb2b9517ad9 100644 --- a/plc4go/protocols/opcua/readwrite/model/ContentFilterResult.go +++ b/plc4go/protocols/opcua/readwrite/model/ContentFilterResult.go @@ -198,13 +198,13 @@ func ContentFilterResultParseWithBuffer(ctx context.Context, readBuffer utils.Re return nil, errors.Wrap(pullErr, "Error pulling for elementResults") } // Count array - elementResults := make([]ExtensionObjectDefinition, noOfElementResults) + elementResults := make([]ExtensionObjectDefinition, utils.Max(noOfElementResults, 0)) // This happens when the size is set conditional to 0 if len(elementResults) == 0 { elementResults = nil } { - _numItems := uint16(noOfElementResults) + _numItems := uint16(utils.Max(noOfElementResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -232,13 +232,13 @@ func ContentFilterResultParseWithBuffer(ctx context.Context, readBuffer utils.Re return nil, errors.Wrap(pullErr, "Error pulling for elementDiagnosticInfos") } // Count array - elementDiagnosticInfos := make([]DiagnosticInfo, noOfElementDiagnosticInfos) + elementDiagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfElementDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(elementDiagnosticInfos) == 0 { elementDiagnosticInfos = nil } { - _numItems := uint16(noOfElementDiagnosticInfos) + _numItems := uint16(utils.Max(noOfElementDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/CreateMonitoredItemsRequest.go b/plc4go/protocols/opcua/readwrite/model/CreateMonitoredItemsRequest.go index dd60f70f203..d7c47562fde 100644 --- a/plc4go/protocols/opcua/readwrite/model/CreateMonitoredItemsRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/CreateMonitoredItemsRequest.go @@ -235,13 +235,13 @@ func CreateMonitoredItemsRequestParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for itemsToCreate") } // Count array - itemsToCreate := make([]ExtensionObjectDefinition, noOfItemsToCreate) + itemsToCreate := make([]ExtensionObjectDefinition, utils.Max(noOfItemsToCreate, 0)) // This happens when the size is set conditional to 0 if len(itemsToCreate) == 0 { itemsToCreate = nil } { - _numItems := uint16(noOfItemsToCreate) + _numItems := uint16(utils.Max(noOfItemsToCreate, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/CreateMonitoredItemsResponse.go b/plc4go/protocols/opcua/readwrite/model/CreateMonitoredItemsResponse.go index cdff7c23167..2ce76ee6729 100644 --- a/plc4go/protocols/opcua/readwrite/model/CreateMonitoredItemsResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/CreateMonitoredItemsResponse.go @@ -222,13 +222,13 @@ func CreateMonitoredItemsResponseParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for results") } // Count array - results := make([]ExtensionObjectDefinition, noOfResults) + results := make([]ExtensionObjectDefinition, utils.Max(noOfResults, 0)) // This happens when the size is set conditional to 0 if len(results) == 0 { results = nil } { - _numItems := uint16(noOfResults) + _numItems := uint16(utils.Max(noOfResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func CreateMonitoredItemsResponseParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/CreateSessionResponse.go b/plc4go/protocols/opcua/readwrite/model/CreateSessionResponse.go index b922606f424..2a8660c347e 100644 --- a/plc4go/protocols/opcua/readwrite/model/CreateSessionResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/CreateSessionResponse.go @@ -358,13 +358,13 @@ func CreateSessionResponseParseWithBuffer(ctx context.Context, readBuffer utils. return nil, errors.Wrap(pullErr, "Error pulling for serverEndpoints") } // Count array - serverEndpoints := make([]ExtensionObjectDefinition, noOfServerEndpoints) + serverEndpoints := make([]ExtensionObjectDefinition, utils.Max(noOfServerEndpoints, 0)) // This happens when the size is set conditional to 0 if len(serverEndpoints) == 0 { serverEndpoints = nil } { - _numItems := uint16(noOfServerEndpoints) + _numItems := uint16(utils.Max(noOfServerEndpoints, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -392,13 +392,13 @@ func CreateSessionResponseParseWithBuffer(ctx context.Context, readBuffer utils. return nil, errors.Wrap(pullErr, "Error pulling for serverSoftwareCertificates") } // Count array - serverSoftwareCertificates := make([]ExtensionObjectDefinition, noOfServerSoftwareCertificates) + serverSoftwareCertificates := make([]ExtensionObjectDefinition, utils.Max(noOfServerSoftwareCertificates, 0)) // This happens when the size is set conditional to 0 if len(serverSoftwareCertificates) == 0 { serverSoftwareCertificates = nil } { - _numItems := uint16(noOfServerSoftwareCertificates) + _numItems := uint16(utils.Max(noOfServerSoftwareCertificates, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/DataChangeNotification.go b/plc4go/protocols/opcua/readwrite/model/DataChangeNotification.go index bc844fec6b4..1d063a12c17 100644 --- a/plc4go/protocols/opcua/readwrite/model/DataChangeNotification.go +++ b/plc4go/protocols/opcua/readwrite/model/DataChangeNotification.go @@ -208,13 +208,13 @@ func DataChangeNotificationParseWithBuffer(ctx context.Context, readBuffer utils return nil, errors.Wrap(pullErr, "Error pulling for monitoredItems") } // Count array - monitoredItems := make([]ExtensionObjectDefinition, noOfMonitoredItems) + monitoredItems := make([]ExtensionObjectDefinition, utils.Max(noOfMonitoredItems, 0)) // This happens when the size is set conditional to 0 if len(monitoredItems) == 0 { monitoredItems = nil } { - _numItems := uint16(noOfMonitoredItems) + _numItems := uint16(utils.Max(noOfMonitoredItems, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -242,13 +242,13 @@ func DataChangeNotificationParseWithBuffer(ctx context.Context, readBuffer utils return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/DataSetWriterDataType.go b/plc4go/protocols/opcua/readwrite/model/DataSetWriterDataType.go index b744bdc19b1..286d6211f09 100644 --- a/plc4go/protocols/opcua/readwrite/model/DataSetWriterDataType.go +++ b/plc4go/protocols/opcua/readwrite/model/DataSetWriterDataType.go @@ -339,13 +339,13 @@ func DataSetWriterDataTypeParseWithBuffer(ctx context.Context, readBuffer utils. return nil, errors.Wrap(pullErr, "Error pulling for dataSetWriterProperties") } // Count array - dataSetWriterProperties := make([]ExtensionObjectDefinition, noOfDataSetWriterProperties) + dataSetWriterProperties := make([]ExtensionObjectDefinition, utils.Max(noOfDataSetWriterProperties, 0)) // This happens when the size is set conditional to 0 if len(dataSetWriterProperties) == 0 { dataSetWriterProperties = nil } { - _numItems := uint16(noOfDataSetWriterProperties) + _numItems := uint16(utils.Max(noOfDataSetWriterProperties, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/DataTypeSchemaHeader.go b/plc4go/protocols/opcua/readwrite/model/DataTypeSchemaHeader.go index 8c1f841a836..0dd50124707 100644 --- a/plc4go/protocols/opcua/readwrite/model/DataTypeSchemaHeader.go +++ b/plc4go/protocols/opcua/readwrite/model/DataTypeSchemaHeader.go @@ -256,13 +256,13 @@ func DataTypeSchemaHeaderParseWithBuffer(ctx context.Context, readBuffer utils.R return nil, errors.Wrap(pullErr, "Error pulling for namespaces") } // Count array - namespaces := make([]PascalString, noOfNamespaces) + namespaces := make([]PascalString, utils.Max(noOfNamespaces, 0)) // This happens when the size is set conditional to 0 if len(namespaces) == 0 { namespaces = nil } { - _numItems := uint16(noOfNamespaces) + _numItems := uint16(utils.Max(noOfNamespaces, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -290,13 +290,13 @@ func DataTypeSchemaHeaderParseWithBuffer(ctx context.Context, readBuffer utils.R return nil, errors.Wrap(pullErr, "Error pulling for structureDataTypes") } // Count array - structureDataTypes := make([]DataTypeDescription, noOfStructureDataTypes) + structureDataTypes := make([]DataTypeDescription, utils.Max(noOfStructureDataTypes, 0)) // This happens when the size is set conditional to 0 if len(structureDataTypes) == 0 { structureDataTypes = nil } { - _numItems := uint16(noOfStructureDataTypes) + _numItems := uint16(utils.Max(noOfStructureDataTypes, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -324,13 +324,13 @@ func DataTypeSchemaHeaderParseWithBuffer(ctx context.Context, readBuffer utils.R return nil, errors.Wrap(pullErr, "Error pulling for enumDataTypes") } // Count array - enumDataTypes := make([]DataTypeDescription, noOfEnumDataTypes) + enumDataTypes := make([]DataTypeDescription, utils.Max(noOfEnumDataTypes, 0)) // This happens when the size is set conditional to 0 if len(enumDataTypes) == 0 { enumDataTypes = nil } { - _numItems := uint16(noOfEnumDataTypes) + _numItems := uint16(utils.Max(noOfEnumDataTypes, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -358,13 +358,13 @@ func DataTypeSchemaHeaderParseWithBuffer(ctx context.Context, readBuffer utils.R return nil, errors.Wrap(pullErr, "Error pulling for simpleDataTypes") } // Count array - simpleDataTypes := make([]DataTypeDescription, noOfSimpleDataTypes) + simpleDataTypes := make([]DataTypeDescription, utils.Max(noOfSimpleDataTypes, 0)) // This happens when the size is set conditional to 0 if len(simpleDataTypes) == 0 { simpleDataTypes = nil } { - _numItems := uint16(noOfSimpleDataTypes) + _numItems := uint16(utils.Max(noOfSimpleDataTypes, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/DeleteMonitoredItemsRequest.go b/plc4go/protocols/opcua/readwrite/model/DeleteMonitoredItemsRequest.go index 723d4ed226a..5a85760499d 100644 --- a/plc4go/protocols/opcua/readwrite/model/DeleteMonitoredItemsRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/DeleteMonitoredItemsRequest.go @@ -206,13 +206,13 @@ func DeleteMonitoredItemsRequestParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for monitoredItemIds") } // Count array - monitoredItemIds := make([]uint32, noOfMonitoredItemIds) + monitoredItemIds := make([]uint32, utils.Max(noOfMonitoredItemIds, 0)) // This happens when the size is set conditional to 0 if len(monitoredItemIds) == 0 { monitoredItemIds = nil } { - _numItems := uint16(noOfMonitoredItemIds) + _numItems := uint16(utils.Max(noOfMonitoredItemIds, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/DeleteMonitoredItemsResponse.go b/plc4go/protocols/opcua/readwrite/model/DeleteMonitoredItemsResponse.go index ddb6bddf5ab..159f2c786d8 100644 --- a/plc4go/protocols/opcua/readwrite/model/DeleteMonitoredItemsResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/DeleteMonitoredItemsResponse.go @@ -222,13 +222,13 @@ func DeleteMonitoredItemsResponseParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for results") } // Count array - results := make([]StatusCode, noOfResults) + results := make([]StatusCode, utils.Max(noOfResults, 0)) // This happens when the size is set conditional to 0 if len(results) == 0 { results = nil } { - _numItems := uint16(noOfResults) + _numItems := uint16(utils.Max(noOfResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func DeleteMonitoredItemsResponseParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/DeleteNodesRequest.go b/plc4go/protocols/opcua/readwrite/model/DeleteNodesRequest.go index 104e092e86a..d512f526e71 100644 --- a/plc4go/protocols/opcua/readwrite/model/DeleteNodesRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/DeleteNodesRequest.go @@ -193,13 +193,13 @@ func DeleteNodesRequestParseWithBuffer(ctx context.Context, readBuffer utils.Rea return nil, errors.Wrap(pullErr, "Error pulling for nodesToDelete") } // Count array - nodesToDelete := make([]ExtensionObjectDefinition, noOfNodesToDelete) + nodesToDelete := make([]ExtensionObjectDefinition, utils.Max(noOfNodesToDelete, 0)) // This happens when the size is set conditional to 0 if len(nodesToDelete) == 0 { nodesToDelete = nil } { - _numItems := uint16(noOfNodesToDelete) + _numItems := uint16(utils.Max(noOfNodesToDelete, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/DeleteNodesResponse.go b/plc4go/protocols/opcua/readwrite/model/DeleteNodesResponse.go index b186f9a4008..d45c11ab9c8 100644 --- a/plc4go/protocols/opcua/readwrite/model/DeleteNodesResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/DeleteNodesResponse.go @@ -222,13 +222,13 @@ func DeleteNodesResponseParseWithBuffer(ctx context.Context, readBuffer utils.Re return nil, errors.Wrap(pullErr, "Error pulling for results") } // Count array - results := make([]StatusCode, noOfResults) + results := make([]StatusCode, utils.Max(noOfResults, 0)) // This happens when the size is set conditional to 0 if len(results) == 0 { results = nil } { - _numItems := uint16(noOfResults) + _numItems := uint16(utils.Max(noOfResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func DeleteNodesResponseParseWithBuffer(ctx context.Context, readBuffer utils.Re return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/DeleteReferencesRequest.go b/plc4go/protocols/opcua/readwrite/model/DeleteReferencesRequest.go index b557ea38ac5..e412827029c 100644 --- a/plc4go/protocols/opcua/readwrite/model/DeleteReferencesRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/DeleteReferencesRequest.go @@ -193,13 +193,13 @@ func DeleteReferencesRequestParseWithBuffer(ctx context.Context, readBuffer util return nil, errors.Wrap(pullErr, "Error pulling for referencesToDelete") } // Count array - referencesToDelete := make([]ExtensionObjectDefinition, noOfReferencesToDelete) + referencesToDelete := make([]ExtensionObjectDefinition, utils.Max(noOfReferencesToDelete, 0)) // This happens when the size is set conditional to 0 if len(referencesToDelete) == 0 { referencesToDelete = nil } { - _numItems := uint16(noOfReferencesToDelete) + _numItems := uint16(utils.Max(noOfReferencesToDelete, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/DeleteReferencesResponse.go b/plc4go/protocols/opcua/readwrite/model/DeleteReferencesResponse.go index 312faa0cdbb..e794895df07 100644 --- a/plc4go/protocols/opcua/readwrite/model/DeleteReferencesResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/DeleteReferencesResponse.go @@ -222,13 +222,13 @@ func DeleteReferencesResponseParseWithBuffer(ctx context.Context, readBuffer uti return nil, errors.Wrap(pullErr, "Error pulling for results") } // Count array - results := make([]StatusCode, noOfResults) + results := make([]StatusCode, utils.Max(noOfResults, 0)) // This happens when the size is set conditional to 0 if len(results) == 0 { results = nil } { - _numItems := uint16(noOfResults) + _numItems := uint16(utils.Max(noOfResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func DeleteReferencesResponseParseWithBuffer(ctx context.Context, readBuffer uti return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/DeleteSubscriptionsRequest.go b/plc4go/protocols/opcua/readwrite/model/DeleteSubscriptionsRequest.go index e29f16e68a1..2ba4b704672 100644 --- a/plc4go/protocols/opcua/readwrite/model/DeleteSubscriptionsRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/DeleteSubscriptionsRequest.go @@ -188,13 +188,13 @@ func DeleteSubscriptionsRequestParseWithBuffer(ctx context.Context, readBuffer u return nil, errors.Wrap(pullErr, "Error pulling for subscriptionIds") } // Count array - subscriptionIds := make([]uint32, noOfSubscriptionIds) + subscriptionIds := make([]uint32, utils.Max(noOfSubscriptionIds, 0)) // This happens when the size is set conditional to 0 if len(subscriptionIds) == 0 { subscriptionIds = nil } { - _numItems := uint16(noOfSubscriptionIds) + _numItems := uint16(utils.Max(noOfSubscriptionIds, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/DeleteSubscriptionsResponse.go b/plc4go/protocols/opcua/readwrite/model/DeleteSubscriptionsResponse.go index 5efaa3df673..5d31b185370 100644 --- a/plc4go/protocols/opcua/readwrite/model/DeleteSubscriptionsResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/DeleteSubscriptionsResponse.go @@ -222,13 +222,13 @@ func DeleteSubscriptionsResponseParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for results") } // Count array - results := make([]StatusCode, noOfResults) + results := make([]StatusCode, utils.Max(noOfResults, 0)) // This happens when the size is set conditional to 0 if len(results) == 0 { results = nil } { - _numItems := uint16(noOfResults) + _numItems := uint16(utils.Max(noOfResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func DeleteSubscriptionsResponseParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/EndpointDescription.go b/plc4go/protocols/opcua/readwrite/model/EndpointDescription.go index 4ca612c38f6..764f2a475da 100644 --- a/plc4go/protocols/opcua/readwrite/model/EndpointDescription.go +++ b/plc4go/protocols/opcua/readwrite/model/EndpointDescription.go @@ -311,13 +311,13 @@ func EndpointDescriptionParseWithBuffer(ctx context.Context, readBuffer utils.Re return nil, errors.Wrap(pullErr, "Error pulling for userIdentityTokens") } // Count array - userIdentityTokens := make([]ExtensionObjectDefinition, noOfUserIdentityTokens) + userIdentityTokens := make([]ExtensionObjectDefinition, utils.Max(noOfUserIdentityTokens, 0)) // This happens when the size is set conditional to 0 if len(userIdentityTokens) == 0 { userIdentityTokens = nil } { - _numItems := uint16(noOfUserIdentityTokens) + _numItems := uint16(utils.Max(noOfUserIdentityTokens, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/EndpointUrlListDataType.go b/plc4go/protocols/opcua/readwrite/model/EndpointUrlListDataType.go index 4daae14dd2d..4dcaaca0d7e 100644 --- a/plc4go/protocols/opcua/readwrite/model/EndpointUrlListDataType.go +++ b/plc4go/protocols/opcua/readwrite/model/EndpointUrlListDataType.go @@ -169,13 +169,13 @@ func EndpointUrlListDataTypeParseWithBuffer(ctx context.Context, readBuffer util return nil, errors.Wrap(pullErr, "Error pulling for endpointUrlList") } // Count array - endpointUrlList := make([]PascalString, noOfEndpointUrlList) + endpointUrlList := make([]PascalString, utils.Max(noOfEndpointUrlList, 0)) // This happens when the size is set conditional to 0 if len(endpointUrlList) == 0 { endpointUrlList = nil } { - _numItems := uint16(noOfEndpointUrlList) + _numItems := uint16(utils.Max(noOfEndpointUrlList, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/EventFieldList.go b/plc4go/protocols/opcua/readwrite/model/EventFieldList.go index f2fc7d40970..574f0ecadd5 100644 --- a/plc4go/protocols/opcua/readwrite/model/EventFieldList.go +++ b/plc4go/protocols/opcua/readwrite/model/EventFieldList.go @@ -187,13 +187,13 @@ func EventFieldListParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuf return nil, errors.Wrap(pullErr, "Error pulling for eventFields") } // Count array - eventFields := make([]Variant, noOfEventFields) + eventFields := make([]Variant, utils.Max(noOfEventFields, 0)) // This happens when the size is set conditional to 0 if len(eventFields) == 0 { eventFields = nil } { - _numItems := uint16(noOfEventFields) + _numItems := uint16(utils.Max(noOfEventFields, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/EventNotificationList.go b/plc4go/protocols/opcua/readwrite/model/EventNotificationList.go index 0eb97cdd436..277ee8715de 100644 --- a/plc4go/protocols/opcua/readwrite/model/EventNotificationList.go +++ b/plc4go/protocols/opcua/readwrite/model/EventNotificationList.go @@ -179,13 +179,13 @@ func EventNotificationListParseWithBuffer(ctx context.Context, readBuffer utils. return nil, errors.Wrap(pullErr, "Error pulling for events") } // Count array - events := make([]ExtensionObjectDefinition, noOfEvents) + events := make([]ExtensionObjectDefinition, utils.Max(noOfEvents, 0)) // This happens when the size is set conditional to 0 if len(events) == 0 { events = nil } { - _numItems := uint16(noOfEvents) + _numItems := uint16(utils.Max(noOfEvents, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/FieldMetaData.go b/plc4go/protocols/opcua/readwrite/model/FieldMetaData.go index 37e713e4976..123f9b97958 100644 --- a/plc4go/protocols/opcua/readwrite/model/FieldMetaData.go +++ b/plc4go/protocols/opcua/readwrite/model/FieldMetaData.go @@ -347,13 +347,13 @@ func FieldMetaDataParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuff return nil, errors.Wrap(pullErr, "Error pulling for arrayDimensions") } // Count array - arrayDimensions := make([]uint32, noOfArrayDimensions) + arrayDimensions := make([]uint32, utils.Max(noOfArrayDimensions, 0)) // This happens when the size is set conditional to 0 if len(arrayDimensions) == 0 { arrayDimensions = nil } { - _numItems := uint16(noOfArrayDimensions) + _numItems := uint16(utils.Max(noOfArrayDimensions, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -401,13 +401,13 @@ func FieldMetaDataParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuff return nil, errors.Wrap(pullErr, "Error pulling for properties") } // Count array - properties := make([]ExtensionObjectDefinition, noOfProperties) + properties := make([]ExtensionObjectDefinition, utils.Max(noOfProperties, 0)) // This happens when the size is set conditional to 0 if len(properties) == 0 { properties = nil } { - _numItems := uint16(noOfProperties) + _numItems := uint16(utils.Max(noOfProperties, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/FindServersOnNetworkRequest.go b/plc4go/protocols/opcua/readwrite/model/FindServersOnNetworkRequest.go index 2c82e1c088d..538123e62d8 100644 --- a/plc4go/protocols/opcua/readwrite/model/FindServersOnNetworkRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/FindServersOnNetworkRequest.go @@ -229,13 +229,13 @@ func FindServersOnNetworkRequestParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for serverCapabilityFilter") } // Count array - serverCapabilityFilter := make([]PascalString, noOfServerCapabilityFilter) + serverCapabilityFilter := make([]PascalString, utils.Max(noOfServerCapabilityFilter, 0)) // This happens when the size is set conditional to 0 if len(serverCapabilityFilter) == 0 { serverCapabilityFilter = nil } { - _numItems := uint16(noOfServerCapabilityFilter) + _numItems := uint16(utils.Max(noOfServerCapabilityFilter, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/FindServersOnNetworkResponse.go b/plc4go/protocols/opcua/readwrite/model/FindServersOnNetworkResponse.go index 651be68b39c..9be489ed092 100644 --- a/plc4go/protocols/opcua/readwrite/model/FindServersOnNetworkResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/FindServersOnNetworkResponse.go @@ -211,13 +211,13 @@ func FindServersOnNetworkResponseParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for servers") } // Count array - servers := make([]ExtensionObjectDefinition, noOfServers) + servers := make([]ExtensionObjectDefinition, utils.Max(noOfServers, 0)) // This happens when the size is set conditional to 0 if len(servers) == 0 { servers = nil } { - _numItems := uint16(noOfServers) + _numItems := uint16(utils.Max(noOfServers, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/FindServersRequest.go b/plc4go/protocols/opcua/readwrite/model/FindServersRequest.go index b093128e259..59ba645d03f 100644 --- a/plc4go/protocols/opcua/readwrite/model/FindServersRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/FindServersRequest.go @@ -246,13 +246,13 @@ func FindServersRequestParseWithBuffer(ctx context.Context, readBuffer utils.Rea return nil, errors.Wrap(pullErr, "Error pulling for localeIds") } // Count array - localeIds := make([]PascalString, noOfLocaleIds) + localeIds := make([]PascalString, utils.Max(noOfLocaleIds, 0)) // This happens when the size is set conditional to 0 if len(localeIds) == 0 { localeIds = nil } { - _numItems := uint16(noOfLocaleIds) + _numItems := uint16(utils.Max(noOfLocaleIds, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -280,13 +280,13 @@ func FindServersRequestParseWithBuffer(ctx context.Context, readBuffer utils.Rea return nil, errors.Wrap(pullErr, "Error pulling for serverUris") } // Count array - serverUris := make([]PascalString, noOfServerUris) + serverUris := make([]PascalString, utils.Max(noOfServerUris, 0)) // This happens when the size is set conditional to 0 if len(serverUris) == 0 { serverUris = nil } { - _numItems := uint16(noOfServerUris) + _numItems := uint16(utils.Max(noOfServerUris, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/FindServersResponse.go b/plc4go/protocols/opcua/readwrite/model/FindServersResponse.go index 3bcdf39397a..ad028dab3b2 100644 --- a/plc4go/protocols/opcua/readwrite/model/FindServersResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/FindServersResponse.go @@ -193,13 +193,13 @@ func FindServersResponseParseWithBuffer(ctx context.Context, readBuffer utils.Re return nil, errors.Wrap(pullErr, "Error pulling for servers") } // Count array - servers := make([]ExtensionObjectDefinition, noOfServers) + servers := make([]ExtensionObjectDefinition, utils.Max(noOfServers, 0)) // This happens when the size is set conditional to 0 if len(servers) == 0 { servers = nil } { - _numItems := uint16(noOfServers) + _numItems := uint16(utils.Max(noOfServers, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/GetEndpointsRequest.go b/plc4go/protocols/opcua/readwrite/model/GetEndpointsRequest.go index 4a1f4feda4a..333f2d5eb1e 100644 --- a/plc4go/protocols/opcua/readwrite/model/GetEndpointsRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/GetEndpointsRequest.go @@ -246,13 +246,13 @@ func GetEndpointsRequestParseWithBuffer(ctx context.Context, readBuffer utils.Re return nil, errors.Wrap(pullErr, "Error pulling for localeIds") } // Count array - localeIds := make([]PascalString, noOfLocaleIds) + localeIds := make([]PascalString, utils.Max(noOfLocaleIds, 0)) // This happens when the size is set conditional to 0 if len(localeIds) == 0 { localeIds = nil } { - _numItems := uint16(noOfLocaleIds) + _numItems := uint16(utils.Max(noOfLocaleIds, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -280,13 +280,13 @@ func GetEndpointsRequestParseWithBuffer(ctx context.Context, readBuffer utils.Re return nil, errors.Wrap(pullErr, "Error pulling for profileUris") } // Count array - profileUris := make([]PascalString, noOfProfileUris) + profileUris := make([]PascalString, utils.Max(noOfProfileUris, 0)) // This happens when the size is set conditional to 0 if len(profileUris) == 0 { profileUris = nil } { - _numItems := uint16(noOfProfileUris) + _numItems := uint16(utils.Max(noOfProfileUris, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/GetEndpointsResponse.go b/plc4go/protocols/opcua/readwrite/model/GetEndpointsResponse.go index 7dd76073b7f..fa172ae1421 100644 --- a/plc4go/protocols/opcua/readwrite/model/GetEndpointsResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/GetEndpointsResponse.go @@ -193,13 +193,13 @@ func GetEndpointsResponseParseWithBuffer(ctx context.Context, readBuffer utils.R return nil, errors.Wrap(pullErr, "Error pulling for endpoints") } // Count array - endpoints := make([]ExtensionObjectDefinition, noOfEndpoints) + endpoints := make([]ExtensionObjectDefinition, utils.Max(noOfEndpoints, 0)) // This happens when the size is set conditional to 0 if len(endpoints) == 0 { endpoints = nil } { - _numItems := uint16(noOfEndpoints) + _numItems := uint16(utils.Max(noOfEndpoints, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/HistoryData.go b/plc4go/protocols/opcua/readwrite/model/HistoryData.go index 5c708afbbd7..91bcc513eb1 100644 --- a/plc4go/protocols/opcua/readwrite/model/HistoryData.go +++ b/plc4go/protocols/opcua/readwrite/model/HistoryData.go @@ -169,13 +169,13 @@ func HistoryDataParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer return nil, errors.Wrap(pullErr, "Error pulling for dataValues") } // Count array - dataValues := make([]DataValue, noOfDataValues) + dataValues := make([]DataValue, utils.Max(noOfDataValues, 0)) // This happens when the size is set conditional to 0 if len(dataValues) == 0 { dataValues = nil } { - _numItems := uint16(noOfDataValues) + _numItems := uint16(utils.Max(noOfDataValues, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/HistoryEvent.go b/plc4go/protocols/opcua/readwrite/model/HistoryEvent.go index c8d47d66d32..35bdc10594c 100644 --- a/plc4go/protocols/opcua/readwrite/model/HistoryEvent.go +++ b/plc4go/protocols/opcua/readwrite/model/HistoryEvent.go @@ -169,13 +169,13 @@ func HistoryEventParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffe return nil, errors.Wrap(pullErr, "Error pulling for events") } // Count array - events := make([]ExtensionObjectDefinition, noOfEvents) + events := make([]ExtensionObjectDefinition, utils.Max(noOfEvents, 0)) // This happens when the size is set conditional to 0 if len(events) == 0 { events = nil } { - _numItems := uint16(noOfEvents) + _numItems := uint16(utils.Max(noOfEvents, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/HistoryEventFieldList.go b/plc4go/protocols/opcua/readwrite/model/HistoryEventFieldList.go index 36b1924f1ec..e1dfaafbfcc 100644 --- a/plc4go/protocols/opcua/readwrite/model/HistoryEventFieldList.go +++ b/plc4go/protocols/opcua/readwrite/model/HistoryEventFieldList.go @@ -169,13 +169,13 @@ func HistoryEventFieldListParseWithBuffer(ctx context.Context, readBuffer utils. return nil, errors.Wrap(pullErr, "Error pulling for eventFields") } // Count array - eventFields := make([]Variant, noOfEventFields) + eventFields := make([]Variant, utils.Max(noOfEventFields, 0)) // This happens when the size is set conditional to 0 if len(eventFields) == 0 { eventFields = nil } { - _numItems := uint16(noOfEventFields) + _numItems := uint16(utils.Max(noOfEventFields, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/HistoryReadRequest.go b/plc4go/protocols/opcua/readwrite/model/HistoryReadRequest.go index 3c28d544fa5..5e855dde8f0 100644 --- a/plc4go/protocols/opcua/readwrite/model/HistoryReadRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/HistoryReadRequest.go @@ -281,13 +281,13 @@ func HistoryReadRequestParseWithBuffer(ctx context.Context, readBuffer utils.Rea return nil, errors.Wrap(pullErr, "Error pulling for nodesToRead") } // Count array - nodesToRead := make([]ExtensionObjectDefinition, noOfNodesToRead) + nodesToRead := make([]ExtensionObjectDefinition, utils.Max(noOfNodesToRead, 0)) // This happens when the size is set conditional to 0 if len(nodesToRead) == 0 { nodesToRead = nil } { - _numItems := uint16(noOfNodesToRead) + _numItems := uint16(utils.Max(noOfNodesToRead, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/HistoryReadResponse.go b/plc4go/protocols/opcua/readwrite/model/HistoryReadResponse.go index 70bc68c5763..86a16ece02f 100644 --- a/plc4go/protocols/opcua/readwrite/model/HistoryReadResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/HistoryReadResponse.go @@ -222,13 +222,13 @@ func HistoryReadResponseParseWithBuffer(ctx context.Context, readBuffer utils.Re return nil, errors.Wrap(pullErr, "Error pulling for results") } // Count array - results := make([]ExtensionObjectDefinition, noOfResults) + results := make([]ExtensionObjectDefinition, utils.Max(noOfResults, 0)) // This happens when the size is set conditional to 0 if len(results) == 0 { results = nil } { - _numItems := uint16(noOfResults) + _numItems := uint16(utils.Max(noOfResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func HistoryReadResponseParseWithBuffer(ctx context.Context, readBuffer utils.Re return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/HistoryUpdateRequest.go b/plc4go/protocols/opcua/readwrite/model/HistoryUpdateRequest.go index e7a7e27c01c..96957b24d0b 100644 --- a/plc4go/protocols/opcua/readwrite/model/HistoryUpdateRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/HistoryUpdateRequest.go @@ -193,13 +193,13 @@ func HistoryUpdateRequestParseWithBuffer(ctx context.Context, readBuffer utils.R return nil, errors.Wrap(pullErr, "Error pulling for historyUpdateDetails") } // Count array - historyUpdateDetails := make([]ExtensionObject, noOfHistoryUpdateDetails) + historyUpdateDetails := make([]ExtensionObject, utils.Max(noOfHistoryUpdateDetails, 0)) // This happens when the size is set conditional to 0 if len(historyUpdateDetails) == 0 { historyUpdateDetails = nil } { - _numItems := uint16(noOfHistoryUpdateDetails) + _numItems := uint16(utils.Max(noOfHistoryUpdateDetails, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/HistoryUpdateResponse.go b/plc4go/protocols/opcua/readwrite/model/HistoryUpdateResponse.go index f99e2aa3cb3..2bbb5d87b6f 100644 --- a/plc4go/protocols/opcua/readwrite/model/HistoryUpdateResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/HistoryUpdateResponse.go @@ -222,13 +222,13 @@ func HistoryUpdateResponseParseWithBuffer(ctx context.Context, readBuffer utils. return nil, errors.Wrap(pullErr, "Error pulling for results") } // Count array - results := make([]ExtensionObjectDefinition, noOfResults) + results := make([]ExtensionObjectDefinition, utils.Max(noOfResults, 0)) // This happens when the size is set conditional to 0 if len(results) == 0 { results = nil } { - _numItems := uint16(noOfResults) + _numItems := uint16(utils.Max(noOfResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func HistoryUpdateResponseParseWithBuffer(ctx context.Context, readBuffer utils. return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/HistoryUpdateResult.go b/plc4go/protocols/opcua/readwrite/model/HistoryUpdateResult.go index 2aa471f9056..3d97d343bc8 100644 --- a/plc4go/protocols/opcua/readwrite/model/HistoryUpdateResult.go +++ b/plc4go/protocols/opcua/readwrite/model/HistoryUpdateResult.go @@ -222,13 +222,13 @@ func HistoryUpdateResultParseWithBuffer(ctx context.Context, readBuffer utils.Re return nil, errors.Wrap(pullErr, "Error pulling for operationResults") } // Count array - operationResults := make([]StatusCode, noOfOperationResults) + operationResults := make([]StatusCode, utils.Max(noOfOperationResults, 0)) // This happens when the size is set conditional to 0 if len(operationResults) == 0 { operationResults = nil } { - _numItems := uint16(noOfOperationResults) + _numItems := uint16(utils.Max(noOfOperationResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func HistoryUpdateResultParseWithBuffer(ctx context.Context, readBuffer utils.Re return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/ModifyMonitoredItemsRequest.go b/plc4go/protocols/opcua/readwrite/model/ModifyMonitoredItemsRequest.go index dc12a2856b6..197783ef252 100644 --- a/plc4go/protocols/opcua/readwrite/model/ModifyMonitoredItemsRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/ModifyMonitoredItemsRequest.go @@ -235,13 +235,13 @@ func ModifyMonitoredItemsRequestParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for itemsToModify") } // Count array - itemsToModify := make([]ExtensionObjectDefinition, noOfItemsToModify) + itemsToModify := make([]ExtensionObjectDefinition, utils.Max(noOfItemsToModify, 0)) // This happens when the size is set conditional to 0 if len(itemsToModify) == 0 { itemsToModify = nil } { - _numItems := uint16(noOfItemsToModify) + _numItems := uint16(utils.Max(noOfItemsToModify, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/ModifyMonitoredItemsResponse.go b/plc4go/protocols/opcua/readwrite/model/ModifyMonitoredItemsResponse.go index c6eaa21ffad..59ffaea8d6d 100644 --- a/plc4go/protocols/opcua/readwrite/model/ModifyMonitoredItemsResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/ModifyMonitoredItemsResponse.go @@ -222,13 +222,13 @@ func ModifyMonitoredItemsResponseParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for results") } // Count array - results := make([]ExtensionObjectDefinition, noOfResults) + results := make([]ExtensionObjectDefinition, utils.Max(noOfResults, 0)) // This happens when the size is set conditional to 0 if len(results) == 0 { results = nil } { - _numItems := uint16(noOfResults) + _numItems := uint16(utils.Max(noOfResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func ModifyMonitoredItemsResponseParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/NetworkGroupDataType.go b/plc4go/protocols/opcua/readwrite/model/NetworkGroupDataType.go index f932fb514f9..bff4ec8af17 100644 --- a/plc4go/protocols/opcua/readwrite/model/NetworkGroupDataType.go +++ b/plc4go/protocols/opcua/readwrite/model/NetworkGroupDataType.go @@ -193,13 +193,13 @@ func NetworkGroupDataTypeParseWithBuffer(ctx context.Context, readBuffer utils.R return nil, errors.Wrap(pullErr, "Error pulling for networkPaths") } // Count array - networkPaths := make([]ExtensionObjectDefinition, noOfNetworkPaths) + networkPaths := make([]ExtensionObjectDefinition, utils.Max(noOfNetworkPaths, 0)) // This happens when the size is set conditional to 0 if len(networkPaths) == 0 { networkPaths = nil } { - _numItems := uint16(noOfNetworkPaths) + _numItems := uint16(utils.Max(noOfNetworkPaths, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/Node.go b/plc4go/protocols/opcua/readwrite/model/Node.go index 4587643e09a..9f8ca446f23 100644 --- a/plc4go/protocols/opcua/readwrite/model/Node.go +++ b/plc4go/protocols/opcua/readwrite/model/Node.go @@ -394,13 +394,13 @@ func NodeParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer, ident return nil, errors.Wrap(pullErr, "Error pulling for rolePermissions") } // Count array - rolePermissions := make([]ExtensionObjectDefinition, noOfRolePermissions) + rolePermissions := make([]ExtensionObjectDefinition, utils.Max(noOfRolePermissions, 0)) // This happens when the size is set conditional to 0 if len(rolePermissions) == 0 { rolePermissions = nil } { - _numItems := uint16(noOfRolePermissions) + _numItems := uint16(utils.Max(noOfRolePermissions, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -428,13 +428,13 @@ func NodeParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer, ident return nil, errors.Wrap(pullErr, "Error pulling for userRolePermissions") } // Count array - userRolePermissions := make([]ExtensionObjectDefinition, noOfUserRolePermissions) + userRolePermissions := make([]ExtensionObjectDefinition, utils.Max(noOfUserRolePermissions, 0)) // This happens when the size is set conditional to 0 if len(userRolePermissions) == 0 { userRolePermissions = nil } { - _numItems := uint16(noOfUserRolePermissions) + _numItems := uint16(utils.Max(noOfUserRolePermissions, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -469,13 +469,13 @@ func NodeParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer, ident return nil, errors.Wrap(pullErr, "Error pulling for references") } // Count array - references := make([]ExtensionObjectDefinition, noOfReferences) + references := make([]ExtensionObjectDefinition, utils.Max(noOfReferences, 0)) // This happens when the size is set conditional to 0 if len(references) == 0 { references = nil } { - _numItems := uint16(noOfReferences) + _numItems := uint16(utils.Max(noOfReferences, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/NodeReference.go b/plc4go/protocols/opcua/readwrite/model/NodeReference.go index be48cdc16e8..0f5d8bd2d47 100644 --- a/plc4go/protocols/opcua/readwrite/model/NodeReference.go +++ b/plc4go/protocols/opcua/readwrite/model/NodeReference.go @@ -257,13 +257,13 @@ func NodeReferenceParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuff return nil, errors.Wrap(pullErr, "Error pulling for referencedNodeIds") } // Count array - referencedNodeIds := make([]NodeId, noOfReferencedNodeIds) + referencedNodeIds := make([]NodeId, utils.Max(noOfReferencedNodeIds, 0)) // This happens when the size is set conditional to 0 if len(referencedNodeIds) == 0 { referencedNodeIds = nil } { - _numItems := uint16(noOfReferencedNodeIds) + _numItems := uint16(utils.Max(noOfReferencedNodeIds, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/NodeTypeDescription.go b/plc4go/protocols/opcua/readwrite/model/NodeTypeDescription.go index 6b3965fa712..3da8a211dc8 100644 --- a/plc4go/protocols/opcua/readwrite/model/NodeTypeDescription.go +++ b/plc4go/protocols/opcua/readwrite/model/NodeTypeDescription.go @@ -233,13 +233,13 @@ func NodeTypeDescriptionParseWithBuffer(ctx context.Context, readBuffer utils.Re return nil, errors.Wrap(pullErr, "Error pulling for dataToReturn") } // Count array - dataToReturn := make([]ExtensionObjectDefinition, noOfDataToReturn) + dataToReturn := make([]ExtensionObjectDefinition, utils.Max(noOfDataToReturn, 0)) // This happens when the size is set conditional to 0 if len(dataToReturn) == 0 { dataToReturn = nil } { - _numItems := uint16(noOfDataToReturn) + _numItems := uint16(utils.Max(noOfDataToReturn, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/NotificationMessage.go b/plc4go/protocols/opcua/readwrite/model/NotificationMessage.go index f403d11a18e..d1b37dce022 100644 --- a/plc4go/protocols/opcua/readwrite/model/NotificationMessage.go +++ b/plc4go/protocols/opcua/readwrite/model/NotificationMessage.go @@ -205,13 +205,13 @@ func NotificationMessageParseWithBuffer(ctx context.Context, readBuffer utils.Re return nil, errors.Wrap(pullErr, "Error pulling for notificationData") } // Count array - notificationData := make([]ExtensionObject, noOfNotificationData) + notificationData := make([]ExtensionObject, utils.Max(noOfNotificationData, 0)) // This happens when the size is set conditional to 0 if len(notificationData) == 0 { notificationData = nil } { - _numItems := uint16(noOfNotificationData) + _numItems := uint16(utils.Max(noOfNotificationData, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/ParsingResult.go b/plc4go/protocols/opcua/readwrite/model/ParsingResult.go index b997c4cf998..6e212ce4ab6 100644 --- a/plc4go/protocols/opcua/readwrite/model/ParsingResult.go +++ b/plc4go/protocols/opcua/readwrite/model/ParsingResult.go @@ -222,13 +222,13 @@ func ParsingResultParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuff return nil, errors.Wrap(pullErr, "Error pulling for dataStatusCodes") } // Count array - dataStatusCodes := make([]StatusCode, noOfDataStatusCodes) + dataStatusCodes := make([]StatusCode, utils.Max(noOfDataStatusCodes, 0)) // This happens when the size is set conditional to 0 if len(dataStatusCodes) == 0 { dataStatusCodes = nil } { - _numItems := uint16(noOfDataStatusCodes) + _numItems := uint16(utils.Max(noOfDataStatusCodes, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func ParsingResultParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuff return nil, errors.Wrap(pullErr, "Error pulling for dataDiagnosticInfos") } // Count array - dataDiagnosticInfos := make([]DiagnosticInfo, noOfDataDiagnosticInfos) + dataDiagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDataDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(dataDiagnosticInfos) == 0 { dataDiagnosticInfos = nil } { - _numItems := uint16(noOfDataDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDataDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/ProgramDiagnostic2DataType.go b/plc4go/protocols/opcua/readwrite/model/ProgramDiagnostic2DataType.go index d3561ff7654..e6827395a26 100644 --- a/plc4go/protocols/opcua/readwrite/model/ProgramDiagnostic2DataType.go +++ b/plc4go/protocols/opcua/readwrite/model/ProgramDiagnostic2DataType.go @@ -410,13 +410,13 @@ func ProgramDiagnostic2DataTypeParseWithBuffer(ctx context.Context, readBuffer u return nil, errors.Wrap(pullErr, "Error pulling for lastMethodInputArguments") } // Count array - lastMethodInputArguments := make([]ExtensionObjectDefinition, noOfLastMethodInputArguments) + lastMethodInputArguments := make([]ExtensionObjectDefinition, utils.Max(noOfLastMethodInputArguments, 0)) // This happens when the size is set conditional to 0 if len(lastMethodInputArguments) == 0 { lastMethodInputArguments = nil } { - _numItems := uint16(noOfLastMethodInputArguments) + _numItems := uint16(utils.Max(noOfLastMethodInputArguments, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -444,13 +444,13 @@ func ProgramDiagnostic2DataTypeParseWithBuffer(ctx context.Context, readBuffer u return nil, errors.Wrap(pullErr, "Error pulling for lastMethodOutputArguments") } // Count array - lastMethodOutputArguments := make([]ExtensionObjectDefinition, noOfLastMethodOutputArguments) + lastMethodOutputArguments := make([]ExtensionObjectDefinition, utils.Max(noOfLastMethodOutputArguments, 0)) // This happens when the size is set conditional to 0 if len(lastMethodOutputArguments) == 0 { lastMethodOutputArguments = nil } { - _numItems := uint16(noOfLastMethodOutputArguments) + _numItems := uint16(utils.Max(noOfLastMethodOutputArguments, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -478,13 +478,13 @@ func ProgramDiagnostic2DataTypeParseWithBuffer(ctx context.Context, readBuffer u return nil, errors.Wrap(pullErr, "Error pulling for lastMethodInputValues") } // Count array - lastMethodInputValues := make([]Variant, noOfLastMethodInputValues) + lastMethodInputValues := make([]Variant, utils.Max(noOfLastMethodInputValues, 0)) // This happens when the size is set conditional to 0 if len(lastMethodInputValues) == 0 { lastMethodInputValues = nil } { - _numItems := uint16(noOfLastMethodInputValues) + _numItems := uint16(utils.Max(noOfLastMethodInputValues, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -512,13 +512,13 @@ func ProgramDiagnostic2DataTypeParseWithBuffer(ctx context.Context, readBuffer u return nil, errors.Wrap(pullErr, "Error pulling for lastMethodOutputValues") } // Count array - lastMethodOutputValues := make([]Variant, noOfLastMethodOutputValues) + lastMethodOutputValues := make([]Variant, utils.Max(noOfLastMethodOutputValues, 0)) // This happens when the size is set conditional to 0 if len(lastMethodOutputValues) == 0 { lastMethodOutputValues = nil } { - _numItems := uint16(noOfLastMethodOutputValues) + _numItems := uint16(utils.Max(noOfLastMethodOutputValues, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/ProgramDiagnosticDataType.go b/plc4go/protocols/opcua/readwrite/model/ProgramDiagnosticDataType.go index d96d5224f47..7261c90fed8 100644 --- a/plc4go/protocols/opcua/readwrite/model/ProgramDiagnosticDataType.go +++ b/plc4go/protocols/opcua/readwrite/model/ProgramDiagnosticDataType.go @@ -352,13 +352,13 @@ func ProgramDiagnosticDataTypeParseWithBuffer(ctx context.Context, readBuffer ut return nil, errors.Wrap(pullErr, "Error pulling for lastMethodInputArguments") } // Count array - lastMethodInputArguments := make([]ExtensionObjectDefinition, noOfLastMethodInputArguments) + lastMethodInputArguments := make([]ExtensionObjectDefinition, utils.Max(noOfLastMethodInputArguments, 0)) // This happens when the size is set conditional to 0 if len(lastMethodInputArguments) == 0 { lastMethodInputArguments = nil } { - _numItems := uint16(noOfLastMethodInputArguments) + _numItems := uint16(utils.Max(noOfLastMethodInputArguments, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -386,13 +386,13 @@ func ProgramDiagnosticDataTypeParseWithBuffer(ctx context.Context, readBuffer ut return nil, errors.Wrap(pullErr, "Error pulling for lastMethodOutputArguments") } // Count array - lastMethodOutputArguments := make([]ExtensionObjectDefinition, noOfLastMethodOutputArguments) + lastMethodOutputArguments := make([]ExtensionObjectDefinition, utils.Max(noOfLastMethodOutputArguments, 0)) // This happens when the size is set conditional to 0 if len(lastMethodOutputArguments) == 0 { lastMethodOutputArguments = nil } { - _numItems := uint16(noOfLastMethodOutputArguments) + _numItems := uint16(utils.Max(noOfLastMethodOutputArguments, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/PubSubConfigurationDataType.go b/plc4go/protocols/opcua/readwrite/model/PubSubConfigurationDataType.go index a73f586a9ac..b561e528c7f 100644 --- a/plc4go/protocols/opcua/readwrite/model/PubSubConfigurationDataType.go +++ b/plc4go/protocols/opcua/readwrite/model/PubSubConfigurationDataType.go @@ -214,13 +214,13 @@ func PubSubConfigurationDataTypeParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for publishedDataSets") } // Count array - publishedDataSets := make([]ExtensionObjectDefinition, noOfPublishedDataSets) + publishedDataSets := make([]ExtensionObjectDefinition, utils.Max(noOfPublishedDataSets, 0)) // This happens when the size is set conditional to 0 if len(publishedDataSets) == 0 { publishedDataSets = nil } { - _numItems := uint16(noOfPublishedDataSets) + _numItems := uint16(utils.Max(noOfPublishedDataSets, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -248,13 +248,13 @@ func PubSubConfigurationDataTypeParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for connections") } // Count array - connections := make([]ExtensionObjectDefinition, noOfConnections) + connections := make([]ExtensionObjectDefinition, utils.Max(noOfConnections, 0)) // This happens when the size is set conditional to 0 if len(connections) == 0 { connections = nil } { - _numItems := uint16(noOfConnections) + _numItems := uint16(utils.Max(noOfConnections, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/PubSubConnectionDataType.go b/plc4go/protocols/opcua/readwrite/model/PubSubConnectionDataType.go index 0f7183e448d..fa5c6759a39 100644 --- a/plc4go/protocols/opcua/readwrite/model/PubSubConnectionDataType.go +++ b/plc4go/protocols/opcua/readwrite/model/PubSubConnectionDataType.go @@ -374,13 +374,13 @@ func PubSubConnectionDataTypeParseWithBuffer(ctx context.Context, readBuffer uti return nil, errors.Wrap(pullErr, "Error pulling for connectionProperties") } // Count array - connectionProperties := make([]ExtensionObjectDefinition, noOfConnectionProperties) + connectionProperties := make([]ExtensionObjectDefinition, utils.Max(noOfConnectionProperties, 0)) // This happens when the size is set conditional to 0 if len(connectionProperties) == 0 { connectionProperties = nil } { - _numItems := uint16(noOfConnectionProperties) + _numItems := uint16(utils.Max(noOfConnectionProperties, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -421,13 +421,13 @@ func PubSubConnectionDataTypeParseWithBuffer(ctx context.Context, readBuffer uti return nil, errors.Wrap(pullErr, "Error pulling for writerGroups") } // Count array - writerGroups := make([]PubSubGroupDataType, noOfWriterGroups) + writerGroups := make([]PubSubGroupDataType, utils.Max(noOfWriterGroups, 0)) // This happens when the size is set conditional to 0 if len(writerGroups) == 0 { writerGroups = nil } { - _numItems := uint16(noOfWriterGroups) + _numItems := uint16(utils.Max(noOfWriterGroups, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -455,13 +455,13 @@ func PubSubConnectionDataTypeParseWithBuffer(ctx context.Context, readBuffer uti return nil, errors.Wrap(pullErr, "Error pulling for readerGroups") } // Count array - readerGroups := make([]PubSubGroupDataType, noOfReaderGroups) + readerGroups := make([]PubSubGroupDataType, utils.Max(noOfReaderGroups, 0)) // This happens when the size is set conditional to 0 if len(readerGroups) == 0 { readerGroups = nil } { - _numItems := uint16(noOfReaderGroups) + _numItems := uint16(utils.Max(noOfReaderGroups, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/PubSubGroupDataType.go b/plc4go/protocols/opcua/readwrite/model/PubSubGroupDataType.go index 8f2a3e13404..04e5159e59f 100644 --- a/plc4go/protocols/opcua/readwrite/model/PubSubGroupDataType.go +++ b/plc4go/protocols/opcua/readwrite/model/PubSubGroupDataType.go @@ -321,13 +321,13 @@ func PubSubGroupDataTypeParseWithBuffer(ctx context.Context, readBuffer utils.Re return nil, errors.Wrap(pullErr, "Error pulling for securityKeyServices") } // Count array - securityKeyServices := make([]ExtensionObjectDefinition, noOfSecurityKeyServices) + securityKeyServices := make([]ExtensionObjectDefinition, utils.Max(noOfSecurityKeyServices, 0)) // This happens when the size is set conditional to 0 if len(securityKeyServices) == 0 { securityKeyServices = nil } { - _numItems := uint16(noOfSecurityKeyServices) + _numItems := uint16(utils.Max(noOfSecurityKeyServices, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -362,13 +362,13 @@ func PubSubGroupDataTypeParseWithBuffer(ctx context.Context, readBuffer utils.Re return nil, errors.Wrap(pullErr, "Error pulling for groupProperties") } // Count array - groupProperties := make([]ExtensionObjectDefinition, noOfGroupProperties) + groupProperties := make([]ExtensionObjectDefinition, utils.Max(noOfGroupProperties, 0)) // This happens when the size is set conditional to 0 if len(groupProperties) == 0 { groupProperties = nil } { - _numItems := uint16(noOfGroupProperties) + _numItems := uint16(utils.Max(noOfGroupProperties, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/PublishRequest.go b/plc4go/protocols/opcua/readwrite/model/PublishRequest.go index 2e3844a3c28..eff1162bea0 100644 --- a/plc4go/protocols/opcua/readwrite/model/PublishRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/PublishRequest.go @@ -193,13 +193,13 @@ func PublishRequestParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuf return nil, errors.Wrap(pullErr, "Error pulling for subscriptionAcknowledgements") } // Count array - subscriptionAcknowledgements := make([]ExtensionObjectDefinition, noOfSubscriptionAcknowledgements) + subscriptionAcknowledgements := make([]ExtensionObjectDefinition, utils.Max(noOfSubscriptionAcknowledgements, 0)) // This happens when the size is set conditional to 0 if len(subscriptionAcknowledgements) == 0 { subscriptionAcknowledgements = nil } { - _numItems := uint16(noOfSubscriptionAcknowledgements) + _numItems := uint16(utils.Max(noOfSubscriptionAcknowledgements, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/PublishResponse.go b/plc4go/protocols/opcua/readwrite/model/PublishResponse.go index 0871b31f825..1e9db3a355c 100644 --- a/plc4go/protocols/opcua/readwrite/model/PublishResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/PublishResponse.go @@ -291,13 +291,13 @@ func PublishResponseParseWithBuffer(ctx context.Context, readBuffer utils.ReadBu return nil, errors.Wrap(pullErr, "Error pulling for availableSequenceNumbers") } // Count array - availableSequenceNumbers := make([]uint32, noOfAvailableSequenceNumbers) + availableSequenceNumbers := make([]uint32, utils.Max(noOfAvailableSequenceNumbers, 0)) // This happens when the size is set conditional to 0 if len(availableSequenceNumbers) == 0 { availableSequenceNumbers = nil } { - _numItems := uint16(noOfAvailableSequenceNumbers) + _numItems := uint16(utils.Max(noOfAvailableSequenceNumbers, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -362,13 +362,13 @@ func PublishResponseParseWithBuffer(ctx context.Context, readBuffer utils.ReadBu return nil, errors.Wrap(pullErr, "Error pulling for results") } // Count array - results := make([]StatusCode, noOfResults) + results := make([]StatusCode, utils.Max(noOfResults, 0)) // This happens when the size is set conditional to 0 if len(results) == 0 { results = nil } { - _numItems := uint16(noOfResults) + _numItems := uint16(utils.Max(noOfResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -396,13 +396,13 @@ func PublishResponseParseWithBuffer(ctx context.Context, readBuffer utils.ReadBu return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/PublishedVariableDataType.go b/plc4go/protocols/opcua/readwrite/model/PublishedVariableDataType.go index 3de2f141604..8dc8d227ba5 100644 --- a/plc4go/protocols/opcua/readwrite/model/PublishedVariableDataType.go +++ b/plc4go/protocols/opcua/readwrite/model/PublishedVariableDataType.go @@ -313,13 +313,13 @@ func PublishedVariableDataTypeParseWithBuffer(ctx context.Context, readBuffer ut return nil, errors.Wrap(pullErr, "Error pulling for metaDataProperties") } // Count array - metaDataProperties := make([]QualifiedName, noOfMetaDataProperties) + metaDataProperties := make([]QualifiedName, utils.Max(noOfMetaDataProperties, 0)) // This happens when the size is set conditional to 0 if len(metaDataProperties) == 0 { metaDataProperties = nil } { - _numItems := uint16(noOfMetaDataProperties) + _numItems := uint16(utils.Max(noOfMetaDataProperties, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/QueryDataSet.go b/plc4go/protocols/opcua/readwrite/model/QueryDataSet.go index d3cd0df20ba..0a50f3066d4 100644 --- a/plc4go/protocols/opcua/readwrite/model/QueryDataSet.go +++ b/plc4go/protocols/opcua/readwrite/model/QueryDataSet.go @@ -217,13 +217,13 @@ func QueryDataSetParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffe return nil, errors.Wrap(pullErr, "Error pulling for values") } // Count array - values := make([]Variant, noOfValues) + values := make([]Variant, utils.Max(noOfValues, 0)) // This happens when the size is set conditional to 0 if len(values) == 0 { values = nil } { - _numItems := uint16(noOfValues) + _numItems := uint16(utils.Max(noOfValues, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/QueryFirstRequest.go b/plc4go/protocols/opcua/readwrite/model/QueryFirstRequest.go index adf6e831477..0bbcf35dfbe 100644 --- a/plc4go/protocols/opcua/readwrite/model/QueryFirstRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/QueryFirstRequest.go @@ -250,13 +250,13 @@ func QueryFirstRequestParseWithBuffer(ctx context.Context, readBuffer utils.Read return nil, errors.Wrap(pullErr, "Error pulling for nodeTypes") } // Count array - nodeTypes := make([]ExtensionObjectDefinition, noOfNodeTypes) + nodeTypes := make([]ExtensionObjectDefinition, utils.Max(noOfNodeTypes, 0)) // This happens when the size is set conditional to 0 if len(nodeTypes) == 0 { nodeTypes = nil } { - _numItems := uint16(noOfNodeTypes) + _numItems := uint16(utils.Max(noOfNodeTypes, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/QueryFirstResponse.go b/plc4go/protocols/opcua/readwrite/model/QueryFirstResponse.go index 8836a027f07..57783c19718 100644 --- a/plc4go/protocols/opcua/readwrite/model/QueryFirstResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/QueryFirstResponse.go @@ -273,13 +273,13 @@ func QueryFirstResponseParseWithBuffer(ctx context.Context, readBuffer utils.Rea return nil, errors.Wrap(pullErr, "Error pulling for queryDataSets") } // Count array - queryDataSets := make([]ExtensionObjectDefinition, noOfQueryDataSets) + queryDataSets := make([]ExtensionObjectDefinition, utils.Max(noOfQueryDataSets, 0)) // This happens when the size is set conditional to 0 if len(queryDataSets) == 0 { queryDataSets = nil } { - _numItems := uint16(noOfQueryDataSets) + _numItems := uint16(utils.Max(noOfQueryDataSets, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -320,13 +320,13 @@ func QueryFirstResponseParseWithBuffer(ctx context.Context, readBuffer utils.Rea return nil, errors.Wrap(pullErr, "Error pulling for parsingResults") } // Count array - parsingResults := make([]ExtensionObjectDefinition, noOfParsingResults) + parsingResults := make([]ExtensionObjectDefinition, utils.Max(noOfParsingResults, 0)) // This happens when the size is set conditional to 0 if len(parsingResults) == 0 { parsingResults = nil } { - _numItems := uint16(noOfParsingResults) + _numItems := uint16(utils.Max(noOfParsingResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -354,13 +354,13 @@ func QueryFirstResponseParseWithBuffer(ctx context.Context, readBuffer utils.Rea return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/QueryNextResponse.go b/plc4go/protocols/opcua/readwrite/model/QueryNextResponse.go index d0041447570..6e8cdc6c6fa 100644 --- a/plc4go/protocols/opcua/readwrite/model/QueryNextResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/QueryNextResponse.go @@ -204,13 +204,13 @@ func QueryNextResponseParseWithBuffer(ctx context.Context, readBuffer utils.Read return nil, errors.Wrap(pullErr, "Error pulling for queryDataSets") } // Count array - queryDataSets := make([]ExtensionObjectDefinition, noOfQueryDataSets) + queryDataSets := make([]ExtensionObjectDefinition, utils.Max(noOfQueryDataSets, 0)) // This happens when the size is set conditional to 0 if len(queryDataSets) == 0 { queryDataSets = nil } { - _numItems := uint16(noOfQueryDataSets) + _numItems := uint16(utils.Max(noOfQueryDataSets, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/ReadRequest.go b/plc4go/protocols/opcua/readwrite/model/ReadRequest.go index ce6853c247c..8cec38c552d 100644 --- a/plc4go/protocols/opcua/readwrite/model/ReadRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/ReadRequest.go @@ -235,13 +235,13 @@ func ReadRequestParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer return nil, errors.Wrap(pullErr, "Error pulling for nodesToRead") } // Count array - nodesToRead := make([]ExtensionObjectDefinition, noOfNodesToRead) + nodesToRead := make([]ExtensionObjectDefinition, utils.Max(noOfNodesToRead, 0)) // This happens when the size is set conditional to 0 if len(nodesToRead) == 0 { nodesToRead = nil } { - _numItems := uint16(noOfNodesToRead) + _numItems := uint16(utils.Max(noOfNodesToRead, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/ReadResponse.go b/plc4go/protocols/opcua/readwrite/model/ReadResponse.go index 75f22b1a2b3..4ed49165c4f 100644 --- a/plc4go/protocols/opcua/readwrite/model/ReadResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/ReadResponse.go @@ -222,13 +222,13 @@ func ReadResponseParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffe return nil, errors.Wrap(pullErr, "Error pulling for results") } // Count array - results := make([]DataValue, noOfResults) + results := make([]DataValue, utils.Max(noOfResults, 0)) // This happens when the size is set conditional to 0 if len(results) == 0 { results = nil } { - _numItems := uint16(noOfResults) + _numItems := uint16(utils.Max(noOfResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func ReadResponseParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffe return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/RegisterNodesRequest.go b/plc4go/protocols/opcua/readwrite/model/RegisterNodesRequest.go index ce33759da73..689cb0b60d2 100644 --- a/plc4go/protocols/opcua/readwrite/model/RegisterNodesRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/RegisterNodesRequest.go @@ -193,13 +193,13 @@ func RegisterNodesRequestParseWithBuffer(ctx context.Context, readBuffer utils.R return nil, errors.Wrap(pullErr, "Error pulling for nodesToRegister") } // Count array - nodesToRegister := make([]NodeId, noOfNodesToRegister) + nodesToRegister := make([]NodeId, utils.Max(noOfNodesToRegister, 0)) // This happens when the size is set conditional to 0 if len(nodesToRegister) == 0 { nodesToRegister = nil } { - _numItems := uint16(noOfNodesToRegister) + _numItems := uint16(utils.Max(noOfNodesToRegister, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/RegisterNodesResponse.go b/plc4go/protocols/opcua/readwrite/model/RegisterNodesResponse.go index 9020ec0bd23..a955e0b03c0 100644 --- a/plc4go/protocols/opcua/readwrite/model/RegisterNodesResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/RegisterNodesResponse.go @@ -193,13 +193,13 @@ func RegisterNodesResponseParseWithBuffer(ctx context.Context, readBuffer utils. return nil, errors.Wrap(pullErr, "Error pulling for registeredNodeIds") } // Count array - registeredNodeIds := make([]NodeId, noOfRegisteredNodeIds) + registeredNodeIds := make([]NodeId, utils.Max(noOfRegisteredNodeIds, 0)) // This happens when the size is set conditional to 0 if len(registeredNodeIds) == 0 { registeredNodeIds = nil } { - _numItems := uint16(noOfRegisteredNodeIds) + _numItems := uint16(utils.Max(noOfRegisteredNodeIds, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/RegisterServer2Request.go b/plc4go/protocols/opcua/readwrite/model/RegisterServer2Request.go index 09d3aaf6c11..01d07cdeeef 100644 --- a/plc4go/protocols/opcua/readwrite/model/RegisterServer2Request.go +++ b/plc4go/protocols/opcua/readwrite/model/RegisterServer2Request.go @@ -217,13 +217,13 @@ func RegisterServer2RequestParseWithBuffer(ctx context.Context, readBuffer utils return nil, errors.Wrap(pullErr, "Error pulling for discoveryConfiguration") } // Count array - discoveryConfiguration := make([]ExtensionObject, noOfDiscoveryConfiguration) + discoveryConfiguration := make([]ExtensionObject, utils.Max(noOfDiscoveryConfiguration, 0)) // This happens when the size is set conditional to 0 if len(discoveryConfiguration) == 0 { discoveryConfiguration = nil } { - _numItems := uint16(noOfDiscoveryConfiguration) + _numItems := uint16(utils.Max(noOfDiscoveryConfiguration, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/RegisterServer2Response.go b/plc4go/protocols/opcua/readwrite/model/RegisterServer2Response.go index 3de165b018f..6818fe009ff 100644 --- a/plc4go/protocols/opcua/readwrite/model/RegisterServer2Response.go +++ b/plc4go/protocols/opcua/readwrite/model/RegisterServer2Response.go @@ -222,13 +222,13 @@ func RegisterServer2ResponseParseWithBuffer(ctx context.Context, readBuffer util return nil, errors.Wrap(pullErr, "Error pulling for configurationResults") } // Count array - configurationResults := make([]StatusCode, noOfConfigurationResults) + configurationResults := make([]StatusCode, utils.Max(noOfConfigurationResults, 0)) // This happens when the size is set conditional to 0 if len(configurationResults) == 0 { configurationResults = nil } { - _numItems := uint16(noOfConfigurationResults) + _numItems := uint16(utils.Max(noOfConfigurationResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func RegisterServer2ResponseParseWithBuffer(ctx context.Context, readBuffer util return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/RegisteredServer.go b/plc4go/protocols/opcua/readwrite/model/RegisteredServer.go index adb7c66313c..cae57855e5d 100644 --- a/plc4go/protocols/opcua/readwrite/model/RegisteredServer.go +++ b/plc4go/protocols/opcua/readwrite/model/RegisteredServer.go @@ -295,13 +295,13 @@ func RegisteredServerParseWithBuffer(ctx context.Context, readBuffer utils.ReadB return nil, errors.Wrap(pullErr, "Error pulling for serverNames") } // Count array - serverNames := make([]LocalizedText, noOfServerNames) + serverNames := make([]LocalizedText, utils.Max(noOfServerNames, 0)) // This happens when the size is set conditional to 0 if len(serverNames) == 0 { serverNames = nil } { - _numItems := uint16(noOfServerNames) + _numItems := uint16(utils.Max(noOfServerNames, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -355,13 +355,13 @@ func RegisteredServerParseWithBuffer(ctx context.Context, readBuffer utils.ReadB return nil, errors.Wrap(pullErr, "Error pulling for discoveryUrls") } // Count array - discoveryUrls := make([]PascalString, noOfDiscoveryUrls) + discoveryUrls := make([]PascalString, utils.Max(noOfDiscoveryUrls, 0)) // This happens when the size is set conditional to 0 if len(discoveryUrls) == 0 { discoveryUrls = nil } { - _numItems := uint16(noOfDiscoveryUrls) + _numItems := uint16(utils.Max(noOfDiscoveryUrls, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/RelativePath.go b/plc4go/protocols/opcua/readwrite/model/RelativePath.go index 808e15306fc..2bb54be5385 100644 --- a/plc4go/protocols/opcua/readwrite/model/RelativePath.go +++ b/plc4go/protocols/opcua/readwrite/model/RelativePath.go @@ -169,13 +169,13 @@ func RelativePathParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffe return nil, errors.Wrap(pullErr, "Error pulling for elements") } // Count array - elements := make([]ExtensionObjectDefinition, noOfElements) + elements := make([]ExtensionObjectDefinition, utils.Max(noOfElements, 0)) // This happens when the size is set conditional to 0 if len(elements) == 0 { elements = nil } { - _numItems := uint16(noOfElements) + _numItems := uint16(utils.Max(noOfElements, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/ResponseHeader.go b/plc4go/protocols/opcua/readwrite/model/ResponseHeader.go index 4b7498b3d30..b9ffebabb93 100644 --- a/plc4go/protocols/opcua/readwrite/model/ResponseHeader.go +++ b/plc4go/protocols/opcua/readwrite/model/ResponseHeader.go @@ -264,13 +264,13 @@ func ResponseHeaderParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuf return nil, errors.Wrap(pullErr, "Error pulling for stringTable") } // Count array - stringTable := make([]PascalString, noOfStringTable) + stringTable := make([]PascalString, utils.Max(noOfStringTable, 0)) // This happens when the size is set conditional to 0 if len(stringTable) == 0 { stringTable = nil } { - _numItems := uint16(noOfStringTable) + _numItems := uint16(utils.Max(noOfStringTable, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/ServerOnNetwork.go b/plc4go/protocols/opcua/readwrite/model/ServerOnNetwork.go index 477e4d7301e..988daac2bdd 100644 --- a/plc4go/protocols/opcua/readwrite/model/ServerOnNetwork.go +++ b/plc4go/protocols/opcua/readwrite/model/ServerOnNetwork.go @@ -235,13 +235,13 @@ func ServerOnNetworkParseWithBuffer(ctx context.Context, readBuffer utils.ReadBu return nil, errors.Wrap(pullErr, "Error pulling for serverCapabilities") } // Count array - serverCapabilities := make([]PascalString, noOfServerCapabilities) + serverCapabilities := make([]PascalString, utils.Max(noOfServerCapabilities, 0)) // This happens when the size is set conditional to 0 if len(serverCapabilities) == 0 { serverCapabilities = nil } { - _numItems := uint16(noOfServerCapabilities) + _numItems := uint16(utils.Max(noOfServerCapabilities, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/SessionDiagnosticsDataType.go b/plc4go/protocols/opcua/readwrite/model/SessionDiagnosticsDataType.go index bc3577cb391..01db7dac3e7 100644 --- a/plc4go/protocols/opcua/readwrite/model/SessionDiagnosticsDataType.go +++ b/plc4go/protocols/opcua/readwrite/model/SessionDiagnosticsDataType.go @@ -696,13 +696,13 @@ func SessionDiagnosticsDataTypeParseWithBuffer(ctx context.Context, readBuffer u return nil, errors.Wrap(pullErr, "Error pulling for localeIds") } // Count array - localeIds := make([]PascalString, noOfLocaleIds) + localeIds := make([]PascalString, utils.Max(noOfLocaleIds, 0)) // This happens when the size is set conditional to 0 if len(localeIds) == 0 { localeIds = nil } { - _numItems := uint16(noOfLocaleIds) + _numItems := uint16(utils.Max(noOfLocaleIds, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/SessionSecurityDiagnosticsDataType.go b/plc4go/protocols/opcua/readwrite/model/SessionSecurityDiagnosticsDataType.go index a3ec3309e10..5ef61ab895e 100644 --- a/plc4go/protocols/opcua/readwrite/model/SessionSecurityDiagnosticsDataType.go +++ b/plc4go/protocols/opcua/readwrite/model/SessionSecurityDiagnosticsDataType.go @@ -283,13 +283,13 @@ func SessionSecurityDiagnosticsDataTypeParseWithBuffer(ctx context.Context, read return nil, errors.Wrap(pullErr, "Error pulling for clientUserIdHistory") } // Count array - clientUserIdHistory := make([]PascalString, noOfClientUserIdHistory) + clientUserIdHistory := make([]PascalString, utils.Max(noOfClientUserIdHistory, 0)) // This happens when the size is set conditional to 0 if len(clientUserIdHistory) == 0 { clientUserIdHistory = nil } { - _numItems := uint16(noOfClientUserIdHistory) + _numItems := uint16(utils.Max(noOfClientUserIdHistory, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/SessionlessInvokeRequestType.go b/plc4go/protocols/opcua/readwrite/model/SessionlessInvokeRequestType.go index d4dc11a75c3..b91fa6198d1 100644 --- a/plc4go/protocols/opcua/readwrite/model/SessionlessInvokeRequestType.go +++ b/plc4go/protocols/opcua/readwrite/model/SessionlessInvokeRequestType.go @@ -256,13 +256,13 @@ func SessionlessInvokeRequestTypeParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for namespaceUris") } // Count array - namespaceUris := make([]PascalString, noOfNamespaceUris) + namespaceUris := make([]PascalString, utils.Max(noOfNamespaceUris, 0)) // This happens when the size is set conditional to 0 if len(namespaceUris) == 0 { namespaceUris = nil } { - _numItems := uint16(noOfNamespaceUris) + _numItems := uint16(utils.Max(noOfNamespaceUris, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -290,13 +290,13 @@ func SessionlessInvokeRequestTypeParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for serverUris") } // Count array - serverUris := make([]PascalString, noOfServerUris) + serverUris := make([]PascalString, utils.Max(noOfServerUris, 0)) // This happens when the size is set conditional to 0 if len(serverUris) == 0 { serverUris = nil } { - _numItems := uint16(noOfServerUris) + _numItems := uint16(utils.Max(noOfServerUris, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -324,13 +324,13 @@ func SessionlessInvokeRequestTypeParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for localeIds") } // Count array - localeIds := make([]PascalString, noOfLocaleIds) + localeIds := make([]PascalString, utils.Max(noOfLocaleIds, 0)) // This happens when the size is set conditional to 0 if len(localeIds) == 0 { localeIds = nil } { - _numItems := uint16(noOfLocaleIds) + _numItems := uint16(utils.Max(noOfLocaleIds, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/SessionlessInvokeResponseType.go b/plc4go/protocols/opcua/readwrite/model/SessionlessInvokeResponseType.go index baf87aaadf3..198ccb44061 100644 --- a/plc4go/protocols/opcua/readwrite/model/SessionlessInvokeResponseType.go +++ b/plc4go/protocols/opcua/readwrite/model/SessionlessInvokeResponseType.go @@ -209,13 +209,13 @@ func SessionlessInvokeResponseTypeParseWithBuffer(ctx context.Context, readBuffe return nil, errors.Wrap(pullErr, "Error pulling for namespaceUris") } // Count array - namespaceUris := make([]PascalString, noOfNamespaceUris) + namespaceUris := make([]PascalString, utils.Max(noOfNamespaceUris, 0)) // This happens when the size is set conditional to 0 if len(namespaceUris) == 0 { namespaceUris = nil } { - _numItems := uint16(noOfNamespaceUris) + _numItems := uint16(utils.Max(noOfNamespaceUris, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -243,13 +243,13 @@ func SessionlessInvokeResponseTypeParseWithBuffer(ctx context.Context, readBuffe return nil, errors.Wrap(pullErr, "Error pulling for serverUris") } // Count array - serverUris := make([]PascalString, noOfServerUris) + serverUris := make([]PascalString, utils.Max(noOfServerUris, 0)) // This happens when the size is set conditional to 0 if len(serverUris) == 0 { serverUris = nil } { - _numItems := uint16(noOfServerUris) + _numItems := uint16(utils.Max(noOfServerUris, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/SetMonitoringModeRequest.go b/plc4go/protocols/opcua/readwrite/model/SetMonitoringModeRequest.go index 2cc36eb1f4a..476afd84d99 100644 --- a/plc4go/protocols/opcua/readwrite/model/SetMonitoringModeRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/SetMonitoringModeRequest.go @@ -230,13 +230,13 @@ func SetMonitoringModeRequestParseWithBuffer(ctx context.Context, readBuffer uti return nil, errors.Wrap(pullErr, "Error pulling for monitoredItemIds") } // Count array - monitoredItemIds := make([]uint32, noOfMonitoredItemIds) + monitoredItemIds := make([]uint32, utils.Max(noOfMonitoredItemIds, 0)) // This happens when the size is set conditional to 0 if len(monitoredItemIds) == 0 { monitoredItemIds = nil } { - _numItems := uint16(noOfMonitoredItemIds) + _numItems := uint16(utils.Max(noOfMonitoredItemIds, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/SetMonitoringModeResponse.go b/plc4go/protocols/opcua/readwrite/model/SetMonitoringModeResponse.go index e1e8eaa0407..d10d8f6f9ed 100644 --- a/plc4go/protocols/opcua/readwrite/model/SetMonitoringModeResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/SetMonitoringModeResponse.go @@ -222,13 +222,13 @@ func SetMonitoringModeResponseParseWithBuffer(ctx context.Context, readBuffer ut return nil, errors.Wrap(pullErr, "Error pulling for results") } // Count array - results := make([]StatusCode, noOfResults) + results := make([]StatusCode, utils.Max(noOfResults, 0)) // This happens when the size is set conditional to 0 if len(results) == 0 { results = nil } { - _numItems := uint16(noOfResults) + _numItems := uint16(utils.Max(noOfResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func SetMonitoringModeResponseParseWithBuffer(ctx context.Context, readBuffer ut return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/SetPublishingModeRequest.go b/plc4go/protocols/opcua/readwrite/model/SetPublishingModeRequest.go index a715985a890..19aeb571fb8 100644 --- a/plc4go/protocols/opcua/readwrite/model/SetPublishingModeRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/SetPublishingModeRequest.go @@ -228,13 +228,13 @@ func SetPublishingModeRequestParseWithBuffer(ctx context.Context, readBuffer uti return nil, errors.Wrap(pullErr, "Error pulling for subscriptionIds") } // Count array - subscriptionIds := make([]uint32, noOfSubscriptionIds) + subscriptionIds := make([]uint32, utils.Max(noOfSubscriptionIds, 0)) // This happens when the size is set conditional to 0 if len(subscriptionIds) == 0 { subscriptionIds = nil } { - _numItems := uint16(noOfSubscriptionIds) + _numItems := uint16(utils.Max(noOfSubscriptionIds, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/SetPublishingModeResponse.go b/plc4go/protocols/opcua/readwrite/model/SetPublishingModeResponse.go index 3a4c50a21b2..95116b01a9d 100644 --- a/plc4go/protocols/opcua/readwrite/model/SetPublishingModeResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/SetPublishingModeResponse.go @@ -222,13 +222,13 @@ func SetPublishingModeResponseParseWithBuffer(ctx context.Context, readBuffer ut return nil, errors.Wrap(pullErr, "Error pulling for results") } // Count array - results := make([]StatusCode, noOfResults) + results := make([]StatusCode, utils.Max(noOfResults, 0)) // This happens when the size is set conditional to 0 if len(results) == 0 { results = nil } { - _numItems := uint16(noOfResults) + _numItems := uint16(utils.Max(noOfResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func SetPublishingModeResponseParseWithBuffer(ctx context.Context, readBuffer ut return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/SetTriggeringRequest.go b/plc4go/protocols/opcua/readwrite/model/SetTriggeringRequest.go index a1005e4c4ae..fed0d4037b6 100644 --- a/plc4go/protocols/opcua/readwrite/model/SetTriggeringRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/SetTriggeringRequest.go @@ -248,13 +248,13 @@ func SetTriggeringRequestParseWithBuffer(ctx context.Context, readBuffer utils.R return nil, errors.Wrap(pullErr, "Error pulling for linksToAdd") } // Count array - linksToAdd := make([]uint32, noOfLinksToAdd) + linksToAdd := make([]uint32, utils.Max(noOfLinksToAdd, 0)) // This happens when the size is set conditional to 0 if len(linksToAdd) == 0 { linksToAdd = nil } { - _numItems := uint16(noOfLinksToAdd) + _numItems := uint16(utils.Max(noOfLinksToAdd, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -282,13 +282,13 @@ func SetTriggeringRequestParseWithBuffer(ctx context.Context, readBuffer utils.R return nil, errors.Wrap(pullErr, "Error pulling for linksToRemove") } // Count array - linksToRemove := make([]uint32, noOfLinksToRemove) + linksToRemove := make([]uint32, utils.Max(noOfLinksToRemove, 0)) // This happens when the size is set conditional to 0 if len(linksToRemove) == 0 { linksToRemove = nil } { - _numItems := uint16(noOfLinksToRemove) + _numItems := uint16(utils.Max(noOfLinksToRemove, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/SetTriggeringResponse.go b/plc4go/protocols/opcua/readwrite/model/SetTriggeringResponse.go index ee3794bd2ca..439816a1960 100644 --- a/plc4go/protocols/opcua/readwrite/model/SetTriggeringResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/SetTriggeringResponse.go @@ -280,13 +280,13 @@ func SetTriggeringResponseParseWithBuffer(ctx context.Context, readBuffer utils. return nil, errors.Wrap(pullErr, "Error pulling for addResults") } // Count array - addResults := make([]StatusCode, noOfAddResults) + addResults := make([]StatusCode, utils.Max(noOfAddResults, 0)) // This happens when the size is set conditional to 0 if len(addResults) == 0 { addResults = nil } { - _numItems := uint16(noOfAddResults) + _numItems := uint16(utils.Max(noOfAddResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -314,13 +314,13 @@ func SetTriggeringResponseParseWithBuffer(ctx context.Context, readBuffer utils. return nil, errors.Wrap(pullErr, "Error pulling for addDiagnosticInfos") } // Count array - addDiagnosticInfos := make([]DiagnosticInfo, noOfAddDiagnosticInfos) + addDiagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfAddDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(addDiagnosticInfos) == 0 { addDiagnosticInfos = nil } { - _numItems := uint16(noOfAddDiagnosticInfos) + _numItems := uint16(utils.Max(noOfAddDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -348,13 +348,13 @@ func SetTriggeringResponseParseWithBuffer(ctx context.Context, readBuffer utils. return nil, errors.Wrap(pullErr, "Error pulling for removeResults") } // Count array - removeResults := make([]StatusCode, noOfRemoveResults) + removeResults := make([]StatusCode, utils.Max(noOfRemoveResults, 0)) // This happens when the size is set conditional to 0 if len(removeResults) == 0 { removeResults = nil } { - _numItems := uint16(noOfRemoveResults) + _numItems := uint16(utils.Max(noOfRemoveResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -382,13 +382,13 @@ func SetTriggeringResponseParseWithBuffer(ctx context.Context, readBuffer utils. return nil, errors.Wrap(pullErr, "Error pulling for removeDiagnosticInfos") } // Count array - removeDiagnosticInfos := make([]DiagnosticInfo, noOfRemoveDiagnosticInfos) + removeDiagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfRemoveDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(removeDiagnosticInfos) == 0 { removeDiagnosticInfos = nil } { - _numItems := uint16(noOfRemoveDiagnosticInfos) + _numItems := uint16(utils.Max(noOfRemoveDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/StructureField.go b/plc4go/protocols/opcua/readwrite/model/StructureField.go index 66aee3146b3..da253242605 100644 --- a/plc4go/protocols/opcua/readwrite/model/StructureField.go +++ b/plc4go/protocols/opcua/readwrite/model/StructureField.go @@ -281,13 +281,13 @@ func StructureFieldParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuf return nil, errors.Wrap(pullErr, "Error pulling for arrayDimensions") } // Count array - arrayDimensions := make([]uint32, noOfArrayDimensions) + arrayDimensions := make([]uint32, utils.Max(noOfArrayDimensions, 0)) // This happens when the size is set conditional to 0 if len(arrayDimensions) == 0 { arrayDimensions = nil } { - _numItems := uint16(noOfArrayDimensions) + _numItems := uint16(utils.Max(noOfArrayDimensions, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/TransferResult.go b/plc4go/protocols/opcua/readwrite/model/TransferResult.go index f659249f809..96f363d5d7f 100644 --- a/plc4go/protocols/opcua/readwrite/model/TransferResult.go +++ b/plc4go/protocols/opcua/readwrite/model/TransferResult.go @@ -188,13 +188,13 @@ func TransferResultParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuf return nil, errors.Wrap(pullErr, "Error pulling for availableSequenceNumbers") } // Count array - availableSequenceNumbers := make([]uint32, noOfAvailableSequenceNumbers) + availableSequenceNumbers := make([]uint32, utils.Max(noOfAvailableSequenceNumbers, 0)) // This happens when the size is set conditional to 0 if len(availableSequenceNumbers) == 0 { availableSequenceNumbers = nil } { - _numItems := uint16(noOfAvailableSequenceNumbers) + _numItems := uint16(utils.Max(noOfAvailableSequenceNumbers, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/TransferSubscriptionsRequest.go b/plc4go/protocols/opcua/readwrite/model/TransferSubscriptionsRequest.go index f12ab699d46..56f8b2f4d3c 100644 --- a/plc4go/protocols/opcua/readwrite/model/TransferSubscriptionsRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/TransferSubscriptionsRequest.go @@ -204,13 +204,13 @@ func TransferSubscriptionsRequestParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for subscriptionIds") } // Count array - subscriptionIds := make([]uint32, noOfSubscriptionIds) + subscriptionIds := make([]uint32, utils.Max(noOfSubscriptionIds, 0)) // This happens when the size is set conditional to 0 if len(subscriptionIds) == 0 { subscriptionIds = nil } { - _numItems := uint16(noOfSubscriptionIds) + _numItems := uint16(utils.Max(noOfSubscriptionIds, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/TransferSubscriptionsResponse.go b/plc4go/protocols/opcua/readwrite/model/TransferSubscriptionsResponse.go index b78372edce5..20ddf1c2026 100644 --- a/plc4go/protocols/opcua/readwrite/model/TransferSubscriptionsResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/TransferSubscriptionsResponse.go @@ -222,13 +222,13 @@ func TransferSubscriptionsResponseParseWithBuffer(ctx context.Context, readBuffe return nil, errors.Wrap(pullErr, "Error pulling for results") } // Count array - results := make([]ExtensionObjectDefinition, noOfResults) + results := make([]ExtensionObjectDefinition, utils.Max(noOfResults, 0)) // This happens when the size is set conditional to 0 if len(results) == 0 { results = nil } { - _numItems := uint16(noOfResults) + _numItems := uint16(utils.Max(noOfResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func TransferSubscriptionsResponseParseWithBuffer(ctx context.Context, readBuffe return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/TranslateBrowsePathsToNodeIdsRequest.go b/plc4go/protocols/opcua/readwrite/model/TranslateBrowsePathsToNodeIdsRequest.go index a2312362351..01704255744 100644 --- a/plc4go/protocols/opcua/readwrite/model/TranslateBrowsePathsToNodeIdsRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/TranslateBrowsePathsToNodeIdsRequest.go @@ -193,13 +193,13 @@ func TranslateBrowsePathsToNodeIdsRequestParseWithBuffer(ctx context.Context, re return nil, errors.Wrap(pullErr, "Error pulling for browsePaths") } // Count array - browsePaths := make([]ExtensionObjectDefinition, noOfBrowsePaths) + browsePaths := make([]ExtensionObjectDefinition, utils.Max(noOfBrowsePaths, 0)) // This happens when the size is set conditional to 0 if len(browsePaths) == 0 { browsePaths = nil } { - _numItems := uint16(noOfBrowsePaths) + _numItems := uint16(utils.Max(noOfBrowsePaths, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/TranslateBrowsePathsToNodeIdsResponse.go b/plc4go/protocols/opcua/readwrite/model/TranslateBrowsePathsToNodeIdsResponse.go index 90a6364c25a..43130e8140d 100644 --- a/plc4go/protocols/opcua/readwrite/model/TranslateBrowsePathsToNodeIdsResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/TranslateBrowsePathsToNodeIdsResponse.go @@ -222,13 +222,13 @@ func TranslateBrowsePathsToNodeIdsResponseParseWithBuffer(ctx context.Context, r return nil, errors.Wrap(pullErr, "Error pulling for results") } // Count array - results := make([]ExtensionObjectDefinition, noOfResults) + results := make([]ExtensionObjectDefinition, utils.Max(noOfResults, 0)) // This happens when the size is set conditional to 0 if len(results) == 0 { results = nil } { - _numItems := uint16(noOfResults) + _numItems := uint16(utils.Max(noOfResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func TranslateBrowsePathsToNodeIdsResponseParseWithBuffer(ctx context.Context, r return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/TrustListDataType.go b/plc4go/protocols/opcua/readwrite/model/TrustListDataType.go index 8431e9f25b3..f85a2d81fd8 100644 --- a/plc4go/protocols/opcua/readwrite/model/TrustListDataType.go +++ b/plc4go/protocols/opcua/readwrite/model/TrustListDataType.go @@ -274,13 +274,13 @@ func TrustListDataTypeParseWithBuffer(ctx context.Context, readBuffer utils.Read return nil, errors.Wrap(pullErr, "Error pulling for trustedCertificates") } // Count array - trustedCertificates := make([]PascalByteString, noOfTrustedCertificates) + trustedCertificates := make([]PascalByteString, utils.Max(noOfTrustedCertificates, 0)) // This happens when the size is set conditional to 0 if len(trustedCertificates) == 0 { trustedCertificates = nil } { - _numItems := uint16(noOfTrustedCertificates) + _numItems := uint16(utils.Max(noOfTrustedCertificates, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -308,13 +308,13 @@ func TrustListDataTypeParseWithBuffer(ctx context.Context, readBuffer utils.Read return nil, errors.Wrap(pullErr, "Error pulling for trustedCrls") } // Count array - trustedCrls := make([]PascalByteString, noOfTrustedCrls) + trustedCrls := make([]PascalByteString, utils.Max(noOfTrustedCrls, 0)) // This happens when the size is set conditional to 0 if len(trustedCrls) == 0 { trustedCrls = nil } { - _numItems := uint16(noOfTrustedCrls) + _numItems := uint16(utils.Max(noOfTrustedCrls, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -342,13 +342,13 @@ func TrustListDataTypeParseWithBuffer(ctx context.Context, readBuffer utils.Read return nil, errors.Wrap(pullErr, "Error pulling for issuerCertificates") } // Count array - issuerCertificates := make([]PascalByteString, noOfIssuerCertificates) + issuerCertificates := make([]PascalByteString, utils.Max(noOfIssuerCertificates, 0)) // This happens when the size is set conditional to 0 if len(issuerCertificates) == 0 { issuerCertificates = nil } { - _numItems := uint16(noOfIssuerCertificates) + _numItems := uint16(utils.Max(noOfIssuerCertificates, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -376,13 +376,13 @@ func TrustListDataTypeParseWithBuffer(ctx context.Context, readBuffer utils.Read return nil, errors.Wrap(pullErr, "Error pulling for issuerCrls") } // Count array - issuerCrls := make([]PascalByteString, noOfIssuerCrls) + issuerCrls := make([]PascalByteString, utils.Max(noOfIssuerCrls, 0)) // This happens when the size is set conditional to 0 if len(issuerCrls) == 0 { issuerCrls = nil } { - _numItems := uint16(noOfIssuerCrls) + _numItems := uint16(utils.Max(noOfIssuerCrls, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/UnregisterNodesRequest.go b/plc4go/protocols/opcua/readwrite/model/UnregisterNodesRequest.go index 59325ce2d7e..16525bb0250 100644 --- a/plc4go/protocols/opcua/readwrite/model/UnregisterNodesRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/UnregisterNodesRequest.go @@ -193,13 +193,13 @@ func UnregisterNodesRequestParseWithBuffer(ctx context.Context, readBuffer utils return nil, errors.Wrap(pullErr, "Error pulling for nodesToUnregister") } // Count array - nodesToUnregister := make([]NodeId, noOfNodesToUnregister) + nodesToUnregister := make([]NodeId, utils.Max(noOfNodesToUnregister, 0)) // This happens when the size is set conditional to 0 if len(nodesToUnregister) == 0 { nodesToUnregister = nil } { - _numItems := uint16(noOfNodesToUnregister) + _numItems := uint16(utils.Max(noOfNodesToUnregister, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/Variant.go b/plc4go/protocols/opcua/readwrite/model/Variant.go index e3f4bcc5bdd..f3f51154408 100644 --- a/plc4go/protocols/opcua/readwrite/model/Variant.go +++ b/plc4go/protocols/opcua/readwrite/model/Variant.go @@ -275,13 +275,13 @@ func VariantParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer) (V return nil, errors.Wrap(pullErr, "Error pulling for arrayDimensions") } // Count array - arrayDimensions := make([]bool, utils.InlineIf(bool((noOfArrayDimensions) == (nil)), func() any { return uint16(uint16(0)) }, func() any { return uint16((*noOfArrayDimensions)) }).(uint16)) + arrayDimensions := make([]bool, utils.Max(utils.InlineIf(bool((noOfArrayDimensions) == (nil)), func() any { return uint16(uint16(0)) }, func() any { return uint16((*noOfArrayDimensions)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(arrayDimensions) == 0 { arrayDimensions = nil } { - _numItems := uint16(utils.InlineIf(bool((noOfArrayDimensions) == (nil)), func() any { return uint16(uint16(0)) }, func() any { return uint16((*noOfArrayDimensions)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((noOfArrayDimensions) == (nil)), func() any { return uint16(uint16(0)) }, func() any { return uint16((*noOfArrayDimensions)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantByte.go b/plc4go/protocols/opcua/readwrite/model/VariantByte.go index dd7641006b7..25cce084ec2 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantByte.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantByte.go @@ -174,13 +174,13 @@ func VariantByteParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]uint8, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]uint8, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantByteString.go b/plc4go/protocols/opcua/readwrite/model/VariantByteString.go index c693d813f69..149af953410 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantByteString.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantByteString.go @@ -179,13 +179,13 @@ func VariantByteStringParseWithBuffer(ctx context.Context, readBuffer utils.Read return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]ByteStringArray, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]ByteStringArray, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantDataValue.go b/plc4go/protocols/opcua/readwrite/model/VariantDataValue.go index 1fece3d7209..163944921fd 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantDataValue.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantDataValue.go @@ -179,13 +179,13 @@ func VariantDataValueParseWithBuffer(ctx context.Context, readBuffer utils.ReadB return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]DataValue, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]DataValue, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantDateTime.go b/plc4go/protocols/opcua/readwrite/model/VariantDateTime.go index 34697ed4cf5..9e458982ed3 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantDateTime.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantDateTime.go @@ -174,13 +174,13 @@ func VariantDateTimeParseWithBuffer(ctx context.Context, readBuffer utils.ReadBu return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]int64, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]int64, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantDiagnosticInfo.go b/plc4go/protocols/opcua/readwrite/model/VariantDiagnosticInfo.go index 45bf65e5021..d7346b22916 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantDiagnosticInfo.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantDiagnosticInfo.go @@ -179,13 +179,13 @@ func VariantDiagnosticInfoParseWithBuffer(ctx context.Context, readBuffer utils. return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]DiagnosticInfo, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]DiagnosticInfo, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantDouble.go b/plc4go/protocols/opcua/readwrite/model/VariantDouble.go index 640997ea1a8..0d708d7c3e3 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantDouble.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantDouble.go @@ -174,13 +174,13 @@ func VariantDoubleParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuff return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]float64, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]float64, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantExpandedNodeId.go b/plc4go/protocols/opcua/readwrite/model/VariantExpandedNodeId.go index a3b94ddd36e..3e8c0bd81ee 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantExpandedNodeId.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantExpandedNodeId.go @@ -179,13 +179,13 @@ func VariantExpandedNodeIdParseWithBuffer(ctx context.Context, readBuffer utils. return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]ExpandedNodeId, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]ExpandedNodeId, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantExtensionObject.go b/plc4go/protocols/opcua/readwrite/model/VariantExtensionObject.go index db7e7adfaad..b795fa3c93c 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantExtensionObject.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantExtensionObject.go @@ -179,13 +179,13 @@ func VariantExtensionObjectParseWithBuffer(ctx context.Context, readBuffer utils return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]ExtensionObject, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]ExtensionObject, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantFloat.go b/plc4go/protocols/opcua/readwrite/model/VariantFloat.go index 0ca73d1f814..cf1f6bc70f3 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantFloat.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantFloat.go @@ -174,13 +174,13 @@ func VariantFloatParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffe return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]float32, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]float32, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantGuid.go b/plc4go/protocols/opcua/readwrite/model/VariantGuid.go index 6800b4ea9a1..4be4098f690 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantGuid.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantGuid.go @@ -179,13 +179,13 @@ func VariantGuidParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]GuidValue, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]GuidValue, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantInt16.go b/plc4go/protocols/opcua/readwrite/model/VariantInt16.go index 872598af4e1..3404d95bfeb 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantInt16.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantInt16.go @@ -174,13 +174,13 @@ func VariantInt16ParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffe return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]int16, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]int16, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantInt32.go b/plc4go/protocols/opcua/readwrite/model/VariantInt32.go index 437c1f016aa..8120a0838b6 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantInt32.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantInt32.go @@ -174,13 +174,13 @@ func VariantInt32ParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffe return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]int32, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]int32, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantInt64.go b/plc4go/protocols/opcua/readwrite/model/VariantInt64.go index b148458c789..42f8cf15518 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantInt64.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantInt64.go @@ -174,13 +174,13 @@ func VariantInt64ParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffe return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]int64, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]int64, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantLocalizedText.go b/plc4go/protocols/opcua/readwrite/model/VariantLocalizedText.go index 3763ed4c434..4eee1f5b6f5 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantLocalizedText.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantLocalizedText.go @@ -179,13 +179,13 @@ func VariantLocalizedTextParseWithBuffer(ctx context.Context, readBuffer utils.R return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]LocalizedText, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]LocalizedText, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantNodeId.go b/plc4go/protocols/opcua/readwrite/model/VariantNodeId.go index da2609f12fa..9ad55fa70b7 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantNodeId.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantNodeId.go @@ -179,13 +179,13 @@ func VariantNodeIdParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuff return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]NodeId, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]NodeId, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantQualifiedName.go b/plc4go/protocols/opcua/readwrite/model/VariantQualifiedName.go index ba8ee7f485f..0faf1575dca 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantQualifiedName.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantQualifiedName.go @@ -179,13 +179,13 @@ func VariantQualifiedNameParseWithBuffer(ctx context.Context, readBuffer utils.R return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]QualifiedName, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]QualifiedName, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantStatusCode.go b/plc4go/protocols/opcua/readwrite/model/VariantStatusCode.go index f2cfe363354..28e88ef77fc 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantStatusCode.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantStatusCode.go @@ -179,13 +179,13 @@ func VariantStatusCodeParseWithBuffer(ctx context.Context, readBuffer utils.Read return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]StatusCode, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]StatusCode, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantString.go b/plc4go/protocols/opcua/readwrite/model/VariantString.go index 5070e40ad19..3a8e7efbebc 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantString.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantString.go @@ -179,13 +179,13 @@ func VariantStringParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuff return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]PascalString, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]PascalString, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantUInt16.go b/plc4go/protocols/opcua/readwrite/model/VariantUInt16.go index 622349b1d59..c4f6442a082 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantUInt16.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantUInt16.go @@ -174,13 +174,13 @@ func VariantUInt16ParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuff return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]uint16, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]uint16, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantUInt32.go b/plc4go/protocols/opcua/readwrite/model/VariantUInt32.go index f370a749ded..343fd75af9a 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantUInt32.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantUInt32.go @@ -174,13 +174,13 @@ func VariantUInt32ParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuff return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]uint32, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]uint32, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantUInt64.go b/plc4go/protocols/opcua/readwrite/model/VariantUInt64.go index b0e52b6d905..c06f5c86ee0 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantUInt64.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantUInt64.go @@ -174,13 +174,13 @@ func VariantUInt64ParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuff return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]uint64, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]uint64, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantVariant.go b/plc4go/protocols/opcua/readwrite/model/VariantVariant.go index 6c4a2240ab2..cc92e938c74 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantVariant.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantVariant.go @@ -179,13 +179,13 @@ func VariantVariantParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuf return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]Variant, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]Variant, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/VariantXmlElement.go b/plc4go/protocols/opcua/readwrite/model/VariantXmlElement.go index 00c81fd1336..807bbe73ca7 100644 --- a/plc4go/protocols/opcua/readwrite/model/VariantXmlElement.go +++ b/plc4go/protocols/opcua/readwrite/model/VariantXmlElement.go @@ -179,13 +179,13 @@ func VariantXmlElementParseWithBuffer(ctx context.Context, readBuffer utils.Read return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]PascalString, utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + value := make([]PascalString, utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16)) + _numItems := uint16(utils.Max(utils.InlineIf(bool((arrayLength) == (nil)), func() any { return uint16(uint16(1)) }, func() any { return uint16((*arrayLength)) }).(uint16), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/WriteRequest.go b/plc4go/protocols/opcua/readwrite/model/WriteRequest.go index 421cd44f40d..7b734226cb6 100644 --- a/plc4go/protocols/opcua/readwrite/model/WriteRequest.go +++ b/plc4go/protocols/opcua/readwrite/model/WriteRequest.go @@ -193,13 +193,13 @@ func WriteRequestParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffe return nil, errors.Wrap(pullErr, "Error pulling for nodesToWrite") } // Count array - nodesToWrite := make([]ExtensionObjectDefinition, noOfNodesToWrite) + nodesToWrite := make([]ExtensionObjectDefinition, utils.Max(noOfNodesToWrite, 0)) // This happens when the size is set conditional to 0 if len(nodesToWrite) == 0 { nodesToWrite = nil } { - _numItems := uint16(noOfNodesToWrite) + _numItems := uint16(utils.Max(noOfNodesToWrite, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/WriteResponse.go b/plc4go/protocols/opcua/readwrite/model/WriteResponse.go index 74682674c28..f8dbed5687f 100644 --- a/plc4go/protocols/opcua/readwrite/model/WriteResponse.go +++ b/plc4go/protocols/opcua/readwrite/model/WriteResponse.go @@ -222,13 +222,13 @@ func WriteResponseParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuff return nil, errors.Wrap(pullErr, "Error pulling for results") } // Count array - results := make([]StatusCode, noOfResults) + results := make([]StatusCode, utils.Max(noOfResults, 0)) // This happens when the size is set conditional to 0 if len(results) == 0 { results = nil } { - _numItems := uint16(noOfResults) + _numItems := uint16(utils.Max(noOfResults, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx @@ -256,13 +256,13 @@ func WriteResponseParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuff return nil, errors.Wrap(pullErr, "Error pulling for diagnosticInfos") } // Count array - diagnosticInfos := make([]DiagnosticInfo, noOfDiagnosticInfos) + diagnosticInfos := make([]DiagnosticInfo, utils.Max(noOfDiagnosticInfos, 0)) // This happens when the size is set conditional to 0 if len(diagnosticInfos) == 0 { diagnosticInfos = nil } { - _numItems := uint16(noOfDiagnosticInfos) + _numItems := uint16(utils.Max(noOfDiagnosticInfos, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/opcua/readwrite/model/XmlElement.go b/plc4go/protocols/opcua/readwrite/model/XmlElement.go index a82677de81f..86228106242 100644 --- a/plc4go/protocols/opcua/readwrite/model/XmlElement.go +++ b/plc4go/protocols/opcua/readwrite/model/XmlElement.go @@ -136,13 +136,13 @@ func XmlElementParseWithBuffer(ctx context.Context, readBuffer utils.ReadBuffer) return nil, errors.Wrap(pullErr, "Error pulling for value") } // Count array - value := make([]string, length) + value := make([]string, utils.Max(length, 0)) // This happens when the size is set conditional to 0 if len(value) == 0 { value = nil } { - _numItems := uint16(length) + _numItems := uint16(utils.Max(length, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/Alarm8MessageQueryType.go b/plc4go/protocols/s7/readwrite/model/Alarm8MessageQueryType.go index 361be39f054..db70c1ecaa2 100644 --- a/plc4go/protocols/s7/readwrite/model/Alarm8MessageQueryType.go +++ b/plc4go/protocols/s7/readwrite/model/Alarm8MessageQueryType.go @@ -221,13 +221,13 @@ func Alarm8MessageQueryTypeParseWithBuffer(ctx context.Context, readBuffer utils return nil, errors.Wrap(pullErr, "Error pulling for messageObjects") } // Count array - messageObjects := make([]AlarmMessageObjectQueryType, uint16(byteCount)/uint16(uint16(12))) + messageObjects := make([]AlarmMessageObjectQueryType, utils.Max(uint16(byteCount)/uint16(uint16(12)), 0)) // This happens when the size is set conditional to 0 if len(messageObjects) == 0 { messageObjects = nil } { - _numItems := uint16(uint16(byteCount) / uint16(uint16(12))) + _numItems := uint16(utils.Max(uint16(byteCount)/uint16(uint16(12)), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/AlarmMessageAckPushType.go b/plc4go/protocols/s7/readwrite/model/AlarmMessageAckPushType.go index b98569fb39e..a224e10b6e7 100644 --- a/plc4go/protocols/s7/readwrite/model/AlarmMessageAckPushType.go +++ b/plc4go/protocols/s7/readwrite/model/AlarmMessageAckPushType.go @@ -181,13 +181,13 @@ func AlarmMessageAckPushTypeParseWithBuffer(ctx context.Context, readBuffer util return nil, errors.Wrap(pullErr, "Error pulling for messageObjects") } // Count array - messageObjects := make([]AlarmMessageAckObjectPushType, numberOfObjects) + messageObjects := make([]AlarmMessageAckObjectPushType, utils.Max(numberOfObjects, 0)) // This happens when the size is set conditional to 0 if len(messageObjects) == 0 { messageObjects = nil } { - _numItems := uint16(numberOfObjects) + _numItems := uint16(utils.Max(numberOfObjects, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/AlarmMessageAckResponseType.go b/plc4go/protocols/s7/readwrite/model/AlarmMessageAckResponseType.go index 66ec0758fac..b3d240fcb19 100644 --- a/plc4go/protocols/s7/readwrite/model/AlarmMessageAckResponseType.go +++ b/plc4go/protocols/s7/readwrite/model/AlarmMessageAckResponseType.go @@ -153,13 +153,13 @@ func AlarmMessageAckResponseTypeParseWithBuffer(ctx context.Context, readBuffer return nil, errors.Wrap(pullErr, "Error pulling for messageObjects") } // Count array - messageObjects := make([]uint8, numberOfObjects) + messageObjects := make([]uint8, utils.Max(numberOfObjects, 0)) // This happens when the size is set conditional to 0 if len(messageObjects) == 0 { messageObjects = nil } { - _numItems := uint16(numberOfObjects) + _numItems := uint16(utils.Max(numberOfObjects, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/AlarmMessageAckType.go b/plc4go/protocols/s7/readwrite/model/AlarmMessageAckType.go index dac07472e4d..03b28e08814 100644 --- a/plc4go/protocols/s7/readwrite/model/AlarmMessageAckType.go +++ b/plc4go/protocols/s7/readwrite/model/AlarmMessageAckType.go @@ -158,13 +158,13 @@ func AlarmMessageAckTypeParseWithBuffer(ctx context.Context, readBuffer utils.Re return nil, errors.Wrap(pullErr, "Error pulling for messageObjects") } // Count array - messageObjects := make([]AlarmMessageObjectAckType, numberOfObjects) + messageObjects := make([]AlarmMessageObjectAckType, utils.Max(numberOfObjects, 0)) // This happens when the size is set conditional to 0 if len(messageObjects) == 0 { messageObjects = nil } { - _numItems := uint16(numberOfObjects) + _numItems := uint16(utils.Max(numberOfObjects, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/AlarmMessageObjectPushType.go b/plc4go/protocols/s7/readwrite/model/AlarmMessageObjectPushType.go index 9b26b7913dc..e2adebdf07c 100644 --- a/plc4go/protocols/s7/readwrite/model/AlarmMessageObjectPushType.go +++ b/plc4go/protocols/s7/readwrite/model/AlarmMessageObjectPushType.go @@ -318,13 +318,13 @@ func AlarmMessageObjectPushTypeParseWithBuffer(ctx context.Context, readBuffer u return nil, errors.Wrap(pullErr, "Error pulling for AssociatedValues") } // Count array - AssociatedValues := make([]AssociatedValueType, numberOfValues) + AssociatedValues := make([]AssociatedValueType, utils.Max(numberOfValues, 0)) // This happens when the size is set conditional to 0 if len(AssociatedValues) == 0 { AssociatedValues = nil } { - _numItems := uint16(numberOfValues) + _numItems := uint16(utils.Max(numberOfValues, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/AlarmMessagePushType.go b/plc4go/protocols/s7/readwrite/model/AlarmMessagePushType.go index 725d2e7d1dc..73447625d0e 100644 --- a/plc4go/protocols/s7/readwrite/model/AlarmMessagePushType.go +++ b/plc4go/protocols/s7/readwrite/model/AlarmMessagePushType.go @@ -181,13 +181,13 @@ func AlarmMessagePushTypeParseWithBuffer(ctx context.Context, readBuffer utils.R return nil, errors.Wrap(pullErr, "Error pulling for messageObjects") } // Count array - messageObjects := make([]AlarmMessageObjectPushType, numberOfObjects) + messageObjects := make([]AlarmMessageObjectPushType, utils.Max(numberOfObjects, 0)) // This happens when the size is set conditional to 0 if len(messageObjects) == 0 { messageObjects = nil } { - _numItems := uint16(numberOfObjects) + _numItems := uint16(utils.Max(numberOfObjects, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/AlarmMessageQueryType.go b/plc4go/protocols/s7/readwrite/model/AlarmMessageQueryType.go index b1310cb6710..93159b650d0 100644 --- a/plc4go/protocols/s7/readwrite/model/AlarmMessageQueryType.go +++ b/plc4go/protocols/s7/readwrite/model/AlarmMessageQueryType.go @@ -232,13 +232,13 @@ func AlarmMessageQueryTypeParseWithBuffer(ctx context.Context, readBuffer utils. return nil, errors.Wrap(pullErr, "Error pulling for messageObjects") } // Count array - messageObjects := make([]AlarmMessageObjectQueryType, numberOfObjects) + messageObjects := make([]AlarmMessageObjectQueryType, utils.Max(numberOfObjects, 0)) // This happens when the size is set conditional to 0 if len(messageObjects) == 0 { messageObjects = nil } { - _numItems := uint16(numberOfObjects) + _numItems := uint16(utils.Max(numberOfObjects, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/AssociatedQueryValueType.go b/plc4go/protocols/s7/readwrite/model/AssociatedQueryValueType.go index a7a97731f85..a5b74a695a2 100644 --- a/plc4go/protocols/s7/readwrite/model/AssociatedQueryValueType.go +++ b/plc4go/protocols/s7/readwrite/model/AssociatedQueryValueType.go @@ -182,13 +182,13 @@ func AssociatedQueryValueTypeParseWithBuffer(ctx context.Context, readBuffer uti return nil, errors.Wrap(pullErr, "Error pulling for data") } // Count array - data := make([]uint8, valueLength) + data := make([]uint8, utils.Max(valueLength, 0)) // This happens when the size is set conditional to 0 if len(data) == 0 { data = nil } { - _numItems := uint16(valueLength) + _numItems := uint16(utils.Max(valueLength, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/AssociatedValueType.go b/plc4go/protocols/s7/readwrite/model/AssociatedValueType.go index 99d238ff9ec..9bb03d24a27 100644 --- a/plc4go/protocols/s7/readwrite/model/AssociatedValueType.go +++ b/plc4go/protocols/s7/readwrite/model/AssociatedValueType.go @@ -185,13 +185,13 @@ func AssociatedValueTypeParseWithBuffer(ctx context.Context, readBuffer utils.Re return nil, errors.Wrap(pullErr, "Error pulling for data") } // Count array - data := make([]uint8, EventItemLength(ctx, readBuffer, valueLength)) + data := make([]uint8, utils.Max(EventItemLength(ctx, readBuffer, valueLength), 0)) // This happens when the size is set conditional to 0 if len(data) == 0 { data = nil } { - _numItems := uint16(EventItemLength(ctx, readBuffer, valueLength)) + _numItems := uint16(utils.Max(EventItemLength(ctx, readBuffer, valueLength), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/CycServiceItemDbReadType.go b/plc4go/protocols/s7/readwrite/model/CycServiceItemDbReadType.go index 8035c90c76f..f43b7e930a9 100644 --- a/plc4go/protocols/s7/readwrite/model/CycServiceItemDbReadType.go +++ b/plc4go/protocols/s7/readwrite/model/CycServiceItemDbReadType.go @@ -168,13 +168,13 @@ func CycServiceItemDbReadTypeParseWithBuffer(ctx context.Context, readBuffer uti return nil, errors.Wrap(pullErr, "Error pulling for items") } // Count array - items := make([]SubItem, numberOfAreas) + items := make([]SubItem, utils.Max(numberOfAreas, 0)) // This happens when the size is set conditional to 0 if len(items) == 0 { items = nil } { - _numItems := uint16(numberOfAreas) + _numItems := uint16(utils.Max(numberOfAreas, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/S7ParameterReadVarRequest.go b/plc4go/protocols/s7/readwrite/model/S7ParameterReadVarRequest.go index 37475235f50..3becf027fa4 100644 --- a/plc4go/protocols/s7/readwrite/model/S7ParameterReadVarRequest.go +++ b/plc4go/protocols/s7/readwrite/model/S7ParameterReadVarRequest.go @@ -165,13 +165,13 @@ func S7ParameterReadVarRequestParseWithBuffer(ctx context.Context, readBuffer ut return nil, errors.Wrap(pullErr, "Error pulling for items") } // Count array - items := make([]S7VarRequestParameterItem, numItems) + items := make([]S7VarRequestParameterItem, utils.Max(numItems, 0)) // This happens when the size is set conditional to 0 if len(items) == 0 { items = nil } { - _numItems := uint16(numItems) + _numItems := uint16(utils.Max(numItems, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/S7ParameterUserData.go b/plc4go/protocols/s7/readwrite/model/S7ParameterUserData.go index ea8eae42827..0fe44247c1b 100644 --- a/plc4go/protocols/s7/readwrite/model/S7ParameterUserData.go +++ b/plc4go/protocols/s7/readwrite/model/S7ParameterUserData.go @@ -165,13 +165,13 @@ func S7ParameterUserDataParseWithBuffer(ctx context.Context, readBuffer utils.Re return nil, errors.Wrap(pullErr, "Error pulling for items") } // Count array - items := make([]S7ParameterUserDataItem, numItems) + items := make([]S7ParameterUserDataItem, utils.Max(numItems, 0)) // This happens when the size is set conditional to 0 if len(items) == 0 { items = nil } { - _numItems := uint16(numItems) + _numItems := uint16(utils.Max(numItems, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/S7ParameterWriteVarRequest.go b/plc4go/protocols/s7/readwrite/model/S7ParameterWriteVarRequest.go index 48a2b69216d..2551bba4e4a 100644 --- a/plc4go/protocols/s7/readwrite/model/S7ParameterWriteVarRequest.go +++ b/plc4go/protocols/s7/readwrite/model/S7ParameterWriteVarRequest.go @@ -165,13 +165,13 @@ func S7ParameterWriteVarRequestParseWithBuffer(ctx context.Context, readBuffer u return nil, errors.Wrap(pullErr, "Error pulling for items") } // Count array - items := make([]S7VarRequestParameterItem, numItems) + items := make([]S7VarRequestParameterItem, utils.Max(numItems, 0)) // This happens when the size is set conditional to 0 if len(items) == 0 { items = nil } { - _numItems := uint16(numItems) + _numItems := uint16(utils.Max(numItems, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/S7PayloadReadVarResponse.go b/plc4go/protocols/s7/readwrite/model/S7PayloadReadVarResponse.go index 819b7f3d69d..2d7f9f7091d 100644 --- a/plc4go/protocols/s7/readwrite/model/S7PayloadReadVarResponse.go +++ b/plc4go/protocols/s7/readwrite/model/S7PayloadReadVarResponse.go @@ -155,13 +155,13 @@ func S7PayloadReadVarResponseParseWithBuffer(ctx context.Context, readBuffer uti return nil, errors.Wrap(pullErr, "Error pulling for items") } // Count array - items := make([]S7VarPayloadDataItem, CastS7ParameterReadVarResponse(parameter).GetNumItems()) + items := make([]S7VarPayloadDataItem, utils.Max(CastS7ParameterReadVarResponse(parameter).GetNumItems(), 0)) // This happens when the size is set conditional to 0 if len(items) == 0 { items = nil } { - _numItems := uint16(CastS7ParameterReadVarResponse(parameter).GetNumItems()) + _numItems := uint16(utils.Max(CastS7ParameterReadVarResponse(parameter).GetNumItems(), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/S7PayloadUserData.go b/plc4go/protocols/s7/readwrite/model/S7PayloadUserData.go index 1295e81e968..3ddcc278ac7 100644 --- a/plc4go/protocols/s7/readwrite/model/S7PayloadUserData.go +++ b/plc4go/protocols/s7/readwrite/model/S7PayloadUserData.go @@ -155,13 +155,13 @@ func S7PayloadUserDataParseWithBuffer(ctx context.Context, readBuffer utils.Read return nil, errors.Wrap(pullErr, "Error pulling for items") } // Count array - items := make([]S7PayloadUserDataItem, uint16(len(CastS7ParameterUserData(parameter).GetItems()))) + items := make([]S7PayloadUserDataItem, utils.Max(uint16(len(CastS7ParameterUserData(parameter).GetItems())), 0)) // This happens when the size is set conditional to 0 if len(items) == 0 { items = nil } { - _numItems := uint16(uint16(len(CastS7ParameterUserData(parameter).GetItems()))) + _numItems := uint16(utils.Max(uint16(len(CastS7ParameterUserData(parameter).GetItems())), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCpuFunctionAlarmAckRequest.go b/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCpuFunctionAlarmAckRequest.go index 899db192722..26275996018 100644 --- a/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCpuFunctionAlarmAckRequest.go +++ b/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCpuFunctionAlarmAckRequest.go @@ -201,13 +201,13 @@ func S7PayloadUserDataItemCpuFunctionAlarmAckRequestParseWithBuffer(ctx context. return nil, errors.Wrap(pullErr, "Error pulling for messageObjects") } // Count array - messageObjects := make([]AlarmMessageObjectAckType, numberOfObjects) + messageObjects := make([]AlarmMessageObjectAckType, utils.Max(numberOfObjects, 0)) // This happens when the size is set conditional to 0 if len(messageObjects) == 0 { messageObjects = nil } { - _numItems := uint16(numberOfObjects) + _numItems := uint16(utils.Max(numberOfObjects, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCpuFunctionAlarmAckResponse.go b/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCpuFunctionAlarmAckResponse.go index ee8f02b0b49..30164eebf0b 100644 --- a/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCpuFunctionAlarmAckResponse.go +++ b/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCpuFunctionAlarmAckResponse.go @@ -186,13 +186,13 @@ func S7PayloadUserDataItemCpuFunctionAlarmAckResponseParseWithBuffer(ctx context return nil, errors.Wrap(pullErr, "Error pulling for messageObjects") } // Count array - messageObjects := make([]uint8, numberOfObjects) + messageObjects := make([]uint8, utils.Max(numberOfObjects, 0)) // This happens when the size is set conditional to 0 if len(messageObjects) == 0 { messageObjects = nil } { - _numItems := uint16(numberOfObjects) + _numItems := uint16(utils.Max(numberOfObjects, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCyclicServicesChangeDrivenPush.go b/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCyclicServicesChangeDrivenPush.go index 896ef597631..5e03e0ca7b1 100644 --- a/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCyclicServicesChangeDrivenPush.go +++ b/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCyclicServicesChangeDrivenPush.go @@ -181,13 +181,13 @@ func S7PayloadUserDataItemCyclicServicesChangeDrivenPushParseWithBuffer(ctx cont return nil, errors.Wrap(pullErr, "Error pulling for items") } // Count array - items := make([]AssociatedQueryValueType, itemsCount) + items := make([]AssociatedQueryValueType, utils.Max(itemsCount, 0)) // This happens when the size is set conditional to 0 if len(items) == 0 { items = nil } { - _numItems := uint16(itemsCount) + _numItems := uint16(utils.Max(itemsCount, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCyclicServicesChangeDrivenSubscribeResponse.go b/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCyclicServicesChangeDrivenSubscribeResponse.go index 89096fffae1..967cf95b827 100644 --- a/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCyclicServicesChangeDrivenSubscribeResponse.go +++ b/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCyclicServicesChangeDrivenSubscribeResponse.go @@ -181,13 +181,13 @@ func S7PayloadUserDataItemCyclicServicesChangeDrivenSubscribeResponseParseWithBu return nil, errors.Wrap(pullErr, "Error pulling for items") } // Count array - items := make([]AssociatedQueryValueType, itemsCount) + items := make([]AssociatedQueryValueType, utils.Max(itemsCount, 0)) // This happens when the size is set conditional to 0 if len(items) == 0 { items = nil } { - _numItems := uint16(itemsCount) + _numItems := uint16(utils.Max(itemsCount, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCyclicServicesPush.go b/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCyclicServicesPush.go index b82316e03a3..42aaef2876f 100644 --- a/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCyclicServicesPush.go +++ b/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCyclicServicesPush.go @@ -181,13 +181,13 @@ func S7PayloadUserDataItemCyclicServicesPushParseWithBuffer(ctx context.Context, return nil, errors.Wrap(pullErr, "Error pulling for items") } // Count array - items := make([]AssociatedValueType, itemsCount) + items := make([]AssociatedValueType, utils.Max(itemsCount, 0)) // This happens when the size is set conditional to 0 if len(items) == 0 { items = nil } { - _numItems := uint16(itemsCount) + _numItems := uint16(utils.Max(itemsCount, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCyclicServicesSubscribeRequest.go b/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCyclicServicesSubscribeRequest.go index 95c3eeec247..e886ce6af3d 100644 --- a/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCyclicServicesSubscribeRequest.go +++ b/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCyclicServicesSubscribeRequest.go @@ -223,13 +223,13 @@ func S7PayloadUserDataItemCyclicServicesSubscribeRequestParseWithBuffer(ctx cont return nil, errors.Wrap(pullErr, "Error pulling for item") } // Count array - item := make([]CycServiceItemType, itemsCount) + item := make([]CycServiceItemType, utils.Max(itemsCount, 0)) // This happens when the size is set conditional to 0 if len(item) == 0 { item = nil } { - _numItems := uint16(itemsCount) + _numItems := uint16(utils.Max(itemsCount, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCyclicServicesSubscribeResponse.go b/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCyclicServicesSubscribeResponse.go index 6ce70ce11df..4eb7d21c6a5 100644 --- a/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCyclicServicesSubscribeResponse.go +++ b/plc4go/protocols/s7/readwrite/model/S7PayloadUserDataItemCyclicServicesSubscribeResponse.go @@ -181,13 +181,13 @@ func S7PayloadUserDataItemCyclicServicesSubscribeResponseParseWithBuffer(ctx con return nil, errors.Wrap(pullErr, "Error pulling for items") } // Count array - items := make([]AssociatedValueType, itemsCount) + items := make([]AssociatedValueType, utils.Max(itemsCount, 0)) // This happens when the size is set conditional to 0 if len(items) == 0 { items = nil } { - _numItems := uint16(itemsCount) + _numItems := uint16(utils.Max(itemsCount, 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/S7PayloadWriteVarRequest.go b/plc4go/protocols/s7/readwrite/model/S7PayloadWriteVarRequest.go index 7c15cb08cda..bd3ed7c4795 100644 --- a/plc4go/protocols/s7/readwrite/model/S7PayloadWriteVarRequest.go +++ b/plc4go/protocols/s7/readwrite/model/S7PayloadWriteVarRequest.go @@ -155,13 +155,13 @@ func S7PayloadWriteVarRequestParseWithBuffer(ctx context.Context, readBuffer uti return nil, errors.Wrap(pullErr, "Error pulling for items") } // Count array - items := make([]S7VarPayloadDataItem, uint16(len(CastS7ParameterWriteVarRequest(parameter).GetItems()))) + items := make([]S7VarPayloadDataItem, utils.Max(uint16(len(CastS7ParameterWriteVarRequest(parameter).GetItems())), 0)) // This happens when the size is set conditional to 0 if len(items) == 0 { items = nil } { - _numItems := uint16(uint16(len(CastS7ParameterWriteVarRequest(parameter).GetItems()))) + _numItems := uint16(utils.Max(uint16(len(CastS7ParameterWriteVarRequest(parameter).GetItems())), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/protocols/s7/readwrite/model/S7PayloadWriteVarResponse.go b/plc4go/protocols/s7/readwrite/model/S7PayloadWriteVarResponse.go index ebdf5ee4374..c260803cf3a 100644 --- a/plc4go/protocols/s7/readwrite/model/S7PayloadWriteVarResponse.go +++ b/plc4go/protocols/s7/readwrite/model/S7PayloadWriteVarResponse.go @@ -155,13 +155,13 @@ func S7PayloadWriteVarResponseParseWithBuffer(ctx context.Context, readBuffer ut return nil, errors.Wrap(pullErr, "Error pulling for items") } // Count array - items := make([]S7VarPayloadStatusItem, CastS7ParameterWriteVarResponse(parameter).GetNumItems()) + items := make([]S7VarPayloadStatusItem, utils.Max(CastS7ParameterWriteVarResponse(parameter).GetNumItems(), 0)) // This happens when the size is set conditional to 0 if len(items) == 0 { items = nil } { - _numItems := uint16(CastS7ParameterWriteVarResponse(parameter).GetNumItems()) + _numItems := uint16(utils.Max(CastS7ParameterWriteVarResponse(parameter).GetNumItems(), 0)) for _curItem := uint16(0); _curItem < _numItems; _curItem++ { arrayCtx := utils.CreateArrayContext(ctx, int(_numItems), int(_curItem)) _ = arrayCtx diff --git a/plc4go/spi/default/DefaultCodec.go b/plc4go/spi/default/DefaultCodec.go index 2b992bcd5d4..0a7ecc1de2e 100644 --- a/plc4go/spi/default/DefaultCodec.go +++ b/plc4go/spi/default/DefaultCodec.go @@ -307,13 +307,23 @@ func (m *defaultCodec) Work() { } }() + lastLoopTime := time.Now() // Start an endless loop mainLoop: for m.running.Load() { + if processingTime := time.Since(lastLoopTime); processingTime < 10*time.Millisecond { + // Ensure that we leave at least 10ms between loops to not burn cycles + sleepTime := 10*time.Millisecond - processingTime + workerLog.Trace().Stringer("sleepTime", sleepTime).Msg("sleeping") // we use stringer instead of Dur to have it a bit more readable + time.Sleep(sleepTime) + } else { + workerLog.Debug().Stringer("processingTime", processingTime).Msg("no need to sleep") // we use stringer instead of Dur to have it a bit more readable + } workerLog.Trace().Msg("Working") // Check for any expired expectations. // (Doing this outside the loop lets us expire expectations even if no input is coming in) now := time.Now() + lastLoopTime = now // Guard against empty expectations m.expectationsChangeMutex.RLock() @@ -321,8 +331,6 @@ mainLoop: m.expectationsChangeMutex.RUnlock() if numberOfExpectations <= 0 && m.customMessageHandling == nil { workerLog.Trace().Msg("no available expectations") - // Sleep for 10ms - time.Sleep(10 * time.Millisecond) continue mainLoop } m.TimeoutExpectations(now) @@ -353,14 +361,10 @@ mainLoop: } if err != nil { workerLog.Error().Err(err).Msg("got an error reading from transport") - time.Sleep(10 * time.Millisecond) continue mainLoop } if message == nil { workerLog.Trace().Msg("Not enough data yet") - // Sleep for 10ms before checking again, in order to not - // consume 100% CPU Power. - time.Sleep(10 * time.Millisecond) continue mainLoop } workerLog.Trace().Stringer("message", message).Msg("got message") diff --git a/plc4go/spi/default/DefaultCodec_test.go b/plc4go/spi/default/DefaultCodec_test.go index a30ab1312f4..46a65beef18 100644 --- a/plc4go/spi/default/DefaultCodec_test.go +++ b/plc4go/spi/default/DefaultCodec_test.go @@ -1084,6 +1084,8 @@ func Test_defaultCodec_TimeoutExpectations(t *testing.T) { log: testutils.ProduceTestingLogger(t), } m.TimeoutExpectations(tt.args.now) + // TODO: handle error is called async so we sleep here a bit. Not sure if we want to sync something here at all + time.Sleep(100 * time.Millisecond) }) } } diff --git a/plc4go/spi/default/mock_CustomMessageHandler_test.go b/plc4go/spi/default/mock_CustomMessageHandler_test.go index 0673083643b..b51ba45b9e9 100644 --- a/plc4go/spi/default/mock_CustomMessageHandler_test.go +++ b/plc4go/spi/default/mock_CustomMessageHandler_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package _default diff --git a/plc4go/spi/default/mock_DefaultBrowserRequirements_test.go b/plc4go/spi/default/mock_DefaultBrowserRequirements_test.go index a17847165eb..116a1c3b258 100644 --- a/plc4go/spi/default/mock_DefaultBrowserRequirements_test.go +++ b/plc4go/spi/default/mock_DefaultBrowserRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package _default diff --git a/plc4go/spi/default/mock_DefaultBrowser_test.go b/plc4go/spi/default/mock_DefaultBrowser_test.go index 3baf41e78ee..f39fa4d67d9 100644 --- a/plc4go/spi/default/mock_DefaultBrowser_test.go +++ b/plc4go/spi/default/mock_DefaultBrowser_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package _default diff --git a/plc4go/spi/default/mock_DefaultCodecRequirements_test.go b/plc4go/spi/default/mock_DefaultCodecRequirements_test.go index f88c7ff205e..f77a3f467a1 100644 --- a/plc4go/spi/default/mock_DefaultCodecRequirements_test.go +++ b/plc4go/spi/default/mock_DefaultCodecRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package _default diff --git a/plc4go/spi/default/mock_DefaultCodec_test.go b/plc4go/spi/default/mock_DefaultCodec_test.go index 673ff72a16c..16fafe7882c 100644 --- a/plc4go/spi/default/mock_DefaultCodec_test.go +++ b/plc4go/spi/default/mock_DefaultCodec_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package _default diff --git a/plc4go/spi/default/mock_DefaultConnectionRequirements_test.go b/plc4go/spi/default/mock_DefaultConnectionRequirements_test.go index d365820836e..dafa3224325 100644 --- a/plc4go/spi/default/mock_DefaultConnectionRequirements_test.go +++ b/plc4go/spi/default/mock_DefaultConnectionRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package _default diff --git a/plc4go/spi/default/mock_DefaultConnection_test.go b/plc4go/spi/default/mock_DefaultConnection_test.go index ca400ab4c13..df833f30355 100644 --- a/plc4go/spi/default/mock_DefaultConnection_test.go +++ b/plc4go/spi/default/mock_DefaultConnection_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package _default diff --git a/plc4go/spi/default/mock_DefaultDriverRequirements_test.go b/plc4go/spi/default/mock_DefaultDriverRequirements_test.go index 37d33a6895a..60aba73be84 100644 --- a/plc4go/spi/default/mock_DefaultDriverRequirements_test.go +++ b/plc4go/spi/default/mock_DefaultDriverRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package _default diff --git a/plc4go/spi/default/mock_DefaultDriver_test.go b/plc4go/spi/default/mock_DefaultDriver_test.go index f83819dc834..25427919e86 100644 --- a/plc4go/spi/default/mock_DefaultDriver_test.go +++ b/plc4go/spi/default/mock_DefaultDriver_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package _default diff --git a/plc4go/spi/default/mock_DefaultPlcConnectionCloseResult_test.go b/plc4go/spi/default/mock_DefaultPlcConnectionCloseResult_test.go index 2e960c3d54c..75595e0fc77 100644 --- a/plc4go/spi/default/mock_DefaultPlcConnectionCloseResult_test.go +++ b/plc4go/spi/default/mock_DefaultPlcConnectionCloseResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package _default diff --git a/plc4go/spi/default/mock_DefaultPlcConnectionConnectResult_test.go b/plc4go/spi/default/mock_DefaultPlcConnectionConnectResult_test.go index 92ad32d5724..ea3de01eed1 100644 --- a/plc4go/spi/default/mock_DefaultPlcConnectionConnectResult_test.go +++ b/plc4go/spi/default/mock_DefaultPlcConnectionConnectResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package _default diff --git a/plc4go/spi/default/mock_DefaultPlcConnectionPingResult_test.go b/plc4go/spi/default/mock_DefaultPlcConnectionPingResult_test.go index 780327b5f85..36b93d7790f 100644 --- a/plc4go/spi/default/mock_DefaultPlcConnectionPingResult_test.go +++ b/plc4go/spi/default/mock_DefaultPlcConnectionPingResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package _default diff --git a/plc4go/spi/default/mock_Expectation_test.go b/plc4go/spi/default/mock_Expectation_test.go index 8926fee1231..b84cfb6d6b3 100644 --- a/plc4go/spi/default/mock_Expectation_test.go +++ b/plc4go/spi/default/mock_Expectation_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package _default diff --git a/plc4go/spi/default/mock_MessageCodec_test.go b/plc4go/spi/default/mock_MessageCodec_test.go index 75316b78bd1..5547bd24b3f 100644 --- a/plc4go/spi/default/mock_MessageCodec_test.go +++ b/plc4go/spi/default/mock_MessageCodec_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package _default diff --git a/plc4go/spi/default/mock_Message_test.go b/plc4go/spi/default/mock_Message_test.go index 0e3465e7b8e..d202943dc42 100644 --- a/plc4go/spi/default/mock_Message_test.go +++ b/plc4go/spi/default/mock_Message_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package _default diff --git a/plc4go/spi/default/mock_PlcConnectionConnectResult_test.go b/plc4go/spi/default/mock_PlcConnectionConnectResult_test.go index 4dc6904ab0d..08d4ffea6eb 100644 --- a/plc4go/spi/default/mock_PlcConnectionConnectResult_test.go +++ b/plc4go/spi/default/mock_PlcConnectionConnectResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package _default diff --git a/plc4go/spi/default/mock_PlcConnection_test.go b/plc4go/spi/default/mock_PlcConnection_test.go index 62d79b76cce..2cd705c4984 100644 --- a/plc4go/spi/default/mock_PlcConnection_test.go +++ b/plc4go/spi/default/mock_PlcConnection_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package _default diff --git a/plc4go/spi/default/mock_PlcQuery_test.go b/plc4go/spi/default/mock_PlcQuery_test.go index 910f55b9031..4f85ed49711 100644 --- a/plc4go/spi/default/mock_PlcQuery_test.go +++ b/plc4go/spi/default/mock_PlcQuery_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package _default diff --git a/plc4go/spi/default/mock_PlcTagHandler_test.go b/plc4go/spi/default/mock_PlcTagHandler_test.go index 2a0ea804842..db640edb75e 100644 --- a/plc4go/spi/default/mock_PlcTagHandler_test.go +++ b/plc4go/spi/default/mock_PlcTagHandler_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package _default diff --git a/plc4go/spi/default/mock_TransportInstance_test.go b/plc4go/spi/default/mock_TransportInstance_test.go index 60289b1ab89..fa686baf509 100644 --- a/plc4go/spi/default/mock_TransportInstance_test.go +++ b/plc4go/spi/default/mock_TransportInstance_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package _default diff --git a/plc4go/spi/interceptors/mock_PlcReadRequestResult_test.go b/plc4go/spi/interceptors/mock_PlcReadRequestResult_test.go index ed805e3001b..a64a99db77f 100644 --- a/plc4go/spi/interceptors/mock_PlcReadRequestResult_test.go +++ b/plc4go/spi/interceptors/mock_PlcReadRequestResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package interceptors diff --git a/plc4go/spi/interceptors/mock_PlcReadRequest_test.go b/plc4go/spi/interceptors/mock_PlcReadRequest_test.go index 579c450f2cb..2321b576735 100644 --- a/plc4go/spi/interceptors/mock_PlcReadRequest_test.go +++ b/plc4go/spi/interceptors/mock_PlcReadRequest_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package interceptors diff --git a/plc4go/spi/interceptors/mock_PlcReadResponse_test.go b/plc4go/spi/interceptors/mock_PlcReadResponse_test.go index 7107dc00e1c..f99b1524b71 100644 --- a/plc4go/spi/interceptors/mock_PlcReadResponse_test.go +++ b/plc4go/spi/interceptors/mock_PlcReadResponse_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package interceptors diff --git a/plc4go/spi/interceptors/mock_PlcWriteRequestResult_test.go b/plc4go/spi/interceptors/mock_PlcWriteRequestResult_test.go index 1007d10adcc..de9f97cdd4d 100644 --- a/plc4go/spi/interceptors/mock_PlcWriteRequestResult_test.go +++ b/plc4go/spi/interceptors/mock_PlcWriteRequestResult_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package interceptors diff --git a/plc4go/spi/interceptors/mock_PlcWriteRequest_test.go b/plc4go/spi/interceptors/mock_PlcWriteRequest_test.go index 1abdc0aabf4..0d480898b5f 100644 --- a/plc4go/spi/interceptors/mock_PlcWriteRequest_test.go +++ b/plc4go/spi/interceptors/mock_PlcWriteRequest_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package interceptors diff --git a/plc4go/spi/interceptors/mock_PlcWriteResponse_test.go b/plc4go/spi/interceptors/mock_PlcWriteResponse_test.go index 0c10c15facf..c50c812d7cc 100644 --- a/plc4go/spi/interceptors/mock_PlcWriteResponse_test.go +++ b/plc4go/spi/interceptors/mock_PlcWriteResponse_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package interceptors diff --git a/plc4go/spi/interceptors/mock_ReadRequestInterceptorExposer_test.go b/plc4go/spi/interceptors/mock_ReadRequestInterceptorExposer_test.go index ba794e1ca0a..f1b44accba8 100644 --- a/plc4go/spi/interceptors/mock_ReadRequestInterceptorExposer_test.go +++ b/plc4go/spi/interceptors/mock_ReadRequestInterceptorExposer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package interceptors diff --git a/plc4go/spi/interceptors/mock_ReadRequestInterceptor_test.go b/plc4go/spi/interceptors/mock_ReadRequestInterceptor_test.go index 58b16c99c67..6657c89ba01 100644 --- a/plc4go/spi/interceptors/mock_ReadRequestInterceptor_test.go +++ b/plc4go/spi/interceptors/mock_ReadRequestInterceptor_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package interceptors diff --git a/plc4go/spi/interceptors/mock_ReaderExposer_test.go b/plc4go/spi/interceptors/mock_ReaderExposer_test.go index a4290cb7bcb..d4c0a7178e3 100644 --- a/plc4go/spi/interceptors/mock_ReaderExposer_test.go +++ b/plc4go/spi/interceptors/mock_ReaderExposer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package interceptors diff --git a/plc4go/spi/interceptors/mock_RequestInterceptor_test.go b/plc4go/spi/interceptors/mock_RequestInterceptor_test.go index c72c16ac9a9..0e381b5a209 100644 --- a/plc4go/spi/interceptors/mock_RequestInterceptor_test.go +++ b/plc4go/spi/interceptors/mock_RequestInterceptor_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package interceptors diff --git a/plc4go/spi/interceptors/mock_WriteRequestInterceptorExposer_test.go b/plc4go/spi/interceptors/mock_WriteRequestInterceptorExposer_test.go index c43c7c29a96..cce82583793 100644 --- a/plc4go/spi/interceptors/mock_WriteRequestInterceptorExposer_test.go +++ b/plc4go/spi/interceptors/mock_WriteRequestInterceptorExposer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package interceptors diff --git a/plc4go/spi/interceptors/mock_WriteRequestInterceptor_test.go b/plc4go/spi/interceptors/mock_WriteRequestInterceptor_test.go index f54df324b16..75f2a89a432 100644 --- a/plc4go/spi/interceptors/mock_WriteRequestInterceptor_test.go +++ b/plc4go/spi/interceptors/mock_WriteRequestInterceptor_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package interceptors diff --git a/plc4go/spi/interceptors/mock_WriterExposer_test.go b/plc4go/spi/interceptors/mock_WriterExposer_test.go index c79c5383ff9..08971fd5b65 100644 --- a/plc4go/spi/interceptors/mock_WriterExposer_test.go +++ b/plc4go/spi/interceptors/mock_WriterExposer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package interceptors diff --git a/plc4go/spi/interceptors/mock_readRequestFactory_test.go b/plc4go/spi/interceptors/mock_readRequestFactory_test.go index b1db55bd290..7a993611bef 100644 --- a/plc4go/spi/interceptors/mock_readRequestFactory_test.go +++ b/plc4go/spi/interceptors/mock_readRequestFactory_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package interceptors diff --git a/plc4go/spi/interceptors/mock_readResponseFactory_test.go b/plc4go/spi/interceptors/mock_readResponseFactory_test.go index 9de5a6b03dc..5ccbf2b7f42 100644 --- a/plc4go/spi/interceptors/mock_readResponseFactory_test.go +++ b/plc4go/spi/interceptors/mock_readResponseFactory_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package interceptors diff --git a/plc4go/spi/interceptors/mock_writeRequestFactory_test.go b/plc4go/spi/interceptors/mock_writeRequestFactory_test.go index 2ed2e3f4155..3a4d6454a5a 100644 --- a/plc4go/spi/interceptors/mock_writeRequestFactory_test.go +++ b/plc4go/spi/interceptors/mock_writeRequestFactory_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package interceptors diff --git a/plc4go/spi/interceptors/mock_writeResponseFactory_test.go b/plc4go/spi/interceptors/mock_writeResponseFactory_test.go index 44a727bc624..50563270c0e 100644 --- a/plc4go/spi/interceptors/mock_writeResponseFactory_test.go +++ b/plc4go/spi/interceptors/mock_writeResponseFactory_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package interceptors diff --git a/plc4go/spi/mock_AcceptsMessage_test.go b/plc4go/spi/mock_AcceptsMessage_test.go index 037cc871c10..39d42cd01fd 100644 --- a/plc4go/spi/mock_AcceptsMessage_test.go +++ b/plc4go/spi/mock_AcceptsMessage_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package spi diff --git a/plc4go/spi/mock_CompletableFuture_test.go b/plc4go/spi/mock_CompletableFuture_test.go index c98090a32ff..7a8817b0236 100644 --- a/plc4go/spi/mock_CompletableFuture_test.go +++ b/plc4go/spi/mock_CompletableFuture_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package spi diff --git a/plc4go/spi/mock_CompletionFuture_test.go b/plc4go/spi/mock_CompletionFuture_test.go index e683fc2ebb1..2294728b772 100644 --- a/plc4go/spi/mock_CompletionFuture_test.go +++ b/plc4go/spi/mock_CompletionFuture_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package spi diff --git a/plc4go/spi/mock_Expectation_test.go b/plc4go/spi/mock_Expectation_test.go index 2aaefd7f485..a97cc9786b3 100644 --- a/plc4go/spi/mock_Expectation_test.go +++ b/plc4go/spi/mock_Expectation_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package spi diff --git a/plc4go/spi/mock_HandleError_test.go b/plc4go/spi/mock_HandleError_test.go index 9582d447d92..6d8d4cebe18 100644 --- a/plc4go/spi/mock_HandleError_test.go +++ b/plc4go/spi/mock_HandleError_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package spi diff --git a/plc4go/spi/mock_HandleMessage_test.go b/plc4go/spi/mock_HandleMessage_test.go index 885a72721b3..e712c562a39 100644 --- a/plc4go/spi/mock_HandleMessage_test.go +++ b/plc4go/spi/mock_HandleMessage_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package spi diff --git a/plc4go/spi/mock_HandlerExposer_test.go b/plc4go/spi/mock_HandlerExposer_test.go index 88e8c8cca9a..9cdf40aa4e9 100644 --- a/plc4go/spi/mock_HandlerExposer_test.go +++ b/plc4go/spi/mock_HandlerExposer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package spi diff --git a/plc4go/spi/mock_MessageCodec_test.go b/plc4go/spi/mock_MessageCodec_test.go index 4b027bf2153..35f6aa86db8 100644 --- a/plc4go/spi/mock_MessageCodec_test.go +++ b/plc4go/spi/mock_MessageCodec_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package spi diff --git a/plc4go/spi/mock_Message_test.go b/plc4go/spi/mock_Message_test.go index f13c6ebcb3c..a2c42eee90f 100644 --- a/plc4go/spi/mock_Message_test.go +++ b/plc4go/spi/mock_Message_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package spi diff --git a/plc4go/spi/mock_PlcBrowser_test.go b/plc4go/spi/mock_PlcBrowser_test.go index 79f78fcb8a9..2b0a70798d7 100644 --- a/plc4go/spi/mock_PlcBrowser_test.go +++ b/plc4go/spi/mock_PlcBrowser_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package spi diff --git a/plc4go/spi/mock_PlcDiscoverer_test.go b/plc4go/spi/mock_PlcDiscoverer_test.go index a236cace625..45d31a6583f 100644 --- a/plc4go/spi/mock_PlcDiscoverer_test.go +++ b/plc4go/spi/mock_PlcDiscoverer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package spi diff --git a/plc4go/spi/mock_PlcReader_test.go b/plc4go/spi/mock_PlcReader_test.go index 53df1242d5f..55cbbdfa83b 100644 --- a/plc4go/spi/mock_PlcReader_test.go +++ b/plc4go/spi/mock_PlcReader_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package spi diff --git a/plc4go/spi/mock_PlcSubscriber_test.go b/plc4go/spi/mock_PlcSubscriber_test.go index 1af131cfed2..05acdde0004 100644 --- a/plc4go/spi/mock_PlcSubscriber_test.go +++ b/plc4go/spi/mock_PlcSubscriber_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package spi diff --git a/plc4go/spi/mock_PlcTagHandler_test.go b/plc4go/spi/mock_PlcTagHandler_test.go index 707708376f9..dd0e3828480 100644 --- a/plc4go/spi/mock_PlcTagHandler_test.go +++ b/plc4go/spi/mock_PlcTagHandler_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package spi diff --git a/plc4go/spi/mock_PlcValueHandler_test.go b/plc4go/spi/mock_PlcValueHandler_test.go index 5840f28595a..cde26483e99 100644 --- a/plc4go/spi/mock_PlcValueHandler_test.go +++ b/plc4go/spi/mock_PlcValueHandler_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package spi diff --git a/plc4go/spi/mock_PlcWriter_test.go b/plc4go/spi/mock_PlcWriter_test.go index 5586907e626..282d260b040 100644 --- a/plc4go/spi/mock_PlcWriter_test.go +++ b/plc4go/spi/mock_PlcWriter_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package spi diff --git a/plc4go/spi/mock_TransportAware_test.go b/plc4go/spi/mock_TransportAware_test.go index 050cc513c3c..d65de70662e 100644 --- a/plc4go/spi/mock_TransportAware_test.go +++ b/plc4go/spi/mock_TransportAware_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package spi diff --git a/plc4go/spi/mock_TransportInstanceExposer_test.go b/plc4go/spi/mock_TransportInstanceExposer_test.go index 7107d24df29..d634c3785c3 100644 --- a/plc4go/spi/mock_TransportInstanceExposer_test.go +++ b/plc4go/spi/mock_TransportInstanceExposer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package spi diff --git a/plc4go/spi/model/mock_DefaultPlcSubscriptionEventRequirements_test.go b/plc4go/spi/model/mock_DefaultPlcSubscriptionEventRequirements_test.go index 6ed8c231a95..acfbec8a820 100644 --- a/plc4go/spi/model/mock_DefaultPlcSubscriptionEventRequirements_test.go +++ b/plc4go/spi/model/mock_DefaultPlcSubscriptionEventRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/spi/model/mock_PlcBrowseItem_test.go b/plc4go/spi/model/mock_PlcBrowseItem_test.go index d49a1634b24..b471e913a58 100644 --- a/plc4go/spi/model/mock_PlcBrowseItem_test.go +++ b/plc4go/spi/model/mock_PlcBrowseItem_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/spi/model/mock_PlcBrowser_test.go b/plc4go/spi/model/mock_PlcBrowser_test.go index 2e07c52e46f..6ad7e418b05 100644 --- a/plc4go/spi/model/mock_PlcBrowser_test.go +++ b/plc4go/spi/model/mock_PlcBrowser_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/spi/model/mock_PlcQuery_test.go b/plc4go/spi/model/mock_PlcQuery_test.go index 206f2373366..225ff5575db 100644 --- a/plc4go/spi/model/mock_PlcQuery_test.go +++ b/plc4go/spi/model/mock_PlcQuery_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/spi/model/mock_PlcReader_test.go b/plc4go/spi/model/mock_PlcReader_test.go index 1f62ff5e9a7..06f094658f3 100644 --- a/plc4go/spi/model/mock_PlcReader_test.go +++ b/plc4go/spi/model/mock_PlcReader_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/spi/model/mock_PlcSubscriber_test.go b/plc4go/spi/model/mock_PlcSubscriber_test.go index c1d7add5aee..7235ebccd20 100644 --- a/plc4go/spi/model/mock_PlcSubscriber_test.go +++ b/plc4go/spi/model/mock_PlcSubscriber_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/spi/model/mock_PlcTagHandler_test.go b/plc4go/spi/model/mock_PlcTagHandler_test.go index 25ec6728269..b9beb455229 100644 --- a/plc4go/spi/model/mock_PlcTagHandler_test.go +++ b/plc4go/spi/model/mock_PlcTagHandler_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/spi/model/mock_PlcTag_test.go b/plc4go/spi/model/mock_PlcTag_test.go index 378db2a5637..cd2a8358046 100644 --- a/plc4go/spi/model/mock_PlcTag_test.go +++ b/plc4go/spi/model/mock_PlcTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/spi/model/mock_PlcValueHandler_test.go b/plc4go/spi/model/mock_PlcValueHandler_test.go index 375dc0354a1..1368fce6939 100644 --- a/plc4go/spi/model/mock_PlcValueHandler_test.go +++ b/plc4go/spi/model/mock_PlcValueHandler_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/spi/model/mock_PlcWriter_test.go b/plc4go/spi/model/mock_PlcWriter_test.go index 201387c4520..58f05e6b01b 100644 --- a/plc4go/spi/model/mock_PlcWriter_test.go +++ b/plc4go/spi/model/mock_PlcWriter_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/spi/model/mock_ReadRequestInterceptor_test.go b/plc4go/spi/model/mock_ReadRequestInterceptor_test.go index efdfc35537f..e44ed6cb16e 100644 --- a/plc4go/spi/model/mock_ReadRequestInterceptor_test.go +++ b/plc4go/spi/model/mock_ReadRequestInterceptor_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/spi/model/mock_WriteRequestInterceptor_test.go b/plc4go/spi/model/mock_WriteRequestInterceptor_test.go index 0855631d861..fb9b00f2b34 100644 --- a/plc4go/spi/model/mock_WriteRequestInterceptor_test.go +++ b/plc4go/spi/model/mock_WriteRequestInterceptor_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package model diff --git a/plc4go/spi/options/mock_DiscoveryOptionDeviceName_test.go b/plc4go/spi/options/mock_DiscoveryOptionDeviceName_test.go index 84105576645..0b7101b4c74 100644 --- a/plc4go/spi/options/mock_DiscoveryOptionDeviceName_test.go +++ b/plc4go/spi/options/mock_DiscoveryOptionDeviceName_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package options diff --git a/plc4go/spi/options/mock_DiscoveryOptionLocalAddress_test.go b/plc4go/spi/options/mock_DiscoveryOptionLocalAddress_test.go index a93670729da..d9c01088503 100644 --- a/plc4go/spi/options/mock_DiscoveryOptionLocalAddress_test.go +++ b/plc4go/spi/options/mock_DiscoveryOptionLocalAddress_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package options diff --git a/plc4go/spi/options/mock_DiscoveryOptionProtocolSpecific_test.go b/plc4go/spi/options/mock_DiscoveryOptionProtocolSpecific_test.go index cd43760d922..74b99a1c72a 100644 --- a/plc4go/spi/options/mock_DiscoveryOptionProtocolSpecific_test.go +++ b/plc4go/spi/options/mock_DiscoveryOptionProtocolSpecific_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package options diff --git a/plc4go/spi/options/mock_DiscoveryOptionProtocol_test.go b/plc4go/spi/options/mock_DiscoveryOptionProtocol_test.go index f9a60dced0e..45fa67fd13d 100644 --- a/plc4go/spi/options/mock_DiscoveryOptionProtocol_test.go +++ b/plc4go/spi/options/mock_DiscoveryOptionProtocol_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package options diff --git a/plc4go/spi/options/mock_DiscoveryOptionRemoteAddress_test.go b/plc4go/spi/options/mock_DiscoveryOptionRemoteAddress_test.go index 6cf1a385a5e..de14fee7e73 100644 --- a/plc4go/spi/options/mock_DiscoveryOptionRemoteAddress_test.go +++ b/plc4go/spi/options/mock_DiscoveryOptionRemoteAddress_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package options diff --git a/plc4go/spi/options/mock_DiscoveryOptionTransport_test.go b/plc4go/spi/options/mock_DiscoveryOptionTransport_test.go index 351dcbcfc96..d3e49c1a3e3 100644 --- a/plc4go/spi/options/mock_DiscoveryOptionTransport_test.go +++ b/plc4go/spi/options/mock_DiscoveryOptionTransport_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package options diff --git a/plc4go/spi/options/mock_WithDiscoveryOption_test.go b/plc4go/spi/options/mock_WithDiscoveryOption_test.go index 6253c1591e3..5b1f9054c33 100644 --- a/plc4go/spi/options/mock_WithDiscoveryOption_test.go +++ b/plc4go/spi/options/mock_WithDiscoveryOption_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package options diff --git a/plc4go/spi/options/mock_WithOption_test.go b/plc4go/spi/options/mock_WithOption_test.go index 4fc211d84f1..4280edc7351 100644 --- a/plc4go/spi/options/mock_WithOption_test.go +++ b/plc4go/spi/options/mock_WithOption_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package options diff --git a/plc4go/spi/pool/mock_CompletionFuture_test.go b/plc4go/spi/pool/mock_CompletionFuture_test.go index f38a3f46f37..3c54d864e2c 100644 --- a/plc4go/spi/pool/mock_CompletionFuture_test.go +++ b/plc4go/spi/pool/mock_CompletionFuture_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package pool diff --git a/plc4go/spi/pool/mock_Executor_test.go b/plc4go/spi/pool/mock_Executor_test.go index 4681e1e65d3..cf819f39b84 100644 --- a/plc4go/spi/pool/mock_Executor_test.go +++ b/plc4go/spi/pool/mock_Executor_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package pool diff --git a/plc4go/spi/pool/mock_Runnable_test.go b/plc4go/spi/pool/mock_Runnable_test.go index 18fc911ffba..e37a967826e 100644 --- a/plc4go/spi/pool/mock_Runnable_test.go +++ b/plc4go/spi/pool/mock_Runnable_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package pool diff --git a/plc4go/spi/testutils/TestUtils.go b/plc4go/spi/testutils/TestUtils.go index 021e8f891a8..57fdf32ab6d 100644 --- a/plc4go/spi/testutils/TestUtils.go +++ b/plc4go/spi/testutils/TestUtils.go @@ -23,11 +23,13 @@ import ( "bytes" "context" "fmt" + "github.com/rs/zerolog/pkgerrors" "os" "runtime" "runtime/debug" "strconv" "strings" + "sync" "testing" "time" @@ -224,9 +226,15 @@ func ProduceTestingLogger(t *testing.T) zerolog.Logger { if highLogPrecision { logger = logger.With().Timestamp().Logger() } + stackSetter.Do(func() { + zerolog.ErrorStackMarshaler = pkgerrors.MarshalStack + }) + logger = logger.With().Stack().Logger() return logger } +var stackSetter sync.Once + // EnrichOptionsWithOptionsForTesting appends options useful for testing to config.WithOption s func EnrichOptionsWithOptionsForTesting(t *testing.T, _options ...options.WithOption) []options.WithOption { if extractedTraceWorkers, found := options.ExtractTracerWorkers(_options...); found { diff --git a/plc4go/spi/testutils/mock_ConnectionConnectAwaiter_test.go b/plc4go/spi/testutils/mock_ConnectionConnectAwaiter_test.go index ee0c662a1ac..e6bf147b000 100644 --- a/plc4go/spi/testutils/mock_ConnectionConnectAwaiter_test.go +++ b/plc4go/spi/testutils/mock_ConnectionConnectAwaiter_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package testutils diff --git a/plc4go/spi/testutils/mock_Parser_test.go b/plc4go/spi/testutils/mock_Parser_test.go index 7affc8f45ed..a6ab2a5405a 100644 --- a/plc4go/spi/testutils/mock_Parser_test.go +++ b/plc4go/spi/testutils/mock_Parser_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package testutils diff --git a/plc4go/spi/testutils/mock_TestTransportInstance_test.go b/plc4go/spi/testutils/mock_TestTransportInstance_test.go index 4849ee18c9f..e6c8ab92b39 100644 --- a/plc4go/spi/testutils/mock_TestTransportInstance_test.go +++ b/plc4go/spi/testutils/mock_TestTransportInstance_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package testutils diff --git a/plc4go/spi/testutils/mock_WithTestCaseOption_test.go b/plc4go/spi/testutils/mock_WithTestCaseOption_test.go index c563f10b2d5..196baf79434 100644 --- a/plc4go/spi/testutils/mock_WithTestCaseOption_test.go +++ b/plc4go/spi/testutils/mock_WithTestCaseOption_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package testutils diff --git a/plc4go/spi/testutils/mock_XmlParser_test.go b/plc4go/spi/testutils/mock_XmlParser_test.go index cb6e1cf4617..0ae8da965b4 100644 --- a/plc4go/spi/testutils/mock_XmlParser_test.go +++ b/plc4go/spi/testutils/mock_XmlParser_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package testutils diff --git a/plc4go/spi/tracer/mock_Provider_test.go b/plc4go/spi/tracer/mock_Provider_test.go index feaefb46651..8effe86d5d0 100644 --- a/plc4go/spi/tracer/mock_Provider_test.go +++ b/plc4go/spi/tracer/mock_Provider_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package tracer diff --git a/plc4go/spi/tracer/mock_Tracer_test.go b/plc4go/spi/tracer/mock_Tracer_test.go index f4abf7b8717..4173f28f684 100644 --- a/plc4go/spi/tracer/mock_Tracer_test.go +++ b/plc4go/spi/tracer/mock_Tracer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package tracer diff --git a/plc4go/spi/transactions/mock_CompletionFuture_test.go b/plc4go/spi/transactions/mock_CompletionFuture_test.go index b0c5ffce6e2..9f185f59e34 100644 --- a/plc4go/spi/transactions/mock_CompletionFuture_test.go +++ b/plc4go/spi/transactions/mock_CompletionFuture_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package transactions diff --git a/plc4go/spi/transactions/mock_Executor_test.go b/plc4go/spi/transactions/mock_Executor_test.go index b02c7ff89b0..f741d9dacd6 100644 --- a/plc4go/spi/transactions/mock_Executor_test.go +++ b/plc4go/spi/transactions/mock_Executor_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package transactions diff --git a/plc4go/spi/transactions/mock_RequestTransactionManager_test.go b/plc4go/spi/transactions/mock_RequestTransactionManager_test.go index 5b665876c1f..c3f353e232e 100644 --- a/plc4go/spi/transactions/mock_RequestTransactionManager_test.go +++ b/plc4go/spi/transactions/mock_RequestTransactionManager_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package transactions diff --git a/plc4go/spi/transactions/mock_RequestTransactionRunnable_test.go b/plc4go/spi/transactions/mock_RequestTransactionRunnable_test.go index e0254910f58..a6df574812c 100644 --- a/plc4go/spi/transactions/mock_RequestTransactionRunnable_test.go +++ b/plc4go/spi/transactions/mock_RequestTransactionRunnable_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package transactions diff --git a/plc4go/spi/transactions/mock_RequestTransaction_test.go b/plc4go/spi/transactions/mock_RequestTransaction_test.go index cd60bc4c9ab..895f6b8ee94 100644 --- a/plc4go/spi/transactions/mock_RequestTransaction_test.go +++ b/plc4go/spi/transactions/mock_RequestTransaction_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package transactions diff --git a/plc4go/spi/transports/mock_ExtendedReader_test.go b/plc4go/spi/transports/mock_ExtendedReader_test.go index 5040234799d..a164ee7700f 100644 --- a/plc4go/spi/transports/mock_ExtendedReader_test.go +++ b/plc4go/spi/transports/mock_ExtendedReader_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package transports diff --git a/plc4go/spi/transports/mock_TransportInstance_test.go b/plc4go/spi/transports/mock_TransportInstance_test.go index 0b49426fa35..2ebcbec1e53 100644 --- a/plc4go/spi/transports/mock_TransportInstance_test.go +++ b/plc4go/spi/transports/mock_TransportInstance_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package transports diff --git a/plc4go/spi/transports/mock_Transport_test.go b/plc4go/spi/transports/mock_Transport_test.go index 0155f923e6e..aaf5d738c84 100644 --- a/plc4go/spi/transports/mock_Transport_test.go +++ b/plc4go/spi/transports/mock_Transport_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package transports diff --git a/plc4go/spi/transports/utils/mock_DefaultBufferedTransportInstanceRequirements_test.go b/plc4go/spi/transports/utils/mock_DefaultBufferedTransportInstanceRequirements_test.go index f41de8538ad..52809c2ce80 100644 --- a/plc4go/spi/transports/utils/mock_DefaultBufferedTransportInstanceRequirements_test.go +++ b/plc4go/spi/transports/utils/mock_DefaultBufferedTransportInstanceRequirements_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package utils diff --git a/plc4go/spi/transports/utils/mock_DefaultBufferedTransportInstance_test.go b/plc4go/spi/transports/utils/mock_DefaultBufferedTransportInstance_test.go index ea423f5170a..d16a5a2ffe5 100644 --- a/plc4go/spi/transports/utils/mock_DefaultBufferedTransportInstance_test.go +++ b/plc4go/spi/transports/utils/mock_DefaultBufferedTransportInstance_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package utils diff --git a/plc4go/spi/transports/utils/mock_Option_test.go b/plc4go/spi/transports/utils/mock_Option_test.go index f125c2f3f14..fbef7457715 100644 --- a/plc4go/spi/transports/utils/mock_Option_test.go +++ b/plc4go/spi/transports/utils/mock_Option_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package utils diff --git a/plc4go/spi/utils/mock_AsciiBoxWriter_test.go b/plc4go/spi/utils/mock_AsciiBoxWriter_test.go index 5fb43111851..4984f3e5970 100644 --- a/plc4go/spi/utils/mock_AsciiBoxWriter_test.go +++ b/plc4go/spi/utils/mock_AsciiBoxWriter_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package utils diff --git a/plc4go/spi/utils/mock_AsciiBoxer_test.go b/plc4go/spi/utils/mock_AsciiBoxer_test.go index 1dd05e6d5c9..34f269fd781 100644 --- a/plc4go/spi/utils/mock_AsciiBoxer_test.go +++ b/plc4go/spi/utils/mock_AsciiBoxer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package utils diff --git a/plc4go/spi/utils/mock_ErrorIdentify_test.go b/plc4go/spi/utils/mock_ErrorIdentify_test.go index f8a260d6757..71d852903d7 100644 --- a/plc4go/spi/utils/mock_ErrorIdentify_test.go +++ b/plc4go/spi/utils/mock_ErrorIdentify_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package utils diff --git a/plc4go/spi/utils/mock_LengthAware_test.go b/plc4go/spi/utils/mock_LengthAware_test.go index c90f34c469f..c57222d17e7 100644 --- a/plc4go/spi/utils/mock_LengthAware_test.go +++ b/plc4go/spi/utils/mock_LengthAware_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package utils diff --git a/plc4go/spi/utils/mock_PlcValue_test.go b/plc4go/spi/utils/mock_PlcValue_test.go index 0c0eaeb8a9e..020a943a9c6 100644 --- a/plc4go/spi/utils/mock_PlcValue_test.go +++ b/plc4go/spi/utils/mock_PlcValue_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package utils diff --git a/plc4go/spi/utils/mock_PositionAware_test.go b/plc4go/spi/utils/mock_PositionAware_test.go index 860ec6b31fc..d8cc3e33354 100644 --- a/plc4go/spi/utils/mock_PositionAware_test.go +++ b/plc4go/spi/utils/mock_PositionAware_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package utils diff --git a/plc4go/spi/utils/mock_ReadBufferByteBased_test.go b/plc4go/spi/utils/mock_ReadBufferByteBased_test.go index dbb0f110b19..98305c243df 100644 --- a/plc4go/spi/utils/mock_ReadBufferByteBased_test.go +++ b/plc4go/spi/utils/mock_ReadBufferByteBased_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package utils diff --git a/plc4go/spi/utils/mock_ReadBuffer_test.go b/plc4go/spi/utils/mock_ReadBuffer_test.go index 0d07b3d23df..093c5a460bc 100644 --- a/plc4go/spi/utils/mock_ReadBuffer_test.go +++ b/plc4go/spi/utils/mock_ReadBuffer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package utils diff --git a/plc4go/spi/utils/mock_Serializable_test.go b/plc4go/spi/utils/mock_Serializable_test.go index e8417132478..5adf0f20622 100644 --- a/plc4go/spi/utils/mock_Serializable_test.go +++ b/plc4go/spi/utils/mock_Serializable_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package utils diff --git a/plc4go/spi/utils/mock_WithReaderArgs_test.go b/plc4go/spi/utils/mock_WithReaderArgs_test.go index ca09dbffaf8..a41ab415562 100644 --- a/plc4go/spi/utils/mock_WithReaderArgs_test.go +++ b/plc4go/spi/utils/mock_WithReaderArgs_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package utils diff --git a/plc4go/spi/utils/mock_WithReaderWriterArgs_test.go b/plc4go/spi/utils/mock_WithReaderWriterArgs_test.go index 1229e4a0eed..e3d6cc1ffa4 100644 --- a/plc4go/spi/utils/mock_WithReaderWriterArgs_test.go +++ b/plc4go/spi/utils/mock_WithReaderWriterArgs_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package utils diff --git a/plc4go/spi/utils/mock_WithWriterArgs_test.go b/plc4go/spi/utils/mock_WithWriterArgs_test.go index eb85bf5cace..b8a809b3f21 100644 --- a/plc4go/spi/utils/mock_WithWriterArgs_test.go +++ b/plc4go/spi/utils/mock_WithWriterArgs_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package utils diff --git a/plc4go/spi/utils/mock_WriteBufferBoxBased_test.go b/plc4go/spi/utils/mock_WriteBufferBoxBased_test.go index 61a2dc78e5a..0f5e74b76ed 100644 --- a/plc4go/spi/utils/mock_WriteBufferBoxBased_test.go +++ b/plc4go/spi/utils/mock_WriteBufferBoxBased_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package utils diff --git a/plc4go/spi/utils/mock_WriteBufferByteBased_test.go b/plc4go/spi/utils/mock_WriteBufferByteBased_test.go index 11279035491..5f0590df479 100644 --- a/plc4go/spi/utils/mock_WriteBufferByteBased_test.go +++ b/plc4go/spi/utils/mock_WriteBufferByteBased_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package utils diff --git a/plc4go/spi/utils/mock_WriteBufferJsonBased_test.go b/plc4go/spi/utils/mock_WriteBufferJsonBased_test.go index 416ea10610f..4c7c9e34ab9 100644 --- a/plc4go/spi/utils/mock_WriteBufferJsonBased_test.go +++ b/plc4go/spi/utils/mock_WriteBufferJsonBased_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package utils diff --git a/plc4go/spi/utils/mock_WriteBufferXmlBased_test.go b/plc4go/spi/utils/mock_WriteBufferXmlBased_test.go index c91dc842a5f..e6af4a2e5a3 100644 --- a/plc4go/spi/utils/mock_WriteBufferXmlBased_test.go +++ b/plc4go/spi/utils/mock_WriteBufferXmlBased_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package utils diff --git a/plc4go/spi/utils/mock_WriteBuffer_test.go b/plc4go/spi/utils/mock_WriteBuffer_test.go index 54d1fb4b5b4..4b0b99e08ea 100644 --- a/plc4go/spi/utils/mock_WriteBuffer_test.go +++ b/plc4go/spi/utils/mock_WriteBuffer_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package utils diff --git a/plc4go/spi/values/mock_ArrayInfo_test.go b/plc4go/spi/values/mock_ArrayInfo_test.go index debb2bc2009..0a0fab0796c 100644 --- a/plc4go/spi/values/mock_ArrayInfo_test.go +++ b/plc4go/spi/values/mock_ArrayInfo_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package values diff --git a/plc4go/spi/values/mock_PlcTag_test.go b/plc4go/spi/values/mock_PlcTag_test.go index 9e0554e5027..901e35672a1 100644 --- a/plc4go/spi/values/mock_PlcTag_test.go +++ b/plc4go/spi/values/mock_PlcTag_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package values diff --git a/plc4go/spi/values/mock_WriteBufferPlcValueBased_test.go b/plc4go/spi/values/mock_WriteBufferPlcValueBased_test.go index 0042d35a1cb..00db1742e1c 100644 --- a/plc4go/spi/values/mock_WriteBufferPlcValueBased_test.go +++ b/plc4go/spi/values/mock_WriteBufferPlcValueBased_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package values diff --git a/plc4go/tests/drivers/tests/manual_opcua_driver_test.go b/plc4go/tests/drivers/tests/manual_opcua_driver_test.go new file mode 100644 index 00000000000..9822c11e730 --- /dev/null +++ b/plc4go/tests/drivers/tests/manual_opcua_driver_test.go @@ -0,0 +1,60 @@ +/* + * 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 tests + +import ( + "fmt" + "testing" + + "github.com/apache/plc4x/plc4go/internal/opcua" + plc4go "github.com/apache/plc4x/plc4go/pkg/api" + "github.com/apache/plc4x/plc4go/pkg/api/transports" + "github.com/apache/plc4x/plc4go/spi/options/converter" + "github.com/apache/plc4x/plc4go/spi/testutils" + + "github.com/stretchr/testify/assert" + "github.com/stretchr/testify/require" +) + +func TestManualOpcuaRead(t *testing.T) { + t.Skip() + + optionsForTesting := testutils.EnrichOptionsWithOptionsForTesting(t) + + connectionString := "opcua://milo.digitalpetri.com:62541/milo" + driverManager := plc4go.NewPlcDriverManager(converter.WithOptionToExternal(optionsForTesting...)...) + t.Cleanup(func() { + assert.NoError(t, driverManager.Close()) + }) + driverManager.RegisterDriver(opcua.NewDriver(optionsForTesting...)) + transports.RegisterTcpTransport(driverManager, converter.WithOptionToExternal(optionsForTesting...)...) + connectionResult := <-driverManager.GetConnection(connectionString) + if err := connectionResult.GetErr(); err != nil { + t.Fatal(err) + } + connection := connectionResult.GetConnection() + defer connection.Close() + readRequest, err := connection.ReadRequestBuilder(). + AddTagAddress("something", "ns=2;i=10846;BOOL"). + Build() + require.NoError(t, err) + readRequestResult := <-readRequest.Execute() + fmt.Printf("%s", readRequestResult.GetResponse()) +} diff --git a/plc4go/tests/drivers/tests/manual_opcua_milo_test.go b/plc4go/tests/drivers/tests/manual_opcua_milo_test.go new file mode 100644 index 00000000000..d39dda11674 --- /dev/null +++ b/plc4go/tests/drivers/tests/manual_opcua_milo_test.go @@ -0,0 +1,51 @@ +/* + * 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 tests + +import ( + "testing" + + "github.com/apache/plc4x/plc4go/internal/opcua" + plc4go "github.com/apache/plc4x/plc4go/pkg/api" + "github.com/apache/plc4x/plc4go/pkg/api/transports" + "github.com/apache/plc4x/plc4go/spi/options/converter" + "github.com/apache/plc4x/plc4go/spi/testutils" + + "github.com/stretchr/testify/assert" +) + +func TestManualMiloOpcuaRead(t *testing.T) { + t.Skip() + + optionsForTesting := testutils.EnrichOptionsWithOptionsForTesting(t) + + connectionString := "opcua://milo.digitalpetri.com:62541/milo" + driverManager := plc4go.NewPlcDriverManager(converter.WithOptionToExternal(optionsForTesting...)...) + t.Cleanup(func() { + assert.NoError(t, driverManager.Close()) + }) + driverManager.RegisterDriver(opcua.NewDriver(optionsForTesting...)) + transports.RegisterTcpTransport(driverManager, converter.WithOptionToExternal(optionsForTesting...)...) + test := testutils.NewManualTestSuite(t, connectionString, driverManager) + + test.AddTestCase("ns=2;i=10846;BOOL", 0) + + test.Run() +} diff --git a/plc4go/tools/plc4xbrowser/ui/actions.go b/plc4go/tools/plc4xbrowser/ui/actions.go index 8ab96d2a2b8..2a9b442d100 100644 --- a/plc4go/tools/plc4xbrowser/ui/actions.go +++ b/plc4go/tools/plc4xbrowser/ui/actions.go @@ -20,10 +20,12 @@ package ui import ( + "bytes" "fmt" "github.com/apache/plc4x/plc4go/internal/ads" "github.com/apache/plc4x/plc4go/internal/bacnetip" "github.com/apache/plc4x/plc4go/internal/cbus" + "github.com/apache/plc4x/plc4go/internal/opcua" "github.com/apache/plc4x/plc4go/internal/s7" plc4go "github.com/apache/plc4x/plc4go/pkg/api" "github.com/apache/plc4x/plc4go/pkg/api/transports" @@ -31,6 +33,7 @@ import ( "github.com/rivo/tview" "github.com/rs/zerolog" "github.com/rs/zerolog/log" + "strings" ) func InitSubsystem() { @@ -42,14 +45,38 @@ func InitSubsystem() { logLevel = parsedLevel } } - driverManager = plc4go.NewPlcDriverManager() log.Logger = log. //// Enable below if you want to see the filenames //With().Caller().Logger(). - Output(zerolog.ConsoleWriter{Out: tview.ANSIWriter(consoleOutput)}). + Output(zerolog.NewConsoleWriter( + func(w *zerolog.ConsoleWriter) { + w.Out = tview.ANSIWriter(consoleOutput) + }, + func(w *zerolog.ConsoleWriter) { + w.FormatFieldValue = func(i interface{}) string { + if aString, ok := i.(string); ok && strings.Contains(aString, "\\n") { + return fmt.Sprintf("\x1b[%dm%v\x1b[0m", 31, "see below") + } + return fmt.Sprintf("%s", i) + } + w.FormatExtra = func(m map[string]interface{}, buffer *bytes.Buffer) error { + for key, i := range m { + if aString, ok := i.(string); ok && strings.Contains(aString, "\n") { + buffer.WriteString("\n") + buffer.WriteString(fmt.Sprintf("\x1b[%dm%v\x1b[0m", 32, "field "+key)) + buffer.WriteString(":\n" + aString) + } + } + return nil + } + }, + ), + ). Level(logLevel) + driverManager = plc4go.NewPlcDriverManager() + // We offset the commands executed with the last commands commandsExecuted = len(config.History.Last10Commands) outputCommandHistory() @@ -116,6 +143,13 @@ func registerDriver(driverId string) error { transports.RegisterTcpTransport(driverManager) tcpRegistered = true } + case "opcua": + driver = opcua.NewDriver() + driverManager.RegisterDriver(driver) + if !tcpRegistered { + transports.RegisterTcpTransport(driverManager) + tcpRegistered = true + } default: return errors.Errorf("Unknown driver %s", driverId) } diff --git a/plc4go/tools/plc4xbrowser/ui/common.go b/plc4go/tools/plc4xbrowser/ui/common.go index ee7b61a591e..c052901f5d8 100644 --- a/plc4go/tools/plc4xbrowser/ui/common.go +++ b/plc4go/tools/plc4xbrowser/ui/common.go @@ -29,7 +29,7 @@ import ( "time" ) -const protocols = "ads,bacnetip,c-bus,s7" +const protocols = "ads,bacnetip,c-bus,opcua,s7" var protocolList = strings.Split(protocols, ",") diff --git a/plc4go/tools/plc4xbrowser/ui/config.go b/plc4go/tools/plc4xbrowser/ui/config.go index 4658a974929..47a325b46dc 100644 --- a/plc4go/tools/plc4xbrowser/ui/config.go +++ b/plc4go/tools/plc4xbrowser/ui/config.go @@ -26,6 +26,7 @@ import ( "gopkg.in/yaml.v3" "os" "path" + "sync" "time" ) @@ -83,7 +84,11 @@ func LoadConfig() { } } +var saveMutex sync.Mutex + func saveConfig() { + saveMutex.Lock() + defer saveMutex.Unlock() config.LastUpdated = time.Now() f, err := os.OpenFile(configFile, os.O_RDWR|os.O_CREATE, 0755) if err != nil { diff --git a/plc4go/tools/plc4xpcapanalyzer/internal/common/mock_FilteredPackage_test.go b/plc4go/tools/plc4xpcapanalyzer/internal/common/mock_FilteredPackage_test.go index f41754c7e6a..47972fa0b4b 100644 --- a/plc4go/tools/plc4xpcapanalyzer/internal/common/mock_FilteredPackage_test.go +++ b/plc4go/tools/plc4xpcapanalyzer/internal/common/mock_FilteredPackage_test.go @@ -17,7 +17,7 @@ * under the License. */ -// Code generated by mockery v2.23.4. DO NOT EDIT. +// Code generated by mockery v2.32.4. DO NOT EDIT. package common 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 331cff40fc5..57002d7eade 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 @@ -133,7 +133,7 @@ public PlcConnection getConnection(String connectionString) throws PlcConnection // Create the configuration object. this.configuration = (EIPConfiguration) new ConfigurationFactory().createConfiguration( - getConfigurationType(), paramString); + getConfigurationType(), protocolCode, transportCode, transportConfig, paramString); if (configuration == null) { throw new PlcConnectionException("Unsupported configuration"); } @@ -165,6 +165,12 @@ public PlcConnection getConnection(String connectionString) throws PlcConnection // Give drivers the option to customize the channel. initializePipeline(channelFactory); + // Make the "fire discover event" overridable via system property. + boolean fireDiscoverEvent = fireDiscoverEvent(); + if(System.getProperty(PROPERTY_PLC4X_FORCE_FIRE_DISCOVER_EVENT) != null) { + fireDiscoverEvent = Boolean.parseBoolean(System.getProperty(PROPERTY_PLC4X_FORCE_FIRE_DISCOVER_EVENT)); + } + // Make the "await setup complete" overridable via system property. boolean awaitSetupComplete = awaitSetupComplete(); if(System.getProperty(PROPERTY_PLC4X_FORCE_AWAIT_SETUP_COMPLETE) != null) { @@ -189,6 +195,7 @@ public PlcConnection getConnection(String connectionString) throws PlcConnection getValueHandler(), configuration, channelFactory, + fireDiscoverEvent, awaitSetupComplete, awaitDisconnectComplete, awaitDiscoverComplete, diff --git a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java index 366864ef647..14fdf1fb383 100644 --- a/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java +++ b/plc4j/drivers/knxnetip/src/main/generated/org/apache/plc4x/java/knxnetip/readwrite/KnxManufacturer.java @@ -735,9 +735,10 @@ public enum KnxManufacturer { M_SHENZHEN_EASTKAME_TECHNOLOGY_CO___LTD_( (int) 638, (int) 696, (String) "Shenzhen EastKame Technology Co., Ltd."), M_BOLATU((int) 639, (int) 697, (String) "BOLATU"), - M_ABB___RESERVED((int) 640, (int) 43954, (String) "ABB - reserved"), + M_RECBER_KABLO_A_S_((int) 640, (int) 698, (String) "RECBER KABLO A.S."), + M_ABB___RESERVED((int) 641, (int) 43954, (String) "ABB - reserved"), M_BUSCH_JAEGER_ELEKTRO___RESERVED( - (int) 641, (int) 43959, (String) "Busch-Jaeger Elektro - reserved"); + (int) 642, (int) 43959, (String) "Busch-Jaeger Elektro - reserved"); private static final Map map; static { diff --git a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/OpcuaPlcDriver.java b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/OpcuaPlcDriver.java index 5fcda2b8da7..4e07de46fea 100644 --- a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/OpcuaPlcDriver.java +++ b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/OpcuaPlcDriver.java @@ -19,41 +19,23 @@ package org.apache.plc4x.java.opcua; import io.netty.buffer.ByteBuf; -import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.exceptions.PlcConnectionException; import org.apache.plc4x.java.opcua.config.OpcuaConfiguration; +import org.apache.plc4x.java.opcua.context.OpcuaDriverContext; import org.apache.plc4x.java.opcua.optimizer.OpcuaOptimizer; import org.apache.plc4x.java.opcua.protocol.OpcuaProtocolLogic; import org.apache.plc4x.java.opcua.readwrite.OpcuaAPU; import org.apache.plc4x.java.opcua.tag.OpcuaPlcTagHandler; import org.apache.plc4x.java.opcua.tag.OpcuaTag; import org.apache.plc4x.java.spi.configuration.Configuration; -import org.apache.plc4x.java.spi.configuration.ConfigurationFactory; -import org.apache.plc4x.java.spi.connection.*; -import org.apache.plc4x.java.spi.transport.Transport; +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.ServiceLoader; import java.util.function.ToIntFunction; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import static org.apache.plc4x.java.spi.configuration.ConfigurationFactory.configure; public class OpcuaPlcDriver extends GeneratedDriverBase { - public static final Pattern INET_ADDRESS_PATTERN = Pattern.compile("(:(?[a-z0-9]*))?://" + - "(?[\\w.-]+)(:" + - "(?\\d*))?"); - - public static final Pattern URI_PATTERN = Pattern.compile("^(?opcua)" + - INET_ADDRESS_PATTERN + - "(?[\\w/=]*)[?]?" + - "(?([^=]+=[^=&]+&?)*)" - ); - - private boolean isEncrypted; - @Override public String getProtocolCode() { return "opcua"; @@ -74,11 +56,6 @@ protected String getDefaultTransport() { return "tcp"; } - @Override - protected boolean awaitDiscoverComplete() { - return isEncrypted; - } - @Override protected boolean canRead() { return true; @@ -119,115 +96,11 @@ protected ProtocolStackConfigurer getStackConfigurer() { .withProtocol(OpcuaProtocolLogic.class) .withPacketSizeEstimator(ByteLengthEstimator.class) .withParserArgs(true) + .withDriverContext(OpcuaDriverContext.class) .littleEndian() .build(); } - @Override - public PlcConnection getConnection(String connectionString) throws PlcConnectionException { - // Split up the connection string into it's individual segments. - Matcher matcher = URI_PATTERN.matcher(connectionString); - if (!matcher.matches()) { - throw new PlcConnectionException( - "Connection string doesn't match the format '{protocol-code}:({transport-code})?//{transport-host}(:{transport-port})(/{transport-endpoint})(?{parameter-string)?'"); - } - final String protocolCode = matcher.group("protocolCode"); - final String transportCode = (matcher.group("transportCode") != null) ? - matcher.group("transportCode") : getDefaultTransport(); - final String transportHost = matcher.group("transportHost"); - final String transportPort = matcher.group("transportPort"); - final String transportEndpoint = matcher.group("transportEndpoint"); - final String paramString = matcher.group("paramString"); - - // Check if the protocol code matches this driver. - if (!protocolCode.equals(getProtocolCode())) { - // Actually this shouldn't happen as the DriverManager should have not used this driver in the first place. - throw new PlcConnectionException( - "This driver is not suited to handle this connection string"); - } - - // Create the configuration object. - OpcuaConfiguration configuration = (OpcuaConfiguration) new ConfigurationFactory().createConfiguration( - getConfigurationType(), paramString); - if (configuration == null) { - throw new PlcConnectionException("Unsupported configuration"); - } - configuration.setTransportCode(transportCode); - configuration.setHost(transportHost); - configuration.setPort(transportPort); - configuration.setTransportEndpoint(transportEndpoint); - String portAddition = transportPort != null ? ":" + transportPort : ""; - configuration.setEndpoint("opc." + transportCode + "://" + transportHost + portAddition + transportEndpoint); - - // Try to find a transport in order to create a communication channel. - Transport transport = null; - ServiceLoader transportLoader = ServiceLoader.load( - Transport.class, Thread.currentThread().getContextClassLoader()); - for (Transport curTransport : transportLoader) { - if (curTransport.getTransportCode().equals(transportCode)) { - transport = curTransport; - break; - } - } - if (transport == null) { - throw new PlcConnectionException("Unsupported transport " + transportCode); - } - - // Inject the configuration into the transport. - configure(configuration, transport); - - // Create an instance of the communication channel which the driver should use. - ChannelFactory channelFactory = transport.createChannelFactory(transportHost + ":" + transportPort); - if (channelFactory == null) { - throw new PlcConnectionException("Unable to get channel factory from url " + transportHost + ":" + transportPort); - } - configure(configuration, channelFactory); - - // Give drivers the option to customize the channel. - initializePipeline(channelFactory); - - // Make the "await setup complete" overridable via system property. - boolean awaitSetupComplete = awaitSetupComplete(); - if (System.getProperty(PROPERTY_PLC4X_FORCE_AWAIT_SETUP_COMPLETE) != null) { - awaitSetupComplete = Boolean.parseBoolean(System.getProperty(PROPERTY_PLC4X_FORCE_AWAIT_SETUP_COMPLETE)); - } - - // Make the "await disconnect complete" overridable via system property. - boolean awaitDisconnectComplete = awaitDisconnectComplete(); - if (System.getProperty(PROPERTY_PLC4X_FORCE_AWAIT_DISCONNECT_COMPLETE) != null) { - awaitDisconnectComplete = Boolean.parseBoolean(System.getProperty(PROPERTY_PLC4X_FORCE_AWAIT_DISCONNECT_COMPLETE)); - } - - if (configuration.getSecurityPolicy() != null && !(configuration.getSecurityPolicy().equals("None"))) { - try { - configuration.openKeyStore(); - } catch (Exception e) { - throw new PlcConnectionException("Unable to open keystore, please confirm you have the correct permissions"); - } - } - - this.isEncrypted = configuration.isEncrypted(); - - // Make the "await disconnect complete" overridable via system property. - boolean awaitDiscoverComplete = awaitDiscoverComplete(); - if (System.getProperty(PROPERTY_PLC4X_FORCE_AWAIT_DISCOVER_COMPLETE) != null) { - awaitDiscoverComplete = Boolean.parseBoolean(System.getProperty(PROPERTY_PLC4X_FORCE_AWAIT_DISCOVER_COMPLETE)); - } - - return new DefaultNettyPlcConnection( - canRead(), canWrite(), canSubscribe(), canBrowse(), - getTagHandler(), - getValueHandler(), - configuration, - channelFactory, - awaitSetupComplete, - awaitDisconnectComplete, - awaitDiscoverComplete, - getStackConfigurer(), - getOptimizer(), - null); - } - /** * Estimate the Length of a Packet */ diff --git a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/config/OpcuaConfiguration.java b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/config/OpcuaConfiguration.java index da712da6681..4905694a4ee 100644 --- a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/config/OpcuaConfiguration.java +++ b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/config/OpcuaConfiguration.java @@ -18,47 +18,22 @@ */ package org.apache.plc4x.java.opcua.config; -import org.apache.plc4x.java.api.exceptions.PlcConnectionException; -import org.apache.plc4x.java.opcua.context.CertificateGenerator; -import org.apache.plc4x.java.opcua.context.CertificateKeyPair; -import org.apache.plc4x.java.opcua.readwrite.PascalByteString; import org.apache.plc4x.java.spi.configuration.Configuration; import org.apache.plc4x.java.spi.configuration.annotations.ConfigurationParameter; import org.apache.plc4x.java.spi.configuration.annotations.defaults.BooleanDefaultValue; import org.apache.plc4x.java.spi.configuration.annotations.defaults.StringDefaultValue; import org.apache.plc4x.java.transport.tcp.TcpTransportConfiguration; -import org.bouncycastle.jce.provider.BouncyCastleProvider; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.nio.file.FileSystems; -import java.security.KeyPair; -import java.security.KeyStore; -import java.security.PrivateKey; -import java.security.Security; -import java.security.cert.X509Certificate; public class OpcuaConfiguration implements Configuration, TcpTransportConfiguration { - static { - // Required for SecurityPolicy.Aes256_Sha256_RsaPss - Security.addProvider(new BouncyCastleProvider()); - } + @ConfigurationParameter("protocolCode") + private String protocolCode; - private static final Logger LOGGER = LoggerFactory.getLogger(OpcuaConfiguration.class); + @ConfigurationParameter("transportCode") + private String transportCode; - private String code; - private String host; - private String port; - private String endpoint; - private String transportEndpoint; - private String params; - private Boolean isEncrypted = false; - private PascalByteString thumbprint; - private byte[] senderCertificate; + @ConfigurationParameter("transportConfig") + private String transportConfig; @ConfigurationParameter("discovery") @BooleanDefaultValue(true) @@ -83,7 +58,17 @@ public class OpcuaConfiguration implements Configuration, TcpTransportConfigurat @ConfigurationParameter("keyStorePassword") private String keyStorePassword; - private CertificateKeyPair ckp; + public String getProtocolCode() { + return protocolCode; + } + + public String getTransportCode() { + return transportCode; + } + + public String getTransportConfig() { + return transportConfig; + } public boolean isDiscovery() { return discovery; @@ -113,128 +98,18 @@ public String getKeyStorePassword() { return keyStorePassword; } - public PascalByteString getThumbprint() { - return thumbprint; - } - - public CertificateKeyPair getCertificateKeyPair() { - return ckp; - } - - public boolean isEncrypted() { - return isEncrypted; - } - - public void setDiscovery(boolean discovery) { - this.discovery = discovery; - } - - public void setUsername(String username) { - this.username = username; - } - - public void setPassword(String password) { - this.password = password; - } - - public void setCertDirectory(String certDirectory) { - this.certDirectory = certDirectory; - } - - public void setSecurityPolicy(String securityPolicy) { - this.securityPolicy = securityPolicy; - } - - public void setKeyStoreFile(String keyStoreFile) { - this.keyStoreFile = keyStoreFile; - } - - public void setKeyStorePassword(String keyStorePassword) { - this.keyStorePassword = keyStorePassword; - } - - public void setThumbprint(PascalByteString thumbprint) { - this.thumbprint = thumbprint; - } - - public String getTransportCode() { - return code; - } - - public String getHost() { - return host; - } - - public String getPort() { - return port; - } - - public String getEndpoint() { - return endpoint; - } - - public String getTransportEndpoint() { - return transportEndpoint; - } - - public byte[] getSenderCertificate() { - return this.senderCertificate; - } - - public void setTransportCode(String code) { - this.code = code; - } - - public void setHost(String host) { - this.host = host; - } - - public void setPort(String port) { - this.port = port; - } - - public void setEndpoint(String endpoint) { - this.endpoint = endpoint; - } - - public void setTransportEndpoint(String transportEndpoint) { - this.transportEndpoint = transportEndpoint; - } - - public void openKeyStore() throws Exception { - this.isEncrypted = true; - File securityTempDir = new File(certDirectory, "security"); - if (!securityTempDir.exists() && !securityTempDir.mkdirs()) { - throw new PlcConnectionException("Unable to create directory please confirm folder permissions on " + certDirectory); - } - KeyStore keyStore = KeyStore.getInstance("PKCS12"); - File serverKeyStore = securityTempDir.toPath().resolve(keyStoreFile).toFile(); - - File pkiDir = FileSystems.getDefault().getPath(certDirectory).resolve("pki").toFile(); - if (!serverKeyStore.exists()) { - ckp = CertificateGenerator.generateCertificate(); - LOGGER.info("Creating new KeyStore at {}", serverKeyStore); - keyStore.load(null, keyStorePassword.toCharArray()); - keyStore.setKeyEntry("plc4x-certificate-alias", ckp.getKeyPair().getPrivate(), keyStorePassword.toCharArray(), new X509Certificate[]{ckp.getCertificate()}); - keyStore.store(new FileOutputStream(serverKeyStore), keyStorePassword.toCharArray()); - } else { - LOGGER.info("Loading KeyStore at {}", serverKeyStore); - keyStore.load(new FileInputStream(serverKeyStore), keyStorePassword.toCharArray()); - String alias = keyStore.aliases().nextElement(); - KeyPair kp = new KeyPair(keyStore.getCertificate(alias).getPublicKey(), - (PrivateKey) keyStore.getKey(alias, keyStorePassword.toCharArray())); - ckp = new CertificateKeyPair(kp, (X509Certificate) keyStore.getCertificate(alias)); - } - } @Override public String toString() { - return "Configuration{" + '}'; + return "OpcuaConfiguration{" + + "discovery=" + discovery + + ", username='" + username + '\'' + + ", password='" + (password != null ? "******" : null) + '\'' + + ", securityPolicy='" + securityPolicy + '\'' + + ", keyStoreFile='" + keyStoreFile + '\'' + + ", certDirectory='" + certDirectory + '\'' + + ", keyStorePassword='" + (keyStorePassword != null ? "******" : null) + '\'' + + '}'; } - - public void setSenderCertificate(byte[] certificate) { - this.senderCertificate = certificate; - } - } diff --git a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/OpcuaDriverContext.java b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/OpcuaDriverContext.java new file mode 100644 index 00000000000..975240234a9 --- /dev/null +++ b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/OpcuaDriverContext.java @@ -0,0 +1,177 @@ +/* + * 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.opcua.context; + +import org.apache.plc4x.java.api.exceptions.PlcRuntimeException; +import org.apache.plc4x.java.opcua.config.OpcuaConfiguration; +import org.apache.plc4x.java.opcua.readwrite.PascalByteString; +import org.apache.plc4x.java.spi.configuration.HasConfiguration; +import org.apache.plc4x.java.spi.context.DriverContext; +import org.bouncycastle.jce.provider.BouncyCastleProvider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.nio.file.FileSystems; +import java.security.KeyPair; +import java.security.KeyStore; +import java.security.PrivateKey; +import java.security.Security; +import java.security.cert.X509Certificate; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +public class OpcuaDriverContext implements DriverContext, HasConfiguration { + + private static final Logger LOGGER = LoggerFactory.getLogger(OpcuaDriverContext.class); + + public static final Pattern INET_ADDRESS_PATTERN = Pattern.compile("(:(?[a-z0-9]*))?://" + + "(?[\\w.-]+)(:" + + "(?\\d*))?"); + + public static final Pattern URI_PATTERN = Pattern.compile("^(?opcua)" + + INET_ADDRESS_PATTERN + + "(?[\\w/=]*)[?]?" + + "(?([^=]+=[^=&]+&?)*)" + ); + + + static { + // Required for SecurityPolicy.Aes256_Sha256_RsaPss + Security.addProvider(new BouncyCastleProvider()); + } + + private String code; + private String host; + private String port; + private String endpoint; + private String transportEndpoint; + private Boolean isEncrypted = false; + private PascalByteString thumbprint; + private byte[] senderCertificate; + private CertificateKeyPair certificateKeyPair; + + public void openKeyStore(OpcuaConfiguration configuration) throws Exception { + this.isEncrypted = true; + String certDirectory = configuration.getCertDirectory(); + File securityTempDir = new File(certDirectory, "security"); + if (!securityTempDir.exists() && !securityTempDir.mkdirs()) { + throw new PlcRuntimeException("Unable to create directory please confirm folder permissions on " + certDirectory); + } + KeyStore keyStore = KeyStore.getInstance("PKCS12"); + File serverKeyStore = securityTempDir.toPath().resolve(configuration.getKeyStoreFile()).toFile(); + + File pkiDir = FileSystems.getDefault().getPath(certDirectory).resolve("pki").toFile(); + char[] password = configuration.getKeyStorePassword().toCharArray(); + if (!serverKeyStore.exists()) { + certificateKeyPair = CertificateGenerator.generateCertificate(); + LOGGER.info("Creating new KeyStore at {}", serverKeyStore); + keyStore.load(null, password); + keyStore.setKeyEntry("plc4x-certificate-alias", certificateKeyPair.getKeyPair().getPrivate(), password, new X509Certificate[]{certificateKeyPair.getCertificate()}); + keyStore.store(new FileOutputStream(serverKeyStore), password); + } else { + LOGGER.info("Loading KeyStore at {}", serverKeyStore); + keyStore.load(new FileInputStream(serverKeyStore), password); + String alias = keyStore.aliases().nextElement(); + KeyPair kp = new KeyPair(keyStore.getCertificate(alias).getPublicKey(), + (PrivateKey) keyStore.getKey(alias, password)); + certificateKeyPair = new CertificateKeyPair(kp, (X509Certificate) keyStore.getCertificate(alias)); + } + } + + public String getHost() { + return host; + } + + public void setHost(String host) { + this.host = host; + } + + public String getPort() { + return port; + } + + public String getEndpoint() { + return endpoint; + } + + public String getTransportEndpoint() { + return transportEndpoint; + } + + public Boolean getEncrypted() { + return isEncrypted; + } + + public PascalByteString getThumbprint() { + return thumbprint; + } + + public void setThumbprint(PascalByteString thumbprint) { + this.thumbprint = thumbprint; + } + + public byte[] getSenderCertificate() { + return senderCertificate; + } + + public void setSenderCertificate(byte[] senderCertificate) { + this.senderCertificate = senderCertificate; + } + + public CertificateKeyPair getCertificateKeyPair() { + return certificateKeyPair; + } + + @Override + public void setConfiguration(OpcuaConfiguration configuration) { + Matcher matcher = getMatcher(configuration); + code = matcher.group("transportCode"); + host = matcher.group("transportHost"); + port = matcher.group("transportPort"); + transportEndpoint = matcher.group("transportEndpoint"); + + String portAddition = port != null ? ":" + port : ""; + endpoint = "opc." + code + "://" + host + portAddition + transportEndpoint; + + + if (configuration.getSecurityPolicy() != null && !(configuration.getSecurityPolicy().equals("None"))) { + try { + openKeyStore(configuration); + } catch (Exception e) { + throw new PlcRuntimeException("Unable to open keystore, please confirm you have the correct permissions"); + } + } + } + + private static Matcher getMatcher(OpcuaConfiguration configuration) { + String uri = configuration.getProtocolCode() + ":" + configuration.getTransportCode() + "://" + configuration.getTransportConfig(); + + // Split up the connection string into it's individual segments. + Matcher matcher = URI_PATTERN.matcher(uri); + if (!matcher.matches()) { + throw new PlcRuntimeException( + "Connection string doesn't match the format '{protocol-code}:({transport-code})?//{transport-host}(:{transport-port})(/{transport-endpoint})(?{parameter-string)?': " + uri); + } + return matcher; + } +} diff --git a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/SecureChannel.java b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/SecureChannel.java index 507be1f28bd..138c5240d78 100644 --- a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/SecureChannel.java +++ b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/context/SecureChannel.java @@ -25,7 +25,6 @@ import org.apache.plc4x.java.opcua.config.OpcuaConfiguration; import org.apache.plc4x.java.opcua.readwrite.*; import org.apache.plc4x.java.spi.ConversationContext; -import org.apache.plc4x.java.spi.context.DriverContext; import org.apache.plc4x.java.spi.generation.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -69,7 +68,7 @@ public class SecureChannel { private static final PascalString SECURITY_POLICY_NONE = new PascalString("http://opcfoundation.org/UA/SecurityPolicy#None"); protected static final PascalString NULL_STRING = new PascalString(""); private static final PascalByteString NULL_BYTE_STRING = new PascalByteString(-1, null); - private static final ExpandedNodeId NULL_EXPANDED_NODEID = new ExpandedNodeId(false, + private static final ExpandedNodeId NULL_EXPANDED_NODE_ID = new ExpandedNodeId(false, false, new NodeIdTwoByte((short) 0), null, @@ -77,7 +76,7 @@ public class SecureChannel { ); protected static final ExtensionObject NULL_EXTENSION_OBJECT = new ExtensionObject( - NULL_EXPANDED_NODEID, + NULL_EXPANDED_NODE_ID, new ExtensionObjectEncodingMask(false, false, false), new NullExtension()); // Body @@ -87,7 +86,7 @@ public class SecureChannel { public static final Pattern URI_PATTERN = Pattern.compile("^(?opc)" + INET_ADDRESS_PATTERN + - "(?[\\w/=]*)[\\?]?" + "(?[\\w/=]*)[?]?" ); private static final long EPOCH_OFFSET = 116444736000000000L; //Offset between OPC UA epoch time and linux epoch time. @@ -100,10 +99,6 @@ public class SecureChannel { private final AtomicInteger requestHandleGenerator = new AtomicInteger(1); private PascalString policyId; private UserTokenType tokenType; - private boolean discovery; - private String certFile; - private final String keyStoreFile; - private CertificateKeyPair ckp; private final PascalString endpoint; private final String username; private final String password; @@ -113,35 +108,32 @@ public class SecureChannel { private final boolean isEncrypted; private byte[] senderCertificate = null; private byte[] senderNonce = null; - private final PascalByteString certificateThumbprint = null; - private final boolean checkedEndpoints = false; - private EncryptionHandler encryptionHandler = null; + private final EncryptionHandler encryptionHandler; private final OpcuaConfiguration configuration; + private final OpcuaDriverContext driverContext; private final AtomicInteger channelId = new AtomicInteger(1); private final AtomicInteger tokenId = new AtomicInteger(1); private NodeIdTypeDefinition authenticationToken = new NodeIdTwoByte((short) 0); - ConversationContext context; + private ConversationContext context; private final SecureChannelTransactionManager channelTransactionManager = new SecureChannelTransactionManager(); private long lifetime = DEFAULT_CONNECTION_LIFETIME; private CompletableFuture keepAlive; - private int sendBufferSize; - private int maxMessageSize; private final List endpoints = new ArrayList<>(); - private final AtomicLong senderSequenceNumber = new AtomicLong(); - public SecureChannel(DriverContext driverContext, OpcuaConfiguration configuration) { + public SecureChannel(OpcuaDriverContext driverContext, OpcuaConfiguration configuration) { this.configuration = configuration; - this.endpoint = new PascalString(configuration.getEndpoint()); + this.driverContext = driverContext; + this.endpoint = new PascalString(driverContext.getEndpoint()); this.username = configuration.getUsername(); this.password = configuration.getPassword(); this.securityPolicy = "http://opcfoundation.org/UA/SecurityPolicy#" + configuration.getSecurityPolicy(); - CertificateKeyPair ckp = configuration.getCertificateKeyPair(); + CertificateKeyPair ckp = driverContext.getCertificateKeyPair(); if (configuration.getSecurityPolicy() != null && configuration.getSecurityPolicy().equals("Basic256Sha256")) { //Sender Certificate gets populated during the 'discover' phase when encryption is enabled. - this.senderCertificate = configuration.getSenderCertificate(); + this.senderCertificate = driverContext.getSenderCertificate(); this.encryptionHandler = new EncryptionHandler(ckp, this.senderCertificate, configuration.getSecurityPolicy()); try { this.publicCertificate = new PascalByteString(ckp.getCertificate().getEncoded().length, ckp.getCertificate().getEncoded()); @@ -149,24 +141,23 @@ public SecureChannel(DriverContext driverContext, OpcuaConfiguration configurati } catch (CertificateEncodingException e) { throw new PlcRuntimeException("Failed to encode the certificate"); } - this.thumbprint = configuration.getThumbprint(); + this.thumbprint = driverContext.getThumbprint(); } else { this.encryptionHandler = new EncryptionHandler(ckp, this.senderCertificate, configuration.getSecurityPolicy()); this.publicCertificate = NULL_BYTE_STRING; this.thumbprint = NULL_BYTE_STRING; this.isEncrypted = false; } - this.keyStoreFile = configuration.getKeyStoreFile(); // Generate a list of endpoints we can use. try { - InetAddress address = InetAddress.getByName(this.configuration.getHost()); + InetAddress address = InetAddress.getByName(driverContext.getHost()); this.endpoints.add(address.getHostAddress()); this.endpoints.add(address.getHostName()); this.endpoints.add(address.getCanonicalHostName()); } catch (UnknownHostException e) { LOGGER.warn("Unable to resolve host name. Using original host from connection string which may cause issues connecting to server"); - this.endpoints.add(this.configuration.getHost()); + this.endpoints.add(driverContext.getHost()); } } @@ -487,10 +478,10 @@ private void onConnectActivateSessionRequest(ConversationContext conte this.senderNonce = sessionResponse.getServerNonce().getStringValue(); String[] endpoints = new String[3]; try { - InetAddress address = InetAddress.getByName(this.configuration.getHost()); - endpoints[0] = "opc.tcp://" + address.getHostAddress() + ":" + configuration.getPort() + configuration.getTransportEndpoint(); - endpoints[1] = "opc.tcp://" + address.getHostName() + ":" + configuration.getPort() + configuration.getTransportEndpoint(); - endpoints[2] = "opc.tcp://" + address.getCanonicalHostName() + ":" + configuration.getPort() + configuration.getTransportEndpoint(); + InetAddress address = InetAddress.getByName(driverContext.getHost()); + endpoints[0] = "opc.tcp://" + address.getHostAddress() + ":" + driverContext.getPort() + driverContext.getTransportEndpoint(); + endpoints[1] = "opc.tcp://" + address.getHostName() + ":" + driverContext.getPort() + driverContext.getTransportEndpoint(); + endpoints[2] = "opc.tcp://" + address.getCanonicalHostName() + ":" + driverContext.getPort() + driverContext.getTransportEndpoint(); } catch (UnknownHostException e) { LOGGER.debug("error getting host", e); } @@ -728,6 +719,10 @@ private void onDisconnectCloseSecureChannel(ConversationContext contex } public void onDiscover(ConversationContext context) { + if (!driverContext.getEncrypted()) { + LOGGER.debug("not encrypted, ignoring onDiscover"); + return; + } // Only the TCP transport supports login. LOGGER.debug("Opcua Driver running in ACTIVE mode, discovering endpoints"); @@ -914,14 +909,14 @@ public void onDiscoverGetEndpointsRequest(ConversationContext context, EndpointDescription endpointDescription = (EndpointDescription) endpoint; if (endpointDescription.getEndpointUrl().getStringValue().equals(this.endpoint.getStringValue()) && endpointDescription.getSecurityPolicyUri().getStringValue().equals(this.securityPolicy)) { LOGGER.info("Found OPC UA endpoint {}", this.endpoint.getStringValue()); - this.configuration.setSenderCertificate(endpointDescription.getServerCertificate().getStringValue()); + driverContext.setSenderCertificate(endpointDescription.getServerCertificate().getStringValue()); } } try { MessageDigest messageDigest = MessageDigest.getInstance("SHA-1"); - byte[] digest = messageDigest.digest(this.configuration.getSenderCertificate()); - this.configuration.setThumbprint(new PascalByteString(digest.length, digest)); + byte[] digest = messageDigest.digest(driverContext.getSenderCertificate()); + driverContext.setThumbprint(new PascalByteString(digest.length, digest)); } catch (NoSuchAlgorithmException e) { LOGGER.error("Failed to find hashing algorithm"); } @@ -1183,16 +1178,16 @@ private boolean isEndpoint(EndpointDescription endpoint) throws PlcRuntimeExcept return false; } - if (!configuration.getPort().equals(matcher.group("transportPort"))) { + if (!driverContext.getPort().equals(matcher.group("transportPort"))) { return false; } - if (!configuration.getTransportEndpoint().equals(matcher.group("transportEndpoint"))) { + if (!driverContext.getTransportEndpoint().equals(matcher.group("transportEndpoint"))) { return false; } if (!configuration.isDiscovery()) { - configuration.setHost(matcher.group("transportHost")); + driverContext.setHost(matcher.group("transportHost")); } return true; @@ -1219,11 +1214,11 @@ private void hasIdentity(UserTokenPolicy[] policies) { /** * Creates an IdentityToken to authenticate with a server. * - * @param tokenType the token type - * @param securityPolicy the security policy + * @param tokenType the token type + * @param policyId the security policy * @return returns an ExtensionObject with an IdentityToken. */ - private ExtensionObject getIdentityToken(UserTokenType tokenType, String securityPolicy) { + private ExtensionObject getIdentityToken(UserTokenType tokenType, String policyId) { ExpandedNodeId extExpandedNodeId; switch (tokenType) { case userTokenTypeAnonymous: @@ -1241,7 +1236,7 @@ private ExtensionObject getIdentityToken(UserTokenType tokenType, String securit return new ExtensionObject( extExpandedNodeId, new ExtensionObjectEncodingMask(false, false, true), - new UserIdentityToken(new PascalString(securityPolicy), anonymousIdentityToken) + new UserIdentityToken(new PascalString(policyId), anonymousIdentityToken) ); case userTokenTypeUserName: //Encrypt the password using the server nonce and server public key @@ -1271,7 +1266,7 @@ private ExtensionObject getIdentityToken(UserTokenType tokenType, String securit return new ExtensionObject( extExpandedNodeId, new ExtensionObjectEncodingMask(false, false, true), - new UserIdentityToken(new PascalString(securityPolicy), userNameIdentityToken)); + new UserIdentityToken(new PascalString(policyId), userNameIdentityToken)); } return null; } diff --git a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java index f8ecec32458..fb320c26d93 100644 --- a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java +++ b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/protocol/OpcuaProtocolLogic.java @@ -26,6 +26,7 @@ import org.apache.plc4x.java.api.types.PlcValueType; import org.apache.plc4x.java.api.value.PlcValue; import org.apache.plc4x.java.opcua.config.OpcuaConfiguration; +import org.apache.plc4x.java.opcua.context.OpcuaDriverContext; import org.apache.plc4x.java.opcua.context.SecureChannel; import org.apache.plc4x.java.opcua.readwrite.*; import org.apache.plc4x.java.opcua.tag.OpcuaTag; @@ -76,7 +77,6 @@ public class OpcuaProtocolLogic extends Plc4xProtocolBase implements H private OpcuaConfiguration configuration; private final Map subscriptions = new HashMap<>(); private SecureChannel channel; - private final AtomicBoolean securedConnection = new AtomicBoolean(false); @Override public void setConfiguration(OpcuaConfiguration configuration) { @@ -99,7 +99,7 @@ public void onDisconnect(ConversationContext context) { @Override public void setDriverContext(DriverContext driverContext) { super.setDriverContext(driverContext); - this.channel = new SecureChannel(driverContext, this.configuration); + this.channel = new SecureChannel((OpcuaDriverContext) driverContext, this.configuration); } @Override @@ -107,7 +107,7 @@ public void onConnect(ConversationContext context) { LOGGER.debug("Opcua Driver running in ACTIVE mode."); if (this.channel == null) { - this.channel = new SecureChannel(driverContext, this.configuration); + this.channel = new SecureChannel((OpcuaDriverContext) driverContext, this.configuration); } this.channel.onConnect(context); } @@ -117,7 +117,7 @@ public void onDiscover(ConversationContext context) { // Only the TCP transport supports login. LOGGER.debug("Opcua Driver running in ACTIVE mode, discovering endpoints"); if (this.channel == null) { - this.channel = new SecureChannel(driverContext, this.configuration); + this.channel = new SecureChannel((OpcuaDriverContext) driverContext, this.configuration); } channel.onDiscover(context); } diff --git a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/tag/OpcuaTag.java b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/tag/OpcuaTag.java index 4b92e8a9d1d..7b945996241 100644 --- a/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/tag/OpcuaTag.java +++ b/plc4j/drivers/opcua/src/main/java/org/apache/plc4x/java/opcua/tag/OpcuaTag.java @@ -37,7 +37,7 @@ public class OpcuaTag implements PlcSubscriptionTag { - public static final Pattern ADDRESS_PATTERN = Pattern.compile("^ns=(?\\d+);(?[isgb])=(?[^;]+)?(;(?[a-zA-Z_]+))?"); + public static final Pattern ADDRESS_PATTERN = Pattern.compile("^ns=(?\\d+);(?[isgb])=(?[^;]+)?(;(?[a-zA-Z_]+))?$"); private final OpcuaIdentifierType identifierType; diff --git a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/ManualMiloOpcua.java b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/ManualMiloOpcua.java new file mode 100644 index 00000000000..8ac70f89e8a --- /dev/null +++ b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/ManualMiloOpcua.java @@ -0,0 +1,36 @@ +/* + * 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.opcua; + +import org.apache.plc4x.test.manual.ManualTest; + +public class ManualMiloOpcua extends ManualTest { + + public ManualMiloOpcua(String connectionString) { + super(connectionString); + } + + public static void main(String[] args) throws Exception { + ManualMiloOpcua manualMiloOpcua = new ManualMiloOpcua("opcua:tcp://milo.digitalpetri.com:62541/milo"); + manualMiloOpcua + .addTestCase("ns=2;i=10846;BOOL", 0) + .run(); + } +} diff --git a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/ManualPLC4XOpcua.java b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/ManualPLC4XOpcua.java index 6897b34253c..8e2297d1fc8 100644 --- a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/ManualPLC4XOpcua.java +++ b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/ManualPLC4XOpcua.java @@ -20,12 +20,8 @@ import org.apache.plc4x.java.DefaultPlcDriverManager; import org.apache.plc4x.java.api.PlcConnection; -import org.apache.plc4x.java.api.exceptions.PlcConnectionException; -import org.apache.plc4x.java.api.exceptions.PlcRuntimeException; import org.apache.plc4x.java.api.messages.*; -import org.apache.plc4x.java.api.model.PlcTag; import org.apache.plc4x.java.api.types.PlcResponseCode; -import org.apache.plc4x.java.opcua.tag.OpcuaPlcTagHandler; import org.apache.plc4x.java.opcua.protocol.OpcuaSubscriptionHandle; import org.eclipse.milo.examples.server.ExampleServer; @@ -41,7 +37,6 @@ * The current version is tested against a public server, which is to be replaced later by a separate instance of the Milo framework. * Afterwards the code represented here will be used as an example for the introduction page. *

- * */ public class ManualPLC4XOpcua { private static final String BOOL_IDENTIFIER = "ns=2;s=HelloWorld/ScalarTypes/Boolean"; @@ -80,67 +75,54 @@ public class ManualPLC4XOpcua { //Don't exists private static final String DOES_NOT_EXIST_IDENTIFIER = "ns=2;i=12512623"; - public static void main(String... args) { + public static void main(String... args) throws Exception { + // When switching JDK versions from a newer to an older version, + // this can cause the server to not start correctly. + // Deleting the directory makes sure the key-store is initialized correctly. + Path securityBaseDir = Paths.get(System.getProperty("java.io.tmpdir"), "server", "security"); try { - // When switching JDK versions from a newer to an older version, - // this can cause the server to not start correctly. - // Deleting the directory makes sure the key-store is initialized correctly. - Path securityBaseDir = Paths.get(System.getProperty("java.io.tmpdir"), "server", "security"); - try { - Files.delete(securityBaseDir); - } catch (Exception e) { - // Ignore this ... - } - - ExampleServer testServer = new ExampleServer(); - testServer.startup().get(); + Files.delete(securityBaseDir); } catch (Exception e) { - throw new PlcRuntimeException(e); + // Ignore this ... } - PlcConnection opcuaConnection = null; - OpcuaPlcTagHandler tagH = new OpcuaPlcTagHandler(); - PlcTag tag = tagH.parseTag(BOOL_IDENTIFIER); - try { - opcuaConnection = new DefaultPlcDriverManager().getConnection("opcua:tcp://127.0.0.1:12686/milo?discovery=false"); - } catch (PlcConnectionException e) { - throw new PlcRuntimeException(e); - } - try { - PlcReadRequest.Builder builder = opcuaConnection.readRequestBuilder(); - builder.addTagAddress("Bool", BOOL_IDENTIFIER); - builder.addTagAddress("ByteString", BYTE_STRING_IDENTIFIER); - builder.addTagAddress("Byte", BYTE_IDENTIFIER); - builder.addTagAddress("Double", DOUBLE_IDENTIFIER); - builder.addTagAddress("Float", FLOAT_IDENTIFIER); - builder.addTagAddress("Int16", INT16_IDENTIFIER); - builder.addTagAddress("Int32", INT32_IDENTIFIER); - builder.addTagAddress("Int64", INT64_IDENTIFIER); - builder.addTagAddress("Integer", INTEGER_IDENTIFIER); - builder.addTagAddress("SByte", SBYTE_IDENTIFIER); - builder.addTagAddress("String", STRING_IDENTIFIER); - builder.addTagAddress("UInt16", UINT16_IDENTIFIER); - builder.addTagAddress("UInt32", UINT32_IDENTIFIER); - builder.addTagAddress("UInt64", UINT64_IDENTIFIER); - builder.addTagAddress("UInteger", UINTEGER_IDENTIFIER); - - builder.addTagAddress("BoolArray", BOOL_ARRAY_IDENTIFIER); - builder.addTagAddress("ByteStringArray", BYTE_STRING_ARRAY_IDENTIFIER); - builder.addTagAddress("ByteArray", BYTE_ARRAY_IDENTIFIER); - builder.addTagAddress("DoubleArray", DOUBLE_ARRAY_IDENTIFIER); - builder.addTagAddress("FloatArray", FLOAT_ARRAY_IDENTIFIER); - builder.addTagAddress("Int16Array", INT16_ARRAY_IDENTIFIER); - builder.addTagAddress("Int32Array", INT32_ARRAY_IDENTIFIER); - builder.addTagAddress("Int64Array", INT64_ARRAY_IDENTIFIER); - builder.addTagAddress("IntegerArray", INTEGER_ARRAY_IDENTIFIER); - builder.addTagAddress("SByteArray", SBYTE_ARRAY_IDENTIFIER); - builder.addTagAddress("StringArray", STRING_ARRAY_IDENTIFIER); - builder.addTagAddress("UInt16Array", UINT16_ARRAY_IDENTIFIER); - builder.addTagAddress("UInt32Array", UINT32_ARRAY_IDENTIFIER); - builder.addTagAddress("UInt64Array", UINT64_ARRAY_IDENTIFIER); - builder.addTagAddress("UIntegerArray", UINTEGER_ARRAY_IDENTIFIER); - - builder.addTagAddress("DoesNotExists", DOES_NOT_EXIST_IDENTIFIER); + ExampleServer testServer = new ExampleServer(); + testServer.startup().get(); + try (PlcConnection opcuaConnection = new DefaultPlcDriverManager().getConnection("opcua:tcp://127.0.0.1:12686/milo?discovery=false")) { + PlcReadRequest.Builder builder = opcuaConnection.readRequestBuilder(). + addTagAddress("Bool", BOOL_IDENTIFIER). + addTagAddress("ByteString", BYTE_STRING_IDENTIFIER). + addTagAddress("Byte", BYTE_IDENTIFIER). + addTagAddress("Double", DOUBLE_IDENTIFIER). + addTagAddress("Float", FLOAT_IDENTIFIER). + addTagAddress("Int16", INT16_IDENTIFIER). + addTagAddress("Int32", INT32_IDENTIFIER). + addTagAddress("Int64", INT64_IDENTIFIER). + addTagAddress("Integer", INTEGER_IDENTIFIER). + addTagAddress("SByte", SBYTE_IDENTIFIER). + addTagAddress("String", STRING_IDENTIFIER). + addTagAddress("UInt16", UINT16_IDENTIFIER). + addTagAddress("UInt32", UINT32_IDENTIFIER). + addTagAddress("UInt64", UINT64_IDENTIFIER). + addTagAddress("UInteger", UINTEGER_IDENTIFIER). + + addTagAddress("BoolArray", BOOL_ARRAY_IDENTIFIER). + addTagAddress("ByteStringArray", BYTE_STRING_ARRAY_IDENTIFIER). + addTagAddress("ByteArray", BYTE_ARRAY_IDENTIFIER). + addTagAddress("DoubleArray", DOUBLE_ARRAY_IDENTIFIER). + addTagAddress("FloatArray", FLOAT_ARRAY_IDENTIFIER). + addTagAddress("Int16Array", INT16_ARRAY_IDENTIFIER). + addTagAddress("Int32Array", INT32_ARRAY_IDENTIFIER). + addTagAddress("Int64Array", INT64_ARRAY_IDENTIFIER). + addTagAddress("IntegerArray", INTEGER_ARRAY_IDENTIFIER). + addTagAddress("SByteArray", SBYTE_ARRAY_IDENTIFIER). + addTagAddress("StringArray", STRING_ARRAY_IDENTIFIER). + addTagAddress("UInt16Array", UINT16_ARRAY_IDENTIFIER). + addTagAddress("UInt32Array", UINT32_ARRAY_IDENTIFIER). + addTagAddress("UInt64Array", UINT64_ARRAY_IDENTIFIER). + addTagAddress("UIntegerArray", UINTEGER_ARRAY_IDENTIFIER). + + addTagAddress("DoesNotExists", DOES_NOT_EXIST_IDENTIFIER); PlcReadRequest request = builder.build(); @@ -149,60 +131,62 @@ public static void main(String... args) { //Collection coll = response.getAllStrings("String"); - PlcWriteRequest.Builder wBuilder = opcuaConnection.writeRequestBuilder(); - wBuilder.addTagAddress("w-Bool", BOOL_IDENTIFIER, true); - //wBuilder.addTagAddress("w-ByteString", BYTE_STRING_IDENTIFIER, "TEST".getBytes()); - wBuilder.addTagAddress("w-Byte", BYTE_IDENTIFIER, (byte) 1); - wBuilder.addTagAddress("w-Double", DOUBLE_IDENTIFIER, (double) 0.25); - wBuilder.addTagAddress("w-Float", FLOAT_IDENTIFIER, (float) 0.25); - wBuilder.addTagAddress("w-INT16", INT16_IDENTIFIER, 12); - wBuilder.addTagAddress("w-Int32", INT32_IDENTIFIER, (int) 314); - wBuilder.addTagAddress("w-Int64", INT64_IDENTIFIER, (long) 123125); - wBuilder.addTagAddress("w-Integer", INTEGER_IDENTIFIER, (int) 314); - wBuilder.addTagAddress("w-SByte", SBYTE_IDENTIFIER, (byte) 1); - wBuilder.addTagAddress("w-String", STRING_IDENTIFIER, "TEST"); - wBuilder.addTagAddress("w-UInt16", UINT16_IDENTIFIER, new BigInteger("12")); - wBuilder.addTagAddress("w-UInt32", UINT32_IDENTIFIER, new BigInteger("123")); - wBuilder.addTagAddress("w-UInt64", UINT64_IDENTIFIER, new BigInteger("1245152")); - wBuilder.addTagAddress("w-UInteger", UINTEGER_IDENTIFIER, new BigInteger("1245152")); + PlcWriteRequest.Builder wBuilder = opcuaConnection.writeRequestBuilder(). + addTagAddress("w-Bool", BOOL_IDENTIFIER, true). + + //addTagAddress("w-ByteString", BYTE_STRING_IDENTIFIER, "TEST".getBytes()). + addTagAddress("w-Byte", BYTE_IDENTIFIER, (byte) 1). + + addTagAddress("w-Double", DOUBLE_IDENTIFIER, (double) 0.25). + addTagAddress("w-Float", FLOAT_IDENTIFIER, (float) 0.25). + addTagAddress("w-INT16", INT16_IDENTIFIER, 12). + addTagAddress("w-Int32", INT32_IDENTIFIER, (int) 314). + addTagAddress("w-Int64", INT64_IDENTIFIER, (long) 123125). + addTagAddress("w-Integer", INTEGER_IDENTIFIER, (int) 314). + addTagAddress("w-SByte", SBYTE_IDENTIFIER, (byte) 1). + addTagAddress("w-String", STRING_IDENTIFIER, "TEST"). + addTagAddress("w-UInt16", UINT16_IDENTIFIER, new BigInteger("12")). + addTagAddress("w-UInt32", UINT32_IDENTIFIER, new BigInteger("123")). + addTagAddress("w-UInt64", UINT64_IDENTIFIER, new BigInteger("1245152")). + addTagAddress("w-UInteger", UINTEGER_IDENTIFIER, new BigInteger("1245152")); PlcWriteRequest writeRequest = wBuilder.build(); PlcWriteResponse wResponse = writeRequest.execute().get(); // Create Subscription - PlcSubscriptionRequest.Builder sBuilder = opcuaConnection.subscriptionRequestBuilder(); - sBuilder.addChangeOfStateTagAddress("Bool", BOOL_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("ByteString", BYTE_STRING_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("Byte", BYTE_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("Double", DOUBLE_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("Float", FLOAT_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("Int16", INT16_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("Int32", INT32_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("Int64", INT64_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("Integer", INTEGER_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("SByte", SBYTE_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("String", STRING_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("UInt16", UINT16_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("UInt32", UINT32_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("UInt64", UINT64_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("UInteger", UINTEGER_IDENTIFIER); - - sBuilder.addChangeOfStateTagAddress("BoolArray", BOOL_ARRAY_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("ByteStringArray", BYTE_STRING_ARRAY_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("ByteArray", BYTE_ARRAY_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("DoubleArray", DOUBLE_ARRAY_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("FloatArray", FLOAT_ARRAY_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("Int16Array", INT16_ARRAY_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("Int32Array", INT32_ARRAY_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("Int64Array", INT64_ARRAY_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("IntegerArray", INTEGER_ARRAY_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("SByteArray", SBYTE_ARRAY_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("StringArray", STRING_ARRAY_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("UInt16Array", UINT16_ARRAY_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("UInt32Array", UINT32_ARRAY_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("UInt64Array", UINT64_ARRAY_IDENTIFIER); - sBuilder.addChangeOfStateTagAddress("UIntegerArray", UINTEGER_ARRAY_IDENTIFIER); - - sBuilder.addChangeOfStateTagAddress("DoesNotExists", DOES_NOT_EXIST_IDENTIFIER); + PlcSubscriptionRequest.Builder sBuilder = opcuaConnection.subscriptionRequestBuilder(). + addChangeOfStateTagAddress("Bool", BOOL_IDENTIFIER). + addChangeOfStateTagAddress("ByteString", BYTE_STRING_IDENTIFIER). + addChangeOfStateTagAddress("Byte", BYTE_IDENTIFIER). + addChangeOfStateTagAddress("Double", DOUBLE_IDENTIFIER). + addChangeOfStateTagAddress("Float", FLOAT_IDENTIFIER). + addChangeOfStateTagAddress("Int16", INT16_IDENTIFIER). + addChangeOfStateTagAddress("Int32", INT32_IDENTIFIER). + addChangeOfStateTagAddress("Int64", INT64_IDENTIFIER). + addChangeOfStateTagAddress("Integer", INTEGER_IDENTIFIER). + addChangeOfStateTagAddress("SByte", SBYTE_IDENTIFIER). + addChangeOfStateTagAddress("String", STRING_IDENTIFIER). + addChangeOfStateTagAddress("UInt16", UINT16_IDENTIFIER). + addChangeOfStateTagAddress("UInt32", UINT32_IDENTIFIER). + addChangeOfStateTagAddress("UInt64", UINT64_IDENTIFIER). + addChangeOfStateTagAddress("UInteger", UINTEGER_IDENTIFIER). + + addChangeOfStateTagAddress("BoolArray", BOOL_ARRAY_IDENTIFIER). + addChangeOfStateTagAddress("ByteStringArray", BYTE_STRING_ARRAY_IDENTIFIER). + addChangeOfStateTagAddress("ByteArray", BYTE_ARRAY_IDENTIFIER). + addChangeOfStateTagAddress("DoubleArray", DOUBLE_ARRAY_IDENTIFIER). + addChangeOfStateTagAddress("FloatArray", FLOAT_ARRAY_IDENTIFIER). + addChangeOfStateTagAddress("Int16Array", INT16_ARRAY_IDENTIFIER). + addChangeOfStateTagAddress("Int32Array", INT32_ARRAY_IDENTIFIER). + addChangeOfStateTagAddress("Int64Array", INT64_ARRAY_IDENTIFIER). + addChangeOfStateTagAddress("IntegerArray", INTEGER_ARRAY_IDENTIFIER). + addChangeOfStateTagAddress("SByteArray", SBYTE_ARRAY_IDENTIFIER). + addChangeOfStateTagAddress("StringArray", STRING_ARRAY_IDENTIFIER). + addChangeOfStateTagAddress("UInt16Array", UINT16_ARRAY_IDENTIFIER). + addChangeOfStateTagAddress("UInt32Array", UINT32_ARRAY_IDENTIFIER). + addChangeOfStateTagAddress("UInt64Array", UINT64_ARRAY_IDENTIFIER). + addChangeOfStateTagAddress("UIntegerArray", UINTEGER_ARRAY_IDENTIFIER). + + addChangeOfStateTagAddress("DoesNotExists", DOES_NOT_EXIST_IDENTIFIER); PlcSubscriptionRequest subscriptionRequest = sBuilder.build(); // Get result of creating subscription @@ -220,11 +204,6 @@ public static void main(String... args) { subscriptionHandle.stopSubscriber(); Thread.sleep(20000); - opcuaConnection.close(); - - } catch (Exception e) { - throw new PlcRuntimeException(e); } - } } diff --git a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaDriverIT.java b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaDriverIT.java index 1ef7e526f88..f2e2dd7dc16 100644 --- a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaDriverIT.java +++ b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaDriverIT.java @@ -23,7 +23,7 @@ public class OpcuaDriverIT extends DriverTestsuiteRunner { public OpcuaDriverIT() { - super("/protocols/opcua/DriverTestsuite.xml", true); + super("/protocols/opcua/DriverTestsuite.xml", false); } } diff --git a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java index 0de19d26db1..d8c5038599f 100644 --- a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java +++ b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/OpcuaPlcDriverTest.java @@ -29,23 +29,22 @@ import org.assertj.core.api.Condition; import org.eclipse.milo.examples.server.ExampleServer; import org.junit.jupiter.api.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import java.math.BigInteger; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.Arrays; import java.util.concurrent.ExecutionException; import java.util.stream.Stream; -import static org.apache.plc4x.java.opcua.OpcuaPlcDriver.INET_ADDRESS_PATTERN; -import static org.apache.plc4x.java.opcua.OpcuaPlcDriver.URI_PATTERN; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.fail; -import static org.junit.jupiter.api.Assumptions.assumeTrue; public class OpcuaPlcDriverTest { + private static final Logger LOGGER = LoggerFactory.getLogger(OpcuaPlcDriverTest.class); + // Read only variables of milo example server of version 3.6 private static final String BOOL_IDENTIFIER_READ_WRITE = "ns=2;s=HelloWorld/ScalarTypes/Boolean"; private static final String BYTE_IDENTIFIER_READ_WRITE = "ns=2;s=HelloWorld/ScalarTypes/Byte"; @@ -176,11 +175,6 @@ Stream connectionWithDiscoveryParam() throws Exception { @Nested class readWrite { - @BeforeEach - public void testForLinux() { - checkForLinux(); // TODO: seems those do not run on linux - } - @Test public void readVariables() throws Exception { PlcConnection opcuaConnection = new DefaultPlcDriverManager().getConnection(tcpConnectionAddress); @@ -221,33 +215,35 @@ public void readVariables() throws Exception { PlcReadRequest request = builder.build(); PlcReadResponse response = request.execute().get(); - assertThat(response.getResponseCode("Bool")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("Byte")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("Double")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("Float")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("Int16")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("Int32")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("Int64")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("Integer")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("SByte")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("String")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("UInt16")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("UInt32")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("UInt64")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("UInteger")).isEqualTo(PlcResponseCode.OK); - - assertThat(response.getResponseCode("BoolArray")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("ByteArray")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("DoubleArray")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("FloatArray")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("Int16Array")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("Int32Array")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("Int64Array")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("SByteArray")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("StringArray")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("UInt16Array")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("UInt32Array")).isEqualTo(PlcResponseCode.OK); - assertThat(response.getResponseCode("UInt64Array")).isEqualTo(PlcResponseCode.OK); + List.of( + "Bool", + "Byte", + "Double", + "Float", + "Int16", + "Int32", + "Int64", + "Integer", + "SByte", + "String", + "UInt16", + "UInt32", + "UInt64", + "UInteger", + "BoolArray", + "ByteArray", + "DoubleArray", + "FloatArray", + "Int16Array", + "Int32Array", + "Int64Array", + "SByteArray", + "StringArray", + "UInt16Array", + "UInt32Array", + "UInt64Array" + ).forEach(tag -> assertThat(response.getResponseCode(tag)).isEqualTo(PlcResponseCode.OK)); + assertThat(response.getResponseCode("DoesNotExists")).isEqualTo(PlcResponseCode.NOT_FOUND); @@ -337,38 +333,12 @@ public void writeVariables() throws Exception { } - - @Test - public void testOpcuaAddressPattern() { - assertThat(":tcp://localhost").matches(INET_ADDRESS_PATTERN); - assertThat(":tcp://localhost:3131").matches(INET_ADDRESS_PATTERN); - assertThat(":tcp://www.google.de").matches(INET_ADDRESS_PATTERN); - assertThat(":tcp://www.google.de:443").matches(INET_ADDRESS_PATTERN); - assertThat(":tcp://127.0.0.1").matches(INET_ADDRESS_PATTERN); - assertThat(":tcp://127.0.0.1:251").matches(INET_ADDRESS_PATTERN); - assertThat(":tcp://254.254.254.254:1337").matches(INET_ADDRESS_PATTERN); - assertThat(":tcp://254.254.254.254").matches(INET_ADDRESS_PATTERN); - - - assertThat("opcua:tcp://localhost").matches(URI_PATTERN); - assertThat("opcua:tcp://localhost:3131").matches(URI_PATTERN); - assertThat("opcua:tcp://www.google.de").matches(URI_PATTERN); - assertThat("opcua:tcp://www.google.de:443").matches(URI_PATTERN); - assertThat("opcua:tcp://127.0.0.1").matches(URI_PATTERN); - assertThat("opcua:tcp://127.0.0.1:251").matches(URI_PATTERN); - assertThat("opcua:tcp://254.254.254.254:1337").matches(URI_PATTERN); - assertThat("opcua:tcp://254.254.254.254").matches(URI_PATTERN); - - assertThat("opcua:tcp://127.0.0.1?discovery=false").matches(URI_PATTERN); - assertThat("opcua:tcp://opcua.demo-this.com:51210/UA/SampleServer?discovery=false").matches(URI_PATTERN); - } - /* Test added to test the syncronized Trnasactionhandler. The test originally failed one out of every 5 or so. */ - - public void multipleThreads() { + //@Test + public void multipleThreads() throws Exception { class ReadWorker extends Thread { private final PlcConnection connection; @@ -388,10 +358,12 @@ public void run() { assertThat(read_response.getResponseCode("Bool")).isEqualTo(PlcResponseCode.OK); } - } catch (ExecutionException | InterruptedException executionException) { - executionException.printStackTrace(); + } catch (ExecutionException e) { + LOGGER.error("run aborted", e); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new RuntimeException(e); } - } } @@ -413,81 +385,30 @@ public void run() { PlcWriteResponse write_response = write_request.execute().get(); assertThat(write_response.getResponseCode("Bool")).isEqualTo(PlcResponseCode.OK); } - } catch (ExecutionException | InterruptedException executionException) { - executionException.printStackTrace(); + } catch (ExecutionException e) { + LOGGER.error("run aborted", e); + } catch (InterruptedException e) { + Thread.currentThread().interrupt(); + throw new RuntimeException(e); } } } - try { - PlcConnection opcuaConnection = new DefaultPlcDriverManager().getConnection(tcpConnectionAddress); - Condition is_connected = new Condition<>(PlcConnection::isConnected, "is connected"); - assertThat(opcuaConnection).is(is_connected); + PlcConnection opcuaConnection = new DefaultPlcDriverManager().getConnection(tcpConnectionAddress); + Condition is_connected = new Condition<>(PlcConnection::isConnected, "is connected"); + assertThat(opcuaConnection).is(is_connected); - ReadWorker read_worker = new ReadWorker(opcuaConnection); - WriteWorker write_worker = new WriteWorker(opcuaConnection); - read_worker.start(); - write_worker.start(); + ReadWorker read_worker = new ReadWorker(opcuaConnection); + WriteWorker write_worker = new WriteWorker(opcuaConnection); + read_worker.start(); + write_worker.start(); - read_worker.join(); - write_worker.join(); + read_worker.join(); + write_worker.join(); - opcuaConnection.close(); - assert !opcuaConnection.isConnected(); - } catch (Exception e) { - fail("Exception during readVariables Test EXCEPTION: " + e.getMessage()); - } + opcuaConnection.close(); + assert !opcuaConnection.isConnected(); } - private final String[] validTCPOPC = { - "localhost", - "127.0.0.1", - "254.254.254.254" - }; - private final int[] validPorts = { - 1337, - 42, - 1, - 24152 - }; - private final String[] nDiscoveryParams = { - "discovery=false" - }; - - - @TestFactory - Stream testConnectionStringPattern() throws Exception { - return Arrays.stream(validTCPOPC) - .map(address -> DynamicContainer.dynamicContainer("Address: " + address, () -> Arrays.stream(validPorts) - .mapToObj(port -> DynamicTest.dynamicTest("Port: " + port, () -> { - assertThat("opcua:tcp://" + address + ":555?discovery=true").matches(URI_PATTERN); - assertThat("opcua:tcp://" + address + ":555?discovery=True").matches(URI_PATTERN); - assertThat("opcua:tcp://" + address + ":555?discovery=TRUE").matches(URI_PATTERN); - assertThat("opcua:tcp://" + address + ":555?Discovery=True").matches(URI_PATTERN); - //No Port Specified - assertThat("opcua:tcp://" + address + "?discovery=True").matches(URI_PATTERN); - //No Transport Specified - assertThat("opcua://" + address + ":647?discovery=True").matches(URI_PATTERN); - //No Params Specified - assertThat("opcua:tcp://" + address + ":111").matches(URI_PATTERN); - //No Transport and Params Specified - assertThat("opcua://" + address + ":754").matches(URI_PATTERN); - }) - ) - .map(DynamicNode.class::cast) - .iterator() - ) - ); - } - - static void checkForLinux() { - /*assumeTrue(() -> { - String OS = System.getProperty("os.name").toLowerCase(); - return !OS.contains("nix") - && !OS.contains("nux") - && !OS.contains("aix") - && !OS.contains("mac"); - }, "somehow opcua doesn't run properly on linux");*/ - } } diff --git a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/context/OpcuaDriverContextTest.java b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/context/OpcuaDriverContextTest.java new file mode 100644 index 00000000000..62dc142c8a5 --- /dev/null +++ b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/context/OpcuaDriverContextTest.java @@ -0,0 +1,98 @@ +/* + * 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.opcua.context; + +import org.junit.jupiter.api.*; + +import java.util.Arrays; +import java.util.stream.Stream; + +import static org.apache.plc4x.java.opcua.context.OpcuaDriverContext.INET_ADDRESS_PATTERN; +import static org.apache.plc4x.java.opcua.context.OpcuaDriverContext.URI_PATTERN; +import static org.assertj.core.api.Assertions.assertThat; + +class OpcuaDriverContextTest { + + @Test + public void testOpcuaAddressPattern() { + assertThat(":tcp://localhost").matches(INET_ADDRESS_PATTERN); + assertThat(":tcp://localhost:3131").matches(INET_ADDRESS_PATTERN); + assertThat(":tcp://www.google.de").matches(INET_ADDRESS_PATTERN); + assertThat(":tcp://www.google.de:443").matches(INET_ADDRESS_PATTERN); + assertThat(":tcp://127.0.0.1").matches(INET_ADDRESS_PATTERN); + assertThat(":tcp://127.0.0.1:251").matches(INET_ADDRESS_PATTERN); + assertThat(":tcp://254.254.254.254:1337").matches(INET_ADDRESS_PATTERN); + assertThat(":tcp://254.254.254.254").matches(INET_ADDRESS_PATTERN); + + + assertThat("opcua:tcp://localhost").matches(URI_PATTERN); + assertThat("opcua:tcp://localhost:3131").matches(URI_PATTERN); + assertThat("opcua:tcp://www.google.de").matches(URI_PATTERN); + assertThat("opcua:tcp://www.google.de:443").matches(URI_PATTERN); + assertThat("opcua:tcp://127.0.0.1").matches(URI_PATTERN); + assertThat("opcua:tcp://127.0.0.1:251").matches(URI_PATTERN); + assertThat("opcua:tcp://254.254.254.254:1337").matches(URI_PATTERN); + assertThat("opcua:tcp://254.254.254.254").matches(URI_PATTERN); + + assertThat("opcua:tcp://127.0.0.1?discovery=false").matches(URI_PATTERN); + assertThat("opcua:tcp://opcua.demo-this.com:51210/UA/SampleServer?discovery=false").matches(URI_PATTERN); + } + + + private final String[] validTCPOPC = { + "localhost", + "127.0.0.1", + "254.254.254.254" + }; + private final int[] validPorts = { + 1337, + 42, + 1, + 24152 + }; + private final String[] nDiscoveryParams = { + "discovery=false" + }; + + @TestFactory + Stream testConnectionStringPattern() throws Exception { + return Arrays.stream(validTCPOPC) + .map(address -> DynamicContainer.dynamicContainer("Address: " + address, () -> Arrays.stream(validPorts) + .mapToObj(port -> DynamicTest.dynamicTest("Port: " + port, () -> { + assertThat("opcua:tcp://" + address + ":555?discovery=true").matches(URI_PATTERN); + assertThat("opcua:tcp://" + address + ":555?discovery=True").matches(URI_PATTERN); + assertThat("opcua:tcp://" + address + ":555?discovery=TRUE").matches(URI_PATTERN); + assertThat("opcua:tcp://" + address + ":555?Discovery=True").matches(URI_PATTERN); + //No Port Specified + assertThat("opcua:tcp://" + address + "?discovery=True").matches(URI_PATTERN); + //No Transport Specified + assertThat("opcua://" + address + ":647?discovery=True").matches(URI_PATTERN); + //No Params Specified + assertThat("opcua:tcp://" + address + ":111").matches(URI_PATTERN); + //No Transport and Params Specified + assertThat("opcua://" + address + ":754").matches(URI_PATTERN); + }) + ) + .map(DynamicNode.class::cast) + .iterator() + ) + ); + } +} \ No newline at end of file diff --git a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandleTest.java b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandleTest.java index e3840350bf6..20dd30fa701 100644 --- a/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandleTest.java +++ b/plc4j/drivers/opcua/src/test/java/org/apache/plc4x/java/opcua/protocol/OpcuaSubscriptionHandleTest.java @@ -35,6 +35,8 @@ import java.nio.file.Paths; import java.util.concurrent.TimeUnit; +import static org.assertj.core.api.Assertions.assertThat; + // ! For some odd reason does this test not work on VMs running in Parallels. // cdutz: I have done way more than my fair share on tracking down this issue and am simply giving up on it. // I tracked it down into the core of Milo several times now, but got lost in there. @@ -75,55 +77,33 @@ public class OpcuaSubscriptionHandleTest { private static PlcConnection opcuaConnection; - @BeforeEach - public void before() { - } - - @AfterEach - public void after() { - - } - // ! If this test fails, see comment at the top of the class before investigating. @BeforeAll - public static void setup() { + public static void setup() throws Exception { + // When switching JDK versions from a newer to an older version, + // this can cause the server to not start correctly. + // Deleting the directory makes sure the key-store is initialized correctly. + Path securityBaseDir = Paths.get(System.getProperty("java.io.tmpdir"), "server", "security"); try { - // When switching JDK versions from a newer to an older version, - // this can cause the server to not start correctly. - // Deleting the directory makes sure the key-store is initialized correctly. - Path securityBaseDir = Paths.get(System.getProperty("java.io.tmpdir"), "server", "security"); - try { - Files.delete(securityBaseDir); - } catch (Exception e) { - // Ignore this ... - } - - exampleServer = new ExampleServer(); - exampleServer.startup().get(); - //Connect - opcuaConnection = new DefaultPlcDriverManager().getConnection(tcpConnectionAddress); - assert opcuaConnection.isConnected(); + Files.delete(securityBaseDir); } catch (Exception e) { - e.printStackTrace(); - try { - exampleServer.shutdown().get(); - } catch (Exception j) { - j.printStackTrace(); - } + // Ignore this ... } + + exampleServer = new ExampleServer(); + exampleServer.startup().get(); + //Connect + opcuaConnection = new DefaultPlcDriverManager().getConnection(tcpConnectionAddress); + assertThat(opcuaConnection).extracting(PlcConnection::isConnected).isEqualTo(true); } @AfterAll - public static void tearDown() { - try { - // Close Connection - opcuaConnection.close(); - assert !opcuaConnection.isConnected(); + public static void tearDown() throws Exception { + // Close Connection + opcuaConnection.close(); + assertThat(opcuaConnection).extracting(PlcConnection::isConnected).isEqualTo(false); - exampleServer.shutdown().get(); - } catch (Exception e) { - e.printStackTrace(); - } + exampleServer.shutdown().get(); } // ! If this test fails, see comment at the top of the class before investigating. diff --git a/plc4j/drivers/profinet/src/test/java/org/apache/plc4x/java/profinet/ProfinetBrowseTests.java b/plc4j/drivers/profinet/src/test/java/org/apache/plc4x/java/profinet/ProfinetBrowseTests.java index 28228fe3cb2..94bc173806b 100644 --- a/plc4j/drivers/profinet/src/test/java/org/apache/plc4x/java/profinet/ProfinetBrowseTests.java +++ b/plc4j/drivers/profinet/src/test/java/org/apache/plc4x/java/profinet/ProfinetBrowseTests.java @@ -32,15 +32,14 @@ import java.util.List; import java.util.Map; -import static org.junit.jupiter.api.Assertions.assertEquals; - @TestInstance(TestInstance.Lifecycle.PER_CLASS) public class ProfinetBrowseTests { @Test - public void readProfinetBrowseTagsCheckStatus() { + public void readProfinetBrowseTagsCheckStatus() { ProfinetConfiguration configuration = new ConfigurationFactory().createConfiguration( - ProfinetConfiguration.class, "gsddirectory=src/test/resources/&devices=[[device_name, PLC4X_1, (PLC4X_DUMMY_MODULE, , PLC4X_DUMMY_MODULE, )]]"); + ProfinetConfiguration.class, "", "", "", + "gsddirectory=src/test/resources/&devices=[[device_name, PLC4X_1, (PLC4X_DUMMY_MODULE, , PLC4X_DUMMY_MODULE, )]]" ); Map configuredDevices = configuration.getDevices().getConfiguredDevices(); Map devices = new HashMap<>(); @@ -66,9 +65,10 @@ public void readProfinetBrowseTagsCheckStatus() { } @Test - public void readProfinetBrowseTagsCheckFloat() { + public void readProfinetBrowseTagsCheckFloat() { ProfinetConfiguration configuration = new ConfigurationFactory().createConfiguration( - ProfinetConfiguration.class, "gsddirectory=src/test/resources/&devices=[[device_name, PLC4X_1, (PLC4X_DUMMY_MODULE, , PLC4X_DUMMY_MODULE, )]]"); + ProfinetConfiguration.class, "", "", "", + "gsddirectory=src/test/resources/&devices=[[device_name, PLC4X_1, (PLC4X_DUMMY_MODULE, , PLC4X_DUMMY_MODULE, )]]"); Map configuredDevices = configuration.getDevices().getConfiguredDevices(); Map devices = new HashMap<>(); @@ -96,9 +96,10 @@ public void readProfinetBrowseTagsCheckFloat() { } @Test - public void readProfinetBrowseTagsCheckBoolean() { + public void readProfinetBrowseTagsCheckBoolean() { ProfinetConfiguration configuration = new ConfigurationFactory().createConfiguration( - ProfinetConfiguration.class, "gsddirectory=src/test/resources/&devices=[[device_name, PLC4X_1, (PLC4X_DUMMY_MODULE, , PLC4X_DUMMY_MODULE, )]]"); + ProfinetConfiguration.class, "", "", "", + "gsddirectory=src/test/resources/&devices=[[device_name, PLC4X_1, (PLC4X_DUMMY_MODULE, , PLC4X_DUMMY_MODULE, )]]"); Map configuredDevices = configuration.getDevices().getConfiguredDevices(); Map devices = new HashMap<>(); diff --git a/plc4j/drivers/profinet/src/test/java/org/apache/plc4x/java/profinet/ProfinetDeviceContextTests.java b/plc4j/drivers/profinet/src/test/java/org/apache/plc4x/java/profinet/ProfinetDeviceContextTests.java index 4a4791a0df3..570ede8fd63 100644 --- a/plc4j/drivers/profinet/src/test/java/org/apache/plc4x/java/profinet/ProfinetDeviceContextTests.java +++ b/plc4j/drivers/profinet/src/test/java/org/apache/plc4x/java/profinet/ProfinetDeviceContextTests.java @@ -41,9 +41,10 @@ public class ProfinetDeviceContextTests { @Test - public void readProfinetAllocatedSubModulesLengthCheck() { + public void readProfinetAllocatedSubModulesLengthCheck() { ProfinetConfiguration configuration = new ConfigurationFactory().createConfiguration( - ProfinetConfiguration.class, "gsddirectory=src/test/resources/&devices=[[device_name_1, PLC4X_1, (PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE)]]"); + ProfinetConfiguration.class, "", "", "", + "gsddirectory=src/test/resources/&devices=[[device_name_1, PLC4X_1, (PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE)]]"); Map configuredDevices = configuration.getDevices().getConfiguredDevices(); Map devices = new HashMap<>(); @@ -60,7 +61,7 @@ public void readProfinetAllocatedSubModulesLengthCheck() { devices.get(entry.getValue().getDevicename()).setIpAddress(entry.getValue().getIpaddress()); } - ProfinetDevice device =devices.get("DEVICE_NAME_1"); + ProfinetDevice device = devices.get("DEVICE_NAME_1"); device.setVendorDeviceId("CAFE", "0001"); ProfinetModule[] modules = device.getDeviceContext().getModules(); @@ -69,9 +70,10 @@ public void readProfinetAllocatedSubModulesLengthCheck() { } @Test - public void readProfinetAllocatedSubModulesTypeCheck() { + public void readProfinetAllocatedSubModulesTypeCheck() { ProfinetConfiguration configuration = new ConfigurationFactory().createConfiguration( - ProfinetConfiguration.class, "gsddirectory=src/test/resources/&devices=[[device_name_1, PLC4X_1, (PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE)]]"); + ProfinetConfiguration.class, "", "", "", + "gsddirectory=src/test/resources/&devices=[[device_name_1, PLC4X_1, (PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE)]]"); Map configuredDevices = configuration.getDevices().getConfiguredDevices(); Map devices = new HashMap<>(); @@ -102,9 +104,10 @@ public void readProfinetAllocatedSubModulesTypeCheck() { } @Test - public void readProfinetAllocatedSubModulesTypeCheckEmptyModule() { + public void readProfinetAllocatedSubModulesTypeCheckEmptyModule() { ProfinetConfiguration configuration = new ConfigurationFactory().createConfiguration( - ProfinetConfiguration.class, "gsddirectory=src/test/resources/&devices=[[device_name_1, PLC4X_1, (PLC4X_DUMMY_MODULE, , PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE)]]"); + ProfinetConfiguration.class, "", "", "", + "gsddirectory=src/test/resources/&devices=[[device_name_1, PLC4X_1, (PLC4X_DUMMY_MODULE, , PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE)]]"); Map configuredDevices = configuration.getDevices().getConfiguredDevices(); Map devices = new HashMap<>(); @@ -135,9 +138,9 @@ public void readProfinetAllocatedSubModulesTypeCheckEmptyModule() { } @Test - public void readExpectedSubModuleApiBlocks() { + public void readExpectedSubModuleApiBlocks() { ProfinetConfiguration configuration = new ConfigurationFactory().createConfiguration( - ProfinetConfiguration.class, "gsddirectory=src/test/resources/&devices=[[device_name_1, PLC4X_1, (PLC4X_DUMMY_MODULE, , PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE)]]"); + ProfinetConfiguration.class, "", "", "", "gsddirectory=src/test/resources/&devices=[[device_name_1, PLC4X_1, (PLC4X_DUMMY_MODULE, , PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE)]]"); Map configuredDevices = configuration.getDevices().getConfiguredDevices(); Map devices = new HashMap<>(); diff --git a/plc4j/drivers/profinet/src/test/java/org/apache/plc4x/java/profinet/gsdml/ProfinetConfigurationTests.java b/plc4j/drivers/profinet/src/test/java/org/apache/plc4x/java/profinet/gsdml/ProfinetConfigurationTests.java index 26589e1bb08..4fb9a7b4c2f 100644 --- a/plc4j/drivers/profinet/src/test/java/org/apache/plc4x/java/profinet/gsdml/ProfinetConfigurationTests.java +++ b/plc4j/drivers/profinet/src/test/java/org/apache/plc4x/java/profinet/gsdml/ProfinetConfigurationTests.java @@ -48,7 +48,8 @@ public class ProfinetConfigurationTests { public void readGsdDirectory() { String directory = "src/test/resources"; ProfinetConfiguration configuration = new ConfigurationFactory().createConfiguration( - ProfinetConfiguration.class, "devices=[[device_name_1, PLC4X, (PLC4X_1)]]&gsddirectory=" + directory); + ProfinetConfiguration.class, "", "", "", + "devices=[[device_name_1, PLC4X, (PLC4X_1)]]&gsddirectory=" + directory); assertEquals(1, configuration.getGsdFiles().getGsdFiles().size()); } @@ -58,7 +59,8 @@ public void readGsdFilesInDirectory() { String directory = "src/test/resources"; new ConfigurationFactory().createConfiguration( - ProfinetConfiguration.class, "devices=[[device_name_1, PLC4X, (PLC4X_1)]]&gsddirectory=" + directory); + ProfinetConfiguration.class, "", "", "", + "devices=[[device_name_1, PLC4X, (PLC4X_1)]]&gsddirectory=" + directory); Map gsdFiles = ProfinetConfiguration.getGsdFiles().getGsdFiles(); assertEquals(gsdFiles.size(), 1); @@ -67,7 +69,7 @@ public void readGsdFilesInDirectory() { @Test public void parseJoinedDeviceConfiguration() { ProfinetConfiguration configuration = new ConfigurationFactory().createConfiguration( - ProfinetConfiguration.class, "gsddirectory=src/test/resources&devices=[[device_name_1,device_access_1,(submodule_1,submodule_2)]]"); + ProfinetConfiguration.class, "", "", "", "gsddirectory=src/test/resources&devices=[[device_name_1,device_access_1,(submodule_1,submodule_2)]]"); assertEquals(1, configuration.getDevices().getConfiguredDevices().size()); } @@ -79,7 +81,7 @@ public void parseJoinedDeviceConfigurationExtraSpaces() { String[] deviceNames = new String[] {"DEVICE_NAME_1"}; ProfinetConfiguration configuration = new ConfigurationFactory().createConfiguration( - ProfinetConfiguration.class, "devices=[[device_name_1, device_access_1, (submodule_1, submodule_2)]]&gsddirectory=src/test/resources"); + ProfinetConfiguration.class, "", "", "", "devices=[[device_name_1, device_access_1, (submodule_1, submodule_2)]]&gsddirectory=src/test/resources"); Map devices = configuration.getDevices().getConfiguredDevices(); @@ -93,7 +95,7 @@ public void readProfinetDevicesMultiple() { String[] deviceNames = new String[] {"DEVICE_NAME_1","DEVICE_NAME_2","DEVICE_NAME_3"}; ProfinetConfiguration configuration = new ConfigurationFactory().createConfiguration( - ProfinetConfiguration.class, "devices=[[device_name_1, PLC4X_1, (PLC4X_01,PLC4X_02,PLC4X_01,PLC4X_02)],[device_name_2, PLC4X_1, (PLC4X_01,PLC4X_02,PLC4X_01,PLC4X_02)],[device_name_3, PLC4X_1, (PLC4X_01,PLC4X_02,PLC4X_01,PLC4X_02)]]&gsddirectory=src/test/resources"); + ProfinetConfiguration.class, "", "", "", "devices=[[device_name_1, PLC4X_1, (PLC4X_01,PLC4X_02,PLC4X_01,PLC4X_02)],[device_name_2, PLC4X_1, (PLC4X_01,PLC4X_02,PLC4X_01,PLC4X_02)],[device_name_3, PLC4X_1, (PLC4X_01,PLC4X_02,PLC4X_01,PLC4X_02)]]&gsddirectory=src/test/resources"); Map devices = configuration.getDevices().getConfiguredDevices(); @@ -106,7 +108,7 @@ public void readProfinetDevicesMultiple() { public void readProfinetLowerCase() { String[] deviceName = new String[] {"device_Name_1"}; ProfinetConfiguration configuration = new ConfigurationFactory().createConfiguration( - ProfinetConfiguration.class, "devices=[[device_name_1, device_access_1, (submodule_1, submodule_2)]]&gsddirectory=src/test/resources"); + ProfinetConfiguration.class, "", "", "", "devices=[[device_name_1, device_access_1, (submodule_1, submodule_2)]]&gsddirectory=src/test/resources"); Map devices = configuration.getDevices().getConfiguredDevices(); @@ -118,7 +120,7 @@ public void readProfinetLowerCase() { @Test public void setIncorrectSubModule() { ProfinetConfiguration configuration = new ConfigurationFactory().createConfiguration( - ProfinetConfiguration.class, "devices=[[device_name_1, PLC4X_1, (PLC4X_01, PLC4X_02, PLC4X_01, PLC4X_02)]]&gsddirectory=src/test/resources"); + ProfinetConfiguration.class, "", "", "", "devices=[[device_name_1, PLC4X_1, (PLC4X_01, PLC4X_02, PLC4X_01, PLC4X_02)]]&gsddirectory=src/test/resources"); Map configuredDevices = configuration.getDevices().getConfiguredDevices(); Map devices = new HashMap<>(); @@ -143,7 +145,7 @@ public void setIncorrectSubModule() { @Test public void setCorrectSubModule() { ProfinetConfiguration configuration = new ConfigurationFactory().createConfiguration( - ProfinetConfiguration.class, "devices=[[device_name_1, PLC4X_1, (PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE)]]&gsddirectory=src/test/resources"); + ProfinetConfiguration.class, "", "", "", "devices=[[device_name_1, PLC4X_1, (PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE)]]&gsddirectory=src/test/resources"); Map configuredDevices = configuration.getDevices().getConfiguredDevices(); Map devices = new HashMap<>(); @@ -167,7 +169,7 @@ public void setCorrectSubModule() { @Test public void setCorrectSubModuleCaseInsensitive() { ProfinetConfiguration configuration = new ConfigurationFactory().createConfiguration( - ProfinetConfiguration.class, "devices=[[device_name_1, PLC4X_1, (PLC4X_DUMMY_MODULE, PLC4X_dummy_MODULE, PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE)]]&gsddirectory=src/test/resources"); + ProfinetConfiguration.class, "", "", "", "devices=[[device_name_1, PLC4X_1, (PLC4X_DUMMY_MODULE, PLC4X_dummy_MODULE, PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE)]]&gsddirectory=src/test/resources"); Map configuredDevices = configuration.getDevices().getConfiguredDevices(); Map devices = new HashMap<>(); @@ -193,7 +195,7 @@ public void parseJoinedDeviceConfigurationSpacesInDeviceAccessName() { String[] deviceNames = new String[] {"DEVICE_NAME_1"}; ProfinetConfiguration configuration = new ConfigurationFactory().createConfiguration( - ProfinetConfiguration.class, "devices=[[device_name_1, PLC4X 1, (PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE)]]&gsddirectory=src/test/resources"); + ProfinetConfiguration.class, "", "", "", "devices=[[device_name_1, PLC4X 1, (PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE)]]&gsddirectory=src/test/resources"); Map configuredDevices = configuration.getDevices().getConfiguredDevices(); Map devices = new HashMap<>(); @@ -221,7 +223,7 @@ public void parseJoinedDeviceConfigurationSpacesInDeviceName() { String[] deviceNames = new String[] {"DEVICE NAME 1"}; ProfinetConfiguration configuration = new ConfigurationFactory().createConfiguration( - ProfinetConfiguration.class, "devices=[[device name 1, PLC4X 1, (PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE)]]&gsddirectory=src/test/resources"); + ProfinetConfiguration.class, "", "", "", "devices=[[device name 1, PLC4X 1, (PLC4X_DUMMY_MODULE, PLC4X_DUMMY_MODULE)]]&gsddirectory=src/test/resources"); Map configuredDevices = configuration.getDevices().getConfiguredDevices(); Map devices = new HashMap<>(); @@ -248,7 +250,7 @@ public void parseJoinedDeviceConfigurationSpacesInDeviceModuleName() { String[] deviceNames = new String[] {"DEVICE NAME 1"}; ProfinetConfiguration configuration = new ConfigurationFactory().createConfiguration( - ProfinetConfiguration.class, "devices=[[device name 1, PLC4X 1, (PLC4X DUMMY MODULE, PLC4X DUMMY MODULE)]]&gsddirectory=src/test/resources"); + ProfinetConfiguration.class, "", "", "", "devices=[[device name 1, PLC4X 1, (PLC4X DUMMY MODULE, PLC4X DUMMY MODULE)]]&gsddirectory=src/test/resources"); Map configuredDevices = configuration.getDevices().getConfiguredDevices(); Map devices = new HashMap<>(); @@ -277,7 +279,7 @@ public void parseAllowedModuleSingleSlot() { String[] deviceNames = new String[] {"DEVICE NAME 1"}; ProfinetConfiguration configuration = new ConfigurationFactory().createConfiguration( - ProfinetConfiguration.class, "devices=[[device name 1, PLC4X 1, (PLC4X DUMMY MODULE, PLC4X DUMMY MODULE,,1)]]&gsddirectory=src/test/resources"); + ProfinetConfiguration.class, "", "", "", "devices=[[device name 1, PLC4X 1, (PLC4X DUMMY MODULE, PLC4X DUMMY MODULE,,1)]]&gsddirectory=src/test/resources"); Map configuredDevices = configuration.getDevices().getConfiguredDevices(); Map devices = new HashMap<>(); @@ -309,7 +311,7 @@ public void parseIpAddress() { String[] deviceNames = new String[] {"DEVICE NAME 1"}; ProfinetConfiguration configuration = new ConfigurationFactory().createConfiguration( - ProfinetConfiguration.class, "devices=[[device name 1, PLC4X 1, (PLC4X DUMMY MODULE, PLC4X DUMMY MODULE,,1), 10.1.1.1]]&gsddirectory=src/test/resources"); + ProfinetConfiguration.class, "", "", "", "devices=[[device name 1, PLC4X 1, (PLC4X DUMMY MODULE, PLC4X DUMMY MODULE,,1), 10.1.1.1]]&gsddirectory=src/test/resources"); Map configuredDevices = configuration.getDevices().getConfiguredDevices(); Map devices = new HashMap<>(); @@ -334,7 +336,7 @@ public void sendIPSetRequest() { String[] deviceNames = new String[] {"DEVICE NAME 1"}; ProfinetConfiguration configuration = new ConfigurationFactory().createConfiguration( - ProfinetConfiguration.class, "devices=[[device name 1, PLC4X 1, (PLC4X DUMMY MODULE, PLC4X DUMMY MODULE,,1), 10.1.1.1]]&gsddirectory=src/test/resources"); + ProfinetConfiguration.class, "", "", "", "devices=[[device name 1, PLC4X 1, (PLC4X DUMMY MODULE, PLC4X DUMMY MODULE,,1), 10.1.1.1]]&gsddirectory=src/test/resources"); NetworkInterface networkInterface = new DummyNetworkInterface("10.1.1.2", "255.255.255.0", "0.0.0.0"); Map configuredDevices = configuration.getDevices().getConfiguredDevices(); diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/S7HGeneratedDriverBase.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/S7HGeneratedDriverBase.java index 318903a2229..20c14857194 100644 --- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/S7HGeneratedDriverBase.java +++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/S7HGeneratedDriverBase.java @@ -80,7 +80,7 @@ public PlcConnection getConnection(String connectionString) throws PlcConnection // Create the configuration object. Configuration configuration = new ConfigurationFactory().createConfiguration( - getConfigurationType(), paramString); + getConfigurationType(), protocolCode, transportCode, transportConfig, paramString); if (configuration == null) { throw new PlcConnectionException("Unsupported configuration"); } @@ -124,6 +124,12 @@ public PlcConnection getConnection(String connectionString) throws PlcConnection } } + // Make the "fire discover event" overridable via system property. + boolean fireDiscoverEvent = fireDiscoverEvent(); + if(System.getProperty(PROPERTY_PLC4X_FORCE_FIRE_DISCOVER_EVENT) != null) { + fireDiscoverEvent = Boolean.parseBoolean(System.getProperty(PROPERTY_PLC4X_FORCE_FIRE_DISCOVER_EVENT)); + } + // Make the "await setup complete" overridable via system property. boolean awaitSetupComplete = awaitSetupComplete(); if (System.getProperty(PROPERTY_PLC4X_FORCE_AWAIT_SETUP_COMPLETE) != null) { @@ -149,6 +155,7 @@ public PlcConnection getConnection(String connectionString) throws PlcConnection configuration, channelFactory, secondaryChannelFactory, + fireDiscoverEvent, awaitSetupComplete, awaitDisconnectComplete, awaitDiscoverComplete, diff --git a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/connection/S7HDefaultNettyPlcConnection.java b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/connection/S7HDefaultNettyPlcConnection.java index 201c6e688e8..02713966d7a 100644 --- a/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/connection/S7HDefaultNettyPlcConnection.java +++ b/plc4j/drivers/s7/src/main/java/org/apache/plc4x/java/s7/readwrite/connection/S7HDefaultNettyPlcConnection.java @@ -76,6 +76,7 @@ public S7HDefaultNettyPlcConnection(boolean canRead, Configuration configuration, ChannelFactory channelFactory, ChannelFactory secondaryChannelFactory, + boolean fireDiscoverEvent, boolean awaitSessionSetupComplete, boolean awaitSessionDisconnectComplete, boolean awaitSessionDiscoverComplete, @@ -90,6 +91,7 @@ public S7HDefaultNettyPlcConnection(boolean canRead, valueHandler, configuration, channelFactory, + fireDiscoverEvent, awaitSessionSetupComplete, awaitSessionDisconnectComplete, awaitSessionDiscoverComplete, diff --git a/plc4j/integrations/apache-calcite/pom.xml b/plc4j/integrations/apache-calcite/pom.xml index bc3d01a8c31..5ad41245218 100644 --- a/plc4j/integrations/apache-calcite/pom.xml +++ b/plc4j/integrations/apache-calcite/pom.xml @@ -153,7 +153,7 @@ com.google.protobuf protobuf-java - 3.23.4 + 3.24.0 org.checkerframework @@ -163,7 +163,7 @@ com.google.errorprone error_prone_annotations - 2.21.0 + 2.21.1 diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/configuration/ConfigurationFactory.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/configuration/ConfigurationFactory.java index b2b16662e1f..b0558ece38a 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/configuration/ConfigurationFactory.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/configuration/ConfigurationFactory.java @@ -22,12 +22,13 @@ import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.reflect.FieldUtils; import org.apache.plc4x.java.api.exceptions.PlcRuntimeException; -import org.apache.plc4x.java.spi.configuration.annotations.*; +import org.apache.plc4x.java.spi.configuration.annotations.ConfigurationParameter; +import org.apache.plc4x.java.spi.configuration.annotations.ParameterConverter; +import org.apache.plc4x.java.spi.configuration.annotations.Required; import org.apache.plc4x.java.spi.configuration.annotations.defaults.*; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.UnsupportedEncodingException; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.ParameterizedType; @@ -52,8 +53,8 @@ public class ConfigurationFactory { private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationFactory.class); - // TODO Respect Path Params - public T createConfiguration(Class pClazz, String configurationString) { + public T createConfiguration(Class pClazz, String protocolCode, String transportCode, + String transportConfig, String paramString) { // Get a map of all configuration parameter fields. // - Get a list of all fields in the given class. Map fields = Arrays.stream(FieldUtils.getAllFields(pClazz)) @@ -76,14 +77,28 @@ public T createConfiguration(Class pClazz, String c try { instance = pClazz.getDeclaredConstructor().newInstance(); } catch (InvocationTargetException | InstantiationException | - IllegalAccessException | NoSuchMethodException e) { + IllegalAccessException | NoSuchMethodException e) { throw new IllegalArgumentException("Unable to Instantiate Configuration Class", e); } // Process the parameters passed in with the connection string. try { // Get a map of all parameters in the connection string. - Map> paramStringValues = splitQuery(configurationString); + Map> paramStringValues = splitQuery(paramString); + paramStringValues = new HashMap<>(paramStringValues); + List previousValue; + previousValue = paramStringValues.put("protocolCode", List.of(protocolCode)); + if (previousValue != null) { + LOGGER.warn("protocolCode with value {} overridden by", protocolCode); + } + previousValue = paramStringValues.put("transportCode", List.of(transportCode)); + if (previousValue != null) { + LOGGER.warn("transportCode with value {} overridden by", transportCode); + } + previousValue = paramStringValues.put("transportConfig", List.of(transportConfig)); + if (previousValue != null) { + LOGGER.warn("transportConfig with value {} overridden by", transportConfig); + } // Iterate over all fields and set the values to either the values specified // in the param string or to defaults configured by annotations. @@ -135,7 +150,7 @@ public static T configure(Configuration configuration, T obj) { if (configClass.isAssignableFrom(configuration.getClass())) { try { ((HasConfiguration) obj).setConfiguration(configuration); - } catch(Throwable t) { + } catch (Throwable t) { LOGGER.error("Error setting the configuration", t); throw new PlcRuntimeException("Error setting the configuration", t); } @@ -182,7 +197,8 @@ private static Object toFieldValue(Field field, String valueString) { if (converter.getType().isAssignableFrom(field.getType())) { return converter.convert(valueString); } - } catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) { + } catch (InstantiationException | IllegalAccessException | InvocationTargetException | + NoSuchMethodException e) { throw new IllegalArgumentException("Could not initialize parameter converter", e); } throw new IllegalArgumentException("Unsupported field type " + field.getType() + " for converter " + converterClass); diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/DefaultNettyPlcConnection.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/DefaultNettyPlcConnection.java index 9ccc30ebb0d..f2ae2e5abba 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/DefaultNettyPlcConnection.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/DefaultNettyPlcConnection.java @@ -54,7 +54,7 @@ public class DefaultNettyPlcConnection extends AbstractPlcConnection implements protected final Configuration configuration; protected final ChannelFactory channelFactory; - + protected final boolean fireDiscoverEvent; protected final boolean awaitSessionSetupComplete; protected final boolean awaitSessionDisconnectComplete; protected final boolean awaitSessionDiscoverComplete; @@ -73,6 +73,7 @@ public DefaultNettyPlcConnection(boolean canRead, PlcValueHandler valueHandler, Configuration configuration, ChannelFactory channelFactory, + boolean fireDiscoverEvent, boolean awaitSessionSetupComplete, boolean awaitSessionDisconnectComplete, boolean awaitSessionDiscoverComplete, @@ -82,6 +83,7 @@ public DefaultNettyPlcConnection(boolean canRead, super(canRead, canWrite, canSubscribe, canBrowse, tagHandler, valueHandler, optimizer, authentication); this.configuration = configuration; this.channelFactory = channelFactory; + this.fireDiscoverEvent = fireDiscoverEvent; this.awaitSessionSetupComplete = awaitSessionSetupComplete; //Used to signal that a disconnect has completed while closing a connection. this.awaitSessionDisconnectComplete = awaitSessionDisconnectComplete; @@ -109,7 +111,7 @@ public void connect() throws PlcConnectionException { ConfigurationFactory.configure(configuration, channelFactory); // Have the channel factory create a new channel instance. - if (awaitSessionDiscoverComplete) { + if (fireDiscoverEvent) { channel = channelFactory.createChannel(getChannelHandler(sessionSetupCompleteFuture, sessionDisconnectCompleteFuture, sessionDiscoveredCompleteFuture)); channel.closeFuture().addListener(future -> { if (!sessionDiscoveredCompleteFuture.isDone()) { @@ -123,7 +125,8 @@ public void connect() throws PlcConnectionException { } }); channel.pipeline().fireUserEventTriggered(new DiscoverEvent()); - + } + if (awaitSessionDiscoverComplete) { // Wait till the connection is established. sessionDiscoveredCompleteFuture.get(); } diff --git a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/GeneratedDriverBase.java b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/GeneratedDriverBase.java index 7159fde5415..6159ce230ae 100644 --- a/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/GeneratedDriverBase.java +++ b/plc4j/spi/src/main/java/org/apache/plc4x/java/spi/connection/GeneratedDriverBase.java @@ -18,25 +18,26 @@ */ package org.apache.plc4x.java.spi.connection; -import static org.apache.plc4x.java.spi.configuration.ConfigurationFactory.*; - import org.apache.plc4x.java.api.PlcConnection; import org.apache.plc4x.java.api.PlcDriver; import org.apache.plc4x.java.api.authentication.PlcAuthentication; import org.apache.plc4x.java.api.exceptions.PlcConnectionException; +import org.apache.plc4x.java.api.value.PlcValueHandler; import org.apache.plc4x.java.spi.configuration.Configuration; -import org.apache.plc4x.java.spi.generation.Message; import org.apache.plc4x.java.spi.configuration.ConfigurationFactory; +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.api.value.PlcValueHandler; import java.util.ServiceLoader; import java.util.regex.Matcher; import java.util.regex.Pattern; +import static org.apache.plc4x.java.spi.configuration.ConfigurationFactory.configure; + public abstract class GeneratedDriverBase implements PlcDriver { + public static final String PROPERTY_PLC4X_FORCE_FIRE_DISCOVER_EVENT = "PLC4X_FORCE_FIRE_DISCOVER_EVENT"; public static final String PROPERTY_PLC4X_FORCE_AWAIT_SETUP_COMPLETE = "PLC4X_FORCE_AWAIT_SETUP_COMPLETE"; public static final String PROPERTY_PLC4X_FORCE_AWAIT_DISCONNECT_COMPLETE = "PLC4X_FORCE_AWAIT_DISCONNECT_COMPLETE"; public static final String PROPERTY_PLC4X_FORCE_AWAIT_DISCOVER_COMPLETE = "PLC4X_FORCE_AWAIT_DISCOVER_COMPLETE"; @@ -62,6 +63,10 @@ protected boolean canBrowse() { return false; } + protected boolean fireDiscoverEvent() { + return true; + } + protected boolean awaitSetupComplete() { return true; } @@ -105,11 +110,11 @@ public PlcConnection getConnection(String connectionString, PlcAuthentication au Matcher matcher = URI_PATTERN.matcher(connectionString); if (!matcher.matches()) { throw new PlcConnectionException( - "Connection string doesn't match the format '{protocol-code}:({transport-code})?//{transport-address}(?{parameter-string)?'"); + "Connection string doesn't match the format '{protocol-code}:({transport-code})?//{transport-config}(?{parameter-string)?'"); } final String protocolCode = matcher.group("protocolCode"); - final String transportCode = (matcher.group("transportCode") != null) ? - matcher.group("transportCode") : getDefaultTransport(); + String transportCodeMatch = matcher.group("transportCode"); + final String transportCode = (transportCodeMatch != null) ? transportCodeMatch : getDefaultTransport(); final String transportConfig = matcher.group("transportConfig"); final String paramString = matcher.group("paramString"); @@ -121,8 +126,8 @@ public PlcConnection getConnection(String connectionString, PlcAuthentication au } // Create the configuration object. - Configuration configuration = new ConfigurationFactory().createConfiguration( - getConfigurationType(), paramString); + Configuration configuration = new ConfigurationFactory() + .createConfiguration(getConfigurationType(), protocolCode, transportCode, transportConfig, paramString); if (configuration == null) { throw new PlcConnectionException("Unsupported configuration"); } @@ -146,7 +151,7 @@ public PlcConnection getConnection(String connectionString, PlcAuthentication au // Create an instance of the communication channel which the driver should use. ChannelFactory channelFactory = transport.createChannelFactory(transportConfig); - if(channelFactory == null) { + if (channelFactory == null) { throw new PlcConnectionException("Unable to get channel factory from url " + transportConfig); } configure(configuration, channelFactory); @@ -154,21 +159,27 @@ public PlcConnection getConnection(String connectionString, PlcAuthentication au // Give drivers the option to customize the channel. initializePipeline(channelFactory); + // Make the "fire discover event" overridable via system property. + boolean fireDiscoverEvent = fireDiscoverEvent(); + if (System.getProperty(PROPERTY_PLC4X_FORCE_FIRE_DISCOVER_EVENT) != null) { + fireDiscoverEvent = Boolean.parseBoolean(System.getProperty(PROPERTY_PLC4X_FORCE_FIRE_DISCOVER_EVENT)); + } + // Make the "await setup complete" overridable via system property. boolean awaitSetupComplete = awaitSetupComplete(); - if(System.getProperty(PROPERTY_PLC4X_FORCE_AWAIT_SETUP_COMPLETE) != null) { + if (System.getProperty(PROPERTY_PLC4X_FORCE_AWAIT_SETUP_COMPLETE) != null) { awaitSetupComplete = Boolean.parseBoolean(System.getProperty(PROPERTY_PLC4X_FORCE_AWAIT_SETUP_COMPLETE)); } // Make the "await disconnect complete" overridable via system property. boolean awaitDisconnectComplete = awaitDisconnectComplete(); - if(System.getProperty(PROPERTY_PLC4X_FORCE_AWAIT_DISCONNECT_COMPLETE) != null) { + if (System.getProperty(PROPERTY_PLC4X_FORCE_AWAIT_DISCONNECT_COMPLETE) != null) { awaitDisconnectComplete = Boolean.parseBoolean(System.getProperty(PROPERTY_PLC4X_FORCE_AWAIT_DISCONNECT_COMPLETE)); } // Make the "await disconnect complete" overridable via system property. boolean awaitDiscoverComplete = awaitDiscoverComplete(); - if(System.getProperty(PROPERTY_PLC4X_FORCE_AWAIT_DISCOVER_COMPLETE) != null) { + if (System.getProperty(PROPERTY_PLC4X_FORCE_AWAIT_DISCOVER_COMPLETE) != null) { awaitDiscoverComplete = Boolean.parseBoolean(System.getProperty(PROPERTY_PLC4X_FORCE_AWAIT_DISCOVER_COMPLETE)); } @@ -178,6 +189,7 @@ public PlcConnection getConnection(String connectionString, PlcAuthentication au getValueHandler(), configuration, channelFactory, + fireDiscoverEvent, awaitSetupComplete, awaitDisconnectComplete, awaitDiscoverComplete, @@ -186,5 +198,4 @@ public PlcConnection getConnection(String connectionString, PlcAuthentication au authentication); } - } diff --git a/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/parser/ConnectionParserTest.java b/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/parser/ConnectionParserTest.java index 64c34644b80..0349273488d 100644 --- a/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/parser/ConnectionParserTest.java +++ b/plc4j/spi/src/test/java/org/apache/plc4x/java/spi/parser/ConnectionParserTest.java @@ -18,22 +18,22 @@ */ package org.apache.plc4x.java.spi.parser; -import static org.junit.jupiter.api.Assertions.assertEquals; - import org.apache.plc4x.java.api.exceptions.PlcConnectionException; import org.apache.plc4x.java.spi.configuration.Configuration; import org.apache.plc4x.java.spi.configuration.ConfigurationFactory; import org.apache.plc4x.java.spi.configuration.annotations.ConfigurationParameter; -import org.apache.plc4x.java.spi.configuration.annotations.defaults.IntDefaultValue; import org.apache.plc4x.java.spi.configuration.annotations.Required; +import org.apache.plc4x.java.spi.configuration.annotations.defaults.IntDefaultValue; import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.assertEquals; + class ConnectionParserTest { @Test void parse() throws PlcConnectionException { PropertiesDescriptor properties = new ConfigurationFactory().createConfiguration( - PropertiesDescriptor.class, "rackId=2"); + PropertiesDescriptor.class, "", "", "", "rackId=2"); assertEquals(2, properties.getRackId()); assertEquals(1, properties.getSlotId()); diff --git a/plc4j/transports/tcp/src/main/java/org/apache/plc4x/java/transport/tcp/TcpTransport.java b/plc4j/transports/tcp/src/main/java/org/apache/plc4x/java/transport/tcp/TcpTransport.java index a83f86e6d2a..47e28d47032 100644 --- a/plc4j/transports/tcp/src/main/java/org/apache/plc4x/java/transport/tcp/TcpTransport.java +++ b/plc4j/transports/tcp/src/main/java/org/apache/plc4x/java/transport/tcp/TcpTransport.java @@ -31,7 +31,7 @@ public class TcpTransport implements Transport, HasConfiguration { private static final Pattern TRANSPORT_TCP_PATTERN = Pattern.compile( - "^((?[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})|(?[a-zA-Z0-9.\\-]+))(:(?[0-9]{1,5}))?"); + "^((?[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3})|(?[a-zA-Z0-9.\\-]+))(:(?[0-9]{1,5}))?.*"); private TcpTransportConfiguration configuration; @@ -53,8 +53,8 @@ public void setConfiguration(TcpTransportConfiguration configuration) { @Override public ChannelFactory createChannelFactory(String transportConfig) { final Matcher matcher = TRANSPORT_TCP_PATTERN.matcher(transportConfig); - if(!matcher.matches()) { - throw new PlcRuntimeException("Invalid url for TCP transport"); + if (!matcher.matches()) { + throw new PlcRuntimeException("Invalid url for TCP transport: " + transportConfig); } String ip = matcher.group("ip"); String hostname = matcher.group("hostname"); @@ -62,7 +62,7 @@ public ChannelFactory createChannelFactory(String transportConfig) { // If the port wasn't specified, try to get a default port from the configuration. int port; - if(portString != null) { + if (portString != null) { port = Integer.parseInt(portString); } else if ((configuration != null) && (configuration.getDefaultPort() != TcpTransportConfiguration.NO_DEFAULT_PORT)) { diff --git a/plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/manual/ManualTest.java b/plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/manual/ManualTest.java index 85cfd2f8499..a3162624a60 100644 --- a/plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/manual/ManualTest.java +++ b/plc4j/utils/test-utils/src/main/java/org/apache/plc4x/test/manual/ManualTest.java @@ -51,8 +51,9 @@ public ManualTest(String connectionString, boolean testWrite) { testCases = new ArrayList<>(); } - public void addTestCase(String address, Object expectedReadValue) { + public ManualTest addTestCase(String address, Object expectedReadValue) { testCases.add(new TestCase(address, expectedReadValue, null)); + return this; } public void run() throws Exception { @@ -72,13 +73,13 @@ public void run() throws Exception { Assertions.assertEquals(tagName, readResponse.getTagNames().iterator().next(), tagName); Assertions.assertEquals(PlcResponseCode.OK, readResponse.getResponseCode(tagName), tagName); Assertions.assertNotNull(readResponse.getPlcValue(tagName), tagName); - if(readResponse.getPlcValue(tagName) instanceof PlcList) { + if (readResponse.getPlcValue(tagName) instanceof PlcList) { PlcList plcList = (PlcList) readResponse.getPlcValue(tagName); List expectedValues; if (testCase.expectedReadValue instanceof PlcList) { PlcList expectedPlcList = (PlcList) testCase.expectedReadValue; expectedValues = expectedPlcList.getList(); - } else if(testCase.expectedReadValue instanceof List) { + } else if (testCase.expectedReadValue instanceof List) { expectedValues = (List) testCase.expectedReadValue; } else { Assertions.fail("Got a list of values, but only expected one."); @@ -104,9 +105,9 @@ public void run() throws Exception { } // Try writing the same value back to the PLC. - if(testWrite) { + if (testWrite) { PlcValue plcValue; - if(testCase.expectedReadValue instanceof PlcValue) { + if (testCase.expectedReadValue instanceof PlcValue) { plcValue = ((PlcValue) testCase.expectedReadValue); } else { plcValue = PlcValues.of(testCase.expectedReadValue); diff --git a/pom.xml b/pom.xml index 7262c59f99b..4c0c921aaa4 100644 --- a/pom.xml +++ b/pom.xml @@ -124,7 +124,7 @@ 1.10.0 1.10.0 2.1.4 - 3.15 + 3.15.1 2.3.32 4.0.12 2.10.1 @@ -136,13 +136,13 @@ 6.5.1 4.0.2 - 11.0.15 + 12.0.0 5.13.0 2.12.5 2.10.3 5.10.0 1.8.2 - 1.4.8 + 1.4.11 3.2.0 @@ -157,7 +157,7 @@ 2.2.4 2.5.10 - 2.2.10 + 2.2.11 true false @@ -636,7 +636,7 @@ org.yaml snakeyaml - 2.0 + 2.1 diff --git a/src/site/asciidoc/index.adoc b/src/site/asciidoc/index.adoc index cbed626f264..41df1d89b10 100644 --- a/src/site/asciidoc/index.adoc +++ b/src/site/asciidoc/index.adoc @@ -160,7 +160,7 @@ Card image cap

-
Apache StreamPipes (incubating)
+
Apache StreamPipes
diff --git a/src/site/asciidoc/users/index.adoc b/src/site/asciidoc/users/index.adoc index 305a2290771..68c38820c23 100644 --- a/src/site/asciidoc/users/index.adoc +++ b/src/site/asciidoc/users/index.adoc @@ -312,7 +312,7 @@ Besides providing access to devices using one of above protocols, Apache PLC4X a Card image cap
-
Apache StreamPipes™ (incubating)
+
Apache StreamPipes™
diff --git a/src/site/asciidoc/users/integrations/apache-streampipes.adoc b/src/site/asciidoc/users/integrations/apache-streampipes.adoc index f6bbc52bbf5..4eb4f0851fc 100644 --- a/src/site/asciidoc/users/integrations/apache-streampipes.adoc +++ b/src/site/asciidoc/users/integrations/apache-streampipes.adoc @@ -17,4 +17,4 @@ :imagesdir: ../../images/ :icons: font -== Apache StreamPipes (incubating) +== Apache StreamPipes diff --git a/src/site/resources/images/integrations/apache_streampipes_logo.png b/src/site/resources/images/integrations/apache_streampipes_logo.png index a4287891836..1bef5cd232a 100644 Binary files a/src/site/resources/images/integrations/apache_streampipes_logo.png and b/src/site/resources/images/integrations/apache_streampipes_logo.png differ