Esempio n. 1
0
    def _process_data(self):
        for sect, opts in conf_sects.items():
            if not self.cp.has_section(sect):
                # print 'skipping section ' ,sect
                continue
            bools = opts.get('bools', [])
            floats = opts.get('floats', [])
            ints = opts.get('ints', [])
            thissect = {}
            is_ordered = False
            if 'ordered' in opts:
                is_ordered = True

            for opt in self.cp.options(sect):
                get = self.cp.get
                if opt in bools:
                    get = self.cp.getboolean
                elif opt in floats:
                    get = self.cp.getfloat
                elif opt in ints:
                    get = self.cp.getint
                val = get(sect, opt)
                if is_ordered and '||' in val:
                    nam, val = val.split('||', 1)
                    opt = opt.strip()
                    val = nam, val.strip()
                thissect[opt] = val
            self.config[sect] = thissect

        if 'positions' in self.config:
            out = OrderedDict()
            poskeys = list(self.config['positions'].keys())
            poskeys.sort()
            for key in poskeys:
                name, val = self.config['positions'][key]
                name = name.strip()
                img, posval = val.strip().split('||')
                pos = [float(i) for i in posval.split(',')]
                out[name] = dict(image=img.strip(), position=pos)
            self.config['positions'] = out

        if 'stages' in self.config:
            out = OrderedDict()
            skeys = list(self.config['stages'].keys())
            skeys.sort()
            for key in skeys:
                name, val = self.config['stages'][key]
                name = name.strip()
                label, desc, sign = val.split('||')
                out[name] = dict(label=label.strip(),
                                 desc=desc.strip(),
                                 sign=int(sign))
            self.config['stages'] = out
            self.nstages = len(out)
Esempio n. 2
0
        'ints': ('finex_dir', 'finey_dir')
    },
    'camera': {
        'ordered': False
    },
    'stages': {
        'ordered': True
    },
    'positions': {
        'ordered': True
    }
}

conf_objs = OrderedDict(
    (('setup', ('verify_move', 'verify_erase', 'verify_overwrite', 'finex_dir',
                'finey_dir')), ('camera', ('type', 'image_folder', 'ad_prefix',
                                           'ad_format', 'web_url')),
     ('stages', None), ('positions', None)))

conf_files = ('SampleStage_autosave.ini', 'SampleStage.ini',
              '//cars5/Data/xas_user/config/SampleStage.ini')


class StageConfig(object):
    def __init__(self, filename=None, text=None):
        self.config = {}
        self.cp = ConfigParser()
        self.nstages = 0
        conf_found = False
        if filename is None:
            for fname in conf_files:
Esempio n. 3
0
    def __init__(self,
                 parent,
                 inst,
                 db=None,
                 writer=None,
                 pvlist=None,
                 size=(-1, -1)):
        self.last_draw = 0
        self.inst = inst
        self.pvlist = pvlist
        self.db = db
        self.write_message = writer
        self.pvs = {}
        self.pvdesc = {}
        self.pv_components = OrderedDict()

        wx.Panel.__init__(self, parent, size=size)

        #for p in self.db.get_ordered_instpvs(inst):
        #    self.add_pv(p.pv.name)

        self.colors = colors = GUIColors()
        self.parent = parent
        self.SetFont(parent.GetFont())
        titlefont = self.GetFont()
        titlefont.PointSize += 2
        titlefont.SetWeight(wx.BOLD)

        splitter = wx.SplitterWindow(self,
                                     -1,
                                     style=wx.SP_3D | wx.SP_BORDER
                                     | wx.SP_LIVE_UPDATE)

        rpanel = wx.Panel(splitter, style=wx.BORDER_SUNKEN, size=(-1, 225))
        self.leftpanel = wx.Panel(splitter,
                                  style=wx.BORDER_SUNKEN,
                                  size=(-1, 325))

        # self.leftsizer = wx.GridBagSizer(12, 4)
        self.leftsizer = wx.BoxSizer(wx.VERTICAL)

        splitter.SetMinimumPaneSize(225)

        toprow = wx.Panel(self.leftpanel)

        self.inst_title = SimpleText(toprow,
                                     ' %s ' % inst.name,
                                     font=titlefont,
                                     colour=colors.title,
                                     minsize=(150, -1),
                                     style=wx.ALIGN_LEFT | wx.ALIGN_BOTTOM)

        self.pos_name = wx.TextCtrl(toprow,
                                    value="",
                                    size=(250, 25),
                                    style=wx.TE_PROCESS_ENTER)
        self.pos_name.Bind(wx.EVT_TEXT_ENTER, self.onSavePosition)

        topsizer = wx.BoxSizer(wx.HORIZONTAL)
        topsizer.Add(self.inst_title, 0,
                     wx.ALIGN_CENTER | wx.ALIGN_CENTER_VERTICAL, 1)
        topsizer.Add(
            SimpleText(toprow,
                       'Save Current Position:',
                       minsize=(180, -1),
                       style=wx.ALIGN_CENTER), 1,
            wx.ALIGN_CENTER_VERTICAL | wx.ALL, 1)

        topsizer.Add(self.pos_name, 0,
                     wx.GROW | wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL, 1)

        pack(toprow, topsizer)
        self.toprow = toprow

        # start a timer to check for when to fill in PV panels
        timer_id = wx.NewId()
        # self.etimer = wx.Timer(self)
        self.etimer2 = wx.Timer(self)
        self.puttimer = wx.Timer(self)
        self.etimer_count = 0
        self.etimer_poll = 25

        # self.Bind(wx.EVT_TIMER, self.OnConnectTimer, self.etimer)
        self.Bind(wx.EVT_TIMER, self.OnEtimer2, self.etimer2)

        self.Bind(wx.EVT_TIMER, self.OnPutTimer, self.puttimer)

        rsizer = wx.BoxSizer(wx.VERTICAL)
        btn_goto = add_button(rpanel,
                              "Go To",
                              size=(70, -1),
                              action=self.OnMove)
        btn_erase = add_button(rpanel,
                               "Erase",
                               size=(70, -1),
                               action=self.onErase)

        brow = wx.BoxSizer(wx.HORIZONTAL)
        brow.Add(btn_goto, 0, ALL_EXP | wx.ALIGN_LEFT, 1)
        brow.Add(btn_erase, 0, ALL_EXP | wx.ALIGN_LEFT, 1)

        self.pos_list = wx.ListBox(rpanel, size=(225, -1))
        self.pos_list.SetBackgroundColour(wx.WHITE)
        self.pos_list.Bind(wx.EVT_RIGHT_DOWN, self.onRightClick)
        self.pos_list.Bind(wx.EVT_LISTBOX, self.onPosSelect)
        self.pos_list.Bind(wx.EVT_LEFT_DCLICK, self.OnMove)

        self.pos_list.Clear()
        for pos in inst.positions:
            self.pos_list.Append(pos.name)

        rsizer.Add(brow, 0, wx.ALIGN_LEFT | wx.ALL)
        rsizer.Add(self.pos_list, 1, wx.EXPAND | wx.ALIGN_CENTER, 1)
        pack(rpanel, rsizer)

        splitter.SplitVertically(self.leftpanel, rpanel, -150)

        self.leftpanel.SetMinSize((750, 150))
        rpanel.SetMinSize((150, -1))

        sizer = wx.BoxSizer(wx.VERTICAL)
        sizer.Add(splitter, 1, wx.GROW | wx.ALL, 0)
        pack(self, sizer)
        print ' start etimer2 for ', self.inst.name, time.ctime()
        self.etimer2.Start(1)