Exemple #1
0
    def __init__(self, widget):
        super().__init__()
        self.widget = widget
        self.beamline = Registry.get_utility(IBeamline)
        self.collector = DataCollector()
        self.collecting = False
        self.stopping = False
        self.pause_info = False
        self.start_time = 0
        self.frame_monitor = None
        self.first_frame = True
        self.monitors = {}
        self.image_viewer = ImageViewer()
        self.microscope = Registry.get_utility(IMicroscope)
        self.run_editor = datawidget.RunEditor()
        self.editor_frame = arrowframe.ArrowFrame()
        self.editor_frame.add(self.run_editor.data_form)
        self.widget.datasets_overlay.add_overlay(self.editor_frame)
        self.run_store = Gio.ListStore(item_type=datawidget.RunItem)
        self.run_store.connect('items-changed', self.on_runs_changed)

        self.collector.connect('done', self.on_done)
        self.collector.connect('paused', self.on_pause)
        self.collector.connect('stopped', self.on_stopped)
        self.collector.connect('progress', self.on_progress)
        self.collector.connect('started', self.on_started)
        Registry.add_utility(IDatasets, self)
        self.setup()
Exemple #2
0
 def __init__(self, console=False):
     from mxdc.conf import settings
     super().__init__()
     self.console = console
     self.config_files = settings.get_configs()
     self.registry = {}
     self.config = DotDict()
     self.lock = threading.RLock()
     self.logger = get_module_logger(self.__class__.__name__)
     self.load_config()
     Registry.add_utility(IBeamline, self)
Exemple #3
0
    def __init__(self, view, widget):
        super().__init__()
        self.model = Gtk.ListStore(*self.Data.TYPES)
        self.search_model = self.model.filter_new()
        self.search_model.set_visible_func(self.search_data)
        self.sort_model = Gtk.TreeModelSort(model=self.search_model)
        self.group_model = Gio.ListStore(item_type=GroupItem)
        self.group_registry = {}
        self.prefetch_pending = False
        self.initializing = True

        # initialize properties
        self.props.next_sample = {}
        self.props.current_sample = {}
        self.props.ports = set()
        self.props.containers = set()

        cache = load_cache('samples')
        self.props.cache = set() if not cache else set(cache)

        self.filter_text = ''

        self.view = view
        self.widget = widget
        self.view.set_model(self.sort_model)

        self.beamline = Registry.get_utility(IBeamline)

        self.setup()
        self.model.connect('row-changed', self.on_sample_row_changed)
        self.widget.samples_selectall_btn.connect('clicked',
                                                  self.on_select_all)
        self.widget.samples_selectnone_btn.connect('clicked',
                                                   self.on_unselect_all)
        self.view.connect('key-press-event', self.on_key_press)
        self.widget.samples_reload_btn.connect('clicked',
                                               lambda x: self.import_mxlive())
        self.beamline.automounter.connect('sample', self.on_sample_mounted)
        self.beamline.automounter.connect('next-port', self.on_prefetched)
        self.beamline.automounter.connect('ports', self.update_states)
        self.widget.samples_mount_btn.connect('clicked',
                                              lambda x: self.mount_action())
        self.widget.samples_dismount_btn.connect(
            'clicked', lambda x: self.dismount_action())
        self.widget.samples_search_entry.connect('search-changed',
                                                 self.on_search)
        self.widget.mxdc_main.connect('realize', self.import_mxlive)
        self.connect('notify::cache', self.on_cache)
        self.connect('notify::current-sample', self.on_cur_changed)
        self.connect('notify::next-sample', self.on_next_changed)

        Registry.add_utility(ISampleStore, self)
Exemple #4
0
    def __init__(self, root, threshold=0.5):
        super().__init__(threshold=threshold)
        self.name = root

        self.x = self.add_pv(f'{root}:x')
        self.y = self.add_pv(f'{root}:y')
        self.score = self.add_pv(f'{root}:score')
        self.w = self.add_pv(f'{root}:w')
        self.h = self.add_pv(f'{root}:h')
        self.label = self.add_pv(f'{root}:label')
        self.status = self.add_pv(f'{root}:status')
        self.score.connect('changed', self.on_score)

        Registry.add_utility(ICenter, self)
