Example #1
0
class LEDAClient(object):
	def __init__(self, host, port, log):
		self.host = host
		self.port = port
		self.log  = log
		#self.connect()
	def connect(self, timeout=10):
		self.log.write("Connecting to remote server %s:%i" \
			               % (self.host,self.port))
		self.sock = SimpleSocket(timeout=timeout)
		try:
			self.sock.connect(self.host, self.port)
		except SimpleSocket.timeout_error:
			self.log.write("All connections were refused", -2)
			self.sock = None
		except:
			self.log.write("Failed to connect. "+str(sys.exc_info()[1]), -2)
			self.sock = None
		else:
			self.log.write("Connection successful")
	def isConnected(self):
		return self.sock is not None
	def _sendmsg(self, msg, timeout="default"):
		if self.sock is None:
			self.log.write("send: Not connected (%s:%i)" % (self.host,self.port), -2)
			return None
		if len(msg) <= 256:
			self.log.write("Sending message "+msg, 4)
		else:
			self.log.write("Sending long message of length %i bytes"%(len(msg)), 4)
		try:
			self.sock.send(msg)
			ret = self.sock.receive(timeout=timeout)
		except:
			self.log.write("recv: Not connected (%s:%i)" % (self.host,self.port), -2)
			self.sock = None
			return None
		if len(ret) < 256:
			self.log.write("Received response "+ret, 4)
		else:
			self.log.write("Received long response of length %i bytes"%(len(ret)), 4)
		return ret
	def _sendcmd(self, cmd):
		ret = self._sendmsg(cmd)
		if ret is None:
			return None
		if ret == 'ok':
			return True
		else:
			self.log.write("Remote command failed", -2)
			raise Exception("Remote command failed")
Example #2
0
sectorname = opts.sectorname
gain = opts.gain

#try:
#   sectorname=sys.argv[1]
#except:
#   sectorname=''
   #print "usage: aohrms.py <sector>"
   #sys.exit(1)  

s=SECTOR(sectorname,fed,17,ccu,pxfec,caen)
print "Sector   ",sectorname
print "FED slot ",s.fedslot

ccu.send("sector "+sectorname).readlines()

#ccu.send("cratereset").readlines()

for l in ccu.send("scanccu").readlines():
   print l

## for l in ccu.send("which fec").readlines():
##    print l

## for l in ccu.send("which ring").readlines():
##    print l

## for l in ccu.send("which ccu").readlines():
##    print l 
Example #3
0
from SimpleSocket import SimpleSocket
import ROOT
from ROOT import *

########################################################

# connect
print "connecting to pxfec,",
pxfec = SimpleSocket('localhost', 2000)
print " done"

print "connecting to digfed,",
digfed = SimpleSocket('localhost', 2006)
print " done"

digfed.send("initFitelS").readlines()
digfed.send("piggyS").readlines()
digfed.send("fiber 3").readlines()

pxfec.send("module 28")
pxfec.send("tbm tbmadelay 93")
pxfec.send("tbm tbmbdelay 93")
pxfec.send("tbm tbmplldelay 208")
time.sleep(0.1)
pxfec.send("roc 0:15")
pxfec.send("mask")
#pxfec.send("roc 3")
#pxfec.send("arm 10 10")
#pxfec.send("roc 6")
#pxfec.send("arm 10 10")
#pxfec.send("roc 0:15")
Example #4
0
########################################################


# connect
print "connecting to pxfec,",
pxfec=SimpleSocket( 'localhost', 2015)
print " done"

print "connecting to ccu,",
ccu=SimpleSocket( 'localhost', 2005)
print " done"

print "connecting to digitalfed,",
digfed=SimpleSocket( 'localhost', 2060)
print " done"
pxfec.send("roc 0:15").readlines()
pxfec.send("trim 0").readlines()
pxfec.send("mask").readlines()


for roc in range(0, 16, 1):
  pxfec.send("mask").readlines()
  pxfec.send("roc {0:d}".format(roc)).readlines()
  pxfec.send("unmask").readlines()

  for caldel in range(40, 200, 20):
    pxfec.send("CalDel {0:d}".format(caldel)).readlines()
    print "roc: ", roc, "\tcaldel: ", caldel, "\n"

    for i in digfed.send("testcal 100").readlines():
      print i
