procon_bypass_man 0.3.5 → 0.3.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/.circleci/config.yml +4 -0
  3. data/CHANGELOG.md +10 -3
  4. data/Gemfile +1 -0
  5. data/Gemfile.lock +3 -1
  6. data/Steepfile +0 -1
  7. data/bin/console +3 -0
  8. data/bin/generate_output_report +18 -0
  9. data/bin/validate_external_input +19 -0
  10. data/docs/getting_started.md +5 -0
  11. data/docs/setting/integration_external_input_serial_port.md +56 -0
  12. data/docs/setting/integration_external_input_serial_port_format.md +36 -0
  13. data/lib/procon_bypass_man/background/jobs/post_completed_remote_action_job.rb +20 -0
  14. data/lib/procon_bypass_man/background/jobs/report_info_log_job.rb +11 -0
  15. data/lib/procon_bypass_man/background/jobs/report_procon_performance_measurements_job.rb +1 -0
  16. data/lib/procon_bypass_man/background.rb +1 -0
  17. data/lib/procon_bypass_man/bypass/procon_to_switch.rb +19 -1
  18. data/lib/procon_bypass_man/commands/print_boot_message_command.rb +2 -0
  19. data/lib/procon_bypass_man/commands/send_info_log_command.rb +11 -0
  20. data/lib/procon_bypass_man/commands.rb +1 -0
  21. data/lib/procon_bypass_man/configuration.rb +7 -1
  22. data/lib/procon_bypass_man/external_input/channels/base.rb +12 -0
  23. data/lib/procon_bypass_man/external_input/channels/serial_port_channel.rb +48 -0
  24. data/lib/procon_bypass_man/external_input/channels/tcpip.rb +16 -0
  25. data/lib/procon_bypass_man/external_input/channels.rb +12 -0
  26. data/lib/procon_bypass_man/external_input/external_data.rb +79 -0
  27. data/lib/procon_bypass_man/external_input.rb +35 -0
  28. data/lib/procon_bypass_man/processor.rb +3 -2
  29. data/lib/procon_bypass_man/procon/button_collection.rb +5 -0
  30. data/lib/procon_bypass_man/procon/performance_measurement/measurements_summarizer.rb +4 -0
  31. data/lib/procon_bypass_man/procon/performance_measurement.rb +7 -1
  32. data/lib/procon_bypass_man/procon.rb +38 -12
  33. data/lib/procon_bypass_man/procon_display/status.rb +1 -2
  34. data/lib/procon_bypass_man/procon_display.rb +0 -1
  35. data/lib/procon_bypass_man/{remote_macro → remote_action}/queue_over_process.rb +2 -2
  36. data/lib/procon_bypass_man/{remote_macro/remote_macro_object.rb → remote_action/remote_action_object.rb} +1 -1
  37. data/lib/procon_bypass_man/{remote_macro/remote_macro_receiver.rb → remote_action/remote_action_receiver.rb} +8 -7
  38. data/lib/procon_bypass_man/remote_action/remote_action_sender.rb +9 -0
  39. data/lib/procon_bypass_man/remote_action/remote_pbm_job/base_action.rb +55 -0
  40. data/lib/procon_bypass_man/remote_action/remote_pbm_job/change_pbm_version_action.rb +31 -0
  41. data/lib/procon_bypass_man/remote_action/remote_pbm_job/commands/run_remote_pbm_job_dispatch_command.rb +29 -0
  42. data/lib/procon_bypass_man/{remote_pbm_action/commands/update_remote_pbm_action_status_command.rb → remote_action/remote_pbm_job/commands/update_remote_pbm_job_status_command.rb} +2 -2
  43. data/lib/procon_bypass_man/remote_action/remote_pbm_job/reboot_os_action.rb +24 -0
  44. data/lib/procon_bypass_man/remote_action/remote_pbm_job/report_procon_status.rb +25 -0
  45. data/lib/procon_bypass_man/remote_action/remote_pbm_job/restore_pbm_setting.rb +42 -0
  46. data/lib/procon_bypass_man/remote_action/remote_pbm_job/stop_pbm_action.rb +23 -0
  47. data/lib/procon_bypass_man/{remote_pbm_action/value_objects/remote_pbm_action_object.rb → remote_action/remote_pbm_job/value_objects/remote_pbm_job_object.rb} +2 -2
  48. data/lib/procon_bypass_man/remote_action/remote_pbm_job.rb +45 -0
  49. data/lib/procon_bypass_man/remote_action/task.rb +14 -0
  50. data/lib/procon_bypass_man/{remote_macro → remote_action}/task_queue.rb +1 -1
  51. data/lib/procon_bypass_man/remote_action.rb +19 -0
  52. data/lib/procon_bypass_man/support/callbacks.rb +1 -0
  53. data/lib/procon_bypass_man/support/retryable.rb +4 -2
  54. data/lib/procon_bypass_man/support/{update_remote_pbm_action_status_http_client.rb → update_remote_pbm_job_status_http_client.rb} +1 -1
  55. data/lib/procon_bypass_man/support/web_connectivity_checker.rb +39 -0
  56. data/lib/procon_bypass_man/version.rb +1 -1
  57. data/lib/procon_bypass_man/websocket/client.rb +42 -26
  58. data/lib/procon_bypass_man.rb +12 -8
  59. data/project_template/app.rb +10 -1
  60. data/project_template/app.rb.erb +11 -1
  61. data/sig/main.rbs +0 -6
  62. metadata +34 -20
  63. data/lib/procon_bypass_man/procon_display/bypass_hook.rb +0 -12
  64. data/lib/procon_bypass_man/remote_macro/remote_macro_sender.rb +0 -8
  65. data/lib/procon_bypass_man/remote_macro/task.rb +0 -2
  66. data/lib/procon_bypass_man/remote_macro.rb +0 -16
  67. data/lib/procon_bypass_man/remote_pbm_action/base_action.rb +0 -53
  68. data/lib/procon_bypass_man/remote_pbm_action/change_pbm_version_action.rb +0 -29
  69. data/lib/procon_bypass_man/remote_pbm_action/commands/run_remote_pbm_action_dispatch_command.rb +0 -21
  70. data/lib/procon_bypass_man/remote_pbm_action/reboot_os_action.rb +0 -22
  71. data/lib/procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb +0 -41
  72. data/lib/procon_bypass_man/remote_pbm_action/stop_pbm_action.rb +0 -21
  73. data/lib/procon_bypass_man/remote_pbm_action.rb +0 -36
