コード例 #1
0
 def cb_jsonRecorder(self):
     if self.w_jsonRecorderCheckBox.isChecked():
         HasyUtils.setEnv("JsonRecorder", True)
         a = HasyUtils.getEnv("JsonRecorder")
         self.logWidget.append("JsonRecorder: %s" % repr(a))
     else:
         HasyUtils.setEnv("JsonRecorder", False)
         a = HasyUtils.getEnv("JsonRecorder")
         self.logWidget.append("JsonRecorder: %s" % repr(a))
コード例 #2
0
 def cb_showCtrlAxis(self):
     hsh = HasyUtils.getEnv("_ViewOptions")
     if self.w_showCtrlAxisCheckBox.isChecked():
         hsh['ShowCtrlAxis'] = True
     else:
         hsh['ShowCtrlAxis'] = False
     HasyUtils.setEnv("_ViewOptions", hsh)
コード例 #3
0
 def cb_onCondition(self):
     if self.w_onConditionCheckBox.isChecked():
         HasyUtils.runMacro("gc_enable")
         a = HasyUtils.getEnv("GeneralCondition")
         self.logWidget.append("General condition: %s" % repr(a))
     else:
         HasyUtils.runMacro("gc_disable")
         self.logWidget.append("General condition: disabled")
コード例 #4
0
 def cb_generalStop(self):
     if self.w_generalStopCheckBox.isChecked():
         HasyUtils.runMacro("gs_enable")
         a = HasyUtils.getEnv("GeneralOnStopFunction")
         self.logWidget.append("General on stop: %s" % repr(a))
     else:
         HasyUtils.runMacro("gs_disable")
         self.logWidget.append("General on stop: disabled")
コード例 #5
0
 def cb_LogMacro(self):
     if self.w_LogMacroCheckBox.isChecked():
         HasyUtils.setEnv("LogMacro", True)
         a = HasyUtils.getEnv("LogMacro")
         self.logWidget.append("LogMacro: %s" % repr(a))
     else:
         HasyUtils.setEnv("LogMacro", False)
         self.logWidget.append("LogMacro: disabled")
コード例 #6
0
    def cb_generalHooks(self):

        if self.w_generalHooksCheckBox.isChecked():
            HasyUtils.runMacro("gh_enable")
            hsh = HasyUtils.getEnv("_GeneralHooks")
            self.logWidget.append("GeneralHooks: %s" % repr(hsh))
        else:
            HasyUtils.runMacro("gh_disable")
            self.logWidget.append("GeneralHooks: disabled")
コード例 #7
0
    def _prepareFileNames(self, scanID):

        self.scanDir = HasyUtils.getEnv('ScanDir')
        if scanID == -1:
            scanID = int(self.getEnv('ScanID'))
        self.scanId = scanID

        self.scanFile = HasyUtils.getEnv('ScanFile')
        if type(self.scanFile) is list:
            self.scanFile = self.scanFile[0]

        prefix, ext = self.scanFile.split('.')
        if ext != 'fio':
            self.output(
                "ppPurge._prepareFileNames: scanFile %s has the wrong extension (NOT fio)"
            )
            return False

        self.scanName = "%s_%05d" % (prefix, scanID)

        logFile = self.scanDir + "/" + self.scanName + "_ppPurge.log"
        if os.path.isfile(logFile):
            self.output("ppPurge: %s exists already" % logFile)
            self.output("ppPurge: file retained, ppPurge aborted")
            return False

        self.imageRootDir = self.scanDir + "/" + self.scanName
        self.detectorDirs = []
        filesTemp = []
        for rootDir, subDirs, files in HasyUtils.walkLevel(self.imageRootDir,
                                                           level=0):
            filesTemp.extend(files)
            for sDir in subDirs:
                self.detectorDirs.append(rootDir + "/" + sDir)
        #
        # get MCA files, make sure they begin with <scanName>_mca_s
        #
        self.mcaFiles = []
        mcaPattern = self.scanName + "_mca_s"
        for elm in filesTemp:
            if elm.find(mcaPattern) == 0:
                self.mcaFiles.append(self.imageRootDir + "/" + elm)

        return True
コード例 #8
0
 def cb_reloadGeneralHooks(self):
     lst = HasyUtils.getEnv("_GeneralHooks")
     if lst is None:
         self.logWidget.append("GeneralHooks: disabled")
         return
     #
     # use the first hook macro name. relmac pulls-in the whole file
     #
     HasyUtils.runMacro("relmac %s" % lst[0][0])
     return
