diff --git a/src/components/rfid_pn532.py b/src/components/rfid_pn532.py
index 3a1e4a0..fde6449 100644
--- a/src/components/rfid_pn532.py
+++ b/src/components/rfid_pn532.py
@@ -45,36 +45,37 @@ class RFID_PN532(Component):
@pyqtSlot()
def _get(self):
- if self.mutex.tryLock():
- try:
- if not self.connected:
- self.open_device()
- else:
- target = self.clf.sense(RemoteTarget('106A'), RemoteTarget('106B'), RemoteTarget('212F'))
- if target is not None:
- tag = nfc.tag.activate(self.clf, target)
- if tag is not None:
- self.log.debug("tag present")
- if tag.ndef is not None:
- tag_content=tag.ndef.records[0].text
- if tag_content!=self.current_data:
- self.log.info(f"new tag detected:{tag_content}")
- self.current_data=tag_content
- self.new_id_signal.emit(self.current_data)
- else:
- self.log.error("tag is not NDEF")
+ if not self.simulate:
+ if self.mutex.tryLock():
+ try:
+ if not self.connected:
+ self.open_device()
else:
- if self.current_data:
- self.log.info(f"tag removed:{self.current_data}")
- self.current_data = None
- self.new_id_signal.emit(None)
- self.log.debug("no target present")
+ target = self.clf.sense(RemoteTarget('106A'), RemoteTarget('106B'), RemoteTarget('212F'))
+ if target is not None:
+ tag = nfc.tag.activate(self.clf, target)
+ if tag is not None:
+ self.log.debug("tag present")
+ if tag.ndef is not None:
+ tag_content=tag.ndef.records[0].text
+ if tag_content!=self.current_data:
+ self.log.info(f"new tag detected:{tag_content}")
+ self.current_data=tag_content
+ self.new_id_signal.emit(self.current_data)
+ else:
+ self.log.error("tag is not NDEF")
+ else:
+ if self.current_data:
+ self.log.info(f"tag removed:{self.current_data}")
+ self.current_data = None
+ self.new_id_signal.emit(None)
+ self.log.debug("no target present")
- except Exception as e:
- self.log.info(f"{e}")
- self.connected = False
- finally:
- self.mutex.unlock()
+ except Exception as e:
+ self.log.info(f"{e}")
+ self.connected = False
+ finally:
+ self.mutex.unlock()
def write_tag(self,data):
self.data_to_write=copy.deepcopy(data)
diff --git a/src/components/usb_586x.py b/src/components/usb_586x.py
index 9632f2f..b87b98d 100644
--- a/src/components/usb_586x.py
+++ b/src/components/usb_586x.py
@@ -176,6 +176,7 @@ class USB_586x(Component):
if is_win or self.simulate:
if self.simulate:
read=[1,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0]
+ break
else:
if self.io_ok:
ret = self.di_read(0, self.in_size)
diff --git a/src/lib/helpers/single_process.py b/src/lib/helpers/single_process.py
new file mode 100644
index 0000000..f085123
--- /dev/null
+++ b/src/lib/helpers/single_process.py
@@ -0,0 +1,25 @@
+from PyQt5.QtCore import QSharedMemory
+
+
+class SingleProcess:
+ def __init__(self, key='memory_condition_key'):
+ self._shm = QSharedMemory(key)
+ if not self._shm.attach():
+ if not self._shm.create(1):
+ raise RuntimeError('error creating shared memory: %s' %
+ self._shm.errorString())
+ self.condition = False
+
+ def __enter__(self):
+ self._shm.lock()
+ if self._shm.data()[0] == b'\x00':
+ self.condition = True
+ self._shm.data()[0] = b'\x01'
+ self._shm.unlock()
+ return self.condition
+
+ def __exit__(self, exc_type, exc_value, traceback):
+ if self.condition:
+ self._shm.lock()
+ self._shm.data()[0] = b'\x00'
+ self._shm.unlock()
diff --git a/src/main.py b/src/main.py
index b618aac..fc7f700 100644
--- a/src/main.py
+++ b/src/main.py
@@ -11,6 +11,7 @@ import weakref
from datetime import datetime
from pathlib import Path
+from lib.helpers.single_process import SingleProcess
if platform.system().lower() == "windows":
sys.path.append(f"{os.getcwd()}\src\components")
@@ -254,17 +255,24 @@ try:
if __name__ == "__main__":
app = QApplication(sys.argv)
- main = Main()
- if "--no-gui" not in sys.argv:
- app.exec()
- if "--interact" in sys.argv:
- import code
- import readline
- variables = globals().copy()
- variables.update(locals())
- shell = code.InteractiveConsole(variables)
- shell.interact()
+ with SingleProcess() as single_process_lock:
+ if not single_process_lock:
+ logging.error(f"Program already opened, exiting...")
+ QMessageBox.critical(None, "ERRORE", "IL PROGRAMMA E' GIA' IN ESECUZIONE")
+ exit(0)
+
+ main = Main()
+ if "--no-gui" not in sys.argv:
+ app.exec()
+ if "--interact" in sys.argv:
+ import code
+ import readline
+
+ variables = globals().copy()
+ variables.update(locals())
+ shell = code.InteractiveConsole(variables)
+ shell.interact()
except Exception:
logging.exception(traceback.format_exc())
# extype, value, tb = sys.exc_info()
diff --git a/src/ui/barcode_recipe_selection/barcode_recipe_selection.ui b/src/ui/barcode_recipe_selection/barcode_recipe_selection.ui
index 2805d48..b45d4a3 100644
--- a/src/ui/barcode_recipe_selection/barcode_recipe_selection.ui
+++ b/src/ui/barcode_recipe_selection/barcode_recipe_selection.ui
@@ -6,8 +6,8 @@
0
0
- 1445
- 793
+ 1273
+ 698
@@ -27,30 +27,6 @@
0
-
-
-
-
- 0
- 0
-
-
-
-
- 200
- 200
-
-
-
-
- 12
-
-
-
-
-
-
-
- -
@@ -70,13 +46,11 @@
- 123
-456
-abc
+
- -
+
-
diff --git a/src/ui/test_assembly/test_assembly.ui b/src/ui/test_assembly/test_assembly.ui
index 20f4c1e..ad12a3e 100755
--- a/src/ui/test_assembly/test_assembly.ui
+++ b/src/ui/test_assembly/test_assembly.ui
@@ -6,8 +6,8 @@
0
0
- 94
- 130
+ 627
+ 332
@@ -26,7 +26,7 @@
0
-
-
+
-
@@ -34,11 +34,17 @@
0
+
+
+ 100
+ 100
+
+
- false
+ true
Qt::AlignCenter