Example #5
0
sockdir = "/home/cmspixel/TriDAS/pixel/BPixelTools/tools/python"
if not sockdir in sys.path: sys.path.append(sockdir)
from SimpleSocket import SimpleSocket

########################################################

# connect
print "connecting to pxfec,",
pxfec = SimpleSocket('localhost', 2000)
print " done"

print "connecting to digfed,",
digfed = SimpleSocket('localhost', 2006)
print " done"

digfed.send("initFitelS").readlines()
digfed.send("piggyS").readlines()
digfed.send("fiber 1").readlines()

pxfec.send("module 28")
#pxfec.send("tbm tbmadelay 101")
#pxfec.send("tbm tbmbdelay 101")
#pxfec.send("tbm tbmplldelay 252")
time.sleep(0.1)
pxfec.send("roc 0:15")
pxfec.send("ReadBack 12")
pxfec.send("Vana 100")
#pxfec.send("mask")
#pxfec.send("roc 3")
#pxfec.send("arm 10 10")
#pxfec.send("roc 6")
Example #6
0
group2=GROUP(fed, ccu, pxfec, caen, name + 'L34', 0x13,log)
group.append(group1)
group.append(group2)
########################################################
# in real life we have this layout:
# sector.pohlist= range(1,9)+ range(14,15)
sector.pohlist= range(2,3)+range(5,7)
sector.poh[2].fedchannels=[None,5,6,7,8]
sector.poh[5].fedchannels=[None,1,2,3,4]
sector.poh[6].fedchannels=[None,9,10,11,12]
########################################################
# fed channel to bundle to poh map is stored in:
# pohfile=open('pohfiber.txt', 'r')
 

ccu.send("sector " + str(sector.name)).readlines()
ccu.send("reset").readlines()
ccu.send("piareset all").readlines()

###############################################################################
ccu.send("power all").readlines()
ccu.send("reset").readlines()

print "setting poh bias and gain"

   

print ccu.send("group " + sector.poh[2].group).readlines()
    #ccu.send("reset").readlines()
    
    #print sector.poh[k].name +" setall 3 3 3 3 40 40 40 40"
Example #7
0
sectorname = opts.sectorname
gain = opts.gain

#try:
#   sectorname=sys.argv[1]
#except:
#   sectorname=''
#print "usage: aohrms.py <sector>"
#sys.exit(1)

s = SECTOR(sectorname, fed, 17, ccu, pxfec, caen)
print "Sector   ", sectorname
print "FED slot ", s.fedslot

ccu.send("sector " + sectorname).readlines()

#ccu.send("cratereset").readlines()

for l in ccu.send("scanccu").readlines():
    print l

## for l in ccu.send("which fec").readlines():
##    print l

## for l in ccu.send("which ring").readlines():
##    print l

## for l in ccu.send("which ccu").readlines():
##    print l
Example #8
0
print "connecting to pxfec,",
pxfec=SimpleSocket( 'localhost', 2000)
print " done"
print "connecting to digital fed,",
digfed=SimpleSocket( 'localhost', dfedport)
print " done"
log=Logger()

# choose an arbitray sector in that shell and get ring and slot from the server
#s=SECTOR("-6P",fed,17,ccu,pxfec,caen)
s=GROUP(fed, ccu, pxfec, caen, "+6PL12", 0x11, log)

verbose = True

ccu.send("reset").readlines()
ccu.send("scanccu").readlines()
ccu.send("piareset all").readlines()

for l in ccu.send("scanccu").readlines():
    if (verbose): print l

ccu.send("fec 21").readlines()
ccu.send("ring 0x8").readlines()
ccu.send("ccu 0x7c").readlines()


ccu.send("channel 0x11").readlines()
ccu.send("delay25 init").readlines()
ccu.send("pll reset").readlines()
ccu.send("pll init").readlines()
Example #9
0
    assert 0 <= x <= 255

########################################################

print "connecting to ccu prog %s:%i" % (fechost, fecport)
ccu = SimpleSocket(fechost, fecport)
log = Logger()
print
print 'not sending cratereset, reset, piareset all as old script did'

