class LibComponent::Input
Instanciate an input pin to your component
Attributes
Public Class Methods
instaciate an input pin with its name and the interface this pin will support
# 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
Public Instance Methods
Event style for read definition Can also be overloaded by developper
# File lib/openplacos/libcomponent.rb, line 105 def on_read(&block) self.singleton_class.instance_eval { define_method(:read , &block) } end
Event style for write definition Can also be overloaded by developper
# File lib/openplacos/libcomponent.rb, line 113 def on_write(&block) self.singleton_class.instance_eval { define_method(:write , &block) } end
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.
# 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 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.
# 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
Private Instance Methods
Initialize this interface Please implement init method at your end
# File lib/openplacos/libcomponent.rb, line 157 def init_iface if(@last_iface_init != @interface) if(self.respond_to?(:init)) self.init end end @component.set_last_iface_init(@name, @interface) # set last_iface_name end
If pin has to be set to input mode Please implement set_input method at your end
# File lib/openplacos/libcomponent.rb, line 134 def set_input_lib if (@input != 1) # 1 means input / 0 output if(self.respond_to?(:set_input)) self.set_input() end @input = 1 end @last_iface_init = @interface end
Iface changed since last call, turn off previous one Please implement exit method at your end
# File lib/openplacos/libcomponent.rb, line 123 def set_off() if (@last_iface_init != @interface) prev_iface = @component.get_input_iface(@name, @last_iface_init) if(prev_iface.respond_to?(:exit)) prev_iface.exit() end end end
If pin has to be set to output mode Please implement set_output method at your end
# File lib/openplacos/libcomponent.rb, line 146 def set_output_lib if (@input != 0) # 1 means input / 0 output if(self.respond_to?(:set_output)) self.set_output() end @input = 0 end end