def __init__(self, parent=None): QWidget.__init__(self, parent) self.ui = uic.loadUiType('main.ui')[0]() self.ui.setupUi(self) self.localize() self.ui.config.setup(self.ui.terminals, self.ui.payments) self.ui.terminals.ready.connect(self.ui.config.terminals_ready) self.ui.config.terminals_changed.connect(self.ui.terminals.update_model) self.ui.config.terminals_changed.connect(self.enable_buttons) self.ui.payments.session_started.connect(self.session_start) self.ui.payments.session_ended.connect(self.session_end) self.db = LocalDB() self.left_terminals = [] self.right_terminals = [] self.ui.leftUp.clicked.connect(self.left_up) self.ui.leftDown.clicked.connect(self.left_down) self.ui.rightUp.clicked.connect(self.right_up) self.ui.rightDown.clicked.connect(self.right_down) self.ui.payments.new_payment.connect(lambda: self.ui.tabs.setCurrentIndex(1)) self.session_end()
def __init__(self): self.__itsDB = LocalDB() self.__isOnlineDB = False self.__itsKeyMap = dict() self.__isFilterChanged = False self.__itsFilteredHeader = [] self.__itsFilteredData = [] self.__itsSCFLength = 15 pass
def changeLocalDB(self): if self.__isOnlineDB: self.__itsDB = LocalDB() self.__isFilterChanged = False self.__isOnlineDB = False pass
class Main(QWidget): def __init__(self, parent=None): QWidget.__init__(self, parent) self.ui = uic.loadUiType('main.ui')[0]() self.ui.setupUi(self) self.localize() self.ui.config.setup(self.ui.terminals, self.ui.payments) self.ui.terminals.ready.connect(self.ui.config.terminals_ready) self.ui.config.terminals_changed.connect(self.ui.terminals.update_model) self.ui.config.terminals_changed.connect(self.enable_buttons) self.ui.payments.session_started.connect(self.session_start) self.ui.payments.session_ended.connect(self.session_end) self.db = LocalDB() self.left_terminals = [] self.right_terminals = [] self.ui.leftUp.clicked.connect(self.left_up) self.ui.leftDown.clicked.connect(self.left_down) self.ui.rightUp.clicked.connect(self.right_up) self.ui.rightDown.clicked.connect(self.right_down) self.ui.payments.new_payment.connect(lambda: self.ui.tabs.setCurrentIndex(1)) self.session_end() #self.setWindowFlags(Qt.CustomizeWindowHint) def enable_buttons(self): self.left_terminals = self.db.get_terminals_id_by_option('left') self.ui.leftUp.setEnabled(not not self.left_terminals) self.ui.leftDown.setEnabled(not not self.left_terminals) self.right_terminals = \ self.db.get_terminals_id_by_option('right') self.ui.rightUp.setEnabled(not not self.right_terminals) self.ui.rightDown.setEnabled(not not self.right_terminals) def disable_buttons(self): [bt.setEnabled(False) for bt in [self.ui.leftUp, self.ui.leftDown, self.ui.rightUp, self.ui.rightDown]] def session_start(self): [self.ui.tabs.setTabEnabled(i, True) for i in [0, 2]] self.ui.terminals.start_mainloop() self.enable_buttons() def session_end(self): [self.ui.tabs.setTabEnabled(i, False) for i in [0, 2]] self.disable_buttons() self.ui.terminals.stop_mainloop() def localize(self): self.ui.tabs.setTabText(0, _('Terminals')) self.ui.tabs.setTabText(1, _('Payments')) self.ui.tabs.setTabText(2, _('Config')) def left_up(self): for addr in self.left_terminals: self.ui.terminals.terminal_open(addr) def left_down(self): for addr in self.left_terminals: self.ui.terminals.terminal_close(addr) def right_up(self): for addr in self.right_terminals: self.ui.terminals.terminal_open(addr) def right_down(self): for addr in self.right_terminals: self.ui.terminals.terminal_close(addr) #noinspection PyPep8Naming def closeEvent(self, event): self.ui.terminals.stop_mainloop() self.ui.payments.stop_reader() return QWidget.closeEvent(self, event)
import detect from PIL import Image import tflite_runtime.interpreter as tflite import platform from alert_encoder import create_alert from db import LocalDB, persist_alert ON_DEVICE: bool = True # Whether we're on the development machine (ON_DEVICE=False), or on the Pi (ON_DEVICE=True) SLEEP_TIME: int = 1 # second camera = PiCamera() camera.rotation = 180 # in degrees, adjust based on your setup db = LocalDB() EDGETPU_SHARED_LIB = { "Linux": "libedgetpu.so.1", "Darwin": "libedgetpu.1.dylib", "Windows": "edgetpu.dll", }[platform.system()] cur_dir: str = sys.path[0] CONFIG_PATH: str = os.path.join(cur_dir, "config.yaml") with open(CONFIG_PATH, "r") as f: operational_config = yaml.safe_load(f) if "device" not in operational_config: raise Exception("Failed to load configuration") DATE_FORMAT: str = "%Y-%m-%d %H:%M:%S.%f"