示例#1
0
def main():

    from taurus.qt.qtgui.application import TaurusApplication
    import sys

    from taurus.core.util.argparse import get_taurus_parser

    parser = get_taurus_parser()
    parser.set_usage("python showscanonline.py [door_name]")
    app = TaurusApplication(app_name='Showscan Online',
                            org_domain="Sardana",
                            org_name="Tango communinity",
                            cmd_line_parser=parser)

    gui = TaurusGuiLite()
    args = app.get_command_line_args()

    if len(args) < 1:
        parser.print_help(sys.stderr)
        sys.exit(1)

    door_name = args[0]
    widget = ShowScanOnline(gui)
    widget.setModel(door_name)
    gui.show()
    sys.exit(app.exec_())
示例#2
0
def main():
    from taurus.qt.qtgui.application import TaurusApplication
    from taurus.core.util import argparse
    import sys

    parser = argparse.get_taurus_parser()
    parser.usage = "%prog [options] <LimaCCDs device>"

    app = TaurusApplication(sys.argv,
                            cmd_line_parser=parser,
                            app_name="BeamViewer",
                            app_version="1.0")

    args = app.get_command_line_args()

    widget = BeamViewer(toolbar=True, options={'show_contrast': True})

    if len(args) < 1:
        parser.print_help()
        sys.exit(1)

    widget.setModel(args[0])
    widget.show()

    sys.exit(app.exec_())
示例#3
0
def TaurusPanelMain():
    '''A launcher for TaurusPanel.'''
    # NOTE: DON'T PUT TEST CODE HERE.
    # THIS IS CALLED FROM THE LAUNCHER SCRIPT (<taurus>/scripts/tauruspanel)
    from taurus.qt.qtgui.application import TaurusApplication
    from taurus.core.util import argparse
    import sys

    parser = argparse.get_taurus_parser()
    parser.set_usage("%prog [options] [devname]")
    parser.set_description("Taurus Application inspired in Jive and Atk Panel")

    app = TaurusApplication(cmd_line_parser=parser, app_name="tauruspanel",
                            app_version=taurus.Release.version)
    args = app.get_command_line_args()
    options = app.get_command_line_options()

    w = TaurusDevPanel()

    if options.tango_host is None:
        options.tango_host = taurus.Authority().getNormalName()
    w.setTangoHost(options.tango_host)

    if len(args) == 1:
        w.setDevice(args[0])

    w.show()

    sys.exit(app.exec_())
示例#4
0
def TaurusPanelMain():
    '''A launcher for TaurusPanel.'''
    # NOTE: DON'T PUT TEST CODE HERE.
    # THIS IS CALLED FROM THE LAUNCHER SCRIPT (<taurus>/scripts/tauruspanel)
    from taurus.qt.qtgui.application import TaurusApplication
    from taurus.core.util import argparse
    import sys

    parser = argparse.get_taurus_parser()
    parser.set_usage("%prog [options] [devname]")
    parser.set_description("Taurus Application inspired in Jive and Atk Panel")

    app = TaurusApplication(cmd_line_parser=parser,
                            app_name="tauruspanel",
                            app_version=taurus.Release.version)
    args = app.get_command_line_args()
    options = app.get_command_line_options()

    w = TaurusDevPanel()

    if options.tango_host is None:
        options.tango_host = taurus.Authority().getNormalName()
    w.setTangoHost(options.tango_host)

    if len(args) == 1:
        w.setDevice(args[0])

    w.show()

    sys.exit(app.exec_())
示例#5
0
def TaurusPanelMain():
    """A launcher for TaurusPanel."""

    from taurus.qt.qtgui.panel import TaurusDevPanel

    parser = argparse.get_taurus_parser()
    parser.set_usage("%prog [options] [devname]")
    parser.set_description("Taurus Application inspired in Jive and Atk Panel")

    app = TaurusApplication(cmd_line_parser=parser,
                            app_name="tauruspanel",
                            app_version=Release.version)
    args = app.get_command_line_args()
    options = app.get_command_line_options()

    w = TaurusDevPanel()

    if options.tango_host is None:
        options.tango_host = taurus.Authority().getNormalName()
    w.setTangoHost(options.tango_host)

    if len(args) == 1:
        w.setDevice(args[0])

    w.show()

    sys.exit(app.exec_())
