Duration only from last speech and other updates to panopticon

This commit is contained in:
Ruben van de Ven 2019-11-14 16:00:41 +01:00
parent 31d62a9710
commit 7cf2cca16e
5 changed files with 32 additions and 15 deletions

View file

@ -158,7 +158,7 @@ class CentralCommand(object):
# status['history'] = hv.story.getLogSummary() # disabled as it is a bit slow. We now have eventLog
# status['counts'] = {t: len(a) for t, a in status['history'].items() if t != 'directions' }
status['counts'] = {} if not hv.story else hv.story.getLogCounts()
status['duration'] = 0 if not hv.story else (hv.story.timer.getElapsed('first_speech') if hv.story.timer.hasMark('first_speech') else hv.story.timer.getElapsed())
status['duration'] = None if not hv.story else (hv.story.timer.getElapsed('first_speech') if hv.story.timer.hasMark('first_speech') else None)
status['has_state'] = Story.hugveyHasSavedState(hv.lightId)
status['variables'] = {} if not isSelected or not hv.story else hv.story.variableValues
@ -735,6 +735,7 @@ class HugveyState(object):
self.logger.info(f"set language: {language_code}")
self.language_code = language_code
self.future_language_code = language_code
if self.google:
self.google.setLanguage(language_code)

View file

@ -119,32 +119,40 @@ def getWebSocketHandler(central_command):
self.__class__.selections[self] = int(hv_id)
def msgBlock(self, hv_id):
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'block'})
if central_command.hugveys[hv_id].eventQueue:
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'block'})
def msgUnblock(self, hv_id):
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'unblock'})
if central_command.hugveys[hv_id].eventQueue:
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'unblock'})
def msgResume(self, hv_id):
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'resume'})
if central_command.hugveys[hv_id].eventQueue:
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'resume'})
def msgPause(self, hv_id):
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'pause'})
if central_command.hugveys[hv_id].eventQueue:
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'pause'})
def msgRestart(self, hv_id):
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'restart'})
if central_command.hugveys[hv_id].eventQueue:
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'restart'})
def msgFinish(self, hv_id):
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'finish'})
if central_command.hugveys[hv_id].eventQueue:
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'finish'})
def msgChangeLanguage(self, hv_id, lang_code):
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_language', 'lang_code': lang_code})
if central_command.hugveys[hv_id].eventQueue:
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_language', 'lang_code': lang_code})
def msgChangeLanguageForAllAvailableHugveys(self, lang_code):
"""
Set language for all future hugvey runs (so after a 'finish')
"""
for hv_id in central_command.hugveys:
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_language_if_available', 'lang_code': lang_code})
if central_command.hugveys[hv_id].eventQueue:
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_language_if_available', 'lang_code': lang_code})
def msgSetLoopTime(self, loop_time):
parts = loop_time.split(":")
@ -161,13 +169,16 @@ def getWebSocketHandler(central_command):
central_command.setLoopTime(seconds)
def msgChangeLightId(self, hv_id, lightId):
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_light', 'light_id': lightId})
if central_command.hugveys[hv_id].eventQueue:
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_light', 'light_id': lightId})
def msgChangeLightStatus(self, hv_id, status):
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_light_status', 'status': status})
if central_command.hugveys[hv_id].eventQueue:
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_light_status', 'status': status})
def msgPlayMsg(self, hv_id, msg_id, reloadStory):
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'play_msg', 'msg_id': msg_id, 'reloadStory':bool(reloadStory)})
if central_command.hugveys[hv_id].eventQueue:
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'play_msg', 'msg_id': msg_id, 'reloadStory':bool(reloadStory)})
@classmethod
def rmConnection(cls, client):

View file

@ -1808,7 +1808,11 @@ class Story(object):
self.logger.info("Current message: ({0}) \"{1}\"".format(
message.id, message.getText()))
self.addToLog(message)
if message.id != self.story.startMessage.id:
self.addToLog(message)
else:
self.logger.debug("Not counting start message")
self.hugvey.eventLogger.info(f"message: {message.id} {message.uuid} start \"{message.getText()}\"")
# TODO: prep events & timer etc.

View file

@ -27,7 +27,7 @@
@click="showHugvey(hv)"
>
<h1>
{{ hv.id }}
{{ hv.light_id }} <span v-if="hv.id != hv.light_id">(#{{hv.id}})</span>
</h1>
<div class='status'>{{ hv.status }}</div>
<div v-if="hv.status != 'off' && hv.status != 'gone' && hv.status != 'loading'">
@ -53,7 +53,7 @@
<img class='icon' src="/images/icon-position.svg" title="position">
{{ hv.msg }}
</div>
<div class='timer'>
<div class='timer' v-if="hv.duration">
<img class='icon' src="/images/icon-clock.svg" title="timer">
{{ timer(hv, 'duration') }}
</div>

View file

@ -171,6 +171,7 @@ img.icon{
position: absolute;
left: 5px;
top: 5px;
font-size:150%;
}
.status{