Sha256: 77f87b28b9832a6aca0bdb0552fad792ffb8fd2e0c90d39d8c9b9df636f0730d

Contents?: true

Size: 874 Bytes

Versions: 19

Compression:

Stored size: 874 Bytes

Contents

class ProconBypassMan::DeviceConnection::OutputReportGenerator
  def initialize
    @counter = 0
  end

  # @return [String]
  def generate_by_step(step)
    sub_command_with_arg = ProconBypassMan::DeviceConnection::ProconSettingOverrider::ALL_SETTINGS[step]&.join or raise("Unsupport step")
    raw_data = generate(sub_command_with_arg)
    count_up
    raw_data
  end

  # @return [String]
  def generate_by_sub_command_with_arg(sub_command_with_arg)
    raw_data = generate(sub_command_with_arg)
    count_up
    raw_data
  end

  private

  # @return [String]
  def generate(sub_command_with_arg)
    [
      ["01", counter, "00" * 8, sub_command_with_arg].join
    ].pack("H*")
  end

  def count_up
    @counter = @counter + 1
    if @counter >= 256
      @counter = 0
    else
      @counter
    end
  end

  def counter
    @counter.to_s(16).rjust(2, "0")
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
procon_bypass_man-0.3.12 lib/procon_bypass_man/device_connection/output_report_generator.rb
procon_bypass_man-0.3.11 lib/procon_bypass_man/device_connection/output_report_generator.rb
procon_bypass_man-0.3.10 lib/procon_bypass_man/device_connection/output_report_generator.rb
procon_bypass_man-0.3.9 lib/procon_bypass_man/device_connection/output_report_generator.rb
procon_bypass_man-0.3.8.1 lib/procon_bypass_man/device_connection/output_report_generator.rb
procon_bypass_man-0.3.8 lib/procon_bypass_man/device_connection/output_report_generator.rb
procon_bypass_man-0.3.7 lib/procon_bypass_man/device_connection/output_report_generator.rb
procon_bypass_man-0.3.6 lib/procon_bypass_man/device_connection/output_report_generator.rb
procon_bypass_man-0.3.5 lib/procon_bypass_man/device_connection/output_report_generator.rb
procon_bypass_man-0.3.4 lib/procon_bypass_man/device_connection/output_report_generator.rb
procon_bypass_man-0.3.3.1 lib/procon_bypass_man/device_connection/output_report_generator.rb
procon_bypass_man-0.3.3 lib/procon_bypass_man/device_connection/output_report_generator.rb
procon_bypass_man-0.3.2 lib/procon_bypass_man/device_connection/output_report_generator.rb
procon_bypass_man-0.3.1 lib/procon_bypass_man/device_connection/output_report_generator.rb
procon_bypass_man-0.3.0 lib/procon_bypass_man/device_connection/output_report_generator.rb
procon_bypass_man-0.2.3 lib/procon_bypass_man/device_connection/output_report_generator.rb
procon_bypass_man-0.2.2 lib/procon_bypass_man/device_connection/output_report_generator.rb
procon_bypass_man-0.2.1 lib/procon_bypass_man/device_connection/output_report_generator.rb
procon_bypass_man-0.2.0 lib/procon_bypass_man/device_connection/output_report_generator.rb