Change management of state : we assume the printer is online. Otherwise,
because this is a real-time command, we might not get the good answer and fail to print fast enough. See https://download4.epson.biz/sec_pubs/pos/reference_en/escpos/realtime_commands.html
This commit is contained in:
@@ -322,22 +322,29 @@ class EscPosPrinter(Printer):
|
|||||||
self.app.logger.info("Did a cut")
|
self.app.logger.info("Did a cut")
|
||||||
self.ready = True
|
self.ready = True
|
||||||
|
|
||||||
def _state(self):
|
def _state(self) -> bool:
|
||||||
self.app.logger.debug("Online : %s " , self.printer.is_online())
|
has_paper = self._has_paper()
|
||||||
self.app.logger.debug("Has paper : %s " , self._has_paper())
|
is_ready = self.ready
|
||||||
self.app.logger.debug("Ready : %s " , self.ready)
|
|
||||||
return self.printer.is_online() and self.ready and self._has_paper()
|
self.app.logger.debug("Has paper : %s " , has_paper )
|
||||||
|
self.app.logger.debug("Ready : %s " , is_ready )
|
||||||
|
|
||||||
|
return is_ready and has_paper # and is_online
|
||||||
|
|
||||||
def print_task(self, task_type, data):
|
def print_task(self, task_type, data):
|
||||||
"""Execute actual print based on task type"""
|
"""Execute actual print based on task type"""
|
||||||
|
|
||||||
|
|
||||||
with self._lock:
|
with self._lock:
|
||||||
self.app.logger.debug("Acquired lock to start print")
|
self.app.logger.debug("Acquired lock to start print")
|
||||||
|
|
||||||
while not self._state():
|
i_m_ready = self._state()
|
||||||
self.app.logger.debug("Waiting for the printer to become ready..")
|
while not i_m_ready:
|
||||||
|
self.app.logger.debug("Waiting for the printer to become ready, current state %s ", str(i_m_ready))
|
||||||
|
i_m_ready = self._state()
|
||||||
time.sleep(0.3)
|
time.sleep(0.3)
|
||||||
|
|
||||||
self.app.logger.debug("Checked state to start printing %s", self._state())
|
self.app.logger.debug("Checked state to start printing : %s", self._state())
|
||||||
self.ready = False
|
self.ready = False
|
||||||
try:
|
try:
|
||||||
self.app.logger.debug("Checking task type")
|
self.app.logger.debug("Checking task type")
|
||||||
|
|||||||
Reference in New Issue
Block a user