Class: ProconBypassMan::DeviceConnection::ProconSettingOverrider
- Inherits:
-
Object
- Object
- ProconBypassMan::DeviceConnection::ProconSettingOverrider
- Defined in:
- lib/procon_bypass_man/device_connection/procon_setting_overrider.rb
Constant Summary collapse
- SUB_COMMAND_HOME_LED_ON =
"38"
- SUB_COMMAND_ARG_HOME_LED_ON =
"1FF0FF"
- ALL_SETTINGS =
{ home_led_on: [SUB_COMMAND_HOME_LED_ON, SUB_COMMAND_ARG_HOME_LED_ON], }
- SPECIAL_SUB_COMMAND_ARGS =
TODO 自動生成する
{ SUB_COMMAND_HOME_LED_ON => SUB_COMMAND_ARG_HOME_LED_ON, }
Instance Attribute Summary collapse
-
#output_report_generator ⇒ Object
Returns the value of attribute output_report_generator.
-
#output_report_watcher ⇒ Object
Returns the value of attribute output_report_watcher.
-
#procon ⇒ Object
Returns the value of attribute procon.
Instance Method Summary collapse
- #execute! ⇒ Object
-
#initialize(procon:) ⇒ ProconSettingOverrider
constructor
A new instance of ProconSettingOverrider.
- #run_once ⇒ Object
Constructor Details
#initialize(procon:) ⇒ ProconSettingOverrider
Returns a new instance of ProconSettingOverrider.
17 18 19 20 21 22 23 24 25 26 27 |
# File 'lib/procon_bypass_man/device_connection/procon_setting_overrider.rb', line 17 def initialize(procon: ) use_steps = {} if ProconBypassMan.config.enable_home_led_on_connect use_steps.merge!(home_led_on: ALL_SETTINGS[:home_led_on]) end @setting_steps = use_steps.keys self.procon = ProconBypassMan::DeviceModel.new(procon) self.output_report_watcher = ProconBypassMan::DeviceConnection::SpoofingOutputReportWatcher.new(expected_sub_commands: use_steps.values) self.output_report_generator = ProconBypassMan::DeviceConnection::OutputReportGenerator.new end |
Instance Attribute Details
#output_report_generator ⇒ Object
Returns the value of attribute output_report_generator.
2 3 4 |
# File 'lib/procon_bypass_man/device_connection/procon_setting_overrider.rb', line 2 def output_report_generator @output_report_generator end |
#output_report_watcher ⇒ Object
Returns the value of attribute output_report_watcher.
2 3 4 |
# File 'lib/procon_bypass_man/device_connection/procon_setting_overrider.rb', line 2 def output_report_watcher @output_report_watcher end |
#procon ⇒ Object
Returns the value of attribute procon.
2 3 4 |
# File 'lib/procon_bypass_man/device_connection/procon_setting_overrider.rb', line 2 def procon @procon end |
Instance Method Details
#execute! ⇒ Object
29 30 31 32 33 34 35 36 37 |
# File 'lib/procon_bypass_man/device_connection/procon_setting_overrider.rb', line 29 def execute! loop do run_once if output_report_watcher.timeout_or_completed? break end end end |
#run_once ⇒ Object
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 |
# File 'lib/procon_bypass_man/device_connection/procon_setting_overrider.rb', line 39 def run_once begin raw_data = non_blocking_read_procon rescue IO::EAGAINWaitReadable return end ProconBypassMan.logger.info "[procon_setting_overrider] <<< #{raw_data.unpack("H*").first}" output_report_watcher.mark_as_receive(raw_data) if output_report_watcher.has_unreceived_command? re_override_setting_by_cmd(output_report_watcher.unreceived_sub_command_with_arg) else if(setting_step = @setting_steps.shift) override_setting_by_step(setting_step) else return end end end |