escalator 0.2.1 → 0.2.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +2 -0
- data/Gemfile.lock +1 -1
- data/README.md +92 -23
- data/README_jp.md +104 -32
- data/escalator.gemspec +2 -2
- data/exe/escalator +25 -0
- data/lib/escalator/asm.rb +11 -8
- data/lib/escalator/cli.rb +11 -2
- data/lib/escalator/config.rb +50 -27
- data/lib/escalator/config_target.rb +93 -0
- data/lib/escalator/console.rb +124 -0
- data/lib/escalator/escalator.rb +36 -0
- data/lib/escalator/plc_define.rb +35 -0
- data/lib/escalator/plc_device.rb +171 -0
- data/lib/escalator/protocol/emulator/emu_protocol.rb +49 -0
- data/lib/escalator/protocol/emulator/emulator.rb +29 -0
- data/lib/escalator/protocol/keyence/keyence.rb +31 -0
- data/lib/escalator/protocol/keyence/kv_device.rb +51 -0
- data/lib/escalator/protocol/keyence/kv_protocol.rb +161 -0
- data/lib/escalator/protocol/mitsubishi/mc_protocol.rb +44 -4
- data/lib/escalator/protocol/mitsubishi/mitsubishi.rb +0 -6
- data/lib/escalator/protocol/mitsubishi/qdevice.rb +2 -2
- data/lib/escalator/protocol/protocol.rb +29 -2
- data/lib/escalator/tasks/build.rb +22 -28
- data/lib/escalator/uploader.rb +16 -29
- data/lib/escalator/version.rb +1 -1
- data/lib/escalator.rb +4 -12
- data/lib/plc/emulator/emu_device.rb +121 -0
- data/lib/plc/emulator/emu_plc.rb +411 -0
- data/lib/plc/emulator/emu_plc_server.rb +71 -0
- data/lib/plc/emulator/emulator.rb +28 -0
- data/{plc → lib/plc}/mitsubishi/iq-r/r08/LICENSE +0 -0
- data/lib/plc/mitsubishi/iq-r/r08/r08.gx3 +0 -0
- data/lib/plc/plc.rb +27 -0
- data/template/escalator/asm/main.esc +52 -7
- data/template/escalator/config/plc.yml +23 -7
- metadata +22 -8
- data/plc/mitsubishi/iq-r/r08/r08.gx3 +0 -0
@@ -0,0 +1,411 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2016 ITO SOFT DESIGN Inc.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
|
23
|
+
require 'escalator/plc_device'
|
24
|
+
|
25
|
+
include Escalator
|
26
|
+
|
27
|
+
module Plc
|
28
|
+
module Emulator
|
29
|
+
|
30
|
+
class EmuPlc
|
31
|
+
|
32
|
+
attr_accessor :program_data
|
33
|
+
attr_reader :program_pointer
|
34
|
+
attr_reader :device_dict
|
35
|
+
attr_reader :errors
|
36
|
+
|
37
|
+
SUFFIXES = %w(x y m c t l sc cc tc d cs ts h sd)
|
38
|
+
|
39
|
+
SUFFIXES.each do |k|
|
40
|
+
attr_reader :"#{k}_devices"
|
41
|
+
end
|
42
|
+
|
43
|
+
STOP_PLC_FLAG = 2 # bit 1
|
44
|
+
CLEAR_PROGRAM_FLAG = 4 # bit 2 require bit 1 on
|
45
|
+
|
46
|
+
CYCLE_RUN_FLAG = 2
|
47
|
+
|
48
|
+
def initialize
|
49
|
+
SUFFIXES.each do |k|
|
50
|
+
eval "@#{k}_devices = []"
|
51
|
+
end
|
52
|
+
@lock = Mutex.new
|
53
|
+
reset
|
54
|
+
end
|
55
|
+
|
56
|
+
def device_by_name name
|
57
|
+
@lock.synchronize {
|
58
|
+
d = device_dict[name]
|
59
|
+
unless d
|
60
|
+
d = EmuDevice.new name
|
61
|
+
device_dict[name] = d
|
62
|
+
end
|
63
|
+
d
|
64
|
+
}
|
65
|
+
end
|
66
|
+
|
67
|
+
def device_by_type_and_number type, number
|
68
|
+
d = EmuDevice.new type, number
|
69
|
+
device_by_name d.name
|
70
|
+
end
|
71
|
+
|
72
|
+
def reset
|
73
|
+
@word = 0
|
74
|
+
@program_data = []
|
75
|
+
@device_dict ||= {}
|
76
|
+
@lock.synchronize {
|
77
|
+
@device_dict.values.each do |d|
|
78
|
+
d.reset
|
79
|
+
end
|
80
|
+
}
|
81
|
+
end
|
82
|
+
|
83
|
+
def run_cycle
|
84
|
+
status_to_plc = device_by_name "SD0"
|
85
|
+
status_form_plc = device_by_name "SD1"
|
86
|
+
sync_input
|
87
|
+
case status_to_plc.value & (STOP_PLC_FLAG | CLEAR_PROGRAM_FLAG)
|
88
|
+
when STOP_PLC_FLAG
|
89
|
+
status_form_plc.value = 0
|
90
|
+
sleep 0.1
|
91
|
+
when STOP_PLC_FLAG | CLEAR_PROGRAM_FLAG
|
92
|
+
reset
|
93
|
+
status_form_plc.value = CLEAR_PROGRAM_FLAG
|
94
|
+
sleep 0.1
|
95
|
+
when 0
|
96
|
+
status_form_plc.value = CYCLE_RUN_FLAG
|
97
|
+
@program_pointer = 0
|
98
|
+
@stacks = [[]]
|
99
|
+
while fetch_and_execution; end
|
100
|
+
sleep 0.0001
|
101
|
+
else
|
102
|
+
sleep 0.1
|
103
|
+
end
|
104
|
+
sync_output
|
105
|
+
end
|
106
|
+
|
107
|
+
def bool
|
108
|
+
unless @stacks.empty?
|
109
|
+
!!@stacks.last.last
|
110
|
+
else
|
111
|
+
nil
|
112
|
+
end
|
113
|
+
end
|
114
|
+
|
115
|
+
def run
|
116
|
+
Thread.new do
|
117
|
+
loop do
|
118
|
+
run_cycle
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
|
123
|
+
def execute_console_commands line
|
124
|
+
a = line.chomp.split(/\s+/)
|
125
|
+
case a.first
|
126
|
+
when /^ST/i
|
127
|
+
d = device_by_name a[1]
|
128
|
+
d.set_value true, :in
|
129
|
+
"OK\r"
|
130
|
+
when /^RS/i
|
131
|
+
d = device_by_name a[1]
|
132
|
+
d.set_value false, :in
|
133
|
+
"OK\r"
|
134
|
+
when /^RDS/i
|
135
|
+
d = device_by_name a[1]
|
136
|
+
c = a[2].to_i
|
137
|
+
r = []
|
138
|
+
if d.bit_device?
|
139
|
+
c.times do
|
140
|
+
r << (d.bool(:out) ? 1 : 0)
|
141
|
+
d = device_by_name (d+1).name
|
142
|
+
end
|
143
|
+
else
|
144
|
+
case d.suffix
|
145
|
+
when "PRG"
|
146
|
+
c.times do
|
147
|
+
r << program_data[d.number * 2, 2].pack("c*").unpack("n").first
|
148
|
+
d = device_by_name (d+1).name
|
149
|
+
end
|
150
|
+
else
|
151
|
+
c.times do
|
152
|
+
r << d.word(:out)
|
153
|
+
d = device_by_name (d+1).name
|
154
|
+
end
|
155
|
+
end
|
156
|
+
end
|
157
|
+
r.map{|e| e.to_s}.join(" ") + "\r"
|
158
|
+
when /^WRS/i
|
159
|
+
d = device_by_name a[1]
|
160
|
+
c = a[2].to_i
|
161
|
+
case d.suffix
|
162
|
+
when "PRG"
|
163
|
+
a[3, c].each do |v|
|
164
|
+
program_data[d.number * 2, 2] = [v.to_i].pack("n").unpack("c*")
|
165
|
+
d = device_by_name (d+1).name
|
166
|
+
end
|
167
|
+
else
|
168
|
+
if d.bit_device?
|
169
|
+
a[3, c].each do |v|
|
170
|
+
d.set_value v == "0" ? false : true, :in
|
171
|
+
d = device_by_name (d+1).name
|
172
|
+
end
|
173
|
+
else
|
174
|
+
a[3, c].each do |v|
|
175
|
+
d.word = v.to_i
|
176
|
+
d.set_value v.to_i, :in
|
177
|
+
d = device_by_name (d+1).name
|
178
|
+
end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
"OK\r"
|
182
|
+
when /E/
|
183
|
+
eval(a[1..-1].join(" ")).inspect
|
184
|
+
else
|
185
|
+
raise "Unknown command #{a.first}"
|
186
|
+
end
|
187
|
+
end
|
188
|
+
|
189
|
+
private
|
190
|
+
|
191
|
+
def stack
|
192
|
+
@stacks.last
|
193
|
+
end
|
194
|
+
|
195
|
+
def sync_input
|
196
|
+
@lock.synchronize {
|
197
|
+
device_dict.values.each do |d|
|
198
|
+
d.sync_input
|
199
|
+
end
|
200
|
+
}
|
201
|
+
end
|
202
|
+
|
203
|
+
def sync_output
|
204
|
+
@lock.synchronize {
|
205
|
+
device_dict.values.each do |d|
|
206
|
+
d.sync_output
|
207
|
+
end
|
208
|
+
}
|
209
|
+
end
|
210
|
+
|
211
|
+
def bool= value
|
212
|
+
if stack.empty?
|
213
|
+
stack << value
|
214
|
+
else
|
215
|
+
stack[-1] = value
|
216
|
+
end
|
217
|
+
end
|
218
|
+
|
219
|
+
def and_join_stack
|
220
|
+
@stacks[-1] = [@stacks.last.inject(true){|r,b| r & b}]
|
221
|
+
end
|
222
|
+
|
223
|
+
def mnenonic_table
|
224
|
+
@mnemonic_table ||= begin
|
225
|
+
s = <<EOB
|
226
|
+
|00|END|INV|MEP|ANB|MEF|ORB|FEND|NOP|
|
227
|
+
|10|LD|LDI|LDP|LDPI|LDF|LDFI|MC|MCR|
|
228
|
+
|20|AND|ANI|ANDP|ANPI|ANDF|ANFI|
|
229
|
+
|30|OR|ORI|ORP|ORPI|ORF|ORFI|
|
230
|
+
|40|OUT|OUTI|MPS|MRD|MPP| |
|
231
|
+
|50|SET|RST|PLS| |PLF||
|
232
|
+
|60|FF||||||
|
233
|
+
|70|
|
234
|
+
|80|SFT|SFTP|SFL|SFLP|SFR|SFRP|
|
235
|
+
|90|BSFL|BSFLP|DSFL|DSFLP|BSFR|BSFRP|DSFR|DSFRP|
|
236
|
+
|A0|SFTL|SFTLP|WSFL|WSFLP|SFTR|SFTRP|WFSR|WSFRP|
|
237
|
+
EOB
|
238
|
+
table = {}
|
239
|
+
s.lines.each_with_index do |line, h|
|
240
|
+
line.chomp.split("|")[2..-1].each_with_index do |mnemonic, l|
|
241
|
+
unless mnemonic.length == 0
|
242
|
+
table[h << 4 | l] = mnemonic.downcase.to_sym
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
table
|
247
|
+
end
|
248
|
+
end
|
249
|
+
|
250
|
+
def fetch_and_execution
|
251
|
+
code = fetch_1_byte
|
252
|
+
return false unless code
|
253
|
+
mnemonic = mnenonic_table[code]
|
254
|
+
if mnemonic && respond_to?(mnemonic, true)
|
255
|
+
r = send mnemonic
|
256
|
+
r
|
257
|
+
else
|
258
|
+
nil
|
259
|
+
end
|
260
|
+
end
|
261
|
+
|
262
|
+
def fetch_1_byte
|
263
|
+
if @program_pointer < program_data.size
|
264
|
+
program_data[@program_pointer].tap do
|
265
|
+
@program_pointer += 1
|
266
|
+
end
|
267
|
+
else
|
268
|
+
nil
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
272
|
+
def fetch_device_or_value
|
273
|
+
c = fetch_1_byte
|
274
|
+
return false unless c
|
275
|
+
|
276
|
+
# check value type
|
277
|
+
case c & 0xe0
|
278
|
+
when 0x80
|
279
|
+
# bit device
|
280
|
+
when 0x00
|
281
|
+
# immediate number
|
282
|
+
return c
|
283
|
+
else
|
284
|
+
add_error "invalidate value type #{c.to_h(16)}"
|
285
|
+
return false
|
286
|
+
end
|
287
|
+
|
288
|
+
# device type
|
289
|
+
device_type = c & 0x0f
|
290
|
+
|
291
|
+
# number
|
292
|
+
number = 0
|
293
|
+
if (c & 0x10) == 0
|
294
|
+
number = fetch_1_byte
|
295
|
+
else
|
296
|
+
number = fetch_2_byte
|
297
|
+
end
|
298
|
+
|
299
|
+
# make device
|
300
|
+
d = device_by_type_and_number device_type, number
|
301
|
+
unless d
|
302
|
+
add_error "invalid device type #{c&0x3} and number #{number}"
|
303
|
+
return false
|
304
|
+
end
|
305
|
+
d
|
306
|
+
end
|
307
|
+
|
308
|
+
def fetch_bool_value inverse=false
|
309
|
+
d = fetch_device_or_value
|
310
|
+
return false unless d
|
311
|
+
unless d.is_a? EmuDevice
|
312
|
+
add_error "ld must be specify a device nor number #{d}"
|
313
|
+
return false
|
314
|
+
end
|
315
|
+
inverse ? !d.bool : d.bool
|
316
|
+
end
|
317
|
+
|
318
|
+
def add_error reason
|
319
|
+
@errors << {pc:@program_pointer, reason:reason}
|
320
|
+
end
|
321
|
+
|
322
|
+
|
323
|
+
# --- mnenonic ---
|
324
|
+
def ld inverse=false
|
325
|
+
b = fetch_bool_value inverse
|
326
|
+
return false if b.nil?
|
327
|
+
stack << b
|
328
|
+
true
|
329
|
+
end
|
330
|
+
def ldi; ld true; end
|
331
|
+
|
332
|
+
def inv
|
333
|
+
and_join_stack
|
334
|
+
self.bool = !self.bool
|
335
|
+
true
|
336
|
+
end
|
337
|
+
|
338
|
+
def and inverse=false
|
339
|
+
b = fetch_bool_value inverse
|
340
|
+
return false if b.nil?
|
341
|
+
self.bool &= b
|
342
|
+
true
|
343
|
+
end
|
344
|
+
def ani; send :and, true; end
|
345
|
+
|
346
|
+
def or inverse=false
|
347
|
+
b = fetch_bool_value inverse
|
348
|
+
return false if b.nil?
|
349
|
+
self.bool |= b
|
350
|
+
true
|
351
|
+
end
|
352
|
+
def ori; send :or, true; end
|
353
|
+
|
354
|
+
def anb
|
355
|
+
true
|
356
|
+
end
|
357
|
+
|
358
|
+
def orb
|
359
|
+
b = self.bool
|
360
|
+
stack.pop
|
361
|
+
self.bool |= b
|
362
|
+
true
|
363
|
+
end
|
364
|
+
|
365
|
+
def nop; true; end
|
366
|
+
|
367
|
+
def mps
|
368
|
+
and_join_stack
|
369
|
+
@stacks << [self.bool]
|
370
|
+
true
|
371
|
+
end
|
372
|
+
|
373
|
+
def mrd
|
374
|
+
@stacks.pop
|
375
|
+
@stacks << [self.bool]
|
376
|
+
true
|
377
|
+
end
|
378
|
+
def mpp; mrd; end
|
379
|
+
|
380
|
+
def out inverse=false
|
381
|
+
and_join_stack
|
382
|
+
d = fetch_device_or_value
|
383
|
+
unless d.is_a? EmuDevice
|
384
|
+
add_error "ld must be specify a device nor number #{d}"
|
385
|
+
return false
|
386
|
+
end
|
387
|
+
d.bool = inverse ? !self.bool : self.bool unless d.input?
|
388
|
+
stack.pop
|
389
|
+
true
|
390
|
+
end
|
391
|
+
def outi; out true; end
|
392
|
+
|
393
|
+
def set inverse=false
|
394
|
+
and_join_stack
|
395
|
+
d = fetch_device_or_value
|
396
|
+
unless d.is_a? EmuDevice
|
397
|
+
add_error "ld must be specify a device nor number #{d}"
|
398
|
+
return false
|
399
|
+
end
|
400
|
+
d.bool = !inverse if self.bool unless d.input?
|
401
|
+
stack.pop
|
402
|
+
true
|
403
|
+
end
|
404
|
+
def rst; set true; end
|
405
|
+
|
406
|
+
|
407
|
+
|
408
|
+
end
|
409
|
+
|
410
|
+
end
|
411
|
+
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2016 ITO SOFT DESIGN Inc.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
|
23
|
+
require 'socket'
|
24
|
+
require 'escalator/plc_device'
|
25
|
+
|
26
|
+
module Plc
|
27
|
+
module Emulator
|
28
|
+
|
29
|
+
class EmuPlcServer
|
30
|
+
|
31
|
+
class << self
|
32
|
+
|
33
|
+
def launch
|
34
|
+
@server ||= begin
|
35
|
+
server = new
|
36
|
+
server.run
|
37
|
+
server
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
def initialize config = {}
|
44
|
+
@port = config[:port] || 5555
|
45
|
+
@plc = EmuPlc.new
|
46
|
+
end
|
47
|
+
|
48
|
+
def run
|
49
|
+
@plc.run
|
50
|
+
Thread.new do
|
51
|
+
server = TCPServer.open @port
|
52
|
+
puts "launching emulator ... "
|
53
|
+
loop do
|
54
|
+
socket = server.accept
|
55
|
+
puts "done launching"
|
56
|
+
while line = socket.gets
|
57
|
+
begin
|
58
|
+
r = @plc.execute_console_commands line
|
59
|
+
socket.puts r
|
60
|
+
rescue => e
|
61
|
+
socket.puts "E0 #{e}\r"
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2016 ITO SOFT DESIGN Inc.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
|
23
|
+
dir = File.expand_path(File.dirname(__FILE__))
|
24
|
+
$:.unshift dir unless $:.include? dir
|
25
|
+
|
26
|
+
require 'emu_device'
|
27
|
+
require 'emu_plc'
|
28
|
+
require 'emu_plc_server'
|
File without changes
|
Binary file
|
data/lib/plc/plc.rb
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2016 ITO SOFT DESIGN Inc.
|
3
|
+
#
|
4
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
5
|
+
# a copy of this software and associated documentation files (the
|
6
|
+
# "Software"), to deal in the Software without restriction, including
|
7
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
8
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
9
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
10
|
+
# the following conditions:
|
11
|
+
#
|
12
|
+
# The above copyright notice and this permission notice shall be
|
13
|
+
# included in all copies or substantial portions of the Software.
|
14
|
+
#
|
15
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
16
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
17
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
18
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
19
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
20
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
21
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
22
|
+
|
23
|
+
dir = File.expand_path(File.dirname(__FILE__))
|
24
|
+
$:.unshift dir unless $:.include? dir
|
25
|
+
|
26
|
+
# Use load instead require, because there are two emulator files.
|
27
|
+
load File.join(dir, 'emulator/emulator.rb')
|
@@ -1,7 +1,52 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
LD
|
4
|
-
OR
|
5
|
-
ANI
|
6
|
-
|
7
|
-
|
1
|
+
# |-|X0|-+-|/X1|-|/Y1|---(Y0)
|
2
|
+
# |-|Y0|-+
|
3
|
+
LD X0
|
4
|
+
OR Y0
|
5
|
+
ANI X1
|
6
|
+
ANI Y1
|
7
|
+
OUT Y0
|
8
|
+
|
9
|
+
# |X1|-+-|/X0|-|/Y0|---(Y1)
|
10
|
+
# |Y1|-+
|
11
|
+
LD X1
|
12
|
+
OR Y1
|
13
|
+
ANI X0
|
14
|
+
ANI Y0
|
15
|
+
OUT Y1
|
16
|
+
|
17
|
+
# |M0|-+-|M2|-+---(M4)
|
18
|
+
# |M1|-+-|M3|-+
|
19
|
+
LD M0
|
20
|
+
OR M1
|
21
|
+
LD M2
|
22
|
+
OR M3
|
23
|
+
ANB
|
24
|
+
OUT M4
|
25
|
+
|
26
|
+
# |M5|-+-|M7|-+---(M10)
|
27
|
+
# |M6|-+ |
|
28
|
+
# |
|
29
|
+
# |M8|-+------+
|
30
|
+
# |M9|-+
|
31
|
+
LD M5
|
32
|
+
OR M6
|
33
|
+
AND M7
|
34
|
+
LD M8
|
35
|
+
OR M9
|
36
|
+
ORB
|
37
|
+
OUT M10
|
38
|
+
|
39
|
+
# |M11|-+-/-+---(M13)
|
40
|
+
# |M12|-+ +---(Y2)
|
41
|
+
# +---(/Y3)
|
42
|
+
LD M11
|
43
|
+
OR M12
|
44
|
+
INV
|
45
|
+
MPS
|
46
|
+
OUT M13
|
47
|
+
MRD
|
48
|
+
OUT Y2
|
49
|
+
MPP
|
50
|
+
OUTI Y3
|
51
|
+
|
52
|
+
END
|
@@ -1,7 +1,23 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
:
|
7
|
-
|
1
|
+
# Run rake with target like this.
|
2
|
+
# > rake target=iq-r
|
3
|
+
|
4
|
+
# plc section
|
5
|
+
plc:
|
6
|
+
iq-r: # It's a target name
|
7
|
+
cpu: iq-r # It's just a comment.
|
8
|
+
protocol: mc_protocol # It's a protocol to communicate with PLC.
|
9
|
+
host: 192.168.0.10 # It's PLC's IP address or dns name.
|
10
|
+
port: 5007 # It's PLC's port no.
|
11
|
+
|
12
|
+
# You can describe targets multiply.
|
13
|
+
#
|
14
|
+
# plc2:
|
15
|
+
# cpu: kv-5000
|
16
|
+
# protocl: kv_protocol
|
17
|
+
# ...
|
18
|
+
|
19
|
+
# default section
|
20
|
+
default:
|
21
|
+
# If you set target iq-r, `rake` is same as `rake target=iq-r`.
|
22
|
+
# default target is emulator.
|
23
|
+
# target: iq-r
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: escalator
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katsuyoshi Ito
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-11-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -52,9 +52,8 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '10.0'
|
55
|
-
description:
|
56
|
-
|
57
|
-
any PLC with same ladder source or binary and prepare full stack tools.
|
55
|
+
description: We aim to design abstraction ladder which is able to run on any PLC with
|
56
|
+
same ladder source or binary and prepare full stack tools.
|
58
57
|
email:
|
59
58
|
- kito@itosoft.com
|
60
59
|
executables:
|
@@ -77,7 +76,17 @@ files:
|
|
77
76
|
- lib/escalator/asm.rb
|
78
77
|
- lib/escalator/cli.rb
|
79
78
|
- lib/escalator/config.rb
|
79
|
+
- lib/escalator/config_target.rb
|
80
|
+
- lib/escalator/console.rb
|
81
|
+
- lib/escalator/escalator.rb
|
80
82
|
- lib/escalator/intel_hex.rb
|
83
|
+
- lib/escalator/plc_define.rb
|
84
|
+
- lib/escalator/plc_device.rb
|
85
|
+
- lib/escalator/protocol/emulator/emu_protocol.rb
|
86
|
+
- lib/escalator/protocol/emulator/emulator.rb
|
87
|
+
- lib/escalator/protocol/keyence/keyence.rb
|
88
|
+
- lib/escalator/protocol/keyence/kv_device.rb
|
89
|
+
- lib/escalator/protocol/keyence/kv_protocol.rb
|
81
90
|
- lib/escalator/protocol/mitsubishi/mc_protocol.rb
|
82
91
|
- lib/escalator/protocol/mitsubishi/mitsubishi.rb
|
83
92
|
- lib/escalator/protocol/mitsubishi/qdevice.rb
|
@@ -85,15 +94,20 @@ files:
|
|
85
94
|
- lib/escalator/tasks/build.rb
|
86
95
|
- lib/escalator/uploader.rb
|
87
96
|
- lib/escalator/version.rb
|
88
|
-
- plc/
|
89
|
-
- plc/
|
97
|
+
- lib/plc/emulator/emu_device.rb
|
98
|
+
- lib/plc/emulator/emu_plc.rb
|
99
|
+
- lib/plc/emulator/emu_plc_server.rb
|
100
|
+
- lib/plc/emulator/emulator.rb
|
101
|
+
- lib/plc/mitsubishi/iq-r/r08/LICENSE
|
102
|
+
- lib/plc/mitsubishi/iq-r/r08/r08.gx3
|
103
|
+
- lib/plc/plc.rb
|
90
104
|
- sample/escalator/sample1.esc
|
91
105
|
- sample/escalator/sample2.esc
|
92
106
|
- sample/escalator/sample2.png
|
93
107
|
- template/escalator/Rakefile
|
94
108
|
- template/escalator/asm/main.esc
|
95
109
|
- template/escalator/config/plc.yml
|
96
|
-
homepage: https://github.com/ito-soft-design/escalator
|
110
|
+
homepage: https://github.com/ito-soft-design/escalator
|
97
111
|
licenses:
|
98
112
|
- MIT
|
99
113
|
metadata: {}
|
Binary file
|