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: if self.submit_page_at:
return "submitted by worker" return "submitted by worker"
if self.open_page_at: if self.open_page_at:
return "started working" return "working"
if self.accept_time: if self.accept_time:
return "accepted by worker" return "accepted by worker"
return "created" return "created"

View file

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