Class: I2c_command
- Inherits:
-
Qt::Widget
- Object
- Qt::Widget
- I2c_command
- Defined in:
- lib/class/i2c/I2c_command.rb
Instance Method Summary collapse
- #check_form_param ⇒ Object
-
#initialize(chip, bus_id, parent) ⇒ I2c_command
constructor
A new instance of I2c_command.
- #open_generic_cmd ⇒ Object
Constructor Details
#initialize(chip, bus_id, parent) ⇒ I2c_command
Returns a new instance of I2c_command.
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/class/i2c/I2c_command.rb', line 12 def initialize(chip, bus_id, parent) super() @view = Ui_I2c_command.new centerWindow(self) @view.setupUi(self) @view.rbn_read.setChecked(true) inputRestrict(@view.lie_size, 0) @chip = chip @chip_settings = chip.i2c_setting @bus_id = bus_id @parent = parent end |
Instance Method Details
#check_form_param ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/class/i2c/I2c_command.rb', line 40 def check_form_param if @view.lie_size.text.empty? || @view.lie_size.text.to_i.zero? Qt::MessageBox.new( Qt::MessageBox::Information, "Form invalid", "Payload size must be filled and superior to 0" ).exec return 0 end return 1 end |
#open_generic_cmd ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/class/i2c/I2c_command.rb', line 25 def open_generic_cmd return 0 if check_form_param.zero? if @view.rbn_read.isChecked mode = "r" addr = @chip_settings.address_r else mode = "w" addr = @chip_settings.address_w end i2c_cmd_form = Command_editor.new(0, nil, @chip, @bus_id, @parent, :mode => mode, :size => @view.lie_size.text, :addr => addr) i2c_cmd_form.setWindowModality(Qt::ApplicationModal) i2c_cmd_form.show close end |