def __init__(self, subsystems, logger=None, version_file='ccs_versions.txt'): """ Constructor. Parameters ---------- subsystems : dict A dictionary of subsystem names keyed by desired attribute name, e.g., dict(ts8='ts8', pd='ts/PhotoDiode', mono='ts/Monochromator') logger : logging.Logger, optional Logger to be used by the SubsystemDecorator class. Default: None. version_file : str, optional Text file to contain the CCS subsystem version information. This can be set to None to suppress writing the file. Default: 'ccs_versions.txt'. """ self._proxy_subsystems = ccs_python_proxies.CCS.subsystem_names for key, value in subsystems.items(): if value in self._proxy_subsystems: proxy_subsystem = ccs_python_proxies.CCS.attachSubsystem(value) self.__dict__[key] = SubsystemDecorator(proxy_subsystem, logger=logger, name=value) continue self.__dict__[key] = SubsystemDecorator(CCS.attachSubsystem(value), logger=logger, name=value) self.version_file = version_file self._get_version_info(subsystems)
def _get_version_info(self, subsystems): # Version info is only available for "real" subsystems like # 'ts' or 'ts8-bench', not whatever things like # 'ts/Monochromator' are called in CCS parlance. So extract # the parts before the '/' as the "real" subsystem names of # interest real_subsystems = set([ x.split('/')[0] for x in subsystems.values() if x not in self._proxy_subsystems ]) self.subsystems = OrderedDict() for subsystem in real_subsystems: my_subsystem = CCS.attachSubsystem(subsystem) reply = my_subsystem.synchCommand(10, 'getDistributionInfo') try: result = reply.getResult().toString() self.subsystems[subsystem] = self._parse_version_info(result) except AttributeError: # Running in python for unit tests. pass
#!/usr/bin/env ccs-script from optparse import OptionParser from org.lsst.ccs.scripting import CCS from java.time import Duration import time # setup controls ts = CCS.attachSubsystem("ts8-motorplatform") bb = CCS.attachSubsystem("ts8-raft") reb0 = CCS.attachSubsystem("ts8-raft/R00.Reb0") tm = int(time.time()) # set output directory output_dir = "/gpfs/slac/lsst/fs3/g/data/jobHarness/jh_stage/LCA-11021_RTM/LCA-11021_RTM-004/mp_slit_intensitytester/%d/S${sensorLoc}/" % tm bb.sendSynchCommand("setDefaultImageDirectory", output_dir) print("The output directory has been set to - \n" + output_dir) Timeout = Duration.ofSeconds(300) CCS.setDefaultTimeout(Timeout) start = time.time() # reference values #xstart = 310.0 #ystart = 210.0 #xend = 440.0 #yend = 300.0
# # - Homer ############################################################################### from org.lsst.ccs.scripting import CCS from java.lang import Exception import sys import time CCS.setThrowExceptions(True) cdir = tsCWD rebsub = {} serial_number = {} ts8sub = CCS.attachSubsystem("%s" % ts8) tssub = CCS.attachSubsystem("ts") cryosub = CCS.attachSubsystem("ts/Cryo") pwrsub = CCS.attachSubsystem("ccs-rebps") pwrmainsub = CCS.attachSubsystem("ccs-rebps/MainCtrl") rebdevs = ts8sub.synchCommand(10, "getREBDevices").getResult() idx = 0 for id in rebdevs: rebsub[id] = CCS.attachSubsystem("%s/%s" % (ts8, id)) result = pwrsub.synchCommand(20, "setNamedPowerOn %d heater True" % idx).getResult() result = rebsub[id].synchCommand(10, "setHeaterPower 0 0.0").getResult() idx = idx + 1
raise Exception if (abs(cur_ps)>0.0 and chkreb) : if (abs(cur_reb-cur_ps)/cur_ps > 0.20) : pwrsub.synchCommand(10,"setNamedPowerOn %d %s False" % (rebid,pwr)) stat = "Current %s with value %f differs by > 10%% to current from reb channel %s with value %f. POWER TO THIS CHANNEL HAS BEEN SHUT OFF!" % (pwr_chan,cur_ps,reb_chan,cur_reb) raise Exception(stat) print stat return if (True): #attach CCS subsystem Devices for scripting ts8sub = CCS.attachSubsystem("ts8"); pwrsub = CCS.attachSubsystem("ccs-rebps"); pwrmainsub = CCS.attachSubsystem("ccs-rebps/MainCtrl"); status_value = None result = pwrsub.synchCommand(10,"getChannelNames"); channames = result.getResult() # print channames rebids = ts8sub.synchCommand(10,"getREBIds").getResult() for i in rebids : # print "Checking if REBID=%d is present" % i # present = False
CCS.setThrowExceptions(True) doPD = False runnum = "no-eTrav" try: runnum = RUNNUM #tsCWD.split('/')[len(tsCWD.split('/'))-4] except: pass print "Run number = %s" % runnum if (True): #attach CCS subsystem Devices for scripting print "Attaching teststand subsystems" tssub = CCS.attachSubsystem("%s" % ts) print "attaching Bias subsystem" biassub = CCS.attachSubsystem("%s/Bias" % ts) print "attaching PD subsystem" pdsub = CCS.attachSubsystem("%s/PhotoDiode" % ts) print "attaching Mono subsystem" monosub = CCS.attachSubsystem("%s/Monochromator" % ts) # print "attaching PDU subsystem" # pdusub = CCS.attachSubsystem("%s/PDU" % ts ); print "Attaching ts8 subsystem" ts8sub = CCS.attachSubsystem("ts8") time.sleep(3.) ts8sub.synchCommand(10, "setRunNumber", runnum)
try: cdir = tsCWD unit = CCDID # sys.stdout = open("%s/rebalive_results.txt" % cdir, "w") sys.stdout = Logger() print "Running as a job harness. Results are being recorded in rebalive_results.txt" except: print "Running standalone. Statements will be sent to standard output." print "start tstamp: %f" % time.time() if not dorun: print "setup for repair ... not running" else: #attach CCS subsystem Devices for scripting ts8sub = CCS.attachSubsystem("%s" % ts8) pwrsub = CCS.attachSubsystem("ccs-rebps") pwrmainsub = CCS.attachSubsystem("ccs-rebps/MainCtrl") status_value = True result = pwrsub.synchCommand(10, "getChannelNames") channames = result.getResult() # print channames rebnames = ts8sub.synchCommand(10, "getREBDeviceNames").getResult() idmap = [] print "length = %d" % len(sys.argv)
#!/usr/bin/env ccs-script from optparse import OptionParser from org.lsst.ccs.scripting import CCS from java.time import Duration import time # setup controls ts = CCS.attachSubsystem("ts8-motorplatform") bb = CCS.attachSubsystem("ts8-raft") tm = int(time.time()) # set output directory output_dir = "/gpfs/slac/lsst/fs3/g/data/jobHarness/jh_stage/LCA-11021_RTM/LCA-11021_RTM-004/mp_laser_streak/%d/S${sensorLoc}/" % tm bb.sendSynchCommand("setDefaultImageDirectory",output_dir) print("The output directory has been set to - \n"+output_dir) Timeout = Duration.ofSeconds(300) CCS.setDefaultTimeout(Timeout) start = time.time() iset = 1 if iset==0 : xstart1 = 310.0
#!/usr/bin/env ccs-script import os import time #import config import sys #sys.path.insert(0,"/home/homer/scripts/") from pd import PhotodiodeReadout #from org.lsst.ccs.utilities.location import LocationSet #import jarray from java.lang import String from org.lsst.ccs.scripting import CCS #from ccs import aliases #from ccs import proxies from java.time import Duration #bb = CCS.attachProxy("ts8-bench") bb = CCS.attachSubsystem("ts8-bench") reb0 = CCS.attachSubsystem("ts8-fp/R22/Reb0") def test_pd(exposure): pd_readout = PhotodiodeReadout(exposure) pd_readout.start_accumulation() time.sleep(2.5) print("starting exposure") reb0.sendSynchCommand("setRegister 0x100000 [0x103bc]") # light time.sleep(exposure) reb0.sendSynchCommand("setRegister 0x100000 [0x3bc]") # light print("exposure complete")
# ############################################################################### from org.lsst.ccs.scripting import CCS from java.lang import Exception import sys import time import eolib CCS.setThrowExceptions(True) #try: if True: #attach CCS subsystem Devices for scripting print "Attaching teststand subsystems" tssub = CCS.attachSubsystem("%s" % ts) arcsub = CCS.attachSubsystem("archon") print "attaching Bias subsystem" biassub = CCS.attachSubsystem("%s/Bias" % ts) print "attaching PD subsystem" pdsub = CCS.attachSubsystem("%s/PhotoDiode" % ts) print "attaching Mono subsystem" monosub = CCS.attachSubsystem("%s/Monochromator" % ts) print "attaching PDU subsystem" pdusub = CCS.attachSubsystem("%s/PDU" % ts) print "Attaching archon subsystem" # arcsub = CCS.attachSubsystem("%s" % archon); # print "attaching XED subsystem" # xedsub = CCS.attachSubsystem("%s/Fe55" % ts); # retract the Fe55 arm
# test the test stand for readiness # ############################################################################### from org.lsst.ccs.scripting import CCS from java.lang import Exception import sys import time import eolib CCS.setThrowExceptions(True); #attach CCS subsystem Devices for scripting print "Attaching teststand subsystems" tssub = CCS.attachSubsystem("%s" % ts); print "attaching PD subsystem" pdsub = CCS.attachSubsystem("%s/PhotoDiode" % ts); print "attaching Mono subsystem" monosub = CCS.attachSubsystem("%s/Monochromator" % ts ); print "attaching PDU subsystem" pdusub = CCS.attachSubsystem("%s/PDU" % ts ); print "Attaching teststand 8 subsystem" ts8sub = None rebpssub = None usets8 = True try: ts8sub = CCS.attachSubsystem("%s" % ts8); rebpssub = CCS.attachSubsystem("ccs-rebps"); except:
def __init__(self, subsystemName, replyHandler): self._subsysName = subsystemName self._subsysHandle = CCS.attachSubsystem(subsystemName) CCS.addStatusBusListener(replyHandler, replyHandler.getMessageFilter())
def attachProxy(key, level=0): return ccsProxy(CCS.attachSubsystem(key, level), key)
ndFilter = False colorFilter = True spot = False shutter = True fe55Shutter = False cb = None ts8mono = None try: cb = CCS.attachProxy("comcam-bench") except: print("No comcam-bench yet!") pass try: ts8mono = CCS.attachSubsystem("ts8-bench/Monochromator") except: print("No comcam-bench yet!") pass def sanityCheck(): state = cb.getState() alert = state.getState(AlertState) if alert != AlertState.NOMINAL: print "WARNING: bot_bench subsystem is in alert state %s" % alert def setNDFilter(filter): if not ndFilter: return
############################################################################### from org.lsst.ccs.scripting import CCS from java.lang import Exception import sys import time import eolib CCS.setThrowExceptions(True); cdir = tsCWD rebsub = {} serial_number = {} tssub = CCS.attachSubsystem("ts"); monosub = CCS.attachSubsystem("%s/Monochromator" % ts ); ts8sub = CCS.attachSubsystem("%s" % ts8); cryosub = CCS.attachSubsystem("ts/Cryo"); pwrsub = CCS.attachSubsystem("ccs-rebps"); pwrmainsub = CCS.attachSubsystem("ccs-rebps/MainCtrl"); rebdevs = ts8sub.synchCommand(10,"getREBDevices").getResult() # set new state istate = tssub.synchCommand(10,"getstate").getResult() print "istate before = ",istate," : " ext = int(jobname.split("__")[1]) if ext>400 : ext= ext - 400 istate = (istate & 0xffffff) | (ext << 24) print "istate after = ",istate
#!/usr/bin/env ccs-script from optparse import OptionParser from org.lsst.ccs.scripting import CCS from java.time import Duration import time # setup controls ts = CCS.attachSubsystem("metrology/Positioner") bb = CCS.attachSubsystem("ts8-raft") tm = int(time.time()) # set output directory output_dir = "/gpfs/slac/lsst/fs3/g/data/jobHarness/jh_stage/LCA-11021_RTM/LCA-11021_RTM-016/post_streakTest1_chk/%d/S${sensorLoc}/" % tm bb.sendSynchCommand("setDefaultImageDirectory", output_dir) print("The output directory has been set to - \n" + output_dir) Timeout = Duration.ofSeconds(600) CCS.setDefaultTimeout(Timeout) start = time.time() # starting point xstart = 65.0 ystart = -72.6 x = xstart y = ystart # step increments
def attachProxy(key): return ccsProxy(CCS.attachSubsystem(key), key)
#!/usr/bin/env ccs-script from optparse import OptionParser from org.lsst.ccs.scripting import CCS #from ccs import aliases import time #from ccs import proxies #fp = CCS.attachProxy("ts7-2/Cryo") ts = CCS.attachSubsystem("ts7-2/Cryo") start = time.time() while (True): print "%f %11.3f %11.3f %11.3f %11.3f %11.3f" % ( time.time(), (time.time() - start), ts.sendSynchCommand("getTemp A"), ts.sendSynchCommand("getTemp B"), ts.sendSynchCommand("getTemp C"), ts.sendSynchCommand("getTemp D")) time.sleep(5.0)