Coder Social home page Coder Social logo

etm / opcua-smart Goto Github PK

View Code? Open in Web Editor NEW
6.0 2.0 2.0 1.08 MB

OPC-UA Ruby Bindings (open62541)

Home Page: https://rubygems.org/gems/opcua

License: GNU Lesser General Public License v3.0

Ruby 0.95% Shell 0.03% C 99.01% Makefile 0.01% Vim Script 0.01%
ruby opc-ua opc-ua-server opc-ua-client opc-ua-wrapper rubygems ruby-gems

opcua-smart's People

Contributors

etm avatar fpauker avatar ttrau avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

opcua-smart's Issues

How return value in method?

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

Wrong instantiation of Types

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.

How to get integer value from node

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

NodeIds in Types

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.

Smashing compile error

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

'
/var/lib/gems/2.5.0/gems/rack-2.2.3/lib/rack/builder.rb:125:in instance_eval' /var/lib/gems/2.5.0/gems/rack-2.2.3/lib/rack/builder.rb:125:in initialize'
config.ru:1:in new' config.ru:1:in '
/var/lib/gems/2.5.0/gems/thin-1.8.1/lib/rack/adapter/loader.rb:33:in eval' /var/lib/gems/2.5.0/gems/thin-1.8.1/lib/rack/adapter/loader.rb:33:in load'
/var/lib/gems/2.5.0/gems/thin-1.8.1/lib/thin/controllers/controller.rb:182:in load_rackup_config' /var/lib/gems/2.5.0/gems/thin-1.8.1/lib/thin/controllers/controller.rb:72:in start'
/var/lib/gems/2.5.0/gems/thin-1.8.1/lib/thin/runner.rb:203:in run_command' /var/lib/gems/2.5.0/gems/thin-1.8.1/lib/thin/runner.rb:159:in run!'
/var/lib/gems/2.5.0/gems/thin-1.8.1/bin/thin:6:in <top (required)>' /usr/local/bin/thin:23:in load'
/usr/local/bin/thin:23:in `<top (required)>'

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!!

fatal error: 'open62541.h' file not found

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ò :)

Delete nodes in address space

Provide method for deleting nodes in address space. This is required for dynamic construction of the address space.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.