示例#6
0
def main():
    from taurus.core.util import argparse
    from taurus.qt.qtgui.application import TaurusApplication

    parser = argparse.get_taurus_parser()
    parser.set_usage("%prog [options]")
    parser.set_description("Sardana macro sequencer.\n"
                           "It allows the creation of sequences of "
                           "macros, executed one after the other.\n"
                           "The sequences can be stored under xml files")
    parser.add_option("-f",
                      "--file",
                      dest="file",
                      default=None,
                      help="load an xml macro sequence file")

    app = TaurusApplication(cmd_line_parser=parser,
                            app_name="sequencer",
                            app_version=sardana.Release.version)
    args = app.get_command_line_args()
    options = app.get_command_line_options()

    app.setOrganizationName(globals.ORGANIZATION_NAME)
    app.setApplicationName(globals.SEQUENCER_APPLICATION_NAME)
    sequencer = createSequencer(args, options)
    sequencer.show()
    sys.exit(app.exec_())
示例#7
0
def main():
    from taurus.core.util import argparse
    from taurus.qt.qtgui.application import TaurusApplication

    parser = argparse.get_taurus_parser()
    parser.set_usage("%prog [options]")
    parser.set_description("Sardana macro sequencer.\n"
                           "It allows the creation of sequences of "
                           "macros, executed one after the other.\n"
                           "The sequences can be stored under xml files")
    parser.add_option("-f", "--file",
                      dest="file", default=None,
                      help="load an xml macro sequence file")

    app = TaurusApplication(cmd_line_parser=parser,
                            app_name="sequencer",
                            app_version=sardana.Release.version)
    args = app.get_command_line_args()
    options = app.get_command_line_options()

    app.setOrganizationName(globals.ORGANIZATION_NAME)
    app.setApplicationName(globals.SEQUENCER_APPLICATION_NAME)
    sequencer = createSequencer(args, options)
    sequencer.show()
    sys.exit(app.exec_())
def main():
    parser = argparse.get_taurus_parser()
    parser.add_option("--model")
    app = TaurusApplication(sys.argv, cmd_line_parser=parser,
                            app_name='ctdiMeasuredFillingPattern',
                            app_version=__version, org_domain='ALBA',
                            org_name='ALBA')
    options = app.get_command_line_options()
    ui = MainWindow()
    if options.model is not None:
        ui.setModel(options.model)
    ui.show()
    sys.exit(app.exec_())
示例#9
0
def taurusconfigeditor():
    from taurus.qt.qtgui.panel.taurusconfigeditor import QConfigEditor

    parser = argparse.get_taurus_parser()
    parser.set_usage("%prog [options] [INIFILENAME]")
    parser.set_description("taurus configuration editor")
    app = TaurusApplication(cmd_line_parser=parser,
                            app_name="taurusconfigeditor",
                            app_version=Release.version)
    args = app.get_command_line_args()
    w = QConfigEditor()
    w.setMinimumSize(500, 500)
    w.show()
    if len(args) == 1:
        w.loadFile(args[0])
    sys.exit(app.exec_())
def main():
    import sys
    import json
    import taurus.core.util.argparse as argparse

    parser = argparse.get_taurus_parser()
    parser.set_usage("%prog [options] <devName>")
    parser.set_description("This is a test script for the Iocaste of Hazemeyer Power supplies.")
    parser.add_option("--pollingPeriod")
    parser.add_option("--waitTime")
    parser.add_option("--transitions")
    parser.add_option("--realExecution")

    parser, options, args = argparse.init_taurus_args(parser=parser)

    if not len(args) == 1:
        sys.stderr.write("Need to supply one (and only one) device Name\n")
        sys.exit(1)

    print("args = %s"%(args))
    optionsstr = "%s"%options
    optionsdict = eval(optionsstr)

    print("optionsdict = %s"%(optionsdict))

    if optionsdict['pollingPeriod'] == None: pollinglist = 250
    else: pollinglist = json.loads(optionsdict['pollingPeriod'])

    if optionsdict['transitions'] == None: transitions = 1000
    else: transitions = int(optionsdict['transitions'])

    if optionsdict['realExecution'] == None: realExecution = True
    else: realExecution = eval(optionsdict['realExecution'])

    for pollperiod in pollinglist:
        for Wsingle in [True,False]:
            if optionsdict['waitTime'] == None: waitTime = (10*1000)/pollperiod #mean 10s
            else: waitTime = (int(optionsdict['waitTime'])*1000)/pollperiod
            print("HazemeyerIocaster_Tester(devName=%s,"\
                  "pollingPeriod=%s,ntimes=%s,transitions=%s,"\
                  "useWsingle=%s"\
                  %(args[0],pollperiod,waitTime,transitions,Wsingle))
            if realExecution:
                tester = HazemeyerIocaster_Tester(args[0],pollperiod,waitTime,transitions,Wsingle)
