first commit

This commit is contained in:
2025-04-16 23:15:08 +09:00
commit 74f134c71a
153 changed files with 11803 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
# Modbus::Service.new(plc_id: 1, type: "bit_coil", start_address: 0, end_address: 15).execute
module Modbus
module Commands
def bit_coil(slave)
read_bit(slave, :read_coils)
end
end
end

View File

@@ -0,0 +1,8 @@
# Modbus::Service.new(plc_id: 1, type: "bit_input", start_address: 0, end_address: 15).execute
module Modbus
module Commands
def bit_input(slave)
read_bit(slave, :discrete_inputs)
end
end
end

View File

@@ -0,0 +1,8 @@
# Modbus::Service.new(plc_id: 1, type: "word_holding_float32", start_address: 0, end_address: 15).execute
module Modbus
module Commands
def word_holding_float32(slave)
read_float(slave, :holding_registers)
end
end
end

View File

@@ -0,0 +1,8 @@
# Modbus::Service.new(plc_id: 1, type: "word_holding_int16", start_address: 16, end_address: 31).execute
module Modbus
module Commands
def word_holding_int16(slave)
read_int(slave, 16, :holding_registers)
end
end
end

View File

@@ -0,0 +1,8 @@
# Modbus::Service.new(plc_id: 1, type: "word_input_float32", start_address: 0, end_address: 15).execute
module Modbus
module Commands
def word_input_float32(slave)
read_float(slave, :input_registers)
end
end
end

View File

@@ -0,0 +1,8 @@
# Modbus::Service.new(plc_id: 1, type: "word_input_int16", start_address: 0, end_address: 15).execute
module Modbus
module Commands
def word_input_int16(slave)
read_int(slave, 16, :input_registers)
end
end
end

View File

@@ -0,0 +1,8 @@
# Modbus::Service.new(plc_id: 1, type: "write_bit", start_address: 0, value: 1).execute
module Modbus
module Commands
def write_bit(slave)
write_coil(slave)
end
end
end

View File

@@ -0,0 +1,8 @@
# Modbus::Service.new(plc_id: 1, type: "write_bit_toggle", start_address: 0).execute
module Modbus
module Commands
def write_bit_toggle(slave)
write_toggle_coil(slave)
end
end
end

View File

@@ -0,0 +1,8 @@
# Modbus::Service.new(plc_id: 1, type: "float32", start_address: 0, value: 123.45).execute
module Modbus
module Commands
def write_float32(slave)
write_float(slave)
end
end
end

View File

@@ -0,0 +1,8 @@
# Modbus::Service.new(plc_id: 1, type: "int16", start_address: 0, value: 123).execute
module Modbus
module Commands
def write_int16(slave)
write_int(slave, 16)
end
end
end