escalator 0.1.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +11 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +26 -0
- data/LICENSE +21 -0
- data/README.md +10 -0
- data/README_jp.md +10 -0
- data/Rakefile +9 -0
- data/bin/console +14 -0
- data/bin/setup +8 -0
- data/escalator.gemspec +26 -0
- data/exe/escalator +3 -0
- data/lib/escalator/asm.rb +208 -0
- data/lib/escalator/cli.rb +40 -0
- data/lib/escalator/intel_hex.rb +45 -0
- data/lib/escalator/tasks/build.rb +127 -0
- data/lib/escalator/version.rb +26 -0
- data/lib/escalator.rb +35 -0
- data/sample/escalator/sample1.esc +4 -0
- data/sample/escalator/sample2.esc +28 -0
- data/sample/escalator/sample2.png +0 -0
- data/template/escalator/Rakefile +1 -0
- data/template/escalator/asm/main.esc +7 -0
- metadata +112 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c264fb022bd1412ffaed30646286e0a482d4f14c
|
4
|
+
data.tar.gz: e4db446ef5fe43d1019276831145a95b42dc23a1
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 71972f246ec5255677e2e8efdc03a3f8c29fcfeeb65054cddca735ba4f726bd69f3a746208458b8b2728ab0e9d66b8671096a85b29dc3aacc68fe8f86033e986
|
7
|
+
data.tar.gz: 9b80c9f45104c524e82464eba6daaf05e1ecd3504e458bc1a858691d7a67fbffdb729bc8e0779e04dcba164ec567de79a33ef18b79cfcae3680176d12c53373f
|
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
escalator (0.1.1)
|
5
|
+
thor
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: https://rubygems.org/
|
9
|
+
specs:
|
10
|
+
power_assert (0.2.7)
|
11
|
+
rake (10.5.0)
|
12
|
+
test-unit (3.1.7)
|
13
|
+
power_assert
|
14
|
+
thor (0.19.1)
|
15
|
+
|
16
|
+
PLATFORMS
|
17
|
+
ruby
|
18
|
+
|
19
|
+
DEPENDENCIES
|
20
|
+
bundler (~> 1.11)
|
21
|
+
escalator!
|
22
|
+
rake (~> 10.0)
|
23
|
+
test-unit
|
24
|
+
|
25
|
+
BUNDLED WITH
|
26
|
+
1.11.2
|
data/LICENSE
ADDED
@@ -0,0 +1,21 @@
|
|
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 a copy
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
7
|
+
in the Software without restriction, including without limitation the rights
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
10
|
+
furnished to do so, subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
13
|
+
all copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
+
THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
# Escalator
|
2
|
+
|
3
|
+
The escalator is a simple abstract ladder for PLC (Programmable Logic Controller).
|
4
|
+
|
5
|
+
My aim is to design runnable abstraction ladder which is running on any PLC with same ladder source or binary and prepare full stack tools.
|
6
|
+
|
7
|
+
## License
|
8
|
+
|
9
|
+
The gem is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).
|
10
|
+
|
data/README_jp.md
ADDED
data/Rakefile
ADDED
data/bin/console
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "bundler/setup"
|
4
|
+
require "escalator"
|
5
|
+
|
6
|
+
# You can add fixtures and/or initialization code here to make experimenting
|
7
|
+
# with your gem easier. You can also use a different console, if you like.
|
8
|
+
|
9
|
+
# (If you use this, don't forget to add pry to your Gemfile!)
|
10
|
+
# require "pry"
|
11
|
+
# Pry.start
|
12
|
+
|
13
|
+
require "irb"
|
14
|
+
IRB.start
|
data/bin/setup
ADDED
data/escalator.gemspec
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# coding: utf-8
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'escalator/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |spec|
|
7
|
+
spec.name = "escalator"
|
8
|
+
spec.version = Escalator::VERSION
|
9
|
+
spec.authors = ["Katsuyoshi Ito"]
|
10
|
+
spec.email = ["kito@itosoft.com"]
|
11
|
+
|
12
|
+
spec.summary = %q{The escalator is a simple abstract ladder for PLC (Programmable Logic Controller).}
|
13
|
+
spec.description = %q{The escalator is a simple abstract ladder for PLC (Programmable Logic Controller). My aim is to design runnable abstraction ladder which is running on any PLC with same ladder source or binary and prepare full stack tools.}
|
14
|
+
spec.homepage = "https://github.com/ito-soft-design/escalator/wiki"
|
15
|
+
spec.license = "MIT"
|
16
|
+
|
17
|
+
spec.add_dependency "thor"
|
18
|
+
|
19
|
+
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
20
|
+
spec.bindir = "exe"
|
21
|
+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
22
|
+
spec.require_paths = ["lib"]
|
23
|
+
|
24
|
+
spec.add_development_dependency "bundler", "~> 1.11"
|
25
|
+
spec.add_development_dependency "rake", "~> 10.0"
|
26
|
+
end
|
data/exe/escalator
ADDED
@@ -0,0 +1,208 @@
|
|
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 Asm
|
27
|
+
|
28
|
+
attr_reader :codes
|
29
|
+
attr_reader :endian
|
30
|
+
|
31
|
+
LITTLE_ENDIAN = 0
|
32
|
+
BIG_ENDIAN = 1
|
33
|
+
|
34
|
+
def initialize source, endian = nil
|
35
|
+
@endian = endian || LITTLE_ENDIAN
|
36
|
+
@lines = []
|
37
|
+
address = 0
|
38
|
+
source.each_line do | line|
|
39
|
+
@lines << AsmLine.new(line, address, @endian)
|
40
|
+
address = @lines.last.next_address
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
def dump
|
45
|
+
@codes.map do |c|
|
46
|
+
c.to_s(16).rjust(2, "0")
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def dump_line
|
51
|
+
@lines.map do |line|
|
52
|
+
"#{line.address.to_s(16).rjust(4, "0")} #{line.dump_line}"
|
53
|
+
end
|
54
|
+
.join("\n") << "\n"
|
55
|
+
end
|
56
|
+
|
57
|
+
def codes
|
58
|
+
@lines.map do |line|
|
59
|
+
line.codes
|
60
|
+
end.flatten
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def parse line
|
66
|
+
@lines << AsmLine.new(line)
|
67
|
+
end
|
68
|
+
|
69
|
+
|
70
|
+
end
|
71
|
+
|
72
|
+
class AsmLine
|
73
|
+
attr_reader :line
|
74
|
+
attr_reader :codes
|
75
|
+
attr_reader :address
|
76
|
+
attr_reader :endian
|
77
|
+
|
78
|
+
def initialize line, address = 0, endian = nil
|
79
|
+
@endian = endian || Asm::LITTLE_ENDIAN
|
80
|
+
@line = line.upcase.chomp
|
81
|
+
@codes = []
|
82
|
+
@address = address
|
83
|
+
parse
|
84
|
+
end
|
85
|
+
|
86
|
+
def dump_line
|
87
|
+
"#{dump}\t#{line}"
|
88
|
+
end
|
89
|
+
|
90
|
+
def dump
|
91
|
+
@codes.map do |c|
|
92
|
+
c.to_s(16).rjust(2, "0")
|
93
|
+
end
|
94
|
+
.join(" ")
|
95
|
+
.ljust(12)
|
96
|
+
end
|
97
|
+
|
98
|
+
def next_address
|
99
|
+
address + codes.size
|
100
|
+
end
|
101
|
+
|
102
|
+
private
|
103
|
+
|
104
|
+
OPERAND_TYPE_NONE = 0
|
105
|
+
OPERAND_TYPE_TYPE_AND_NUMBER = 1
|
106
|
+
OPERAND_TYPE_TYPE_AND_NUMBER_NUMBER = 2
|
107
|
+
|
108
|
+
def parse
|
109
|
+
a = line.split(/\s+/)
|
110
|
+
mnemonic, operand1, operand2 = a
|
111
|
+
@codes << encode_mnemonic(mnemonic) if mnemonic
|
112
|
+
case operand_type(mnemonic)
|
113
|
+
when OPERAND_TYPE_TYPE_AND_NUMBER
|
114
|
+
@codes += parse_type_and_number(operand1)
|
115
|
+
end
|
116
|
+
end
|
117
|
+
|
118
|
+
def operand_type mnemonic
|
119
|
+
case mnemonic
|
120
|
+
when /LD/, /AND/, /OR[^B]?$/, /OUT/, "SET", "RST", "PLS", "PLF", "FF", /SF(L|R)/
|
121
|
+
OPERAND_TYPE_TYPE_AND_NUMBER
|
122
|
+
else
|
123
|
+
OPERAND_TYPE_NONE
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
MNEMONIC_DEF = <<EOB
|
128
|
+
| |00|10|20|30|40|50|60|70|80|90|A0|B0|C0|D0|E0|F0|
|
129
|
+
|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|:-:|
|
130
|
+
|00|END|INV|MEP|ANB|MEF|ORB|FEND|NOP|
|
131
|
+
|01|LD|LDI|LDP|LDPI|LDF|LDFI|MC|MCR|
|
132
|
+
|02|AND|ANI|ANDP|ANPI|ANDF|ANFI|
|
133
|
+
|03|OR|ORI|ORP|ORPI|ORF|ORFI|
|
134
|
+
|04|OUT|OUTI|MPS|MPD|MPP| |
|
135
|
+
|05|SET|RST|PLS| |PLF||
|
136
|
+
|06|FF||| |||
|
137
|
+
|07|
|
138
|
+
|08|SFT|SFTP|SFL|SFLP|SFR|SFRP|
|
139
|
+
|09|BSFL|BSFLP|DSFL|DSFLP|BSFR|BSFRP|DSFR|DSFRP|
|
140
|
+
|0A|SFTL|SFTLP|WSFL|WSFLP|SFTR|SFTRP|WFSR|WSFRP|
|
141
|
+
|0B|
|
142
|
+
|0C|
|
143
|
+
|0D|
|
144
|
+
|0E|
|
145
|
+
|0F|
|
146
|
+
EOB
|
147
|
+
def mnemonic_dict
|
148
|
+
@@mnemonic_dict ||= begin
|
149
|
+
h = {}
|
150
|
+
MNEMONIC_DEF.dup.split(/\n/)[2..-1].each_with_index do |line, upper|
|
151
|
+
line.split(/\|/)[2..-1].each_with_index do |mnemonic, lower|
|
152
|
+
mnemonic.strip!
|
153
|
+
next if mnemonic.nil? || mnemonic.length == 0
|
154
|
+
code = (upper << 4) | lower
|
155
|
+
h[mnemonic] = code
|
156
|
+
end
|
157
|
+
end
|
158
|
+
h
|
159
|
+
end
|
160
|
+
end
|
161
|
+
|
162
|
+
def encode_mnemonic mnemonic
|
163
|
+
mnemonic_dict[mnemonic]
|
164
|
+
end
|
165
|
+
|
166
|
+
def parse_type_and_number operand
|
167
|
+
/([[:alpha:]]*)(\d+[0-9A-Fa-f]*)\.?(\d*)?/ =~ operand
|
168
|
+
suffix = $1
|
169
|
+
number = $2
|
170
|
+
bit = $3
|
171
|
+
len = 16
|
172
|
+
case suffix
|
173
|
+
when "X", "Y"
|
174
|
+
number = number.to_i(16)
|
175
|
+
else
|
176
|
+
number = number.to_i
|
177
|
+
end
|
178
|
+
type_code = %W(X Y M - C T L SC CC TC D NOP - CS TS H SD).index(suffix)
|
179
|
+
raise "undefind suffix: #{suffix}" if type_code.nil?
|
180
|
+
|
181
|
+
case (type_code & 0xc) >> 2
|
182
|
+
when 0, 1
|
183
|
+
type_code |= 0x80
|
184
|
+
else
|
185
|
+
type_code |= 0xa0
|
186
|
+
end
|
187
|
+
|
188
|
+
if number < 256
|
189
|
+
[type_code, number]
|
190
|
+
else
|
191
|
+
case endian
|
192
|
+
when Asm::LITTLE_ENDIAN
|
193
|
+
[type_code | 0x10, number & 0xff, (number & 0xff00) >> 8]
|
194
|
+
when Asm::BIG_ENDIAN
|
195
|
+
[type_code | 0x10, (number & 0xff00) >> 8, number & 0xff]
|
196
|
+
end
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
end
|
201
|
+
|
202
|
+
|
203
|
+
end
|
204
|
+
|
205
|
+
if $0 == __FILE__
|
206
|
+
asm = Escalator::Asm.new ARGF
|
207
|
+
puts asm.dump_line
|
208
|
+
end
|
@@ -0,0 +1,40 @@
|
|
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
|
+
require 'thor'
|
25
|
+
require 'fileutils'
|
26
|
+
|
27
|
+
include FileUtils
|
28
|
+
|
29
|
+
module Escalator
|
30
|
+
class CLI < Thor
|
31
|
+
|
32
|
+
desc "create", "Create a new project"
|
33
|
+
def create(name)
|
34
|
+
template_path = File.join(Escalator_root, "template", "escalator")
|
35
|
+
cp_r template_path, name
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
module Escalator
|
2
|
+
|
3
|
+
class IntelHex
|
4
|
+
|
5
|
+
attr_reader :offset, :codes
|
6
|
+
|
7
|
+
def initialize codes, offset = 0
|
8
|
+
@offset = offset
|
9
|
+
@codes = codes
|
10
|
+
end
|
11
|
+
|
12
|
+
def dump
|
13
|
+
addr = offset
|
14
|
+
lines = []
|
15
|
+
@codes.each_slice(16) do |line_codes|
|
16
|
+
c = line_codes.size
|
17
|
+
s = ":#{c.to_s(16).rjust(2, '0')}"
|
18
|
+
s << "#{addr.to_s(16).rjust(4, '0')}"
|
19
|
+
s << "00"
|
20
|
+
line_codes.each do |code|
|
21
|
+
s << "#{code.to_s(16).rjust(2, '0')}"
|
22
|
+
end
|
23
|
+
check_sum = 256 - (s[1..-1].scan(/.{2}/).inject(0){|sum, code| sum += code.to_i(16)} & 0xff)
|
24
|
+
s << "#{check_sum.to_s(16).rjust(2, '0')}"
|
25
|
+
lines << s
|
26
|
+
addr += c
|
27
|
+
end
|
28
|
+
|
29
|
+
lines << ":00000001FF"
|
30
|
+
lines << ""
|
31
|
+
lines.join("\n")
|
32
|
+
end
|
33
|
+
|
34
|
+
def gxworks_memory_image
|
35
|
+
lines = []
|
36
|
+
@codes.each_slice(8) do |line_codes|
|
37
|
+
lines << line_codes.join("\t")
|
38
|
+
end
|
39
|
+
|
40
|
+
lines.join("\n")
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
44
|
+
|
45
|
+
end
|
@@ -0,0 +1,127 @@
|
|
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
|
+
Escalator_root = File.expand_path(File.join(File.dirname(__FILE__), "../../../"))
|
25
|
+
|
26
|
+
require 'escalator/asm'
|
27
|
+
require 'escalator/intel_hex'
|
28
|
+
require 'rake/loaders/makefile'
|
29
|
+
|
30
|
+
#directory "build"
|
31
|
+
|
32
|
+
directory "build"
|
33
|
+
|
34
|
+
desc "Assemble codes"
|
35
|
+
rule %r{^build/.+\.lst} => ['%{^build,asm}X.esc'] do |t|
|
36
|
+
Rake::Task["build"].invoke
|
37
|
+
begin
|
38
|
+
$stderr = File.open('hb.log', 'w')
|
39
|
+
$stdout = $stderr
|
40
|
+
ensure
|
41
|
+
$stdout = STDOUT
|
42
|
+
$stderr = STDERR
|
43
|
+
end
|
44
|
+
#dir = "./asm"
|
45
|
+
stream = StringIO.new
|
46
|
+
#filename = "asm/#{t.source}"
|
47
|
+
puts "asm #{t.source}"
|
48
|
+
asm = Escalator::Asm.new File.read(t.source)
|
49
|
+
#dst = File.join("build", t.name)
|
50
|
+
File.write(t.name, asm.dump_line)
|
51
|
+
end
|
52
|
+
|
53
|
+
desc "Make hex codes"
|
54
|
+
rule %r{^build/.+\.hex} => ['%{^build,asm}X.esc'] do |t|
|
55
|
+
Rake::Task["build"].invoke
|
56
|
+
begin
|
57
|
+
$stderr = File.open('hb.log', 'w')
|
58
|
+
$stdout = $stderr
|
59
|
+
ensure
|
60
|
+
$stdout = STDOUT
|
61
|
+
$stderr = STDERR
|
62
|
+
end
|
63
|
+
stream = StringIO.new
|
64
|
+
asm = Escalator::Asm.new File.read(t.source)
|
65
|
+
hex = Escalator::IntelHex.new asm.codes
|
66
|
+
File.write(t.name, hex.dump)
|
67
|
+
end
|
68
|
+
|
69
|
+
desc "GX Works Memory Image"
|
70
|
+
rule %r{^build/.+\.gxwm} => ['%{^build,asm}X.esc'] do |t|
|
71
|
+
Rake::Task["build"].invoke
|
72
|
+
begin
|
73
|
+
$stderr = File.open('hb.log', 'w')
|
74
|
+
$stdout = $stderr
|
75
|
+
ensure
|
76
|
+
$stdout = STDOUT
|
77
|
+
$stderr = STDERR
|
78
|
+
end
|
79
|
+
stream = StringIO.new
|
80
|
+
asm = Escalator::Asm.new File.read(t.source)
|
81
|
+
hex = Escalator::IntelHex.new asm.codes
|
82
|
+
File.write(t.name, hex.gxworks_memory_image)
|
83
|
+
end
|
84
|
+
|
85
|
+
=begin
|
86
|
+
desc "Assemble codes"
|
87
|
+
task :asm do
|
88
|
+
# @refer: https://github.com/rsutphin/handbrake.rb/issues/1
|
89
|
+
begin
|
90
|
+
$stderr = File.open('hb.log', 'w')
|
91
|
+
$stdout = $stderr
|
92
|
+
mkdir_p "build"
|
93
|
+
ensure
|
94
|
+
$stdout = STDOUT
|
95
|
+
$stderr = STDERR
|
96
|
+
end
|
97
|
+
dir = "./asm"
|
98
|
+
stream = StringIO.new
|
99
|
+
sources = Dir.glob("asm/**/*.esc").each do |filename|
|
100
|
+
puts "asm #{filename}"
|
101
|
+
asm = Escalator::Asm.new File.read(filename)
|
102
|
+
dst = File.join("build", File.basename(filename, ".*") + ".lst")
|
103
|
+
File.write(dst, asm.dump_line)
|
104
|
+
end
|
105
|
+
end
|
106
|
+
|
107
|
+
desc "Make hex codes"
|
108
|
+
task :hex do
|
109
|
+
begin
|
110
|
+
$stderr = File.open('hb.log', 'w')
|
111
|
+
$stdout = $stderr
|
112
|
+
mkdir_p "build"
|
113
|
+
ensure
|
114
|
+
$stdout = STDOUT
|
115
|
+
$stderr = STDERR
|
116
|
+
end
|
117
|
+
dir = "./asm"
|
118
|
+
stream = StringIO.new
|
119
|
+
sources = Dir.glob("asm/**/*.esc").each do |filename|
|
120
|
+
puts "hex #{filename}"
|
121
|
+
asm = Escalator::Asm.new File.read(filename)
|
122
|
+
dst = File.join("build", File.basename(filename, ".*") + ".hex")
|
123
|
+
hex = Escalator::IntelHex.new asm.codes
|
124
|
+
File.write(dst, hex.dump)
|
125
|
+
end
|
126
|
+
end
|
127
|
+
=end
|
@@ -0,0 +1,26 @@
|
|
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
|
+
VERSION = "0.1.2"
|
26
|
+
end
|
data/lib/escalator.rb
ADDED
@@ -0,0 +1,35 @@
|
|
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
|
+
require "escalator/version"
|
25
|
+
require "escalator/cli"
|
26
|
+
require "escalator/asm"
|
27
|
+
require "escalator/intel_hex"
|
28
|
+
|
29
|
+
Escalator_root = File.expand_path(File.join(File.dirname(__FILE__), ".."))
|
30
|
+
|
31
|
+
module Escalator
|
32
|
+
end
|
33
|
+
|
34
|
+
|
35
|
+
Escalator::CLI.start
|
@@ -0,0 +1,28 @@
|
|
1
|
+
LD X0
|
2
|
+
OUT Y0
|
3
|
+
LD M0
|
4
|
+
OR M3
|
5
|
+
ANI M2
|
6
|
+
OUT M3
|
7
|
+
LD M4
|
8
|
+
ANI M5
|
9
|
+
LDI M7
|
10
|
+
AND M8
|
11
|
+
ORB
|
12
|
+
LD M4
|
13
|
+
ANI M5
|
14
|
+
LDI M7
|
15
|
+
AND M8
|
16
|
+
ORB
|
17
|
+
ANB
|
18
|
+
OUT M6
|
19
|
+
LD M9
|
20
|
+
ANI M10
|
21
|
+
OUT M6
|
22
|
+
MPS
|
23
|
+
AND M11
|
24
|
+
OUT M12
|
25
|
+
MPP
|
26
|
+
AND M13
|
27
|
+
OUT M14
|
28
|
+
END
|
Binary file
|
@@ -0,0 +1 @@
|
|
1
|
+
require 'escalator/tasks/build'
|
metadata
ADDED
@@ -0,0 +1,112 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: escalator
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.2
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Katsuyoshi Ito
|
8
|
+
autorequire:
|
9
|
+
bindir: exe
|
10
|
+
cert_chain: []
|
11
|
+
date: 2016-10-03 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: thor
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: bundler
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '1.11'
|
34
|
+
type: :development
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '1.11'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: rake
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - "~>"
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '10.0'
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - "~>"
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '10.0'
|
55
|
+
description: The escalator is a simple abstract ladder for PLC (Programmable Logic
|
56
|
+
Controller). My aim is to design runnable abstraction ladder which is running on
|
57
|
+
any PLC with same ladder source or binary and prepare full stack tools.
|
58
|
+
email:
|
59
|
+
- kito@itosoft.com
|
60
|
+
executables:
|
61
|
+
- escalator
|
62
|
+
extensions: []
|
63
|
+
extra_rdoc_files: []
|
64
|
+
files:
|
65
|
+
- ".gitignore"
|
66
|
+
- Gemfile
|
67
|
+
- Gemfile.lock
|
68
|
+
- LICENSE
|
69
|
+
- README.md
|
70
|
+
- README_jp.md
|
71
|
+
- Rakefile
|
72
|
+
- bin/console
|
73
|
+
- bin/setup
|
74
|
+
- escalator.gemspec
|
75
|
+
- exe/escalator
|
76
|
+
- lib/escalator.rb
|
77
|
+
- lib/escalator/asm.rb
|
78
|
+
- lib/escalator/cli.rb
|
79
|
+
- lib/escalator/intel_hex.rb
|
80
|
+
- lib/escalator/tasks/build.rb
|
81
|
+
- lib/escalator/version.rb
|
82
|
+
- sample/escalator/sample1.esc
|
83
|
+
- sample/escalator/sample2.esc
|
84
|
+
- sample/escalator/sample2.png
|
85
|
+
- template/escalator/Rakefile
|
86
|
+
- template/escalator/asm/main.esc
|
87
|
+
homepage: https://github.com/ito-soft-design/escalator/wiki
|
88
|
+
licenses:
|
89
|
+
- MIT
|
90
|
+
metadata: {}
|
91
|
+
post_install_message:
|
92
|
+
rdoc_options: []
|
93
|
+
require_paths:
|
94
|
+
- lib
|
95
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
96
|
+
requirements:
|
97
|
+
- - ">="
|
98
|
+
- !ruby/object:Gem::Version
|
99
|
+
version: '0'
|
100
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - ">="
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0'
|
105
|
+
requirements: []
|
106
|
+
rubyforge_project:
|
107
|
+
rubygems_version: 2.5.1
|
108
|
+
signing_key:
|
109
|
+
specification_version: 4
|
110
|
+
summary: The escalator is a simple abstract ladder for PLC (Programmable Logic Controller).
|
111
|
+
test_files: []
|
112
|
+
has_rdoc:
|