Skip to content

Commit

Permalink
fix: fix ReferenceNodes usage with mask set
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Aug 24, 2023
1 parent 0ddf736 commit f20bc2f
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion node.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ package opcua

import (
"context"
"encoding/base64"
"strings"

"github.com/gopcua/opcua/id"
Expand Down Expand Up @@ -160,7 +161,23 @@ func (n *Node) ReferencedNodes(ctx context.Context, refs uint32, dir ua.BrowseDi
return nil, err
}
for _, r := range res {
nodes = append(nodes, n.c.Node(r.NodeID.NodeID))
nodeID := r.NodeID.NodeID
switch nodeID.Type() {
case ua.NodeIDTypeTwoByte:
nodeID = ua.NewTwoByteNodeID(uint8(nodeID.IntID()))
case ua.NodeIDTypeFourByte:
nodeID = ua.NewFourByteNodeID(uint8(nodeID.Namespace()), uint16(nodeID.IntID()))
case ua.NodeIDTypeNumeric:
nodeID = ua.NewNumericNodeID(nodeID.Namespace(), nodeID.IntID())
case ua.NodeIDTypeString:
nodeID = ua.NewStringNodeID(nodeID.Namespace(), nodeID.StringID())
case ua.NodeIDTypeGUID:
nodeID = ua.NewGUIDNodeID(nodeID.Namespace(), nodeID.String())
case ua.NodeIDTypeByteString:
bytes, _ := base64.StdEncoding.DecodeString(nodeID.String())
nodeID = ua.NewByteStringNodeID(nodeID.Namespace(), bytes)
}
nodes = append(nodes, n.c.Node(nodeID))
}
return nodes, nil
}
Expand Down

0 comments on commit f20bc2f

Please sign in to comment.