fix st-ten-8

This commit is contained in:
neo-dl 2023-08-24 12:10:01 +02:00
parent 86b839aff3
commit b0c101d54c
6 changed files with 87 additions and 72 deletions

View File

@ -45,6 +45,7 @@ class RFID_PN532(Component):
@pyqtSlot()
def _get(self):
if not self.simulate:
if self.mutex.tryLock():
try:
if not self.connected:

View File

@ -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)

View File

@ -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()

View File

@ -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,6 +255,13 @@ try:
if __name__ == "__main__":
app = QApplication(sys.argv)
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()

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>1445</width>
<height>793</height>
<width>1273</width>
<height>698</height>
</rect>
</property>
<property name="windowTitle">
@ -27,30 +27,6 @@
<number>0</number>
</property>
<item row="2" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="state_l">
<property name="sizePolicy">
<sizepolicy hsizetype="Maximum" vsizetype="Maximum">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>200</width>
<height>200</height>
</size>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="3" column="0" alignment="Qt::AlignHCenter">
<widget class="QPlainTextEdit" name="barcode_input_l">
<property name="minimumSize">
<size>
@ -70,13 +46,11 @@
</font>
</property>
<property name="plainText">
<string>123
456
abc</string>
<string/>
</property>
</widget>
</item>
<item row="4" column="0" alignment="Qt::AlignHCenter">
<item row="3" column="0" alignment="Qt::AlignHCenter">
<widget class="QPushButton" name="recipe_selection_b">
<property name="font">
<font>

View File

@ -6,8 +6,8 @@
<rect>
<x>0</x>
<y>0</y>
<width>94</width>
<height>130</height>
<width>627</width>
<height>332</height>
</rect>
</property>
<property name="windowTitle">
@ -26,7 +26,7 @@
<property name="bottomMargin">
<number>0</number>
</property>
<item row="0" column="0">
<item row="0" column="0" alignment="Qt::AlignHCenter">
<widget class="QLabel" name="img_l">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
@ -34,11 +34,17 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>100</width>
<height>100</height>
</size>
</property>
<property name="text">
<string/>
</property>
<property name="scaledContents">
<bool>false</bool>
<bool>true</bool>
</property>
<property name="alignment">
<set>Qt::AlignCenter</set>