escalator 0.2.1 → 0.2.2
Sign up to get free protection for your applications and to get access to all the features.
- 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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dfe377639702aeca02103cea9454ca87ccdeb14d
|
4
|
+
data.tar.gz: d79050293143f59fedd8456ac4d5dc903776fc44
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 734cbfe7bbc43d355cfc1cff00f1071aaca84be94d7813575f7bba9bbcefbfc0153b04bcf5415bf5b7354b3dc3f2e2f012d321213132aaf7cafc835e8eabe27f
|
7
|
+
data.tar.gz: 2011273b79c0aa5776ea148c3dba0ad21fb029e6ca28a6582cc83f6752803ee7c114fef653c32b813594a9556716c2af6c7b2f95d9cce469d2697e7dbe62c3b9
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -1,17 +1,19 @@
|
|
1
|
+
[[Japanese description is here.]](https://github.com/ito-soft-design/escalator/blob/master/README_jp.md)
|
2
|
+
|
1
3
|
# Escalator
|
2
4
|
|
3
5
|
The escalator is a simple abstract ladder for PLC (Programmable Logic Controller).
|
4
6
|
|
5
|
-
We aim to design
|
7
|
+
We aim to design abstraction ladder which is able to run on any PLC with same ladder source or binary and prepare full stack tools.
|
6
8
|
|
7
9
|
# Getting started
|
8
10
|
|
9
11
|
It's required the Ruby environment.
|
10
|
-
To prepare Ruby environment, please find web sites.
|
12
|
+
To prepare the Ruby environment, please find web sites.
|
11
13
|
|
12
14
|
Install Escalator at the command prompt.
|
13
15
|
|
14
|
-
```
|
16
|
+
```sh
|
15
17
|
$ gem install escalator
|
16
18
|
```
|
17
19
|
|
@@ -19,12 +21,12 @@ $ gem install escalator
|
|
19
21
|
|
20
22
|
At the command prompt, create a new Escalator project.
|
21
23
|
|
22
|
-
```
|
24
|
+
```sh
|
23
25
|
$ escalator create my_project
|
24
26
|
$ cd my_project
|
25
27
|
```
|
26
28
|
|
27
|
-
Created files are consisted like
|
29
|
+
Created files are consisted like the tree below.
|
28
30
|
|
29
31
|
```
|
30
32
|
.
|
@@ -41,31 +43,41 @@ Created files are consisted like below the tree.
|
|
41
43
|
└── r08.gx3
|
42
44
|
```
|
43
45
|
|
46
|
+
[![](http://img.youtube.com/vi/aFEtOIgKLvQ/0.jpg)](https://youtu.be/aFEtOIgKLvQ)
|
47
|
+
|
44
48
|
# Connection configuration
|
45
49
|
|
46
50
|
## PLC configuration
|
47
51
|
|
48
52
|
There is a plc project under the plc directory.
|
49
53
|
Launch the one of the plc project which you want to use.
|
50
|
-
(Currently we support MITSUBISHI iQ-R R08CUP only.)
|
54
|
+
(Currently we support the Emulator and MITSUBISHI iQ-R R08CUP only.)
|
51
55
|
|
52
56
|
Configure ethernet connection by the tool which is provided by plc maker.
|
53
57
|
Then upload settings and plc program to the plc.
|
54
58
|
|
59
|
+
[![](http://img.youtube.com/vi/fGdyIo9AmuE/0.jpg)](https://youtu.be/fGdyIo9AmuE)
|
60
|
+
|
61
|
+
|
55
62
|
## Escalator configuration
|
56
63
|
|
57
64
|
There is a configuration file at config/plc.yml.
|
58
|
-
|
65
|
+
Currently we support MITSUBISHI iQ-R R08CUP and the Emulator.
|
66
|
+
You only change host to an ip address of your plc.
|
59
67
|
|
60
68
|
```
|
61
|
-
|
62
|
-
|
63
|
-
:
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
69
|
+
# plc.yml
|
70
|
+
plc: # Beginning of PLC section.
|
71
|
+
iq-r: # It's a target name
|
72
|
+
cpu: iq-r # It's just a comment.
|
73
|
+
protocol: mc_protocol # It's a protocol to communicate with PLC.
|
74
|
+
host: 192.168.0.10 # It's PLC's IP address or dns name.
|
75
|
+
port: 5007 # It's PLC's port no.
|
68
76
|
```
|
77
|
+
|
78
|
+
[![](http://img.youtube.com/vi/m0JaOBFIHqw/0.jpg)](https://youtu.be/m0JaOBFIHqw)
|
79
|
+
|
80
|
+
|
69
81
|
## Escalator programming
|
70
82
|
|
71
83
|
Escalator program file is located under the asm directory.
|
@@ -75,24 +87,81 @@ Edit it and programming.
|
|
75
87
|
Refer [Wiki](https://github.com/ito-soft-design/escalator/wiki/mnemonic) to check mnemonic.
|
76
88
|
|
77
89
|
```
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
ANI X2
|
83
|
-
OUT M0
|
90
|
+
# main.esc
|
91
|
+
LD M0
|
92
|
+
AND M1
|
93
|
+
OUT M2
|
84
94
|
END
|
85
95
|
```
|
86
96
|
|
97
|
+
[![](http://img.youtube.com/vi/OjaSqrkWv8Q/0.jpg)](https://youtu.be/OjaSqrkWv8Q)
|
98
|
+
|
99
|
+
|
87
100
|
# Transfer the Escalator program
|
88
101
|
|
89
|
-
At the command prompt, use rake command to upload escalator program to the plc.
|
90
|
-
|
102
|
+
At the command prompt, use ```rake``` command to upload escalator program to the plc.
|
103
|
+
By default, the target plc is ```emulator```. Then launch the Emulator.
|
91
104
|
|
105
|
+
```sh
|
106
|
+
$ rake
|
92
107
|
```
|
93
|
-
|
108
|
+
|
109
|
+
If you use with the ```target``` option, the target PLC is it.
|
110
|
+
|
111
|
+
```sh
|
112
|
+
$ rake target=iq-r
|
94
113
|
```
|
95
114
|
|
115
|
+
You can describe the default target by the target section in plc.yml.
|
116
|
+
|
117
|
+
```
|
118
|
+
# plc.yml
|
119
|
+
default:
|
120
|
+
target: iq-r
|
121
|
+
```
|
122
|
+
|
123
|
+
```rake``` is same as ```rake target=iq-r```.
|
124
|
+
|
125
|
+
|
126
|
+
The Escalator program runs immediately after uploaded.
|
127
|
+
|
128
|
+
```sh
|
129
|
+
$ rake [target=iq-r]
|
130
|
+
uploading build/main.hex ...
|
131
|
+
launching emulator ...
|
132
|
+
done launching
|
133
|
+
done uploading
|
134
|
+
|
135
|
+
Escalator is an abstract PLC.
|
136
|
+
This is a console to communicate with PLC.
|
137
|
+
|
138
|
+
>
|
139
|
+
```
|
140
|
+
|
141
|
+
After uploaded the program, it becomes in to console mode.
|
142
|
+
You can read and write a device by entering commands.
|
143
|
+
|
144
|
+
Use the r command if you want to read devices.
|
145
|
+
Below example reads values of devices from M0 to M7.
|
146
|
+
|
147
|
+
```sh
|
148
|
+
> r m0 8
|
149
|
+
```
|
150
|
+
|
151
|
+
Below example writes values to devices from M0 to M7.
|
152
|
+
|
153
|
+
```sh
|
154
|
+
> w m0 0 0 0 1 1 0 1 1
|
155
|
+
```
|
156
|
+
|
157
|
+
|
158
|
+
[![](http://img.youtube.com/vi/qGbicGLB7Gs/0.jpg)](https://youtu.be/qGbicGLB7Gs)
|
159
|
+
|
160
|
+
|
161
|
+
# Information related escalator
|
162
|
+
|
163
|
+
- [My japanese diary [escalator]](http://diary.itosoft.com/?category=escalator)
|
164
|
+
- [Wiki](https://github.com/ito-soft-design/escalator/wiki/)
|
96
165
|
|
97
166
|
|
98
167
|
## License
|
data/README_jp.md
CHANGED
@@ -1,36 +1,38 @@
|
|
1
|
-
#
|
1
|
+
# エスカレーター
|
2
|
+
|
3
|
+
## 概要
|
2
4
|
|
3
5
|
エスカレーターはPLC(Programmable Logic Controller)向けの抽象的なラダーです。
|
4
6
|
どのPLCでも同じソース(できればバイナリー)で実行できる形態を目指しています。
|
5
7
|
|
6
8
|
まずはニーモニックレベルで実現し、その上に分かりやすい形のプログラミングツールを用意できればと考えています。
|
7
9
|
|
8
|
-
|
10
|
+
## 使い方
|
9
11
|
|
10
12
|
使用するにはRubyが実行できる環境が必要です。
|
11
13
|
Rubyの実行環境の構築はWebサイト等を検索して構築してください。
|
12
14
|
|
13
|
-
|
15
|
+
### インストール
|
14
16
|
|
15
17
|
gemでエスカレーターをインストールします。
|
16
18
|
|
17
|
-
```
|
19
|
+
```sh
|
18
20
|
$ gem install escalator
|
19
21
|
```
|
20
22
|
|
21
|
-
|
23
|
+
### プロジェクト作成
|
22
24
|
|
23
25
|
エスカレーターをインストールするとescalatorコマンドが使用できる様になります。
|
24
26
|
escalatorコマンドでラダーを構成するプロジェクトファイルを作ります。
|
25
27
|
|
26
|
-
```
|
28
|
+
```sh
|
27
29
|
$ escalator create my_project
|
28
30
|
$ cd my_project
|
29
31
|
```
|
30
32
|
|
31
33
|
ファイルの構成は下の様になっています。
|
32
34
|
plc以下にエスカレーターを実行するPLCプロジェクトの雛形があります。
|
33
|
-
|
35
|
+
現在はエミュレーターと三菱電機のiQ-RシリーズR08CPUのみの対応となっています。
|
34
36
|
他メーカーや他の機種は今後追加する予定です。
|
35
37
|
|
36
38
|
|
@@ -49,30 +51,36 @@ plc以下にエスカレーターを実行するPLCプロジェクトの雛形
|
|
49
51
|
└── r08.gx3
|
50
52
|
```
|
51
53
|
|
52
|
-
|
54
|
+
[![](http://img.youtube.com/vi/aFEtOIgKLvQ/0.jpg)](https://youtu.be/aFEtOIgKLvQ)
|
55
|
+
|
56
|
+
### 通信設定
|
57
|
+
|
58
|
+
#### PLCの通信設定
|
53
59
|
|
54
|
-
|
60
|
+
plc以下の使用したいPLCのプロジェクトファイルを開きます。
|
61
|
+
IPアドレスなど必要な箇所変更し、PLCに転送します。
|
55
62
|
|
56
|
-
|
57
|
-
変更後PLCに設定とプログラムを書き込みます。
|
63
|
+
[![](http://img.youtube.com/vi/fGdyIo9AmuE/0.jpg)](https://youtu.be/fGdyIo9AmuE)
|
58
64
|
|
59
|
-
|
65
|
+
#### エスカレーターの設定
|
60
66
|
|
61
67
|
config/plc.ymlファイルで設定します。
|
62
68
|
|
63
|
-
現在はiQ-Rのみの対応なので:host: 192.168.0.
|
69
|
+
現在はiQ-Rのみの対応なので:host: 192.168.0.10の行でPLCに設定したIPアドレスを指定するだけで接続できます。
|
64
70
|
|
65
71
|
```
|
66
|
-
|
67
|
-
|
68
|
-
:
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
72
|
+
# plc.yml
|
73
|
+
plc: # Beginning of PLC section.
|
74
|
+
iq-r: # It's a target name
|
75
|
+
cpu: iq-r # It's just a comment.
|
76
|
+
protocol: mc_protocol # It's a protocol to communicate with PLC.
|
77
|
+
host: 192.168.0.10 # It's PLC's IP address or dns name.
|
78
|
+
port: 5007 # It's PLC's port no.
|
73
79
|
```
|
74
80
|
|
75
|
-
|
81
|
+
[![](http://img.youtube.com/vi/m0JaOBFIHqw/0.jpg)](https://youtu.be/m0JaOBFIHqw)
|
82
|
+
|
83
|
+
### エスカレータープログラム作成
|
76
84
|
|
77
85
|
エスカレーターのプログラムはasm以下にあります。
|
78
86
|
現在はmain.escファイルから生成します。
|
@@ -83,30 +91,94 @@ PLC側の実装がまだ進んでいないので実行できるニーモニッ
|
|
83
91
|
ニーモニックについては[Wiki](https://github.com/ito-soft-design/escalator/wiki/mnemonic)の方を参照してください。
|
84
92
|
|
85
93
|
```
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
ANI X2
|
91
|
-
OUT M0
|
94
|
+
# main.esc
|
95
|
+
LD M0
|
96
|
+
AND M1
|
97
|
+
OUT M2
|
92
98
|
END
|
93
99
|
```
|
94
100
|
|
95
|
-
|
101
|
+
[![](http://img.youtube.com/vi/OjaSqrkWv8Q/0.jpg)](https://youtu.be/OjaSqrkWv8Q)
|
102
|
+
|
103
|
+
### プログラムの転送
|
104
|
+
|
105
|
+
エスカレータープログラムをplcに転送するには```rake```コマンドを使用します。
|
106
|
+
デフォルトではエミュレーターが対象になり、エミュレーターが起動します。
|
107
|
+
|
108
|
+
```sh
|
109
|
+
$ rake
|
110
|
+
```
|
111
|
+
|
112
|
+
targetを指定するとplc.ymlのplcセクション内の該当するターゲットが対象になります。
|
113
|
+
|
114
|
+
```sh
|
115
|
+
$ rake target=iq-r
|
116
|
+
```
|
117
|
+
|
118
|
+
plc.ymlファイルのdefaultセクションのtargetでデフォルトのターゲトを設定できます。
|
119
|
+
|
120
|
+
```
|
121
|
+
# plc.yml
|
122
|
+
default:
|
123
|
+
target: iq-r
|
124
|
+
```
|
125
|
+
|
126
|
+
この場合に```rake```を行うと```rake target=iq-r```をしたのと同じになります。
|
127
|
+
|
96
128
|
|
97
|
-
エスカレータープログラムをplcに転送するはrakeコマンドを使用します。
|
98
129
|
転送後プログラムが実行されます。
|
99
130
|
|
131
|
+
```sh
|
132
|
+
$ rake [target=iq-r]
|
133
|
+
uploading build/main.hex ...
|
134
|
+
launching emulator ...
|
135
|
+
done launching
|
136
|
+
done uploading
|
137
|
+
|
138
|
+
Escalator is an abstract PLC.
|
139
|
+
This is a console to communicate with PLC.
|
140
|
+
|
141
|
+
>
|
100
142
|
```
|
101
|
-
|
143
|
+
|
144
|
+
アップロードが完了するとコンソールモードになります。
|
145
|
+
コンソールモードではコマンドを打つ事でデバイスの読み書きができます。
|
146
|
+
|
147
|
+
デバイスの値を読み取るにはrコマンドを使用します。
|
148
|
+
下の例ではm0から8子分のデバイスを読み出します。
|
149
|
+
|
150
|
+
```sh
|
151
|
+
> r m0 8
|
152
|
+
```
|
153
|
+
|
154
|
+
デバイスに値を書き込むにはwコマンドを使用します。
|
155
|
+
下の例ではM0からM7まで書き込んでいます。
|
156
|
+
|
157
|
+
```sh
|
158
|
+
> w m0 0 0 0 1 1 0 1 1
|
102
159
|
```
|
103
160
|
|
161
|
+
ボタンを押した様にパルス状にデバイスをオンにするにはpwコマンドを使用します。
|
162
|
+
|
163
|
+
```sh
|
164
|
+
> p m0
|
165
|
+
```
|
166
|
+
|
167
|
+
オンになる時間をデバイスのあとに指定することもできます。単位は秒です。
|
168
|
+
|
169
|
+
```sh
|
170
|
+
> p m0 1.5
|
171
|
+
```
|
172
|
+
|
173
|
+
|
174
|
+
|
175
|
+
[![](http://img.youtube.com/vi/qGbicGLB7Gs/0.jpg)](https://youtu.be/qGbicGLB7Gs)
|
104
176
|
|
105
|
-
|
177
|
+
## エスカレーターに関する情報
|
106
178
|
|
107
179
|
- [一往確認日記 [escalator]](http://diary.itosoft.com/?category=escalator)
|
108
180
|
- [Wiki](https://github.com/ito-soft-design/escalator/wiki/)
|
109
181
|
|
110
|
-
|
182
|
+
## ライセンス
|
111
183
|
|
112
184
|
MIT
|
data/escalator.gemspec
CHANGED
@@ -10,8 +10,8 @@ Gem::Specification.new do |spec|
|
|
10
10
|
spec.email = ["kito@itosoft.com"]
|
11
11
|
|
12
12
|
spec.summary = %q{The escalator is a simple abstract ladder for PLC (Programmable Logic Controller).}
|
13
|
-
spec.description = %q{
|
14
|
-
spec.homepage = "https://github.com/ito-soft-design/escalator
|
13
|
+
spec.description = %q{We aim to design abstraction ladder which is able to run on any PLC with same ladder source or binary and prepare full stack tools.}
|
14
|
+
spec.homepage = "https://github.com/ito-soft-design/escalator"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
17
|
spec.add_dependency "thor"
|
data/exe/escalator
CHANGED
@@ -1,3 +1,28 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
# The MIT License (MIT)
|
4
|
+
#
|
5
|
+
# Copyright (c) 2016 ITO SOFT DESIGN Inc.
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining
|
8
|
+
# a copy of this software and associated documentation files (the
|
9
|
+
# "Software"), to deal in the Software without restriction, including
|
10
|
+
# without limitation the rights to use, copy, modify, merge, publish,
|
11
|
+
# distribute, sublicense, and/or sell copies of the Software, and to
|
12
|
+
# permit persons to whom the Software is furnished to do so, subject to
|
13
|
+
# the following conditions:
|
14
|
+
#
|
15
|
+
# The above copyright notice and this permission notice shall be
|
16
|
+
# included in all copies or substantial portions of the Software.
|
17
|
+
#
|
18
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
19
|
+
# EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
20
|
+
# MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
21
|
+
# NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
22
|
+
# LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
23
|
+
# OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
24
|
+
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
25
|
+
|
3
26
|
require "escalator"
|
27
|
+
|
28
|
+
Escalator::CLI.start
|
data/lib/escalator/asm.rb
CHANGED
@@ -35,7 +35,7 @@ module Escalator
|
|
35
35
|
@endian = endian || BIG_ENDIAN
|
36
36
|
@lines = []
|
37
37
|
address = 0
|
38
|
-
source.each_line do |
|
38
|
+
source.each_line do |line|
|
39
39
|
@lines << AsmLine.new(line, address, @endian)
|
40
40
|
address = @lines.last.next_address
|
41
41
|
end
|
@@ -106,18 +106,21 @@ module Escalator
|
|
106
106
|
OPERAND_TYPE_TYPE_AND_NUMBER_NUMBER = 2
|
107
107
|
|
108
108
|
def parse
|
109
|
-
|
109
|
+
/([^#]*)/ =~ line
|
110
|
+
a = $1.split(/\s+/)
|
110
111
|
mnemonic, operand1, operand2 = a
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
112
|
+
if mnemonic
|
113
|
+
@codes << encode_mnemonic(mnemonic)
|
114
|
+
case operand_type(mnemonic)
|
115
|
+
when OPERAND_TYPE_TYPE_AND_NUMBER
|
116
|
+
@codes += parse_type_and_number(operand1)
|
117
|
+
end
|
115
118
|
end
|
116
119
|
end
|
117
120
|
|
118
121
|
def operand_type mnemonic
|
119
122
|
case mnemonic
|
120
|
-
when /LD/, /AND/, /OR[^B]?$/, /OUT/, "SET", "RST", "PLS", "PLF", "FF", /SF(L|R)/
|
123
|
+
when /LD/, /AND/, /ANI/, /OR[^B]?$/, /OUT/, "SET", "RST", "PLS", "PLF", "FF", /SF(L|R)/
|
121
124
|
OPERAND_TYPE_TYPE_AND_NUMBER
|
122
125
|
else
|
123
126
|
OPERAND_TYPE_NONE
|
@@ -131,7 +134,7 @@ module Escalator
|
|
131
134
|
|01|LD|LDI|LDP|LDPI|LDF|LDFI|MC|MCR|
|
132
135
|
|02|AND|ANI|ANDP|ANPI|ANDF|ANFI|
|
133
136
|
|03|OR|ORI|ORP|ORPI|ORF|ORFI|
|
134
|
-
|04|OUT|OUTI|MPS|
|
137
|
+
|04|OUT|OUTI|MPS|MRD|MPP| |
|
135
138
|
|05|SET|RST|PLS| |PLF||
|
136
139
|
|06|FF||| |||
|
137
140
|
|07|
|
data/lib/escalator/cli.rb
CHANGED
@@ -31,10 +31,19 @@ module Escalator
|
|
31
31
|
|
32
32
|
desc "create", "Create a new project"
|
33
33
|
def create(name)
|
34
|
-
|
34
|
+
if File.exist? name
|
35
|
+
puts "ERROR: #{name} already exists."
|
36
|
+
exit -1
|
37
|
+
end
|
38
|
+
root_dir = File.expand_path(File.join(File.dirname(__FILE__), "..", ".."))
|
39
|
+
template_path = File.join(root_dir, "template", "escalator")
|
35
40
|
cp_r template_path, name
|
36
|
-
temlate_plc_path = File.join(
|
41
|
+
temlate_plc_path = File.join(root_dir, "lib", "plc")
|
37
42
|
cp_r temlate_plc_path, name
|
43
|
+
%w(plc.rb emulator).each do |fn|
|
44
|
+
rm_r File.join(name, "plc", fn)
|
45
|
+
end
|
46
|
+
puts "#{name} was successfully created."
|
38
47
|
end
|
39
48
|
|
40
49
|
end
|
data/lib/escalator/config.rb
CHANGED
@@ -22,51 +22,74 @@
|
|
22
22
|
# WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
23
23
|
|
24
24
|
require 'active_support/core_ext/string/inflections'
|
25
|
-
require "escalator/protocol/protocol"
|
26
|
-
require 'escalator/uploader'
|
27
25
|
require 'yaml'
|
26
|
+
require 'json'
|
27
|
+
require 'protocol/protocol'
|
28
28
|
|
29
29
|
include Escalator::Protocol::Mitsubishi
|
30
|
+
include Escalator::Protocol::Keyence
|
31
|
+
include Escalator::Protocol::Emulator
|
30
32
|
|
31
33
|
module Escalator
|
32
34
|
|
33
|
-
|
34
35
|
class EscalatorConfig
|
35
36
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
37
|
+
class << self
|
38
|
+
|
39
|
+
def default
|
40
|
+
@config ||= begin
|
41
|
+
load File.join("config", "plc.yml")
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def load path
|
46
|
+
h = {}
|
47
|
+
if File.exist?(path)
|
48
|
+
h = YAML.load(File.read(path))
|
49
|
+
h = JSON.parse(h.to_json, symbolize_names: true)
|
50
|
+
end
|
40
51
|
new h || {}
|
41
52
|
end
|
53
|
+
|
42
54
|
end
|
43
55
|
|
44
56
|
def initialize options={}
|
45
|
-
default = {
|
46
|
-
|
57
|
+
default = {
|
58
|
+
input: "asm/main.asm",
|
59
|
+
output: "build/main.hex",
|
60
|
+
}
|
61
|
+
emulator_default = {
|
62
|
+
host: "localhost",
|
63
|
+
port: 5555,
|
64
|
+
protocol: "emu_protocol",
|
65
|
+
}
|
66
|
+
|
67
|
+
@config = default.merge options
|
68
|
+
@config[:plc] ||= {}
|
69
|
+
@config[:plc][:emulator] = @config[:plc][:emulator] ? emulator_default.merge(@config[:plc][:emulator]) : emulator_default
|
70
|
+
|
71
|
+
@config[:default] ||= {}
|
72
|
+
|
73
|
+
@targets = {}
|
47
74
|
end
|
48
75
|
|
49
|
-
def
|
50
|
-
@
|
51
|
-
plc_info = @config[:plc]
|
52
|
-
p = eval("#{plc_info[:protocol].camelize}.new")
|
53
|
-
p.host = plc_info[:host] if plc_info[:host]
|
54
|
-
p.port = plc_info[:port] if plc_info[:port]
|
55
|
-
p.log_level = plc_info[:log_level] if plc_info[:log_level]
|
56
|
-
p
|
57
|
-
rescue
|
58
|
-
nil
|
59
|
-
end
|
76
|
+
def [] key
|
77
|
+
@config[key]
|
60
78
|
end
|
61
79
|
|
62
|
-
def
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
80
|
+
def target name=nil
|
81
|
+
name ||= (@config[:default][:target] || :emulator)
|
82
|
+
name = name.to_sym if name.is_a? String
|
83
|
+
target = @targets[name]
|
84
|
+
unless target
|
85
|
+
h = @config[:plc][name]
|
86
|
+
unless h.nil? || h.empty?
|
87
|
+
h = {name:name}.merge h
|
88
|
+
target = EscalatorConfigTarget.new h
|
89
|
+
@targets[name] = target
|
90
|
+
end
|
69
91
|
end
|
92
|
+
target
|
70
93
|
end
|
71
94
|
|
72
95
|
def method_missing(name, *args)
|