Compare commits
No commits in common. "329cb1083d965ff1a91ea60bd12bbb1c5c3959ce" and "32e6b5ba51e80765f6dc1abd49d5499b2bf60a49" have entirely different histories.
329cb1083d
...
32e6b5ba51
|
@ -289,12 +289,9 @@ 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 and (not delta['azimuth'] or (delta['azimuth'] >= 0) != direction['azimuth']):
|
||||
pan = 0
|
||||
changed = True
|
||||
'''
|
||||
if pan > 0:
|
||||
pan = min(pan, delta['azimuth'])
|
||||
|
|
31
server.py
31
server.py
|
@ -33,8 +33,7 @@ with open('camera.json') as fd:
|
|||
|
||||
state = {
|
||||
'time': {},
|
||||
'status': 'Idle',
|
||||
'sequence': [],
|
||||
'status': 'Idle'
|
||||
}
|
||||
|
||||
def run_async(func):
|
||||
|
@ -91,6 +90,7 @@ class ControlQueue:
|
|||
self.q.put(None)
|
||||
self._worker.join()
|
||||
|
||||
|
||||
class API(object):
|
||||
|
||||
def __call__(self, method, kwargs):
|
||||
|
@ -98,8 +98,7 @@ class API(object):
|
|||
|
||||
def getPresets(self, **data):
|
||||
result = {}
|
||||
#result['presets'] = ctl.camera.get_presets(True)
|
||||
result['presets'] = []
|
||||
result['presets'] = ctl.camera.get_presets(True)
|
||||
return result
|
||||
|
||||
def setPreset(self, **data):
|
||||
|
@ -164,17 +163,6 @@ 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()
|
||||
|
@ -228,20 +216,9 @@ 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}),
|
||||
|
@ -253,7 +230,7 @@ def main():
|
|||
'gzip': True,
|
||||
}
|
||||
app = Application(handlers, **options)
|
||||
print('listening on http://%s:%s/' % (ADDRESS, PORT))
|
||||
print('listening on http://%s:%s/' % (ADDRESS, PORT))
|
||||
app.listen(PORT, ADDRESS)
|
||||
|
||||
main = IOLoop.instance()
|
||||
|
|
|
@ -51,7 +51,6 @@ 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,
|
||||
|
@ -321,13 +320,10 @@ 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: disabled})
|
||||
$('button.continue_from').attr({disabled: disabled})
|
||||
$('button.run_from').attr({disabled: response.result.status == 'Active'})
|
||||
$('button.continue_from').attr({disabled: response.result.status == 'Active'})
|
||||
$('button.stop').attr({disabled: response.result.status != 'Active'})
|
||||
if (response.result.duration && response.result.status == 'Active') {
|
||||
$('#duration').html(formatDuration(response.result.duration))
|
||||
|
@ -377,17 +373,7 @@ function updateStatus() {
|
|||
seq.seqid = uuidv4()
|
||||
}
|
||||
})
|
||||
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() {})
|
||||
}
|
||||
localStorage.sequence = JSON.stringify(data)
|
||||
|
||||
var gotSelection = grid.getSelectedRows().length > 0
|
||||
$('button.goto').attr({disabled: !gotSelection})
|
||||
|
@ -622,9 +608,8 @@ $('button.all_presets').on({click: function() {
|
|||
$('input.import_sequence').on({change: function() {
|
||||
var reader = new FileReader()
|
||||
reader.onload = function(event) {
|
||||
var sequence = JSON.parse(reader.result)
|
||||
api('updateSequence', {sequence: sequence}, function() {})
|
||||
loadData(sequence)
|
||||
localStorage.sequence = reader.result
|
||||
loadData(JSON.parse(reader.result))
|
||||
}
|
||||
reader.readAsText(this.files[0]);
|
||||
}})
|
||||
|
@ -669,11 +654,9 @@ function shiftPresets(offset, callback) {
|
|||
function init() {
|
||||
api('getPresets', {}, function(response) {
|
||||
presets = response.result.presets
|
||||
api('getSequence', {}, function(response) {
|
||||
loadData(response.result.sequence)
|
||||
updateStatus()
|
||||
setInterval(updateStatus, 1000)
|
||||
})
|
||||
loadData(JSON.parse(localStorage.sequence || '[]'))
|
||||
updateStatus()
|
||||
setInterval(updateStatus, 1000)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user