This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rehearsal ------------------------------------------------------------ | |
Read coils 0.480000 0.080000 0.560000 ( 0.495899) | |
Read discrete inputs 0.420000 0.140000 0.560000 ( 0.503507) | |
Read holding registers 1.360000 0.150000 1.510000 ( 1.436041) | |
Read input registers 1.330000 0.150000 1.480000 ( 1.424927) | |
Write single coil 0.290000 0.120000 0.410000 ( 0.335850) | |
Write single register 0.300000 0.090000 0.390000 ( 0.329078) | |
Write multiple coils 0.510000 0.120000 0.630000 ( 0.564480) | |
Write multiple registers 1.540000 0.110000 1.650000 ( 1.582799) | |
--------------------------------------------------- total: 7.190000sec |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "lipa/web" | |
#Configuration | |
srv = root :server do | |
node :message do | |
html text("Hello World!") | |
end | |
end | |
srv.run! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rmodbus" | |
ModBus::TCPClient.connect('127.0.0.1',9999) do |cl| | |
cl.debig = true | |
cl.with_slave(1) do |sl_1| | |
sl_1.debug #=> true | |
end | |
cl.with_slave(2) do |sl_2| | |
sl_2.debug = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "rmodbus" | |
s = ModBus::TCPServer.new(9999, 1) | |
s.holding_registers = [1] * 10 | |
s.start | |
ModBus::TCPClient.connect('127.0.0.1',9999) do |cl| | |
cl.with_slave(1) do |slave| | |
slave.raise_exception_on_mismatch = true | |
slave.debug =true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dir_2["dir_1/dir_2/searched_obj"] | |
dir_2["searched_obj"] | |
dir_2["./searched_obj"] | |
dir_2["../dir_2/searched_obj"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require "lipa" | |
store = Lipa::Tree.new :store do | |
kind :category, :for => :node do | |
unit_count Proc.new { | |
count = 0 | |
children.values.each do |u| | |
count += u.count if u.kind == "unit" | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
t = Lipa::Tree.new :tree do | |
kind :some_kind, :for => :node | |
with :attr_1 => 999 do | |
some_kind :obj_1 | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Lipa::Tree["tree://dir_1/dir_2/file_1"].size | |
#or | |
tree["dir_1/dir_2/file_1"].size | |
#or | |
tree.dir_1.dir_2.file_1.size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
=begin | |
It's very simple example of implementation | |
REST-PCA gateway | |
for communication with TCP ModBus devices | |
It receives REST requests | |
(e.g http://127.0.0.1:4567/mb/127.0.0.1/8502/1/coils/6/17 ) | |
and returns data in JSON format addr : data: | |
{"coils": { | |
"6":{ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'lipa' | |
un = root :universe do | |
kind :planet_system do | |
num_planet run{ | |
count = 0 | |
children.values.each do |planet| | |
count += 1 if planet.kind == :planet | |
end | |
count |