Commit 7cf5fbff authored by anthraxx's avatar anthraxx
Browse files

move transaction timeout to outer config values

parent 0ebe0beb
......@@ -20,6 +20,7 @@ class FooBarPay:
DEFAULT_DATABASE = 'sqlite:///foobarpay.sqlite'
ALLOW_CUSTOMER_CREATION = False
INPUT_BLOCK_TIME = 0.5
IDLE_TIMEOUT = 10
def __init__(self, cli_arguments):
logging.basicConfig(level=logging.DEBUG if cli_arguments.debug else logging.INFO)
......@@ -34,7 +35,9 @@ class FooBarPay:
else:
self.scanner = EvdevScanner(cli_arguments.scanner)
self.initialize_products()
self.logic = Logic(self.display, self.database, allow_customer_creation=self.ALLOW_CUSTOMER_CREATION)
self.logic = Logic(self.display, self.database,
allow_customer_creation=self.ALLOW_CUSTOMER_CREATION,
idle_timeout=self.IDLE_TIMEOUT)
def initialize_products(self):
self.database.get_or_create(Product, id=4100060009503, name="Extaler Mineralquell", price=100)
......
......@@ -13,12 +13,12 @@ class Logic(object):
USER_ID_PREFIX = '999'
LOAD_PREFIX = '980'
IDLE_TIMEOUT = 10
def __init__(self, display, database, allow_customer_creation=True):
def __init__(self, display, database, allow_customer_creation=True, idle_timeout=10):
self.display = display
self.database = database
self.allow_customer_creation = allow_customer_creation
self.idle_timeout = idle_timeout
self.last_action = 0
self.reset()
......@@ -110,7 +110,7 @@ class Logic(object):
""" Returns True if the logic has a running transaction or does anything else """
def tick(self):
# timeout not yet expired
if self.last_action + self.IDLE_TIMEOUT > time():
if self.last_action + self.idle_timeout > time():
return True
# reset state after timeout
if self.state != self.State.Idle:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment