etm / opcua-smart Goto Github PK
View Code? Open in Web Editor NEWOPC-UA Ruby Bindings (open62541)
Home Page: https://rubygems.org/gems/opcua
License: GNU Lesser General Public License v3.0
OPC-UA Ruby Bindings (open62541)
Home Page: https://rubygems.org/gems/opcua
License: GNU Lesser General Public License v3.0
Hi,
I used the following example code for connecting to a OPCUA server:
require 'opcua/client'
client = OPCUA::Client.new("opc.tcp://192.168.1.50:4840")
client.subscription_interval = 100 # default 500
while true do
if (node = client.get 2, 3) # get node from nodeid
#p node
p node.value
else
p 'invalid nodeid'
end
sleep(2)
end
Somehow you need to set the node ID instead of the string as given in de example.
I run for testing a python opcua server with intergers and strings.
When I use the ID for the string variable the node.value changes to this value but when I use the ID for a interger variable then it gives back 'nil'.
Do you know what I am doing wrong?
Thanks in advance! @etm
Hi! The reserved word 'return' is not accepted when call the method, and this aborted.
##Server
t.add_method :MethodX,
inputarg1: OPCUA::TYPES::INT32 do |node, inputarg1|
p "Argument: #{inputarg1}"
return inputarg1 + 1
end
##Client
p node.call 1
What I do wrong? tnks
support for opc ua arrays
Provide method for deleting nodes in address space. This is required for dynamic construction of the address space.
When execute, show this error:
`require_relative': cannot load such file -- /home/user/opcua-smart/lib/opcua/client.so (LoadError)
how fix this error?
opcua-smart/example/client_method.rb
Line 2 in 9da1881
Hello,
I'm trying to use the gem, I have compiled and installed the open62541 library in my environment.
When I try to install the gem got:
_Installing opcua 0.21 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.
current directory: /tmp/bundler20201215-19767-16wmwjpopcua-0.21/gems/opcua-0.21/ext/opcua/server
/usr/local/bin/ruby -I /usr/local/lib/ruby/2.6.0 -r ./siteconf20201215-19767-12k0s4e.rb extconf.rb
creating Makefile
current directory: /tmp/bundler20201215-19767-16wmwjpopcua-0.21/gems/opcua-0.21/ext/opcua/server
make "DESTDIR=" clean
current directory: /tmp/bundler20201215-19767-16wmwjpopcua-0.21/gems/opcua-0.21/ext/opcua/server
make "DESTDIR="
compiling finders.c
In file included from finders.c:1:
./finders.h:4:10: fatal error: 'open62541.h' file not found
#include <open62541.h>
^~~~~~~~~~~~~
1 error generated.
*** Error code 1_
I saw that the file not found is not in the include dir, but after manually adding it from the project legacy folder I've got the same error.
What am I doing wrong?
Thanks
Nicolò :)
Hi,
I am trying to use this gem on my raspberry Pi 4 with smashing dashboard but when I run "smashing start" I get the following error:
bundler: failed to load command: thin (/usr/local/bin/thin)
NameError: uninitialized constant OPCUA
/home/pi/Documents/pi_dashboard/jobs/table.rb:5:in <top (required)>' /var/lib/gems/2.5.0/gems/smashing-1.3.5/lib/dashing/app.rb:177:in
require'
/var/lib/gems/2.5.0/gems/smashing-1.3.5/lib/dashing/app.rb:177:in block in require_glob' /var/lib/gems/2.5.0/gems/smashing-1.3.5/lib/dashing/app.rb:176:in
each'
/var/lib/gems/2.5.0/gems/smashing-1.3.5/lib/dashing/app.rb:176:in require_glob' /var/lib/gems/2.5.0/gems/smashing-1.3.5/lib/dashing/app.rb:187:in
<top (required)>'
/var/lib/gems/2.5.0/gems/smashing-1.3.5/lib/dashing.rb:3:in require' /var/lib/gems/2.5.0/gems/smashing-1.3.5/lib/dashing.rb:3:in
<top (required)>'
config.ru:1:in require' config.ru:1:in
block in
instance_eval' /var/lib/gems/2.5.0/gems/rack-2.2.3/lib/rack/builder.rb:125:in
initialize'new' config.ru:1:in
'eval' /var/lib/gems/2.5.0/gems/thin-1.8.1/lib/rack/adapter/loader.rb:33:in
load'load_rackup_config' /var/lib/gems/2.5.0/gems/thin-1.8.1/lib/thin/controllers/controller.rb:72:in
start'run_command' /var/lib/gems/2.5.0/gems/thin-1.8.1/lib/thin/runner.rb:159:in
run!'<top (required)>' /usr/local/bin/thin:23:in
load'My .rb file looks like the following:
#require_relative '../lib/opcua/client'
#require opcua/client
client = OPCUA::Client.new("opc.tcp://192.168.1.50:4840")
client.subscription_interval = 100
if (node = client.get 2, 'Pressure')
p node
p node.value
else
p 'invalid nodeid'
end
When I run "ldconfig -p | grep libopen6" I get this:
libopen62541.so.1 (libc6,hard-float) => /usr/local/lib/libopen62541.so.1
libopen62541.so (libc6,hard-float) => /usr/local/lib/libopen62541.so
Hoppefully you can help me.
Thanks in advance!!
When defining two types like:
server.add_namespace "https://centurio.work/ur10"
tt = server.types.add_object_type(:TargetType).tap{ |t|
t.add_variable :JointPositions
}
#causes errors, because both Jointpositions got the same nodeid
at = server.types.add_object_type(:ActualType).tap{ |t|
t.add_variable :JointPositions
}
i get an error
AddNodes: Node could not add the new node to the nodestore with error code BadNodeIdExists
because both JointPositions nodes got the same Nodeid.
I have defined the following code
at = server.types.add_object_type(:ActualType).tap{ |t|
t.add_variable :JointPositions
t.add_variable :JointVelocities
t.add_variable :JointCurrents
}
rt = server.types.add_object_type(:RobotType).tap{ |r|
r.add_object :Actual, at, OPCUA::MANDATORY
When i connect to the server with UA Expert all nodes of the type were instantiated twice. Once with a numeric random NodeId and once with the string NodeId.
When i manifest the ActualType after instantiation of the RobotType everthing works.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.