Exemple #5
0
    def __init__(self):
        super().__init__()
        self.pending_results = set()
        self.runs = []
        self.results = {}
        self.config = {}
        self.total_frames = 0
        self.count = 0

        self.analyst = Registry.get_utility(IAnalyst)
        self.analysis_link = self.beamline.detector.connect(
            'progress', self.on_frame_collected)
        self.unwatch_frames()

        Registry.add_utility(IRasterCollector, self)
Exemple #6
0
    def __init__(self, size=680):
        super(ImageViewer, self).__init__()
        self.setup_gui()
        self.set(0.5, 0.5, 1, 1)
        self.dataset = None
        self.canvas = None
        self.size = size
        self.following = False
        self.collecting = False
        self.following_id = None
        self.last_follow_time = 0
        self.directory = None

        self.reflections = []

        self.build_gui()
        Registry.add_utility(IImageViewer, self)
Exemple #7
0
    def __init__(self):
        super().__init__()

        self.run_list = []
        self.runs = []
        self.results = []
        self.config = {}
        self.total = 1
        self.current_wedge = None

        self.analyst = Registry.get_utility(IAnalyst)
        self.progress_link = self.beamline.detector.connect(
            'progress', self.on_progress)
        self.unwatch_frames()

        #self.beamline.synchrotron.connect('ready', self.on_beam_change)
        Registry.add_utility(IDataCollector, self)
Exemple #8
0
 def __init__(self, widget):
     self.plotter = plotter.Plotter()
     self.fit = Fit(self.plotter)
     self.widget = widget
     self.widget.scan_box.pack_start(self.plotter, True, True, 0)
     self.axis = self.plotter.axis.get('default')
     self.start_time = 0
     self.scan = None
     self.scan_links = []
     self.scan_callbacks = {
         'started': self.on_start,
         'new-point': self.on_new_point,
         'progress': self.on_progress,
         'done': self.on_done,
         'error': self.on_error,
         'stopped': self.on_stop,
         'new-row': self.on_new_row,
     }
     Registry.add_utility(IScanPlotter, self)
Exemple #9
0
    def __init__(self, widget):
        super().__init__()
        self.timeout_id = None
        self.max_fps = 20
        self.fps_update = 0
        self.video_ready = False
        self.queue_overlay()
        self.overlay_surface = None
        self.overlay_ctx = None

        self.props.grid = None
        self.props.grid_xyz = None
        self.props.points = []
        self.props.grid_bbox = []
        self.props.grid_scores = {}
        self.props.grid_params = {}
        self.props.grid_state = self.GridState.PENDING
        self.props.grid_cmap = colors.ColorMapper(min_val=0, max_val=100)
        self.props.tool = self.ToolState.DEFAULT
        self.prev_tool = self.tool

        self.tool_cursors = {
            self.ToolState.DEFAULT:
            None,
            self.ToolState.CENTERING:
            Gdk.Cursor.new_from_name(Gdk.Display.get_default(), 'pointer'),
            self.ToolState.GRID:
            Gdk.Cursor.new_from_name(Gdk.Display.get_default(), 'cell'),
            self.ToolState.MEASUREMENT:
            Gdk.Cursor.new_from_name(Gdk.Display.get_default(), 'crosshair'),
        }

        self.ruler_box = numpy.array([[0, 0], [0, 0]])

        self.widget = widget
        self.beamline = Registry.get_utility(IBeamline)
        self.camera = self.beamline.sample_video
        self.centering = centering.Centering()
        self.setup()

        Registry.add_utility(IMicroscope, self)
        self.load_from_cache()
Exemple #10
0
 def __init__(self, manager):
     super().__init__()
     self.manager = manager
     self.beamline = Registry.get_utility(IBeamline)
     Registry.add_utility(IAnalyst, self)