hour loop
This commit is contained in:
parent
765fc78c7b
commit
38d0ef4714
30
camera.py
30
camera.py
|
@ -147,7 +147,7 @@ class Camera:
|
||||||
if '<statusCode>1</statusCode>' not in r:
|
if '<statusCode>1</statusCode>' not in r:
|
||||||
print(r)
|
print(r)
|
||||||
elif duration:
|
elif duration:
|
||||||
time.sleep(duration)
|
self.sleep(duration)
|
||||||
self.continuous(self.STOP)
|
self.continuous(self.STOP)
|
||||||
|
|
||||||
def set_preset(self, id, name):
|
def set_preset(self, id, name):
|
||||||
|
@ -168,12 +168,24 @@ class Camera:
|
||||||
time.sleep(1)
|
time.sleep(1)
|
||||||
print('presets loaded')
|
print('presets loaded')
|
||||||
|
|
||||||
def sequence(self, steps=[], speed=12, goto_first=True, loop=False):
|
def sleep(self, seconds):
|
||||||
|
n = float(seconds)
|
||||||
|
if self.abort:
|
||||||
|
return
|
||||||
|
while n > 0:
|
||||||
|
step = min(n, 0.5)
|
||||||
|
time.sleep(step)
|
||||||
|
n -= step
|
||||||
|
if self.abort:
|
||||||
|
return
|
||||||
|
|
||||||
|
def sequence(self, steps=[], speed=12, goto_first=True, loop=False, hour_loop=False):
|
||||||
self.sequence_start = 0
|
self.sequence_start = 0
|
||||||
if goto_first:
|
if goto_first:
|
||||||
#self.goto_preset(steps[0], pan=100, tilt=100, zoom=100)
|
#self.goto_preset(steps[0], pan=100, tilt=100, zoom=100)
|
||||||
first = steps[0]
|
first = steps[0]
|
||||||
steps = steps[1:]
|
steps = steps[1:]
|
||||||
|
hour = time.gmtime().tm_hour
|
||||||
while True:
|
while True:
|
||||||
if goto_first:
|
if goto_first:
|
||||||
if isinstance(first, dict):
|
if isinstance(first, dict):
|
||||||
|
@ -182,11 +194,13 @@ class Camera:
|
||||||
first = first['preset']
|
first = first['preset']
|
||||||
self.fast_preset(first, True)
|
self.fast_preset(first, True)
|
||||||
#self.goto_preset(first, pan=speed, tilt=speed)
|
#self.goto_preset(first, pan=speed, tilt=speed)
|
||||||
if self.abort:
|
self.sleep(3)
|
||||||
return
|
|
||||||
time.sleep(3)
|
|
||||||
self.sequence_start = t0 = time.time()
|
self.sequence_start = t0 = time.time()
|
||||||
for step in steps:
|
for step in steps:
|
||||||
|
next_hour = time.gmtime().tm_hour
|
||||||
|
if hour_loop and next_hour != hour:
|
||||||
|
hour = next_hour
|
||||||
|
break
|
||||||
self.next_target = step
|
self.next_target = step
|
||||||
segment_t0 = time.time()
|
segment_t0 = time.time()
|
||||||
if self.abort:
|
if self.abort:
|
||||||
|
@ -206,9 +220,7 @@ class Camera:
|
||||||
kwargs['zoom_last'] = step['zoom_last']
|
kwargs['zoom_last'] = step['zoom_last']
|
||||||
self.goto_preset(step['preset'], **kwargs)
|
self.goto_preset(step['preset'], **kwargs)
|
||||||
if 'sleep' in step:
|
if 'sleep' in step:
|
||||||
if self.abort:
|
self.sleep(step['sleep'])
|
||||||
return
|
|
||||||
time.sleep(float(step['sleep']))
|
|
||||||
else:
|
else:
|
||||||
self.goto_preset(step, pan=speed, tilt=speed)
|
self.goto_preset(step, pan=speed, tilt=speed)
|
||||||
|
|
||||||
|
@ -217,7 +229,7 @@ class Camera:
|
||||||
self.segment_times[step['seqid']] = segment_time
|
self.segment_times[step['seqid']] = segment_time
|
||||||
self.sequence_time = time.time() - t0
|
self.sequence_time = time.time() - t0
|
||||||
self.next_target = None
|
self.next_target = None
|
||||||
if not loop:
|
if not loop and not hour_loop:
|
||||||
break
|
break
|
||||||
|
|
||||||
def fast_preset(self, id, wait=False):
|
def fast_preset(self, id, wait=False):
|
||||||
|
|
|
@ -84,6 +84,7 @@
|
||||||
<ul>
|
<ul>
|
||||||
<li><button class="run">run</button></li>
|
<li><button class="run">run</button></li>
|
||||||
<li><button class="loop">loop</button></li>
|
<li><button class="loop">loop</button></li>
|
||||||
|
<li><button class="hour_loop">hour loop</button></li>
|
||||||
<li><button class="goto">go to selected</button></li>
|
<li><button class="goto">go to selected</button></li>
|
||||||
<li><button class="run_from">run from selected</button></li>
|
<li><button class="run_from">run from selected</button></li>
|
||||||
<li><button class="continue_from">continue to selected</button></li>
|
<li><button class="continue_from">continue to selected</button></li>
|
||||||
|
|
|
@ -481,6 +481,19 @@ $('button.loop').on({click: function() {
|
||||||
//console.log(response)
|
//console.log(response)
|
||||||
})
|
})
|
||||||
}})
|
}})
|
||||||
|
$('button.hour_loop').on({click: function() {
|
||||||
|
data.forEach(function(seq) {
|
||||||
|
if (!seq.seqid) {
|
||||||
|
seq.seqid = uuidv4()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
api('run', {
|
||||||
|
'steps': data,
|
||||||
|
'hour_loop': true
|
||||||
|
}, function(response) {
|
||||||
|
//console.log(response)
|
||||||
|
})
|
||||||
|
}})
|
||||||
$('button.run_from').on({click: function() {
|
$('button.run_from').on({click: function() {
|
||||||
var selected = grid.getSelectedRows()[0];
|
var selected = grid.getSelectedRows()[0];
|
||||||
api('run', {
|
api('run', {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user