Skip to content

Commit

Permalink
migrate opcua provider
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Milchev <[email protected]>
  • Loading branch information
imilchev committed Feb 12, 2024
1 parent aa0094f commit 8cbdfac
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
12 changes: 4 additions & 8 deletions providers/opcua/connection/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import (
)

type OpcuaConnection struct {
id uint32
plugin.Connection
Conf *inventory.Config
asset *inventory.Asset
client *opcua.Client
Expand All @@ -23,9 +23,9 @@ type OpcuaConnection struct {

func NewOpcuaConnection(id uint32, asset *inventory.Asset, conf *inventory.Config) (*OpcuaConnection, error) {
conn := &OpcuaConnection{
Conf: conf,
id: id,
asset: asset,
Connection: plugin.NewConnection(id, asset),
Conf: conf,
asset: asset,
}

// initialize connection
Expand Down Expand Up @@ -82,10 +82,6 @@ func (c *OpcuaConnection) Name() string {
return "opcua"
}

func (c *OpcuaConnection) ID() uint32 {
return c.id
}

func (c *OpcuaConnection) Asset() *inventory.Asset {
return c.asset
}
Expand Down
19 changes: 9 additions & 10 deletions providers/opcua/provider/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,15 @@ func (s *Service) connect(req *plugin.ConnectReq, callback plugin.ProviderCallba
}

asset.Connections[0].Id = conn.ID()
return &plugin.Runtime{
Connection: conn,
Callback: callback,
HasRecording: req.HasRecording,
CreateResource: resources.CreateResource,
NewResource: resources.NewResource,
GetData: resources.GetData,
SetData: resources.SetData,
Upstream: upstream,
}, nil
return plugin.NewRuntime(
conn,
callback,
req.HasRecording,
resources.CreateResource,
resources.NewResource,
resources.GetData,
resources.SetData,
upstream), nil
})
if err != nil {
return nil, err
Expand Down

0 comments on commit 8cbdfac

Please sign in to comment.