Class: Smartware::Driver::CashAcceptor::CCNET

Inherits:
Object
  • Object
show all
Defined in:
lib/smartware/drivers/cash_acceptor/ccnet.rb

Constant Summary collapse

RESET =

Commands

0x30
GET_STATUS =
0x31
SET_SECURITY =
0x32
POLL =
0x33
ENABLE_BILL_TYPES =
0x34
STACK =
0x35
RETURN =
0x36
IDENTIFICATION =
0x37
HOLD =
0x38
SET_BARCODE_PARAMETERS =
0x39
EXTRACT_BARCODE_DATA =
0x3A
GET_BILL_TABLE =
0x41
GET_CRC32_OF_THE_CODE =
0x51
DOWNLOAD =
0x50
REQUEST_STATISTICS =
0x60
ACK =
0x00
DISPENCE =
0x3C
POWER_UP =

States

0x10
POWER_UP_WITH_BILL_IN_VALIDATOR =
0x11
POWER_UP_WITH_BILL_IN_STACKER =
0x12
INITIALIZE =
0x13
IDLING =
0x14
ACCEPTING =
0x15
STACKING =
0x17
RETURNING =
0x18
UNIT_DISABLED =
0x19
HOLDING =
0x1A
DEVICE_BUSY =
0x1B
REJECTING =
0x1C
DROP_CASETTE_FULL =
0x41
DROP_CASETTE_OUT_OF_POSITION =
0x42
VALIDATOR_JAMMED =
0x43
DROP_CASETTE_JAMMED =
0x44
CHEATED =
0x45
PAUSE =
0x46
FAILURE =
0x47
ESCROW =
0x80
STACKED =
0x81
RETURNED =
0x82
ERRORS =
{
  0x41 => Interface::CashAcceptor::DROP_CASETTE_FULL,
  0x42 => Interface::CashAcceptor::DROP_CASETTE_OUT_OF_POSITION,
  0x43 => Interface::CashAcceptor::VALIDATOR_JAMMED,
  0x44 => Interface::CashAcceptor::DROP_CASETTE_JAMMED,
  0x45 => Interface::CashAcceptor::CHEATED,
  0x47 => Interface::CashAcceptor::BILL_VALIDATOR_FAILURE,
  0x50 => Interface::CashAcceptor::STACK_MOTOR_FAILURE,
  0x51 => Interface::CashAcceptor::TRANSPORT_MOTOR_SPEED_FAILURE,
  0x52 => Interface::CashAcceptor::TRANSPORT_MOTOR_FAILURE,
  0x53 => Interface::CashAcceptor::ALIGNING_MOTOR_FAILURE,
  0x54 => Interface::CashAcceptor::INITIAL_CASETTE_STATUS_FAILURE,
  0x55 => Interface::CashAcceptor::OPTIC_CANAL_FAILURE,
  0x56 => Interface::CashAcceptor::MAGNETIC_CANAL_FAILURE,
  0x5f => Interface::CashAcceptor::CAPACITANCE_CANAL_FAILURE
}

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ CCNET

Returns a new instance of CCNET.



72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
# File 'lib/smartware/drivers/cash_acceptor/ccnet.rb', line 72

def initialize(config)
  @io = SerialPort.new(config["port"], 9600, 8, 1, SerialPort::NONE)
  @io.flow_control = SerialPort::NONE

  @connection = EventMachine.attach @io, CCNETConnection
  @connection.address = 3

  @open = nil
  @closed = nil
  @escrow = nil
  @stacked = nil
  @returned = nil
  @status = nil

  @bill_types = nil
  @identification = nil
  @enabled_types = 0

  set_poll
end

Instance Attribute Details

#bill_typesObject (readonly)

Returns the value of attribute bill_types.



67
68
69
# File 'lib/smartware/drivers/cash_acceptor/ccnet.rb', line 67

def bill_types
  @bill_types
end

#closedObject

Returns the value of attribute closed.



69
70
71
# File 'lib/smartware/drivers/cash_acceptor/ccnet.rb', line 69

def closed
  @closed
end

#enabled_typesObject

Returns the value of attribute enabled_types.



70
71
72
# File 'lib/smartware/drivers/cash_acceptor/ccnet.rb', line 70

def enabled_types
  @enabled_types
end

#escrow=(value) ⇒ Object

Sets the attribute escrow

Parameters:

  • value

    the value to set the attribute escrow to.



69
70
71
# File 'lib/smartware/drivers/cash_acceptor/ccnet.rb', line 69

def escrow=(value)
  @escrow = value
end

#openObject

Returns the value of attribute open.



69
70
71
# File 'lib/smartware/drivers/cash_acceptor/ccnet.rb', line 69

def open
  @open
end

#returned=(value) ⇒ Object

Sets the attribute returned

Parameters:

  • value

    the value to set the attribute returned to.



69
70
71
# File 'lib/smartware/drivers/cash_acceptor/ccnet.rb', line 69

def returned=(value)
  @returned = value
end

#stacked=(value) ⇒ Object

Sets the attribute stacked

Parameters:

  • value

    the value to set the attribute stacked to.



69
70
71
# File 'lib/smartware/drivers/cash_acceptor/ccnet.rb', line 69

def stacked=(value)
  @stacked = value
end

#statusObject

Returns the value of attribute status.



69
70
71
# File 'lib/smartware/drivers/cash_acceptor/ccnet.rb', line 69

def status
  @status
end

Instance Method Details

#modelObject



93
94
95
96
97
# File 'lib/smartware/drivers/cash_acceptor/ccnet.rb', line 93

def model
  return nil if @identification.nil?

  @identification[0..14]
end

#versionObject



99
100
101
102
103
# File 'lib/smartware/drivers/cash_acceptor/ccnet.rb', line 99

def version
  return nil if @identification.nil?

  @identification[15..26]
end