tag="FEC %d ring 0x%i :"%(fecslot,fecring)
print 'tag is', tag
fecringfound=False
fecfound=False
status=""
for l in ccu.send("mapccu").readlines():
    print l
    if l.strip().startswith("FEC %d"%(fecslot)):
        fecfound=True
    if l.strip().startswith(tag):
        fecringfound=True
        status=l.strip().split(":")[1].strip()
if not fecfound:
    log.error("No such FEC %d"%fecslot)
    sys.exit(1)
if not fecringfound:
    log.error("ring/mfec not found "+tag)
    sys.exit(1)
    
if status=="no CCU found":
    log.error("no CCU found "+tag)
Example #10
0
pxfec = 2000
caen = 0  # not used
fedport = 2006
fecport = 2001
########################################################

# connect
print "connecting to pxfec,",
pxfec = SimpleSocket('localhost', 2000)
print " done"  # port

print "connecting to ccu,",
########################################################
ccu = SimpleSocket('localhost', fecport)
print " done"  # port

pxfec.send("cn +6PL12").readlines()
pxfec.send("module 28").readlines()
pxfec.send("roc 0:15").readlines()
#ccu.send("channel 0x11").readlines()

for i in range(30, 600000):

    print "Setting Delay=%i" % (i)
    #ccu.send("delay25 set d2 %i"%i).readlines()
    pxfec.send("Vana 0").readlines()
    #time.sleep(3)
    pxfec.send("Vana 255").readlines()
    #time.sleep(3)
    pxfec.send("Vana 0").readlines()
Example #11
0
# choose an arbitray sector in that shell and get ring and slot from the server
#s=SECTOR("-6P",fed,17,ccu,pxfec,caen)
s=GROUP(fed, 6, ccu, pxfec, caen, "+2PL12", 0x11, log)
print "FED slot ",s.fedslot

verbose = True

#ccu.send("cratereset").readlines()
#ccu.send("scanccu").readlines()
#ccu.send("piareset all").readlines()

#for l in ccu.send("scanccu").readlines():
#    if (verbose): print l

ccu.send("fec 12").readlines()
ccu.send("ring 0x8").readlines()
ccu.send("ccu 0x7b").readlines()


ccu.send("channel 0x11").readlines()
for i in range(1,10):
    print i
    for l in ccu.send("poh7 read").readlines():
        print l
    sleep(1)
    for l in ccu.send("poh7 setall 1 1 1 1 2 2 2 2").readlines():
        print l
    sleep(1)
#ccu.send("delay25 init").readlines()
#ccu.send("pll reset").readlines()
Example #12
0
from SimpleSocket import SimpleSocket
import sys,readline
""" console client for SimpleSocket servers or SimpleServer applications"""

if not len(sys.argv)==3:
    print "usage: python client.py <host> <port>"
    sys.exit(1)
    
host,port=sys.argv[1],int(sys.argv[2])


try:
    readline.read_history_file(".history")
except:
    pass

mySocket=SimpleSocket( host, port)


while mySocket.isOpen():
    cmd=raw_input("%s " %(mySocket.prompt))
    mySocket.send(cmd)
    for l in mySocket.readline():
        print l
    
mySocket.close()
readline.write_history_file(".history")
Example #13
0
        gr.SetPoint(i, t, float(rms) * 100.)
        i += 1
        if t > tmax:
            tmax = tmax * 2
            h = TH2D('hd', "", 2, 0, tmax, 2, 0, 1024)
            h.Draw()


try:
    sectorname = sys.argv[1]
except:
    print "usage: aohrms.py <sector>"
    sys.exit(1)

s = SECTOR(sectorname, fed, 8, ccu, pxfec, caen)
ccu.send("cratereset").readlines()
#rmsvstime(s,4,1)
for l in ccu.send("scanccu").readlines():
    print l

filename = getFilename("testdata/myaoh%s.ps" % (s.name))
rootfile = TFile(os.path.splitext(filename)[0] + ".root", "CREATE")
##TCanvas('c1', '', 200, 10, 800, 800).Print(filename+"[")
TCanvas('c1').Print(filename + "[")
for aoh in range(1, 1):
    showRMSAOH(s, aoh, wait=False, filename=filename)
TCanvas('c1').Print(filename + "]")
#for h in hList: h.Write()
#rootfile.Write()
rootfile.Close()
#showRMSAOH(s,4)
Example #14
0
  c1.Print(filename)
  gCanvases.append(c1)
        
  if wait:
      raw_input("hit return to continue")


