Compare commits
2 Commits
32e6b5ba51
...
329cb1083d
Author | SHA1 | Date | |
---|---|---|---|
329cb1083d | |||
df190dda02 |
|
@ -289,9 +289,12 @@ class Camera:
|
|||
#print(current, delta, move)
|
||||
current, delta = get_delta()
|
||||
changed = False
|
||||
if 'azimuth' in delta and 'azimuth' in direction:
|
||||
if pan and (not delta['azimuth'] or (delta['azimuth'] >= 0) != direction['azimuth']):
|
||||
pan = 0
|
||||
changed = True
|
||||
else:
|
||||
print('why no azimuth? delta: %s direction: %s' % (delta, direction))
|
||||
'''
|
||||
if pan > 0:
|
||||
pan = min(pan, delta['azimuth'])
|
||||
|
|
29
server.py
29
server.py
|
@ -33,7 +33,8 @@ with open('camera.json') as fd:
|
|||
|
||||
state = {
|
||||
'time': {},
|
||||
'status': 'Idle'
|
||||
'status': 'Idle',
|
||||
'sequence': [],
|
||||
}
|
||||
|
||||
def run_async(func):
|
||||
|
@ -90,7 +91,6 @@ class ControlQueue:
|
|||
self.q.put(None)
|
||||
self._worker.join()
|
||||
|
||||
|
||||
class API(object):
|
||||
|
||||
def __call__(self, method, kwargs):
|
||||
|
@ -98,7 +98,8 @@ class API(object):
|
|||
|
||||
def getPresets(self, **data):
|
||||
result = {}
|
||||
result['presets'] = ctl.camera.get_presets(True)
|
||||
#result['presets'] = ctl.camera.get_presets(True)
|
||||
result['presets'] = []
|
||||
return result
|
||||
|
||||
def setPreset(self, **data):
|
||||
|
@ -163,6 +164,17 @@ class API(object):
|
|||
result['position'] = ctl.camera.last_position
|
||||
return result
|
||||
|
||||
def updateSequence(self, **data):
|
||||
print('updateSequence')
|
||||
state['sequence'] = data['sequence']
|
||||
with open('sequence.json', 'w') as fd:
|
||||
json.dump(state['sequence'], fd, indent=4, ensure_ascii=False)
|
||||
|
||||
def getSequence(self, **data):
|
||||
result = {}
|
||||
result['sequence'] = state['sequence']
|
||||
return result
|
||||
|
||||
#@run_async
|
||||
def api_task(request, callback):
|
||||
api = API()
|
||||
|
@ -216,9 +228,20 @@ class MainHandler(tornado.web.RequestHandler):
|
|||
self.set_header('Expires', '0')
|
||||
self.write(content)
|
||||
|
||||
def load_sequence():
|
||||
if os.path.exists('sequence.json'):
|
||||
try:
|
||||
with open('sequence.json') as fd:
|
||||
data = json.load(fd)
|
||||
except:
|
||||
data = []
|
||||
state['sequence'] = data
|
||||
|
||||
def main():
|
||||
global ctl
|
||||
ctl = ControlQueue()
|
||||
load_sequence()
|
||||
|
||||
handlers = [
|
||||
(r'/api/', RPCHandler),
|
||||
(r'/static/(.*)', StaticFileHandler, {'path': STATIC_PATH}),
|
||||
|
|
|
@ -51,6 +51,7 @@ if (value == null || value == undefined || !value.length || !isInt(value)) {
|
|||
}
|
||||
}
|
||||
|
||||
var currentSequence;
|
||||
var presets = [];
|
||||
var system_presets = [
|
||||
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
|
||||
|
@ -320,10 +321,13 @@ function totalDuration() {
|
|||
function updateStatus() {
|
||||
api('status', {}, function(response) {
|
||||
if (response.result) {
|
||||
var gotSelection = grid.getSelectedRows().length > 0
|
||||
var disabled = !gotSelection || response.result.status == 'Active'
|
||||
|
||||
$('#status').html(response.result.status)
|
||||
$('button.run').attr({disabled: response.result.status == 'Active'})
|
||||
$('button.run_from').attr({disabled: response.result.status == 'Active'})
|
||||
$('button.continue_from').attr({disabled: response.result.status == 'Active'})
|
||||
$('button.run_from').attr({disabled: disabled})
|
||||
$('button.continue_from').attr({disabled: disabled})
|
||||
$('button.stop').attr({disabled: response.result.status != 'Active'})
|
||||
if (response.result.duration && response.result.status == 'Active') {
|
||||
$('#duration').html(formatDuration(response.result.duration))
|
||||
|
@ -373,7 +377,17 @@ function updateStatus() {
|
|||
seq.seqid = uuidv4()
|
||||
}
|
||||
})
|
||||
localStorage.sequence = JSON.stringify(data)
|
||||
var sequence = JSON.stringify(data.map(step => {
|
||||
step = Object.assign({}, step)
|
||||
delete step.duration
|
||||
delete step.status
|
||||
return step
|
||||
}))
|
||||
if (sequence != currentSequence) {
|
||||
console.log('updateSequence')
|
||||
currentSequence = sequence
|
||||
api('updateSequence', {sequence: data}, function() {})
|
||||
}
|
||||
|
||||
var gotSelection = grid.getSelectedRows().length > 0
|
||||
$('button.goto').attr({disabled: !gotSelection})
|
||||
|
@ -608,8 +622,9 @@ $('button.all_presets').on({click: function() {
|
|||
$('input.import_sequence').on({change: function() {
|
||||
var reader = new FileReader()
|
||||
reader.onload = function(event) {
|
||||
localStorage.sequence = reader.result
|
||||
loadData(JSON.parse(reader.result))
|
||||
var sequence = JSON.parse(reader.result)
|
||||
api('updateSequence', {sequence: sequence}, function() {})
|
||||
loadData(sequence)
|
||||
}
|
||||
reader.readAsText(this.files[0]);
|
||||
}})
|
||||
|
@ -654,10 +669,12 @@ function shiftPresets(offset, callback) {
|
|||
function init() {
|
||||
api('getPresets', {}, function(response) {
|
||||
presets = response.result.presets
|
||||
loadData(JSON.parse(localStorage.sequence || '[]'))
|
||||
api('getSequence', {}, function(response) {
|
||||
loadData(response.result.sequence)
|
||||
updateStatus()
|
||||
setInterval(updateStatus, 1000)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function init_shift() {
|
||||
|
|
Loading…
Reference in New Issue
Block a user