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,93 @@
|
|
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 'active_support/core_ext/string/inflections'
|
24
|
+
require 'yaml'
|
25
|
+
require 'json'
|
26
|
+
require 'protocol/protocol'
|
27
|
+
|
28
|
+
include Escalator::Protocol::Mitsubishi
|
29
|
+
include Escalator::Protocol::Keyence
|
30
|
+
include Escalator::Protocol::Emulator
|
31
|
+
|
32
|
+
module Escalator
|
33
|
+
|
34
|
+
class EscalatorConfigTarget
|
35
|
+
|
36
|
+
class << self
|
37
|
+
|
38
|
+
def finalize
|
39
|
+
proc {
|
40
|
+
EmuPlcServer.terminate
|
41
|
+
}
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
def initialize options={}
|
47
|
+
@target_info = options
|
48
|
+
ObjectSpace.define_finalizer(self, self.class.finalize)
|
49
|
+
end
|
50
|
+
|
51
|
+
def protocol
|
52
|
+
@protocol ||= begin
|
53
|
+
p = eval("#{@target_info[:protocol].camelize}.new")
|
54
|
+
p.host = @target_info[:host] if @target_info[:host]
|
55
|
+
p.port = @target_info[:port] if @target_info[:port]
|
56
|
+
p.log_level = @target_info[:log_level] if @target_info[:log_level]
|
57
|
+
p
|
58
|
+
rescue
|
59
|
+
nil
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def uploader
|
64
|
+
@uploader ||= begin
|
65
|
+
u = Uploader.new
|
66
|
+
u.protocol = self.protocol
|
67
|
+
u
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
def method_missing(name, *args)
|
72
|
+
name = name.to_s unless name.is_a? String
|
73
|
+
case name.to_s
|
74
|
+
when /(.*)=$/
|
75
|
+
@target_info[$1.to_sym] = args.first
|
76
|
+
else
|
77
|
+
@target_info[name.to_sym]
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def run
|
82
|
+
case self.name
|
83
|
+
when :emulator
|
84
|
+
Plc::Emulator::EmuPlcServer.launch
|
85
|
+
else
|
86
|
+
# DO NOTHIN
|
87
|
+
# Actual device is running independently.
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|
@@ -0,0 +1,124 @@
|
|
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 'singleton'
|
24
|
+
require 'curses'
|
25
|
+
|
26
|
+
module Escalator
|
27
|
+
|
28
|
+
attr_accessor :target
|
29
|
+
|
30
|
+
class Console
|
31
|
+
include Singleton
|
32
|
+
|
33
|
+
def self.finalize
|
34
|
+
proc {
|
35
|
+
#Curses.close_screen
|
36
|
+
}
|
37
|
+
end
|
38
|
+
|
39
|
+
def initialize
|
40
|
+
#Curses.init_screen
|
41
|
+
ObjectSpace.define_finalizer(self, self.class.finalize)
|
42
|
+
end
|
43
|
+
|
44
|
+
def run
|
45
|
+
l = true
|
46
|
+
trap(:INT) { puts "\n> " }
|
47
|
+
|
48
|
+
display_title
|
49
|
+
|
50
|
+
loop do
|
51
|
+
begin
|
52
|
+
print "> "
|
53
|
+
line = STDIN.gets
|
54
|
+
case line.chomp
|
55
|
+
when /^\s*exit\s*$/, /^\s*quit\s*$/, /^\s*q\s*$/
|
56
|
+
break
|
57
|
+
when /^r\s+(\w+)(\s+(\d+))?/
|
58
|
+
d = protocol.device_by_name EscDevice.new($1)
|
59
|
+
c = $2 ? $2.to_i : 1
|
60
|
+
values = protocol.get_from_devices d, c
|
61
|
+
puts values.join(" ")
|
62
|
+
when /^p\s+(\w+)(\s+(\d+))?/
|
63
|
+
d = protocol.device_by_name EscDevice.new($1)
|
64
|
+
t = $2 ? $2.to_f : 0.1
|
65
|
+
protocol.set_to_devices d, 1
|
66
|
+
sleep t
|
67
|
+
protocol.set_to_devices d, 0
|
68
|
+
when /^w\s+(\w+)/
|
69
|
+
d = protocol.device_by_name EscDevice.new($1)
|
70
|
+
v = $'.scan(/\d+/).map{|e| e.to_i}
|
71
|
+
protocol.set_to_devices d, v
|
72
|
+
when /^E\s+/
|
73
|
+
puts protocol.execute(line)
|
74
|
+
when /^help/, /^h/
|
75
|
+
display_help
|
76
|
+
end
|
77
|
+
rescue => e
|
78
|
+
puts "*** ERROR: #{e} ***"
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
private
|
84
|
+
|
85
|
+
def protocol
|
86
|
+
target.protocol
|
87
|
+
end
|
88
|
+
|
89
|
+
def display_title
|
90
|
+
puts <<EOB
|
91
|
+
|
92
|
+
Escalator is an abstract PLC.
|
93
|
+
This is a console to communicate with PLC.
|
94
|
+
|
95
|
+
EOB
|
96
|
+
end
|
97
|
+
|
98
|
+
def display_help
|
99
|
+
puts <<EOB
|
100
|
+
Commands:
|
101
|
+
|
102
|
+
r: Read values from device.
|
103
|
+
r device [count]
|
104
|
+
e.g.) it reads values from M0 to M7.
|
105
|
+
> r m0 8
|
106
|
+
w: Write values to device.
|
107
|
+
w device value1 value2 ...
|
108
|
+
e.g.) it write values from D0 to D7.
|
109
|
+
> w d0 1 2 3 4 5 6 7 8
|
110
|
+
e.g.) it write values from M0 to M7.
|
111
|
+
> w m0 0 0 0 1 1 0 1 1
|
112
|
+
p: Pulse out on device. Default duration is 0.1 sec
|
113
|
+
p device [duration]
|
114
|
+
e.g.) it write 1 to m0, then write 0 after 0.5 sec.
|
115
|
+
> w m0 0.5
|
116
|
+
q: Quit this. You can use quit and exit instead of q.
|
117
|
+
h: Show help. You can use help instead of h.
|
118
|
+
|
119
|
+
EOB
|
120
|
+
end
|
121
|
+
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
@@ -0,0 +1,36 @@
|
|
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 "version"
|
27
|
+
require "cli"
|
28
|
+
require "asm"
|
29
|
+
require "intel_hex"
|
30
|
+
require "plc_define"
|
31
|
+
require "uploader"
|
32
|
+
require "config"
|
33
|
+
require "config_target"
|
34
|
+
require "plc_device"
|
35
|
+
require "protocol/protocol"
|
36
|
+
require "console"
|
@@ -0,0 +1,35 @@
|
|
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
|
+
module Escalator
|
24
|
+
module PlcDefine
|
25
|
+
|
26
|
+
# status flags
|
27
|
+
# SD0
|
28
|
+
ESC_STATUS_TO_PLC_STOP_PLC_FLAG = 2 # bit 1
|
29
|
+
ESC_STATUS_TO_PLC_CLEAR_PROGRAM = 4 # bit 2 require bit 1 on
|
30
|
+
# SD1
|
31
|
+
ESC_STATUS_FROM_PLC_CYCLE_RUN = 2
|
32
|
+
ESC_STATUS_FROM_PLC_ACK_CLEAR_PROGRAM = 4
|
33
|
+
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,171 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2016 ITO SOFT DESIGN Inc.
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
module Escalator
|
25
|
+
|
26
|
+
class PlcDevice
|
27
|
+
|
28
|
+
attr_reader :suffix, :number
|
29
|
+
attr_accessor :value
|
30
|
+
|
31
|
+
NUMBER_TYPE_DEC = 0
|
32
|
+
NUMBER_TYPE_DEC_HEX = 1
|
33
|
+
NUMBER_TYPE_HEX = 2
|
34
|
+
|
35
|
+
ESC_SUFFIXES = %w(X Y M - C T L SC CC TC D - CS TS H SD)
|
36
|
+
|
37
|
+
class << self
|
38
|
+
|
39
|
+
def status_to_plc_device
|
40
|
+
@status_to_plc_device ||= new "SD0"
|
41
|
+
end
|
42
|
+
|
43
|
+
def status_from_plc_device
|
44
|
+
@status_from_plc_device ||= new "SD1"
|
45
|
+
end
|
46
|
+
|
47
|
+
def program_area_device
|
48
|
+
@program_area_device ||= new "PRG0"
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
def initialize a, b = nil
|
54
|
+
@suffix = nil
|
55
|
+
@value = 0
|
56
|
+
case a
|
57
|
+
when Fixnum
|
58
|
+
@suffix = ESC_SUFFIXES[a]
|
59
|
+
@number = b
|
60
|
+
when String
|
61
|
+
if b
|
62
|
+
@suffix = a.upcase
|
63
|
+
@number = b
|
64
|
+
else
|
65
|
+
/([A-Z]+)?(\d+)/i =~ a
|
66
|
+
@suffix = ($1 || "").upcase
|
67
|
+
case number_type
|
68
|
+
when NUMBER_TYPE_DEC_HEX
|
69
|
+
n = $2.to_i
|
70
|
+
@number = (n / 100) * 16 + (n % 100)
|
71
|
+
when NUMBER_TYPE_HEX
|
72
|
+
@number = $2.to_i(16)
|
73
|
+
else
|
74
|
+
@number = $2.to_i
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
def name
|
81
|
+
case number_type
|
82
|
+
when NUMBER_TYPE_DEC
|
83
|
+
"#{@suffix}#{@number}"
|
84
|
+
when NUMBER_TYPE_DEC_HEX
|
85
|
+
a = [@number / 16, @number % 16]
|
86
|
+
ns = begin
|
87
|
+
s = a.last.to_s.rjust(2, "0")
|
88
|
+
s = a.first.to_s + s unless a.first == 0
|
89
|
+
s
|
90
|
+
end
|
91
|
+
"#{@suffix}#{ns}"
|
92
|
+
when NUMBER_TYPE_HEX
|
93
|
+
ns = @number.to_s(16)
|
94
|
+
ns = "0" + ns unless /^[0-9]/ =~ ns
|
95
|
+
"#{@suffix}#{ns}"
|
96
|
+
else
|
97
|
+
nil
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def next_device
|
102
|
+
d = self.class.new @suffix, @number + 1
|
103
|
+
d
|
104
|
+
end
|
105
|
+
|
106
|
+
def bit_device?
|
107
|
+
SUFFIXES_FOR_BIT.include? @suffix
|
108
|
+
end
|
109
|
+
|
110
|
+
def + value
|
111
|
+
self.class.new self.suffix, self.number + value
|
112
|
+
end
|
113
|
+
|
114
|
+
def - value
|
115
|
+
self.class.new self.suffix, [self.number - value, 0].max
|
116
|
+
end
|
117
|
+
|
118
|
+
def input?
|
119
|
+
suffixes_for_input.include? @suffix
|
120
|
+
end
|
121
|
+
|
122
|
+
def bool
|
123
|
+
case @value
|
124
|
+
when Fixnum
|
125
|
+
@value != 0
|
126
|
+
else
|
127
|
+
!!@value
|
128
|
+
end
|
129
|
+
end
|
130
|
+
def bool= v; @value = v; end
|
131
|
+
alias :word :value
|
132
|
+
alias :word= :value=
|
133
|
+
|
134
|
+
def device_code
|
135
|
+
ESC_SUFFIXES.index @suffix
|
136
|
+
end
|
137
|
+
|
138
|
+
def reset
|
139
|
+
@value = 0
|
140
|
+
end
|
141
|
+
|
142
|
+
private
|
143
|
+
|
144
|
+
SUFFIXES_FOR_DEC = %w(PRG M C T L SC CC TC D CS TS H SD)
|
145
|
+
SUFFIXES_FOR_DEC_HEX = %w()
|
146
|
+
SUFFIXES_FOR_HEX = %w(X Y)
|
147
|
+
SUFFIXES_FOR_BIT = %w(X Y M C T L SC)
|
148
|
+
SUFFIXES_FOR_INPUT = %w(X)
|
149
|
+
|
150
|
+
def suffixes_for_dec; SUFFIXES_FOR_DEC; end
|
151
|
+
def suffixes_for_dec_hex; SUFFIXES_FOR_DEC_HEX; end
|
152
|
+
def suffixes_for_hex; SUFFIXES_FOR_HEX; end
|
153
|
+
def suffixes_for_bit; SUFFIXES_FOR_BIT; end
|
154
|
+
def suffixes_for_input; SUFFIXES_FOR_INPUT; end
|
155
|
+
|
156
|
+
def suffixes
|
157
|
+
suffixes_for_dec + suffixes_for_dec_hex + suffixeds_for_hex
|
158
|
+
end
|
159
|
+
|
160
|
+
def number_type
|
161
|
+
return NUMBER_TYPE_DEC if suffixes_for_dec.include? @suffix
|
162
|
+
return NUMBER_TYPE_DEC_HEX if suffixes_for_dec_hex.include? @suffix
|
163
|
+
return NUMBER_TYPE_HEX if suffixes_for_hex.include? @suffix
|
164
|
+
nil
|
165
|
+
end
|
166
|
+
|
167
|
+
end
|
168
|
+
|
169
|
+
class EscDevice < PlcDevice; end
|
170
|
+
|
171
|
+
end
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2016 ITO SOFT DESIGN Inc.
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
module Escalator
|
25
|
+
module Protocol
|
26
|
+
module Emulator
|
27
|
+
|
28
|
+
class EmuProtocol < Escalator::Protocol::Keyence::KvProtocol
|
29
|
+
|
30
|
+
def initialize options={}
|
31
|
+
options.merge host:"localhost", port:5555
|
32
|
+
super
|
33
|
+
end
|
34
|
+
|
35
|
+
def execute line
|
36
|
+
@socket.puts(line)
|
37
|
+
@socket.gets
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def device_class
|
43
|
+
EscDevice
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2016 ITO SOFT DESIGN Inc.
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
$:.unshift File.dirname(__FILE__)
|
25
|
+
|
26
|
+
require 'socket'
|
27
|
+
require 'logger'
|
28
|
+
require 'timeout'
|
29
|
+
require 'emu_protocol'
|
@@ -0,0 +1,31 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2016 ITO SOFT DESIGN Inc.
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
dir = File.expand_path(File.dirname(__FILE__))
|
25
|
+
$:.unshift dir unless $:.include? dir
|
26
|
+
|
27
|
+
require 'socket'
|
28
|
+
require 'logger'
|
29
|
+
require 'timeout'
|
30
|
+
require 'kv_device'
|
31
|
+
require 'kv_protocol'
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# The MIT License (MIT)
|
2
|
+
#
|
3
|
+
# Copyright (c) 2016 ITO SOFT DESIGN Inc.
|
4
|
+
#
|
5
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
# a copy of this software and associated documentation files (the
|
7
|
+
# "Software"), to deal in the Software without restriction, including
|
8
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
# the following conditions:
|
12
|
+
#
|
13
|
+
# The above copyright notice and this permission notice shall be
|
14
|
+
# included in all copies or substantial portions of the Software.
|
15
|
+
#
|
16
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
|
+
|
24
|
+
module Escalator
|
25
|
+
module Protocol
|
26
|
+
module Keyence
|
27
|
+
|
28
|
+
class KvDevice < PlcDevice
|
29
|
+
|
30
|
+
def initialize a, b = nil
|
31
|
+
super
|
32
|
+
@suffix = "R" if @suffix.nil? || @suffix.length == 0
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
SUFFIXES_FOR_DEC = %w(DM EM FM ZF TM Z T TC TS C CC CS CTH CTC AT CM VM)
|
38
|
+
SUFFIXES_FOR_DEC_HEX = %w(R MR LR CR)
|
39
|
+
SUFFIXES_FOR_HEX = %w(B VB W)
|
40
|
+
SUFFIXES_FOR_BIT = %w(R B MR LR CR VB)
|
41
|
+
|
42
|
+
def suffixes_for_dec; SUFFIXES_FOR_DEC; end
|
43
|
+
def suffixes_for_dec_hex; SUFFIXES_FOR_DEC_HEX; end
|
44
|
+
def suffixeds_for_hex; SUFFIXES_FOR_HEX; end
|
45
|
+
def suffixes_for_bit; SUFFIXES_FOR_BIT; end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|