ladder_drive 0.6.4 → 0.6.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/Gemfile.lock +31 -23
- data/README_jp.md +2 -2
- data/ladder_drive.gemspec +10 -7
- data/lib/ladder_drive.rb +3 -0
- data/lib/ladder_drive/config.rb +3 -1
- data/lib/ladder_drive/version.rb +1 -1
- data/lib/plc/emulator/emu_plc_server.rb +3 -1
- data/lib/plc/emulator/plc_plugins.rb +20 -13
- data/lib/plc/emulator/plugin_trigger_state.rb +152 -0
- data/plugins/ambient_plugin.rb +1 -33
- data/plugins/ifttt_plugin.rb +4 -27
- data/plugins/slack_plugin.rb +4 -2
- data/plugins/trello_plugin.rb +4 -33
- metadata +55 -8
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9b8a4c3fda62348e4b5e414860c9f3e9b26c962c
|
4
|
+
data.tar.gz: ed8bdb8780a0ba01078c741457b9c40e769c4743
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4d66f4ebbfc6ca268290c4915419b8413c71595bab618e45b3e52f0c470a6e1e8a6ab669179c232b5559b5e7d9ff3b52a2d7e0951488fe51f0536a82633d1179
|
7
|
+
data.tar.gz: 2fc3b6a350452c327c1e8d8336cd61812028f7f682e6ad74e84ee2a93cc751beb44666635aced2604c21d1581563680d4a64c62219cf8f571389893afe93d02f
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -2,37 +2,42 @@ PATH
|
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
4
|
ladder_drive (0.6.4)
|
5
|
-
activesupport (~>
|
6
|
-
|
7
|
-
|
5
|
+
activesupport (~> 4.0)
|
6
|
+
ambient_iot (~> 0.1, >= 0.1.1)
|
7
|
+
dotenv (~> 2.1)
|
8
|
+
ffi (~> 1.9, >= 1.9.24)
|
9
|
+
google_drive (~> 3.0, >= 3.0.3)
|
8
10
|
pi_piper (~> 2.0, >= 2.0.0)
|
9
11
|
ruby-trello (~> 2.1)
|
10
|
-
serialport
|
12
|
+
serialport (~> 1.3.1)
|
11
13
|
thor (~> 0)
|
12
14
|
|
13
15
|
GEM
|
14
16
|
remote: https://rubygems.org/
|
15
17
|
specs:
|
16
|
-
activemodel (
|
17
|
-
activesupport (=
|
18
|
-
|
19
|
-
|
20
|
-
i18n (
|
18
|
+
activemodel (4.2.11.1)
|
19
|
+
activesupport (= 4.2.11.1)
|
20
|
+
builder (~> 3.1)
|
21
|
+
activesupport (4.2.11.1)
|
22
|
+
i18n (~> 0.7)
|
21
23
|
minitest (~> 5.1)
|
24
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
22
25
|
tzinfo (~> 1.1)
|
23
|
-
addressable (2.
|
24
|
-
public_suffix (>= 2.0.2, <
|
26
|
+
addressable (2.7.0)
|
27
|
+
public_suffix (>= 2.0.2, < 5.0)
|
25
28
|
ambient_iot (0.1.1)
|
29
|
+
builder (3.2.3)
|
26
30
|
concurrent-ruby (1.1.5)
|
27
31
|
declarative (0.0.10)
|
28
32
|
declarative-option (0.1.0)
|
29
33
|
domain_name (0.5.20190701)
|
30
34
|
unf (>= 0.0.5, < 1.0.0)
|
35
|
+
dotenv (2.7.5)
|
31
36
|
eventmachine (1.0.9)
|
32
|
-
faraday (0.
|
37
|
+
faraday (0.17.0)
|
33
38
|
multipart-post (>= 1.2, < 3)
|
34
39
|
ffi (1.9.25)
|
35
|
-
google-api-client (0.30.
|
40
|
+
google-api-client (0.30.10)
|
36
41
|
addressable (~> 2.5, >= 2.5.1)
|
37
42
|
googleauth (>= 0.5, < 0.10.0)
|
38
43
|
httpclient (>= 2.8.1, < 3.0)
|
@@ -44,45 +49,47 @@ GEM
|
|
44
49
|
google-api-client (>= 0.11.0, < 0.31.0)
|
45
50
|
googleauth (>= 0.5.0, < 1.0.0)
|
46
51
|
nokogiri (>= 1.5.3, < 2.0.0)
|
47
|
-
googleauth (0.
|
52
|
+
googleauth (0.9.0)
|
48
53
|
faraday (~> 0.12)
|
49
54
|
jwt (>= 1.4, < 3.0)
|
50
55
|
memoist (~> 0.16)
|
51
56
|
multi_json (~> 1.11)
|
52
57
|
os (>= 0.9, < 2.0)
|
53
58
|
signet (~> 0.7)
|
59
|
+
http-accept (1.7.0)
|
54
60
|
http-cookie (1.0.3)
|
55
61
|
domain_name (~> 0.5)
|
56
62
|
httpclient (2.8.3)
|
57
|
-
i18n (
|
63
|
+
i18n (0.9.5)
|
58
64
|
concurrent-ruby (~> 1.0)
|
59
65
|
json (2.2.0)
|
60
66
|
jwt (2.2.1)
|
61
67
|
memoist (0.16.0)
|
62
|
-
mime-types (3.
|
68
|
+
mime-types (3.3)
|
63
69
|
mime-types-data (~> 3.2015)
|
64
|
-
mime-types-data (3.2019.
|
70
|
+
mime-types-data (3.2019.1009)
|
65
71
|
mini_mime (1.0.2)
|
66
72
|
mini_portile2 (2.4.0)
|
67
|
-
minitest (5.
|
73
|
+
minitest (5.12.2)
|
68
74
|
multi_json (1.13.1)
|
69
75
|
multipart-post (2.1.1)
|
70
76
|
netrc (0.11.0)
|
71
|
-
nokogiri (1.10.
|
77
|
+
nokogiri (1.10.4)
|
72
78
|
mini_portile2 (~> 2.4.0)
|
73
79
|
oauth (0.5.4)
|
74
80
|
os (1.0.1)
|
75
81
|
pi_piper (2.0.0)
|
76
82
|
eventmachine (= 1.0.9)
|
77
83
|
ffi
|
78
|
-
power_assert (1.1.
|
79
|
-
public_suffix (
|
84
|
+
power_assert (1.1.5)
|
85
|
+
public_suffix (4.0.1)
|
80
86
|
rake (10.5.0)
|
81
87
|
representable (3.0.4)
|
82
88
|
declarative (< 0.1.0)
|
83
89
|
declarative-option (< 0.2.0)
|
84
90
|
uber (< 0.2.0)
|
85
|
-
rest-client (2.0
|
91
|
+
rest-client (2.1.0)
|
92
|
+
http-accept (>= 1.7.0, < 2.0)
|
86
93
|
http-cookie (>= 1.0.2, < 2.0)
|
87
94
|
mime-types (>= 1.16, < 4.0)
|
88
95
|
netrc (~> 0.8)
|
@@ -100,7 +107,7 @@ GEM
|
|
100
107
|
faraday (~> 0.9)
|
101
108
|
jwt (>= 1.5, < 3.0)
|
102
109
|
multi_json (~> 1.10)
|
103
|
-
test-unit (3.3.
|
110
|
+
test-unit (3.3.4)
|
104
111
|
power_assert
|
105
112
|
test-unit-rr (1.0.5)
|
106
113
|
rr (>= 1.1.1)
|
@@ -121,6 +128,7 @@ DEPENDENCIES
|
|
121
128
|
activesupport (>= 4.0)
|
122
129
|
ambient_iot (>= 0.1.1)
|
123
130
|
bundler (~> 1.11)
|
131
|
+
dotenv
|
124
132
|
ffi (~> 1.9.24)
|
125
133
|
google_drive
|
126
134
|
ladder_drive!
|
data/README_jp.md
CHANGED
@@ -36,8 +36,7 @@ $ cd my_project
|
|
36
36
|
|
37
37
|
ファイルの構成は下の様になっています。
|
38
38
|
plc以下にLadderDriveを実行するPLCプロジェクトの雛形があります。
|
39
|
-
現在はエミュレーターと三菱電機のiQ-RシリーズR08CPUのみの対応となっています。
|
40
|
-
他メーカーや他の機種は今後追加する予定です。
|
39
|
+
現在はエミュレーターと三菱電機のiQ-RシリーズR08CPU、キーエンスKV-5000のみの対応となっています。
|
41
40
|
|
42
41
|
|
43
42
|
```
|
@@ -310,6 +309,7 @@ Ladder DriveをIoT Gateway として機能させるプラグインになりま
|
|
310
309
|
|plc_mapper|複数のPLCのデータをLadder Driveのメモリーに展開します。|
|
311
310
|
|slack|Slackにデータの変化を記録します。|
|
312
311
|
|trello|trelloのカードを指定のリストに移動します。|
|
312
|
+
|ambient|Ambientにデータの変化を記録します。|
|
313
313
|
|
314
314
|
これらの用意されているプラグインをインストールするには
|
315
315
|
|
data/ladder_drive.gemspec
CHANGED
@@ -14,13 +14,16 @@ Gem::Specification.new do |spec|
|
|
14
14
|
spec.homepage = "https://github.com/ito-soft-design/ladder_drive"
|
15
15
|
spec.license = "MIT"
|
16
16
|
|
17
|
-
spec.add_runtime_dependency 'thor',
|
18
|
-
spec.add_runtime_dependency 'activesupport',
|
19
|
-
spec.add_runtime_dependency 'ffi',
|
20
|
-
spec.add_runtime_dependency 'pi_piper',
|
21
|
-
|
22
|
-
spec.add_runtime_dependency '
|
23
|
-
spec.add_runtime_dependency '
|
17
|
+
spec.add_runtime_dependency 'thor', '~> 0'
|
18
|
+
spec.add_runtime_dependency 'activesupport', '~> 4.0'
|
19
|
+
spec.add_runtime_dependency 'ffi', '~> 1.9', '>= 1.9.24'
|
20
|
+
spec.add_runtime_dependency 'pi_piper', '~> 2.0', '>= 2.0.0'
|
21
|
+
|
22
|
+
spec.add_runtime_dependency 'serialport', '~> 1.3', '>= 1.3.1'
|
23
|
+
spec.add_runtime_dependency 'ambient_iot', '~> 0.1', '>= 0.1.1'
|
24
|
+
spec.add_runtime_dependency 'google_drive', '~> 3.0', '>= 3.0.3'
|
25
|
+
spec.add_runtime_dependency 'ruby-trello', '~>2.1'
|
26
|
+
spec.add_runtime_dependency 'dotenv', '~>2.1'
|
24
27
|
|
25
28
|
spec.required_ruby_version = '>= 2.3.3'
|
26
29
|
|
data/lib/ladder_drive.rb
CHANGED
data/lib/ladder_drive/config.rb
CHANGED
@@ -25,6 +25,7 @@ require 'active_support/core_ext/string/inflections'
|
|
25
25
|
require 'yaml'
|
26
26
|
require 'json'
|
27
27
|
require 'protocol/protocol'
|
28
|
+
require 'erb'
|
28
29
|
|
29
30
|
include LadderDrive::Protocol::Mitsubishi
|
30
31
|
include LadderDrive::Protocol::Keyence
|
@@ -46,7 +47,8 @@ module LadderDrive
|
|
46
47
|
def load path
|
47
48
|
h = {}
|
48
49
|
if File.exist?(path)
|
49
|
-
|
50
|
+
erb = ERB.new File.read(path)
|
51
|
+
h = YAML.load(erb.result(binding))
|
50
52
|
h = JSON.parse(h.to_json, symbolize_names: true)
|
51
53
|
end
|
52
54
|
new h || {}
|
data/lib/ladder_drive/version.rb
CHANGED
@@ -52,9 +52,11 @@ module Emulator
|
|
52
52
|
Thread.new do
|
53
53
|
server = TCPServer.open @port
|
54
54
|
puts "launching emulator ... "
|
55
|
+
launched = false
|
55
56
|
loop do
|
56
57
|
Thread.start(server.accept) do |socket|
|
57
|
-
puts "done launching"
|
58
|
+
puts "done launching" unless launched
|
59
|
+
launched ||= true
|
58
60
|
while line = socket.gets
|
59
61
|
begin
|
60
62
|
r = @plc.execute_console_commands line
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (c)
|
2
|
+
# Copyright (c) 201 ITO SOFT DESIGN Inc.
|
3
3
|
#
|
4
4
|
# Permission is hereby granted, free of charge, to any person obtaining
|
5
5
|
# a copy of this software and associated documentation files (the
|
@@ -25,6 +25,8 @@ $:.unshift dir unless $:.include? dir
|
|
25
25
|
|
26
26
|
require 'active_support'
|
27
27
|
require 'active_support/core_ext'
|
28
|
+
require 'erb'
|
29
|
+
require 'plugin_trigger_state'
|
28
30
|
|
29
31
|
module PlcPlugins
|
30
32
|
|
@@ -110,6 +112,8 @@ class Plugin
|
|
110
112
|
def initialize plc
|
111
113
|
@config = load_config
|
112
114
|
@plc = plc
|
115
|
+
@device_states = {}
|
116
|
+
@trigger_states = {}
|
113
117
|
end
|
114
118
|
|
115
119
|
def name
|
@@ -124,31 +128,34 @@ class Plugin
|
|
124
128
|
return false unless self.plc == plc
|
125
129
|
end
|
126
130
|
|
131
|
+
def triggered? trigger_config
|
132
|
+
state = trigger_state_for trigger_config
|
133
|
+
state.reset
|
134
|
+
state.update
|
135
|
+
state.triggered?
|
136
|
+
end
|
137
|
+
|
138
|
+
def trigger_state_for trigger_config
|
139
|
+
@trigger_states[trigger_config.object_id] ||= PluginTriggerState.new(plc, trigger_config)
|
140
|
+
end
|
141
|
+
|
142
|
+
|
127
143
|
private
|
128
144
|
|
129
145
|
def load_config
|
130
146
|
h = {}
|
131
147
|
path = File.join("config", "plugins", "#{name}.yml")
|
132
148
|
if File.exist?(path)
|
133
|
-
|
149
|
+
erb = ERB.new File.read(path)
|
150
|
+
h = YAML.load(erb.result(binding))
|
134
151
|
h = JSON.parse(h.to_json, symbolize_names: true)
|
135
152
|
end
|
136
153
|
h
|
137
154
|
end
|
138
155
|
|
139
|
-
end
|
140
156
|
|
141
157
|
end
|
142
|
-
end
|
143
158
|
|
144
159
|
|
145
|
-
|
146
|
-
def load_plugin_config name
|
147
|
-
h = {}
|
148
|
-
path = File.join("config", "plugins", "#{name}.yml")
|
149
|
-
if File.exist?(path)
|
150
|
-
h = YAML.load(File.read(path))
|
151
|
-
h = JSON.parse(h.to_json, symbolize_names: true)
|
152
|
-
end
|
153
|
-
h
|
160
|
+
end
|
154
161
|
end
|
@@ -0,0 +1,152 @@
|
|
1
|
+
#
|
2
|
+
# Copyright (c) 2018 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 = Dir.pwd
|
24
|
+
$:.unshift dir unless $:.include? dir
|
25
|
+
|
26
|
+
require 'active_support'
|
27
|
+
require 'active_support/core_ext'
|
28
|
+
require 'erb'
|
29
|
+
|
30
|
+
|
31
|
+
module LadderDrive
|
32
|
+
module Emulator
|
33
|
+
|
34
|
+
|
35
|
+
class PluginTriggerState
|
36
|
+
attr_reader :plc
|
37
|
+
attr_reader :config
|
38
|
+
attr_reader :device
|
39
|
+
attr_reader :value_type
|
40
|
+
attr_reader :value
|
41
|
+
|
42
|
+
def initialize plc, config
|
43
|
+
@plc = plc
|
44
|
+
@config = config
|
45
|
+
@value_type = config[:value_type]
|
46
|
+
@devices = {}
|
47
|
+
@next_trigger_times = {}
|
48
|
+
end
|
49
|
+
|
50
|
+
def key
|
51
|
+
object_id
|
52
|
+
end
|
53
|
+
|
54
|
+
def value
|
55
|
+
@value
|
56
|
+
end
|
57
|
+
|
58
|
+
def value= value
|
59
|
+
if @changed.nil?
|
60
|
+
@changed = @value != value
|
61
|
+
@raised = @changed && !!value
|
62
|
+
@fallen = @changed && !value
|
63
|
+
@value = value
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
def changed?
|
68
|
+
!!@changed
|
69
|
+
end
|
70
|
+
|
71
|
+
def raised?
|
72
|
+
!!@raised
|
73
|
+
end
|
74
|
+
|
75
|
+
def fallen?
|
76
|
+
!!@fallen
|
77
|
+
end
|
78
|
+
|
79
|
+
def triggered?
|
80
|
+
!!@triggered
|
81
|
+
end
|
82
|
+
|
83
|
+
def device
|
84
|
+
device_with_trigger(config[:triggers]&.first || config[:trigger])
|
85
|
+
end
|
86
|
+
|
87
|
+
def update
|
88
|
+
return unless @triggered.nil?
|
89
|
+
|
90
|
+
triggers = config[:triggers]
|
91
|
+
triggers ||= [config[:trigger]]
|
92
|
+
|
93
|
+
@triggered = false
|
94
|
+
|
95
|
+
triggers.each do |trigger|
|
96
|
+
case trigger[:type]
|
97
|
+
when "changed", "raise", "fall", "raise_and_fall"
|
98
|
+
device = device_with_trigger(trigger)
|
99
|
+
value = device.send(@value_type || :value)
|
100
|
+
|
101
|
+
# update flags
|
102
|
+
@changed = @value != value
|
103
|
+
case value
|
104
|
+
when true, false, nil
|
105
|
+
@raised = @changed && !!value
|
106
|
+
@fallen = @changed && !value
|
107
|
+
else
|
108
|
+
@fallen = @changed && value == 0
|
109
|
+
@raised = @changed && !@fallen
|
110
|
+
end
|
111
|
+
@value = value
|
112
|
+
|
113
|
+
# judgement triggered
|
114
|
+
case trigger[:type]
|
115
|
+
when "raise"
|
116
|
+
@triggered = true if @raised
|
117
|
+
when "fall"
|
118
|
+
@triggered = true if @fallen
|
119
|
+
else
|
120
|
+
@triggered = true if @changed
|
121
|
+
end
|
122
|
+
|
123
|
+
when "interval"
|
124
|
+
now = Time.now
|
125
|
+
t = @next_trigger_times[trigger.object_id] || now
|
126
|
+
while now >= t
|
127
|
+
@triggered ||= true
|
128
|
+
t += trigger[:interval]
|
129
|
+
end
|
130
|
+
@next_trigger_times[trigger.object_id] = t
|
131
|
+
else
|
132
|
+
@triggered = false
|
133
|
+
end
|
134
|
+
end
|
135
|
+
@triggered
|
136
|
+
end
|
137
|
+
|
138
|
+
def reset
|
139
|
+
@changed = nil
|
140
|
+
@raised = nil
|
141
|
+
@fallen = nil
|
142
|
+
@triggered = nil
|
143
|
+
end
|
144
|
+
|
145
|
+
def device_with_trigger trigger
|
146
|
+
@devices[trigger.object_id] ||= @plc.device_by_name(trigger[:device])
|
147
|
+
end
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
end
|
data/plugins/ambient_plugin.rb
CHANGED
@@ -82,7 +82,6 @@ class AmbientPlugin < Plugin
|
|
82
82
|
return if disabled?
|
83
83
|
|
84
84
|
@values = {}
|
85
|
-
@times = {}
|
86
85
|
@worker_queue = Queue.new
|
87
86
|
|
88
87
|
setup
|
@@ -93,41 +92,10 @@ class AmbientPlugin < Plugin
|
|
93
92
|
return unless config[:channels]
|
94
93
|
|
95
94
|
config[:channels].each do |channel|
|
96
|
-
channel = channel
|
97
95
|
next unless channel[:channel_id]
|
98
96
|
next unless channel[:write_key]
|
99
97
|
begin
|
100
|
-
|
101
|
-
interval_triggered = false
|
102
|
-
now = Time.now
|
103
|
-
triggered = false
|
104
|
-
v = nil
|
105
|
-
case channel[:trigger][:type]
|
106
|
-
when "interval"
|
107
|
-
t = @times[channel.object_id] || now
|
108
|
-
triggered = t <= now
|
109
|
-
if triggered
|
110
|
-
interval_triggered = true
|
111
|
-
t += channel[:trigger][:interval] || 300
|
112
|
-
@times[channel.object_id] = t
|
113
|
-
end
|
114
|
-
else
|
115
|
-
device = plc.device_by_name channel[:trigger][:device]
|
116
|
-
v = device.send channel[:trigger][:value_type]
|
117
|
-
unless @values[device.name] == v
|
118
|
-
@values[device.name] = v
|
119
|
-
case channel[:trigger][:type]
|
120
|
-
when "raise"
|
121
|
-
triggered = !!v
|
122
|
-
when "fall"
|
123
|
-
triggered = !v
|
124
|
-
else
|
125
|
-
triggered = true
|
126
|
-
end
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
next unless triggered || interval_triggered
|
98
|
+
next unless self.triggered?(channel)
|
131
99
|
|
132
100
|
# gether values
|
133
101
|
values = channel[:devices].inject({}) do |h, pair|
|
data/plugins/ifttt_plugin.rb
CHANGED
@@ -76,36 +76,13 @@ class IftttPlugin < Plugin
|
|
76
76
|
return if disabled?
|
77
77
|
config[:events].each do |event|
|
78
78
|
begin
|
79
|
-
|
80
|
-
case event[:trigger][:type]
|
81
|
-
when "interval"
|
82
|
-
now = Time.now
|
83
|
-
t = @times[event.object_id] || now
|
84
|
-
triggered = t <= now
|
85
|
-
if triggered
|
86
|
-
t += event[:trigger][:interval] || 300
|
87
|
-
@times[event.object_id] = t
|
88
|
-
end
|
89
|
-
else
|
90
|
-
d = plc.device_by_name event[:trigger][:device]
|
91
|
-
v = d.send event[:trigger][:value_type], event[:trigger][:text_length] || 8
|
92
|
-
unless @values[event.object_id] == v
|
93
|
-
@values[event.object_id] = v
|
94
|
-
case event[:trigger][:type]
|
95
|
-
when "raise"
|
96
|
-
triggered = !!v
|
97
|
-
when "fall"
|
98
|
-
triggered = !v
|
99
|
-
else
|
100
|
-
triggered = true
|
101
|
-
end
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
next unless triggered
|
79
|
+
next unless self.triggered?(event)
|
106
80
|
|
81
|
+
v = trigger_state_for(event).value
|
107
82
|
@worker_queue.push event:event[:name], payload:event[:params].dup || {}, value:v
|
108
83
|
rescue => e
|
84
|
+
puts $!
|
85
|
+
puts $@
|
109
86
|
p e
|
110
87
|
end
|
111
88
|
end if config[:events]
|
data/plugins/slack_plugin.rb
CHANGED
@@ -97,9 +97,9 @@ class SlackPlugin < Plugin
|
|
97
97
|
t += event[:trigger][:interval] || 300
|
98
98
|
@times[event.object_id] = t
|
99
99
|
end
|
100
|
-
v = device.send event[:value_type], event[:trigger][:text_length] || 8
|
100
|
+
v = device.send event[:value_type] || :device, event[:trigger][:text_length] || 8
|
101
101
|
else
|
102
|
-
v = device.send event[:value_type], event[:text_length] || 8
|
102
|
+
v = device.send event[:value_type] || :value, event[:text_length] || 8
|
103
103
|
unless @values[device.name] == v
|
104
104
|
@values[device.name] = v
|
105
105
|
case event[:trigger][:type]
|
@@ -122,6 +122,8 @@ class SlackPlugin < Plugin
|
|
122
122
|
end
|
123
123
|
rescue => e
|
124
124
|
p e
|
125
|
+
puts $!
|
126
|
+
puts $@
|
125
127
|
end
|
126
128
|
end
|
127
129
|
end
|
data/plugins/trello_plugin.rb
CHANGED
@@ -80,40 +80,11 @@ class TrelloPlugin < Plugin
|
|
80
80
|
|
81
81
|
@config[:events].each do |event|
|
82
82
|
begin
|
83
|
-
|
84
|
-
triggered = false
|
85
|
-
now = Time.now
|
86
|
-
device = nil
|
87
|
-
|
88
|
-
case event[:trigger][:type]
|
89
|
-
when "interval"
|
90
|
-
t = @times[event_id] || now
|
91
|
-
triggered = t <= now
|
92
|
-
if triggered
|
93
|
-
triggered = true
|
94
|
-
t += event[:trigger][:interval] || 300
|
95
|
-
@times[event_id] = t
|
96
|
-
end
|
97
|
-
else
|
98
|
-
device = plc.device_by_name event[:trigger][:device]
|
99
|
-
v = device.send event[:trigger][:value_type], event[:trigger][:text_length] || 8
|
100
|
-
@values[event_id] ||= {}
|
101
|
-
unless @values[event_id][device.name] == v
|
102
|
-
@values[event_id][device.name] = v
|
103
|
-
case event[:trigger][:type]
|
104
|
-
when "raise"
|
105
|
-
triggered = !!v
|
106
|
-
when "fall"
|
107
|
-
triggered = !v
|
108
|
-
else
|
109
|
-
triggered = true
|
110
|
-
end
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
next unless triggered
|
83
|
+
next unless self.triggered?(event)
|
115
84
|
|
116
|
-
|
85
|
+
device = trigger_state_for(event).device
|
86
|
+
v = trigger_state_for(event).value
|
87
|
+
@worker_queue.push event:event, device_name:device.name, value:v, time: Time.now
|
117
88
|
|
118
89
|
rescue => e
|
119
90
|
p e
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ladder_drive
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.6.
|
4
|
+
version: 0.6.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Katsuyoshi Ito
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-
|
11
|
+
date: 2019-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: thor
|
@@ -30,21 +30,21 @@ dependencies:
|
|
30
30
|
requirements:
|
31
31
|
- - "~>"
|
32
32
|
- !ruby/object:Gem::Version
|
33
|
-
version: '
|
33
|
+
version: '4.0'
|
34
34
|
type: :runtime
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
38
|
- - "~>"
|
39
39
|
- !ruby/object:Gem::Version
|
40
|
-
version: '
|
40
|
+
version: '4.0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: ffi
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - "~>"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: 1.9
|
47
|
+
version: '1.9'
|
48
48
|
- - ">="
|
49
49
|
- !ruby/object:Gem::Version
|
50
50
|
version: 1.9.24
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
requirements:
|
55
55
|
- - "~>"
|
56
56
|
- !ruby/object:Gem::Version
|
57
|
-
version: 1.9
|
57
|
+
version: '1.9'
|
58
58
|
- - ">="
|
59
59
|
- !ruby/object:Gem::Version
|
60
60
|
version: 1.9.24
|
@@ -82,16 +82,42 @@ dependencies:
|
|
82
82
|
name: serialport
|
83
83
|
requirement: !ruby/object:Gem::Requirement
|
84
84
|
requirements:
|
85
|
+
- - "~>"
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
version: '1.3'
|
85
88
|
- - ">="
|
86
89
|
- !ruby/object:Gem::Version
|
87
|
-
version:
|
90
|
+
version: 1.3.1
|
88
91
|
type: :runtime
|
89
92
|
prerelease: false
|
90
93
|
version_requirements: !ruby/object:Gem::Requirement
|
91
94
|
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: '1.3'
|
92
98
|
- - ">="
|
93
99
|
- !ruby/object:Gem::Version
|
94
|
-
version:
|
100
|
+
version: 1.3.1
|
101
|
+
- !ruby/object:Gem::Dependency
|
102
|
+
name: ambient_iot
|
103
|
+
requirement: !ruby/object:Gem::Requirement
|
104
|
+
requirements:
|
105
|
+
- - "~>"
|
106
|
+
- !ruby/object:Gem::Version
|
107
|
+
version: '0.1'
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.1.1
|
111
|
+
type: :runtime
|
112
|
+
prerelease: false
|
113
|
+
version_requirements: !ruby/object:Gem::Requirement
|
114
|
+
requirements:
|
115
|
+
- - "~>"
|
116
|
+
- !ruby/object:Gem::Version
|
117
|
+
version: '0.1'
|
118
|
+
- - ">="
|
119
|
+
- !ruby/object:Gem::Version
|
120
|
+
version: 0.1.1
|
95
121
|
- !ruby/object:Gem::Dependency
|
96
122
|
name: google_drive
|
97
123
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,6 +125,9 @@ dependencies:
|
|
99
125
|
- - "~>"
|
100
126
|
- !ruby/object:Gem::Version
|
101
127
|
version: '3.0'
|
128
|
+
- - ">="
|
129
|
+
- !ruby/object:Gem::Version
|
130
|
+
version: 3.0.3
|
102
131
|
type: :runtime
|
103
132
|
prerelease: false
|
104
133
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -106,6 +135,9 @@ dependencies:
|
|
106
135
|
- - "~>"
|
107
136
|
- !ruby/object:Gem::Version
|
108
137
|
version: '3.0'
|
138
|
+
- - ">="
|
139
|
+
- !ruby/object:Gem::Version
|
140
|
+
version: 3.0.3
|
109
141
|
- !ruby/object:Gem::Dependency
|
110
142
|
name: ruby-trello
|
111
143
|
requirement: !ruby/object:Gem::Requirement
|
@@ -120,6 +152,20 @@ dependencies:
|
|
120
152
|
- - "~>"
|
121
153
|
- !ruby/object:Gem::Version
|
122
154
|
version: '2.1'
|
155
|
+
- !ruby/object:Gem::Dependency
|
156
|
+
name: dotenv
|
157
|
+
requirement: !ruby/object:Gem::Requirement
|
158
|
+
requirements:
|
159
|
+
- - "~>"
|
160
|
+
- !ruby/object:Gem::Version
|
161
|
+
version: '2.1'
|
162
|
+
type: :runtime
|
163
|
+
prerelease: false
|
164
|
+
version_requirements: !ruby/object:Gem::Requirement
|
165
|
+
requirements:
|
166
|
+
- - "~>"
|
167
|
+
- !ruby/object:Gem::Version
|
168
|
+
version: '2.1'
|
123
169
|
- !ruby/object:Gem::Dependency
|
124
170
|
name: bundler
|
125
171
|
requirement: !ruby/object:Gem::Requirement
|
@@ -204,6 +250,7 @@ files:
|
|
204
250
|
- lib/plc/emulator/emu_plc_server.rb
|
205
251
|
- lib/plc/emulator/emulator.rb
|
206
252
|
- lib/plc/emulator/plc_plugins.rb
|
253
|
+
- lib/plc/emulator/plugin_trigger_state.rb
|
207
254
|
- lib/plc/keyence/kv/kv-5000/DocumentWindowInfo.xml
|
208
255
|
- lib/plc/keyence/kv/kv-5000/KvsMon.ini
|
209
256
|
- lib/plc/keyence/kv/kv-5000/LadderDrive.mod
|