示例#11
0
def TaurusDevicePanelMain():
    '''A launcher for TaurusDevicePanel.'''
    import sys
    from taurus.qt.qtgui.application import TaurusApplication
    from taurus.core.util import argparse

    parser = argparse.get_taurus_parser()
    parser.set_usage("%prog [options] [devname [attrs]]")
    parser.set_description("Taurus Application inspired in Jive and Atk Panel")
    parser.add_option("",
                      "--config-file",
                      dest="config_file",
                      default=None,
                      help="load a config file (TODO: document this option)")

    app = TaurusApplication(cmd_line_parser=parser,
                            app_name="TaurusDevicePanel",
                            app_version=taurus.Release.version)
    args = app.get_command_line_args()
    options = app.get_command_line_options()

    w = TaurusDevicePanel()
    w.show()

    if len(args) == 0:
        from taurus.qt.qtgui.panel import TaurusModelChooser
        models, ok = TaurusModelChooser.modelChooserDlg(
            w, selectables=[TaurusElementType.Member], singleModel=True)
        model = models[0] if ok and models else None
        filters = ''
    else:
        model = args[0]
        filters = args[1:]

    if options.config_file is not None:
        w.loadConfigFile(options.config_file)
    elif model and filters:
        w.setAttributeFilters({model: filters})

    w.setModel(model)

    sys.exit(app.exec_())
示例#12
0
def main():
    import sys
    from taurus.core.util import argparse
    from taurus.external.qt.qtgui.application import TaurusApplication

    parser = argparse.get_taurus_parser()
    parser.set_usage("%prog [options] [model1 [model2 ...]]")

    app = TaurusApplication(cmd_line_parser=parser)

    args = app.get_command_line_args()
    if not args:
        parser.print_usage()
        sys.exit(1)

    form = MAXForm()
    form.setModel(args)
    form.show()

    sys.exit(app.exec_())
示例#13
0
def main():
    from taurus.core.util import argparse
    from taurus.qt.qtgui.application import TaurusApplication

    parser = argparse.get_taurus_parser()
    parser.set_usage("%prog [options]")
    parser.set_description("Sardana macro executor.\n"
                           "It allows execution of macros, keeping history "
                           "of previous executions and favourites.")
    app = TaurusApplication(sys.argv,
                            cmd_line_parser=parser,
                            app_name="macroexecutor",
                            app_version=sardana.Release.version)
    args = app.get_command_line_args()

    app.setOrganizationName("Taurus")
    app.setApplicationName("macroexecutor")
    macroExecutor = createMacroExecutor(args)
    macroExecutor.show()
    sys.exit(app.exec_())
示例#14
0
def main():
    from taurus.qt.qtgui.application import TaurusApplication
    from taurus.core.util import argparse
    from taurus import Release
    import sys

    parser = argparse.get_taurus_parser()
    parser.set_usage("%prog [options] [INIFILENAME]")
    parser.set_description("taurus configuration editor")
    app = TaurusApplication(cmd_line_parser=parser,
                            app_name="taurusconfigeditor",
                            app_version=Release.version)
    args = app.get_command_line_args()
    w = QConfigEditor()
    w.setMinimumSize(500, 500)
    w.show()
    if len(args) == 1:
        w.loadFile(args[0])

    sys.exit(app.exec_())
示例#15
0
def test():
    import sys
    import taurus
    import time
    from taurus.core.util.argparse import get_taurus_parser
    from taurus.qt.qtgui.application import TaurusApplication

    parser = get_taurus_parser()
    app = TaurusApplication(sys.argv, cmd_line_parser=parser)

    favouritesEditor = FavouritesMacrosEditor()

    args = app.get_command_line_args()
    favouritesEditor.setModel(args[0])
    time.sleep(1)
    macroNode = favouritesEditor.getModelObj().getMacroNodeObj(str(args[1]))
    favouritesEditor.addMacro(macroNode)
    favouritesEditor.show()

    sys.exit(app.exec_())
示例#16
0
def TaurusDevicePanelMain():
    '''A launcher for TaurusDevicePanel.'''
    import sys
    from taurus.qt.qtgui.application import TaurusApplication
    from taurus.core.util import argparse

    parser = argparse.get_taurus_parser()
    parser.set_usage("%prog [options] [devname [attrs]]")
    parser.set_description("Taurus Application inspired in Jive and Atk Panel")
    parser.add_option("", "--config-file", dest="config_file", default=None,
                      help="load a config file (TODO: document this option)")

    app = TaurusApplication(cmd_line_parser=parser, app_name="TaurusDevicePanel",
                            app_version=taurus.Release.version)
    args = app.get_command_line_args()
    options = app.get_command_line_options()

    w = TaurusDevicePanel()
    w.show()

    if len(args) == 0:
        from taurus.qt.qtgui.panel import TaurusModelChooser
        models, ok = TaurusModelChooser.modelChooserDlg(w,
                                                        selectables=[
                                                            TaurusElementType.Member],
                                                        singleModel=True)
        model = models[0] if ok and models else None
        filters = ''
    else:
        model = args[0]
        filters = args[1:]

    if options.config_file is not None:
        w.loadConfigFile(options.config_file)
    elif model and filters:
        w.setAttributeFilters({model: filters})

    w.setModel(model)

    sys.exit(app.exec_())
