Skip to content

Instantly share code, notes, and snippets.

View atimin's full-sized avatar
🎯
Focusing

Alexey Timin atimin

🎯
Focusing
View GitHub Profile
@atimin
atimin / calc_tree.rb
Created October 20, 2011 16:07
For articles about Lipa #1
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
@atimin
atimin / access_in_unix_style.rb
Created October 27, 2011 18:25
Examples for new features of lipa-0.3.0
dir_2["dir_1/dir_2/searched_obj"]
dir_2["searched_obj"]
dir_2["./searched_obj"]
dir_2["../dir_2/searched_obj"]
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
@atimin
atimin / test_rmd.rb
Created October 29, 2011 15:27
Pass options from client to slave
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
require "lipa/web"
#Configuration
srv = root :server do
node :message do
html text("Hello World!")
end
end
srv.run!
@atimin
atimin / With clearing buffer
Created June 27, 2012 21:14
RModBus perfomance. $ bundle exec ruby example/perfomance_rtu_via_tcp.rb
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
@atimin
atimin / gist:3069186
Created July 8, 2012 03:38
Slice N-dimension matrix
#!/usr/bin/env ruby
require 'pp'
require 'test/unit/assertions.rb'
class NMatrix
attr_reader :shape, :elements, :count, :strides
def initialize(shape, elements = nil)
@shape = shape
@atimin
atimin / work_arounds.patch
Created October 26, 2018 10:41
My workarounds for OpcUa Stack
diff --git a/src/OpcUaStackServer/ServiceSet/Session.cpp b/src/OpcUaStackServer/ServiceSet/Session.cpp
index e6ec6a85..54ba71e4 100644
--- a/src/OpcUaStackServer/ServiceSet/Session.cpp
+++ b/src/OpcUaStackServer/ServiceSet/Session.cpp
@@ -255,10 +255,10 @@ namespace OpcUaStackServer
Log(Debug, "user name invalid");
return BadIdentityTokenInvalid;
}
- if (token->passwordLen() == 0) {
- Log(Debug, "password name invalid");
@atimin
atimin / makeDPIFaultRequest.cpp
Last active December 12, 2019 17:04
Make DPI Fault Request
#include "vendor/ra/powerFlex525/DPIFaultManager.h"
using namespace eipScanner;
using namespace eipScanner::vendor::ra::powerFlex525;
struct DPIFaultManagerResponse {
bool isTripped;
bool isErrored; // flag to say that we failed to make the request
std::vector<DPIFaultObject> faultObjects;
};
@atimin
atimin / PowerFlexLogicData.cpp
Last active February 7, 2020 01:42
Read Logic Status and write Logic Command for PowerFlex 525
//
// Created by Aleksey Timin on 11/16/19.
//
#include <cstdlib>
#include <sstream>
#include <cip/connectionManager/NetworkConnectionParams.h>
#include "SessionInfo.h"
#include "MessageRouter.h"
#include "ConnectionManager.h"