summaryrefslogtreecommitdiffstats
path: root/mdb/device.py
diff options
context:
space:
mode:
Diffstat (limited to 'mdb/device.py')
-rw-r--r--mdb/device.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/mdb/device.py b/mdb/device.py
index 7b23afe..0b1940c 100644
--- a/mdb/device.py
+++ b/mdb/device.py
@@ -128,7 +128,7 @@ class MDBDevice(object):
class CashlessMDBDevice(MDBDevice):
base_address = CASHLESS_RESET
state = 'IDLE'
-
+ last_poll = 0
config_data = [
0x01, # Feature level
0x19, 0x85, # PLN x---DD
@@ -160,6 +160,7 @@ class CashlessMDBDevice(MDBDevice):
return []
elif req.command == CASHLESS_POLL:
+ self.last_poll = time.time()
try:
msg = self.poll_queue.get_nowait()
self.logger.info('Sending POLL response: %r', msg)
@@ -195,7 +196,7 @@ class CashlessMDBDevice(MDBDevice):
elif req.data[0] == 0x04:
self.logger.info('VEND: session complete %r', req)
- self.state = 'IDLE'
+ self.state = 'OK'
return [0x07]
elif req.data[0] == 0x05:
@@ -227,7 +228,7 @@ class CashlessMDBDevice(MDBDevice):
self.logger.info(' -> Disp rows: %d', disp_rows)
self.logger.info(' -> Disp info: %d', disp_info)
- self.state = 'IDLE'
+ self.state = 'OK'
return [0x01] + self.config_data
@@ -254,6 +255,10 @@ class CashlessMDBDevice(MDBDevice):
# Called when user selects a product
return True
+ @property
+ def online(self):
+ return time.time() - self.last_poll < 5
+
#
# This is mostly unfinished Bill validator implementation