@@ -59,59 +59,75 @@ module ProconBypassMan
59
59
 
60
60
  # @param [Hash] data
61
61
  def self.dispatch(data: , client: )
62
- pbm_job_hash = data.dig("message")
63
- case pbm_job_hash['action']
62
+ case data.dig("message")['action']
64
63
  when "ping"
65
64
  client.perform('pong', { device_id: ProconBypassMan.device_id, message: 'hello from pbm' })
66
- when ProconBypassMan::RemoteMacro::ACTION_KEY
67
- validate_and_run_remote_macro(data: data)
68
- when *ProconBypassMan::RemotePbmAction::ACTIONS
69
- validate_and_run_remote_pbm_action(data: data)
65
+ when ProconBypassMan::RemoteAction::ACTION_MACRO
66
+ run_remote_macro(data: data)
67
+ when *ProconBypassMan::RemoteAction::RemotePbmJob::ACTIONS_IN_MASTER_PROCESS
68
+ run_remote_pbm_job(data: data, process_to_execute: :master)
69
+ when *ProconBypassMan::RemoteAction::RemotePbmJob::ACTIONS_IN_BYPASS_PROCESS
70
+ run_remote_pbm_job(data: data, process_to_execute: :bypass)
70
71
  else
71
- ProconBypassMan.logger.error "unknown action"
72
+ ProconBypassMan::SendErrorCommand.execute(error: 'unknown remote pbm action')
72
73
  end
73
74
  end
74
75
 
75
- # @raise [ProconBypassMan::RemotePbmActionObject::ValidationError]
76
+ # @raise [ProconBypassMan::RemotePbmJobObject::ValidationError]
76
77
  # @param [Hash] data
78
+ # @param [Symbol] process_to_execute どのプロセスで実行するか
77
79
  # @return [Void]
78
- def self.validate_and_run_remote_pbm_action(data: )
80
+ def self.run_remote_pbm_job(data: , process_to_execute: )
79
81
  pbm_job_hash = data.dig("message")
80
82
  begin
