Skip to content

Commit

Permalink
Resolve #1, resolve #3, resolve #4 and resolve #5
Browse files Browse the repository at this point in the history
  • Loading branch information
Minege committed Jun 27, 2017
1 parent cc5ff6d commit 55bf632
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 18 deletions.
4 changes: 4 additions & 0 deletions eSSP/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ class Status(Enum):
COMMAND_RECAL = (0x07, "Command recall")
SSP6_OPTION_BYTE_DO = (0x58, "Option Byte DO")
NO_EVENT = (0xF9, "No event")
SMART_PAYOUT_NOT_ENOUGH = (0x01, "Not enough value in smart payout")
SMART_PAYOUT_EXACT_AMOUNT = (0x02, "Can't pay exact amount")
SMART_PAYOUT_BUSY = (0x03, "Smart payout is busy")
SMART_PAYOUT_DISABLED = (0x04, "Smart payout is disabled")

def __init__(self, value, debug_message):
self.value = value
Expand Down
28 changes: 14 additions & 14 deletions eSSP/eSSP.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ def __init__(self, com_port, spp_address="0", nv11=False, debug=False):
self.print_debug("Enable Failed")
self.close()

if setup_req.UnitType == 0x03:
if setup_req.UnitType == 0x03: # magic number
for channel in enumerate(setup_req.ChannelData):
self.essp.ssp6_set_coinmech_inhibits(self.sspC, channel.value, channel.cc, Status.ENABLED)
else:
Expand Down Expand Up @@ -125,21 +125,21 @@ def do_actions(self):
self.print_debug("ERROR: Payout failed")
# Checking the error
response_data = cast(self.essp.Status.SSP_get_response_data(self.sspC), POINTER(c_ubyte))
if response_data[1] == 0x01:
self.print_debug("Not enough value in Smart Payout")
elif response_data[1] == 0x02:
self.print_debug("Can't pay exact amount")
elif response_data[1] == 0x03:
self.print_debug("Smart Payout is busy")
elif response_data[1] == 0x04:
self.print_debug("Smart Payout is Status.ENABLED")
if response_data[1] == Status.SMART_PAYOUT_NOT_ENOUGH:
self.print_debug(Status.SMART_PAYOUT_NOT_ENOUGH)
elif response_data[1] == Status.SMART_PAYOUT_EXACT_AMOUNT:
self.print_debug(Status.SMART_PAYOUT_EXACT_AMOUNT)
elif response_data[1] == Status.SMART_PAYOUT_BUSY:
self.print_debug(Status.SMART_PAYOUT_BUSY)
elif response_data[1] == Status.SMART_PAYOUT_DISABLED:
self.print_debug(Status.SMART_PAYOUT_DISABLED)

elif action == Actions.PAYOUT_NEXT_NOTE_NV11: # Payout next note ( NV11 only )
self.print_debug("Payout next note")
setup_req = Ssp6SetupRequestData()
if self.essp.ssp6_setup_request(self.sspC, byref(setup_req)) != Status.SSP_RESPONSE_OK:
self.print_debug("Setup Request Failed")
if setup_req.UnitType != 0x07:
if setup_req.UnitType != 0x07: # Maybe the version, or something ( taken from the SDK C code )
self.print_debug("Payout next note is only valid for NV11")
if self.essp.ssp6_payout_note(self.sspC) != Status.SSP_RESPONSE_OK:
self.print_debug("Payout next note failed")
Expand Down Expand Up @@ -190,12 +190,12 @@ def enable_validator(self):
if self.essp.ssp6_setup_request(self.sspC, byref(setup_req)) != Status.SSP_RESPONSE_OK:
self.print_debug("Setup request failed")
return False
if setup_req.UnitType == 0x03:
if setup_req.UnitType == 0x03: # Magic number
# SMART Hopper requires different inhibit commands
for channel in setup_req.ChannelData:
self.essp.ssp6_set_coinmech_inhibits(self.sspC, channel.value, channel.cc, Status.ENABLED)
else:
if self.essp.ssp6_set_inhibits(self.sspC, 0xFF, 0xFF) != Status.SSP_RESPONSE_OK:
if self.essp.ssp6_set_inhibits(self.sspC, 0xFF, 0xFF) != Status.SSP_RESPONSE_OK: # Magic numbers here too
self.print_debug("Inhibits Failed")
return False

Expand All @@ -210,7 +210,7 @@ def parse_poll(self):

if events.event == Status.SSP_POLL_RESET:
self.print_debug("Unit Reset")
if self.essp.ssp6_host_protocol(self.sspC, Status.CHECKSUM_ERROR) != Status.SSP_RESPONSE_OK:
if self.essp.ssp6_host_protocol(self.sspC, 0x06) != Status.SSP_RESPONSE_OK: # Magic number
self.print_debug("Host Protocol Failed")
self.close()

Expand Down Expand Up @@ -305,7 +305,7 @@ def payout(self, amount, currency="CHF"):
self.__action_helper(amount, currency, Actions.PAYOUT, "payout")

def get_note_amount(self, amount, currency="CHF"):
"""Payout note(s) for completing the amount passed in parameter"""
"""Get the numbers of note of value X in the smart payout device"""
self.__action_helper(amount, currency, Actions.GET_NOTE_AMOUNT, "getnoteamount")

def reset(self):
Expand Down
8 changes: 4 additions & 4 deletions examples/ex1.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ def event_loop():
if note == 0 or currency == 0 or event == 0:
pass # Operation that do not send money info, we don't do anything with it
else:
if note != 4 and event == SSP_POLL_CREDIT:
if note != 4 and event == Status.SSP_POLL_CREDIT:
validator.print_debug("NOT A 100 NOTE")
validator.nv11_stack()
validator.nv11_stack_next_note()
validator.enable_validator()
elif note == 4 and event == SSP_POLL_READ:
elif note == 4 and event == Status.SSP_POLL_READ:
validator.print_debug("100 NOTE")
validator.set_route_storage(100) # Route to storage
validator.do_actions()
Expand Down Expand Up @@ -47,7 +47,7 @@ def event_loop():
validator.reset()
elif choice == "y": # NV11 Payout last entered ( next available )
print("Payout next 1")
validator.nv11_payout()
validator.nv11_payout_next_note()
elif choice == "d": # Disable
validator.disable_validator()
elif choice == "D": # Disable the payout device
Expand Down

0 comments on commit 55bf632

Please sign in to comment.