try:
   sectorname=sys.argv[1]
except:
   print "usage: aohrms.py <sector>"
   sys.exit(1)
   

s=SECTOR(sectorname,fed,7,ccu,pxfec,caen)
print "Sector     ",sectorname
print "FED slot   ",s.fedslot

for l in fed.send("reset").readlines():
   print l

print "read rms"
for i in range(1,37):
   for l in fed.send("rms "+str(i)).readlines():
      print " rms ",l


print "finished"

fed.close()
Example #15
0
class LEDARemoteServerControl(object):
	def __init__(self, host, port, log=LEDALogger()):
		self.host = host
		self.port = port
		self.log  = log
		self.connect()
	def connect(self):
		self.log.write("Connecting to remote server %s:%i" \
			               % (self.host,self.port))
		#self._nstreams = None
		# TODO: This timeout must be long enough to cover long
		#         operations on the server. This is not a good
		#         way to do things; would probably be better to
		#         send an instant response and something like
		#         an asynchronous "I'll get back to you in N secs".
		self.sock = SimpleSocket(timeout=10)
		try:
			self.sock.connect(self.host, self.port)
		except SimpleSocket.timeout_error:
			self.log.write("All connections were refused", -2)
			self.sock = None
		except:
			self.log.write("Failed to connect. "+str(sys.exc_info()[1]), -2)
			self.sock = None
		else:
			self.log.write("Connection successful")
	def isConnected(self):
		return self.sock is not None
	def _sendmsg(self, msg):
		if self.sock is None:
			self.log.write("Not connected", -2)
			self.log.write("Reconnecting", 0)
			self.connect()
			return None
		if len(msg) <= 256:
			self.log.write("Sending message "+msg, 4)
		else:
			self.log.write("Sending long message of length %i bytes"%(len(msg)), 4)
		try:
			self.sock.send(msg)
			ret = self.sock.receive()
		except:
			self.log.write("Not connected", -2)
			self.sock = None
			self.log.write("Reconnecting", 0)
			self.connect()
			return None
		if len(ret) < 256:
			self.log.write("Received response "+ret, 4)
		else:
			self.log.write("Received long response of length %i bytes"%(len(ret)), 4)
		return ret
	def _sendcmd(self, cmd):
		ret = self._sendmsg(cmd)
		if ret is None:
			return
		if ret != 'ok':
			self.log.write("Remote command failed", -2)
			raise Exception("Remote command failed")
	def getStatus(self):
		self.log.write("Requesting server status", 2)
		if self.sock is None:
			self.log.write("Not connected", -2)
			self.log.write("Reconnecting", 0)
			self.connect()
			return None
		encoded = self._sendmsg("status=1")
		if encoded is None:
			return None
		status = json.loads(encoded)
		return status
	def createBuffers(self):
		self.log.write("Creating buffers", 2)
		self._sendcmd("create_buffers=1")
	def destroyBuffers(self):
		self.log.write("Destroying buffers", 2)
		self._sendcmd("destroy_buffers=1")
	def setTotalPowerRecording(self, ncycles):
		self.log.write("Setting total power recording param", 2)
		self._sendcmd("total_power=%i" % ncycles)
	def armPipeline(self, mode='correlator'):
		self.log.write("Arming pipeline in %s mode" % mode, 2)
		self._sendcmd("arm=1&mode=%s" % mode)
	def startPipeline(self, ra=None, dec=None):
		self.log.write("Starting pipeline", 2)
		if ra is not None and dec is not None:
			self._sendcmd("start=1&ra=%s&dec=%s" % (ra,dec))
		else:
			self._sendcmd("start=1")
	def killPipeline(self):
		self.log.write("Killing pipeline", 2)
		self._sendcmd("kill=1")
	def clearLogs(self):
		#self.log.write("Clearing all logs", 2)
		self._sendcmd("clear_logs=1")
	def getVisMatrixImages(self):
		self.log.write("Requesting visibility matrix images", 2)
		encoded = self._sendmsg("vismatrix_images=1")
		if encoded is None:
			return None
		encoded_images = json.loads(encoded)
		return encoded_images
	def exit(self):
		self.log.write("Requesting server control script to exit", 2)
		self._sendcmd("exit=1")
