Skip to content

Commit

Permalink
Add missing HistoryRead methods
Browse files Browse the repository at this point in the history
  • Loading branch information
gstvg authored Jun 21, 2022
1 parent bff20f0 commit a0d6aee
Showing 1 changed file with 90 additions and 0 deletions.
90 changes: 90 additions & 0 deletions client.go
Original file line number Diff line number Diff line change
Expand Up @@ -1173,6 +1173,36 @@ func (c *Client) UnregisterNodesWithContext(ctx context.Context, req *ua.Unregis
return res, err
}

// Note: Starting with v0.5 this method will require a context
// and the corresponding XXXWithContext(ctx) method will be removed.
func (c *Client) HistoryReadEvent(nodes []*ua.HistoryReadValueID, details *ua.ReadEventDetails) (*ua.HistoryReadResponse, error) {
return c.HistoryReadEventWithContext(context.Background(), nodes, details)
}

// Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (c *Client) HistoryReadEventWithContext(ctx context.Context, nodes []*ua.HistoryReadValueID, details *ua.ReadEventDetails) (*ua.HistoryReadResponse, error) {
stats.Client().Add("HistoryReadEvent", 1)
stats.Client().Add("HistoryReadValueID", int64(len(nodes)))

// Part 4, 5.10.3 HistoryRead
req := &ua.HistoryReadRequest{
TimestampsToReturn: ua.TimestampsToReturnBoth,
NodesToRead: nodes,
// Part 11, 6.4 HistoryReadDetails parameters
HistoryReadDetails: &ua.ExtensionObject{
TypeID: ua.NewFourByteExpandedNodeID(0, id.ReadEventDetails_Encoding_DefaultBinary),
EncodingMask: ua.ExtensionObjectBinary,
Value: details,
},
}

var res *ua.HistoryReadResponse
err := c.SendWithContext(ctx, req, func(v interface{}) error {
return safeAssign(v, &res)
})
return res, err
}

// Note: Starting with v0.5 this method will require a context
// and the corresponding XXXWithContext(ctx) method will be removed.
func (c *Client) HistoryReadRawModified(nodes []*ua.HistoryReadValueID, details *ua.ReadRawModifiedDetails) (*ua.HistoryReadResponse, error) {
Expand Down Expand Up @@ -1203,6 +1233,66 @@ func (c *Client) HistoryReadRawModifiedWithContext(ctx context.Context, nodes []
return res, err
}

// Note: Starting with v0.5 this method will require a context
// and the corresponding XXXWithContext(ctx) method will be removed.
func (c *Client) HistoryReadProcessed(nodes []*ua.HistoryReadValueID, details *ua.ReadProcessedDetails) (*ua.HistoryReadResponse, error) {
return c.HistoryReadProcessedWithContext(context.Background(), nodes, details)
}

// Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (c *Client) HistoryReadProcessedWithContext(ctx context.Context, nodes []*ua.HistoryReadValueID, details *ua.ReadProcessedDetails) (*ua.HistoryReadResponse, error) {
stats.Client().Add("HistoryReadProcessed", 1)
stats.Client().Add("HistoryReadValueID", int64(len(nodes)))

// Part 4, 5.10.3 HistoryRead
req := &ua.HistoryReadRequest{
TimestampsToReturn: ua.TimestampsToReturnBoth,
NodesToRead: nodes,
// Part 11, 6.4 HistoryReadDetails parameters
HistoryReadDetails: &ua.ExtensionObject{
TypeID: ua.NewFourByteExpandedNodeID(0, id.ReadProcessedDetails_Encoding_DefaultBinary),
EncodingMask: ua.ExtensionObjectBinary,
Value: details,
},
}

var res *ua.HistoryReadResponse
err := c.SendWithContext(ctx, req, func(v interface{}) error {
return safeAssign(v, &res)
})
return res, err
}

// Note: Starting with v0.5 this method will require a context
// and the corresponding XXXWithContext(ctx) method will be removed.
func (c *Client) HistoryReadAtTime(nodes []*ua.HistoryReadValueID, details *ua.ReadAtTimeDetails) (*ua.HistoryReadResponse, error) {
return c.HistoryReadAtTimeWithContext(context.Background(), nodes, details)
}

// Note: Starting with v0.5 this method is superseded by the non 'WithContext' method.
func (c *Client) HistoryReadAtTimeWithContext(ctx context.Context, nodes []*ua.HistoryReadValueID, details *ua.ReadAtTimeDetails) (*ua.HistoryReadResponse, error) {
stats.Client().Add("HistoryReadAtTime", 1)
stats.Client().Add("HistoryReadValueID", int64(len(nodes)))

// Part 4, 5.10.3 HistoryRead
req := &ua.HistoryReadRequest{
TimestampsToReturn: ua.TimestampsToReturnBoth,
NodesToRead: nodes,
//Part 11, 6.4.5 ReadAtTimeDetails parameters
HistoryReadDetails: &ua.ExtensionObject{
TypeID: ua.NewFourByteExpandedNodeID(0, id.ReadAtTimeDetails_Encoding_DefaultBinary),
EncodingMask: ua.ExtensionObjectBinary,
Value: details,
},
}

var res *ua.HistoryReadResponse
err := c.SendWithContext(ctx, req, func(v interface{}) error {
return safeAssign(v, &res)
})
return res, err
}

// NamespaceArray returns the list of namespaces registered on the server.
//
// Note: Starting with v0.5 this method will require a context
Expand Down

0 comments on commit a0d6aee

Please sign in to comment.