Compare commits

..

No commits in common. "329cb1083d965ff1a91ea60bd12bbb1c5c3959ce" and "32e6b5ba51e80765f6dc1abd49d5499b2bf60a49" have entirely different histories.

3 changed files with 15 additions and 58 deletions

View File

@ -289,12 +289,9 @@ class Camera:
#print(current, delta, move) #print(current, delta, move)
current, delta = get_delta() current, delta = get_delta()
changed = False changed = False
if 'azimuth' in delta and 'azimuth' in direction:
if pan and (not delta['azimuth'] or (delta['azimuth'] >= 0) != direction['azimuth']): if pan and (not delta['azimuth'] or (delta['azimuth'] >= 0) != direction['azimuth']):
pan = 0 pan = 0
changed = True changed = True
else:
print('why no azimuth? delta: %s direction: %s' % (delta, direction))
''' '''
if pan > 0: if pan > 0:
pan = min(pan, delta['azimuth']) pan = min(pan, delta['azimuth'])

View File

@ -33,8 +33,7 @@ with open('camera.json') as fd:
state = { state = {
'time': {}, 'time': {},
'status': 'Idle', 'status': 'Idle'
'sequence': [],
} }
def run_async(func): def run_async(func):
@ -91,6 +90,7 @@ class ControlQueue:
self.q.put(None) self.q.put(None)
self._worker.join() self._worker.join()
class API(object): class API(object):
def __call__(self, method, kwargs): def __call__(self, method, kwargs):
@ -98,8 +98,7 @@ class API(object):
def getPresets(self, **data): def getPresets(self, **data):
result = {} result = {}
#result['presets'] = ctl.camera.get_presets(True) result['presets'] = ctl.camera.get_presets(True)
result['presets'] = []
return result return result
def setPreset(self, **data): def setPreset(self, **data):
@ -164,17 +163,6 @@ class API(object):
result['position'] = ctl.camera.last_position result['position'] = ctl.camera.last_position
return result 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 #@run_async
def api_task(request, callback): def api_task(request, callback):
api = API() api = API()
@ -228,20 +216,9 @@ class MainHandler(tornado.web.RequestHandler):
self.set_header('Expires', '0') self.set_header('Expires', '0')
self.write(content) 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(): def main():
global ctl global ctl
ctl = ControlQueue() ctl = ControlQueue()
load_sequence()
handlers = [ handlers = [
(r'/api/', RPCHandler), (r'/api/', RPCHandler),
(r'/static/(.*)', StaticFileHandler, {'path': STATIC_PATH}), (r'/static/(.*)', StaticFileHandler, {'path': STATIC_PATH}),

View File

@ -51,7 +51,6 @@ if (value == null || value == undefined || !value.length || !isInt(value)) {
} }
} }
var currentSequence;
var presets = []; var presets = [];
var system_presets = [ var system_presets = [
33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46,
@ -321,13 +320,10 @@ function totalDuration() {
function updateStatus() { function updateStatus() {
api('status', {}, function(response) { api('status', {}, function(response) {
if (response.result) { if (response.result) {
var gotSelection = grid.getSelectedRows().length > 0
var disabled = !gotSelection || response.result.status == 'Active'
$('#status').html(response.result.status) $('#status').html(response.result.status)
$('button.run').attr({disabled: response.result.status == 'Active'}) $('button.run').attr({disabled: response.result.status == 'Active'})
$('button.run_from').attr({disabled: disabled}) $('button.run_from').attr({disabled: response.result.status == 'Active'})
$('button.continue_from').attr({disabled: disabled}) $('button.continue_from').attr({disabled: response.result.status == 'Active'})
$('button.stop').attr({disabled: response.result.status != 'Active'}) $('button.stop').attr({disabled: response.result.status != 'Active'})
if (response.result.duration && response.result.status == 'Active') { if (response.result.duration && response.result.status == 'Active') {
$('#duration').html(formatDuration(response.result.duration)) $('#duration').html(formatDuration(response.result.duration))
@ -377,17 +373,7 @@ function updateStatus() {
seq.seqid = uuidv4() seq.seqid = uuidv4()
} }
}) })
var sequence = JSON.stringify(data.map(step => { localStorage.sequence = JSON.stringify(data)
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 var gotSelection = grid.getSelectedRows().length > 0
$('button.goto').attr({disabled: !gotSelection}) $('button.goto').attr({disabled: !gotSelection})
@ -622,9 +608,8 @@ $('button.all_presets').on({click: function() {
$('input.import_sequence').on({change: function() { $('input.import_sequence').on({change: function() {
var reader = new FileReader() var reader = new FileReader()
reader.onload = function(event) { reader.onload = function(event) {
var sequence = JSON.parse(reader.result) localStorage.sequence = reader.result
api('updateSequence', {sequence: sequence}, function() {}) loadData(JSON.parse(reader.result))
loadData(sequence)
} }
reader.readAsText(this.files[0]); reader.readAsText(this.files[0]);
}}) }})
@ -669,12 +654,10 @@ function shiftPresets(offset, callback) {
function init() { function init() {
api('getPresets', {}, function(response) { api('getPresets', {}, function(response) {
presets = response.result.presets presets = response.result.presets
api('getSequence', {}, function(response) { loadData(JSON.parse(localStorage.sequence || '[]'))
loadData(response.result.sequence)
updateStatus() updateStatus()
setInterval(updateStatus, 1000) setInterval(updateStatus, 1000)
}) })
})
} }
function init_shift() { function init_shift() {