Skip to content

Commit 3f7f41a

Browse files
committed
I04_1-165: record table and main window handle holder barcode separately
1 parent 3e39c70 commit 3f7f41a

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

dls_barcode/data_store/store.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,5 +125,6 @@ def _merge_holder_image_into_pins_image(self, holder_img, pins_img):
125125
merged_img.paste(small_holder_img, 0, 0)
126126
return merged_img
127127

128-
129-
128+
def is_new_holder_barcode(self, holder_barcode):
129+
known_holder_barcodes = [r.holder_barcode for r in self.records]
130+
return not holder_barcode in known_holder_barcodes

dls_barcode/gui/main_window.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -267,8 +267,9 @@ def _read_side_scan(self):
267267
# Barcode successfully read
268268
Beeper.beep()
269269
print("MAIN: puck barcode recorded")
270-
if self._record_table.unique_side_barcode(plate): # if new side barcode
271-
self.original_plate = plate
270+
holder_barcode = plate.barcodes()[0]
271+
if self._record_table.is_new_holder_barcode (holder_barcode):
272+
self._current_holder_barcode = holder_barcode
272273
self._latest_holder_image = holder_image
273274
self._message_box.display(MessageFactory.puck_recorded_message())
274275
self._camera_switch.restart_live_capture_from_top()
@@ -286,8 +287,8 @@ def _read_top_scan(self):
286287
# Get the result
287288
plate, pins_image = self._result_queue.get(False)
288289

289-
# Add new record to the table - side is the original_plate read first, top is the plate
290-
self._record_table.add_record_frame(self.original_plate, plate, self._latest_holder_image, pins_image)
290+
# Add new record to the table - side is the _current_holder_barcode read first, top is the plate
291+
self._record_table.add_record_frame(self._current_holder_barcode, plate, self._latest_holder_image, pins_image)
291292
if not plate.is_full_valid():
292293
return
293294

dls_barcode/gui/record_table.py

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ class ScanRecordTable(QGroupBox):
1616
details of the scan to appear in other GUI components (list of barcodes in the barcode
1717
table and image of the puck in the image frame).
1818
"""
19-
COLUMNS = ['Date', 'Time', 'Plate Type', 'Valid', 'Invalid', 'Empty']
19+
COLUMNS = ['Date', 'Time', 'Plate Barcode', 'Plate Type', 'Valid', 'Invalid', 'Empty']
2020

2121
def __init__(self, barcode_table, image_frame, options, to_run_on_table_clicked):
2222
super(ScanRecordTable, self).__init__()
2323

2424
# Read the store from file
25-
self._store = Store(options.store_directory.value(), options, FileManager())
25+
self._store = Store(options.store_directory.value(), options.store_capacity, FileManager())
2626
self._options = options
2727

2828
self._barcodeTable = barcode_table
@@ -43,9 +43,10 @@ def _init_ui(self, to_run_on_table_clicked):
4343
self._table.setColumnWidth(0, 70)
4444
self._table.setColumnWidth(1, 55)
4545
self._table.setColumnWidth(2, 85)
46-
self._table.setColumnWidth(3, 60)
47-
self._table.setColumnWidth(4, 60)
48-
self._table.setColumnWidth(5, 60)
46+
self._table.setColumnWidth(3, 70)
47+
self._table.setColumnWidth(4, 45)
48+
self._table.setColumnWidth(5, 50)
49+
self._table.setColumnWidth(6, 45)
4950
self._table.setSelectionBehavior(QtGui.QAbstractItemView.SelectRows)
5051
self._table.cellPressed.connect(to_run_on_table_clicked)
5152
self._table.cellPressed.connect(self._record_selected)
@@ -81,7 +82,7 @@ def _load_store_records(self):
8182
self._table.setRowCount(self._store.size())
8283

8384
for n, record in enumerate(self._store.records):
84-
items = [record.date, record.time, record.plate_type, record.num_valid_barcodes,
85+
items = [record.date, record.time, record.holder_barcode, record.plate_type, record.num_valid_barcodes,
8586
record.num_unread_slots, record.num_empty_slots]
8687

8788
if (record.num_valid_barcodes + record.num_empty_slots) == record.num_slots:
@@ -136,14 +137,7 @@ def _delete_selected_records(self):
136137
self._store.delete_records(records_to_delete)
137138
self._load_store_records()
138139

139-
def unique_side_barcode(self, plate):
140-
barcodes = []
141-
plate_barcodes = plate.barcodes()
142-
store = self._store
143-
rec = store.records
144-
for m,record in enumerate(rec):
145-
barcodes = barcodes + record.barcodes[:]
146-
if plate_barcodes[0] in barcodes:
147-
return False
148-
return True
140+
def is_new_holder_barcode(self, holder_barcode):
141+
return self._store.is_new_holder_barcode(holder_barcode)
142+
149143

0 commit comments

Comments
 (0)