Class: Smartware::Interface::CardReader

Inherits:
Interface
  • Object
show all
Defined in:
lib/smartware/interfaces/card_reader.rb

Defined Under Namespace

Classes: CardReaderError

Constant Summary collapse

COMMUNICATION_ERROR =
1
HARDWARE_ERROR =
2
CARD_JAM_ERROR =
3
CARD_ERROR =
4
MAG_READ_ERROR =
5
ICC_ERROR =
6

Instance Attribute Summary

Attributes inherited from Interface

#config

Instance Method Summary collapse

Methods inherited from Interface

#error, #model, #repush_events, #shutdown, #status, #version

Constructor Details

#initialize(config, service) ⇒ CardReader

Returns a new instance of CardReader.



21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/smartware/interfaces/card_reader.rb', line 21

def initialize(config, service)
  super

  update_status :model, @device.model
  update_status :version, @device.version
  update_status :card_inserted, false, nil, nil, nil

  @state = :inactive
  @open = false
  @mutex = Mutex.new
  @cvar = ConditionVariable.new

  schedule_status
end

Instance Method Details

#card_insertedObject



50
51
52
# File 'lib/smartware/interfaces/card_reader.rb', line 50

def card_inserted
  @status[:card_inserted]
end

#closeObject



43
44
45
46
47
48
# File 'lib/smartware/interfaces/card_reader.rb', line 43

def close
  @mutex.synchronize do
    @open = false
    @cvar.wait(@mutex)
  end
end

#openObject



36
37
38
39
40
41
# File 'lib/smartware/interfaces/card_reader.rb', line 36

def open
  @mutex.synchronize do
    @open = true
    @cvar.wait(@mutex)
  end
end