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
	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")
Example #3
0
 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")
Example #4
0
	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")
Example #5
0
fechost = 'localhost'      
fecport =  2002    


fedslot =  99
fed=0                      # not used
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
Example #6
0
fecport = 2001

fedslot = 99
fed = 0  # not used
pxfec = 2000
caen = 0  # not used
fedport = 2006
########################################################

# 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"

#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]
Example #7
0
    f = base + "_" + date.today().isoformat()
    if os.path.exists(f + ext):
        template = f + "-%03d"
        for n in range(1, 100):
            if not os.path.exists(template % n + ext):
                return template % n + ext
        print "no valid filename found for ", filename
        return "temp" + ext
    else:
        return f + ext


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

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

print "connecting to fed,",
fed = SimpleSocket('localhost', 2004)
print " done"

caen = None  # not needed
pxfec = None  # not needed

name = "+6P"
sector = SECTOR(name, fed, ccu, pxfec, caen, log)
sector.pohlist = range(2, 3) + range(4, 5) + range(6, 7)


def showRMSPOHTestCCU(sector, poh, wait=True, filename=None):
Example #8
0
gCanvases=[]
########################################################
# port
fechost = 'localhost'      
pxfechost = 'localhost' 
caenhost ='localhost'
fedhost = 'localhost'   
fecport =  2001  
fedport= 2004  
dfedport= 2006            
pxfecport= 2000              
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:])
Example #9
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 #10
0
""" console client for connection to multiple SimpleServer(Sockets) """

# read the server list from mclient.conf
# one line per server: key host port, e.g. "d pc4226 2000"
serverlist = []
try:
    for l in open("mclient.conf").readlines():
        serverlist.append(l.split())
except:
    serverlist = [("d", "localhost", 2000), ("caen", "localhost", 2001),
                  ("ccu", "localhost", 2002), ("fed", "localhost", 2003)]

servers = {}
for key, host, port in serverlist:
    #if SimpleSocket.acceptsConnections(host,int(port)):
    servers[key] = SimpleSocket(host, int(port), timeout=2)
    print "connected to ", key

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

defaultServer = ""
prompt = ">"

while len(servers) > 0:

    # user input of the form [serverKey] [request]
    # example: "d module 23 roc 5 Vcal 120" sends request module... to d
    #          "d"                          makes d the default
Example #11
0
   f=base+"_"+date.today().isoformat()
   if os.path.exists(f+ext):
         template=f+"-%03d"
         for n in range(1,100):
            if not os.path.exists(template%n+ext):
               return template%n+ext
         print "no valid filename found for ",filename
         return "temp"+ext
   else:
      return f+ext

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


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

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

caen=None   # not needed
pxfec=None  # not needed




def showRMSAOHTestCCU(sector,aoh,wait=True,filename=None):
  gStyle.SetOptStat(0)
  gStyle.SetCanvasColor(0)
Example #12
0
# configuration
fechost = 'localhost'
fecport = 2001

fedslot = 99
fed = 0  # not used
pxfec = 2000
caen = 0  # not used

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

# connect

print "connecting to ccu,", fechost, fecport
ccu = SimpleSocket(fechost, fecport)
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, 17, ccu, pxfec, caen, "+1PL12", 0x11, log)
print "FED slot ", s.fedslot

verbose = True
Example #13
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 #14
0
import socket
import pygame, sys
import time
from SimpleSocket import SimpleSocket    

conn = SimpleSocket()
conn.connect("192.168.0.16", 5001)
conn.sock.setblocking(0)

pygame.init()
pygame.display.set_caption('Ev3 Keyboard Control')
size = [400, 400]
screen = pygame.display.set_mode(size)
clock = pygame.time.Clock()
 
while True:
    
    for event in pygame.event.get():
        if event.type == pygame.QUIT:
            pygame.quit()
            sys.exit()
        # check if key is pressed
        # if you use event.key here it will give you error at runtime
        if event.type == pygame.KEYUP:
            if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT   \
                   or event.key == pygame.K_UP:
                conn.sendMessage("stop\n")
                continue
        if event.type == pygame.KEYDOWN:
            if event.key == pygame.K_LEFT:             
                conn.sendMessage("turnleft\n")