示例#17
0
def main():
    import sys
    from taurus.core.util import argparse
    from taurus.external.qt.qtgui.application import TaurusApplication

    parser = argparse.get_taurus_parser()
    parser.usage = "%prog [options] <device>"

    app = TaurusApplication(cmd_line_parser=parser)
    args = app.get_command_line_args()

    if len(args) < 1:
        parser.print_usage()
        sys.exit(1)

    model = args[0]

    w = SwitchBoardPanel()
    w.setModel(model)
    w.show()

    sys.exit(app.exec_())
示例#18
0
def main():
    from taurus.core.util import argparse
    from taurus.qt.qtgui.application import TaurusApplication
    from taurus.qt.qtgui.panel import TaurusForm

    parser = argparse.get_taurus_parser()
    parser.set_usage("%prog [options] [model1 [model2 ...]]")

    app = TaurusApplication(cmd_line_parser=parser)

    args = app.get_command_line_args()
    if not args:
        parser.print_usage()
        sys.exit(1)

    form = TaurusForm()
    form.setFormWidget(GammaSPCeTV)
    form.setModel(args)
    form.setModifiableByUser(True)
    form.show()

    sys.exit(app.exec_())
示例#19
0
def taurusTableMain():
    '''A launcher for TaurusValuesTable.'''

    from taurus.qt.qtgui.application import TaurusApplication
    from taurus.core.util import argparse
    import sys
    import os

    parser = argparse.get_taurus_parser()
    parser.set_usage("%prog [options] [model]]")
    parser.set_description(
        "A table for viewing and editing 1D and 2D attribute values")
    app = TaurusApplication(cmd_line_parser=parser,
                            app_name="TaurusValuesTable",
                            app_version=taurus.Release.version)
    args = app.get_command_line_args()

    dialog = TaurusValuesTable()
    dialog.setModifiableByUser(True)
    dialog.setWindowTitle(app.applicationName())

    # set a model list from the command line or launch the chooser
    if len(args) == 1:
        model = args[0]
        dialog.setModel(model)
    else:
        dialog.chooseModel()
        #model = 'sys/tg_test/1/boolean_spectrum'
        # model = 'sys/tg_test/1/boolean_image'
        # model = 'sys/tg_test/1/string_spectrum'
        # model = 'sys/tg_test/1/float_image'
        # model = 'sys/tg_test/1/double_image'
        # model = 'sys/tg_test/1/double_image_ro'
        # model = 'sys/tg_test/1/wave'
        # dialog.setModel(model)

    dialog.show()
    sys.exit(app.exec_())
示例#20
0
def taurusTableMain():
    '''A launcher for TaurusValuesTable.'''

    from taurus.qt.qtgui.application import TaurusApplication
    from taurus.core.util import argparse
    import sys
    import os

    parser = argparse.get_taurus_parser()
    parser.set_usage("%prog [options] [model]]")
    parser.set_description(
        "A table for viewing and editing 1D and 2D attribute values")
    app = TaurusApplication(cmd_line_parser=parser,
                            app_name="TaurusValuesTable",
                            app_version=taurus.Release.version)
    args = app.get_command_line_args()

    dialog = TaurusValuesTable()
    dialog.setModifiableByUser(True)
    dialog.setWindowTitle(app.applicationName())

    # set a model list from the command line or launch the chooser
    if len(args) == 1:
        model = args[0]
        dialog.setModel(model)
    else:
        dialog.chooseModel()
        #model = 'sys/tg_test/1/boolean_spectrum'
        # model = 'sys/tg_test/1/boolean_image'
        # model = 'sys/tg_test/1/string_spectrum'
        # model = 'sys/tg_test/1/float_image'
        # model = 'sys/tg_test/1/double_image'
        # model = 'sys/tg_test/1/double_image_ro'
        # model = 'sys/tg_test/1/wave'
        # dialog.setModel(model)

    dialog.show()
    sys.exit(app.exec_())
