Skip to content

Commit 2b95af3

Browse files
committed
I04_1-308:
Revised the messages and got 4 scenarios: 2 for side scanner: 1) once the side barcode is not there - display 'No barcodes detected constantly' 2) once the side is there but it was already scanned - display 'Scan Completed' and 2 for top: 1) When fails to read a single pin from the top within given - display 'Scan timeout' briefly and try to scan again 2) When fails to scan the top within a given time but got some pins scanned - display briefly 'Scan timeout' and than 'Scan completed'
1 parent bb45714 commit 2b95af3

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

dls_barcode/camera/scanner_worker.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ def _process_frame(self, frame, config, overlay_queue, result_queue, message_que
7070
message_queue.put(NoNewBarcodeMessage()) #important used in the message logic
7171
elif scan_result.error() is not None and (time.time() - self._last_puck_time > NO_PUCK_TIME):
7272
#TODO use log
73-
print(ScanErrorMessage(scan_result.error()))
73+
message_queue.put(ScanErrorMessage(scan_result.error()))
7474

7575
def _create_scanner(self, cam_position, config):
7676
if cam_position == CameraPosition.SIDE:

dls_barcode/gui/main_window.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from PyQt4 import QtGui, QtCore
66

77
from dls_barcode.config import BarcodeConfig, BarcodeConfigDialog
8-
from dls_barcode.camera import CameraScanner, CameraSwitch, NoNewBarcodeMessage
8+
from dls_barcode.camera import CameraScanner, CameraSwitch, NoNewBarcodeMessage, ScanErrorMessage
99
from dls_barcode.gui.scan_button import ScanButton
1010
from dls_util import Beeper
1111
from dls_util.file import FileManager
@@ -179,12 +179,15 @@ def _read_message_queue(self):
179179
except queue.Empty:
180180
return
181181

182-
if self._camera_switch.is_side() and isinstance(scanner_msg, NoNewBarcodeMessage):
182+
if self._camera_switch.is_side():
183183
if not self._msg_timer_is_running():
184184
# The result queue is read at a slower rate - use a timer to give it time to process a new barcode
185185
self._start_msg_timer()
186-
elif self._has_msg_timer_timeout():
187-
self._message_box.display(MessageFactory.scan_completed_message())
186+
elif self._has_msg_timer_timeout() and isinstance(scanner_msg, NoNewBarcodeMessage):
187+
self._message_box.display(MessageFactory.scan_completed_message())
188+
elif isinstance(scanner_msg, ScanErrorMessage):
189+
self._message_box.display(MessageFactory.from_scanner_message(scanner_msg))
190+
self._reset_msg_timer()
188191
else:
189192
self._reset_msg_timer()
190193

@@ -198,7 +201,7 @@ def _msg_timer_is_running(self):
198201
return self._record_msg_timer is not None
199202

200203
def _has_msg_timer_timeout(self):
201-
timeout = 2 * RESULT_TIMER_PERIOD / 1000
204+
timeout =2 * RESULT_TIMER_PERIOD / 1000
202205
return self._msg_timer_is_running() and time.time() - self._record_msg_timer > timeout
203206

204207
def _read_result_queue(self):
@@ -229,8 +232,6 @@ def _read_side_scan(self):
229232
self._latest_holder_barcode = holder_barcode
230233
self._latest_holder_image = holder_image
231234
self._restart_live_capture_from_top()
232-
else:
233-
self._message_box.display(MessageFactory.scan_completed_message())
234235

235236
def _read_top_scan(self):
236237
if self._result_queue.empty():
@@ -251,7 +252,6 @@ def _read_top_scan(self):
251252
# Barcodes successfully read
252253
Beeper.beep()
253254
print("Scan Completed", self._camera_switch.get_scan_time())
254-
self._message_box.display(MessageFactory.scan_completed_message())
255255
self._restart_live_capture_from_side()
256256

257257
def _restart_live_capture_from_top(self):

dls_barcode/gui/message_factory.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33

44
class MessageFactory:
55

6+
@staticmethod
7+
def from_scanner_message(scanner_msg):
8+
return Message(MessageType.WARNING, scanner_msg.content())
9+
610
@staticmethod
711
def puck_recorded_message():
812
return Message(MessageType.INFO, "Puck barcode recorded")

0 commit comments

Comments
 (0)