gopcua / opcua

Native Go OPC-UA library
MIT License
856 stars 259 forks source link

subscription: add SetMonitoringMode functionality #712

Closed jackchenjc closed 5 months ago

jackchenjc commented 8 months ago

closes #711

Add SetMonitoringMode functionality and fix the potential issue that leaves the mutex locked.

Simply add the following code to examples/subscribe/subscribe.go can test this new feature

resp, err := sub.SetMonitoringMode(ctx, ua.MonitoringModeSampling, res.Results[0].MonitoredItemID)
if err != nil || resp.Results[0] != ua.StatusOK {
    log.Fatal(err)
}
jackchenjc commented 8 months ago

Not sure if we should update item.req.MonitoringMode while getting ua.StatusOK.