fix st-ten-8
This commit is contained in:
parent
86b839aff3
commit
b0c101d54c
@ -45,36 +45,37 @@ class RFID_PN532(Component):
|
|||||||
|
|
||||||
@pyqtSlot()
|
@pyqtSlot()
|
||||||
def _get(self):
|
def _get(self):
|
||||||
if self.mutex.tryLock():
|
if not self.simulate:
|
||||||
try:
|
if self.mutex.tryLock():
|
||||||
if not self.connected:
|
try:
|
||||||
self.open_device()
|
if not self.connected:
|
||||||
else:
|
self.open_device()
|
||||||
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:
|
else:
|
||||||
if self.current_data:
|
target = self.clf.sense(RemoteTarget('106A'), RemoteTarget('106B'), RemoteTarget('212F'))
|
||||||
self.log.info(f"tag removed:{self.current_data}")
|
if target is not None:
|
||||||
self.current_data = None
|
tag = nfc.tag.activate(self.clf, target)
|
||||||
self.new_id_signal.emit(None)
|
if tag is not None:
|
||||||
self.log.debug("no target present")
|
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:
|
except Exception as e:
|
||||||
self.log.info(f"{e}")
|
self.log.info(f"{e}")
|
||||||
self.connected = False
|
self.connected = False
|
||||||
finally:
|
finally:
|
||||||
self.mutex.unlock()
|
self.mutex.unlock()
|
||||||
|
|
||||||
def write_tag(self,data):
|
def write_tag(self,data):
|
||||||
self.data_to_write=copy.deepcopy(data)
|
self.data_to_write=copy.deepcopy(data)
|
||||||
|
|||||||
@ -176,6 +176,7 @@ class USB_586x(Component):
|
|||||||
if is_win or self.simulate:
|
if is_win or self.simulate:
|
||||||
if self.simulate:
|
if self.simulate:
|
||||||
read=[1,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0]
|
read=[1,0,0,0,0,0,0,0],[0,0,0,0,0,0,0,0]
|
||||||
|
break
|
||||||
else:
|
else:
|
||||||
if self.io_ok:
|
if self.io_ok:
|
||||||
ret = self.di_read(0, self.in_size)
|
ret = self.di_read(0, self.in_size)
|
||||||
|
|||||||
25
src/lib/helpers/single_process.py
Normal file
25
src/lib/helpers/single_process.py
Normal 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()
|
||||||
28
src/main.py
28
src/main.py
@ -11,6 +11,7 @@ import weakref
|
|||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
|
from lib.helpers.single_process import SingleProcess
|
||||||
|
|
||||||
if platform.system().lower() == "windows":
|
if platform.system().lower() == "windows":
|
||||||
sys.path.append(f"{os.getcwd()}\src\components")
|
sys.path.append(f"{os.getcwd()}\src\components")
|
||||||
@ -254,17 +255,24 @@ try:
|
|||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
app = QApplication(sys.argv)
|
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()
|
with SingleProcess() as single_process_lock:
|
||||||
variables.update(locals())
|
if not single_process_lock:
|
||||||
shell = code.InteractiveConsole(variables)
|
logging.error(f"Program already opened, exiting...")
|
||||||
shell.interact()
|
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:
|
except Exception:
|
||||||
logging.exception(traceback.format_exc())
|
logging.exception(traceback.format_exc())
|
||||||
# extype, value, tb = sys.exc_info()
|
# extype, value, tb = sys.exc_info()
|
||||||
|
|||||||
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>1445</width>
|
<width>1273</width>
|
||||||
<height>793</height>
|
<height>698</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -27,30 +27,6 @@
|
|||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="2" column="0" alignment="Qt::AlignHCenter">
|
<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">
|
<widget class="QPlainTextEdit" name="barcode_input_l">
|
||||||
<property name="minimumSize">
|
<property name="minimumSize">
|
||||||
<size>
|
<size>
|
||||||
@ -70,13 +46,11 @@
|
|||||||
</font>
|
</font>
|
||||||
</property>
|
</property>
|
||||||
<property name="plainText">
|
<property name="plainText">
|
||||||
<string>123
|
<string/>
|
||||||
456
|
|
||||||
abc</string>
|
|
||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="4" column="0" alignment="Qt::AlignHCenter">
|
<item row="3" column="0" alignment="Qt::AlignHCenter">
|
||||||
<widget class="QPushButton" name="recipe_selection_b">
|
<widget class="QPushButton" name="recipe_selection_b">
|
||||||
<property name="font">
|
<property name="font">
|
||||||
<font>
|
<font>
|
||||||
|
|||||||
@ -6,8 +6,8 @@
|
|||||||
<rect>
|
<rect>
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>94</width>
|
<width>627</width>
|
||||||
<height>130</height>
|
<height>332</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
@ -26,7 +26,7 @@
|
|||||||
<property name="bottomMargin">
|
<property name="bottomMargin">
|
||||||
<number>0</number>
|
<number>0</number>
|
||||||
</property>
|
</property>
|
||||||
<item row="0" column="0">
|
<item row="0" column="0" alignment="Qt::AlignHCenter">
|
||||||
<widget class="QLabel" name="img_l">
|
<widget class="QLabel" name="img_l">
|
||||||
<property name="sizePolicy">
|
<property name="sizePolicy">
|
||||||
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
<sizepolicy hsizetype="Minimum" vsizetype="Minimum">
|
||||||
@ -34,11 +34,17 @@
|
|||||||
<verstretch>0</verstretch>
|
<verstretch>0</verstretch>
|
||||||
</sizepolicy>
|
</sizepolicy>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="minimumSize">
|
||||||
|
<size>
|
||||||
|
<width>100</width>
|
||||||
|
<height>100</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string/>
|
<string/>
|
||||||
</property>
|
</property>
|
||||||
<property name="scaledContents">
|
<property name="scaledContents">
|
||||||
<bool>false</bool>
|
<bool>true</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="alignment">
|
<property name="alignment">
|
||||||
<set>Qt::AlignCenter</set>
|
<set>Qt::AlignCenter</set>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user