Пример #1
0
    def SetPV(self, pv=None):
        "set pv, either an epics.PV object or a pvname"
        if isinstance(pv, epics.PV):
            self.pv = pv
        elif isinstance(pv, (str, unicode)):
            self.pv = epics.PV(pv)
        if self.pv is None:
            return
        self.pv.connection_callbacks.append(self.OnEpicsConnect)
        self.pv.get()
        self.pv.get_ctrlvars()
        # be sure to set precision before value!! or PV may be moved!!
        prec = self.pv.precision
        if prec is None:
            prec = 0
        self.SetPrecision(prec)

        self.SetValue(self.pv.char_value, act=False)

        if self.pv.type in ('string', 'char'):
            self._warn('pvFloatCtrl needs a double or float PV')

        llim = set_float(self.pv.lower_ctrl_limit)
        hlim = set_float(self.pv.upper_ctrl_limit)
        if hlim is not None and llim is not None and hlim > llim:
            self.SetMax(hlim)
            self.SetMin(llim)
        self.pv.add_callback(self._FloatpvEvent, wid=self.GetId())
        self.SetAction(self._onEnter)
Пример #2
0
    def SetPV(self, pv=None):
        "set pv, either an epics.PV object or a pvname"
        if isinstance(pv, epics.PV):
            self.pv = pv
        elif isinstance(pv, (str, unicode)):
            self.pv = epics.get_pv(pv)
        if self.pv is None:
            return
        self.pv.connection_callbacks.append(self.OnEpicsConnect)
        self.pv.get()
        self.pv.get_ctrlvars()
        # be sure to set precision before value!! or PV may be moved!!
        prec = self.pv.precision
        if prec is None:
            prec = 0
        self.SetPrecision(prec)

        self.SetValue(self.pv.char_value, act=False)

        if self.pv.type in ('string', 'char'):
            try:
                x = float(self.pv.value)
            except:
                self._warn('pvFloatCtrl needs a double or float PV')

        llim = set_float(self.pv.lower_ctrl_limit)
        hlim = set_float(self.pv.upper_ctrl_limit)
        if hlim is not None and llim is not None and hlim > llim:
            self.SetMax(hlim)
            self.SetMin(llim)
        ncback = len(self.pv.callbacks) + 1
        self.pv.add_callback(self._pvEvent, wid=self.GetId(), cb_info=ncback)
        self.SetAction(self._onEnter)
Пример #3
0
 def _pvEvent(self, pvname=None, value=None, wid=None,
              char_value=None, **kws):
     "epics PV callback function"
     if pvname is None or value is None or wid is None:
         return
     if char_value is None and value is not None:
         prec = kws.get('precision', None)
         if prec not in (None, 0):
             char_value = ("%%.%if" % prec) % value
         else:
             char_value = set_float(value)
     self.OnPVChange(char_value)
Пример #4
0
 def _pvEvent(self, pvname=None, value=None, wid=None,
              char_value=None, **kws):
     "epics PV callback function"
     if pvname is None or value is None or wid is None:
         return
     if char_value is None and value is not None:
         prec = kws.get('precision', None)
         if prec not in (None, 0):
             char_value = ("%%.%if" % prec) % value
         else:
             char_value = set_float(value)
     self.OnPVChange(char_value)
Пример #5
0
    def _FloatpvEvent(self, pvname=None, value=None, wid=None,
                      char_value=None, **kw):
        "PV callback / event handler for pv change"

        if pvname is None or value is None or wid is None:
            return
        if char_value is None and value is not None:
            prec = kw.get('precision', None)
            if prec not in (None, 0):
                char_value = ("%%.%if" % prec) % value
            else:
                char_value = set_float(value)
        self.SetValue(char_value, act=False)
Пример #6
0
    def _FloatpvEvent(self, pvname=None, value=None, wid=None,
                      char_value=None, **kw):
        "PV callback / event handler for pv change"

        if pvname is None or value is None or wid is None:
            return
        if char_value is None and value is not None:
            prec = kw.get('precision', None)
            if prec not in (None, 0):
                char_value = ("%%.%if" % prec) % value
            else:
                char_value = set_float(value)

        self.SetValue(char_value, act=False)