def connect_to_hardware(self, *args): """ Connect to WBDC and FrontEnd hardware servers. Returns: None """ # WBDC server self.wbdc = get_device_server('wbdc2hw_server-dss43wbdc2', pyro_ns="crux") # FE server self.FE = get_device_server('FE_server-krx43', pyro_ns="crux") self.logger.debug("Successfully got Pyro3 objects") self._simulated = False
def __init__(self, name, inputs=None, output_names=[], active=True): """ In most Device types, the first argument is the device providing the signal source. In the case of a Switch it is the instance which "owns" the switch, which may be an observatory or a telescope. Use the attribute 'sources' to see where the signal comes from. @param observatory : argument to pass to Switch() as the parent @type observatory : Observatory() instance @param swID : logical switch in the matrix, keyed to output port @type swID : int """ mylogger = logging.getLogger(module_logger.name + ".MS287") self.name = name # needed by the next statement mylogger.debug(" initializing %s", self) show_port_sources(inputs, " Inputs to MS287:", mylogger.level) Device.__init__(self, name, inputs=inputs, output_names=output_names, active=active) self.logger = mylogger show_port_sources(inputs, " MS287 inputs redefined:", mylogger.level) self.name = name self.hw = get_device_server("MS287server") self.channel = {} for name in output_names: self.channel[name] = self.Channel(self, name, inputs=self.inputs, output_names=[name], active=active) self.logger.debug(" %s outputs: %s", self.name, self.outputs)
def __init__(self, parent=None): """ Create an instance main GUI This is a minimal class because the appearance and actions of the actual GUI are defined by the ActionConfiguration class instance @param parent : needed by QMainWindow but typically None @type parent : QWidget() instance """ self.logger = logging.getLogger(module_logger.name+".MainWindow") self.logger.debug(" initializing") QtGui.QMainWindow.__init__(self, parent) self.logger = mylogger self.logger.debug(" superclasses initialized") self.wbdc = get_device_server('wbdc2hw_server-mmfranco-0571605') # When using a slow connection, the above can take a while time.sleep(1) self.power_scale = 'mW' self.power = {'R1 E': 0.0, 'R1 H': 0.0, 'R2 E':0.0, 'R2 H':0.0} self.create_menubar() self.logger.debug("menubar created") self.central_frame = self.CentralFrame(self) self.logger.debug("central_frame: created") self.setCentralWidget(self.central_frame) self.create_status_bar() self.timer = QtCore.QTimer()
""" from calibrate_PINs import * import logging import numpy as NP import time from support.pyro import get_device_server if __name__ == "__main__": logging.basicConfig(level=logging.WARNING) mylogger = logging.getLogger() mylogger.setLevel(logging.INFO) fe = get_device_server("FE_server-krx43", "crux") print "Feed 1:",fe.set_WBDC(13) # set feed 1 to sky print "Feed 2:",fe.set_WBDC(15) # set feed 2 to sky #print fe.set_WBDC(14) # set feed 1 to load #print fe.set_WBDC(16) # set feed 2 to load for pm in ['PM1', 'PM2', 'PM3', 'PM4']: # set PMs to dBm print fe.set_WBDC(400+int(pm[-1])) rx = get_device_server("wbdc2hw_server-dss43wbdc2", "crux") crossed = rx.get_Xswitch_state() if crossed: mylogger.warning(" cross-switch in set") polsec_keys = rx.request("self.pol_sec.keys()") polsec_keys.sort() attenuator_keys = {}
grid() xlabel('Control Volts (V)') ylabel('Insertion Loss Gradient (dB/V)') title('Attenuation interpolation') legend(loc='lower left') if __name__ == "__main__": from socket import gethostname logging.basicConfig(level=logging.WARNING) mylogger = logging.getLogger() mylogger.setLevel(logging.INFO) if gethostname() == 'dss43wbdc2': ## Needed when data are to be acquired fe = get_device_server("FE_server-krx43", "crux") print "Feed 1 load is:", fe.set_WBDC(13) # set feed 1 to sky print "Feed 2 load is:", fe.set_WBDC(15) # set feed 2 to sky #print fe.set_WBDC(14) # set feed 1 to load #print fe.set_WBDC(16) # set feed 2 to load for pm in ['PM1', 'PM2', 'PM3', 'PM4']: # set PMs to dBm print fe.set_WBDC(400 + int(pm[-1])) if gethostname() == 'dss43wbdc2': # get data with direct WBDC control rx = WBDC2hwif('WBDC2') crossed = rx.get_Xswitch_state() if crossed: mylogger.warning(" cross-switch in set") pol_secs = {'R1-22': rx.pol_sec['R1-22'], 'R2-22': rx.pol_sec['R2-22']}
def __init__(self, name, inputs=None, output_names=None, active=True, hardware=None): """ Initialize a WBDC2 object. @param name : unique identifier @type name : str @param inputs : a dict with sources for different inputs @type inputs : dict of str:str @param output_names : names of the output channels/ports @type output_names : list of str @param active : True is the FrontEnd instance is functional @type active : bool @param hardware : True if this client connects to the hardware server @type hardware : dict keyed with generic hardware names """ self.name = name if hardware: from support.pyro import get_device_server, pyro_server_request self.hardware = get_device_server("wbdc2hw_server-dss43wbdc2", pyro_ns="crux") self.atten_keys = pyro_server_request(self.hardware.get_atten_IDs) else: self.hardware = None mylogger = logging.getLogger(logger.name + ".WBDC2") mylogger.debug("__init__: for %s", self) show_port_sources(inputs, "WBDC2.__init__: inputs before WBDC_base init:", mylogger.level) if hardware: uri = Pyro5.api.URI("PYRO:Spec@localhost:50003") self.hardware = Pyro5.api.Proxy(uri) try: self.hardware.__get_state__() except Pyro5.errors.CommunicationError as details: mylogger.error("__init__: %s", details) raise Pyro5.errors.CommunicationError( "is the SAO spec server running?") except AttributeError: # no __get_state__ because we have a connection pass else: # use the simulator self.hardware = None WBDC_base.__init__(self, name, active=active, inputs=inputs, output_names=output_names) if inputs is not None: show_port_sources(self.inputs, "WBDC2.__init__: inputs after WBDC_base init:", mylogger.level) show_port_sources(self.outputs, "WBDC2.__init__: outputs after WBDC_base init:", mylogger.level) self.logger = mylogger self.data['bandwidth'] = 1e10 # Hz # The transfer switch is created in WBDC_base if self.hardware: self.crossSwitch.get_state() else: self.crossSwitch.set_state(False) # the four transfer switch outputs (2 feeds, 2 pols) are RF section inputs rfs = list(self.crossSwitch.outputs.keys()) rfs.sort() self.logger.debug("__init__: transfer switch outputs: %s", rfs) self.rf_section = {} for rf in rfs: index = rfs.index(rf) rf_inputs = {} outnames = [] rf_inputs[rf] = self.crossSwitch.outputs[rf] self.logger.debug(" __init__: RF %s inputs is now %s", rf, rf_inputs) for band in WBDC2.bands: outnames.append(rf + band) self.rf_section[rf] = self.RFsection(self, rf, inputs=rf_inputs, output_names=outnames) self.logger.debug(" __init__: RF %s outputs is now %s\n", rf, self.rf_section[rf].outputs) # Outputs from two RFsections for each feed and band feed a pol section self.pol_sec = {} for band in WBDC2.bands: for rx in WBDC_base.RF_names: psec_inputs = {} psec_name = rx + '-' + band for pol in WBDC_base.pol_names: psec_inputs[pol] = self.rf_section[rx + pol].outputs[rx + pol + band] self.logger.debug(" __init__: PolSection %s inputs is now %s", psec_name, psec_inputs) self.pol_sec[psec_name] = self.PolSection(self, psec_name, inputs=psec_inputs) self.pol_sec[psec_name].data['band'] = band self.pol_sec[psec_name].data['receiver'] = rx self.pol_sec[psec_name]._get_state() self.logger.debug(" __init__: pol section %s outputs: %s", self.pol_sec[psec_name].name, list(self.pol_sec[psec_name].outputs.keys())) pol_sec_names = list(self.pol_sec.keys()) pol_sec_names.sort() self.logger.debug(" __init__: pol sections: %s\n", pol_sec_names) # Each pol section has two outputs, each going to a down-converter # Each down-converter has two IF outputs self.DC = {} for name in pol_sec_names: for pol in WBDC_base.out_pols: self.logger.debug("__init__: making DC for %s", name + pol) self.logger.debug("__init__: creating inputs for %s", name + pol) dc_inputs = { name + pol: self.pol_sec[name].outputs[name + pol] } self.DC[name + pol] = self.DownConv(self, name + pol, inputs=dc_inputs) rx, band = name.split('-') self.DC[name + pol].data['receiver'] = rx self.DC[name + pol].data['band'] = band self.DC[name + pol].data['pol'] = pol self.DC[name + pol]._get_state() self.logger.debug("__init__: DC %s created", self.DC[name + pol]) self._update_signals() # invokes WBDC_base._update_signals() # debug outputs self.logger.debug("__init__: %s outputs: %s", self, str(self.outputs)) self.analog_monitor = self.AnalogMonitor(self) self.logger.debug(" initialized for %s", self.name)
fe = FE() ...initialize power meters cal_data = minical_data(fe, pms) gains, Tlinear, Tquadratic, Tnd, NonLin = process_minical(cal_data) """ import logging from MonitorControl.FrontEnds.minical.get_minical import minical_data from MonitorControl.FrontEnds.minical.process_minical import process_minical from support.pyro import get_device_server logger = logging.getLogger(__name__) # the following classes enable the use legacy code in get_minical and process_minical K2 = get_device_server("K2_Server-crux", pyro_ns="crux") class FE(object): def __init(): self.logger = logging.getLogger(module_logger.name + ".FE") def set_feed(feed, code): if feed == 1: if code == sky: K2.set_WBDC(13) elif code == load: K2.set_WBDC(14) else: self.logger.error("set_feed: bad code %d", code) elif feed == 2: