Status changes

This commit is contained in:
Ruben van de Ven 2019-11-01 20:31:39 +01:00
parent 964c9406ba
commit 7d07edb5de
2 changed files with 8 additions and 2 deletions

View file

@ -72,7 +72,7 @@ class HIT(Base):
if self.submit_page_at:
return "submitted by worker"
if self.open_page_at:
return "started working"
return "working"
if self.accept_time:
return "accepted by worker"
return "created"

View file

@ -160,7 +160,6 @@ class CentralManagement():
self.currentHit.submit_page_at = datetime.datetime.utcnow()
self.store.saveHIT(self.currentHit)
self.plotter.park()
self.server.statusPage.set('state', self.currentHit.getStatus())
self.server.statusPage.set('hit_opened', self.currentHit.open_page_at)
# park always triggers a plotter.finished after being processed
@ -218,15 +217,19 @@ class CentralManagement():
self.store.saveHIT(sqsHit)
if updateStatus:
self.logger.warning(f'update status: {sqsHit.getStatus()}')
# TODO: have HITStore/HIT take care of this by emitting a signal
# only update status if it is the currentHit
self.server.statusPage.set('state', sqsHit.getStatus())
else:
self.logger.warning('DO NOT update status')
elif signal.name == 'plotter.finished':
if self.currentHit.submit_page_at:
self.setLight(False)
scan = threading.Thread(target=self.scanImage, name='scan')
scan.start()
self.server.statusPage.set('hit_submitted', self.currentHit.submit_page_at)
self.server.statusPage.set('state', self.currentHit.getStatus())
else:
self.logger.critical(f"Unknown signal: {signal.name}")
@ -303,6 +306,7 @@ class CentralManagement():
proc = subprocess.Popen(cmd, stdout=subprocess.DEVNULL, stderr=subprocess.PIPE)
# opens connection to scanner, but only starts scanning when output becomes ready:
_, e = proc.communicate(80)
time.sleep(5) # sleep a few seconds for scanner to return to start position
if e:
self.logger.critical(f"Scanner caused: {e.decode()}")
@ -347,6 +351,8 @@ class CentralManagement():
# TODO: create
copyfile('www/basic.svg', filename)
time.sleep(5) # sleep a few seconds for scanner to return to start position
self.eventQueue.put(Signal('hit.scanned', {'hit_id':self.currentHit.id}))
self.eventQueue.put(Signal('scan.finished'))