Skip to content

Commit

Permalink
fix(plc4go/opcua): fix remaining compile issues
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Sep 26, 2024
1 parent 7b3f554 commit f847017
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 25 deletions.
2 changes: 1 addition & 1 deletion plc4go/internal/opcua/Reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ func (m *Reader) readSync(ctx context.Context, readRequest apiModel.PlcReadReque
nil,
nil)

extObject := readWriteModel.NewExtensiblePayload(readWriteModel.NewRootExtensionObject(opcuaReadRequest, expandedNodeId, identifier), nil, 0)
extObject := readWriteModel.NewExtensiblePayload(nil, readWriteModel.NewRootExtensionObject(expandedNodeId, opcuaReadRequest, identifier), 0)

buffer := utils.NewWriteBufferByteBased(utils.WithByteOrderForByteBasedBuffer(binary.LittleEndian))
if err := extObject.SerializeWithWriteBuffer(ctx, buffer); err != nil {
Expand Down
34 changes: 17 additions & 17 deletions plc4go/internal/opcua/SecureChannel.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const (
)

var (
SECURITY_POLICY_NONE = readWriteModel.NewPascalString(utils.MakePtr("http://opcfoundation.org/UA/SecurityPolicy#None"))
SECURITY_POLICY_NONE = readWriteModel.NewPascalString(utils.ToPtr("http://opcfoundation.org/UA/SecurityPolicy#None"))
NULL_STRING = readWriteModel.NewPascalString(nil)
NULL_BYTE_STRING = readWriteModel.NewPascalByteString(-1, nil)
NULL_EXPANDED_NODEID = readWriteModel.NewExpandedNodeId(false,
Expand All @@ -73,9 +73,9 @@ var (
INET_ADDRESS_PATTERN = regexp.MustCompile(`(.(?P<transportCode>tcp))?://(?P<transportHost>[\w.-]+)(:(?P<transportPort>\d*))?`)

URI_PATTERN = regexp.MustCompile(`^(?P<protocolCode>opc)` + INET_ADDRESS_PATTERN.String() + `(?P<transportEndpoint>[\w/=]*)[?]?`)
APPLICATION_URI = readWriteModel.NewPascalString(utils.MakePtr("urn:apache:plc4x:client"))
PRODUCT_URI = readWriteModel.NewPascalString(utils.MakePtr("urn:apache:plc4x:client"))
APPLICATION_TEXT = readWriteModel.NewPascalString(utils.MakePtr("OPCUA client for the Apache PLC4X:PLC4J project"))
APPLICATION_URI = readWriteModel.NewPascalString(utils.ToPtr("urn:apache:plc4x:client"))
PRODUCT_URI = readWriteModel.NewPascalString(utils.ToPtr("urn:apache:plc4x:client"))
APPLICATION_TEXT = readWriteModel.NewPascalString(utils.ToPtr("OPCUA client for the Apache PLC4X:PLC4J project"))
DEFAULT_CONNECTION_LIFETIME = uint32(36000000)
)

Expand Down Expand Up @@ -381,8 +381,8 @@ func (s *SecureChannel) onConnectOpenSecureChannel(ctx context.Context, connecti
)

extObject := readWriteModel.NewRootExtensionObject(
openSecureChannelRequest,
expandedNodeId,
openSecureChannelRequest,
identifier,
)

Expand Down Expand Up @@ -505,7 +505,7 @@ func (s *SecureChannel) onConnectCreateSessionRequest(ctx context.Context, conne
applicationName := readWriteModel.NewLocalizedText(
true,
true,
readWriteModel.NewPascalString(utils.MakePtr("en")),
readWriteModel.NewPascalString(utils.ToPtr("en")),
APPLICATION_TEXT)

var discoveryUrls []readWriteModel.PascalString
Expand Down Expand Up @@ -539,8 +539,8 @@ func (s *SecureChannel) onConnectCreateSessionRequest(ctx context.Context, conne
nil)

extObject := readWriteModel.NewRootExtensionObject(
createSessionRequest,
expandedNodeId,
createSessionRequest,
identifier,
)

Expand Down Expand Up @@ -653,8 +653,8 @@ func (s *SecureChannel) onConnectActivateSessionRequest(ctx context.Context, con
nil)

extObject := readWriteModel.NewRootExtensionObject(
activateSessionRequest,
expandedNodeId,
activateSessionRequest,
identifier,
)

Expand Down Expand Up @@ -750,8 +750,8 @@ func (s *SecureChannel) onDisconnect(ctx context.Context, connection *Connection
true)

extObject := readWriteModel.NewRootExtensionObject(
closeSessionRequest,
expandedNodeId,
closeSessionRequest,
closeSessionRequest.GetExtensionId(),
)

Expand Down Expand Up @@ -832,8 +832,8 @@ func (s *SecureChannel) onDisconnectCloseSecureChannel(ctx context.Context, conn
readWriteModel.NewExtensiblePayload(
readWriteModel.NewSequenceHeader(transactionId, transactionId),
readWriteModel.NewRootExtensionObject(
closeSecureChannelRequest,
expandedNodeId,
closeSecureChannelRequest,
identifier,
),
0,
Expand Down Expand Up @@ -973,8 +973,8 @@ func (s *SecureChannel) onDiscoverOpenSecureChannel(ctx context.Context, codec *
)

extObject := readWriteModel.NewRootExtensionObject(
openSecureChannelRequest,
expandedNodeId,
openSecureChannelRequest,
identifier,
)

Expand Down Expand Up @@ -1101,8 +1101,8 @@ func (s *SecureChannel) onDiscoverGetEndpointsRequest(ctx context.Context, codec
)

extObject := readWriteModel.NewRootExtensionObject(
endpointsRequest,
expandedNodeId,
endpointsRequest,
identifier,
)

Expand Down Expand Up @@ -1230,8 +1230,8 @@ func (s *SecureChannel) onDiscoverCloseSecureChannel(ctx context.Context, codec
readWriteModel.NewExtensiblePayload(
readWriteModel.NewSequenceHeader(transactionId, transactionId),
readWriteModel.NewRootExtensionObject(
closeSecureChannelRequest,
expandedNodeId,
closeSecureChannelRequest,
identifier,
),
uint32(0),
Expand Down Expand Up @@ -1337,8 +1337,8 @@ func (s *SecureChannel) keepAlive() {
nil)

extObject := readWriteModel.NewRootExtensionObject(
openSecureChannelRequest,
expandedNodeId,
openSecureChannelRequest,
identifier,
)

Expand Down Expand Up @@ -1570,9 +1570,9 @@ func (s *SecureChannel) getIdentityToken(tokenType readWriteModel.UserTokenType,
nil,
)
return readWriteModel.NewBinaryExtensionObjectWithMask(
anonymousIdentityToken,
extExpandedNodeId,
readWriteModel.NewExtensionObjectEncodingMask(false, false, true),
anonymousIdentityToken,
anonymousIdentityToken.GetExtensionId(),
false,
)
Expand All @@ -1599,7 +1599,7 @@ func (s *SecureChannel) getIdentityToken(tokenType readWriteModel.UserTokenType,
readWriteModel.NewPascalString(policyId),
readWriteModel.NewPascalString(&s.username),
readWriteModel.NewPascalByteString(int32(len(encryptedPassword)), encryptedPassword),
readWriteModel.NewPascalString(utils.MakePtr(PASSWORD_ENCRYPTION_ALGORITHM)),
readWriteModel.NewPascalString(utils.ToPtr(PASSWORD_ENCRYPTION_ALGORITHM)),
)
extExpandedNodeId := readWriteModel.NewExpandedNodeId(
false, //Namespace Uri Specified
Expand All @@ -1608,9 +1608,9 @@ func (s *SecureChannel) getIdentityToken(tokenType readWriteModel.UserTokenType,
nil,
nil)
return readWriteModel.NewBinaryExtensionObjectWithMask(
userNameIdentityToken,
extExpandedNodeId,
readWriteModel.NewExtensionObjectEncodingMask(false, false, true),
userNameIdentityToken,
userNameIdentityToken.GetExtensionId(),
false,
)
Expand Down
10 changes: 7 additions & 3 deletions plc4go/internal/opcua/Subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,9 +149,13 @@ func (s *Subscriber) onSubscribeCreateSubscription(ctx context.Context, cycleTim
nil,
nil)

extObject := readWriteModel.NewExtensiblePayload(readWriteModel.NewRootExtensionObject(
createSubscriptionRequest, expandedNodeId, createSubscriptionRequest.GetExtensionId(),
), nil, 0)
extObject := readWriteModel.NewExtensiblePayload(
nil,
readWriteModel.NewRootExtensionObject(
expandedNodeId, createSubscriptionRequest, createSubscriptionRequest.GetExtensionId(),
),
0,
)

buffer := utils.NewWriteBufferByteBased(utils.WithByteOrderForByteBasedBuffer(binary.LittleEndian))
if err := extObject.SerializeWithWriteBuffer(ctx, buffer); err != nil {
Expand Down
6 changes: 3 additions & 3 deletions plc4go/internal/opcua/SubscriptionHandle.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,8 @@ func (h *SubscriptionHandle) onSubscribeCreateMonitoredItemsRequest() (readWrite
nil)

extObject := readWriteModel.NewRootExtensionObject(
createMonitoredItemsRequest,
expandedNodeId,
createMonitoredItemsRequest,
identifier,
)

Expand Down Expand Up @@ -273,8 +273,8 @@ func (h *SubscriptionHandle) startSubscriber() {
nil)

extObject := readWriteModel.NewRootExtensionObject(
publishRequest,
extExpandedNodeId,
publishRequest,
identifier,
)

Expand Down Expand Up @@ -384,8 +384,8 @@ func (h *SubscriptionHandle) stopSubscriber() {
)

extObject := readWriteModel.NewRootExtensionObject(
deleteSubscriptionrequest,
extExpandedNodeId,
deleteSubscriptionrequest,
identifier,
)

Expand Down
2 changes: 1 addition & 1 deletion plc4go/internal/opcua/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ func readResponse(localLog zerolog.Logger, readRequestIn apiModel.PlcReadRequest
array := variant.GetValue()
qualifiedNameValues := make([]apiValues.PlcValue, len(array))
for i, t := range array {
qualifiedNameValues[i] = spiValues.NewPlcSTRING(fmt.Sprintf("ns=%d;s=%s", t.GetNamespaceIndex(), t.GetName().GetStringValue()))
qualifiedNameValues[i] = spiValues.NewPlcSTRING(fmt.Sprintf("ns=%d;s=%s", t.GetNamespaceIndex(), *t.GetName().GetStringValue()))
}
value = spiValues.NewPlcList(qualifiedNameValues)
case readWriteModel.VariantExtensionObject:
Expand Down

0 comments on commit f847017

Please sign in to comment.