def _switch_factory(self, v_elem, klass=HardwareValve): name = v_elem.text.strip() address = v_elem.find('address') act_elem = v_elem.find('actuator') description = v_elem.find('description') interlocks = [i.text.strip() for i in v_elem.findall('interlock')] if description is not None: description = description.text.strip() actname = act_elem.text.strip() if act_elem is not None else 'valve_controller' actuator = self.get_actuator_by_name(actname) if actuator is None: if not globalv.ignore_initialization_warnings: self.warning_dialog( 'No actuator for {}. Valve will not operate. Check setupfiles/extractionline/valves.xml'.format( name)) qs = True vqs = v_elem.get('query_state') if vqs: qs = vqs == 'true' parent = v_elem.find('parent') parent_name = '' parent_inverted = False if parent is not None: parent_name = parent.text.strip() inverted = parent.find('inverted') if inverted is not None: parent_inverted = to_bool(inverted.text.strip()) check_actuation_enabled = True cae = v_elem.find('check_actuation_enabled') if cae is not None: check_actuation_enabled = to_bool(cae.text.strip()) check_actuation_delay = 0 cad = v_elem.find('check_actuation_delay') if cad is not None: check_actuation_delay = float(cad.text.strip()) hv = klass(name, address=address.text.strip() if address is not None else '', parent=parent_name, parent_inverted=parent_inverted, check_actuation_enabled=check_actuation_enabled, check_actuation_delay=check_actuation_delay, actuator=actuator, description=description, query_state=qs, interlocks=interlocks) return name, hv
def _load_devices(self): #read devices from config #get device from app app = self.application parser = self._get_parser() ds = [] for dev in parser.get_elements('device'): name = dev.text.strip() dname = dev.find('name') if dname is None: self.warning( 'no device name for {}. use a <name> tag'.format(name)) continue dev_name = dname.text.strip() device = None if app: device = app.get_service(ICoreDevice, query='name=="{}"'.format(dev_name)) if device is None: self.warning( 'no device named "{}" available'.format(dev_name)) continue enabled = dev.find('use') if enabled is not None: enabled = to_bool(enabled.text.strip()) d = DashboardDevice(name=name, use=bool(enabled), _device=device) for v in dev.findall('value'): n = v.text.strip() tag = '<{},{}>'.format(name, n) func_name = self._get_xml_value(v, 'func', 'get') period = self._get_xml_value(v, 'period', 60) if not period == 'on_change': try: period = int(period) except ValueError: period = 60 enabled = to_bool(self._get_xml_value(v, 'enabled', False)) timeout = self._get_xml_value(v, 'timeout', 0) d.add_value(n, tag, func_name, period, enabled, timeout) ds.append(d) self.devices = ds
def _load_devices(self): # read devices from config # get device from app app = self.application parser = self._get_parser() ds = [] for dev in parser.get_elements("device"): name = dev.text.strip() dname = dev.find("name") if dname is None: self.warning("no device name for {}. use a <name> tag".format(name)) continue dev_name = dname.text.strip() device = None if app: device = app.get_service(ICoreDevice, query='name=="{}"'.format(dev_name)) if device is None: self.warning('no device named "{}" available'.format(dev_name)) continue enabled = dev.find("use") if enabled is not None: enabled = to_bool(enabled.text.strip()) d = DashboardDevice(name=name, use=bool(enabled), _device=device) for v in dev.findall("value"): n = v.text.strip() tag = "<{},{}>".format(name, n) func_name = self._get_xml_value(v, "func", "get") period = self._get_xml_value(v, "period", 60) if not period == "on_change": try: period = int(period) except ValueError: period = 60 enabled = to_bool(self._get_xml_value(v, "enabled", False)) timeout = self._get_xml_value(v, "timeout", 0) d.add_value(n, tag, func_name, period, enabled, timeout) ds.append(d) self.devices = ds
def start(self): logger.debug('starting update plugin') pref=self.application.preferences # print pref.get('pychron.update.check_on_startup') if to_bool(pref.get('pychron.update.check_on_startup')): url=pref.get('pychron.update.update_url') if to_bool(pref.get('pychron.update.use_development')): url=pref.get('pychron.update.update_url') if url: self._check_for_updates(url) else: self._load_local_revision() else: self._load_local_revision()
def start(self): logger.debug('starting update plugin') pref = self.application.preferences # print pref.get('pychron.update.check_on_startup') if to_bool(pref.get('pychron.update.check_on_startup')): url = pref.get('pychron.update.update_url') if to_bool(pref.get('pychron.update.use_development')): url = pref.get('pychron.update.update_url') if url: self._check_for_updates(url) else: self._load_local_revision() else: self._load_local_revision()
def prepare(self): self.info('Prepare laser') self._ask('Prepare') cnt = 0 tries = 0 maxtries = 200 # timeout after 50 s if globalv.experiment_debug: maxtries = 1 nsuccess = 1 self._cancel_blocking = False ask = self._ask period = 1 cmd = 'IsReady' while tries < maxtries and cnt < nsuccess: if self._cancel_blocking: break time.sleep(period) resp = ask(cmd) if resp is not None: try: if to_bool(resp): cnt += 1 except: cnt = 0 else: cnt = 0 tries += 1 return cnt >= nsuccess
def _new_label(self, label, name, c, layer=1, origin=None, klass=None, **kw): if origin is None: ox, oy = 0, 0 else: ox, oy = origin if klass is None: klass = Label x, y = 0, 0 trans = label.find('translation') if trans is not None: x, y = map(float, trans.text.split(',')) c = self._make_color(c) l = klass(ox + x, oy + y, bgcolor=c, use_border=to_bool(label.get('use_border', 'T')), name=name, text=label.text.strip(), **kw) font = label.find('font') if font is not None: l.font = font.text.strip() self.add_item(l, layer=layer) return l
def _monitor_factory(self): mon = None isok = True self.debug('Experiment Executor mode={}'.format(self.mode)) if self.mode == 'client': ip = InitializationParser() exp = ip.get_plugin('Experiment', category='general') monitor = exp.find('monitor') if monitor is not None: if to_bool(monitor.get('enabled')): host, port, kind = None, None, None comms = monitor.find('communications') host = comms.find('host') port = comms.find('port') kind = comms.find('kind') if host is not None: host = host.text # if host else 'localhost' if port is not None: port = int(port.text) # if port else 1061 if kind is not None: kind = kind.text mon = RemoteAutomatedRunMonitor(host, port, kind, name=monitor.text.strip()) else: mon = AutomatedRunMonitor() self.debug('Automated run monitor {}'.format(mon)) if mon is not None: # mon.configuration_dir_name = paths.monitors_dir isok = mon.load() if isok: return mon else: self.warning( 'no automated run monitor avaliable. Make sure config file is located at setupfiles/monitors/automated_run_monitor.cfg')
def set_dac(self, v, verbose=False): micro = self.microcontroller unprotect = False unblank=False if micro: if self.use_detector_protection: if abs(self._dac - v) >self.detector_protection_threshold: for pd in self.protected_detectors: micro.ask('ProtectDetector {},On'.format(pd), verbose=verbose) unprotect = True elif self.use_beam_blank: if abs(self._dac - v) >self.beam_blank_threshold: micro.ask('BlankBeam True', verbose=verbose) unblank=True micro.ask('SetMagnetDAC {}'.format(v), verbose=verbose) time.sleep(self.settling_time) for i in xrange(50): if not to_bool(micro.ask('GetMagnetMoving')): break time.sleep(0.25) if unprotect: for pd in self.protected_detectors: micro.ask('ProtectDetector {},Off'.format(pd), verbose=verbose) if unblank: micro.ask('BlankBeam False', verbose=verbose) self._dac = v self.dac_changed = True
def set_dac(self, v, verbose=False): micro = self.microcontroller unprotect = False unblank = False if micro: if self.use_detector_protection: if abs(self._dac - v) > self.detector_protection_threshold: for pd in self.protected_detectors: micro.ask('ProtectDetector {},On'.format(pd), verbose=verbose) unprotect = True elif self.use_beam_blank: if abs(self._dac - v) > self.beam_blank_threshold: micro.ask('BlankBeam True', verbose=verbose) unblank = True micro.ask('SetMagnetDAC {}'.format(v), verbose=verbose) time.sleep(self.settling_time) for i in xrange(50): if not to_bool(micro.ask('GetMagnetMoving')): break time.sleep(0.25) if unprotect: for pd in self.protected_detectors: micro.ask('ProtectDetector {},Off'.format(pd), verbose=verbose) if unblank: micro.ask('BlankBeam False', verbose=verbose) self._dac = v self.dac_changed = True
def get_channel_state(self, obj): """ Query the hardware for the channel state """ cmd = 'GetValveState {}'.format(get_valve_name(obj)) resp = self.ask(cmd) if resp is not None: resp = to_bool(resp.strip()) return resp
def GoToHole(self, manager, hole, autocenter, *args): try: hole = int(hole) autocenter = to_bool(autocenter) err = manager.stage_manager.move_to_hole( str(hole), correct_position=autocenter) except (ValueError, TypeError): err = InvalidArgumentsErrorCode('GoToHole', (hole, autocenter)) return self.error_response(err)
def GoToHole(self, manager, hole, autocenter, *args): try: hole = int(hole) autocenter = to_bool(autocenter) err = manager.stage_manager.move_to_hole(str(hole), correct_position=autocenter) except (ValueError, TypeError): err = InvalidArgumentsErrorCode('GoToHole', (hole, autocenter)) return self.error_response(err)
def _block(self, cmd='GetDriveMoving', period=0.25, position_callback=None): ask = self._ask cnt = 0 tries = 0 maxtries = int(50 / float(period)) # timeout after 50 s nsuccess = 2 self._cancel_blocking = False while tries < maxtries and cnt < nsuccess: if self._cancel_blocking: break time.sleep(period) resp = ask(cmd) if self._communicator.simulation: resp = 'False' if resp is not None: try: if not to_bool(resp): cnt += 1 except (ValueError, TypeError): cnt = 0 if position_callback: if self._communicator.simulation: x, y, z = cnt / 3., cnt / 3., 0 position_callback(x, y, z) else: xyz = self.get_position() if xyz: position_callback(*xyz) else: cnt = 0 tries += 1 state = cnt >= nsuccess if state: self.info('Block completed') else: if self._cancel_blocking: self.info('Block failed. canceled by user') else: self.warning('Block failed. timeout after {}s'.format( maxtries * period)) return state
def get_initialization_model(): ip=InitializationParser() rtree = load_plugin_tree() gtree = load_global_tree() for gi in ip.get_plugin_groups(): tree = get_tree(gi, rtree) if tree: for pp in ip.get_plugins(gi, element=True): plugin = get_plugin(pp.text.strip(), tree) if plugin: plugin.enabled = to_bool(pp.get('enabled')) for gi in ip.get_globals(): gv = gtree.get_value(gi.tag) if gv: gv.enabled = to_bool(gi.text.strip()) model = InitializationModel(trees=[gtree, rtree], parser=ip) model.init_hash() return model
def get_channel_state(self, obj): ''' Query the hardware for the channel state ''' # returns one if channel close 0 for open # boolfunc = lambda x:True if x in ['True', 'true', 'T', 't'] else False cmd = 'GetValveState {}'.format(self._get_valve_name(obj)) resp = self.ask(cmd) if resp is not None: resp = to_bool(resp.strip()) return resp
def get_plugins(self, category=None, all_=False, element=False): tree = self.get_root() tree = tree.find('plugins') if category: cat = tree.find(category) if cat is not None: plugins = cat.findall('plugin') else: try: plugins = tree.iter(tag='plugin') except AttributeError: plugins = tree.getiterator(tag='plugin') return [p if element else p.text.strip() for p in plugins if all_ or to_bool(p.get('enabled'))]
def _block(self, cmd='GetDriveMoving', period=0.25, position_callback=None): ask = self._ask cnt = 0 tries = 0 maxtries = int(50 / float(period)) # timeout after 50 s nsuccess = 2 self._cancel_blocking = False while tries < maxtries and cnt < nsuccess: if self._cancel_blocking: break time.sleep(period) resp = ask(cmd) if self._communicator.simulation: resp = 'False' if resp is not None: try: if not to_bool(resp): cnt += 1 except (ValueError, TypeError): cnt = 0 if position_callback: if self._communicator.simulation: x, y, z = cnt / 3., cnt / 3., 0 position_callback(x, y, z) else: xyz = self.get_position() if xyz: position_callback(*xyz) else: cnt = 0 tries += 1 state = cnt >= nsuccess if state: self.info('Block completed') else: if self._cancel_blocking: self.info('Block failed. canceled by user') else: self.warning('Block failed. timeout after {}s'.format(maxtries * period)) return state
def set_dac(self, v, verbose=False): self.debug('setting dac {}'.format(v)) micro = self.microcontroller unprotect = False unblank=False if micro: if self.use_detector_protection: if abs(self._dac - v) >self.detector_protection_threshold: for pd in self.protected_detectors: micro.ask('ProtectDetector {},On'.format(pd), verbose=verbose) unprotect = True elif self.use_beam_blank: if abs(self._dac - v) >self.beam_blank_threshold: micro.ask('BlankBeam True', verbose=verbose) unblank=True micro.ask('SetMagnetDAC {}'.format(v), verbose=verbose) time.sleep(self.settling_time) #only block if move is large and was made slowly. #this should be more explicit. get MAGNET_MOVE_THRESHOLD from RCS # and use it as to test whether to GetMagnetMoving if unprotect or unblank: for i in xrange(50): if not to_bool(micro.ask('GetMagnetMoving')): break time.sleep(0.25) if unprotect: for pd in self.protected_detectors: micro.ask('ProtectDetector {},Off'.format(pd), verbose=verbose) if unblank: micro.ask('BlankBeam False', verbose=verbose) change = v != self._dac if change: self._dac = v self.dac_changed = True return change
def _new_rectangle(self, elem, c, bw=3, layer=1, origin=None, type_tag=''): if origin is None: ox, oy = 0, 0 else: ox, oy = origin key = elem.text.strip() display_name = elem.get('display_name', key) fill = to_bool(elem.get('fill', 'T')) x, y = self._get_floats(elem, 'translation') w, h = self._get_floats(elem, 'dimension') color = elem.find('color') if color is not None: c = color.text.strip() cobj = self.get_item(c) if cobj is not None: c = cobj.default_color else: c = self._make_color(c) rect = RoundedRectangle( x + ox, y + oy, width=w, height=h, name=key, border_width=bw, display_name=display_name, default_color=c, type_tag=type_tag, fill=fill, ) font = elem.find('font') if font is not None: rect.font = font.text.strip() self.add_item(rect, layer=layer) return rect
def _monitor_factory(self): mon = None isok = True self.debug('Experiment Executor mode={}'.format(self.mode)) if self.mode == 'client': ip = InitializationParser() exp = ip.get_plugin('Experiment', category='general') monitor = exp.find('monitor') if monitor is not None: if to_bool(monitor.get('enabled')): host, port, kind = None, None, None comms = monitor.find('communications') host = comms.find('host') port = comms.find('port') kind = comms.find('kind') if host is not None: host = host.text # if host else 'localhost' if port is not None: port = int(port.text) # if port else 1061 if kind is not None: kind = kind.text mon = RemoteAutomatedRunMonitor(host, port, kind, name=monitor.text.strip()) else: mon = AutomatedRunMonitor() self.debug('Automated run monitor {}'.format(mon)) if mon is not None: # mon.configuration_dir_name = paths.monitors_dir isok = mon.load() if isok: return mon else: self.warning( 'no automated run monitor avaliable. Make sure config file is located at setupfiles/monitors/automated_run_monitor.cfg' )
def _new_rectangle(self, elem, c, bw=3, layer=1, origin=None, type_tag=''): if origin is None: ox, oy = 0, 0 else: ox, oy = origin key = elem.text.strip() display_name = elem.get('display_name', key) fill = to_bool(elem.get('fill', 'T')) x, y = self._get_floats(elem, 'translation') w, h = self._get_floats(elem, 'dimension') color = elem.find('color') if color is not None: c = color.text.strip() cobj = self.get_item(c) if cobj is not None: c = cobj.default_color else: c = self._make_color(c) rect = RoundedRectangle(x + ox, y + oy, width=w, height=h, name=key, border_width=bw, display_name=display_name, volume=get_volume(elem), default_color=c, type_tag=type_tag, fill=fill) font = elem.find('font') if font is not None: rect.font = font.text.strip() self.add_item(rect, layer=layer) return rect
def _get_affirmation(self, cmd): token = self.get_tokens(cmd)[0] b = to_bool(token) return b
def _my_task_extensions_default(self): def figure_group(): return Group(SpectrumAction(), IdeogramAction(), InverseIsochronAction(), SeriesAction()) def data_menu(): return SMenu(id="data.menu", name="Data") def vcs_menu(): return SMenu(id="vcs.menu", name="VCS") def grouping_group(): return Group(GroupSelectedAction(), GroupbyAliquotAction(), GroupbyLabnumberAction(), ClearGroupAction()) def reduction_group(): return Group( IsotopeEvolutionAction(), BlankEditAction(), ICFactorAction(), DiscriminationAction(), FluxAction() ) def interpreted_group(): return Group( SetInterpretedAgeAction(), OpenInterpretedAgeAction(), OpenInterpretedAgeGroupAction(), DeleteInterpretedAgeGroupAction(), MakeGroupFromFileAction(), ) def easy_group(): return Group(EasyImportAction(), EasyFiguresAction(), EasyTablesAction(), EasySensitivityAction()) default_actions = [ ("recall_action", RecallAction, "MenuBar/File"), ("find_action", OpenAdvancedQueryAction, "MenuBar/File"), ("batch_edit", BatchEditAction, "MenuBar/Edit"), ("data", data_menu, "MenuBar", {"before": "tools.menu", "after": "view.menu"}), ("reduction_group", reduction_group, "MenuBar/data.menu"), ("figure_group", figure_group, "MenuBar/data.menu"), ("interpreted_group", interpreted_group, "MenuBar/data.menu"), ("tag", TagAction, "MenuBar/data.menu"), ("database_save", DatabaseSaveAction, "MenuBar/data.menu"), ("grouping_group", grouping_group, "MenuBar/data.menu"), ("clear_cache", ClearAnalysisCacheAction, "MenuBar/data.menu"), ("export_analyses", ExportAnalysesAction, "MenuBar/File"), ("equil_inspector", EquilibrationInspectorAction, "MenuBar/tools.menu"), ] exts = [self._make_task_extension(default_actions)] use_vcs = to_bool(self.application.preferences.get("pychron.vcs.use_vcs")) if use_vcs: exts.append( self._make_task_extension( [ ("vcs", vcs_menu, "MenuBar", {"after": "view.menu"}), ("vcs_pull", PullVCSAction, "MenuBar/vcs.menu"), ("vcs_push", PushVCSAction, "MenuBar/vcs.menu"), ] ) ) use_easy = to_bool(self.application.preferences.get("pychron.processing.use_easy")) if use_easy: grp = self._make_task_extension([("easy_group", easy_group, "MenuBar/tools.menu")]) a = self._make_task_extension( [ ("optimal_equilibration", CalcOptimalEquilibrationAction, "MenuBar/tools.menu"), ("easy_fit", EasyFitAction, "MenuBar/tools.menu/easy.group"), ], task_id="pychron.processing.isotope_evolution", ) b = self._make_task_extension( [("easy_blanks", EasyBlanksAction, "MenuBar/Tools/easy.group")], task_id="pychron.processing.blanks" ) c = self._make_task_extension( [("easy_disc", EasyDiscriminationAction, "MenuBar/tools.menu/easy.group")], task_id="pychron.processing.discrimination", ) d = self._make_task_extension( [("easy_ic", EasyICAction, "MenuBar/tools.menu/easy.group")], task_id="pychron.processing.ic_factor" ) e = self._make_task_extension( [("easy_flux", EasyFluxAction, "MenuBar/tools.menu")], task_id="pychron.processing.flux" ) exts.extend((grp, a, b, c, d, e)) return exts
def set_motor_lock(self, name, value): m = self.get_motor(name) if m is not None: m.locked = to_bool(value) return True
'disable_between_positions', # ver 2.0 ('dis_btw_pos', 'disable_between_positions') ]: attr = self._get_attr(attr) idx = self._get_idx(header, attr) if idx: try: param = args[idx] except IndexError: params[rattr] = False continue if param.strip(): bo = to_bool(param) if bo is not None: params[rattr] = bo else: params[rattr] = False # load numbers for attr in ['duration', # 'overlap', 'cleanup', # 'aliquot', 'ramp_duration', # ver 1.0 'extract_group',
def _get_parameters(self, subtree, tag, all_=False, element=False): return [d if element else d.text.strip() for d in subtree.findall(tag) if all_ or to_bool(d.get('enabled'))]
def get_managers(self, elem, all_=False, element=False): return [m if element else m.text.strip() for m in elem.findall('manager') if all_ or to_bool(m.get('enabled'))]
def _set_use_cdd_warming_text(self, v): self.item.use_cdd_warming = to_bool(v)
def load(self, path): parser = ElementTree(file=open(path, 'r')) circles = parser.find('circles') outline = parser.find('outline') bb = outline.find('bounding_box') bs = bb.find('width'), bb.find('height') w, h = map(lambda b: float(b.text), bs) use_label = parser.find('use_label') if use_label is not None: use_label = to_bool(use_label.text.strip()) else: use_label = True data = ArrayPlotData() p = Plot(data=data, padding=100) p.x_grid.visible = False p.y_grid.visible = False p.x_axis.title = 'X cm' p.y_axis.title = 'Y cm' font = 'modern 22' p.x_axis.title_font = font p.x_axis.tick_label_font = font p.y_axis.title_font = font p.y_axis.tick_label_font = font # p.x_axis_visible = False # p.y_axis_visible = False p.index_range.low_setting = -w / 2 p.index_range.high_setting = w / 2 p.value_range.low_setting = -h / 2 p.value_range.high_setting = h / 2 thetas = linspace(0, 2 * pi) radius = circles.find('radius').text radius = float(radius) face_color = circles.find('face_color') if face_color is not None: face_color = face_color.text else: face_color = 'white' for i, pp in enumerate(circles.findall('point')): x, y, l = pp.find('x').text, pp.find('y').text, pp.find( 'label').text # print i, pp, x, y # load hole specific attrs r = pp.find('radius') if r is None: r = radius else: r = float(r.text) fc = pp.find('face_color') if fc is None: fc = face_color else: fc = fc.text x, y = map(float, (x, y)) xs = x + r * sin(thetas) ys = y + r * cos(thetas) xn, yn = 'px{:03n}'.format(i), 'py{:03n}'.format(i) data.set_data(xn, xs) data.set_data(yn, ys) plot = p.plot( (xn, yn), face_color=fc, type='polygon', )[0] if use_label: label = myDataLabel( component=plot, data_point=(x, y), label_text=l, bgcolor='transparent', ) plot.overlays.append(label) self.container.add(p)
def _my_task_extensions_default(self): def figure_group(): return Group( SpectrumAction(), IdeogramAction(), InverseIsochronAction(), SeriesAction(), XYScatterAction(), MenuManager(IdeogramFromFile(), SpectrumFromFile(), name='From File'), RefreshActiveEditorAction(), name='Figures') def data_menu(): return SMenu(id='data.menu', name='Data') # def vcs_menu(): # return SMenu(id='vcs.menu', name='VCS') def grouping_group(): return SMenu(Group(GroupSelectedAction(), GroupbyAliquotAction(), GroupbyLabnumberAction(), GroupbySampleAction(), ClearGroupAction()), Group(GraphGroupSelectedAction(), GraphGroupbySampleAction()), name='Grouping') def reduction_group(): return Group(IsotopeEvolutionAction(), BlankEditAction(), ICFactorAction(), DiscriminationAction(), FluxAction(), name='Reduction') def interpreted_group(): return SMenu(SetInterpretedAgeAction(), OpenInterpretedAgeAction(), OpenInterpretedAgeGroupAction(), DeleteInterpretedAgeGroupAction(), MakeGroupFromFileAction(), name='Interpreted Ages') def analysis_group(): return SMenu(MakeAnalysisGroupAction(), DeleteAnalysisGroupAction(), name='Analysis Grouping') def recall_group(): return Group(RecallAction(), # OpenAdvancedQueryAction(), ConfigureRecallAction()) def misc_group(): return Group(TagAction(), DataReductionTagAction(), SelectDataReductionTagAction(), DatabaseSaveAction(), ClearAnalysisCacheAction(), MakeTASAction(), ModifyK3739Action(), CalculationViewAction(), SummaryLabnumberAction(), name='misc') def activate_group(): return Group(ActivateBlankAction(), ActivateRecallAction(), ActivateIdeogramAction()) default_actions = [('recall_action', RecallAction, 'MenuBar/file.menu'), #('find_action', OpenAdvancedQueryAction, 'MenuBar/file.menu'), ('export_analyses', ExportAnalysesAction, 'MenuBar/file.menu'), ('batch_edit', BatchEditAction, 'MenuBar/Edit'), ('recall_group', recall_group, 'MenuBar/data.menu', {'absolute_position': 'first'}), ('data', data_menu, 'MenuBar', {'before': 'tools.menu', 'after': 'view.menu'}), ('activate_group', activate_group, 'MenuBar/view.menu'), ('reduction_group', reduction_group, 'MenuBar/data.menu'), ('figure_group', figure_group, 'MenuBar/data.menu'), ('interpreted_group', interpreted_group, 'MenuBar/data.menu'), ('grouping_group', grouping_group, 'MenuBar/data.menu'), ('misc_group', misc_group, 'MenuBar/data.menu'), # ('tag', TagAction, 'MenuBar/data.menu'), # ('database_save', DatabaseSaveAction, 'MenuBar/data.menu'), # ('graph_grouping_group', graph_grouping_group, 'MenuBar/data.menu'), # ('clear_cache', ClearAnalysisCacheAction, 'MenuBar/data.menu'), ('make_analysis_group', analysis_group, 'MenuBar/data.menu'), ('make_data_tables', MakeDataTablesAction, 'MenuBar/data.menu', {'absolute_position': 'last'}), # ('make_tas', MakeTASAction, 'MenuBar/data.menu'), # ('modify_k3739', ModifyK3739Action, 'MenuBar/data.menu'), ('equil_inspector', EquilibrationInspectorAction, 'MenuBar/tools.menu'), # ('split_editor_area', SplitEditorActionHor, 'MenuBar/window.menu'), ('split_editor_area', SplitEditorActionVert, 'MenuBar/window.menu')] exts = [self._make_task_extension(default_actions)] # use_vcs = to_bool(self.application.preferences.get('pychron.vcs.use_vcs')) # if use_vcs: # exts.append(self._make_task_extension([('vcs', vcs_menu, 'MenuBar', {'after': 'view.menu'}), # ('vcs_pull', PullVCSAction, 'MenuBar/vcs.menu'), # ('vcs_push', PushVCSAction, 'MenuBar/vcs.menu')])) use_easy = to_bool(self.application.preferences.get('pychron.processing.use_easy')) if use_easy: def easy_group(): return Group(EasyImportAction(), EasyFiguresAction(), EasyCompareAction(), EasyTablesAction(), EasySensitivityAction(), EasyFaradayICAction(), EasyAverageBlanksAction(), id='easy.group') grp = self._make_task_extension([('easy_group', easy_group, 'MenuBar/tools.menu')]) a = self._make_task_extension( [('optimal_equilibration', CalcOptimalEquilibrationAction, 'MenuBar/tools.menu'), ('easy_fit', EasyFitAction, 'MenuBar/tools.menu')], task_id='pychron.processing.isotope_evolution') b = self._make_task_extension([('easy_blanks', EasyBlanksAction, 'MenuBar/tools.menu')], task_id='pychron.processing.blanks') c = self._make_task_extension([('easy_disc', EasyDiscriminationAction, 'MenuBar/tools.menu')], task_id='pychron.processing.discrimination') d = self._make_task_extension([('easy_ic', EasyICAction, 'MenuBar/tools.menu')], task_id='pychron.processing.ic_factor') e = self._make_task_extension([('easy_flux', EasyFluxAction, 'MenuBar/tools.menu')], task_id='pychron.processing.flux') exts.extend((grp, a, b, c, d, e)) return exts
def get_lock_state(self, obj): cmd = 'GetValveLockState {}'.format(get_valve_name(obj)) resp = self.ask(cmd) if resp is not None: resp = resp.strip() return to_bool(resp)
def load(self, path): parser = ElementTree(file=open(path, 'r')) circles = parser.find('circles') outline = parser.find('outline') bb = outline.find('bounding_box') bs = bb.find('width'), bb.find('height') w, h = map(lambda b:float(b.text), bs) use_label = parser.find('use_label') if use_label is not None: use_label = to_bool(use_label.text.strip()) else: use_label = True data = ArrayPlotData() p = Plot(data=data, padding=100) p.x_grid.visible = False p.y_grid.visible = False p.x_axis.title = 'X cm' p.y_axis.title = 'Y cm' font = 'modern 22' p.x_axis.title_font = font p.x_axis.tick_label_font = font p.y_axis.title_font = font p.y_axis.tick_label_font = font # p.x_axis_visible = False # p.y_axis_visible = False p.index_range.low_setting = -w / 2 p.index_range.high_setting = w / 2 p.value_range.low_setting = -h / 2 p.value_range.high_setting = h / 2 thetas = linspace(0, 2 * pi) radius = circles.find('radius').text radius = float(radius) face_color = circles.find('face_color') if face_color is not None: face_color = face_color.text else: face_color = 'white' for i, pp in enumerate(circles.findall('point')): x, y, l = pp.find('x').text, pp.find('y').text, pp.find('label').text # print i, pp, x, y # load hole specific attrs r = pp.find('radius') if r is None: r = radius else: r = float(r.text) fc = pp.find('face_color') if fc is None: fc = face_color else: fc = fc.text x, y = map(float, (x, y)) xs = x + r * sin(thetas) ys = y + r * cos(thetas) xn, yn = 'px{:03n}'.format(i), 'py{:03n}'.format(i) data.set_data(xn, xs) data.set_data(yn, ys) plot = p.plot((xn, yn), face_color=fc, type='polygon', )[0] if use_label: label = myDataLabel(component=plot, data_point=(x, y), label_text=l, bgcolor='transparent', ) plot.overlays.append(label) self.container.add(p)
def _my_task_extensions_default(self): def figure_group(): return Group(SpectrumAction(), IdeogramAction(), InverseIsochronAction(), SeriesAction()) def data_menu(): return SMenu(id='data.menu', name='Data') def vcs_menu(): return SMenu(id='vcs.menu', name='VCS') def grouping_group(): return Group(GroupSelectedAction(), GroupbyAliquotAction(), GroupbyLabnumberAction(), ClearGroupAction()) def reduction_group(): return Group(IsotopeEvolutionAction(), BlankEditAction(), ICFactorAction(), DiscriminationAction(), FluxAction()) def interpreted_group(): return Group(SetInterpretedAgeAction(), OpenInterpretedAgeAction(), OpenInterpretedAgeGroupAction(), DeleteInterpretedAgeGroupAction(), MakeGroupFromFileAction()) def easy_group(): return Group(EasyImportAction(), EasyFiguresAction(), EasyTablesAction(), EasySensitivityAction()) default_actions = [ ('recall_action', RecallAction, 'MenuBar/File'), ('find_action', OpenAdvancedQueryAction, 'MenuBar/File'), ('batch_edit', BatchEditAction, 'MenuBar/Edit'), ('data', data_menu, 'MenuBar', { 'before': 'tools.menu', 'after': 'view.menu' }), ('reduction_group', reduction_group, 'MenuBar/data.menu'), ('figure_group', figure_group, 'MenuBar/data.menu'), ('interpreted_group', interpreted_group, 'MenuBar/data.menu'), ('tag', TagAction, 'MenuBar/data.menu'), ('database_save', DatabaseSaveAction, 'MenuBar/data.menu'), ('grouping_group', grouping_group, 'MenuBar/data.menu'), ('clear_cache', ClearAnalysisCacheAction, 'MenuBar/data.menu'), ('export_analyses', ExportAnalysesAction, 'MenuBar/File'), ('equil_inspector', EquilibrationInspectorAction, 'MenuBar/tools.menu') ] exts = [self._make_task_extension(default_actions)] use_vcs = to_bool( self.application.preferences.get('pychron.vcs.use_vcs')) if use_vcs: exts.append( self._make_task_extension([('vcs', vcs_menu, 'MenuBar', { 'after': 'view.menu' }), ('vcs_pull', PullVCSAction, 'MenuBar/vcs.menu'), ('vcs_push', PushVCSAction, 'MenuBar/vcs.menu')])) use_easy = to_bool( self.application.preferences.get('pychron.processing.use_easy')) if use_easy: grp = self._make_task_extension([('easy_group', easy_group, 'MenuBar/tools.menu')]) a = self._make_task_extension( [('optimal_equilibration', CalcOptimalEquilibrationAction, 'MenuBar/tools.menu'), ('easy_fit', EasyFitAction, 'MenuBar/tools.menu/easy.group')], task_id='pychron.processing.isotope_evolution') b = self._make_task_extension([ ('easy_blanks', EasyBlanksAction, 'MenuBar/Tools/easy.group') ], task_id='pychron.processing.blanks') c = self._make_task_extension( [('easy_disc', EasyDiscriminationAction, 'MenuBar/tools.menu/easy.group')], task_id='pychron.processing.discrimination') d = self._make_task_extension( [('easy_ic', EasyICAction, 'MenuBar/tools.menu/easy.group')], task_id='pychron.processing.ic_factor') e = self._make_task_extension( [('easy_flux', EasyFluxAction, 'MenuBar/tools.menu')], task_id='pychron.processing.flux') exts.extend((grp, a, b, c, d, e)) return exts