本文整理汇总了Python中pychron.core.ui.thread.Thread类的典型用法代码示例。如果您正苦于以下问题:Python Thread类的具体用法?Python Thread怎么用?Python Thread使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Thread类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: _do_execute
def _do_execute(self):
mapper = self.mapper
mapper.laser_manager = self._laser_manager
editor = self.editor
padding = editor.padding
# if editor.discrete_scan:
# mapper.canvas = self.canvas
# self.component = self.canvas
# else:
c = mapper.make_component(padding)
self.component = c
bd = editor.beam_diameter
rp = editor.request_power
cx = editor.center_x
cy = editor.center_y
step_len = editor.step_length
t = Thread(target=mapper.do_power_mapping,
args=(bd, rp, cx, cy, padding, step_len))
t.start()
self._execute_thread = t
return True
开发者ID:OSUPychron,项目名称:pychron,代码行数:27,代码来源:power_map_editor.py
示例2: _home_fired
def _home_fired(self):
"""
"""
t = Thread(name='stage.home', target=self._home)
t.start()
# need to store a reference to thread so it is not garbage collected
self.move_thread = t
开发者ID:NMGRL,项目名称:pychron,代码行数:7,代码来源:stage_manager.py
示例3: _test1
def _test1(self):
self.test_image.setup_images(3,
# (475, 613)
(640, 480)
)
t = Thread(target=self._test)
t.start()
self._t = t
开发者ID:UManPychron,项目名称:pychron,代码行数:9,代码来源:zoom_calibration.py
示例4: execute
def execute(self, block=False, duration=None, thread_safe=True):
"""
if block is true wait for patterning to finish
before returning
"""
if not self.pattern:
return
self.start(show=self.show_patterning)
evt = None
# if current_thread().name != 'MainThread':
if thread_safe:
evt = Event()
invoke_in_main_thread(self._pre_execute, evt)
while not evt.is_set():
time.sleep(0.05)
else:
self._pre_execute(evt)
self.debug('execute xy pattern')
xyp = self.pattern.xy_pattern_enabled
if duration:
self.pattern.external_duration = float(duration)
if xyp:
self._xy_thread = Thread(target=self._execute_xy_pattern)
self._xy_thread.start()
pp = self.pattern.power_pattern
if pp:
self.debug('execute power pattern')
self._power_thread = Thread(target=self._execute_power_pattern)
self._power_thread.start()
zp = self.pattern.z_pattern
if zp:
self.debug('execute z pattern')
self._z_thread = Thread(target=self._execute_z_pattern)
self._z_thread.start()
if block:
if self._xy_thread:
self._xy_thread.join()
if self._z_thread:
self._z_thread.join()
if self._power_thread:
self._power_thread.join()
self.finish()
开发者ID:NMGRL,项目名称:pychron,代码行数:51,代码来源:pattern_executor.py
示例5: _test_fired
def _test_fired(self):
from pychron.globals import globalv
p = '/Users/ross/Sandbox/test_target.jpg'
# p = '/Users/ross/Sandbox/pos_err/pos_err_200_0-002.jpg'
p = '/Users/ross/Sandbox/poserror/pos_err_221_0-007.jpg'
# p = '/Users/ross/Sandbox/poserror/snapshot009.jpg'
# force video to reload test image
self.video.source_frame = None
globalv.video_test_path = p
im = self.setup_image()
# self._test2(im)
from pychron.core.ui.thread import Thread
t = Thread(target=self._test2, args=(im,))
t.start()
self._t = t
开发者ID:UManPychron,项目名称:pychron,代码行数:18,代码来源:test_mv_manager.py
示例6: do_peak_center
def do_peak_center(self,
save=True,
confirm_save=False,
warn=False,
new_thread=True):
self.debug('doing pc')
self.canceled = False
self.alive = True
args = (save, confirm_save, warn)
if new_thread:
t = Thread(name='ion_optics.peak_center', target=self._peak_center,
args=args)
t.start()
self._thread = t
return t
else:
self._peak_center(*args)
开发者ID:jirhiker,项目名称:pychron,代码行数:19,代码来源:ion_optics_manager.py
示例7: do_machine_vision_degas
def do_machine_vision_degas(self, lumens, duration, new_thread=False):
if self.use_video:
dm = self.degasser_factory()
def func():
dm.degas(lumens, duration)
if new_thread:
self._degas_thread = Thread(target=func)
self._degas_thread.start()
else:
func()
开发者ID:OSUPychron,项目名称:pychron,代码行数:12,代码来源:fusions_laser_manager.py
示例8: _move
def _move(self, func, pos, name=None, *args, **kw):
if pos is None:
return
if self.move_thread and self.move_thread.isRunning():
self.stage_controller.stop()
if name is None:
name = func.func_name
self.move_thread = Thread(name='stage.{}'.format(name),
target=func, args=(pos,) + args, kwargs=kw)
self.move_thread.start()
开发者ID:UManPychron,项目名称:pychron,代码行数:12,代码来源:stage_manager.py
示例9: passive_focus
def passive_focus(self, block=False, **kw):
self._evt_autofocusing = TEvent()
self._evt_autofocusing.clear()
# manager = self.laser_manager
oper = self.parameters.operator
self.info('passive focus. operator = {}'.format(oper))
g = self.graph
if not g:
g = Graph(plotcontainer_dict=dict(padding=10),
window_x=0.70,
window_y=20,
window_width=325,
window_height=325,
window_title='Autofocus'
)
self.graph = g
g.clear()
g.new_plot(padding=[40, 10, 10, 40],
xtitle='Z (mm)',
ytitle='Focus Measure ({})'.format(oper)
)
g.new_series()
g.new_series()
invoke_in_main_thread(self._open_graph)
target = self._passive_focus
self._passive_focus_thread = Thread(name='autofocus', target=target,
args=(self._evt_autofocusing,
),
kwargs=kw
)
self._passive_focus_thread.start()
if block:
# while 1:
# if not self._passive_focus_thread.isRunning():
# break
# time.sleep(0.25)
self._passive_focus_thread.join()
开发者ID:NMGRL,项目名称:pychron,代码行数:44,代码来源:autofocus_manager.py
示例10: _set_point
def _set_point(self, v):
if self.canvas.calibrate:
self.warning_dialog('Cannot move while calibrating')
return
if self.canvas.markup:
self.warning_dialog('Cannot move while adding/editing points')
return
if (self.move_thread is None or not self.move_thread.isRunning()) and v is not self._point:
pos = self.canvas.get_item('point', int(v) - 1)
if pos is not None:
self._point = v
self.move_thread = Thread(target=self._move_to_point, args=(pos,))
self.move_thread.start()
else:
err = 'Invalid point {}'.format(v)
self.warning(err)
return err
开发者ID:NMGRL,项目名称:pychron,代码行数:19,代码来源:stage_manager.py
示例11: _execute
def _execute(self):
yd = self._read_control_path()
if yd is None:
sp = 1000
else:
sp = yd['period']
# starts automatically
self.debug('scan starting')
self._timer = Timer(sp, self._scan)
self.info('scan started')
# yd = self._read_control_path()
if yd is not None:
# start a control thread
self._control_thread = Thread(target=self._control,
args=(yd,)
)
self._control_thread.start()
self.info('control started')
开发者ID:OSUPychron,项目名称:pychron,代码行数:23,代码来源:scanner.py
示例12: dump_sample
def dump_sample(self):
self.debug('dump sample')
if self._dumper_thread is None:
self._dumper_thread = Thread(name='DumpSample', target=self._dump_sample)
self._dumper_thread.start()
开发者ID:kenlchen,项目名称:pychron,代码行数:6,代码来源:furnace_manager.py
示例13: StageManager
#.........这里部分代码省略.........
# if self.move_thread is not None:
# self.stage_controller.stop()
#
# # if self.move_thread is None:
#
# pos = self._stage_map.get_hole_pos(v)
# if pos is not None:
# self.visualizer.set_current_hole(v)
# # self._hole = v
# self.move_thread = Thread(name='stage.move_to_hole',
# target=self._move_to_hole, args=(v,))
# self.move_thread.start()
# else:
# err = 'Invalid hole {}'.format(v)
# self.warning(err)
# return err
# def _get_hole(self):
# return self._hole
def _set_point(self, v):
if self.canvas.calibrate:
self.warning_dialog('Cannot move while calibrating')
return
if self.canvas.markup:
self.warning_dialog('Cannot move while adding/editing points')
return
if (self.move_thread is None or not self.move_thread.isRunning()) and v is not self._point:
pos = self.canvas.get_item('point', int(v) - 1)
if pos is not None:
self._point = v
self.move_thread = Thread(target=self._move_to_point, args=(pos,))
self.move_thread.start()
else:
err = 'Invalid point {}'.format(v)
self.warning(err)
return err
def _get_point(self):
return self._point
# ===============================================================================
# handlers
# ===============================================================================
def _stop_button_fired(self):
self._stop()
def _ejoystick_fired(self):
self.joystick = not self.joystick
if self.joystick:
self.stage_controller.enable_joystick()
self.joystick_label = 'Disable Joystick'
self.joystick_timer = self.timer_factory(func=self._joystick_inprogress_update)
else:
if self.joystick_timer is not None:
self.joystick_timer.Stop()
self.stage_controller.disable_joystick()
self.joystick_label = 'Enable Joystick'
def _home_fired(self):
"""
"""
开发者ID:NMGRL,项目名称:pychron,代码行数:67,代码来源:stage_manager.py
示例14: FusionsLaserManager
#.........这里部分代码省略.........
def take_snapshot(self, *args, **kw):
if self.use_video:
return self.stage_manager.snapshot(
auto=True,
inform=False,
*args, **kw)
def start_video_recording(self, name='video', *args, **kw):
if self.use_video:
self.stage_manager.start_recording(basename=name)
def stop_video_recording(self, *args, **kw):
if self.use_video:
self.stage_manager.stop_recording()
def degasser_factory(self):
from pychron.mv.degas.degasser import Degasser
dm = Degasser(
laser_manager=self,
video=self.stage_manager.video,
)
return dm
def do_machine_vision_degas(self, lumens, duration, new_thread=False):
if self.use_video:
dm = self.degasser_factory()
def func():
dm.degas(lumens, duration)
if new_thread:
self._degas_thread = Thread(target=func)
self._degas_thread.start()
else:
func()
def get_brightness(self):
if self.use_video:
return self.stage_manager.get_brightness()
else:
return super(FusionsLaserManager, self).get_brightness()
def is_degassing(self):
if self._degas_thread:
return self._degas_thread.isRunning()
# ===============================================================================
# pyscript interface
# ===============================================================================
def _move_to_position(self, position, autocenter):
if self.stage_manager is not None:
if isinstance(position, tuple):
if len(position) > 1:
x, y = position[:2]
self.stage_manager.linear_move(x, y)
if len(position) == 3:
self.stage_manager.set_z(position[2])
else:
self.stage_manager.move_to_hole(position)
return True
def set_stage_map(self, mapname):
开发者ID:OSUPychron,项目名称:pychron,代码行数:67,代码来源:fusions_laser_manager.py
示例15: NMGRLFurnaceManager
class NMGRLFurnaceManager(BaseFurnaceManager):
funnel = Instance(NMGRLFunnel)
loader_logic = Instance(LoaderLogic)
magnets = Instance(NMGRLMagnetDumper)
setpoint_readback_min = Float(0)
setpoint_readback_max = Float(1600.0)
graph = Instance(StreamGraph)
update_period = Int(2)
dumper_canvas = Instance(DumperCanvas)
_alive = False
_guide_overlay = None
_dumper_thread = None
mode = 'normal'
def activate(self):
# pref_id = 'pychron.furnace'
# bind_preference(self, 'update_period', '{}.update_period'.format(pref_id))
self._start_update()
def prepare_destroy(self):
self._stop_update()
self.loader_logic.manager = None
def dump_sample(self):
self.debug('dump sample')
if self._dumper_thread is None:
self._dumper_thread = Thread(name='DumpSample', target=self._dump_sample)
self._dumper_thread.start()
def is_dump_complete(self):
ret = self._dumper_thread is None
return ret
def actuate_magnets(self):
self.debug('actuate magnets')
if self.loader_logic.check('AM'):
self.magnet.open()
# wait for actuate magnets
pass
else:
self.warning('actuate magnets not enabled')
def lower_funnel(self):
self.debug('lower funnel')
if self.loader_logic.check('FD'):
self.funnel.set_value(self.funnel.down_position)
# todo: update canvas state
return True
else:
self.warning('lowering funnel not enabled')
def raise_funnel(self):
self.debug('raise funnel')
if self.loader_logic.check('FU'):
self.funnel.set_value(self.funnel.up_position)
# todo: update canvas state
return True
else:
self.warning('raising funnel not enabled')
def set_setpoint(self, v):
if self.controller:
# print self.controller, self.controller._cdevice
self.controller.set_setpoint(v)
if not self._guide_overlay:
self._guide_overlay = self.graph.add_horizontal_rule(v)
self._guide_overlay.visible = bool(v)
self._guide_overlay.value = v
# ymi, yma = self.graph.get_y_limits()
d = self.graph.get_data(axis=1)
self.graph.set_y_limits(min_=0, max_=max(d.max(), v * 1.1))
self.graph.redraw()
def read_setpoint(self, update=False):
v = 0
if self.controller:
force = update and not self.controller.is_scanning()
v = self.controller.read_setpoint(force=force)
try:
self.setpoint_readback = v
return v
except TraitError:
pass
# canvas
def set_software_lock(self, name, lock):
if self.switch_manager is not None:
if lock:
#.........这里部分代码省略.........
开发者ID:kenlchen,项目名称:pychron,代码行数:101,代码来源:furnace_manager.py
示例16: PatternExecutor
#.........这里部分代码省略.........
pass
def show_pattern(self):
self.pattern.window_x = 50
self.pattern.window_y = 50
open_view(self.pattern, view='graph_view')
def execute(self, block=False, duration=None, thread_safe=True):
"""
if block is true wait for patterning to finish
before returning
"""
if not self.pattern:
return
self.start(show=self.show_patterning)
evt = None
# if current_thread().name != 'MainThread':
if thread_safe:
evt = Event()
invoke_in_main_thread(self._pre_execute, evt)
while not evt.is_set():
time.sleep(0.05)
else:
self._pre_execute(evt)
self.debug('execute xy pattern')
xyp = self.pattern.xy_pattern_enabled
if duration:
self.pattern.external_duration = float(duration)
if xyp:
self._xy_thread = Thread(target=self._execute_xy_pattern)
self._xy_thread.start()
pp = self.pattern.power_pattern
if pp:
self.debug('execute power pattern')
self._power_thread = Thread(target=self._execute_power_pattern)
self._power_thread.start()
zp = self.pattern.z_pattern
if zp:
self.debug('execute z pattern')
self._z_thread = Thread(target=self._execute_z_pattern)
self._z_thread.start()
if block:
if self._xy_thread:
self._xy_thread.join()
if self._z_thread:
self._z_thread.join()
if self._power_thread:
self._power_thread.join()
self.finish()
def _pre_execute(self, evt):
self.debug('pre execute')
pattern = self.pattern
kind = pattern.kind
if kind in ('SeekPattern', 'DragonFlyPeakPattern'):
self._info = open_view(pattern, view='execution_graph_view')
开发者ID:NMGRL,项目名称:pychron,代码行数:67,代码来源:pattern_executor.py
示例17: _back_button_fired
def _back_button_fired(self):
pos, kw = self.linear_move_history.pop(-1)
t = Thread(target=self.stage_controller.linear_move, args=pos, kwargs=kw)
t.start()
self.move_thread = t
开发者ID:UManPychron,项目名称:pychron,代码行数:5,代码来源:stage_manager.py
示例18: BaseStageManager
#.........这里部分代码省略.........
if ca:
rot = ca.rotation
cpos = ca.center
scale = ca.scale
self.debug('Calibration parameters: '
'rot={:0.3f}, cpos={} scale={:0.3f}'.format(rot, cpos,
scale))
pos = smap.map_to_calibration(pos, cpos, rot,
scale=scale)
return pos
def update_axes(self):
"""
"""
self.info('querying axis positions')
self._update_axes()
# private
def _update_axes(self):
pass
def _move_to_hole(self, key, correct_position=True, **kw):
pass
def _stop(self):
pass
def _move(self, func, pos, name=None, *args, **kw):
if pos is None:
return
if self.move_thread and self.move_thread.isRunning():
self._stop()
if name is None:
name = func.__name__
self.move_thread = Thread(name='stage.{}'.format(name),
target=func, args=(pos,) + args, kwargs=kw)
self.move_thread.start()
def _canvas_factory(self):
raise NotImplementedError
def _stage_map_changed_hook(self):
pass
# handlers
def _calibrated_position_entry_changed(self, new):
self.debug('User entered calibrated position {}'.format(new))
self.goto_position(new)
def _stage_map_name_changed(self, new):
if new:
self.debug('setting stage map to {}'.format(new))
root = self.root
path = os.path.join(root, add_extension(new, '.txt'))
sm = self.stage_map_klass(file_path=path)
self.tray_calibration_manager.load_calibration(stage_map=new)
self.canvas.set_map(sm)
self.canvas.request_redraw()
self.stage_map = sm
self._stage_map_changed_hook()
# defaults
def _root_default(self):
return paths.map_dir
def _tray_calibration_manager_default(self):
t = TrayCalibrationManager(parent=self,
canvas=self.canvas)
return t
def _canvas_default(self):
return self._canvas_factory()
def _save_stage_map(self):
p = self.stage_map_path
self.info('saving stage_map {} to {}'.format(self.stage_map_name, p))
with open(p, 'wb') as f:
pickle.dump(self.stage_map_name, f)
def _load_previous_stage_map(self):
p = self.stage_map_path
if os.path.isfile(p):
self.info('loading previous stage map from {}'.format(p))
with open(p, 'rb') as f:
try:
sm = pickle.load(f)
if not sm.endswith('.center'):
return sm
except (pickle.PickleError, ValueError):
pass
开发者ID:NMGRL,项目名称:pychron,代码行数:101,代码来源:stage_manager.py
示例19: Scanner
#.........这里部分代码省略.........
self._make_func_names() + \
[n for n, _ in self.static_values]
self.data_manager.write_to_frame(header)
self._scanning = True
if self.manager:
if self.manager.enable_device():
self._scanning = True
return self._scanning
def do_scan(self):
self._starttime = time.time()
self._execute()
def _execute(self):
yd = self._read_control_path()
if yd is None:
sp = 1000
else:
sp = yd['period']
# starts automatically
self.debug('scan starting')
self._timer = Timer(sp, self._scan)
self.info('scan started')
# yd = self._read_control_path()
if yd is not None:
# start a control thread
self._control_thread = Thread(target=self._control,
args=(yd,)
)
self._control_thread.start()
self.info('control started')
# if self.manager:
# if self.manager.enable_device():
#
# # starts automatically
# self.debug('scan starting')
# self._timer = Timer(sp, self._scan)
#
# self.info('scan started')
# self._scanning = True
# # yd = self._read_control_path()
# if yd is not None:
# # start a control thread
# self._control_thread = Thread(target=self._control,
# args=(yd,)
# )
# self._control_thread.start()
# self.info('control started')
# else:
# self.warning('Could not enable device')
# else:
# self.warning('no manager available')
def _control(self, ydict):
self.start_control_hook(ydict)
# if self.manager:
# if self.manager.temperature_controller:
# self.manager.temperature_controller.enable_tru_tune = True
开发者ID:OSUPychron,项目名称:pychron,代码行数:67,代码来源:scanner.py
示例20: execute
def execute(self):
self.canceled = False
t = Thread(target=self._execute)
t.start()
self._t = t
开发者ID:UManPychron,项目名称:pychron,代码行数:5,代码来源:easy_manager.py
注:本文中的pychron.core.ui.thread.Thread类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论