Module: ProconBypassMan
- Extended by:
- Configuration::ClassMethods
- Defined in:
- lib/procon_bypass_man/plugin/splatoon3/macro/sokuwari_for_splash_bomb.rb,
lib/procon_bypass_man.rb,
lib/procon_bypass_man/worker.rb,
lib/procon_bypass_man/plugins.rb,
lib/procon_bypass_man/version.rb,
lib/procon_bypass_man/scheduler.rb,
lib/procon_bypass_man/remote_action.rb,
lib/procon_bypass_man/external_input.rb,
lib/procon_bypass_man/support/uptime.rb,
lib/procon_bypass_man/support/forever.rb,
lib/procon_bypass_man/support/load_agv.rb,
lib/procon_bypass_man/support/watchdog.rb,
lib/procon_bypass_man/websocket/client.rb,
lib/procon_bypass_man/support/callbacks.rb,
lib/procon_bypass_man/support/retryable.rb,
lib/procon_bypass_man/support/http_client.rb,
lib/procon_bypass_man/support/safe_timeout.rb,
lib/procon_bypass_man/support/compress_array.rb,
lib/procon_bypass_man/support/renice_command.rb,
lib/procon_bypass_man/external_input/channels.rb,
lib/procon_bypass_man/procon/macro_plugin_map.rb,
lib/procon_bypass_man/plugin/splatoon2/version.rb,
lib/procon_bypass_man/plugin/splatoon3/version.rb,
lib/procon_bypass_man/support/report_http_client.rb,
lib/procon_bypass_man/external_input/boot_message.rb,
lib/procon_bypass_man/procon/value_objects/binary.rb,
lib/procon_bypass_man/external_input/channels/base.rb,
lib/procon_bypass_man/external_input/external_data.rb,
lib/procon_bypass_man/remote_action/remote_pbm_job.rb,
lib/procon_bypass_man/buttons_setting_configuration.rb,
lib/procon_bypass_man/plugin/splatoon2/mode/guruguru.rb,
lib/procon_bypass_man/plugin/splatoon3/mode/guruguru.rb,
lib/procon_bypass_man/support/never_exit_accidentally.rb,
lib/procon_bypass_man/support/remote_macro_http_client.rb,
lib/procon_bypass_man/plugin/splatoon2/macro/fast_return.rb,
lib/procon_bypass_man/plugin/splatoon3/macro/fast_return.rb,
lib/procon_bypass_man/procon/value_objects/procon_reader.rb,
lib/procon_bypass_man/buttons_setting_configuration/layer.rb,
lib/procon_bypass_man/plugin/splatoon2/macro/dasei_cancel.rb,
lib/procon_bypass_man/plugin/splatoon3/macro/dasei_cancel.rb,
lib/procon_bypass_man/buttons_setting_configuration/loader.rb,
lib/procon_bypass_man/external_input/channels/tcpip_channel.rb,
lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_up_key.rb,
lib/procon_bypass_man/plugin/splatoon3/macro/jump_to_up_key.rb,
lib/procon_bypass_man/support/send_device_stats_http_client.rb,
lib/procon_bypass_man/plugin/splatoon2/macro/forward_ikarole.rb,
lib/procon_bypass_man/plugin/splatoon3/macro/forward_ikarole.rb,
lib/procon_bypass_man/support/procon_performance_http_client.rb,
lib/procon_bypass_man/buttons_setting_configuration/validator.rb,
lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_left_key.rb,
lib/procon_bypass_man/plugin/splatoon3/macro/jump_to_left_key.rb,
lib/procon_bypass_man/background/jobs/concerns/job_performable.rb,
lib/procon_bypass_man/plugin/splatoon2/macro/jump_to_right_key.rb,
lib/procon_bypass_man/plugin/splatoon3/macro/jump_to_right_key.rb,
lib/procon_bypass_man/remote_action/remote_pbm_job/base_action.rb,
lib/procon_bypass_man/plugin/splatoon2/macro/charge_tansan_bomb.rb,
lib/procon_bypass_man/plugin/splatoon3/macro/charge_tansan_bomb.rb,
lib/procon_bypass_man/plugin/splatoon3/macro/rotation_left_stick.rb,
lib/procon_bypass_man/external_input/channels/serial_port_channel.rb,
lib/procon_bypass_man/remote_action/remote_pbm_job/stop_pbm_action.rb,
lib/procon_bypass_man/buttons_setting_configuration/metadata_loader.rb,
lib/procon_bypass_man/remote_action/remote_pbm_job/reboot_os_action.rb,
lib/procon_bypass_man/buttons_setting_configuration/param_normalizer.rb,
lib/procon_bypass_man/plugin/splatoon2/macro/sokuwari_for_splash_bomb.rb,
lib/procon_bypass_man/remote_action/remote_pbm_job/restore_pbm_setting.rb,
lib/procon_bypass_man/support/update_remote_pbm_job_status_http_client.rb,
lib/procon_bypass_man/remote_action/remote_pbm_job/report_procon_status.rb,
lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/button.rb,
lib/procon_bypass_man/remote_action/remote_pbm_job/change_pbm_version_action.rb,
lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/if_pressed.rb,
lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/button_list.rb,
lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/force_neutral.rb,
lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/flip_if_pressed.rb,
lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/open_macro_steps.rb,
lib/procon_bypass_man/remote_action/remote_pbm_job/value_objects/remote_pbm_job_object.rb,
lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/if_pressed_allows_nil.rb,
lib/procon_bypass_man/buttons_setting_configuration/param_normalizer/disable_macro_if_pressed.rb,
lib/procon_bypass_man/remote_action/remote_pbm_job/commands/run_remote_pbm_job_dispatch_command.rb,
lib/procon_bypass_man/remote_action/remote_pbm_job/commands/update_remote_pbm_job_status_command.rb
Overview
3にはないので削除予定
Defined Under Namespace
Modules: Background, Bypass, Callbacks, CallbacksRegisterable, CanOverProcess, DeviceConnection, Domains, ExternalInput, HasExternalApiSetting, NeverExitAccidentally, Plugin, ProconDisplay, RemoteAction, Websocket Classes: AnalogStickPosition, AnalogStickTiltingPowerScaler, BaseJob, ButtonsSettingConfiguration, BypassCommand, BypassMode, CompressArray, Configuration, CouldNotLoadConfigError, CycleSleep, DeviceModel, DeviceMouseFinder, DeviceProconFinder, DeviceStatus, EphemeralConfiguration, Forever, HttpClient, InterruptForRestart, LoadAgv, NotFoundProconError, OnMemoryCache, PostCompletedRemoteActionJob, PostCompletedRemoteMacroJob, PressButtonAware, PrintBootMessageCommand, PrintMessageCommand, ProcessChecker, Processor, Procon, ProconPerformanceHttpClient, ProconPerformanceSpanTransferJob, ProconReader, RemoteActionReceiver, RemoteActionSender, RemoteMacroHttpClient, RemotePbmJobObject, ReniceCommand, ReportBootJob, ReportCompletedUpgradePbmJob, ReportErrorJob, ReportErrorReloadConfigJob, ReportEventBaseJob, ReportHttpClient, ReportInfoLogJob, ReportLoadConfigJob, ReportProconPerformanceMeasurementsJob, ReportReloadConfigJob, ReportStartRebootJob, ReportWarningJob, Retryable, RumbleBinary, Runner, SafeTimeout, Scheduler, SendDeviceStatsHttpClient, SendErrorCommand, SendInfoLogCommand, SendReloadConfigEventCommand, SendWarningCommand, SuppressRumble, SyncDeviceStatsJob, UpdateRemotePbmJobStatusCommand, UpdateRemotePbmJobStatusHttpClient, Uptime, UsbDeviceController, Watchdog, WebConnectivityChecker, Worker, WriteDeviceIdCommand, WriteSessionIdCommand, YamlLoader, YamlWriter
Constant Summary collapse
- VERSION =
"0.3.12"
Class Attribute Summary collapse
-
.worker ⇒ Object
Returns the value of attribute worker.
Class Method Summary collapse
-
.buttons_setting_configuration ⇒ Object
NOTE: setting.ymlから読み込んだボタンに関する値を管理する.
- .buttons_setting_configuration=(instance) ⇒ Object
-
.config ⇒ ProconBypassMan::Configuration
NOTE: app.rbみたいな実行ファイルに書き込まれている設定を管理する.
-
.configure(&block) ⇒ void
実行ファイル(app.rb)から呼び出している.
-
.ephemeral_config ⇒ ProconBypassMan::EphemeralConfiguration
NOTE: setting.ymlから読み込んだ一部の値を管理する.
- .eternal_sleep ⇒ void
- .initialize_pbm ⇒ void
- .ready_pbm ⇒ void
- .run(setting_path: nil) ⇒ void
- .run_on_after_fork_of_bypass_process ⇒ void
- .terminate_pbm ⇒ void
Methods included from Configuration::ClassMethods
cache, device_id, digest_path, error_logger, fallback_setting_path, logger, never_exit_accidentally, pid, pid_path, root, session_id
Class Attribute Details
.worker ⇒ Object
Returns the value of attribute worker.
86 87 88 |
# File 'lib/procon_bypass_man.rb', line 86 def worker @worker end |
Class Method Details
.buttons_setting_configuration ⇒ Object
NOTE: setting.ymlから読み込んだボタンに関する値を管理する
168 169 170 |
# File 'lib/procon_bypass_man.rb', line 168 def self. @@buttons_setting_configuration ||= ProconBypassMan::ButtonsSettingConfiguration.new end |
.buttons_setting_configuration=(instance) ⇒ Object
172 173 174 |
# File 'lib/procon_bypass_man.rb', line 172 def self.(instance) @@buttons_setting_configuration = instance end |
.config ⇒ ProconBypassMan::Configuration
NOTE: app.rbみたいな実行ファイルに書き込まれている設定を管理する
157 158 159 |
# File 'lib/procon_bypass_man.rb', line 157 def self.config @@configuration ||= ProconBypassMan::Configuration.new end |
.configure(&block) ⇒ void
This method returns an undefined value.
実行ファイル(app.rb)から呼び出している
147 148 149 150 151 152 153 |
# File 'lib/procon_bypass_man.rb', line 147 def self.configure(&block) require_relative "procon_bypass_man/external_input" @@configuration = ProconBypassMan::Configuration.new @@configuration.instance_eval(&block) nil end |
.ephemeral_config ⇒ ProconBypassMan::EphemeralConfiguration
NOTE: setting.ymlから読み込んだ一部の値を管理する
163 164 165 |
# File 'lib/procon_bypass_man.rb', line 163 def self.ephemeral_config @@ephemeral_configuration ||= ProconBypassMan::EphemeralConfiguration.new end |
.eternal_sleep ⇒ void
This method returns an undefined value.
238 239 240 |
# File 'lib/procon_bypass_man.rb', line 238 def self.eternal_sleep sleep(999999999) end |
.initialize_pbm ⇒ void
This method returns an undefined value.
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 |
# File 'lib/procon_bypass_man.rb', line 177 def self.initialize_pbm if ProconBypassMan.pid && ProconBypassMan::ProcessChecker.running?(ProconBypassMan.pid) ProconBypassMan::SendErrorCommand.execute(error: "別のプロセスでPBMがすでに起動中なので処理を停止します。") raise 'テスト実行中でここに入ると調査が面倒なのでエラーにします' if ENV['PBM_ENV'] == 'test' exit 1 end ProconBypassMan::ReniceCommand.change_priority(to: :low, pid: $$) ProconBypassMan::Background::JobQueue.start! ProconBypassMan::Websocket::Client.start! # TODO ProconBypassMan::DrbObjects.start_all! みたいな感じで書きたい ProconBypassMan::RemoteAction::QueueOverProcess.start! ProconBypassMan::Procon::PerformanceMeasurement::QueueOverProcess.start! ProconBypassMan::Scheduler.start! ProconBypassMan::WriteDeviceIdCommand.execute ProconBypassMan::WriteSessionIdCommand.execute File.write(pid_path, $$) ProconBypassMan::DeviceStatus.change_to_running! end |
.ready_pbm ⇒ void
This method returns an undefined value.
199 200 201 202 203 204 |
# File 'lib/procon_bypass_man.rb', line 199 def self.ready_pbm ProconBypassMan::PrintBootMessageCommand.execute ProconBypassMan::ReportLoadConfigJob.perform_async(ProconBypassMan.config.raw_setting) self.worker = ProconBypassMan::Worker.run end |
.run(setting_path: nil) ⇒ void
This method returns an undefined value.
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
# File 'lib/procon_bypass_man.rb', line 90 def self.run(setting_path: nil) ProconBypassMan::PrintMessageCommand.execute(text: "PBMを起動しています") initialize_pbm # 設定ファイルの読み込み begin ProconBypassMan::ButtonsSettingConfiguration::Loader.load(setting_path: setting_path) rescue ProconBypassMan::CouldNotLoadConfigError ProconBypassMan::SendErrorCommand.execute(error: "設定ファイルが不正です。設定ファイルの読み込みに失敗しました") ProconBypassMan::DeviceStatus.change_to_setting_syntax_error_and_shutdown! # TODO シグナルトラップをしていないのでUSR2を送ったときにプロセスが停止している. 明示的にハンドリングするべき. ProconBypassMan::NeverExitAccidentally.exit_if_allow_at_config do terminate_pbm end return end # デバイスの接続フェーズ begin gadget, procon = ProconBypassMan::DeviceConnection::Command.execute! rescue ProconBypassMan::DeviceConnection::SetupIncompleteError ProconBypassMan::SendErrorCommand.execute(error: "The program is terminating because it encountered a request for the sudo password. Please review your sudo settings.", stdout: true) ProconBypassMan::DeviceStatus.change_to_procon_not_found_error! # NOTE: procon_not_found_errorではないけど、めんどいのでこのステータスにする ProconBypassMan::NeverExitAccidentally.exit_if_allow_at_config do terminate_pbm end return rescue ProconBypassMan::DeviceConnection::NotFoundProconError ProconBypassMan::SendErrorCommand.execute(error: "プロコンが見つかりませんでした。") ProconBypassMan::DeviceStatus.change_to_procon_not_found_error! # TODO シグナルトラップをしていないので以下の状態に、USR2を送ったときにプロセスが停止してしまう ProconBypassMan::NeverExitAccidentally.exit_if_allow_at_config do terminate_pbm end return rescue ProconBypassMan::DeviceConnection::TimeoutError ProconBypassMan::SendErrorCommand.execute(error: "接続に失敗しました。プロコンとRaspberry Piのケーブルを差し直して、再実行してください。\n改善しない場合は、app.logの中身を添えて不具合報告をお願いします。") ProconBypassMan::DeviceStatus.change_to_connected_but_sleeping! FileUtils.rm_rf(ProconBypassMan.pid_path) # NOTE: この状態になったときに手動で起動できるようにする(多重起動禁止回避) %w(TERM INT).each do |sig| Kernel.trap(sig) { exit 0 } end Kernel.trap :USR2 do exit 0 # TODO retryする end eternal_sleep return end ready_pbm Runner.new(gadget: gadget, procon: procon).run # ここでblockingする terminate_pbm end |
.run_on_after_fork_of_bypass_process ⇒ void
This method returns an undefined value.
207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 |
# File 'lib/procon_bypass_man.rb', line 207 def self.run_on_after_fork_of_bypass_process ProconBypassMan::ReniceCommand.change_priority(to: :high, pid: $$) ::GC.start # GC対策することによって一時的に削除した機能. 後で有効にしたい # ProconBypassMan::ProconDisplay::Server.start! DRb.start_service if defined?(DRb) # for libs setting BlueGreenProcess.config.logger = ProconBypassMan.logger BlueGreenProcess.configure do |config| config.after_fork = -> { DRb.start_service if defined?(DRb) ProconBypassMan::RemoteActionReceiver.start! BlueGreenProcess.config.logger = ProconBypassMan.logger } config.shared_variables = [:buttons, :current_layer_key, :recent_left_stick_hypotenuses] end end |
.terminate_pbm ⇒ void
This method returns an undefined value.
228 229 230 231 232 233 234 235 |
# File 'lib/procon_bypass_man.rb', line 228 def self.terminate_pbm FileUtils.rm_rf(ProconBypassMan.pid_path) FileUtils.rm_rf(ProconBypassMan.digest_path) ProconBypassMan::RemoteAction::QueueOverProcess.shutdown ProconBypassMan::Procon::PerformanceMeasurement::QueueOverProcess.shutdown self.worker&.shutdown ProconBypassMan::ExternalInput.shutdown end |