fix st-ten-8
This commit is contained in:
parent
86b839aff3
commit
b0c101d54c
@ -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)
|
||||
|
||||
@ -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)
|
||||
|
||||
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 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()
|
||||
|
||||
@ -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>
|
||||
|
||||
@ -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>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user