コード例 #1
0
ファイル: fig_mdsbook.py プロジェクト: jhillairet/piScope
def convert2figmdsbook2(book):
    #            for page in self.book.walk_page():
    prepare_dwglobal(book)
    if not book.hasvar('mdsplus_server'):
        p = SettingParser()
        v = p.read_setting('mdsplus.default_mdsserver')
        book.setvar('mdsplus_server', v['server'])


#                                 'direct::CMOD')
    if not book.hasvar('mdsscript_main'):
        book.setvar('mdsscript_main', True)
    if not book.hasvar('mdsscope_nticks'):
        book.setvar('mdsscope_nticks', [10, 10])
    if not book.hasvar('mdsscope_autogrid'):
        book.setvar('mdsscope_autogrid', True)
    if not book.hasvar('mdsscope_listenevent'):
        book.setvar('mdsscope_listenevent', True)
    if not book.hasvar('dwscope_filename'):
        book.setvar('dwscope_filename', '')
    if not book.hasvar('global_tdi'):
        book.setvar('global_tdi', '')
    if not book.hasvar('global_tdi_event'):
        book.setvar('global_tdi_event', '')
    convert2figmdsbook(book)
    return book
コード例 #2
0
ファイル: dlg_setting2.py プロジェクト: piScope/piScope
def callback(parent, value, setting, gwparam):
    gs = gwparam.getvar('globalsets')
    gv = gwparam.getvar()

    if not '_flag' in gs:
        gs['_flag'] = [[], [], [], []]
    for m in range(4):
        for key in value[m][0]:
            if not key in gs:
                gs[key] = [None] * 4
            gs[key][m] = value[m][0][key]
    gv['event'] = str(value[4][1])
    gv['shot_global'] = str(value[4][5])
    gv['use_shot_global'] = (value[4][6] == 'on')
    parent.book.setvar('global_tdi', str(value[4][2]))
    parent.book.setvar('global_tdi_event', str(value[4][3]))
    parent.book._use_global_tdi = value[4][4] == 'on'
    gv['global_choice'] = value[4][7]
    parent.mpanalysis = (value[4][8] == "on")

    if not value[5][1][0]:
        parent.book._parallel_page = False
        parent.book._parallel_shot = False
        parent.book._parallel_sec = False
    else:
        parent.book._parallel_page = True
        if not value[5][1][1][0][0]:
            parent.book._parallel_shot = False
            parent.book._parallel_sec = False
        else:
            parent.book._parallel_shot = True
            parent.book._parallel_sec = value[5][1][1][0][1][0]

    parent.book.setvar('mdsscript_main', value[5][2])
    parent.book.setvar('mdsplus_server', str(value[4][0]))

    from ifigure.utils.setting_parser import iFigureSettingParser as SettingParser
    p = SettingParser()
    v = p.read_setting('mdsplus.default_mdsserver')
    if str(v['server']) != str(value[4][0]):
        ret = dialog.message(
            parent,
            '\n'.join([
                'Selected MDS+ server is different from your default setting',
                'Do you want to use this server as your default server?'
            ]),
            'MDS+ server setting',
            4,
            icon=wx.ICON_QUESTION)
        #           print ret
        if ret == 'yes':
            v['server'] = str(value[4][0])
            p.write_setting('mdsplus.default_mdsserver', v)
