dev rfid new featured wip
This commit is contained in:
parent
89565ef276
commit
ceebe6ad6c
@ -3,7 +3,7 @@ import ctypes
|
|||||||
import sys
|
import sys
|
||||||
import platform
|
import platform
|
||||||
from PyQt5.QtCore import QMutex, Qt, QTimer, pyqtSlot, pyqtSignal
|
from PyQt5.QtCore import QMutex, Qt, QTimer, pyqtSlot, pyqtSignal
|
||||||
from .component import Component
|
from src.components import Component
|
||||||
import ndef
|
import ndef
|
||||||
import src.lib.nfc
|
import src.lib.nfc
|
||||||
from src.lib.nfc.clf import RemoteTarget
|
from src.lib.nfc.clf import RemoteTarget
|
||||||
|
|||||||
@ -6,14 +6,52 @@ from PyQt5 import Qt
|
|||||||
from lib.helpers import timing
|
from lib.helpers import timing
|
||||||
from PyQt5.QtCore import Qt, QTimer, QThread
|
from PyQt5.QtCore import Qt, QTimer, QThread
|
||||||
from PyQt5.QtGui import QKeySequence, QPixmap, QPalette, QColor
|
from PyQt5.QtGui import QKeySequence, QPixmap, QPalette, QColor
|
||||||
from PyQt5.QtWidgets import QShortcut, QApplication
|
from PyQt5.QtWidgets import QShortcut, QApplication, QDialog, QVBoxLayout, QLabel, QPushButton, QPlainTextEdit, \
|
||||||
|
QHBoxLayout, QMessageBox
|
||||||
|
|
||||||
from ui.test_test import Test_Test
|
from ui.test_test import Test_Test
|
||||||
from ui.widget import Widget
|
from ui.widget import Widget
|
||||||
from lib import db
|
from lib import db
|
||||||
from lib.db.models import Recipes
|
from lib.db.models import Recipes , Users
|
||||||
test_scan="xxx\nyyy\nzzz"
|
test_scan="xxx\nyyy\nzzz"
|
||||||
|
|
||||||
|
|
||||||
|
class TagWindow(QDialog):
|
||||||
|
def __init__(self, parent=None):
|
||||||
|
super().__init__(parent)
|
||||||
|
|
||||||
|
self.setWindowTitle("Scrittura NFC")
|
||||||
|
self.setFixedSize(400, 300)
|
||||||
|
|
||||||
|
layout = QVBoxLayout(self)
|
||||||
|
|
||||||
|
|
||||||
|
self.text_edit = QPlainTextEdit(self)
|
||||||
|
self.text_edit.setPlaceholderText("Scanerizza il QRcode della Dima")
|
||||||
|
self.text_edit.setFixedHeight(100)
|
||||||
|
|
||||||
|
|
||||||
|
layout.addWidget(self.text_edit)
|
||||||
|
button_layout = QHBoxLayout()
|
||||||
|
|
||||||
|
|
||||||
|
self.ok_button = QPushButton("Conferma Tag", self)
|
||||||
|
self.ok_button.clicked.connect(self.on_ok_clicked)
|
||||||
|
|
||||||
|
# Create the Close button
|
||||||
|
self.close_button = QPushButton("Chiudi", self)
|
||||||
|
self.close_button.clicked.connect(self.close)
|
||||||
|
|
||||||
|
button_layout.addWidget(self.ok_button)
|
||||||
|
button_layout.addWidget(self.close_button)
|
||||||
|
layout.addLayout(button_layout)
|
||||||
|
|
||||||
|
def on_ok_clicked(self):
|
||||||
|
entered_text = self.text_edit.toPlainText()
|
||||||
|
print(f"Text Entered: {entered_text}")
|
||||||
|
self.accept()
|
||||||
|
|
||||||
|
|
||||||
class Barcode_Recipe_Selection(Test_Test):
|
class Barcode_Recipe_Selection(Test_Test):
|
||||||
def __init__(self, parent):
|
def __init__(self, parent):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
@ -34,6 +72,8 @@ class Barcode_Recipe_Selection(Test_Test):
|
|||||||
self.status_palettes["warning"].setColor(QPalette.Base, QColor(255, 165, 0))
|
self.status_palettes["warning"].setColor(QPalette.Base, QColor(255, 165, 0))
|
||||||
self.status_palettes[""].setColor(QPalette.Base, QColor(255, 255, 0))
|
self.status_palettes[""].setColor(QPalette.Base, QColor(255, 255, 0))
|
||||||
|
|
||||||
|
self.tag_b.clicked.connect(self.open_tag_window)
|
||||||
|
|
||||||
self.recipe_selection_b.clicked.connect(self.parent.set_recipe_mode_table)
|
self.recipe_selection_b.clicked.connect(self.parent.set_recipe_mode_table)
|
||||||
self.barcode_input_l.setFocus()
|
self.barcode_input_l.setFocus()
|
||||||
|
|
||||||
@ -49,6 +89,12 @@ class Barcode_Recipe_Selection(Test_Test):
|
|||||||
self.ok_timer.setSingleShot(True)
|
self.ok_timer.setSingleShot(True)
|
||||||
self.ok_timer.timeout.connect(self.set_recipe)
|
self.ok_timer.timeout.connect(self.set_recipe)
|
||||||
|
|
||||||
|
session= Users.get_session()
|
||||||
|
|
||||||
|
if session.is_admin:
|
||||||
|
self.tag_b.setVisible(True)
|
||||||
|
else:
|
||||||
|
self.tag_b.setVisible(False)
|
||||||
|
|
||||||
def start(self, recipe=None, step=None, pieces=None):
|
def start(self, recipe=None, step=None, pieces=None):
|
||||||
|
|
||||||
@ -113,4 +159,35 @@ class Barcode_Recipe_Selection(Test_Test):
|
|||||||
self.parent_assembly_widget().set_text("SCANSIONARE BARCODE SELEZIONE RICETTA")
|
self.parent_assembly_widget().set_text("SCANSIONARE BARCODE SELEZIONE RICETTA")
|
||||||
|
|
||||||
|
|
||||||
|
def open_tag_window(self):
|
||||||
|
|
||||||
|
# Open the tag writing window
|
||||||
|
self.tag_window = TagWindow(self)
|
||||||
|
result = self.tag_window.exec_() # Get the result of the dialog (OK or Cancel)
|
||||||
|
if result != QDialog.Accepted:
|
||||||
|
return # If canceled, return
|
||||||
|
|
||||||
|
entered_text = self.tag_window.text_edit.toPlainText().strip()
|
||||||
|
if not entered_text:
|
||||||
|
QMessageBox.warning(
|
||||||
|
self,
|
||||||
|
"Warning",
|
||||||
|
"The text is empty. Please enter text to write to the tag.",
|
||||||
|
)
|
||||||
|
return
|
||||||
|
|
||||||
|
# Check if the tag is empty
|
||||||
|
if self.parent.components["fixture_id"].current_data:
|
||||||
|
# Tag already contains data, ask for confirmation to overwrite
|
||||||
|
confirmation_result = QMessageBox.question(
|
||||||
|
self,
|
||||||
|
"Tag Already Written",
|
||||||
|
"The tag already contains data. Do you want to overwrite it?",
|
||||||
|
QMessageBox.Yes | QMessageBox.No,
|
||||||
|
)
|
||||||
|
if confirmation_result == QMessageBox.No:
|
||||||
|
return # User does not want to overwrite, so return without writing
|
||||||
|
|
||||||
|
# Write the entered text to the tag
|
||||||
|
self.parent.components["fixture_id"].write_tag(entered_text)
|
||||||
|
QMessageBox.information(self, "Success", "The tag has been successfully written.")
|
||||||
|
|||||||
@ -13,54 +13,146 @@
|
|||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Test Connector</string>
|
<string>Test Connector</string>
|
||||||
</property>
|
</property>
|
||||||
<layout class="QGridLayout" name="gridLayout">
|
<layout class="QGridLayout" name="gridLayout_3">
|
||||||
<property name="leftMargin">
|
<item row="0" column="0">
|
||||||
<number>0</number>
|
<layout class="QGridLayout" name="gridLayout_2">
|
||||||
</property>
|
<item row="0" column="0">
|
||||||
<property name="topMargin">
|
<layout class="QGridLayout" name="gridLayout">
|
||||||
<number>0</number>
|
<item row="1" column="3">
|
||||||
</property>
|
<spacer name="horizontalSpacer_2">
|
||||||
<property name="rightMargin">
|
<property name="orientation">
|
||||||
<number>0</number>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="bottomMargin">
|
<property name="sizeHint" stdset="0">
|
||||||
<number>0</number>
|
<size>
|
||||||
</property>
|
<width>308</width>
|
||||||
<item row="2" column="0" alignment="Qt::AlignHCenter">
|
<height>20</height>
|
||||||
<widget class="QPlainTextEdit" name="barcode_input_l">
|
</size>
|
||||||
<property name="minimumSize">
|
</property>
|
||||||
<size>
|
</spacer>
|
||||||
<width>600</width>
|
</item>
|
||||||
<height>0</height>
|
<item row="4" column="1" colspan="2">
|
||||||
</size>
|
<widget class="QPushButton" name="recipe_selection_b">
|
||||||
</property>
|
<property name="font">
|
||||||
<property name="maximumSize">
|
<font>
|
||||||
<size>
|
<pointsize>20</pointsize>
|
||||||
<width>600</width>
|
</font>
|
||||||
<height>200</height>
|
</property>
|
||||||
</size>
|
<property name="text">
|
||||||
</property>
|
<string>TORNA ALLA TABELLA RICETTE</string>
|
||||||
<property name="font">
|
</property>
|
||||||
<font>
|
</widget>
|
||||||
<pointsize>20</pointsize>
|
</item>
|
||||||
</font>
|
<item row="1" column="1" rowspan="2" colspan="2">
|
||||||
</property>
|
<widget class="QPlainTextEdit" name="barcode_input_l">
|
||||||
<property name="plainText">
|
<property name="minimumSize">
|
||||||
<string/>
|
<size>
|
||||||
</property>
|
<width>600</width>
|
||||||
</widget>
|
<height>0</height>
|
||||||
</item>
|
</size>
|
||||||
<item row="3" column="0" alignment="Qt::AlignHCenter">
|
</property>
|
||||||
<widget class="QPushButton" name="recipe_selection_b">
|
<property name="maximumSize">
|
||||||
<property name="font">
|
<size>
|
||||||
<font>
|
<width>600</width>
|
||||||
<pointsize>20</pointsize>
|
<height>200</height>
|
||||||
</font>
|
</size>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="font">
|
||||||
<string>TORNA ALLA TABELLA RICETTE</string>
|
<font>
|
||||||
</property>
|
<pointsize>20</pointsize>
|
||||||
</widget>
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="plainText">
|
||||||
|
<string/>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="1">
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>78</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<spacer name="horizontalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Horizontal</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>378</width>
|
||||||
|
<height>20</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="3" column="2">
|
||||||
|
<spacer name="verticalSpacer_3">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>78</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
<item row="0" column="1">
|
||||||
|
<spacer name="verticalSpacer_4">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>168</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QPushButton" name="tag_b">
|
||||||
|
<property name="sizePolicy">
|
||||||
|
<sizepolicy hsizetype="Fixed" vsizetype="Fixed">
|
||||||
|
<horstretch>0</horstretch>
|
||||||
|
<verstretch>0</verstretch>
|
||||||
|
</sizepolicy>
|
||||||
|
</property>
|
||||||
|
<property name="font">
|
||||||
|
<font>
|
||||||
|
<pointsize>11</pointsize>
|
||||||
|
</font>
|
||||||
|
</property>
|
||||||
|
<property name="text">
|
||||||
|
<string>SCRIVI TAG NFC</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="1" column="0">
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>28</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
|
</layout>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user