Example not working
AlexanderMatveev opened this issue · comments
opc.NewConnection
not resolved
package main
import (
"fmt"
"github.com/konimarti/opc"
)
func main() {
client, err := opc.NewConnection(
"Graybox.Simulator",
[]string{"localhost"},
[]string{"numeric.sin.int64", "numeric.saw.float"},
)
defer client.Close()
if err != nil {
panic(err)
}
// read single tag: value, quality, timestamp
fmt.Println(client.ReadItem("numeric.sin.int64"))
// read all added tags
fmt.Println(client.Read())
}
@AlexanderMatveev I double-checked the examples and they work perfectly fine. Can you share more details of your problem? What go version are you using on what system (go version
)?
This package is based on Windows OLE/COM so I assume you are running the example code on Windows and have the OPC components installed (as described in the readme file)?
@konimarti thank you for response. I'm writing code from Linux and will run executable on Windows. I figured out that the way of working with this library depends on environment i'm using for development. I configured Goland (Build tags & Vendoring section to Windows), so now IDE doesn't produce any error while coding. By the way, I compile .exe from Linux with
GOOS=windows GOARCH=386 go build
command.
So now I'm confused of configuring connection timeout, because in my case OPC server responses are very slow. But I'm on my way of finding out this.