def prepare(self, assistant, page): if page == self.page0: self.targetstore.data.clear() self.set_page_complete(self.page_match, False) elif page == self.page_match: if len(self.targetstore.data) == 0: f = open(self.page0.get_filename(), 'r') self.lines = f.readlines() self.pm_tt = len(self.lines) gobject.idle_add(self.process_line) elif page == self.page_create_summary: self.create_summary = gtk.TextBuffer() self.create_summary_text.set_buffer(self.create_summary) self.set_page_complete(self.page_create_summary, False) self.active_text = self.create_summary_text login.getProxy().queue(self.create_target, _('Generating summary page preview'), self.page_create_summary, False) elif page == self.page_create: self.create_log = gtk.TextBuffer() self.create_text.set_buffer(self.create_log) self.set_page_complete(self.page_create, False) self.active_text = self.create_text login.getProxy().queue(self.create_target, _('Creating targets'), self.page_create)
def __init__(self,camera_name,client_only): gtk.Window.__init__(self) self.camera_name = camera_name self.client_only = client_only if self.client_only: self.set_title(_('Client for camera {0}').format(self.camera_name)) else: self.set_title(_('Images from camera {0}').format(self.camera_name)) vb = gtk.VBox() tt = gtk.Table(2,7) tt.set_col_spacings(10) tt.set_row_spacings(10) def ll(text): l = gtk.Label(text) l.set_alignment(1,0.5) return l self.status = gtk.Label('IDLE') vb.pack_start(self.status,False,False) if not self.client_only: tt.attach(ll(_('Exposure time')),0,1,0,1) self.exp_t = gtk.SpinButton(gtk.Adjustment(1,0,86400,1,10),digits=2) tt.attach(self.exp_t,1,2,0,1) tt.attach(ll(_('Binning')),0,1,1,2) bins = login.getProxy().getSelection(self.camera_name,'binning') self.binnings = [] hb = gtk.HBox() nb = gtk.RadioButton(None,bins[0]) self.binnings.append(nb) hb.pack_start(nb,False,False) nb.connect('clicked',self.set_binning) for b in bins[1:]: nb = gtk.RadioButton(self.binnings[0],b) self.binnings.append(nb) hb.pack_start(nb,False,False) nb.connect('clicked',self.set_binning) tt.attach(hb,1,2,1,2) tt.attach(ll(_('Channel')),0,1,2,3) ahb = gtk.HButtonBox() self.exp_c = [] self.sofar = [] self.tb = [] try: chan = login.getProxy().getValue(self.camera_name,'CHAN') except KeyError,ke: chan = [True]
def process_line(self): if not self.get_current_page() == 1: return False if len(self.lines) == 0: self.pm_l.set_text('Target matching completed') self.pm_t.set_fraction(1) self.set_page_complete(self.page_match, True) return False l = self.lines[0].rstrip() self.pm_l.set_text(l) self.pm_t.set_fraction( float(self.pm_tt - len(self.lines)) / self.pm_tt) self.lines = self.lines[1:] # process line.. if (len(l) == 0): return True if l[0] == '#' and len(l) > 1 and l[1] == '!': self.parsePiProg(l[1:]) return True if l[0] == '!': self.parsePiProg(l) return True if l[0] == '#': return True a = l.split() if (a[2][0] != '-' and a[2][0] != '+'): a[2] = '+' + a[2] a[1] = radec.from_hms(a[1]) * 15.0 a[2] = radec.from_hms(a[2]) candidates = login.getProxy().loadJson('/api/tbyname', { 'n': a[0], 'pm': 0 })['d'] if len(candidates) == 1: self.pm_l.set_text( _('Matched target {0} to ID {1} by name').format( a[0], candidates[0][0])) else: candidates = login.getProxy().loadJson('/api/tbydistance', { 'ra': a[1], 'dec': a[2], 'radius': 0.1 })['d'] if len(candidates) == 1: self.pm_l.set_text( _('Matched target {0} to {1} with ID {2} by coordinates'). format(a[0], candidates[0][1], candidates[0][0])) else: candidates = None if candidates: self.addTarget(candidates[0][0], candidates[0][1], candidates[0][2], candidates[0][3], a) else: self.addTarget(None, None, None, None, a) return True
def update(self): """Update data for given rect size. Run in thread for expose event""" try: self.update_lock.acquire() self.dh = float(login.getProxy().getValue('centrald', 'day_horizon')) self.nh = float(login.getProxy().getValue('centrald', 'night_horizon')) self.sun_alts = login.getProxy().loadJson('/api/sunalt', { 'from': self.fr, 'to': self.to, 'step': self.rect.width }) try: self.active_target.get_altitude_constraints_v() self.active_target.get_time_constraints_v(self.rect) except AttributeError, ae: pass for tar in self.targets: tar.update_data(self.rect) self.data_rect = self.rect
def prepare(self,assistant,page): if page == self.page1: if len(self.resolved_name.get_text()): self.set_current_page(0) self.resolved_name.set_text('') return def __fill_target(self): try: self.tars = login.getProxy().loadJson('/api/tbystring',{'ts':self.tarname.get_text(),'nearest':20}) except Exception,ex: self.set_page_title(self.page1,_('Cannot resolve target')) self.error_label.set_text(_('Cannot resolve name of target {0} from Simbad.').format(self.tarname.get_text(), ex)) self.set_page_complete(self.page1,True) return self.resolved_name.set_text(self.tars['name']) self.resolved_ra.set_text(radec.ra_string(self.tars['ra'])) self.resolved_dec.set_text(radec.dec_string(self.tars['dec'])) self.resolved_desc.set_text(self.tars['desc']) self.nearest.reload('/api/tbystring',data=self.tars['nearest']['d']) self.nearest.append('/api/tbyname',{'n':self.tarname.get_text(),'ra':self.tars['ra'],'dec':self.tars['dec']}) gobject.idle_add(self.set_current_page, 2) self.set_current_page(self.index_progress) login.getProxy().queue(__fill_target, _('Resolving target {0}').format(self.tarname.get_text()), self)
def prepare(self,assistant,page): if page == self.page0: self.targetstore.data.clear() self.set_page_complete(self.page_match,False) elif page == self.page_match: if len(self.targetstore.data) == 0: f = open(self.page0.get_filename(),'r') self.lines = f.readlines() self.pm_tt = len(self.lines) gobject.idle_add(self.process_line) elif page == self.page_create_summary: self.create_summary = gtk.TextBuffer() self.create_summary_text.set_buffer(self.create_summary) self.set_page_complete(self.page_create_summary,False) self.active_text = self.create_summary_text login.getProxy().queue(self.create_target, _('Generating summary page preview'), self.page_create_summary, False) elif page == self.page_create: self.create_log = gtk.TextBuffer() self.create_text.set_buffer(self.create_log) self.set_page_complete(self.page_create, False) self.active_text = self.create_text login.getProxy().queue(self.create_target, _('Creating targets'), self.page_create)
def set_script(self): if self.target: login.getProxy().loadJson('/api/change_script', { 'id': self.target, 'c': self.camera, 's': self.get_script() })
def create(self): # see if there is candidate to macth.. print 'Trying to find source {0} on {1} {2}'.format(self.source,radec.ra_string(self.ra),radec.dec_string(self.dec)) candidates = login.getProxy().loadJson('/api/tbyname',{'n':self.source,'pm':0})['d'] if len(candidates) == 1: print 'Matched target {0} to ID {1} by name'.format(self.source,candidates[0][0]) else: candidates = login.getProxy().loadJson('/api/tbydistance',{'ra':self.ra,'dec':self.dec,'radius':0.1})['d'] if len(candidates) == 1: print 'Matched target {0} to {1} with ID {2} by coordinates'.format(self.source,candidates[0][1],candidates[0][0]) else: candidates = None if candidates is None or len(candidates) > 1: d = login.getProxy().loadJson('/api/create_target',{'tn':self.source,'ra':self.ra,'dec':self.dec}) self.tar_id = int(d['id']) print 'Create target with ID {0}'.format(self.tar_id) else: self.tar_id = candidates[0][0] # now the observer.. login.getProxy().loadJson('/api/tlabs_delete',{'id':self.tar_id,'ltype':rts2const.LABEL_PI}) login.getProxy().loadJson('/api/tlabs_add',{'id':self.tar_id,'ltype':rts2const.LABEL_PI,'ltext':self.observer}) # script s = self.script() print 'Setting script to',s login.getProxy().loadJson('/api/change_script',{'id':self.tar_id,'c':'C0','s':s})
def take_exposure(self): # tady se resi expozice,.. args = {'ccd':self.camera_name} args = self.add_scaling(args) if self.exptime is None or not (self.exptime == self.exp_t.get_text()): self.exptime = self.exp_t.get_value() ret = login.getProxy().loadData('/api/set',{'d':self.camera_name,'n':'exposure','v':self.exptime},hlib=self.exp_conn) eargs = args eargs['chan'] = self.first_channel() r = login.getProxy().getResponse('/api/exposedata',eargs,hlib=self.exp_conn) self.prepare_frames() self.display_request(r,'/api/currentimage',args,self.get_active_channels())
def grab_thread(self,api): if self.exp_conn is None: self.exp_conn = login.getProxy().newConnection() args = {'ccd':self.camera_name,'chan':self.first_channel()} args = self.add_scaling(args) r = login.getProxy().getResponse(api,args,hlib=self.exp_conn) self.prepare_frames() self.display_request(r,api,args,self.get_active_channels()) self.wait_data_end() self.current_b.set_sensitive(True) self.last_b.set_sensitive(True)
def grab_thread(self, api): if self.exp_conn is None: self.exp_conn = login.getProxy().newConnection() args = {'ccd': self.camera_name, 'chan': self.first_channel()} args = self.add_scaling(args) r = login.getProxy().getResponse(api, args, hlib=self.exp_conn) self.prepare_frames() self.display_request(r, api, args, self.get_active_channels()) self.wait_data_end() self.current_b.set_sensitive(True) self.last_b.set_sensitive(True)
def __init__(self,title=None,parent=None,flags=0,buttons=None,target=1,camera='C0'): gtk.Dialog.__init__(self,title,parent,flags,buttons) self.set_geometry_hints(min_width=600,min_height=300) self.scripteditor = ScriptEditor() self.vbox.add(self.scripteditor) self.scripteditor.script.target = target self.l = gtk.Label('') self.l.set_alignment(0,0.5) self.vbox.pack_end(self.l,False,False) b = gtk.Button(_('Generate')) b.connect('clicked',self.generate) self.action_area.add(b) b = gtk.Button(_('Set script')) b.connect('clicked',self.set_script) self.action_area.add(b) self.cam = gtk.combo_box_new_text() cams = login.getProxy().loadJson('/api/devbytype',{'t':3}) for x in cams: self.cam.append_text(x) self.cam.connect('changed',self.select_camera) self.cam.set_active(0) self.action_area.add(self.cam) self.show_all()
def set_target(self,id): tar = login.getProxy().loadJson('/api/tbyid',{'id':id})['d'][0] self.idl.set_text(str(id)) self.tarname.set_text(tar[1]) self.coordinates.set_radec(tar[2],tar[3]) self.desc.set_text(tar[4])
def __init__(self): # id, name, RA, DEC, ALT, AZ gtk.ListStore.__init__(self,str,float,float,float,float,'gboolean') res = login.getProxy().loadJson('/api/tbytype',{'t':'O'}) for x in res: self.append([x['name'],x['ra'],x['dec'],x['alt'],x['az'],x['enabled']])
def filter_t(self,b): """Filter by target type / label.""" if b.get_active() > 0: self.tids = map(lambda x:x[0],login.getProxy().loadJson('/api/tbylabel',{'l':self.ll[b.get_active()-1][0]})['d']) else: self.tids = None self.filter.refilter()
def update_data(self, rect): self.alts = login.getProxy().loadJson('/api/taltitudes', { 'id': self.id, 'from': self.fr, 'to': self.to, 'steps': rect.width })
def set_target(self, id): tar = login.getProxy().loadJson('/api/tbyid', {'id': id})['d'][0] self.idl.set_text(str(id)) self.tarname.set_text(tar[1]) self.coordinates.set_radec(tar[2], tar[3]) self.desc.set_text(tar[4])
def append(self,path,args={},data=None): self.tv.set_model(None) if data is None: self.data.reload(login.getProxy().loadJson(path,args)['d']) else: self.data.reload(data) self.tv.set_model(self.sm)
def append(self, path, args={}, data=None): self.tv.set_model(None) if data is None: self.data.reload(login.getProxy().loadJson(path, args)['d']) else: self.data.reload(data) self.tv.set_model(self.sm)
def process_line(self): if not self.get_current_page() == 1: return False if len(self.lines) == 0: self.pm_l.set_text('Target matching completed') self.pm_t.set_fraction(1) self.set_page_complete(self.page_match,True) return False l = self.lines[0].rstrip() self.pm_l.set_text(l) self.pm_t.set_fraction(float(self.pm_tt-len(self.lines))/self.pm_tt) self.lines = self.lines[1:] # process line.. if (len(l) == 0): return True if l[0] == '#' and len(l) > 1 and l[1] == '!': self.parsePiProg(l[1:]) return True if l[0] == '!': self.parsePiProg(l) return True if l[0] == '#': return True a = l.split() if (a[2][0] != '-' and a[2][0] != '+'): a[2] = '+' + a[2] a[1] = radec.from_hms(a[1]) * 15.0 a[2] = radec.from_hms(a[2]) candidates = login.getProxy().loadJson('/api/tbyname',{'n':a[0],'pm':0})['d'] if len(candidates) == 1: self.pm_l.set_text(_('Matched target {0} to ID {1} by name').format(a[0],candidates[0][0])) else: candidates = login.getProxy().loadJson('/api/tbydistance',{'ra':a[1],'dec':a[2],'radius':0.1})['d'] if len(candidates) == 1: self.pm_l.set_text(_('Matched target {0} to {1} with ID {2} by coordinates').format(a[0],candidates[0][1],candidates[0][0])) else: candidates = None if candidates: self.addTarget(candidates[0][0],candidates[0][1],candidates[0][2],candidates[0][3],a) else: self.addTarget(None,None,None,None,a) return True
def __fill_target(self): try: self.tars = login.getProxy().loadJson('/api/tbystring',{'ts':self.tarname.get_text(),'nearest':20}) except Exception,ex: self.set_page_title(self.page1,_('Cannot resolve target')) self.error_label.set_text(_('Cannot resolve name of target {0} from Simbad.').format(self.tarname.get_text(), ex)) self.set_page_complete(self.page1,True) return
def device_changed(self,b): m = gtk.ListStore(str) d = login.getProxy().getDevice(self.device.get_active_text()) for n in d.keys(): if (d[n][0] & rts2.json.RTS2_VALUE_WRITABLE) and n != 'filter': m.append([n]) self.name.set_model(m) self.name.set_active(0)
def device_changed(self, b): m = gtk.ListStore(str) d = login.getProxy().getDevice(self.device.get_active_text()) for n in d.keys(): if (d[n][0] & rts2.json.RTS2_VALUE_WRITABLE) and n != 'filter': m.append([n]) self.name.set_model(m) self.name.set_active(0)
def markMonth(self,cal): """Marks dates in month where observations were carried""" y,m,d = cal.get_date() cal.clear_marks() mark = login.getProxy().loadJson('/nights/{0}/{1}/api'.format(y,m+1))['d'] for x in mark: if x[1] > 0: cal.mark_day(x[0])
def markMonth(self, cal): """Marks dates in month where observations were carried""" y, m, d = cal.get_date() cal.clear_marks() mark = login.getProxy().loadJson('/nights/{0}/{1}/api'.format( y, m + 1))['d'] for x in mark: if x[1] > 0: cal.mark_day(x[0])
def set_target(self,target,camera): self.clear() self.target = target self.camera = camera script = login.getProxy().loadJson('/api/script',{'cn':camera,'id':target}) self.load_json(script) self.attach(self.table,0,0)
def get_time_constraints_v(self, rect): if self.cnst_time_v is None: self.cnst_time_v = login.getProxy().loadJson( '/api/cnst_time_v', { 'id': self.id, 'from': self.fr, 'to': self.to, 'steps': rect.width })['constraints'] return self.cnst_time_v
def save_target(self): (ra, dec) = self.coordinates.get_radec() return login.getProxy().loadJson( '/api/update_target', { 'id': int(self.idl.get_text()), 'tn': self.tarname.get_text(), 'ra': ra, 'dec': dec, 'desc': self.desc.get_text() })
def __init__(self): # id, name, RA, DEC, ALT, AZ gtk.ListStore.__init__(self, str, float, float, float, float, 'gboolean') res = login.getProxy().loadJson('/api/tbytype', {'t': 'O'}) for x in res: self.append([ x['name'], x['ra'], x['dec'], x['alt'], x['az'], x['enabled'] ])
def __load_thread(self, rows, r, progressbar): for i in range(1, rows + 1): res = login.getProxy().chunkJson(r) def _add_row(data, res, progressbar, rows, i): data.append_row(res) if progressbar: progressbar.set_fraction(i / float(rows)) progressbar.set_text('{0} of {1}'.format(i, rows)) gobject.idle_add(_add_row, self.data, res, progressbar, rows, i)
def __init__(self): gtk.Table.__init__(self, 2, 2, False) self.tg = gtk.DrawingArea() self.fr = int(login.getProxy().getValue( 'centrald', 'sun_set', refresh_not_found=True) - 1800) self.to = int(login.getProxy().getValue('centrald', 'sun_rise') + 1800) if self.fr > self.to: self.fr -= 86400 self.targets = [] self.active_target = None self.update_lock = threading.Lock() self.data_rect = None self.sun_alts = [] self.tg.set_events(gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.POINTER_MOTION_HINT_MASK) self.tg.connect('expose-event', self.expose) self.attach(self.tg, 1, 2, 0, 1, gtk.EXPAND | gtk.FILL, gtk.EXPAND | gtk.FILL) def motion_notify(ruler, event): return ruler.emit('motion-notify-event', event) self.vr = gtk.VRuler() self.vr.set_metric(gtk.PIXELS) self.vr.set_range(90, -90, 10, 90) self.tg.connect_object('motion-notify-event', motion_notify, self.vr) self.attach(self.vr, 0, 1, 0, 1, gtk.FILL, gtk.EXPAND | gtk.SHRINK | gtk.FILL) self.hr = houraxis.HourAxis(self.fr, self.to - self.fr) self.tg.connect_object('motion-notify-event', motion_notify, self.hr) self.attach(self.hr, 1, 2, 1, 2, gtk.EXPAND | gtk.SHRINK | gtk.FILL, gtk.FILL) self.rect = self.get_allocation() threading.Thread(target=self.update).start()
def take_exposure(self): # tady se resi expozice,.. args = {'ccd': self.camera_name} args = self.add_scaling(args) if self.exptime is None or not (self.exptime == self.exp_t.get_text()): self.exptime = self.exp_t.get_value() ret = login.getProxy().loadData('/api/set', { 'd': self.camera_name, 'n': 'exposure', 'v': self.exptime }, hlib=self.exp_conn) eargs = args eargs['chan'] = self.first_channel() r = login.getProxy().getResponse('/api/exposedata', eargs, hlib=self.exp_conn) self.prepare_frames() self.display_request(r, '/api/currentimage', args, self.get_active_channels())
def update(self): """Update data for given rect size. Run in thread for expose event""" try: self.update_lock.acquire() self.dh = float(login.getProxy().getValue('centrald','day_horizon')) self.nh = float(login.getProxy().getValue('centrald','night_horizon')) self.sun_alts = login.getProxy().loadJson('/api/sunalt',{'from':self.fr,'to':self.to,'step':self.rect.width}) try: self.active_target.get_altitude_constraints_v() self.active_target.get_time_constraints_v(self.rect) except AttributeError,ae: pass for tar in self.targets: tar.update_data(self.rect) self.data_rect = self.rect
def __init__(self, buttons=None, flags=0, selmode=gtk.SELECTION_SINGLE, extended=True, withpm=False): self.ll = login.getProxy().loadJson('/api/labellist')['d'] jsontable.JsonSelectDialog.__init__(self, '/api/tbyname', {'n':'%', 'e':int(extended), 'ch':1, 'propm':int(withpm)}, buttons=buttons, selmode=selmode, search_column=1,flags=flags) self.cb = gtk.combo_box_new_text() self.cb.append_text(_('*** ALL ***')) self.cb.set_tooltip_markup('Click on the list to filter targets with their label.') for l in self.ll: self.cb.append_text(l[2]) self.tids = None self.tnames = None self.cb.connect('changed',self.filter_t) cbh = gtk.Table(2,3,False) l = gtk.Label(_('Group:')) l.set_alignment(0,0.5) cbh.attach(l,0,1,0,1) cbh.attach(self.cb,1,2,0,1,gtk.EXPAND|gtk.FILL|gtk.SHRINK) self.tn = gtk.Entry() self.tn.connect('changed',self.filter_n) l = gtk.Label(_('Target name:')) l.set_alignment(0,0.5) cbh.attach(l,0,1,1,2) cbh.attach(self.tn,1,2,1,2,gtk.EXPAND|gtk.FILL|gtk.SHRINK) l = gtk.Label(_('Minimal altitude')) l.set_alignment(0,0.5) self.maa = gtk.SpinButton(gtk.Adjustment(-90,-90,90,1,10),digits=0) self.maa.connect('changed',lambda x:self.filter.refilter()) cbh.attach(l,0,1,2,3) cbh.attach(self.maa,1,2,2,3,gtk.EXPAND|gtk.FILL|gtk.SHRINK) self.vbox.pack_start(cbh,False,False) def add_filter(self): self.filter = self.js.data.filter_new() self.js.tv.set_model(gtk.TreeModelSort(self.filter)) self.filter.set_visible_func(self.filter_f) self.cb.set_active(0) self.show_all() gobject.idle_add(add_filter,self)
def filter_t(self, b): """Filter by target type / label.""" if b.get_active() > 0: self.tids = map( lambda x: x[0], login.getProxy().loadJson( '/api/tbylabel', {'l': self.ll[b.get_active() - 1][0]})['d']) else: self.tids = None self.filter.refilter()
def key_press(self,widget,key): but = None if key.keyval in self.k_div and self.b_div is not None: but = self.b_div elif key.keyval in self.k_mul and self.b_mul is not None: but = self.b_mul elif key.keyval in self.k_left: but = self.b_ra_minus elif key.keyval in self.k_right: but = self.b_ra_plus elif key.keyval in self.k_up: but = self.b_dec_plus elif key.keyval in self.k_down: but = self.b_dec_minus elif key.keyval in self.k_stop: self.stop_pressed(widget) return True elif key.keyval in self.k_1 and self.b_dist is not None: self.set_dist(0) return True elif key.keyval in self.k_3 and self.b_dist is not None: self.set_dist(1) return True elif key.keyval in self.k_7 and self.b_dist is not None: self.set_dist(2) return True elif key.keyval in self.k_9 and self.b_dist is not None: self.set_dist(3) return True else: return False # if possible, null action which is in progress.. if (self.support_set_and_go == True): if key.keyval in self.k_left and self.b_ra_plus.get_active()==True: self.b_ra_plus.set_active(False) login.getProxy().setValue(self.telescope_name,'ra_guide', '0') return True if key.keyval in self.k_right and self.b_ra_minus.get_active()==True: self.b_ra_minus.set_active(False) login.getProxy().setValue(self.telescope_name,'ra_guide', '0') return True if key.keyval in self.k_down and self.b_dec_plus.get_active()==True: self.b_dec_plus.set_active(False) login.getProxy().setValue(self.telescope_name,'dec_guide', '0') return True if key.keyval in self.k_up and self.b_dec_minus.get_active()==True: self.b_dec_minus.set_active(False) login.getProxy().setValue(self.telescope_name,'dec_guide', '0') return True self.button_pressed(but) return True
def load_target(self,id): const = login.getProxy().loadJson('/api/consts',{'id':id}) for c in const: if c == 'maxRepeats': self.append([c,float('nan'),const[c]]) else: for interval in const[c]: mi,ma = interval if mi is None: mi = float('nan') if ma is None: ma = float('nan') self.append([c,mi,ma])
def __load_thread(self, rows, r, progressbar): for i in range(1, rows + 1): res = login.getProxy().chunkJson(r) def _add_row(data, res, progressbar, rows, i): data.append_row(res) if progressbar: progressbar.set_fraction(i / float(rows)) progressbar.set_text('{0} of {1}'.format( i, rows)) gobject.idle_add(_add_row, self.data, res, progressbar, rows, i)
def __create(self): saved = login.getProxy().loadJson('/api/create_target',{'tn':self.resolved_name.get_text(),'ra':self.tars['ra'],'dec':self.tars['dec'],'desc':self.resolved_desc.get_text()}) l = gtk.Label(_('Created target {0} with coordinates {1} {2} and target ID {3}').format(self.resolved_name.get_text(),radec.ra_string(self.tars['ra']),radec.dec_string(self.tars['dec']),saved['id'])) l.set_line_wrap(True) self.page3.pack_start(l) self.set_page_title(self.page3,_('Created new target')) self.used_target_id = saved['id'] self.set_title(_('Editing new target {0} ({1})').format(self.resolved_name.get_text(),self.used_target_id)) gobject.idle_add(self.set_current_page, 3)
def __init__(self): gtk.Table.__init__(self,2,2,False) self.tg = gtk.DrawingArea() self.fr = int(login.getProxy().getValue('centrald', 'sun_set', refresh_not_found=True) - 1800) self.to = int(login.getProxy().getValue('centrald', 'sun_rise') + 1800) if self.fr > self.to: self.fr -= 86400 self.targets = [] self.active_target = None self.update_lock = threading.Lock() self.data_rect = None self.sun_alts = [] self.tg.set_events(gtk.gdk.POINTER_MOTION_MASK | gtk.gdk.POINTER_MOTION_HINT_MASK) self.tg.connect('expose-event',self.expose) self.attach(self.tg,1,2,0,1,gtk.EXPAND|gtk.FILL,gtk.EXPAND|gtk.FILL) def motion_notify(ruler,event): return ruler.emit('motion-notify-event',event) self.vr = gtk.VRuler() self.vr.set_metric(gtk.PIXELS) self.vr.set_range(90,-90,10,90) self.tg.connect_object('motion-notify-event',motion_notify,self.vr) self.attach(self.vr,0,1,0,1,gtk.FILL,gtk.EXPAND|gtk.SHRINK|gtk.FILL) self.hr = houraxis.HourAxis(self.fr,self.to - self.fr) self.tg.connect_object('motion-notify-event',motion_notify,self.hr) self.attach(self.hr,1,2,1,2,gtk.EXPAND|gtk.SHRINK|gtk.FILL,gtk.FILL) self.rect = self.get_allocation() threading.Thread(target=self.update).start()
def name_changed(self, b): d = self.device.get_active_text() n = self.name.get_active_text() self.vf = login.getProxy().getVariable(d, n)[0] self.vb = rts2.json.RTS2_VALUE_BASETYPE & self.vf if self.operands: self.opbox.remove(self.operands) if self.vb == rts2.json.RTS2_VALUE_SELECTION: self.operands = login.getProxy().getSelectionComboEntry(d, n) self.operands.set_active(login.getProxy().getValue(d, n)) elif self.vb == rts2.json.RTS2_VALUE_INTEGER or self.vb == rts2.json.RTS2_VALUE_LONGINT: self.operands = gtk.SpinButton( gtk.Adjustment(0, -sys.maxint - 1, sys.maxint, 1, 10)) self.operands.set_width_chars(6) self.operands.set_value(int(login.getProxy().getValue(d, n))) elif self.vb == rts2.json.RTS2_VALUE_DOUBLE or self.vb == rts2.json.RTS2_VALUE_FLOAT: self.operands = gtk.SpinButton(gtk.Adjustment( 0, -sys.maxint - 1, sys.maxint, 1, 10), digits=3) self.operands.set_width_chars(6) self.operands.set_value(float(login.getProxy().getValue(d, n))) elif self.vb == rts2.json.RTS2_VALUE_BOOL: self.operands = gtk.HBox() self.rb_true = gtk.RadioButton(None, 'On') self.rb_false = gtk.RadioButton(self.rb_true, 'Off') self.operands.pack_start(self.rb_true) self.operands.pack_end(self.rb_false) if login.getProxy().getValue(d, n): self.rb_true.set_active(True) else: self.rb_false.set_active(True) else: self.operands = gtk.Entry() self.operands.set_width_chars(6) self.operands.set_text(str(login.getProxy().getValue(d, n))) if self.vb == rts2.json.RTS2_VALUE_STRING: if self.op: self.opbox.remove(self.op) self.opbox.pack_start(gtk.Label('='), False, False) self.op = None elif not self.op: self.op = gtk.combo_box_new_text() self.op.append_text('-=') self.op.append_text('=') self.op.append_text('+=') self.op.set_active(1) self.opbox.pack_start(self.op, False, False) self.opbox.pack_end(self.operands, True, True) self.opbox.show_all()
def __init__(self): self.night = datetime.date.today() # look for any old observations within last 12 months for c in range(0,11): d = login.getProxy().loadJson('/nights/{0}/{1}/api'.format(self.night.year,self.night.month))['d'] if len(d) > 0: self.night = self.night.replace(day=d[-1][0]) break self.night -= datetime.timedelta(days=28) jsontable.JsonSelectDialog.__init__(self,'/nights/{0}/{1}/{2}/api'.format(self.night.year,self.night.month,self.night.day),{},buttons=[(_('Show images'),3),(_('Update'),2),(_('Select night'),1)]) self.set_title(_('Night {0}').format(self.night)) self.connect('response',self.responded)
def stop_pressed(self,widget): if self.support_set_and_go == True: login.getProxy().setValue(self.telescope_name,'ra_guide', '0') login.getProxy().setValue(self.telescope_name,'dec_guide', '0') login.getProxy().executeCommand(self.telescope_name,'stop') self.b_ra_minus.set_active(False) self.b_ra_plus.set_active(False) self.b_dec_minus.set_active(False) self.b_dec_plus.set_active(False) self.b_stop.set_active(True) return True
def name_changed(self,b): d = self.device.get_active_text() n = self.name.get_active_text() self.vf = login.getProxy().getVariable(d,n)[0] self.vb = rts2.json.RTS2_VALUE_BASETYPE & self.vf if self.operands: self.opbox.remove(self.operands) if self.vb == rts2.json.RTS2_VALUE_SELECTION: self.operands = login.getProxy().getSelectionComboEntry(d,n) self.operands.set_active(login.getProxy().getValue(d,n)) elif self.vb == rts2.json.RTS2_VALUE_INTEGER or self.vb == rts2.json.RTS2_VALUE_LONGINT: self.operands = gtk.SpinButton(gtk.Adjustment(0,-sys.maxint - 1,sys.maxint,1,10)) self.operands.set_width_chars(6) self.operands.set_value(int(login.getProxy().getValue(d,n))) elif self.vb == rts2.json.RTS2_VALUE_DOUBLE or self.vb == rts2.json.RTS2_VALUE_FLOAT: self.operands = gtk.SpinButton(gtk.Adjustment(0,-sys.maxint - 1,sys.maxint,1,10),digits=3) self.operands.set_width_chars(6) self.operands.set_value(float(login.getProxy().getValue(d,n))) elif self.vb == rts2.json.RTS2_VALUE_BOOL: self.operands = gtk.HBox() self.rb_true = gtk.RadioButton(None,'On') self.rb_false = gtk.RadioButton(self.rb_true,'Off') self.operands.pack_start(self.rb_true) self.operands.pack_end(self.rb_false) if login.getProxy().getValue(d,n): self.rb_true.set_active(True) else: self.rb_false.set_active(True) else: self.operands = gtk.Entry() self.operands.set_width_chars(6) self.operands.set_text(str(login.getProxy().getValue(d,n))) if self.vb == rts2.json.RTS2_VALUE_STRING: if self.op: self.opbox.remove(self.op) self.opbox.pack_start(gtk.Label('='),False,False) self.op = None elif not self.op: self.op = gtk.combo_box_new_text() self.op.append_text('-=') self.op.append_text('=') self.op.append_text('+=') self.op.set_active(1) self.opbox.pack_start(self.op,False,False) self.opbox.pack_end(self.operands,True,True) self.opbox.show_all()
def reload(self): """Load target""" if self.id is None: if self.invalidText: self.label.set_markup(self.invalidText) else: self.label.set_markup('<b>{0}</b> not valid'.format(self.id)) return try: params = {'id':self.id, 'e':'1'} if self.start: params['from'] = int(self.start) self.data = login.getProxy().loadJson('/api/tbyid', params)['d'][0] except Exception,ex: import traceback traceback.print_exc(ex) self.label.set_markup('<b>{0}</b> not loaded'.format(self.id)) self.data = [self.id, 'does not exist', None, None, 360.0, 0, [], [], ['all'], None, False]
def exposure_thread(self,numexp=None): if self.exp_conn is None: self.exp_conn = login.getProxy().newConnection() self.numexp = numexp while self.numexp == None or self.numexp > 0: self.exp_p.set_fraction(0) self.readout_p.set_fraction(0) for x in self.data_pbs: x.set_fraction(0) try: self.take_exposure() except Exception,ex: print 'exposure or readout interrupted',ex traceback.print_exc() self.exp_conn = None self.numexp = 0 if self.numexp: self.numexp -= 1
def exposure_thread(self, numexp=None): if self.exp_conn is None: self.exp_conn = login.getProxy().newConnection() self.numexp = numexp while self.numexp == None or self.numexp > 0: self.exp_p.set_fraction(0) self.readout_p.set_fraction(0) for x in self.data_pbs: x.set_fraction(0) try: self.take_exposure() except Exception, ex: print 'exposure or readout interrupted', ex traceback.print_exc() self.exp_conn = None self.numexp = 0 if self.numexp: self.numexp -= 1
def __init__(self,camera): self.hb = gtk.HBox() self.camera = camera self.device = gtk.combo_box_new_text() for d in login.getProxy().loadJson('/api/devices'): self.device.append_text(d) self.device.connect('changed',self.device_changed) self.hb.pack_start(self.device,False,False) self.hb.pack_start(gtk.Label('.'),False,False) self.name = gtk.combo_box_new_text() self.name.connect('changed',self.name_changed) self.hb.pack_start(self.name,False,True) self.opbox = gtk.HBox() self.op = None self.operands = None
def __init__(self, camera): self.hb = gtk.HBox() self.camera = camera self.device = gtk.combo_box_new_text() for d in login.getProxy().loadJson('/api/devices'): self.device.append_text(d) self.device.connect('changed', self.device_changed) self.hb.pack_start(self.device, False, False) self.hb.pack_start(gtk.Label('.'), False, False) self.name = gtk.combo_box_new_text() self.name.connect('changed', self.name_changed) self.hb.pack_start(self.name, False, True) self.opbox = gtk.HBox() self.op = None self.operands = None
def reload(self): """Load target""" if self.id is None: if self.invalidText: self.label.set_markup(self.invalidText) else: self.label.set_markup('<b>{0}</b> not valid'.format(self.id)) return try: params = {'id': self.id, 'e': '1'} if self.start: params['from'] = int(self.start) self.data = login.getProxy().loadJson('/api/tbyid', params)['d'][0] except Exception, ex: import traceback traceback.print_exc(ex) self.label.set_markup('<b>{0}</b> not loaded'.format(self.id)) self.data = [ self.id, 'does not exist', None, None, 360.0, 0, [], [], ['all'], None, False ]
def __init__(self,id=None): gtk.Notebook.__init__(self) self.basic = TargetBasic() self.append_page(self.basic,gtk.Label(_('Target'))) self.alt = targets.TargetsConstraintBox() self.append_page(self.alt,gtk.Label(_('Altitude'))) self.observations = TargetObservation() self.append_page(self.observations,gtk.Label(_('Observations'))) self.cameras = login.getProxy().loadJson('/api/devbytype',{'t':3}) self.cameras.reverse() self.camid = [] self.scripts = [] if id: self.set_target(id) gobject.idle_add(self.show_all)