81
- pbm_job_object = ProconBypassMan::RemotePbmActionObject.new(action: pbm_job_hash["action"],
83
+ pbm_job_object = ProconBypassMan::RemotePbmJobObject.new(action: pbm_job_hash["action"],
82
84
  status: pbm_job_hash["status"],
83
85
  uuid: pbm_job_hash["uuid"],
84
86
  created_at: pbm_job_hash["created_at"],
85
87
  job_args: pbm_job_hash["args"])
86
88
  pbm_job_object.validate!
87
- rescue ProconBypassMan::RemotePbmActionObject::ValidationError => e
89
+ rescue ProconBypassMan::RemotePbmJobObject::ValidationError => e
88
90
  ProconBypassMan::SendErrorCommand.execute(error: e)
89
91
  return
90
92
  end
91
93
 
92
- ProconBypassMan::RunRemotePbmActionDispatchCommand.execute(
93
- action: pbm_job_object.action,
94
- uuid: pbm_job_object.uuid,
95
- job_args: pbm_job_object.job_args
96
- )
94
+ case process_to_execute
95
+ when :master
96
+ ProconBypassMan::RemoteAction::RemotePbmJob::RunRemotePbmJobDispatchCommand.execute(
97
+ action: pbm_job_object.action,
98
+ uuid: pbm_job_object.uuid,
99
+ job_args: pbm_job_object.job_args
100
+ )
101
+ when :bypass
102
+ ProconBypassMan::RemoteAction::QueueOverProcess.push(
103
+ ProconBypassMan::RemoteAction::Task.new(pbm_job_object.action,
104
+ pbm_job_object.uuid,
105
+ pbm_job_object.job_args,
106
+ ProconBypassMan::RemoteAction::Task::TYPE_ACTION)
107
+ )
108
+ else
109
+ ProconBypassMan::SendErrorCommand.execute(error: 'unknown process to execute')
110
+ end
97
111
  end
98
112
 
99
- def self.validate_and_run_remote_macro(data: )
113
+ def self.run_remote_macro(data: )
100
114
  pbm_job_hash = data.dig("message")
101
115
  begin
102
- remote_macro_object = ProconBypassMan::RemoteMacro::RemoteMacroObject.new(name: pbm_job_hash["name"],
103
- uuid: pbm_job_hash["uuid"],
104
- steps: pbm_job_hash["steps"])
105
- remote_macro_object.validate!
106
- rescue ProconBypassMan::RemoteMacro::RemoteMacroObject::ValidationError => e
116
+ remote_action_object = ProconBypassMan::RemoteAction::RemoteActionObject.new(name: pbm_job_hash["name"],
117
+ uuid: pbm_job_hash["uuid"],
118
+ steps: pbm_job_hash["steps"])
119
+ remote_action_object.validate!
120
+ rescue ProconBypassMan::RemoteAction::RemoteActionObject::ValidationError => e
107
121
  ProconBypassMan::SendErrorCommand.execute(error: e)
108
122
  return
109
123
  end
110
124
 
111
- ProconBypassMan::RemoteMacroSender.execute(
112
- name: remote_macro_object.name,
113
- uuid: remote_macro_object.uuid,
114
- steps: remote_macro_object.steps,
125
+ # TODO: インラインしたい
126
+ ProconBypassMan::RemoteActionSender.execute(
127
+ name: remote_action_object.name,
128
+ uuid: remote_action_object.uuid,
129
+ steps: remote_action_object.steps,
130
+ type: ProconBypassMan::RemoteAction::Task::TYPE_MACRO,
115
131
  )
116
132
  end
117
133
  end
@@ -1,5 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require 'singleton'
3
4
  require "logger"
4
5
  require 'yaml'
5
6
  require "json"
@@ -31,7 +32,7 @@ require_relative "procon_bypass_man/support/on_memory_cache"
31
32
  require_relative "procon_bypass_man/support/http_client"
32
33
  require_relative "procon_bypass_man/support/report_http_client"
33
34
  require_relative "procon_bypass_man/support/remote_macro_http_client"
34
- require_relative "procon_bypass_man/support/update_remote_pbm_action_status_http_client"
35
+ require_relative "procon_bypass_man/support/update_remote_pbm_job_status_http_client"
35
36
  require_relative "procon_bypass_man/support/send_device_stats_http_client"
36
37
  require_relative "procon_bypass_man/support/procon_performance_http_client"
37
38
  require_relative "procon_bypass_man/support/analog_stick_hypotenuse_tilting_power_scaler"
@@ -40,6 +41,7 @@ require_relative "procon_bypass_man/support/cycle_sleep"
40
41
  require_relative "procon_bypass_man/support/can_over_process"
41
42
  require_relative "procon_bypass_man/support/retryable"
42
43
  require_relative "procon_bypass_man/support/renice_command"
44
+ require_relative "procon_bypass_man/support/web_connectivity_checker"
43
45
  require_relative "procon_bypass_man/procon_display"
44
46
  require_relative "procon_bypass_man/background"
45
47
  require_relative "procon_bypass_man/commands"
@@ -55,16 +57,14 @@ require_relative "procon_bypass_man/device_model"
55
57
  require_relative "procon_bypass_man/procon/button"
56
58
  require_relative "procon_bypass_man/procon/analog_stick_cap"
57
59
  require_relative "procon_bypass_man/procon/analog_stick_manipulator"
58
- require_relative "procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object"
59
60
  require_relative "procon_bypass_man/scheduler"
60
61
  require_relative "procon_bypass_man/plugins"
61
62
  require_relative "procon_bypass_man/worker"
62
63
  require_relative "procon_bypass_man/websocket/client"
63
64
  require_relative "procon_bypass_man/websocket/watchdog"
64
65
  require_relative "procon_bypass_man/websocket/forever"
65
-
66
- require_relative "procon_bypass_man/remote_pbm_action"
67
- require_relative "procon_bypass_man/remote_macro"
66
+ require_relative "procon_bypass_man/external_input"
67
+ require_relative "procon_bypass_man/remote_action"
68
68
 
69
69
  STDOUT.sync = true
70
70
  Thread.abort_on_exception = true
@@ -124,6 +124,8 @@ module ProconBypassMan
124
124
  return
125
125
  end
126
126
 
127
+ ProconBypassMan::ExternalInput.prepare_channels
128
+
127
129
  ready_pbm
128
130
  Runner.new(gadget: gadget, procon: procon).run # ここでblockingする
129
131
  terminate_pbm
@@ -132,6 +134,8 @@ module ProconBypassMan
132
134
  # 実行ファイル(app.rb)から呼び出している
133
135
  # @return [void]
134
136
  def self.configure(&block)
137
+ require_relative "procon_bypass_man/external_input"
138
+
135
139
  @@configuration = ProconBypassMan::Configuration.new
136
140
  @@configuration.instance_eval(&block)
137
141
  nil
@@ -161,7 +165,7 @@ module ProconBypassMan
161
165
  ProconBypassMan::Background::JobQueue.start!
162
166
  ProconBypassMan::Websocket::Client.start!
163
167
  # TODO ProconBypassMan::DrbObjects.start_all! みたいな感じで書きたい
164
- ProconBypassMan::RemoteMacro::QueueOverProcess.start!
168
+ ProconBypassMan::RemoteAction::QueueOverProcess.start!
165
169
  ProconBypassMan::Procon::PerformanceMeasurement::QueueOverProcess.start!
166
170
  ProconBypassMan::Scheduler.start!
167
171
 
@@ -193,7 +197,7 @@ module ProconBypassMan
193
197
  BlueGreenProcess.configure do |config|
194
198
  config.after_fork = -> {
195
199
  DRb.start_service if defined?(DRb)
196
- ProconBypassMan::RemoteMacroReceiver.start!
200
+ ProconBypassMan::RemoteActionReceiver.start!
197
201
  BlueGreenProcess.config.logger = ProconBypassMan.logger
198
202
  }
199
203
  config.shared_variables = [:buttons, :current_layer_key, :recent_left_stick_hypotenuses]
@@ -204,7 +208,7 @@ module ProconBypassMan
204
208
  def self.terminate_pbm
205
209
  FileUtils.rm_rf(ProconBypassMan.pid_path)
206
210
  FileUtils.rm_rf(ProconBypassMan.digest_path)
207
- ProconBypassMan::RemoteMacro::QueueOverProcess.shutdown
211
+ ProconBypassMan::RemoteAction::QueueOverProcess.shutdown
208
212
  ProconBypassMan::Procon::PerformanceMeasurement::QueueOverProcess.shutdown
209
213
  self.worker&.shutdown
210
214
  end
@@ -12,7 +12,11 @@ begin
12
12
  gemfile do
13
13
  source 'https://rubygems.org'
14
14
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
15
- gem 'procon_bypass_man', '0.3.5'
15
+ gem 'procon_bypass_man', '0.3.7'
16
+ # uncomment if you want to use master branch
17
+ # gem 'procon_bypass_man', github: 'splaplapla/procon_bypass_man', branch: 'master'
18
+ # uncomment if you want to use serial communication feature
19
+ # gem "serialport"
16
20
  end
17
21
  rescue Bundler::Source::Git::GitCommandError => e
18
22
  retry_count_on_git_command_error = retry_count_on_git_command_error + 1
@@ -49,6 +53,11 @@ ProconBypassMan.configure do |config|
49
53
 
50
54
  # 接続に成功したらコントローラーのHOME LEDを光らせるか
51
55
  config.enable_home_led_on_connect = true
56
+
57
+ # シリアル通信やTCP/IP経由で入力するときに設定してください
58
+ # config.external_input_channels = [
59
+ # ProconBypassMan::ExternalInput::Channels::SerialPortChannel.new(device_path: '/dev/serial0', baud_rate: 9600),
60
+ # ]
52
61
  end
53
62
 
54
63
  ProconBypassMan.run(setting_path: "/usr/share/pbm/current/setting.yml")
@@ -12,7 +12,11 @@ begin
12
12
  gemfile do
13
13
  source 'https://rubygems.org'
14
14
  git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
15
- gem 'procon_bypass_man', '0.3.5'
15
+ gem 'procon_bypass_man', '0.3.7'
16
+ # uncomment if you want to use master branch
17
+ # gem 'procon_bypass_man', github: 'splaplapla/procon_bypass_man', branch: 'master'
18
+ # uncomment if you want to use serial communication feature
19
+ # gem "serialport"
16
20
  end
17
21
  rescue Bundler::Source::Git::GitCommandError => e
18
22
  retry_count_on_git_command_error = retry_count_on_git_command_error + 1
@@ -54,6 +58,12 @@ ProconBypassMan.configure do |config|
54
58
 
55
59
  # 接続に成功したらコントローラーのHOME LEDを光らせるか
56
60
  config.enable_home_led_on_connect = true
61
+
62
+ # シリアル通信やTCP/IP経由で入力するときに設定してください
63
+ # config.external_input_channels = [
64
+ # ProconBypassMan::ExternalInput::Channels::SerialPortChannel.new(device_path: '/dev/serial0', baud_rate: 9600),
65
+ <%-# ProconBypassMan::ExternalInput::Channels::TCPIP.new(port: 9000), # TODO: まだ実装していない -%>
66
+ # ]
57
67
  end
58
68
 
59
69
  ProconBypassMan.run(setting_path: "/usr/share/pbm/current/setting.yml")
data/sig/main.rbs CHANGED
@@ -613,12 +613,6 @@ module ProconBypassMan
613
613
  end
614
614
  end
615
615
 
616
- module ProconBypassMan
617
- class UpdateRemotePbmActionStatusHttpClient
618
- def post: (to_status: ::Symbol) -> untyped
619
- end
620
- end
621
-
622
616
  module ProconBypassMan
623
617
  class CompressArray
624
618
  @array: [String]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: procon_bypass_man
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - jiikko
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2023-02-09 00:00:00.000000000 Z
11
+ date: 2023-04-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pbmenv
@@ -93,10 +93,14 @@ files:
93
93
  - bin/console
94
94
  - bin/dev_api_server.rb
95
95
  - bin/generate_default_app
96
+ - bin/generate_output_report
96
97
  - bin/setup
98
+ - bin/validate_external_input
97
99
  - docs/getting_started.md
98
100
  - docs/how_to_connect_procon.md
99
101
  - docs/run_pbm_on_my_branch.md
102
+ - docs/setting/integration_external_input_serial_port.md
103
+ - docs/setting/integration_external_input_serial_port_format.md
100
104
  - docs/setting/left-analogstick-cap.md
101
105
  - docs/setting/splatoon2_macro_dasei_cancel.md
102
106
  - docs/setting/splatoon2_macro_forward_ikarole.md
@@ -119,12 +123,14 @@ files:
119
123
  - lib/procon_bypass_man/background/jobs/base_job.rb
120
124
  - lib/procon_bypass_man/background/jobs/concerns/has_external_api_setting.rb
121
125
  - lib/procon_bypass_man/background/jobs/concerns/job_performable.rb
126
+ - lib/procon_bypass_man/background/jobs/post_completed_remote_action_job.rb
122
127
  - lib/procon_bypass_man/background/jobs/post_completed_remote_macro_job.rb
123
128
  - lib/procon_bypass_man/background/jobs/report_boot_job.rb
124
129
  - lib/procon_bypass_man/background/jobs/report_completed_upgrade_pbm_job.rb
125
130
  - lib/procon_bypass_man/background/jobs/report_error_job.rb
126
131
  - lib/procon_bypass_man/background/jobs/report_error_reload_config_job.rb
127
132
  - lib/procon_bypass_man/background/jobs/report_event_base_job.rb
133
+ - lib/procon_bypass_man/background/jobs/report_info_log_job.rb
128
134
  - lib/procon_bypass_man/background/jobs/report_load_config_job.rb
129
135
  - lib/procon_bypass_man/background/jobs/report_procon_performance_measurements_job.rb
130
136
  - lib/procon_bypass_man/background/jobs/report_reload_config_job.rb
@@ -154,6 +160,7 @@ files:
154
160
  - lib/procon_bypass_man/commands/print_boot_message_command.rb
155
161
  - lib/procon_bypass_man/commands/print_message_command.rb
156
162
  - lib/procon_bypass_man/commands/send_error_command.rb
163
+ - lib/procon_bypass_man/commands/send_info_log_command.rb
157
164
  - lib/procon_bypass_man/commands/send_reload_config_event_command.rb
158
165
  - lib/procon_bypass_man/commands/send_warning_command.rb
159
166
  - lib/procon_bypass_man/commands/write_device_id_command.rb
@@ -172,6 +179,12 @@ files:
172
179
  - lib/procon_bypass_man/device_model.rb
173
180
  - lib/procon_bypass_man/device_status.rb
174
181
  - lib/procon_bypass_man/ephemeral_configuration.rb
182
+ - lib/procon_bypass_man/external_input.rb
183
+ - lib/procon_bypass_man/external_input/channels.rb
184
+ - lib/procon_bypass_man/external_input/channels/base.rb
185
+ - lib/procon_bypass_man/external_input/channels/serial_port_channel.rb
186
+ - lib/procon_bypass_man/external_input/channels/tcpip.rb
187
+ - lib/procon_bypass_man/external_input/external_data.rb
175
188
  - lib/procon_bypass_man/plugin/splatoon2/macro/charge_tansan_bomb.rb
176
189
  - lib/procon_bypass_man/plugin/splatoon2/macro/dasei_cancel.rb
177
190
  - lib/procon_bypass_man/plugin/splatoon2/macro/fast_return.rb
@@ -232,28 +245,28 @@ files:
232
245
  - lib/procon_bypass_man/procon/value_objects/procon_reader.rb
233
246
  - lib/procon_bypass_man/procon/value_objects/rumble_binary.rb
234
247
  - lib/procon_bypass_man/procon_display.rb
235
- - lib/procon_bypass_man/procon_display/bypass_hook.rb
236
248
  - lib/procon_bypass_man/procon_display/http_request.rb
237
249
  - lib/procon_bypass_man/procon_display/http_response.rb
238
250
  - lib/procon_bypass_man/procon_display/server.rb
239
251
  - lib/procon_bypass_man/procon_display/server_app.rb
240
252
  - lib/procon_bypass_man/procon_display/status.rb
241
- - lib/procon_bypass_man/remote_macro.rb
242
- - lib/procon_bypass_man/remote_macro/queue_over_process.rb
243
- - lib/procon_bypass_man/remote_macro/remote_macro_object.rb
244
- - lib/procon_bypass_man/remote_macro/remote_macro_receiver.rb
245
- - lib/procon_bypass_man/remote_macro/remote_macro_sender.rb
246
- - lib/procon_bypass_man/remote_macro/task.rb
247
- - lib/procon_bypass_man/remote_macro/task_queue.rb
248
- - lib/procon_bypass_man/remote_pbm_action.rb
249
- - lib/procon_bypass_man/remote_pbm_action/base_action.rb
250
- - lib/procon_bypass_man/remote_pbm_action/change_pbm_version_action.rb
251
- - lib/procon_bypass_man/remote_pbm_action/commands/run_remote_pbm_action_dispatch_command.rb
252
- - lib/procon_bypass_man/remote_pbm_action/commands/update_remote_pbm_action_status_command.rb
253
- - lib/procon_bypass_man/remote_pbm_action/reboot_os_action.rb
254
- - lib/procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb
255
- - lib/procon_bypass_man/remote_pbm_action/stop_pbm_action.rb
256
- - lib/procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object.rb
253
+ - lib/procon_bypass_man/remote_action.rb
254
+ - lib/procon_bypass_man/remote_action/queue_over_process.rb
255
+ - lib/procon_bypass_man/remote_action/remote_action_object.rb
256
+ - lib/procon_bypass_man/remote_action/remote_action_receiver.rb
257
+ - lib/procon_bypass_man/remote_action/remote_action_sender.rb
258
+ - lib/procon_bypass_man/remote_action/remote_pbm_job.rb
259
+ - lib/procon_bypass_man/remote_action/remote_pbm_job/base_action.rb
260
+ - lib/procon_bypass_man/remote_action/remote_pbm_job/change_pbm_version_action.rb
261
+ - lib/procon_bypass_man/remote_action/remote_pbm_job/commands/run_remote_pbm_job_dispatch_command.rb
262
+ - lib/procon_bypass_man/remote_action/remote_pbm_job/commands/update_remote_pbm_job_status_command.rb
263
+ - lib/procon_bypass_man/remote_action/remote_pbm_job/reboot_os_action.rb
264
+ - lib/procon_bypass_man/remote_action/remote_pbm_job/report_procon_status.rb
265
+ - lib/procon_bypass_man/remote_action/remote_pbm_job/restore_pbm_setting.rb
266
+ - lib/procon_bypass_man/remote_action/remote_pbm_job/stop_pbm_action.rb
267
+ - lib/procon_bypass_man/remote_action/remote_pbm_job/value_objects/remote_pbm_job_object.rb
268
+ - lib/procon_bypass_man/remote_action/task.rb
269
+ - lib/procon_bypass_man/remote_action/task_queue.rb
257
270
  - lib/procon_bypass_man/runner.rb
258
271
  - lib/procon_bypass_man/scheduler.rb
259
272
  - lib/procon_bypass_man/support/analog_stick_hypotenuse_tilting_power_scaler.rb
@@ -274,9 +287,10 @@ files:
274
287
  - lib/procon_bypass_man/support/retryable.rb
275
288
  - lib/procon_bypass_man/support/safe_timeout.rb
276
289
  - lib/procon_bypass_man/support/send_device_stats_http_client.rb
277
- - lib/procon_bypass_man/support/update_remote_pbm_action_status_http_client.rb
290
+ - lib/procon_bypass_man/support/update_remote_pbm_job_status_http_client.rb
278
291
  - lib/procon_bypass_man/support/uptime.rb
279
292
  - lib/procon_bypass_man/support/usb_device_controller.rb
293
+ - lib/procon_bypass_man/support/web_connectivity_checker.rb
280
294
  - lib/procon_bypass_man/support/yaml_loader.rb
281
295
  - lib/procon_bypass_man/support/yaml_writer.rb
282
296
  - lib/procon_bypass_man/version.rb
@@ -1,12 +0,0 @@
1
- module ProconBypassMan::ProconDisplay::BypassHook
2
- include ProconBypassMan::Callbacks
3
-
4
- define_callbacks :run
5
-
6
- set_callback :run, :after, :write_procon_display_status
7
-
8
- def write_procon_display_status
9
- return unless bypass_value.binary
10
- ProconBypassMan::ProconDisplay::Status.instance.current = bypass_value.binary.to_procon_reader.to_hash.dup
11
- end
12
- end
@@ -1,8 +0,0 @@
1
- class ProconBypassMan::RemoteMacroSender
2
- def self.execute(name: , uuid: , steps: )
3
- ProconBypassMan.logger.info "[remote macro][sender] name: #{name}, uuid: #{uuid}, steps: #{steps}"
4
- ProconBypassMan::RemoteMacro::QueueOverProcess.push(
5
- ProconBypassMan::RemoteMacro::Task.new(name, uuid, steps)
6
- )
7
- end
8
- end
@@ -1,2 +0,0 @@
1
- class ProconBypassMan::RemoteMacro::Task < ::Struct.new(:name, :uuid, :steps)
2
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ProconBypassMan
4
- module RemoteMacro
5
- require "procon_bypass_man/remote_macro/remote_macro_object"
6
- require "procon_bypass_man/remote_macro/remote_macro_receiver"
7
- require "procon_bypass_man/remote_macro/remote_macro_sender"
8
- require "procon_bypass_man/remote_macro/queue_over_process"
9
- require "procon_bypass_man/remote_macro/task"
10
- require "procon_bypass_man/remote_macro/task_queue"
11
-
12
- ACTION_KEY = "remote_macro"
13
-
14
- TaskQueueInProcess = ProconBypassMan::RemoteMacro::TaskQueue.new
15
- end
16
- end
@@ -1,53 +0,0 @@
1
- module ProconBypassMan
2
- module RemotePbmAction
3
- class ActionUnexpectedError < StandardError; end
4
- class NeedPbmVersionError < ActionUnexpectedError; end
5
-
6
- class BaseAction
7
- attr_accessor :pbm_job_uuid
8
-
9
- # @param [String] pbm_job_uuid
10
- def initialize(pbm_job_uuid: )
11
- self.pbm_job_uuid = pbm_job_uuid
12
- end
13
-
14
- # @return [void]
15
- def action_content(_args)
16
- raise NotImplementedError, nil
17
- end
18
-
19
- # @param [Hash] args
20
- # @return [void]
21
- def run!(job_args: )
22
- before_action_callback
23
- action_content(args: job_args)
24
- after_action_callback
25
- rescue => e
26
- be_failed
27
- ProconBypassMan::SendErrorCommand.execute(error: e)
28
- end
29
-
30
- private
31
-
32
- # @return [void]
33
- def before_action_callback; end
34
- # @return [void]
35
- def after_action_callback; end
36
-
37
- # @return [void]
38
- def be_failed
39
- ProconBypassMan::UpdateRemotePbmActionStatusCommand.new(pbm_job_uuid: pbm_job_uuid).execute(to_status: :failed)
40
- end
41
-
42
- # @return [void]
43
- def be_in_progress
44
- ProconBypassMan::UpdateRemotePbmActionStatusCommand.new(pbm_job_uuid: pbm_job_uuid).execute(to_status: :in_progress)
45
- end
46
-
47
- # @return [void]
48
- def be_processed
49
- ProconBypassMan::UpdateRemotePbmActionStatusCommand.new(pbm_job_uuid: pbm_job_uuid).execute(to_status: :processed)
50
- end
51
- end
52
- end
53
- end
@@ -1,29 +0,0 @@
1
- module ProconBypassMan
2
- module RemotePbmAction
3
- class ChangePbmVersionAction < BaseAction
4
-
5
- def action_content(args: )
6
- require "pbmenv"
7
- ProconBypassMan.logger.info "execute ChangePbmVersionAction!"
8
- pbm_version = args["pbm_version"] or raise(ProconBypassMan::RemotePbmAction::NeedPbmVersionError, "pbm_versionが必要です, #{args.inspect}")
9
- Pbmenv.uninstall(pbm_version) # 途中でシャットダウンしてしまった、とか状態が途中の状態かもしれないので一旦消す
10
- Pbmenv.install(pbm_version, enable_pbm_cloud: true)
11
- Pbmenv.use(pbm_version)
12
- Pbmenv.clean(10)
13
- ProconBypassMan.logger.info "#{pbm_version}へアップグレードしました"
14
- ProconBypassMan::ReportCompletedUpgradePbmJob.perform
15
- `reboot` # symlinkの参照先が変わるのでrebootする必要がある
16
- end
17
-
18
- private
19
-
20
- def before_action_callback
21
- be_processed
22
- end
23
-
24
- def after_action_callback
25
- # no-op
26
- end
27
- end
28
- end
29
- end
@@ -1,21 +0,0 @@
1
- class ProconBypassMan::RunRemotePbmActionDispatchCommand
2
- # @param [String] action
3
- # @param [String] uuid
4
- # @return [void]
5
- def self.execute(action: , uuid: , job_args: )
6
- case action
7
- when ProconBypassMan::RemotePbmAction::ACTION_CHANGE_PBM_VERSION
8
- ProconBypassMan::RemotePbmAction::ChangePbmVersionAction.new(pbm_job_uuid: uuid).run!(job_args: job_args)
9
- when ProconBypassMan::RemotePbmAction::ACTION_STOP_PBM
10
- ProconBypassMan::RemotePbmAction::StopPbmAction.new(pbm_job_uuid: uuid).run!(job_args: {})
11
- when ProconBypassMan::RemotePbmAction::ACTION_REBOOT_OS
12
- ProconBypassMan::RemotePbmAction::RebootOsAction.new(pbm_job_uuid: uuid).run!(job_args: {})
13
- when ProconBypassMan::RemotePbmAction::ACTION_RESTORE_SETTING
14
- ProconBypassMan::RemotePbmAction::RestorePbmSettingAction.new(pbm_job_uuid: uuid).run!(job_args: job_args)
15
- else
16
- raise "#{action}は対応していないアクションです"
17
- end
18
- rescue ProconBypassMan::RemotePbmAction::ActionUnexpectedError => e
19
- ProconBypassMan::SendErrorCommand.execute(error: e)
20
- end
21
- end
@@ -1,22 +0,0 @@
1
- module ProconBypassMan
2
- module RemotePbmAction
3
- class RebootOsAction < BaseAction
4
-
5
- def action_content(_args)
6
- ProconBypassMan.logger.info "execute RebootOsAction!"
7
- `reboot`
8
- end
9
-
10
- private
11
-
12
- def before_action_callback
13
- ProconBypassMan::ReportStartRebootJob.perform
14
- be_processed
15
- end
16
-
17
- def after_action_callback
18
- # no-op
19
- end
20
- end
21
- end
22
- end
@@ -1,41 +0,0 @@
1
- module ProconBypassMan
2
- module RemotePbmAction
3
- class RestorePbmSettingAction < BaseAction
4
-
5
- def action_content(args: )
6
- require "pbmenv"
7
- ProconBypassMan.logger.info "execute RestorePbmSettingAction!"
8
- setting = args.dig("setting") or raise(ProconBypassMan::RemotePbmAction::NeedPbmVersionError, "settingが必要です, #{args.inspect}")
9
-
10
- # 復元に失敗したら戻せるように退避する
11
- FileUtils.copy(
12
- ProconBypassMan::ButtonsSettingConfiguration.instance.setting_path,
13
- ProconBypassMan.fallback_setting_path,
14
- )
15
-
16
- ProconBypassMan::YamlWriter.write(
17
- path: ProconBypassMan::ButtonsSettingConfiguration.instance.setting_path,
18
- content: setting,
19
- )
20
-
21
- hot_reload!
22
- end
23
-
24
- private
25
-
26
- def before_action_callback
27
- be_in_progress
28
- end
29
-
30
- def after_action_callback
31
- be_processed
32
- end
33
-
34
- # @return [void]
35
- def hot_reload!
36
- Process.kill(:USR2, ProconBypassMan.pid)
37
- end
38
- end
39
- end
40
- end
41
-
@@ -1,21 +0,0 @@
1
- module ProconBypassMan
2
- module RemotePbmAction
3
- class StopPbmAction < BaseAction
4
-
5
- def action_content(_args)
6
- ProconBypassMan.logger.info "execute StopPbmAction!"
7
- Process.kill("TERM", ProconBypassMan.pid)
8
- end
9
-
10
- private
11
-
12
- def before_action_callback
13
- be_processed
14
- end
15
-
16
- def after_action_callback
17
- # no-op
18
- end
19
- end
20
- end
21
- end
@@ -1,36 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module ProconBypassMan
4
- module RemotePbmAction
5
- require "procon_bypass_man/remote_pbm_action/base_action"
6
- require "procon_bypass_man/remote_pbm_action/change_pbm_version_action"
7
- require "procon_bypass_man/remote_pbm_action/reboot_os_action"
8
- require "procon_bypass_man/remote_pbm_action/stop_pbm_action"
9
- require "procon_bypass_man/remote_pbm_action/restore_pbm_setting.rb"
10
- require "procon_bypass_man/remote_pbm_action/commands/update_remote_pbm_action_status_command"
11
- require "procon_bypass_man/remote_pbm_action/commands/run_remote_pbm_action_dispatch_command"
12
- require "procon_bypass_man/remote_pbm_action/value_objects/remote_pbm_action_object"
13
-
14
- ACTION_CHANGE_PBM_VERSION = "change_pbm_version"
15
- ACTION_REBOOT_OS = "reboot_os"
16
- ACTION_STOP_PBM = "stop_pbm"
17
- ACTION_RESTORE_SETTING = "restore_pbm_setting"
18
-
19
- ACTIONS = [
20
- ACTION_CHANGE_PBM_VERSION,
21
- ACTION_REBOOT_OS,
22
- ACTION_STOP_PBM,
23
- ACTION_RESTORE_SETTING,
24
- ]
25
-
26
- STATUS_FAILED = :failed
27
- STATUS_IN_PROGRESS = :in_progress
28
- STATUS_PROCESSED = :processed
29
-
30
- ACTION_STATUSES = [
31
- STATUS_FAILED,
32
- STATUS_IN_PROGRESS,
33
- STATUS_PROCESSED,
34
- ]
35
- end
36
- end