def _take_measure(self): """Reads the device's weight value, and pushes that value to the frontend.""" with self._device_lock: self._read_weight() if self.data['value'] is not None or self._status[ 'status'] == self.STATUS_ERROR: event_manager.device_changed(self)
def _keyboard_input(self, scancode): """Deal with a keyboard input. Send the character corresponding to the pressed key represented by its scancode to the connected COffice instance. Args: scancode (int): The scancode of the pressed key. """ self.data['value'] = self._scancode_to_char(scancode) if self.data['value']: event_manager.device_changed(self)
def take_control(self, new_owner, html=None): # ALLOW A CASHIER TO TAKE CONTROL OVER THE POSBOX, IN CASE OF MULTIPLE CASHIER PER DISPLAY self.owner = new_owner self.rendered_html = html self.data = { 'value': '', 'owner': self.owner, } event_manager.device_changed(self) self.event_data.set()
def action(self, data): if data.get('action', False) == 'update_layout': layout = { 'layout': data.get('layout'), 'variant': data.get('variant'), } self._change_keyboard_layout(layout) self.save_layout(layout) else: self.data['value'] = '' event_manager.device_changed(self)
def _take_measure(self): """Reads the device's weight value, and pushes that value to the frontend.""" if self._is_reading: with self._device_lock: self._read_weight() self._check_last_weight_time() if self.data['value'] is not None or self._status[ 'status'] == self.STATUS_ERROR: event_manager.device_changed(self) else: time.sleep(0.5)
def action(self, data): if data.get('action') == "update_url": self.update_url(data.get('url')) elif data.get('action') == "display_refresh": self.call_xdotools('F5') elif data.get('action') == "take_control": self.take_control(self.data['owner'], data.get('html')) elif data.get('action') == "customer_facing_display": self.update_customer_facing_display(self.data['owner'], data.get('html')) elif data.get('action') == "get_owner": self.data = { 'value': '', 'owner': self.owner, } event_manager.device_changed(self)
def _barcode_scanner_input(self, scancode): """Deal with a barcode scanner input. Add the new character scanned to the current barcode or complete the barcode if "Return" is pressed. When a barcode is completed, two tasks are performed: - Send a device_changed update to the event manager to notify the listeners that the value has changed (used in Enterprise). - Add the barcode to the list barcodes that are being queried in Community. Args: scancode (int): The scancode of the pressed key. """ if scancode == 28: # Return self.data['value'] = self._current_barcode event_manager.device_changed(self) self._barcodes.put((time.time(), self._current_barcode)) self._current_barcode = '' else: self._current_barcode += self._scancode_to_char(scancode)
def _read_once_action(self, data): """Reads the scale current weight value and pushes it to the frontend.""" self._read_weight() event_manager.device_changed(self)
def _push_status(self): """Updates the current status and pushes it to the frontend.""" self.data['status'] = self._status event_manager.device_changed(self)