Class: Player::AIO
- Includes:
- Enumerable
- Defined in:
- lib/ruby-player/aio.rb
Overview
The aio interface provides access to an analog I/O device.
Instance Attribute Summary collapse
-
#state ⇒ Object
readonly
Returns the value of attribute state.
Attributes inherited from Device
Instance Method Summary collapse
-
#[](id) ⇒ Float
Get single sample [V].
- #[]=(id, voltage) ⇒ Object
- #each ⇒ Object
- #fill(hdr, msg) ⇒ Object
-
#initialize(dev, client) ⇒ AIO
constructor
A new instance of AIO.
-
#set_voltage(id, voltage) ⇒ AIO
The aio interface allows for the voltage level on one output to be set.
-
#voltages ⇒ Object
The samples [V].
Methods inherited from Device
#handle_response, #send_message
Constructor Details
#initialize(dev, client) ⇒ AIO
Returns a new instance of AIO.
22 23 24 25 |
# File 'lib/ruby-player/aio.rb', line 22 def initialize(dev, client) super @state = { voltages: [] } end |
Instance Attribute Details
#state ⇒ Object (readonly)
Returns the value of attribute state.
20 21 22 |
# File 'lib/ruby-player/aio.rb', line 20 def state @state end |
Instance Method Details
#[](id) ⇒ Float
Get single sample [V]
53 54 55 |
# File 'lib/ruby-player/aio.rb', line 53 def [](id) state[:voltages][id] end |
#[]=(id, voltage) ⇒ Object
58 59 60 |
# File 'lib/ruby-player/aio.rb', line 58 def []=(id, voltage) set_voltage(id, voltage) end |
#each ⇒ Object
62 63 64 |
# File 'lib/ruby-player/aio.rb', line 62 def each state[:voltages].each { |v| yield v } end |
#fill(hdr, msg) ⇒ Object
42 43 44 45 46 47 48 49 |
# File 'lib/ruby-player/aio.rb', line 42 def fill(hdr, msg) case hdr.subtype when PLAYER_AIO_DATA_STATE read_state(msg) else hdr end end |
#set_voltage(id, voltage) ⇒ AIO
The aio interface allows for the voltage level on one output to be set
37 38 39 40 |
# File 'lib/ruby-player/aio.rb', line 37 def set_voltage(id, voltage) (PLAYER_MSGTYPE_CMD, PLAYER_AIO_CMD_STATE, [id, voltage].pack("Ng")) self end |
#voltages ⇒ Object
The samples [V]
29 30 31 |
# File 'lib/ruby-player/aio.rb', line 29 def voltages state[:voltages] end |