Example #16
0
class LEDARemoteHeadNodeControl(object):
    def __init__(self, host, port, log=LEDALogger()):
        self.host = host
        self.port = port
        self.log = log
        self.connect()

    def connect(self):
        self.log.write("Connecting to remote headnode %s:%i" % (self.host, self.port))
        # TODO: See comment in leda_headnodecontrol.py
        self.sock = SimpleSocket(timeout=10)
        try:
            self.sock.connect(self.host, self.port)
        except SimpleSocket.timeout_error:
            self.log.write("All connections were refused", -2)
            self.sock = None
        except:
            self.log.write("Failed to connect. " + str(sys.exc_info()[1]), -2)
            self.sock = None
        else:
            self.log.write("Connection successful")

    def isConnected(self):
        return self.sock is not None

    def _sendmsg(self, msg):
        if self.sock is None:
            self.log.write("Not connected", -2)
            return None
        if len(msg) <= 256:
            self.log.write("Sending message " + msg, 4)
        else:
            self.log.write("Sending long message of length %i bytes" % (len(msg)), 4)
        try:
            self.sock.send(msg)
            ret = self.sock.receive()
        except:
            self.log.write("Not connected", -2)
            self.sock = None
            return None
        else:
            if len(ret) <= 256:
                self.log.write("Received response " + ret, 4)
            else:
                self.log.write("Received long response of length %i bytes" % (len(ret)), 4)
            return ret

    def _sendcmd(self, cmd):
        ret = self._sendmsg(cmd)
        if ret is None:
            return
        if ret != "ok":
            self.log.write("Remote command failed", -2)
            raise Exception("Remote command failed")

    def getStatus(self):
        self.log.write("Requesting status", 2)
        # if self.sock is None:
        # 	self.log.write("Not connected", -2)
        # 	return None
        encoded = self._sendmsg("status=1")
        if encoded is None:
            return None
            # print "json.loads('%s')" % encoded
        status = json.loads(encoded)
        return status

    def getADCImages(self):
        self.log.write("Requesting ADC images", 2)
        encoded = self._sendmsg("adc_images=1")
        if encoded is None:
            return None
            # print "json.loads('%s')" % encoded
        encoded_images = json.loads(encoded)
        # images = [Image.open(base64.standard_b64decode(im))
        # TODO: This isn't great. We return the raw binary data as a string.
        images = [[base64.standard_b64decode(adc_im) for adc_im in roach] for roach in encoded_images]
        # images = [base64.standard_b64decode(im)
        # 	          for im in encoded_images]
        return images

    def exit(self):
        self.log.write("Exiting", 2)
        self._sendcmd("exit=1")

    def configure(self):
        self.log.write("Configuring", 2)
        self._sendcmd("configure=1")

    def programRoaches(self):
        self.log.write("Programming roaches", 2)
        self._sendcmd("program_roaches=1")

    def createBuffers(self):
        self.log.write("Creating buffers", 2)
        self._sendcmd("create_buffers=1")

    def setTotalPowerRecording(self, ncycles):
        self.log.write("Setting total power recording param", 2)
        self._sendcmd("total_power=%i" % ncycles)

    def startObservation(self, mode="correlator", ra=None, dec=None):
        self.log.write("Starting observation", 2)
        if ra is not None and dec is not None:
            self._sendcmd("start=1&mode=%s&ra=%s&dec=%s" % (mode, ra, dec))
        else:
            self._sendcmd("start=1&mode=%s" % mode)

    def stopObservation(self):
        self.log.write("Stopping observation", 2)
        self._sendcmd("stop=1")

    def killObservation(self):
        self.log.write("Killing observation", 2)
        self._sendcmd("kill=1")

    def clearLogs(self):
        self.log.write("Clearing all logs", 2)
        self._sendcmd("clear_logs=1")

    def getVisMatrixImages(self):
        self.log.write("Requesting visibility matrix images", 2)
        encoded = self._sendmsg("vismatrix_images=1")
        if encoded is None:
            return None
        encoded_images = json.loads(encoded)
        # TODO: This isn't great. We return the raw binary data as a string.
        images = [base64.standard_b64decode(encoded_image) for encoded_image in encoded_images]
        return images
Example #17
0
caenport= 2005              
caenslot =4  