示例#21
0
def main():
    from taurus.qt.qtgui.application import TaurusApplication
    from taurus.core.util import argparse
    import sys

    parser = argparse.get_taurus_parser()
    parser.usage = "%prog [options] [hostname]"

    app = TaurusApplication(cmd_line_parser=parser)
    args = app.get_command_line_args()

    if len(args) > 0:
        host = args[0]
    else:
        host = taurus.Authority().getNormalName()

    w = TaurusFilterPanel()
    w.setWindowIcon(Qt.QIcon(":/actions/system-shutdown.svg"))
    w.setWindowTitle("A Taurus Filter Example")
    w.setModel(host)
    w.show()

    sys.exit(app.exec_())
示例#22
0
def main():
    from taurus.qt.qtgui.application import TaurusApplication
    from taurus.core.util import argparse
    import sys

    parser = argparse.get_taurus_parser()
    parser.usage = "%prog [options] [hostname]"

    app = TaurusApplication(cmd_line_parser=parser)
    args = app.get_command_line_args()

    if len(args) > 0:
        host = args[0]
    else:
        host = taurus.Authority().getNormalName()

    w = TaurusFilterPanel()
    w.setWindowIcon(Qt.QIcon(":/actions/system-shutdown.svg"))
    w.setWindowTitle("A Taurus Filter Example")
    w.setModel(host)
    w.show()

    sys.exit(app.exec_())
示例#23
0
def run(period=PERIOD):
    """Run LLRF expert GUI."""
    import taurus.core.util.argparse as argparse
    parser = argparse.get_taurus_parser()
    parser.set_usage("%prog [-e, --expert]")
    description_message = "Graphical User Interface to control a LLRF system."
    parser.set_description(description_message)
    parser.add_option('-e', '--expert', action='store_true',
                      help="Launch the GUI in expert mode")

    parser.add_option('-r', '--rf_room', type=str,
                      help="""RF Room to be controlled.
                              \nAvailable options:
                              \n  RF-ROOM-1,RF-ROOM-2,RF-ROOM-3, R1, RF-LAB
                           """)

    parser, options, args = argparse.init_taurus_args(parser=parser)

    # set_polling_period(period)

    import taurus
    taurus.Manager().changeDefaultPollingPeriod(period)
    configure_pythonpath()

    if options.expert:
        models = get_model(options.expert, options.rf_room)
        section, loops, diags, rftrans1, rftrans2 = models
        llrf = None
        llrfdiags = None
    else:
        models = get_model(options.expert, options.rf_room)
        section, loops, diags, llrf, llrfdiags, rftrans1, rftrans2 = models

    app_name = create_app_name(section, options.expert)
    app, gui = create_application(app_name, parser=parser)

    splashLogo = os.path.join(os.path.dirname(__file__),
                              'images/maxivlogo.png')
    splashscreen = Qt.QSplashScreen(Qt.QPixmap(splashLogo))
    splashscreen.show()
    app.processEvents()

    hide_toolbars(gui)

    splashscreen.showMessage('Creating panels')
    create_panels(
        splashscreen=splashscreen,
        gui=gui,
        section=section,
        loops_device=loops,
        diags_device=diags,
        is_expert=options.expert,
        transmitter1=rftrans1,
        transmitter2=rftrans2,
        llrf_device=llrf,
        llrfdiags_device=llrfdiags)
    splashscreen.showMessage('Loading settings')
    load_settings(gui, options.expert)

    gui.show()
    splashscreen.finish(gui)
    sys.exit(app.exec_())
示例#24
0
def taurusFormMain():
    '''A launcher for TaurusForm.'''
    # NOTE: DON'T PUT TEST CODE HERE.
    # THIS IS CALLED FROM THE LAUNCHER SCRIPT (<taurus>/scripts/taurusform)
    # USE test1() instead.
    from taurus.qt.qtgui.application import TaurusApplication
    from taurus.core.util import argparse
    import sys
    import os

    parser = argparse.get_taurus_parser()
    parser.set_usage("%prog [options] [model1 [model2 ...]]")
    parser.set_description("the taurus form panel application")
    parser.add_option("--window-name", dest="window_name",
                      default="TaurusForm", help="Name of the window")
    parser.add_option("--config", "--config-file", dest="config_file", default=None,
                      help="use the given config file for initialization")
    app = TaurusApplication(cmd_line_parser=parser,
                            app_name="taurusform",
                            app_version=taurus.Release.version)
    args = app.get_command_line_args()
    options = app.get_command_line_options()

    dialog = TaurusForm()
    dialog.setModifiableByUser(True)
    dialog.setModelInConfig(True)
    dialog.setWindowTitle(options.window_name)

    # Make sure the window size and position are restored
    dialog.registerConfigProperty(dialog.saveGeometry, dialog.restoreGeometry,
                                  'MainWindowGeometry')

    quitApplicationAction = Qt.QAction(
        Qt.QIcon.fromTheme("process-stop"), 'Close Form', dialog)
    quitApplicationAction.triggered.connect(dialog.close)

    saveConfigAction = Qt.QAction("Save current settings...", dialog)
    saveConfigAction.setShortcut(Qt.QKeySequence.Save)
    saveConfigAction.triggered.connect(
        partial(dialog.saveConfigFile, ofile=None))
    loadConfigAction = Qt.QAction("&Retrieve saved settings...", dialog)
    loadConfigAction.setShortcut(Qt.QKeySequence.Open)
    loadConfigAction.triggered.connect(
        partial(dialog.loadConfigFile, ifile=None))

    dialog.addActions(
        (saveConfigAction, loadConfigAction, quitApplicationAction))

    # set the default map for this installation
    from taurus import tauruscustomsettings
    dialog.setCustomWidgetMap(
        getattr(tauruscustomsettings, 'T_FORM_CUSTOM_WIDGET_MAP', {}))

    # set a model list from the command line or launch the chooser
    if options.config_file is not None:
        dialog.loadConfigFile(options.config_file)
    elif len(args) > 0:
        models = args
        dialog.setModel(models)
    else:
        dialog.chooseModels()

    dialog.show()

    sys.exit(app.exec_())