コード例 #3
0
def MDS_setting(parent, setting, gwparam, mds_server, thread_main):
    def make_gs_arr(gs, s):
        return [gs[key][s] for key in pkeys]

    gs = gwparam.getvar('globalsets')
    gv = gwparam.getvar()
    tab = ['Set1', 'Set2', 'Set3', 'Set4', 'config', 'more']

    list1 = [[None, make_gs_arr(gs, 0), 118, None]]
    list2 = [[None, make_gs_arr(gs, 1), 118, None]]
    list3 = [[None, make_gs_arr(gs, 2), 118, None]]
    list4 = [[None, make_gs_arr(gs, 3), 118, None]]

    txt = "on" if parent.mpanalysis else "off"
    txt2 = "on" if gv['use_shot_global'] else "off"
    txt7 = "on" if parent.init_beginning else "off"
    txt6 = "on" if parent.init_sec else "off"
    txt5 = "on" if parent.init_page else "off"

    list5 = [
        ["MDSconnect", mds_server, 204, None],
        ["Update", gv['event'], 0, None],
        ["Common vars", gv['shot_global'], 0, None],
        ["Use common vars", txt2, 1, {
            "values": ["on", "off"]
        }],
        ["Global setting", gv['global_choice'], 21, None],
        ["Multipage mode", txt, 1, {
            "values": ["on", "off"]
        }],
        #            ["Color Order", gv['color_order'], 22, {}],]
    ]

    tmp2 = [
        [
            None, parent.parallel_sec, 3, {
                "text": 'Parallelize Panels',
                "noindent": True
            }
        ],
    ]
    tmp = [[
        None, (parent.parallel_shot, [parent.parallel_sec]), 27,
        ({
            "text": 'Parallelize Pages'
        }, {
            "elp": tmp2
        })
    ]]
    list6 = [
        [None, "MDSplus session parallelization", 102, None],
        [
            None,
            (parent.parallel_page, [(parent.parallel_shot,
                                     [parent.parallel_sec])]), 27,
            ({
                "text": 'Parallelize Shots',
                "space": 15
            }, {
                "elp": tmp
            })
        ],
        #["At session start",txt7, 1, {"values":["on", "off"]}],
        #["At every page",   txt5, 1, {"values":["on", "off"]}],
        #["At every panel",  txt6, 1, {"values":["on", "off"]}],
        [
            None, thread_main, 3, {
                "text": "Run python script in main thread",
                "noindent": None
            }
        ],
        [
            None, "(!) MDS+ connection is initialized when opening new tree",
            102, None
        ],
    ]

    tip1 = None
    tip2 = None
    tip3 = None
    tip4 = None
    tip5 = [
        'MDSplus server and default Tree',
        'Update event',
        'MDS command called at the begining of page',
        'MDS command called at the begining of section',
        'Global setting selection for shots',
        'Use the same shot numbers for all pages. (shot numbers after semi-colon are ignored)',
    ]

    tip6 = [
        None,
        'Parallelization of MDS session',
        None,
        #'Initialize global/local variables when analysis loop starts',
        #'Initialize global/local variables when analyzing a new panel',
        #'Initialize global/local variables when analyzing a new page',
        None,
    ]

    l = [list1, list2, list3, list4, list5, list6]
    tip = [tip1, tip2, tip3, tip4, tip5, tip6]

    value = DialogEditListTab(tab,
                              l,
                              modal=False,
                              tip=tip,
                              parent=parent,
                              title='Global Setting',
                              style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER)

    if value[0]:
        for m in range(4):
            for i, v in enumerate(value[1][m][0]):
                gs[pkeys[i]][m] = str(v[1])
        gv['event'] = str(value[1][4][1])
        gv['shot_global'] = str(value[1][4][2])
        gv['use_shot_global'] = (value[1][4][3] == 'on')
        gv['global_choice'] = value[1][4][4]
        parent.mpanalysis = (value[1][4][5] == "on")
        #      gv['color_order'] = value[1][4][5]

        #      parent.init_beginning = (value[1][5][3] == "on")
        #      parent.init_page = (value[1][5][4] == "on")
        #      parent.init_sec = (value[1][5][5] == "on")

        if not value[1][5][1][0]:
            parent.parallel_page = False
            parent.parallel_shot = False
            parent.parallel_sec = False
        else:
            parent.parallel_page = True
            if not value[1][5][1][1][0][0]:
                parent.parallel_shot = False
                parent.parallel_sec = False
            else:
                parent.parallel_shot = True
                parent.parallel_sec = value[1][5][1][1][0][1][0]

        parent.book.setvar('mdsscript_main', value[1][5][2])
        parent.book.setvar('mdsplus_server', str(value[1][4][0]))

    from ifigure.utils.setting_parser import iFigureSettingParser as SettingParser
    p = SettingParser()
    v = p.read_setting('mdsplus.default_mdsserver')
    if str(v['server']) != str(value[1][4][0]):
        ret = dialog.message(
            parent,
            '\n'.join([
                'Selected MDS+ server is different from your default setting',
                'Do you want to use this server as your default server?'
            ]),
            'MDS+ server setting',
            2,
            icon=wx.ICON_QUESTION)
        print(ret)
        if ret == 'ok':
            v['server'] = str(value[1][4][0])
            p.write_setting('mdsplus.default_mdsserver', v)

    return value