########################################################
ccu=SimpleSocket( fechost, fecport)
pxfec=SimpleSocket(fechost, pxfecport)
caen=SimpleSocket(caenhost,caenport)
fed=SimpleSocket(fedhost, fedport)
digfed=SimpleSocket( 'localhost', dfedport)
timer.append("Connection to simplesocket")
timer.append(time.time()-start_time)
########################################################
# print "sector and groups names definition"
log=Logger()
name= "+6P"
ccu.send("sector" + name   ).readlines()
out=( ccu.send( "which fec").readlines())
fecslot =int(out[1][-2:])
out=(ccu.send("which ring").readlines())
fecring =int(out[1][-2:])
sector= SECTOR(name,fed,ccu,pxfec,caen,log)
########################################################
module=[23,30]#,15,31]
d1=[13,53]#,48,42]
d2=[53,53]#,53,53]
tbmplldelayvalue=[[6,5],[6,5]]#],[3,3],[5,3]]
tbmplldelaydec=[]
fiber=[[11,12],[10,9]]#,[6,5],[8,7]]#,[],[]] # MAKE IT CONSISTENT
########################################################
ntrigger=1000#20000
slopethr=10 # threshold for the pohbias scan slope
Example #18
0
#variables to play with
NrOfBursts = 100
hertz = 40  #in [kHz]
TriggerPerBurst = 100
gain = 2
bias = 30
#tbmplldelay = 111

rate = int(1. / (hertz * 25 * 10**(-6)))
if (rate > 65535):
    rate = 65536
    print "Warning: Rate set too high, set it on 65536 "

print rate
digfed.send("rate {0:d}".format(rate)).readlines()
digfed.send("burst {0:d}".format(TriggerPerBurst)).readlines()
digfed.send("confamc").readlines()

#create a textfile
datafile = open(
    st, 'w'
)  # where 'datafile' is the name of the created text file (take care, this will
# overwrite the existing file!!)

#initialize poh on gain=0 and bias=0
ccu.send("channel 11").readlines()
ccu.send("poh2 set g0 {0:d}".format(gain)).readlines()
ccu.send("poh2 set b0 {0:d}".format(bias)).readlines()

#initialize module (tbm, pll,...) with help of pxfec
Example #19
0
#   sectorname=sys.argv[1]
#except:
#   sectorname=''
#print "usage: pohrms.py <sector>"
#sys.exit(1)

s = SECTOR(sectorname, fed, ccu, pxfec, caen)
print "Sector   ", sectorname
#print "FED slot ",s.fedslot

s.ccu.send("sector " + sectorname).readlines()
s.ccu.send("channel 0x11 ").readlines()

#ccu.send("cratereset").readlines()

for l in ccu.send("scanccu").readlines():
    print l

for l in ccu.send("which fec").readlines():
    print l

for l in ccu.send("which ring").readlines():
    print l

for l in ccu.send("which ccu").readlines():
    print l

for l in ccu.send("which channel").readlines():
    print l

#print "finished"
Example #20
0
print " done"

print "connecting to pxfec,",
pxfec = SimpleSocket('localhost', 2000)
print " done"

log = Logger()

# choose an arbitray sector in that shell and get ring and slot from the server
#s=SECTOR("-6P",fed,17,ccu,pxfec,caen)
s = GROUP(fed, ccu, pxfec, caen, "+6PL12", 0x11, log)
# print "FED slot ",s.fedslot

verbose = True

ccu.send("reset").readlines()
sleep(0.1)
ccu.send("scanccu").readlines()
ccu.send("piareset doh").readlines()
sleep(0.1)
ccu.send("piareset aoh").readlines()
sleep(0.1)

for l in ccu.send("scanccu").readlines():
    if (verbose): print l

ccu.send("fec 21").readlines()
ccu.send("ring 0x8").readlines()
ccu.send("ccu 0x7c").readlines()

ccu.send("channel 0x11").readlines()
Example #21
0
print "connecting to digitalfed,",
digfed = SimpleSocket('localhost', 2060)
print " done"

#import actual time
ts = time.time()
st = datetime.datetime.fromtimestamp(ts).strftime(
    'biasgain_%d-%m-%Y_%H:%M:%S.txt')

#variables to play with
bursts = 1
hertz = 10  #in [kHz]

