Beispiel #1
0
 def init_device(self):
     if not hasattr(self,'LogLevel'): self.LogLevel = 'DEBUG'
     self.init_my_Logger()
     
     self.state_error,self.init_error,self.event_status='','',''
     self.Cache = fandango.CaselessDict() #A cache is needed to avoid timeouts affecting always_hook and read_attributes
     self.Errors = fandango.CaselessDict()
     self.state_reason = 'Device not initialized'      
     self.last_event_received = 0
     self.ChannelStatus = ''
     self.ChannelName = ''
     self.Channel = ''
     
     #Do not move this lines!, order matters
     self.info( "In "+self.get_name()+"::init_device()" )
     self.set_state(PyTango.DevState.INIT)
     self.get_device_properties(self.get_device_class())
Beispiel #2
0
 def subscribe(self, key, callback):
     """
     Callbacks could be a tuple of (reg0, reg1, reg2, callable)
     If just a callable is passed, then it is executed for any register
     The callable must an evalAttr alike method, 
     accepting (aname,WRITE,VALUE,_locals,push) arguments
     """
     if self.callbacks is None:
         self.callbacks = fandango.CaselessDict()
     if key not in self.callbacks:
         self.callbacks[key] = callback
    def clearBuffers(self, *args):
        self.warning('ArchivedTrendLogger.clearBuffers(%s)' % str(args))
        self.last_args = fn.CaselessDict()
        self.reader.reset()

        for rd in self.reader.configs.values():
            try:
                rd.reset()
                rd.cache.clear()
                rd.last_dates.clear()
            except:
                self.debug('unable to clear %s buffers' % rd)

        for n, ts in self.trend.trendSets.iteritems():
            ts.clearTrends(replot=True)
            #self._xBuffer.moveLeft(self._xBuffer.maxSize())
            #self._yBuffer.moveLeft(self._yBuffer.maxSize())
            ts.forceReading()

        return
Beispiel #4
0
 def __init__(self, cl, name):
     PyTango.Device_4Impl.__init__(self, cl, name)
     self.AttrData, self.reader = fandango.CaselessDict(
     ), None  #Created here to be init() proof
     PyExtractor.init_device(self)
    def setup(self,
              trend,
              use_db=True,
              db_config='',
              tango_host='',
              logger_obj=None,
              multiprocess=USE_MULTIPROCESS,
              schema='',
              show_dialog=False,
              filters=['*', '!DEBUG'],
              force_period=10000,
              value_setter=None):
        #trend widget,attribute,start_date,stop_date,use_db,db_config,tango_host,logger_obj,multiprocess,schema=''):
        print('>' * 80)

        from PyTangoArchiving.reader import Reader, ReaderProcess
        self.tango_host = tango_host
        self.trend = trend
        self.value_setter = value_setter
        self.model_trend_sets = defaultdict(list)
        self.last_check = (0, 0)  #Trend stores here the last bounds
        self.last_check_buffers = 0
        self.logger = logger_obj or trend
        self.log_objs = {}
        self.last_args = fn.CaselessDict()  #{}
        self.last_bounds = (0, 0, 0)  ##NOT USED
        self.on_check_scales = False
        self.last_msg = ''
        self.loglevel = 'INFO'

        self.recount = 0

        self.schema = schema or (use_db and '*') or 'hdb'
        print('In ArchivedTrendLogger.setup(%s,%s)' % (trend, self.schema))
        self.filters = filters
        self._dialog = None
        self.show_dialog(show_dialog)  #The dialog is initialized here
        self.reader = (ReaderProcess if multiprocess else Reader)(
            schema=self.schema,
            config=db_config,
            tango_host=tango_host,
            logger=self)
        try:
            axis = self.trend.axisWidget(self.trend.xBottom)
            #self.trend.connect(axis,Qt.SIGNAL("scaleDivChanged ()"),
            #  lambda s=self:s.dialog()._checked or s.show_dialog())
            ## a new axis change will show archiving dialog
            self.trend.connect(axis, Qt.SIGNAL("scaleDivChanged ()"),
                               self.checkScales)
            self.trend.connect(self.trend, Qt.SIGNAL("refreshData"),
                               self.refreshCurves)

            #self.trend.connect(self.trend._useArchivingAction,Qt.SIGNAL("toggled(bool)"), self.show_dialog)

            MenuActionAppender.ACTIONS.extend(
                getattr(self.trend, 'MENU_ACTIONS', []))
            MenuActionAppender.ACTIONS = list(set(MenuActionAppender.ACTIONS))
            if True:
                TaurusTrend._canvasContextMenu = MenuActionAppender()(
                    TaurusTrend._canvasContextMenu)
            else:
                self.trend._canvasContextMenu = MenuActionAppender()(
                    self.trend._canvasContextMenu)
        except:
            self.warning(traceback.format_exc())
Beispiel #6
0
Commands = fandango.CaselessDict({
    'HV1_ON': 11,
    'HV2_ON': 12,
    'HV3_ON': 13,
    'HV4_ON': 14,
    'Status': 205,
    'ErrorCode': 206,
    'Model': 319,
    'ModeLocal': 8,
    'SerialNumber': 323,
    'SerialType': 504,
    'Channel': 505,
    'Units': 600,
    'Mode': 601,
    'Protect': 602,
    'FixedStep': 603,
    'Dev1': 610,
    'Power1': 612,
    'Vt1': 613,
    'IProt1': 614,
    'SP1': 615,
    'Dev2': 620,
    'Power2': 622,
    'Vt2': 623,
    'IProt2': 624,
    'SP2': 625,
    'Dev3': 630,
    'Power3': 632,
    'Vt3': 633,
    'IProt3': 634,
    'SP3': 635,
    'Dev4': 640,
    'Power4': 642,
    'Vt4': 643,
    'IProt4': 644,
    'SP4': 645,
    'Temp1': 801,
    'Temp2': 802,
    'Temp3': 808,
    'Temp4': 809,
    'Ilock': 803,
    'StatusSP': 804,
    'V1': 810,
    'I1': 811,
    'P1': 812,
    'V2': 820,
    'I2': 821,
    'P2': 822,
    'V3': 830,
    'I3': 831,
    'P3': 832,
    'V4': 840,
    'I4': 841,
    'P4': 842,
})
Beispiel #7
0
import fandango as fn, fandango.callbacks as fc

attrs = map(str.lower, fn.get_matching_attributes('bl00*eps*plc*01/*'))

a = 'bl00/ct/eps-plc-01/State'

t0 = fn.now()
sources = dict(
    (d, fc.EventSource(d, asynchronous=True)) for d in sorted(attrs))

#sources.values()[10].read(synch=True)

cache = fn.CaselessDict()


def hook(src, t, value):
    cache[src.normal_name] = (value)


el = fc.EventListener('A Queue for All')
el.set_value_hook(hook)
print('Subscribing %d attributes' % len(attrs))
[s.addListener(el) for k, s in sorted(sources.items())]
print('Subscription took %f seconds' % (fn.now() - t0))

t0 = fn.now()
print('Waiting ...')
while len(cache) < len(attrs):
    if fn.now() > t0 + 18.:
        break
    fn.wait(1.)