Esempio n. 1
0
 def send_status(self):
     """ Sends the current status of the printer to the connected Flectra instance.
     """
     self.data = {
         'value': '',
         'state': self.state,
     }
     event_manager.device_changed(self)
Esempio n. 2
0
    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'] != self.last_sent_value or self._status[
                    'status'] == self.STATUS_ERROR:
                self.last_sent_value = self.data['value']
                event_manager.device_changed(self)
Esempio n. 3
0
 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()
Esempio n. 4
0
    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 Flectra 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)
Esempio n. 5
0
    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'] != self.last_sent_value or self._status[
                        'status'] == self.STATUS_ERROR:
                    self.last_sent_value = self.data['value']
                    event_manager.device_changed(self)
        else:
            time.sleep(0.5)
Esempio n. 6
0
 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)
     elif data.get('action', False) == 'update_is_scanner':
         is_scanner = {'is_scanner': data.get('is_scanner')}
         self.save_is_scanner(is_scanner)
     else:
         self.data['value'] = ''
         event_manager.device_changed(self)
Esempio n. 7
0
 def action(self, data):
     if data.get('action') == "update_url" and self.device_identifier != 'distant_display':
         self.update_url(data.get('url'))
     elif data.get('action') == "display_refresh" and self.device_identifier != 'distant_display':
         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)
Esempio n. 8
0
    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)
Esempio n. 9
0
    def _read_once_action(self, data):
        """Reads the scale current weight value and pushes it to the frontend."""

        self._read_weight()
        self.last_sent_value = self.data['value']
        event_manager.device_changed(self)
Esempio n. 10
0
    def _push_status(self):
        """Updates the current status and pushes it to the frontend."""

        self.data['status'] = self._status
        event_manager.device_changed(self)