Class: LibComponent::Input

Inherits:
Object
  • Object
show all
Includes:
Pin
Defined in:
lib/openplacos/libcomponent.rb

Overview

Instanciate an input pin to your component

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Pin

#buffer=, #introspect, #set_component

Constructor Details

#initialize(pin_name_, iface_name_) ⇒ Input

instaciate an input pin with its name and the interface this pin will support



68
69
70
71
72
73
# File 'lib/openplacos/libcomponent.rb', line 68

def initialize(pin_name_,iface_name_)
  @name      = pin_name_
  @interface = iface_name_      
  @input     = nil
  @last_iface_init = ""
end

Instance Attribute Details

#inputObject

Returns the value of attribute input.



65
66
67
# File 'lib/openplacos/libcomponent.rb', line 65

def input
  @input
end

#interfaceObject (readonly)

Returns the value of attribute interface.



64
65
66
# File 'lib/openplacos/libcomponent.rb', line 64

def interface
  @interface
end

#last_iface_initObject

Returns the value of attribute last_iface_init.



65
66
67
# File 'lib/openplacos/libcomponent.rb', line 65

def last_iface_init
  @last_iface_init
end

#nameObject (readonly)

Returns the value of attribute name.



64
65
66
# File 'lib/openplacos/libcomponent.rb', line 64

def name
  @name
end

Instance Method Details

#on_read(&block) ⇒ Object

Event style for read definition Can also be overloaded by developper



105
106
107
108
109
# File 'lib/openplacos/libcomponent.rb', line 105

def on_read(&block)
  self.singleton_class.instance_eval {
    define_method(:read , &block)
  }
end

#on_write(&block) ⇒ Object

Event style for write definition Can also be overloaded by developper



113
114
115
116
117
# File 'lib/openplacos/libcomponent.rb', line 113

def on_write(&block)
  self.singleton_class.instance_eval {
    define_method(:write , &block)
  }
end

#read_lib(*args) ⇒ Object

read method called by dbus this method will

  • turning off previous interface

  • turn pin into input mode

  • initialize current interface

  • and then made a read access

All these steps are optionnal and are in charge of component developper.



82
83
84
85
86
87
# File 'lib/openplacos/libcomponent.rb', line 82

def read_lib(*args)
  set_off # set_off last iface
  set_input_lib
  init_iface
  return read(*args)
end

#write_lib(*args) ⇒ Object

write method called by dbus this method will

  • turning off previous interface

  • turn pin into input mode

  • initialize current interface

  • and then made a read access

All these steps are optionnal and are in charge of component developper.



96
97
98
99
100
101
# File 'lib/openplacos/libcomponent.rb', line 96

def write_lib(*args)
  set_off # set_off last iface
  set_output_lib
  init_iface
  return write(*args)
end