rate = int(1 / (hertz * 25 * 10**(-6)))
digfed.send("rate {0:d}".format(rate)).readlines()
digfed.send("confamc").readlines()

#initialize poh on gain=0 and bias=0
ccu.send("channel 11").readlines()
ccu.send("poh2 set g0 3").readlines()
ccu.send("poh2 set b0 30").readlines()

#create a textfile
datafile = open(
    st, 'w'
)  # where 'datafile' is the name of the created text file (take care, this will overwrite the existing file!!)

for i in digfed.send("titlegb {0:d}".format(bursts)).readlines():
    print i
    datafile.write(i)
Example #22
0
########################################################
c1 = TCanvas('c1', 'c1', 200, 10, 800, 800)
########################################################
redundancytest = False  # True
resettest = False
inittest = False  # True
dcdctest = True  #True
vanatest = False
dcdcianatest = True
########################################################
########################################################
########################################################
# print "sector and groups names definition"
log = Logger()
name = "+6P"
ccu.send("sector" + name).readlines()
out = (ccu.send("which fec").readlines())
fecslot = int(out[1][-2:])
out = (ccu.send("which ring").readlines())
fecring = int(out[1][-2:])
sector = SECTOR(name, fed, ccu, pxfec, caen, log)
########################################################
########################################################
ccu.send("sector " + str(sector.name)).readlines()
# ccu.send("reset").readlines()
# ccu.send("piareset all").readlines()
########################################################
# tag="FEC %d ring 0x%s :"%(fecslot,fecring)
# fecringfound=False
# fecfound=False
# status=""
Example #23
0
pxfec=0                    # not used
caen=0                     # not used

########################################################


# connect

print "connecting to ccu,",fechost, fecport
ccu=SimpleSocket( fechost, fecport)
print " done"

log=Logger()

# choose an arbitray sector in that shell and get ring and slot from the server
ccu.send("cratereset").readlines()
ccu.send("reset").readlines()
ccu.send("piareset all").readlines()
fecring = 7
#fecring = 8
fecslot = 9
print "fecring=",fecring
print "fecslot=",fecslot
tag="FEC %d ring 0x%i :"%(fecslot,fecring)
print 'tag is', tag

fecringfound=False
fecfound=False
status=""
for l in ccu.send("mapccu").readlines():
    print l
Example #24
0
           tmax=tmax*2
           h=TH2D('hd', "", 2,0,tmax,2,0,1024 )
           h.Draw()
     


try:
   sectorname=sys.argv[1]
except:
   print "usage: aohrms.py <sector>"
   sys.exit(1)
   


s=SECTOR(sectorname,fed,8,ccu,pxfec,caen)
ccu.send("cratereset").readlines()
#rmsvstime(s,4,1)
for l in ccu.send("scanccu").readlines():
   print l


filename=getFilename("testdata/myaoh%s.ps"%(s.name))
rootfile=TFile(os.path.splitext(filename)[0]+".root","CREATE")
##TCanvas('c1', '', 200, 10, 800, 800).Print(filename+"[")
TCanvas('c1').Print(filename+"[")
for aoh in range(1,1):
   showRMSAOH(s,aoh,wait=False,filename=filename)
TCanvas('c1').Print(filename+"]")
#for h in hList: h.Write()
#rootfile.Write()
rootfile.Close()
Example #25
0
        c1.Update()

    c1.Print(filename)
    gCanvases.append(c1)

    if wait:
        raw_input("hit return to continue")


try:
    sectorname = sys.argv[1]
except:
    print "usage: aohrms.py <sector>"
    sys.exit(1)

s = SECTOR(sectorname, fed, 7, ccu, pxfec, caen)
print "Sector     ", sectorname
print "FED slot   ", s.fedslot

for l in fed.send("reset").readlines():
    print l

print "read rms"
for i in range(1, 37):
    for l in fed.send("rms " + str(i)).readlines():
        print " rms ", l

print "finished"

fed.close()
Example #26
0
from SimpleSocket import SimpleSocket
import sys, readline
""" console client for SimpleSocket servers or SimpleServer applications"""

if not len(sys.argv) == 3:
    print "usage: python client.py <host> <port>"
    sys.exit(1)

host, port = sys.argv[1], int(sys.argv[2])

try:
    readline.read_history_file(".history")
except:
    pass

mySocket = SimpleSocket(host, port)