コード例 #4
0
    def __init__(self, *args, **kargs):
        if "show_prop" in kargs:
            show_prop = kargs["show_prop"]
            del kargs["show_prop"]
        else:
            show_prop = False
        if "worker" in kargs:
            self.workers = kargs['worker']
            del kargs["worker"]
        else:
            self.workers = None

        super(MDSScopeNW, self).__init__(*args, **kargs)
        ScopeEngine.__init__(self, no_window=True)

        if self.book is not None:
            #            for page in self.book.walk_page():
            self.prepare_dwglobal(self.book)
            if not self.book.hasvar('mdsplus_server'):
                p = SettingParser()
                v = p.read_setting('mdsplus.default_mdsserver')
                self.book.setvar('mdsplus_server', v['server'])
#                                 'direct::CMOD')
            if not self.book.hasvar('mdsscript_main'):
                self.book.setvar('mdsscript_main', True)
            if not self.book.hasvar('mdsscope_autogrid'):
                self.book.setvar('mdsscope_autogrid', True)
            if not self.book.hasvar('mdsscope_listenevent'):
                self.book.setvar('mdsscope_listenevent', True)
            if not self.book.hasvar('dwscope_filename'):
                self.book.setvar('dwscope_filename', '')
            from ifigure.mdsplus.fig_mdsbook import convert2figmdsbook
            convert2figmdsbook(self.book)

        self.g = {}  ## global variabls for mainthread scripting
        self._title_mdsjob_count = 0
        self._mdsjob_count = 0
        self._cur_shot = 0
        self._mds_exit_status = 0
        self._figmds_list = []
        self.mpanalysis = False
        self._mpanalysis_mode = True
        self.parallel_page = True
        self.parallel_shot = True
        self.parallel_sec = True
        self.init_beginning = True
        self.init_page = False
        self.init_shot = False
        self.init_sec = False
        self.debug_mode = False
        self.timer = None

        self.previous_shot_set = [[]]
        self.event_dict = {}
        self.InitUI()
        from numpy import linspace
        self._shot_dict = {'linspace': linspace}
        #        self.Thaw()

        proj = self.book.get_root_parent()
        proj = self.book.get_root_parent()
        if self.workers is None:
            if proj.setting.has_child('mdsplus_worker'):
                self.workers = proj.setting.mdsplus_worker
            else:
                file = os.path.join(ifigure.__path__[0], 'add_on', 'setting',
                                    'module', 'mdsplus_worker.py')

                workers = proj.setting.add_absmodule(file)
                workers.rename('mdsplus_worker')
                self.workers = workers

        p = SettingParser()
        p.set_rule('global_set', {}, nocheck=True)
        self.scope_setting = p.read_setting('mdsplus.scope_setting')

        from ifigure.ifigure_config import rcdir, ifiguredir
        mname = 'mdsplus.fig_mds_startup_script'
        def_file = os.path.join(*([ifiguredir] + mname.split('.')))
        user_file = os.path.join(*([rcdir] + mname.split('.'))) + '.py'
        if not os.path.exists(user_file):
            shutil.copy(def_file, user_file)
        self.startup_script = user_file
        dc = {}
        dg = {}
        from ifigure.mdsplus.fig_mds import read_scriptfile
        exec read_scriptfile(self.startup_script) in dg, dc
        self.startup_values = dc

        self._start_mds_threads()  # start session runner and event listener

        self.workers.call_method('onStartWorker')
        #        self.start_pool()
        self.open_engine()
コード例 #5
0
ファイル: mdsplus_worker.py プロジェクト: jhillairet/piScope
def clean(self, *args, **kargs):
    self.td._pool.reset()
    p = SettingParser()
    p.write_setting('mdsplus.connection_setting', self.td.getvar('setting'))
コード例 #6
0
ファイル: mdsplus_worker.py プロジェクト: jhillairet/piScope
def init(self, *args, **kargs):
    #    if not kargs.has_key('src'):
    self.td._pool = MDSWorkerPool()
    p = SettingParser()
    p.set_rule('connection', {}, nocheck=True)
    self.td.setvar('setting', p.read_setting('mdsplus.connection_setting'))