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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1ce5a36623cb9c5ec02d78df78f1c50d8b6f23f54cedf4297bfe76d122def428
4
- data.tar.gz: 6d459721f4dcbf4bde02c62e1ffb0aba296a39718e95d7cb5bbbbc6d27c845a3
3
+ metadata.gz: 29c989ae104586849ff797f9086b997294925372a2997797da279c6b2178098a
4
+ data.tar.gz: d23be38b1c10f9f856407fa65db924e4f8528d453c5fe59f8bdc0832dc3e93f0
5
5
  SHA512:
6
- metadata.gz: 3a15285db88ece865db72a73d94f8f5dceff3958bc1fccd6422e5b63441e9c9f6238d080883220b934b14bd5d7a25ce0509cce00ca2995e7385dce90c8297584
7
- data.tar.gz: f4cbd2665d0733016eb2311b95578360a6f111f847f32bf79a798b215d0e0a59d914fe743b4fd9c3fdeedb8e2d4fefdd3fc442de4c9c285fad7cf56f6a708b5a
6
+ metadata.gz: 53a8875027f7b2e172bbb1873d1b76ff7ec191531e36c43dd044cc26e9bb54c80c2e1c9b63e5c9c0ec9f42829fd502f3cdbd9ac2ba41862c7835b97c8d3b66ac
7
+ data.tar.gz: 5476c22c2648861968b08ace121eef62993c3c05685ecbd08829ab5bdae7a66045a96eb3b22c50af154393edf7f9b027e91a66d70e10f4d1db67bf8d8b240822
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## [0.1.20.1] - 2022-02-13
2
+ - Switchからプロコンへ送信するバイパスのインターバルを設定できるようにしました(切断対策)
3
+
1
4
  ## [0.1.20] - 2022-02-13
2
5
  - pbm-cloudから再起動・設定ファイルの適用指示があったときにackイベントを返すようになりました
3
6
  - 起動オプションにnever_exit_accidentallyを追加しました。これを有効にすると想定外のエラーが起きたときにプロセスが停止しなくなります。デフォルトで無効です。
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- procon_bypass_man (0.1.20)
4
+ procon_bypass_man (0.1.20.1)
5
5
  action_cable_client
6
6
  pbmenv
7
7
  sorted_set
@@ -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
@@ -1,4 +1,5 @@
1
1
  require "procon_bypass_man/bypass/usb_hid_logger"
2
+ require "procon_bypass_man/bypass/bypass_mode"
2
3
 
3
4
  class ProconBypassMan::Bypass
4
5
  include ProconBypassMan::Bypass::UsbHidLogger
@@ -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
- bypass = ProconBypassMan::Bypass.new(gadget: @gadget, procon: @procon, monitor: monitor1)
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(0.02)
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
@@ -74,7 +74,7 @@ module ProconBypassMan
74
74
  args: [->{ ProconBypassMan::DeviceStatus.current }],
75
75
  interval: 60,
76
76
  )
77
- )
77
+ ) if ProconBypassMan.config.has_api_server?
78
78
  end
79
79
 
80
80
  # @param [Schedule] schedule
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module ProconBypassMan
4
- VERSION = "0.1.20"
4
+ VERSION = "0.1.20.1"
5
5
  end
@@ -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