Example #15
0
    base, ext = os.path.splitext(filename)
    f = base + "_" + date.today().isoformat()
    if os.path.exists(f + ext):
        template = f + "-%03d"
        for n in range(1, 100):
            if not os.path.exists(template % n + ext):
                return template % n + ext
        print "no valid filename found for ", filename
        return "temp" + ext
    else:
        return f + ext


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

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

caen = None  # not needed
pxfec = None  # not needed


def showRMSAOH(sector, aoh, wait=True, filename=None):
    ##   gStyle.SetOptStat(0)
    ##   gStyle.SetCanvasColor(0)
    ##   gStyle.SetTitleFillColor(0)
Example #16
0
   """ add date and version """
   base,ext=os.path.splitext(filename)
   f=base+"_"+date.today().isoformat()
   if os.path.exists(f+ext):
         template=f+"-%03d"
         for n in range(1,100):
            if not os.path.exists(template%n+ext):
               return template%n+ext
         print "no valid filename found for ",filename
         return "temp"+ext
   else:
      return f+ext

########################################################
print "connecting to fed,",
fed=SimpleSocket( 'localhost', 2003 )
print " done"

ccu=None
caen=None   # not needed
pxfec=None  # not needed




def showRMSAOHTestCCU(sector,aoh,wait=True,filename=None):
  gStyle.SetOptStat(0)
  gStyle.SetCanvasColor(0)
  gStyle.SetTitleFillColor(0)
     
  sector.aoh[aoh].biasGraphs=[]
Example #17
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 #18
0
import sys, time, os, re
from datetime import date
from time import sleep
sockdir = "/home/cmspixel/TriDAS/pixel/BPixelTools/tools/python"
if not sockdir in sys.path: sys.path.append(sockdir)
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")
Example #19
0
fechost = 'localhost'      
fecport =  2001  


fedslot =  99
fed=0                      # not used
pxfec=2000                 
caen=0                     # not used

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


# connect

print "connecting to ccu,",fechost, fecport
ccu=SimpleSocket( fechost, fecport)
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, 6, ccu, pxfec, caen, "+2PL12", 0x11, log)
print "FED slot ",s.fedslot

verbose = True
Example #20
0
########################################################

# configuration
fechost = 'localhost'
fecport = 2001

fedslot = 99
fed = 0  # not used
pxfec = 2000
caen = 0  # not used
fedport = 2006
########################################################

# 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"

#import actual time
ts = time.time()
st = datetime.datetime.fromtimestamp(ts).strftime(
    'calinject_%d-%m-%Y_%H:%M:%S.txt')
Example #21
0
# configuration
fechost = 'localhost'
fecport = 2001

fedslot = 99
fed = 0  # not used
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)
Example #22
0
		                        disk_outpaths,
		                        disk_cores,
		                        
		                        beam_logfiles,
		                        beam_path,
		                        beam_bufkeys,
		                        beam_gpus,
		                        beam_cores,
		                        site_lat,
		                        site_lon,
		                        site_stands_file,
		                        
		                        baseband_logfiles,
		                        baseband_path,
		                        baseband_bufkeys,
		                        baseband_noutchan,
		                        baseband_cores)
		
		# TESTING
		#port = int(sys.argv[1])
		
		print "Listening for client requests on port %i..." % port
		sock = SimpleSocket()
		sock.listen(functools.partial(onMessage, ledaserver), port)
		
	except:
		logMsg(-2, DL, "main: exception caught: " + str(sys.exc_info()[0]))
		print '-'*60
		traceback.print_exc(file=sys.stdout)
		print '-'*60
Example #23
0
    RCK = 0x20  
    CTR = 0x00  
    SDA = 0x1c  
    RDA = 0x12  
    CLK = 0x18

if bmi + bmo != 1:
    raise ValueError("must specify one of 'bmi' or 'bmo' at cmd line")
