procon_bypass_man 0.1.20 → 0.1.20.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/Gemfile.lock +1 -1
- data/lib/procon_bypass_man/bypass/bypass_mode.rb +21 -0
- data/lib/procon_bypass_man/bypass.rb +1 -0
- data/lib/procon_bypass_man/commands/bypass_command.rb +21 -2
- data/lib/procon_bypass_man/configuration.rb +15 -0
- data/lib/procon_bypass_man/scheduler.rb +1 -1
- data/lib/procon_bypass_man/version.rb +1 -1
- data/project_template/app.rb +3 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 29c989ae104586849ff797f9086b997294925372a2997797da279c6b2178098a
|
4
|
+
data.tar.gz: d23be38b1c10f9f856407fa65db924e4f8528d453c5fe59f8bdc0832dc3e93f0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 53a8875027f7b2e172bbb1873d1b76ff7ec191531e36c43dd044cc26e9bb54c80c2e1c9b63e5c9c0ec9f42829fd502f3cdbd9ac2ba41862c7835b97c8d3b66ac
|
7
|
+
data.tar.gz: 5476c22c2648861968b08ace121eef62993c3c05685ecbd08829ab5bdae7a66045a96eb3b22c50af154393edf7f9b027e91a66d70e10f4d1db67bf8d8b240822
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
@@ -0,0 +1,21 @@
|
|
1
|
+
class ProconBypassMan::BypassMode
|
2
|
+
TYPE_NORMAL = :normal
|
3
|
+
TYPE_AGGRESSIVE = :aggressive
|
4
|
+
TYPES = [TYPE_NORMAL, TYPE_AGGRESSIVE]
|
5
|
+
|
6
|
+
DEFAULT_GADGET_TO_PROCON_INTERVAL = 0.5
|
7
|
+
|
8
|
+
attr_accessor :mode, :gadget_to_procon_interval
|
9
|
+
|
10
|
+
def self.default_value
|
11
|
+
new(
|
12
|
+
mode: TYPE_NORMAL,
|
13
|
+
gadget_to_procon_interval: DEFAULT_GADGET_TO_PROCON_INTERVAL,
|
14
|
+
)
|
15
|
+
end
|
16
|
+
|
17
|
+
def initialize(mode: , gadget_to_procon_interval: )
|
18
|
+
@mode = mode.to_sym
|
19
|
+
@gadget_to_procon_interval = gadget_to_procon_interval
|
20
|
+
end
|
21
|
+
end
|
@@ -27,12 +27,31 @@ class ProconBypassMan::BypassCommand
|
|
27
27
|
monitor1 = ProconBypassMan::IOMonitor.new(label: "switch -> procon")
|
28
28
|
monitor2 = ProconBypassMan::IOMonitor.new(label: "procon -> switch")
|
29
29
|
ProconBypassMan.logger.info "Thread1を起動します"
|
30
|
+
|
31
|
+
@send_interval = 0.005
|
32
|
+
|
30
33
|
t1 = Thread.new do
|
31
|
-
|
34
|
+
timer = ProconBypassMan::SafeTimeout.new(timeout: Time.now + 10)
|
35
|
+
@did_first_step = false
|
32
36
|
loop do
|
37
|
+
bypass = ProconBypassMan::Bypass.new(gadget: @gadget, procon: @procon, monitor: monitor1)
|
33
38
|
break if $will_terminate_token
|
39
|
+
!@did_first_step && timer.throw_if_timeout!
|
34
40
|
bypass.send_gadget_to_procon!
|
35
|
-
sleep(
|
41
|
+
sleep(@send_interval)
|
42
|
+
rescue ProconBypassMan::SafeTimeout::Timeout
|
43
|
+
case ProconBypassMan.config.bypass_mode.mode
|
44
|
+
when ProconBypassMan::BypassMode::TYPE_AGGRESSIVE
|
45
|
+
ProconBypassMan.logger.info "10秒経過したのでThread1を終了します"
|
46
|
+
monitor1.shutdown
|
47
|
+
break
|
48
|
+
when ProconBypassMan::BypassMode::TYPE_NORMAL
|
49
|
+
ProconBypassMan.logger.info "10秒経過したのでsend_intervalを長くします"
|
50
|
+
@send_interval = ProconBypassMan.config.bypass_mode.gadget_to_procon_interval
|
51
|
+
else
|
52
|
+
raise "unknown type"
|
53
|
+
end
|
54
|
+
@did_first_step = true
|
36
55
|
rescue Errno::EIO, Errno::ENODEV, Errno::EPROTO, IOError, Errno::ESHUTDOWN => e
|
37
56
|
ProconBypassMan::SendErrorCommand.execute(error: "Switchとの切断されました.終了処理を開始します. #{e.full_message}")
|
38
57
|
Process.kill "TERM", Process.ppid
|
@@ -65,6 +65,17 @@ class ProconBypassMan::Configuration
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
|
+
def bypass_mode=(value)
|
69
|
+
@bypass_mode = ProconBypassMan::BypassMode.new(
|
70
|
+
mode: value[:mode],
|
71
|
+
gadget_to_procon_interval: value[:gadget_to_procon_interval],
|
72
|
+
)
|
73
|
+
end
|
74
|
+
|
75
|
+
def bypass_mode
|
76
|
+
@bypass_mode || ProconBypassMan::BypassMode.default_value
|
77
|
+
end
|
78
|
+
|
68
79
|
def api_servers=(api_servers)
|
69
80
|
@api_servers = api_servers
|
70
81
|
return self
|
@@ -156,6 +167,10 @@ class ProconBypassMan::Configuration
|
|
156
167
|
end
|
157
168
|
end
|
158
169
|
|
170
|
+
def has_api_server?
|
171
|
+
not api_servers.length.zero?
|
172
|
+
end
|
173
|
+
|
159
174
|
def verbose_bypass_log
|
160
175
|
@verbose_bypass_log || !!ENV["VERBOSE_BYPASS_LOG"]
|
161
176
|
end
|
data/project_template/app.rb
CHANGED
@@ -5,7 +5,7 @@ require 'bundler/inline'
|
|
5
5
|
gemfile do
|
6
6
|
source 'https://rubygems.org'
|
7
7
|
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
8
|
-
gem 'procon_bypass_man', '0.1.20'
|
8
|
+
gem 'procon_bypass_man', '0.1.20.1'
|
9
9
|
end
|
10
10
|
|
11
11
|
ProconBypassMan.configure do |config|
|
@@ -17,6 +17,8 @@ ProconBypassMan.configure do |config|
|
|
17
17
|
config.enable_critical_error_logging = true
|
18
18
|
# pbm-cloudで使う場合はnever_exitにtrueをセットしてください. trueがセットされている場合、不慮の事故が発生してもプロセスが終了しなくなります
|
19
19
|
config.never_exit_accidentally = true
|
20
|
+
# 操作が高頻度で固まるときは、 gadget_to_procon_interval の数値は大きくしてください
|
21
|
+
config.bypass_mode = { mode: :normal, gadget_to_procon_interval: 0.5 }
|
20
22
|
end
|
21
23
|
|
22
24
|
ProconBypassMan.run(setting_path: "/usr/share/pbm/current/setting.yml")
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: procon_bypass_man
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.20
|
4
|
+
version: 0.1.20.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- jiikko
|
@@ -109,6 +109,7 @@ files:
|
|
109
109
|
- lib/procon_bypass_man/buttons_setting_configuration/loader.rb
|
110
110
|
- lib/procon_bypass_man/buttons_setting_configuration/validator.rb
|
111
111
|
- lib/procon_bypass_man/bypass.rb
|
112
|
+
- lib/procon_bypass_man/bypass/bypass_mode.rb
|
112
113
|
- lib/procon_bypass_man/bypass/usb_hid_logger.rb
|
113
114
|
- lib/procon_bypass_man/commands.rb
|
114
115
|
- lib/procon_bypass_man/commands/bypass_command.rb
|