コード例 #9
0
 def cb_applyMacroServerIfc(self):
     for var in self.varsEnv:
         hsh = self.dct[var]
         inp = str(hsh["w_line"].text())
         if len(inp) > 0:
             self.logWidget.append("setting %s to %s %s" %
                                   (var, repr(inp), type(inp)))
             HasyUtils.setEnv(var, inp)
             hsh['w_value'].setText(repr(HasyUtils.getEnv(var)))
             hsh["w_line"].clear()
     return
コード例 #10
0
 def cb_editOnStop(self):
     lst = HasyUtils.getEnv("GeneralOnStopFunction")
     if lst is None:
         self.logWidget.append(
             "GeneralOnStopFunction: disabled, enable before edit")
         return
     editor = os.getenv("EDITOR")
     if editor is None:
         editor = "emacs"
     home = os.getenv("HOME")
     os.system(
         "%s %s/sardanaMacros/generalFunctions/general_functions.py&" %
         (editor, home))
     return
コード例 #11
0
 def cb_editGeneralHooks(self):
     lst = HasyUtils.getEnv("_GeneralHooks")
     if lst is None:
         self.logWidget.append("GeneralHooks: disabled, enable before edit")
         return
     #
     # need just one hooks macro name to identify the file
     #
     hooksMacroName = lst[0][0]
     hsh = HasyUtils.getMacroInfo(hooksMacroName)
     editor = os.getenv("EDITOR")
     if editor is None:
         editor = "emacs"
     os.system("%s %s&" % (editor, hsh['file_path']))
     return
コード例 #12
0
 def fillMgComboBox(self):
     """
     called initially but also after new MGs have been created
     """
     activeMntGrp = HasyUtils.getEnv("ActiveMntGrp")
     count = 0
     self.activeMntGrpComboBox.clear()
     for mg in HasyUtils.getMgAliases():
         self.activeMntGrpComboBox.addItem(mg)
         #
         # initialize the comboBox to the current ActiveMntGrp
         #
         if activeMntGrp == mg:
             self.activeMntGrpComboBox.setCurrentIndex(count)
         count += 1
     return
コード例 #13
0
    def cb_refreshMacroServerIfc(self):

        if self.isMinimized():
            return

        self.activityIndex += 1
        if self.activityIndex > (len(definitions.ACTIVITY_SYMBOLS) - 1):
            self.activityIndex = 0
        self.activity.setTitle(
            definitions.ACTIVITY_SYMBOLS[self.activityIndex])
        #
        # has the ActiveMntGrp been changed from outside?
        #
        if HasyUtils.getMgAliases() is not None:
            activeMntGrp = HasyUtils.getEnv("ActiveMntGrp")
            temp = str(self.activeMntGrpComboBox.currentText())
            if temp != activeMntGrp:
                max = self.activeMntGrpComboBox.count()
                for count in range(0, max):
                    temp1 = str(self.activeMntGrpComboBox.itemText(count))
                    if temp1 == activeMntGrp:
                        self.activeMntGrpComboBox.setCurrentIndex(count)
                    break
                else:
                    self.logWidget.append(
                        "New ActiveMntGrp not on the list, restart widget")

        envDct = HasyUtils.getEnvDct()

        for var in self.varsEnv:
            try:
                res = envDct[var]
                if type(res) is list:
                    res = repr(res)
                if res is None:
                    self.dct[var]["w_value"].setText("None")
                else:
                    self.dct[var]["w_value"].setText(str(res))
            except:
                self.dct[var]["w_value"].setText("None")

        try:
            hsh = envDct["_ViewOptions"]
            if hsh['ShowDial']:
                self.w_showDialCheckBox.setChecked(True)
            else:
                self.w_showDialCheckBox.setChecked(False)
            if hsh['ShowCtrlAxis']:
                self.w_showCtrlAxisCheckBox.setChecked(True)
            else:
                self.w_showCtrlAxisCheckBox.setChecked(False)
        except:
            pass

        try:
            lst = envDct["_GeneralHooks"]
            if lst is None:
                self.w_generalHooksCheckBox.setChecked(False)
            else:
                self.w_generalHooksCheckBox.setChecked(True)
        except:
            self.w_generalHooksCheckBox.setChecked(False)

        try:
            a = envDct["GeneralCondition"]
            if a is None:
                self.w_onConditionCheckBox.setChecked(False)
            else:
                self.w_onConditionCheckBox.setChecked(True)
        except:
            self.w_onConditionCheckBox.setChecked(False)

        try:
            a = envDct["GeneralOnStopFunction"]
            if a is None:
                self.w_generalStopCheckBox.setChecked(False)
            else:
                self.w_generalStopCheckBox.setChecked(True)
        except:
            self.w_generalStopCheckBox.setChecked(False)

        try:
            a = envDct["JsonRecorder"]
            if a is True:
                self.w_jsonRecorderCheckBox.setChecked(True)
            else:
                self.w_jsonRecorderCheckBox.setChecked(False)
        except:
            self.w_jsonRecorderCheckBox.setChecked(False)

        try:
            a = envDct["LogMacro"]
            if a is True:
                self.w_LogMacroCheckBox.setChecked(True)
            else:
                self.w_LogMacroCheckBox.setChecked(False)
        except:
            self.w_LogMacroCheckBox.setChecked(False)
        return
コード例 #14
0
    def prepareWidgets(self):
        w = QtGui.QWidget()
        self.layout_v = QtGui.QVBoxLayout()
        w.setLayout(self.layout_v)
        self.setCentralWidget(w)
        self.dct = {}
        #
        # the ActiveMntGrp
        #
        if HasyUtils.getMgAliases() is not None:
            hBox = QtGui.QHBoxLayout()
            w = QtGui.QLabel("ActiveMntGrp")
            w.setMinimumWidth(120)
            hBox.addWidget(w)
            hBox.addStretch()
            self.activeMntGrpComboBox = QtGui.QComboBox()
            self.activeMntGrpComboBox.setMinimumWidth(250)
            self.fillMgComboBox()

            #
            # connect the callback AFTER the combox is filled. Otherwise there
            # will be some useless changes
            #
            self.activeMntGrpComboBox.currentIndexChanged.connect(
                self.cb_activeMntGrpChanged)
            hBox.addWidget(self.activeMntGrpComboBox)
            hBox.addStretch()
            self.layout_v.addLayout(hBox)

        #
        # horizontal line
        #
        hBox = QtGui.QHBoxLayout()
        w = QtGui.QFrame()
        w.setFrameShape(QtGui.QFrame.HLine)
        w.setFrameShadow(QtGui.QFrame.Sunken)
        hBox.addWidget(w)
        self.layout_v.addLayout(hBox)
        #
        # some Env variables
        #
        self.varsEnv = ["ScanDir", "ScanFile", "FioAdditions"]
        for var in self.varsEnv:
            hBox = QtGui.QHBoxLayout()
            w = QtGui.QLabel("%s:" % var)
            w.setMinimumWidth(120)
            hBox.addWidget(w)
            hsh = {}
            w_value = QtGui.QLabel()
            w_value.setMinimumWidth(250)
            w_value.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Sunken)
            hBox.addWidget(w_value)
            w_line = QtGui.QLineEdit()
            w_line.setAlignment(QtCore.Qt.AlignRight)
            w_line.setMinimumWidth(250)
            hBox.addWidget(w_line)
            self.dct[var] = {"w_value": w_value, "w_line": w_line}
            self.layout_v.addLayout(hBox)
            if var == "ScanFile":
                w.setToolTip(
                    " Use tst.fio or [\"tst.fio\", \"tst.nxs\"] to specify 1 or 2 output files."
                )
                w_value.setToolTip(
                    " Use tst.fio or [\"tst.fio\", \"tst.nxs\"] to specify 1 or 2 output files."
                )
                w_line.setToolTip(
                    " Use tst.fio or [\"tst.fio\", \"tst.nxs\"] to specify 1 or 2 output files."
                )

        #
        # horizontal line
        #
        hBox = QtGui.QHBoxLayout()
        w = QtGui.QFrame()
        w.setFrameShape(QtGui.QFrame.HLine)
        w.setFrameShadow(QtGui.QFrame.Sunken)
        hBox.addWidget(w)
        self.layout_v.addLayout(hBox)
        #
        # JsonRecorder
        #
        hBox = QtGui.QHBoxLayout()
        self.w_jsonRecorderCheckBox = QtGui.QCheckBox()
        self.w_jsonRecorderCheckBox.setToolTip("Enables SardanaMonitor")
        a = HasyUtils.getEnv("JsonRecorder")
        if a is False:
            self.w_jsonRecorderCheckBox.setChecked(False)
        else:
            self.w_jsonRecorderCheckBox.setChecked(True)

        self.w_jsonRecorderCheckBox.stateChanged.connect(self.cb_jsonRecorder)
        hBox.addWidget(self.w_jsonRecorderCheckBox)
        l = QtGui.QLabel("JsonRecorder")
        l.setMinimumWidth(120)
        hBox.addWidget(l)
        hBox.addStretch()
        self.layout_v.addLayout(hBox)
        #
        # horizontal line
        #
        hBox = QtGui.QHBoxLayout()
        w = QtGui.QFrame()
        w.setFrameShape(QtGui.QFrame.HLine)
        w.setFrameShadow(QtGui.QFrame.Sunken)
        hBox.addWidget(w)
        self.layout_v.addLayout(hBox)
        #
        # ShowDial, ShowCtrlAxis
        #
        hsh = HasyUtils.getEnv("_ViewOptions")
        hBox = QtGui.QHBoxLayout()
        self.w_showDialCheckBox = QtGui.QCheckBox()
        self.w_showDialCheckBox.setToolTip(
            "If True, 'Dial' with motor position (wa, wm)")
        if hsh['ShowDial']:
            self.w_showDialCheckBox.setChecked(True)
        else:
            self.w_showDialCheckBox.setChecked(False)
        self.w_showDialCheckBox.stateChanged.connect(self.cb_showDial)
        hBox.addWidget(self.w_showDialCheckBox)
        l = QtGui.QLabel("ShowDial")
        l.setMinimumWidth(120)
        hBox.addWidget(l)

        self.w_showCtrlAxisCheckBox = QtGui.QCheckBox()
        self.w_showCtrlAxisCheckBox.setToolTip(
            "If True, show controller axis with motor position (wa, wm)")
        if hsh['ShowCtrlAxis']:
            self.w_showCtrlAxisCheckBox.setChecked(True)
        else:
            self.w_showCtrlAxisCheckBox.setChecked(False)
        self.w_showCtrlAxisCheckBox.stateChanged.connect(self.cb_showCtrlAxis)
        hBox.addWidget(self.w_showCtrlAxisCheckBox)
        l = QtGui.QLabel("ShowCtrlAxis")
        l.setMinimumWidth(120)
        hBox.addWidget(l)
        hBox.addStretch()
        self.layout_v.addLayout(hBox)
        #
        # horizontal line
        #
        hBox = QtGui.QHBoxLayout()
        w = QtGui.QFrame()
        w.setFrameShape(QtGui.QFrame.HLine)
        w.setFrameShadow(QtGui.QFrame.Sunken)
        hBox.addWidget(w)
        self.layout_v.addLayout(hBox)
        #
        # general hooks on-condition, on-stop
        #
        hBox = QtGui.QHBoxLayout()
        self.w_generalHooksCheckBox = QtGui.QCheckBox()
        lst = HasyUtils.getEnv("_GeneralHooks")
        if lst is None:
            self.w_generalHooksCheckBox.setChecked(False)
        else:
            self.w_generalHooksCheckBox.setChecked(True)

        self.w_generalHooksCheckBox.stateChanged.connect(self.cb_generalHooks)
        hBox.addWidget(self.w_generalHooksCheckBox)
        l = QtGui.QLabel("General hooks")
        l.setMinimumWidth(120)
        hBox.addWidget(l)
        #
        self.w_onConditionCheckBox = QtGui.QCheckBox()
        a = HasyUtils.getEnv("GeneralCondition")
        if a is None:
            self.w_onConditionCheckBox.setChecked(False)
        else:
            self.w_onConditionCheckBox.setChecked(True)

        self.w_onConditionCheckBox.stateChanged.connect(self.cb_onCondition)
        hBox.addWidget(self.w_onConditionCheckBox)
        l = QtGui.QLabel("On condition")
        l.setMinimumWidth(120)
        hBox.addWidget(l)

        self.w_editGeneralHooks = QtGui.QPushButton(self.tr("Edit"))
        self.w_editGeneralHooks.setStatusTip(
            "Edit file containing hooks and on-condition macros")
        hBox.addWidget(self.w_editGeneralHooks)
        self.w_editGeneralHooks.clicked.connect(self.cb_editGeneralHooks)

        self.w_reloadGeneralHooks = QtGui.QPushButton(self.tr("Reload"))
        self.w_reloadGeneralHooks.setStatusTip(
            "Reload hooks and on-condition code")
        hBox.addWidget(self.w_reloadGeneralHooks)
        self.w_reloadGeneralHooks.clicked.connect(self.cb_reloadGeneralHooks)
        #
        self.w_generalStopCheckBox = QtGui.QCheckBox()
        a = HasyUtils.getEnv("GeneralOnStopFunction")
        if a is None:
            self.w_generalStopCheckBox.setChecked(False)
        else:
            self.w_generalStopCheckBox.setChecked(True)

        self.w_generalStopCheckBox.stateChanged.connect(self.cb_generalStop)
        hBox.addWidget(self.w_generalStopCheckBox)
        l = QtGui.QLabel("GeneralOnStopFunction")
        hBox.addWidget(l)
        l.setMinimumWidth(120)

        self.w_editOnStop = QtGui.QPushButton(self.tr("Edit OnStop"))
        self.w_editOnStop.setToolTip("After edit, restart MacroServer")
        self.w_editOnStop.setStatusTip(
            "Edit ~/sardnanaMacros/generalFunctions/general_functions.py")
        hBox.addWidget(self.w_editOnStop)
        self.w_editOnStop.clicked.connect(self.cb_editOnStop)

        hBox.addStretch()
        self.layout_v.addLayout(hBox)
        #
        # horizontal line
        #
        hBox = QtGui.QHBoxLayout()
        w = QtGui.QFrame()
        w.setFrameShape(QtGui.QFrame.HLine)
        w.setFrameShadow(QtGui.QFrame.Sunken)
        hBox.addWidget(w)
        self.layout_v.addLayout(hBox)
        #
        # logging
        #
        # LogMacro
        #
        hBox = QtGui.QHBoxLayout()
        self.w_LogMacroCheckBox = QtGui.QCheckBox()
        self.w_LogMacroCheckBox.setToolTip(
            "If True, logging is active. \nThe file session_<BL>_door_<TANGO_HOST>.<i>.log\nis created in LogMacroDir"
        )
        self.w_LogMacroCheckBox.stateChanged.connect(self.cb_LogMacro)
        hBox.addWidget(self.w_LogMacroCheckBox)
        l = QtGui.QLabel("LogMacro")
        l.setMinimumWidth(120)
        l.setToolTip(
            "If True, logging is active. \nThe file session_<BL>_door_<TANGO_HOST>.<i>.log\nis created in LogMacroDir"
        )
        hBox.addWidget(l)
        hBox.addStretch()
        self.layout_v.addLayout(hBox)
        #
        #
        # LogMacroMode
        #
        self.varsEnv.append("LogMacroMode")
        var = "LogMacroMode"
        w = QtGui.QLabel("%s:" % var)
        w.setToolTip("If False, only one log file is created (recommended)")
        w.setMinimumWidth(120)
        hBox.addWidget(w)
        hsh = {}
        w_value = QtGui.QLabel()
        w_value.setMinimumWidth(250)
        w_value.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Sunken)
        hBox.addWidget(w_value)
        w_line = QtGui.QLineEdit()
        w_line.setAlignment(QtCore.Qt.AlignRight)
        w_line.setMinimumWidth(250)
        hBox.addWidget(w_line)
        self.dct[var] = {"w_value": w_value, "w_line": w_line}

        #
        # LogMacroDir
        #
        self.varsEnv.append("LogMacroDir")
        var = "LogMacroDir"
        hBox = QtGui.QHBoxLayout()
        w = QtGui.QLabel("%s:" % var)
        w.setMinimumWidth(120)
        hBox.addWidget(w)
        hsh = {}
        w_value = QtGui.QLabel()
        w_value.setMinimumWidth(250)
        w_value.setFrameStyle(QtGui.QFrame.Panel | QtGui.QFrame.Sunken)
        hBox.addWidget(w_value)
        w_line = QtGui.QLineEdit()
        w_line.setAlignment(QtCore.Qt.AlignRight)
        w_line.setMinimumWidth(250)
        hBox.addWidget(w_line)
        self.dct[var] = {"w_value": w_value, "w_line": w_line}
        self.layout_v.addLayout(hBox)