示例#25
0
def taurusplot():
    import datetime
    from taurus.qt.qtgui.qwt5 import TaurusPlot

    parser = argparse.get_taurus_parser()
    parser.set_usage("%prog [options] [<model1> [<model2>] ...]")
    parser.set_description("a taurus application for plotting 1D data sets")
    parser.add_option(
        "-x",
        "--x-axis-mode",
        dest="x_axis_mode",
        default='e',
        metavar="t|n",
        help=
        "interprete X values as either timestamps (t) or numbers (n). Accepted values: t|n (e is also accepted as a synonim of n)"
    )
    parser.add_option("--config",
                      "--config-file",
                      dest="config_file",
                      default=None,
                      help="use the given config file for initialization")
    parser.add_option("--import-ascii",
                      dest="import_ascii",
                      default=None,
                      help="import the given ascii file into the plot")
    parser.add_option(
        "--export",
        "--export-file",
        dest="export_file",
        default=None,
        help="use the given file to as output instead of showing the plot")
    parser.add_option("--window-name",
                      dest="window_name",
                      default="TaurusPlot",
                      help="Name of the window")

    app = TaurusApplication(cmd_line_parser=parser,
                            app_name="taurusplot",
                            app_version=Release.version)
    args = app.get_command_line_args()
    options = app.get_command_line_options()
    if options.x_axis_mode.lower() not in ['t', 'e', 'n']:
        parser.print_help(sys.stderr)
        sys.exit(1)

    models = args
    w = TaurusPlot()
    w.setWindowTitle(options.window_name)

    w.setXIsTime(options.x_axis_mode.lower() == 't')
    if options.config_file is not None:
        w.loadConfig(options.config_file)

    if options.import_ascii is not None:
        w.importAscii([options.import_ascii], xcol=0)

    if models:
        w.setModel(models)

    if options.export_file is not None:
        curves = dict.fromkeys(w.trendSets, 0)

        def exportIfAllCurves(curve, trend=w, counters=curves):
            curve = str(curve)
            print('*' * 10 + ' %s: Event received for %s  ' %
                  (datetime.now().isoformat(), curve) + '*' * 10)
            if curve in counters:
                counters[curve] += 1
                if all(counters.values()):
                    trend.exportPdf(options.export_file)
                    print('*' * 10 + ' %s: Exported to : %s  ' %
                          (datetime.now().isoformat(), options.export_file) +
                          '*' * 10)
                    trend.close()
            return

        if not curves:
            w.close()
        else:
            for ts in w.trendSets.values():
                ts.dataChanged.connect(exportIfAllCurves)
        sys.exit(app.exec_())  # exit without showing the widget

    # show the widget
    w.show()
    # if no models are passed, show the data import dialog
    if (len(models) == 0 and options.config_file is None
            and options.import_ascii is None):
        w.showDataImportDlg()

    sys.exit(app.exec_())
