Story now loops if configured to do so. Also light controls to Panopticon
This commit is contained in:
parent
39dbf0502a
commit
8ca727b015
9 changed files with 52 additions and 13 deletions
|
@ -118,7 +118,9 @@ class CentralCommand(object):
|
||||||
# status['status'] = 'off'
|
# status['status'] = 'off'
|
||||||
# return status
|
# return status
|
||||||
|
|
||||||
|
#: :type hv: HugveyState
|
||||||
status['status'] = hv.getStatus()
|
status['status'] = hv.getStatus()
|
||||||
|
status['light_on'] = bool(hv.lightStatus)
|
||||||
status['language'] = hv.language_code
|
status['language'] = hv.language_code
|
||||||
status['light_id'] = hv.lightId
|
status['light_id'] = hv.lightId
|
||||||
status['msg'] = hv.story.currentMessage.id if hv.story and hv.story.currentMessage else None
|
status['msg'] = hv.story.currentMessage.id if hv.story and hv.story.currentMessage else None
|
||||||
|
@ -280,6 +282,7 @@ class CentralCommand(object):
|
||||||
if not r:
|
if not r:
|
||||||
# stop if False, ie. when stream has gone
|
# stop if False, ie. when stream has gone
|
||||||
return
|
return
|
||||||
|
|
||||||
logger.critical(f'Hugvey stopped (crashed?). Reinstantiate after 5 sec')
|
logger.critical(f'Hugvey stopped (crashed?). Reinstantiate after 5 sec')
|
||||||
time.sleep(5)
|
time.sleep(5)
|
||||||
|
|
||||||
|
@ -438,6 +441,7 @@ class HugveyState(object):
|
||||||
self.recorder = None
|
self.recorder = None
|
||||||
self.notShuttingDown = True # TODO: allow shutdown of object
|
self.notShuttingDown = True # TODO: allow shutdown of object
|
||||||
self.startMsgId = None
|
self.startMsgId = None
|
||||||
|
self.lightStatus = 0
|
||||||
self.eventLogger = eventLogger.getChild(f"{self.id}")
|
self.eventLogger = eventLogger.getChild(f"{self.id}")
|
||||||
|
|
||||||
self.setStatus(self.STATE_GONE)
|
self.setStatus(self.STATE_GONE)
|
||||||
|
@ -452,8 +456,12 @@ class HugveyState(object):
|
||||||
|
|
||||||
def setStatus(self, status):
|
def setStatus(self, status):
|
||||||
self.status = status
|
self.status = status
|
||||||
|
|
||||||
|
# if the story is looping, light should not go off when the story starts
|
||||||
|
if status != self.STATE_RUNNING or self.command.config['story']['loop'] is False:
|
||||||
lightOn = status in [self.STATE_AVAILABLE, self.STATE_PAUSE]
|
lightOn = status in [self.STATE_AVAILABLE, self.STATE_PAUSE]
|
||||||
self.setLightStatus(lightOn)
|
self.setLightStatus(lightOn)
|
||||||
|
|
||||||
self.eventLogger.info(f"status: {self.status}")
|
self.eventLogger.info(f"status: {self.status}")
|
||||||
|
|
||||||
def config(self, hostname, ip):
|
def config(self, hostname, ip):
|
||||||
|
@ -504,6 +512,7 @@ class HugveyState(object):
|
||||||
# TODO: test proper functioning
|
# TODO: test proper functioning
|
||||||
self.shutdown()
|
self.shutdown()
|
||||||
|
|
||||||
|
|
||||||
def queueEvent(self, msg):
|
def queueEvent(self, msg):
|
||||||
if 'time' not in msg:
|
if 'time' not in msg:
|
||||||
# add time, so we can track time passed
|
# add time, so we can track time passed
|
||||||
|
@ -572,6 +581,8 @@ class HugveyState(object):
|
||||||
self.setLanguage(event['lang_code'])
|
self.setLanguage(event['lang_code'])
|
||||||
if event['event'] == 'change_light':
|
if event['event'] == 'change_light':
|
||||||
self.setLightId(event['light_id'])
|
self.setLightId(event['light_id'])
|
||||||
|
if event['event'] == 'change_light_status':
|
||||||
|
self.setLightStatus(event['status'])
|
||||||
if event['event'] == 'play_msg':
|
if event['event'] == 'play_msg':
|
||||||
self.logger.info(f"Play given message {event['msg_id']}")
|
self.logger.info(f"Play given message {event['msg_id']}")
|
||||||
if not self.story:
|
if not self.story:
|
||||||
|
@ -654,10 +665,10 @@ class HugveyState(object):
|
||||||
self.setStatus(self.STATE_AVAILABLE)
|
self.setStatus(self.STATE_AVAILABLE)
|
||||||
|
|
||||||
def setLightStatus(self, on):
|
def setLightStatus(self, on):
|
||||||
status = 1 if on else 0
|
self.lightStatus = 1 if on else 0
|
||||||
self.logger.log(LOG_BS, f"Send /hugvey {status}")
|
self.logger.log(LOG_BS, f"Send /hugvey {self.lightStatus}")
|
||||||
|
|
||||||
self.command.commandLight('/hugvey', [self.lightId, status])
|
self.command.commandLight('/hugvey', [self.lightId, self.lightStatus])
|
||||||
|
|
||||||
def setLightId(self, id):
|
def setLightId(self, id):
|
||||||
"""
|
"""
|
||||||
|
@ -740,6 +751,10 @@ class HugveyState(object):
|
||||||
|
|
||||||
self.setLightStatus(False)
|
self.setLightStatus(False)
|
||||||
await self.story.run(startMsgId, resuming)
|
await self.story.run(startMsgId, resuming)
|
||||||
|
|
||||||
|
if self.command.config['story']['loop']:
|
||||||
|
self.logger.info("Loop story")
|
||||||
|
self.restart()
|
||||||
# self.story = None
|
# self.story = None
|
||||||
|
|
||||||
def getStreamer(self):
|
def getStreamer(self):
|
||||||
|
|
|
@ -71,6 +71,8 @@ def getWebSocketHandler(central_command):
|
||||||
self.msgChangeLanguage(msg['hugvey'], msg['lang_code'])
|
self.msgChangeLanguage(msg['hugvey'], msg['lang_code'])
|
||||||
elif msg['action'] == 'change_light':
|
elif msg['action'] == 'change_light':
|
||||||
self.msgChangeLightId(msg['hugvey'], int(msg['light_id']))
|
self.msgChangeLightId(msg['hugvey'], int(msg['light_id']))
|
||||||
|
elif msg['action'] == 'change_light_status':
|
||||||
|
self.msgChangeLightStatus(msg['hugvey'], bool(msg['light_status']))
|
||||||
elif msg['action'] == 'play_msg':
|
elif msg['action'] == 'play_msg':
|
||||||
self.msgPlayMsg(msg['hugvey'], msg['msg_id'], msg['reloadStory'])
|
self.msgPlayMsg(msg['hugvey'], msg['msg_id'], msg['reloadStory'])
|
||||||
else:
|
else:
|
||||||
|
@ -136,6 +138,9 @@ def getWebSocketHandler(central_command):
|
||||||
def msgChangeLightId(self, hv_id, lightId):
|
def msgChangeLightId(self, hv_id, lightId):
|
||||||
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'change_light', 'light_id': lightId})
|
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})
|
||||||
|
|
||||||
def msgPlayMsg(self, hv_id, msg_id, reloadStory):
|
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)})
|
central_command.hugveys[hv_id].eventQueue.put_nowait({'event': 'play_msg', 'msg_id': msg_id, 'reloadStory':bool(reloadStory)})
|
||||||
|
|
||||||
|
|
|
@ -32,3 +32,5 @@ web:
|
||||||
light:
|
light:
|
||||||
ip: "192.168.178.15"
|
ip: "192.168.178.15"
|
||||||
port: 7400
|
port: 7400
|
||||||
|
story:
|
||||||
|
loop: true
|
|
@ -96,7 +96,7 @@ img.icon {
|
||||||
left: 5px;
|
left: 5px;
|
||||||
top: 5px; }
|
top: 5px; }
|
||||||
#status .hugvey .status {
|
#status .hugvey .status {
|
||||||
font-sytle: italic;
|
font-style: italic;
|
||||||
color: gray;
|
color: gray;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 10px;
|
top: 10px;
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class='hugvey' v-for="hv in hugveys"
|
<div class='hugvey' v-for="hv in hugveys"
|
||||||
:class="[{'hugvey--on': hv.status != 'off'},'hugvey--' + hv.status]"
|
:class="[{'hugvey--on': hv.status != 'off'},'hugvey--' + hv.status, 'hugvey--light-' + hv.light_on]"
|
||||||
@click="showHugvey(hv)"
|
@click="showHugvey(hv)"
|
||||||
>
|
>
|
||||||
<h1>
|
<h1>
|
||||||
|
|
2
www/js/crel.min.js
vendored
2
www/js/crel.min.js
vendored
|
@ -9,7 +9,7 @@ crel.attrMap['options'] = function(element, values) {
|
||||||
if(element.tagName != "SELECT") {
|
if(element.tagName != "SELECT") {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
console.log(values);
|
console.log(values, element.value);
|
||||||
if(Array.isArray(values)) {
|
if(Array.isArray(values)) {
|
||||||
for (let option of values) {
|
for (let option of values) {
|
||||||
element.appendChild(crel('option', option));
|
element.appendChild(crel('option', option));
|
||||||
|
|
|
@ -67,6 +67,11 @@ class Panopticon {
|
||||||
console.log(hv_id, light_id, this);
|
console.log(hv_id, light_id, this);
|
||||||
return panopticon.change_light_id(hv_id, light_id);
|
return panopticon.change_light_id(hv_id, light_id);
|
||||||
},
|
},
|
||||||
|
change_light_status: function(e) {
|
||||||
|
let hv_id = parseInt(e.target.dataset.hvid);
|
||||||
|
let checked = e.target.checked;
|
||||||
|
panopticon.send( { action: 'change_light_status', hugvey: hv_id, light_status: checked } );
|
||||||
|
},
|
||||||
showHugvey: function(hv) {
|
showHugvey: function(hv) {
|
||||||
panopticon.selectHugvey(hv.language ? hv.id : null);
|
panopticon.selectHugvey(hv.language ? hv.id : null);
|
||||||
panopticon.hugveys.logbook = [];
|
panopticon.hugveys.logbook = [];
|
||||||
|
|
|
@ -23,7 +23,7 @@
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class='hugvey' v-for="hv in hugveys"
|
<div class='hugvey' v-for="hv in hugveys"
|
||||||
:class="[{'hugvey--on': hv.status != 'off'},'hugvey--' + hv.status]"
|
:class="[{'hugvey--on': hv.status != 'off'},'hugvey--' + hv.status, 'hugvey--light-' + hv.light_on]"
|
||||||
@click="showHugvey(hv)"
|
@click="showHugvey(hv)"
|
||||||
>
|
>
|
||||||
<h1>
|
<h1>
|
||||||
|
@ -69,7 +69,11 @@
|
||||||
<!-- <div class='light'>
|
<!-- <div class='light'>
|
||||||
{{ hv.light }}
|
{{ hv.light }}
|
||||||
</div> -->
|
</div> -->
|
||||||
<div class='light'>Light: <input type="number" step="1" :value="hv.light_id" @change="change_light" :data-hvid="hv.id" v-on:click.stop></div>
|
<div class='light'>
|
||||||
|
Light:
|
||||||
|
<input type="number" step="1" :value="hv.light_id" @change="change_light" :data-hvid="hv.id" v-on:click.stop>
|
||||||
|
<input type="checkbox" v-model="hv.light_on" @change="change_light_status" :data-hvid="hv.id" v-on:click.stop>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -136,7 +136,7 @@ img.icon{
|
||||||
}
|
}
|
||||||
|
|
||||||
.status{
|
.status{
|
||||||
font-sytle: italic;
|
font-style: italic;
|
||||||
color: gray;
|
color: gray;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 10px;
|
top: 10px;
|
||||||
|
@ -208,6 +208,14 @@ img.icon{
|
||||||
background-image: linear-gradient(to top, #587457, #e2f04a);
|
background-image: linear-gradient(to top, #587457, #e2f04a);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TODO
|
||||||
|
// &.hugvey--light-false{
|
||||||
|
// background-image: linear-gradient(to top, #ccc, rgba(255,255,255,0));
|
||||||
|
// }
|
||||||
|
// &.hugvey--light-true{
|
||||||
|
// background-image: linear-gradient(to top, , rgba(255,255,255,0));
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue