def __init__(self, poolName, mntgrpName, flagClear): self.db = Database() # # the pool for the Mg # try: self.poolMg = DeviceProxy(poolName) except Exception as e: Except.print_exception(e) print("failed to get proxy to ", poolName) sys.exit(255) # # find the MG # try: self.mg = DeviceProxy(mntgrpName) except Exception: lst = [mntgrpName, 'exp_t01', 'exp_c01', 'exp_c02'] self.poolMg.command_inout('CreateMeasurementGroup', lst) self.mg = DeviceProxy(mntgrpName) if not flagClear: self.hsh = json.loads(self.mg.Configuration) self.masterTimer = self.findMasterTimer() self.index = len(self.mg.ElementList) else: self.hsh = {} self.hsh[u'controllers'] = {} self.hsh[u'description'] = "Measurement Group" self.hsh[u'label'] = mntgrpName self.index = 0
def run(self, motor): show_ctrlaxis = self.getViewOption(ViewOption.ShowCtrlAxis) pos_format = self.getViewOption(ViewOption.PosFormat) name = motor.getName() motor_device = PyTango.DeviceProxy(name) try: high = motor_device.UnitLimitMax low = motor_device.UnitLimitMin pos = motor_device.Position self.output("") if show_ctrlaxis: axis_nb = getattr(motor, "axis") ctrl_name = self.getController(motor.controller).name ca_name = " (" + ctrl_name + "." + str(axis_nb) + ")" name = name + ca_name self.output(" %s " % name) self.output("") if pos_format != -1: fmt = '%c.%df' % ('%', pos_format) lowstr = fmt % low self.output("UnitLimitMin: %s " % lowstr) posstr = fmt % pos self.output("Current : %s " % posstr) highstr = fmt % high self.output("UnitLimitMax: %s " % highstr) else: self.output("UnitLimitMin: %f " % low) self.output("Current : %f " % pos) self.output("UnitLimitMax: %f " % high) except PyTango.DevFailed as e: Except.print_exception(e) self.warning("Not able to read motor position or limits")
def _addSca(self, device): """ Input: device: sca_exp_mca01_100_200 Returns full controller name, e.g.: haso107klx:10000/controller/hasscactrl/sca_exp_mca01_100_200 Creates a HasySca controller and creates a device for this controller, There is only one device per controller """ mca, roiMin, roiMax = self.parseSCA(device) # # find the tango device name which is used my the sardana device # tgMca = self._getMcaName(mca) # # sca_exp_mca01_100_200_ctrl # ctrlAlias = device + "_ctrl" # # see whether the controller exists already # lst = self.poolMg.ControllerList ctrlFullName = None for elm in lst: chan = json.loads(elm) if ctrlAlias == chan['name']: ctrlFullName = chan['full_name'] break # # if the controller does not exist, create it # proxy = DeviceProxy(tgMca) dataLength = proxy.DataLength if int(roiMax) >= dataLength: raise Exception( "MgUtils._addSca %s " % device, "roiMax %d >= datalength %d " % (int(roiMax), int(dataLength))) if int(roiMin) >= dataLength: raise Exception( "MgUtils._addSca %s " % device, "roiMin %d >= datalength %d " % (int(roiMin), dataLength)) if ctrlFullName is None: lst = [ 'CTExpChannel', 'HasyScaCtrl.py', 'HasyScaCtrl', ctrlAlias, "mca", tgMca, "roi1", roiMin, "roi2", roiMax ] print("MgUtils._addSca", lst) try: self.poolMg.CreateController(lst) except DevFailed as e: Except.print_exception(e) # print "failed to get proxy to ", poolName sys.exit(255) lst = self.poolMg.ControllerList for elm in lst: chan = json.loads(elm) if ctrlAlias == chan['name']: ctrlFullName = chan['full_name'] break if ctrlFullName is None: raise Exception('MgUtils._addSca', "failed to make controller for %s" % device) # # see whether the SCA device exists # lst = self.poolMg.ExpChannelList flag = False for elm in lst: chan = json.loads(elm) if device == chan['name']: flag = True break if not flag: # # "CTExpChannel","HasyScaCtrl","1","sca_exp_mca01_100_200" # lst = ["CTExpChannel", ctrlAlias, "1", device] self.poolMg.CreateElement(lst) return ctrlFullName