示例#26
0
def taurusgui(confname=None):
    from taurus.qt.qtgui.taurusgui import TaurusGui

    taurus.info('Starting execution of TaurusGui')

    parser = argparse.get_taurus_parser()
    parser.set_usage("%prog [options] confname")
    parser.set_description("The taurus GUI application")
    parser.add_option(
        "",
        "--config-dir",
        dest="config_dir",
        default=None,
        help="use the given configuration directory for initialization")
    parser.add_option(
        "",
        "--new-gui",
        action="store_true",
        dest="new_gui",
        default=None,
        help="launch a wizard for creating a new TaurusGUI application")
    parser.add_option(
        "",
        "--fail-proof",
        action="store_true",
        dest="fail_proof",
        default=None,
        help=
        "launch in fail proof mode (it prevents potentially problematic configs from being loaded)"
    )

    app = TaurusApplication(cmd_line_parser=parser,
                            app_name="taurusgui",
                            app_version=taurus.Release.version)
    args = app.get_command_line_args()
    options = app.get_command_line_options()

    if options.new_gui:  # launch app settings wizard instead of taurusgui
        from taurus.qt.qtgui.taurusgui import AppSettingsWizard
        wizard = AppSettingsWizard()
        wizard.show()
        sys.exit(app.exec_())

    if confname is None:
        confname = options.config_dir

    if confname is None:
        if len(
                args
        ) == 1:  # for backwards compat, we allow to specify the confname without the "--config-dir" parameter
            confname = args[0]
        else:
            parser.print_help(sys.stderr)
            sys.exit(1)

    if options.fail_proof:
        configRecursionDepth = 0
    else:
        configRecursionDepth = None

    gui = TaurusGui(None,
                    confname=confname,
                    configRecursionDepth=configRecursionDepth)

    gui.show()
    ret = app.exec_()

    taurus.info('Finished execution of TaurusGui')
    sys.exit(ret)
示例#27
0
    @ProtectTaurusMessageBox(msg='An error occurred trying to abort the macro.')
    def abort(self):
        '''stops macros'''
        door = self.getModelObj()
        if door is not None:
            door.stopMacro()


if __name__ == '__main__':
    import sys
    from taurus.qt.qtgui.application import TaurusApplication
    from taurus.core.util.argparse import get_taurus_parser
    from sardana.macroserver.macros.test import SarDemoEnv

    parser = get_taurus_parser()
    parser.set_usage("python macrobutton.py [door_name]")
    parser.set_description("Macro button for macro execution")

    app = TaurusApplication(app_name="macrobutton",
                            app_version=taurus.Release.version)

    args = app.get_command_line_args()

    if len(args) < 1:
        parser.print_help(sys.stderr)
        sys.exit(1)

    door_name = args[0]

    w = Qt.QWidget()
示例#28
0
    @ProtectTaurusMessageBox(msg='An error occurred trying to abort the macro.'
                             )
    def abort(self):
        '''stops macros'''
        door = self.getModelObj()
        if door is not None:
            door.stopMacro()


if __name__ == '__main__':
    import sys
    from taurus.qt.qtgui.application import TaurusApplication
    from taurus.core.util.argparse import get_taurus_parser
    from sardana.macroserver.macros.test import SarDemoEnv

    parser = get_taurus_parser()
    parser.set_usage("python macrobutton.py [door_name]")
    parser.set_description("Macro button for macro execution")

    app = TaurusApplication(app_name="macrobutton",
                            app_version=taurus.Release.version)

    args = app.get_command_line_args()

    if len(args) < 1:
        parser.print_help(sys.stderr)
        sys.exit(1)

    door_name = args[0]

    w = Qt.QWidget()