for x in (RCK, CTR, SDA, RDA, CLK):
    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
Example #24
0
	stand2leda = stand2leda[inds]
	stand2adc  = adc_inds + 8*(adcs + 2*(roaches))
	"""
	"""
	# Note: Loaded cols are LEDAST, STAND, POSX, POSY
	leda_stands, stands, stands_x, stands_y = \
	    np.loadtxt(stands_file, usecols=[11,0,1,2], unpack=True)
	# Filter out invalid stands
	valid = (leda_stands != 0)
	leda_stands = leda_stands[valid]
	stands   = stands[valid]
	stands_x = stands_x[valid]
	stands_y = stands_y[valid]
	# Sort by LEDA stand index
	inds = leda_stands.argsort()
	stands = stands[inds]
	stands_x  = stands_x[inds]
	stands_y  = stands_y[inds]
	"""
	ledavis = LEDARemoteVisManager(serverhosts, visports,
	                               roachhosts, roachport,
	                               lowfreq, highfreq,
	                               stands_x, stands_y,
	                               #stand2adc, stand2leda,
	                               adc2stand, leda2stand,
	                               LEDALogger(logstream, debuglevel))
	
	print "Listening for client requests on port %i..." % g_port
	sock = SimpleSocket()
	sock.listen(functools.partial(onMessage, ledavis), g_port)
Example #25
0
# configuration
fechost = 'localhost'
fecport = 2001

fedslot = 99
fed = 0  # not used
pxfec = 2000
caen = 0  # not used

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

# connect

print "connecting to ccu,", fechost, fecport
ccu = SimpleSocket(fechost, fecport)
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
Example #26
0
fechost = 'localhost'      
fecport =  2001  


fedslot =  99
fed=0                      # not used
pxfec=2000                 
caen=0                     # not used
dfedport= 2006 
########################################################


# connect

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

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
Example #27
0
sockdir = "/home/cmspixel/TriDAS/pixel/BPixelTools/tools/python"
from SimpleSocket import SimpleSocket
from SystemTests import GROUP, SECTOR, TestRedundancy, TestTriggerStatusFED, tDOH, AOH, DELAY25, PLL, MODULE, TestDCDCEnable, DCDCDisable, POH
from Logger import Logger
from ROOT import *
from array import array
from contextlib import contextmanager
fechost = 'localhost'
pxfechost = 'localhost'
caenhost = 'localhost'
fecport = 2001
pxfecport = 2000
caenport = 2005
caenslot = 4
fed = "dummyfed"
ccu = SimpleSocket(fechost, fecport)
pxfec = SimpleSocket(fechost, pxfecport)
caen = SimpleSocket(caenhost, caenport)
########################################################
########################################################
c1 = TCanvas('c1', 'c1', 200, 10, 800, 800)
########################################################
redundancytest = False  # True
resettest = False
inittest = False  # True
dcdctest = True  #True
vanatest = False
dcdcianatest = True
########################################################
########################################################
########################################################
Example #28
0
    f = base + "_" + date.today().isoformat()
    if os.path.exists(f + ext):
        template = f + "-%03d"
        for n in range(1, 100):
            if not os.path.exists(template % n + ext):
                return template % n + ext
        print "no valid filename found for ", filename
        return "temp" + ext
    else:
        return f + ext


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

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

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

caen = None  # not needed
pxfec = None  # not needed


def showRMSAOHTestCCU(sector, aoh, wait=True, filename=None):
    gStyle.SetOptStat(0)
    gStyle.SetCanvasColor(0)
    gStyle.SetTitleFillColor(0)
Example #29
0
    base, ext = os.path.splitext(filename)
    f = base + "_" + date.today().isoformat()
    if os.path.exists(f + ext):
        template = f + "-%03d"
        for n in range(1, 100):
            if not os.path.exists(template % n + ext):
                return template % n + ext
        print "no valid filename found for ", filename
        return "temp" + ext
    else:
        return f + ext


########################################################
print "connecting to fed,",
fed = SimpleSocket('localhost', 2003)
print " done"

ccu = None
caen = None  # not needed
pxfec = None  # not needed


def showRMSAOHTestCCU(sector, aoh, wait=True, filename=None):
    gStyle.SetOptStat(0)
    gStyle.SetCanvasColor(0)
    gStyle.SetTitleFillColor(0)

    sector.aoh[aoh].biasGraphs = []
    sector.aoh[aoh].rmsGraphs = []
    sector.aoh[aoh].slopeGraphs = []
Example #30
0
# configuration
fechost = 'localhost'      
pxfechost = 'localhost' 
caenhost ='localhost'
fedhost = 'localhost'   
fecport =  2001  
fedport= 2004              
pxfecport= 2000              
caenport= 2005              
caenslot =4  
########################################################
# connect start
########################################################
print "connecting to ccu,",fechost, fecport
ccu=SimpleSocket( fechost, fecport)
print " done"
print "connecting to pxfec,",pxfechost, pxfecport
pxfec=0
print " done"
print "connecting to caen,",caenhost, caenport
caen=0
print " done"
print "connecting to fed,",fedhost, fedport
fed=0
print " done"
########################################################
# connect end
########################################################
log=Logger()
name= "+6P"
Example #31
0
def start_vis_listener(port, disk_outpath, nchan_reduced_stream):
	ledavis = LEDAVis(disk_outpath, nchan_reduced_stream)
	
	print "Listening for client requests on port %i..." % port
	sock = SimpleSocket()
	sock.listen(functools.partial(onMessage, ledavis), port)
Example #32
0
import sys, time, os, re
from datetime import date
from time import sleep
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")
Example #33
0
   """ add date and version """
   base,ext=os.path.splitext(filename)
   f=base+"_"+date.today().isoformat()
   if os.path.exists(f+ext):
         template=f+"-%03d"
         for n in range(1,100):
            if not os.path.exists(template%n+ext):
               return template%n+ext
         print "no valid filename found for ",filename
         return "temp"+ext
   else:
      return f+ext

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

ccu=None
caen=None   # not needed
pxfec=None  # not needed




def showRMSAOHTestCCU(sector,aoh,wait=True,filename=None):
  gStyle.SetOptStat(0)
  gStyle.SetCanvasColor(0)
  gStyle.SetTitleFillColor(0)
     
  sector.aoh[aoh].biasGraphs=[]
Example #34
0
# configuration
fechost = 'localhost'      
fecport =  2001  


fedslot =  99
fed=0                      # not used
pxfec=2000                 
caen=0                     # not used
fedport =  2006
########################################################


# 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):
Example #35
0
   """ add date and version """
   base,ext=os.path.splitext(filename)
   f=base+"_"+date.today().isoformat()
   if os.path.exists(f+ext):
         template=f+"-%03d"
         for n in range(1,100):
            if not os.path.exists(template%n+ext):
               return template%n+ext
         print "no valid filename found for ",filename
         return "temp"+ext
   else:
      return f+ext

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

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

caen=None   # not needed
pxfec=None  # not needed




def showRMSAOH(sector,aoh,wait=True,filename=None):
##   gStyle.SetOptStat(0)
##   gStyle.SetCanvasColor(0)
Example #36
0
# configuration
fechost = 'localhost'
fecport = 2001

fedslot = 99
fed = 0  # not used
pxfec = 2000
caen = 0  # not used
fedport = 2006
########################################################

for i in range(0, 300, 1):

    # 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"

    #import actual time
    ts = time.time()
    #st = datetime.datetime.fromtimestamp(ts).strftime('pll_newFW_ChannelAB_%d-%m-%Y_%H:%M:%S.txt')
    st = "{0:d}".format(i)
Example #37
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 #38
0
# configuration
fechost = 'localhost'      
fecport =  2001  


fedslot =  99
fed=0                      # not used
pxfec=2000                 
caen=0                     # not used
fedport =  2006
########################################################


# 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"





#import actual time
Example #39
0
fedslot =  99
fed=0                      # not used
pxfec=2000                 
caen=0                     # not used
fedport =  2006
########################################################


# 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"


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