Skip to content

Commit 4a5fa35

Browse files
Merge pull request #67 from DiamondLightSource/308_test
308 test
2 parents 459bc04 + 0336f5b commit 4a5fa35

File tree

6 files changed

+15
-16
lines changed

6 files changed

+15
-16
lines changed

dls_barcode/camera/scanner_worker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,8 +67,9 @@ def _process_frame(self, frame, config, overlay_queue, result_queue, message_que
6767
elif scan_result.any_valid_barcodes():
6868
# We have read valid barcodes but they are not new, so the scanner didn't even output a plate
6969
self._last_puck_time = time.time()
70-
message_queue.put(NoNewBarcodeMessage())
70+
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):
72+
#TODO use log
7273
message_queue.put(ScanErrorMessage(scan_result.error()))
7374

7475
def _create_scanner(self, cam_position, config):

dls_barcode/gui/main_window.py

Lines changed: 8 additions & 10 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,15 +179,17 @@ 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.latest_barcode_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()
190-
self._message_box.display(MessageFactory.from_scanner_message(scanner_msg))
191193

192194
def _reset_msg_timer(self):
193195
self._record_msg_timer = None
@@ -199,7 +201,7 @@ def _msg_timer_is_running(self):
199201
return self._record_msg_timer is not None
200202

201203
def _has_msg_timer_timeout(self):
202-
timeout = 2 * RESULT_TIMER_PERIOD / 1000
204+
timeout =2 * RESULT_TIMER_PERIOD / 1000
203205
return self._msg_timer_is_running() and time.time() - self._record_msg_timer > timeout
204206

205207
def _read_result_queue(self):
@@ -229,10 +231,7 @@ def _read_side_scan(self):
229231
if not self._record_table.is_latest_holder_barcode(holder_barcode):
230232
self._latest_holder_barcode = holder_barcode
231233
self._latest_holder_image = holder_image
232-
self._message_box.display(MessageFactory.puck_recorded_message())
233234
self._restart_live_capture_from_top()
234-
else:
235-
self._message_box.display(MessageFactory.latest_barcode_message())
236235

237236
def _read_top_scan(self):
238237
if self._result_queue.empty():
@@ -253,7 +252,6 @@ def _read_top_scan(self):
253252
# Barcodes successfully read
254253
Beeper.beep()
255254
print("Scan Completed", self._camera_switch.get_scan_time())
256-
self._message_box.display(MessageFactory.scan_completed_message())
257255
self._restart_live_capture_from_side()
258256

259257
def _restart_live_capture_from_top(self):

dls_barcode/gui/message_factory.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33

44
class MessageFactory:
5-
@staticmethod
6-
def latest_barcode_message():
7-
return Message(MessageType.WARNING, "Puck barcode already in latest record", lifetime=3)
85

96
@staticmethod
107
def from_scanner_message(scanner_msg):

dls_barcode/scan/open/open_scanner.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ def scan_next_frame(self, frame_img, is_single_image=False):
3030
barcodes = self._perform_frame_scan()
3131
result.set_barcodes(barcodes)
3232
except NoBarcodesDetectedError as ex:
33+
# TODO: logging the error
3334
result.set_error(str(ex))
3435

3536
# Create a 'blank' geometry object to store the barcode locations
@@ -71,7 +72,7 @@ def _locate_all_barcodes_in_image(self):
7172
barcodes = DataMatrix.locate_all_barcodes_in_image_deep(self._frame_img, self.barcode_sizes)
7273
else:
7374
barcodes = DataMatrix.locate_all_barcodes_in_image(self._frame_img, self.barcode_sizes)
74-
75+
# TODO: log the error
7576
if len(barcodes) == 0:
7677
raise NoBarcodesDetectedError()
7778
return barcodes

dls_barcode/scan/with_geometry/geometry_scanner.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ def scan_next_frame(self, frame_img, is_single_image=False):
3636
try:
3737
self._perform_frame_scan()
3838
self._frame_result.set_plate(self._plate)
39+
#TODO: use logs
3940
except (NoBarcodesDetectedError, GeometryException, GeometryAdjustmentError) as ex:
4041
self._frame_result.set_error(str(ex))
4142

@@ -82,7 +83,7 @@ def _perform_frame_scan(self):
8283

8384
def _locate_all_barcodes_in_image(self):
8485
barcodes = DataMatrix.locate_all_barcodes_in_image(self._frame_img, self.barcode_sizes)
85-
86+
#TODO: log this
8687
if len(barcodes) == 0:
8788
raise NoBarcodesDetectedError()
8889

docs/release-notes/release-notes-dev.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Changes merged into master
77
|-----------|--------------|------|-------------|
88
| I04_1-143 | [#62](https://github.com/DiamondLightSource/PuckBarcodeReader/issues/62) | Minor | Record summary table color changes. |
99
| I04_1-172 | [#64](https://github.com/DiamondLightSource/PuckBarcodeReader/issues/64) | Minor | New Start/Stop scan button added. |
10+
| I04_1-308 | [#66](https://github.com/DiamondLightSource/PuckBarcodeReader/issues/66) | Minor | Messages displayed need revision. |
1011

1112
Change Types:
1213
* Major - Backward incompatible change

0 commit comments

Comments
 (0)