示例#29
0
def taurustrend():
    from taurus.qt.qtgui.qwt5 import TaurusTrend
    import datetime

    parser = argparse.get_taurus_parser()
    parser.set_usage("%prog [options] [<model1> [<model2>] ...]")
    parser.set_description("a taurus application for plotting trends")
    parser.add_option(
        "-x",
        "--x-axis-mode",
        dest="x_axis_mode",
        default='t',
        metavar="t|e",
        help=
        "interprete X values as either timestamps (t) or event numbers (e). Accepted values: t|e"
    )
    parser.add_option(
        "-b",
        "--buffer",
        dest="max_buffer_size",
        default=TaurusTrend.DEFAULT_MAX_BUFFER_SIZE,
        help=
        "maximum number of values per curve to be plotted (default = %i) (when reached, the oldest values will be discarded)"
        % TaurusTrend.DEFAULT_MAX_BUFFER_SIZE)
    parser.add_option("--config",
                      "--config-file",
                      dest="config_file",
                      default=None,
                      help="use the given config file for initialization")
    parser.add_option(
        "--export",
        "--export-file",
        dest="export_file",
        default=None,
        help="use the given file to as output instead of showing the plot")
    parser.add_option(
        "-r",
        "--forced-read",
        dest="forced_read_period",
        type="int",
        default=-1,
        metavar="MILLISECONDS",
        help="force Taurustrend to re-read the attributes every MILLISECONDS ms"
    )
    parser.add_option("-a",
                      "--use-archiving",
                      action="store_true",
                      dest="use_archiving",
                      default=False)
    parser.add_option("--window-name",
                      dest="window_name",
                      default="TaurusTrend",
                      help="Name of the window")

    app = TaurusApplication(cmd_line_parser=parser,
                            app_name="taurustrend",
                            app_version=Release.version)
    args = app.get_command_line_args()
    options = app.get_command_line_options()
    if options.x_axis_mode.lower() not in ['t', 'e']:
        parser.print_help(sys.stderr)
        sys.exit(1)

    models = args

    w = TaurusTrend()
    w.setWindowTitle(options.window_name)

    # xistime option
    w.setXIsTime(options.x_axis_mode.lower() == 't')
    # max buffer size option
    w.setMaxDataBufferSize(int(options.max_buffer_size))
    # configuration file option
    if options.config_file is not None:
        w.loadConfig(options.config_file)
    # set models
    if models:
        w.setModel(models)
    # export option
    if options.export_file is not None:
        curves = dict.fromkeys(w.trendSets, 0)

        def exportIfAllCurves(curve, trend=w, counters=curves):
            curve = str(curve)
            print('*' * 10 + ' %s: Event received for %s  ' %
                  (datetime.now().isoformat(), curve) + '*' * 10)
            if curve in counters:
                counters[curve] += 1
                if all(counters.values()):
                    trend.exportPdf(options.export_file)
                    print('*' * 10 + ' %s: Exported to : %s  ' %
                          (datetime.now().isoformat(), options.export_file) +
                          '*' * 10)
                    trend.close()
            return

        if not curves:
            w.close()
        else:
            for ts in w.trendSets.values():
                ts.dataChanged.connect(exportIfAllCurves)
        sys.exit(app.exec_())  # exit without showing the widget

    # period option
    if options.forced_read_period > 0:
        w.setForcedReadingPeriod(options.forced_read_period)

    # archiving option
    w.setUseArchiving(options.use_archiving)

    # show the widget
    w.show()

    # if no models are passed, show the data import dialog
    if len(models) == 0 and options.config_file is None:
        w.showDataImportDlg()

    sys.exit(app.exec_())
示例#30
0
文件: taurusform.py 项目: cmft/taurus
def taurusFormMain():
    '''A launcher for TaurusForm.'''
    # NOTE: DON'T PUT TEST CODE HERE.
    # THIS IS CALLED FROM THE LAUNCHER SCRIPT (<taurus>/scripts/taurusform)
    # USE test1() instead.
    from taurus.qt.qtgui.application import TaurusApplication
    from taurus.core.util import argparse
    import sys
    import os

    parser = argparse.get_taurus_parser()
    parser.set_usage("%prog [options] [model1 [model2 ...]]")
    parser.set_description("the taurus form panel application")
    parser.add_option("--window-name", dest="window_name",
                      default="TaurusForm", help="Name of the window")
    parser.add_option("--config", "--config-file", dest="config_file", default=None,
                      help="use the given config file for initialization")
    app = TaurusApplication(cmd_line_parser=parser,
                            app_name="taurusform",
                            app_version=taurus.Release.version)
    args = app.get_command_line_args()
    options = app.get_command_line_options()

    dialog = TaurusForm()
    dialog.setModifiableByUser(True)
    dialog.setModelInConfig(True)
    dialog.setWindowTitle(options.window_name)

    # Make sure the window size and position are restored
    dialog.registerConfigProperty(dialog.saveGeometry, dialog.restoreGeometry,
                                  'MainWindowGeometry')

    quitApplicationAction = Qt.QAction(
        Qt.QIcon.fromTheme("process-stop"), 'Close Form', dialog)
    quitApplicationAction.triggered[()].connect(dialog.close)

    saveConfigAction = Qt.QAction("Save current settings...", dialog)
    saveConfigAction.setShortcut(Qt.QKeySequence.Save)
    saveConfigAction.triggered[()].connect(dialog.saveConfigFile)

    loadConfigAction = Qt.QAction("&Retrieve saved settings...", dialog)
    loadConfigAction.setShortcut(Qt.QKeySequence.Open)
    loadConfigAction.triggered[()].connect(dialog.loadConfigFile)

    dialog.addActions(
        (saveConfigAction, loadConfigAction, quitApplicationAction))

    # set the default map for this installation
    from taurus import tauruscustomsettings
    dialog.setCustomWidgetMap(
        getattr(tauruscustomsettings, 'T_FORM_CUSTOM_WIDGET_MAP', {}))

    # set a model list from the command line or launch the chooser
    if options.config_file is not None:
        dialog.loadConfigFile(options.config_file)
    elif len(args) > 0:
        models = args
        dialog.setModel(models)
    else:
        dialog.chooseModels()

    dialog.show()

    sys.exit(app.exec_())