101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
|
# File 'lib/plc_access/protocol/omron/fins_tcp_protocol.rb', line 101
def get_bits_from_device(count, device)
open
unless available_bits_range.include? count
raise ArgumentError,
"A count #{count} must be between #{available_bits_range.first} and #{available_bits_range.last} for #{__method__}"
end
device = device_by_name device
raise ArgumentError, "#{device.name} is not bit device!" unless device.bit_device?
command = [1, 1]
command << device_to_a(device)
command << int_to_a(count, 2)
send_packet create_fins_frame( + command)
res = receive
count.times.each_with_object([]) do |i, a|
a << (res[16 + 10 + 4 + i] != 0)
end
end
|