Class: Artoo::Adaptors::Neurosky
- Inherits:
-
Adaptor
- Object
- Adaptor
- Artoo::Adaptors::Neurosky
- Defined in:
- lib/artoo/adaptors/neurosky.rb
Overview
Connect to a neurosky device
Constant Summary collapse
- RETRY_COUNT =
Number of retries when connecting
5
Instance Attribute Summary collapse
-
#neurosky ⇒ Object
readonly
Returns the value of attribute neurosky.
Instance Method Summary collapse
-
#connect ⇒ Boolean
Creates a connection with device.
-
#disconnect ⇒ Boolean
Closes connection with device.
-
#method_missing(method_name, *arguments, &block) ⇒ Object
Uses method missing to call device actions.
-
#name ⇒ String
Name of device.
-
#version ⇒ String
Version of device.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *arguments, &block) ⇒ Object
Uses method missing to call device actions
54 55 56 |
# File 'lib/artoo/adaptors/neurosky.rb', line 54 def method_missing(method_name, *arguments, &block) neurosky.send(method_name, *arguments, &block) end |
Instance Attribute Details
#neurosky ⇒ Object (readonly)
Returns the value of attribute neurosky.
8 9 10 |
# File 'lib/artoo/adaptors/neurosky.rb', line 8 def neurosky @neurosky end |
Instance Method Details
#connect ⇒ Boolean
Creates a connection with device
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/artoo/adaptors/neurosky.rb', line 15 def connect @retries_left = RETRY_COUNT require 'mindset' unless defined?(::Mindset) begin @neurosky = ::Mindset.connect(connect_to) super return true rescue Errno::EBUSY, Errno::ECONNREFUSED => e @retries_left -= 1 if @retries_left > 0 retry else Logger.error e. Logger.error e.backtrace.inspect return false end end end |
#disconnect ⇒ Boolean
Closes connection with device
36 37 38 |
# File 'lib/artoo/adaptors/neurosky.rb', line 36 def disconnect neurosky.disconnect if connected? end |
#name ⇒ String
Name of device
42 43 44 |
# File 'lib/artoo/adaptors/neurosky.rb', line 42 def name "neurosky" end |