mirror of
https://github.com/TheFunny/ArisuAutoSweeper
synced 2025-12-16 15:35:12 +00:00
fix: improve data update stability
This commit is contained in:
parent
44b6d5cdf8
commit
e71118c09e
@ -12,7 +12,10 @@ class DataUpdate(UI):
|
||||
Page:
|
||||
in: page_work
|
||||
"""
|
||||
ap = DigitCounter(OCR_AP).ocr_single_line(self.device.image)
|
||||
ap, _, ap_total = DigitCounter(OCR_AP).ocr_single_line(self.device.image)
|
||||
if ap_total == 0:
|
||||
logger.warning('Invalid AP')
|
||||
return False
|
||||
# Data for Credit and Pyroxene
|
||||
ocr = Digit(OCR_DATA)
|
||||
timeout = Timer(2, count=6).start()
|
||||
@ -21,27 +24,28 @@ class DataUpdate(UI):
|
||||
if len(data) != 2:
|
||||
data = [data[0], data[-1]]
|
||||
logger.attr('Data', data)
|
||||
credit, pyroxene = [int(''.join([v for v in d.ocr_text if v.isdigit()])) for d in data]
|
||||
credit, pyroxene = [int(''.join(filter(lambda x: x.isdigit(), d.ocr_text))) for d in data]
|
||||
if credit > 0 or pyroxene > 0:
|
||||
break
|
||||
|
||||
logger.warning(f'Invalid credit and pyroxene: {data}')
|
||||
if timeout.reached():
|
||||
logger.warning('Get data timeout')
|
||||
break
|
||||
return False
|
||||
|
||||
logger.attr('Credit', credit)
|
||||
logger.attr('Pyroxene', pyroxene)
|
||||
with self.config.multi_set():
|
||||
self.config.stored.AP.set(ap[0], ap[2])
|
||||
self.config.stored.AP.set(ap, ap_total)
|
||||
self.config.stored.Credit.value = credit
|
||||
self.config.stored.Pyroxene.value = pyroxene
|
||||
|
||||
return ap, credit, pyroxene
|
||||
return True
|
||||
|
||||
def run(self):
|
||||
self.ui_ensure(page_work, acquire_lang_checked=False)
|
||||
|
||||
with self.config.multi_set():
|
||||
self._get_data()
|
||||
if self._get_data():
|
||||
self.config.task_delay(server_update=True)
|
||||
else:
|
||||
self.config.task_delay(minute=1)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user