while mySocket.isOpen():
    cmd = raw_input("%s " % (mySocket.prompt))
    mySocket.send(cmd)
    for l in mySocket.readline():
        print l

mySocket.close()
readline.write_history_file(".history")
Example #27
0
    st = "{0:d}".format(i)

    #variables to play with
    NrOfBursts = 1000
    hertz = 40  #in [kHz]
    TriggerPerBurst = 100
    gain = 2
    bias = 30

    rate = int(1. / (hertz * 25 * 10**(-6)))
    if (rate > 65535):
        rate = 65536
        print "Warning: Rate set too high, set it on 65536 "

    print rate
    digfed.send("rate {0:d}".format(rate)).readlines()
    digfed.send("burst {0:d}".format(TriggerPerBurst)).readlines()
    digfed.send("confamc").readlines()

    #create a textfile
    datafile = open(
        st, 'w'
    )  # where 'datafile' is the name of the created text file (take care, this will
    # overwrite the existing file!!)

    #initialize poh on gain=0 and bias=0
    ccu.send("channel 11").readlines()
    ccu.send("poh2 set g0 {0:d}".format(gain)).readlines()
    ccu.send("poh2 set b0 {0:d}".format(bias)).readlines()

    #initialize module (tbm, pll,...) with help of pxfec
Example #28
0
TriggerPerBurst = 1
gain = 2
bias = 30
tbmplldelay = 0
tbmadelay = 0

rate = int(1. / (hertz * 25 * 10**(-6)))
if (rate > 65535):
    rate = 65536
    print "Warning: Rate set too high, set it on 65536 "

print rate
#digfed.send("rate {0:d}".format(rate)).readlines()
#digfed.send("burst {0:d}".format(TriggerPerBurst)).readlines()
#digfed.send("mode 0").readlines()
digfed.send("confcal").readlines()
#digfed.send("confamc").readlines()

#create a textfile
datafile = open(
    st, 'w'
)  # where 'datafile' is the name of the created text file (take care, this will
# overwrite the existing file!!)

#initialize poh on gain=0 and bias=0
#ccu.send("channel 11").readlines()
#ccu.send("poh2 set g0 {0:d}".format(gain)).readlines()
#ccu.send("poh2 set b0 {0:d}".format(bias)).readlines()

#initialize module (tbm, pll,...) with help of pxfec
#pxfec.send("trim 0").readlines()
Example #29
0
tbmplldelay = 0
tbmadelay = 0


rate = int(1./(hertz *25*10**(-6)))
if (rate>65535):
  rate = 65536
  print "Warning: Rate set too high, set it on 65536 "

print rate
#digfed.send("rate {0:d}".format(rate)).readlines()
#digfed.send("burst {0:d}".format(TriggerPerBurst)).readlines()
#digfed.send("mode 0").readlines()
#digfed.send("confcal").readlines()
#digfed.send("confamc").readlines()
digfed.send("enablebgo").readlines()


#create a textfile
datafile = open(st, 'w')     # where 'datafile' is the name of the created text file (take care, this will
                             # overwrite the existing file!!)




#initialize poh on gain=0 and bias=0
#ccu.send("channel 11").readlines()
#ccu.send("poh2 set g0 {0:d}".format(gain)).readlines()
#ccu.send("poh2 set b0 {0:d}".format(bias)).readlines()

Example #30
0
#print " done"

print "connecting to ccu,",
ccu=SimpleSocket( 'localhost', 2005)
print " done"

print "connecting to digitalfed,",
digfed=SimpleSocket( 'localhost', 2060)
print " done"


ts = time.time()
st = datetime.datetime.fromtimestamp(ts).strftime('Frequency_%d-%m-%Y_%H:%M:%S.txt')


datafile = open(st, 'w')     # where 'datafile' is the name of the created text file (take care, this will overwrite the existing file!!)

for i in digfed.send("title {0:d}".format(100)).readlines():
  print i
  datafile.write(i)
  datafile.write('\n')

for hertz in range (1, 1002, 10):
  rate = int(1/(hertz *25*10**(-6)))
  digfed.send("rate {0:d}".format(rate)).readlines()
  digfed.send("confamc").readlines()
  for l in digfed.send("test 100").readlines():
    print l
    datafile.write(l)
    datafile.write('\n')