diff --git a/FofbTool/Configuration.py b/FofbTool/Configuration.py index 22a33d081d3e58e9f6d0790073309301bb1c799d..e37d2eb112c5044bc4581f382157c4bf099ac98d 100644 --- a/FofbTool/Configuration.py +++ b/FofbTool/Configuration.py @@ -162,48 +162,120 @@ def centralnode_configure_comgbe(node_tangopath, npsc): logger.info("{} psc expected in the ethernet frame on {}".format(npsc, node_tangopath)) logger.info("Configure packeter npackets to {}".format(npsc-1)) for n in range(1): - prx["ccnpacketh{}_npackets".format(n)] = npsc-1 + prx["gigethpack{}_npackets".format(n)] = npsc-1 #maclen = npsc*4+10+20+8 #logger.info("Configure packeter framesize (mac length) to {}".format(maclen)) #prx["ccnpacketh{}_framesize".format(n)] = maclen maclen = 0x0800 logger.info("Configure IP protocol to {}".format(hex(maclen))) - prx["ethhead{}_framesize".format(n)] = int(maclen) + prx["gigethhead{}_framesize".format(n)] = int(maclen) ipv = 4 logger.info("Configure IP version to {}".format(hex(ipv))) - prx["ethhead{}_ipv".format(n)] = ipv + prx["gigethhead{}_ipv".format(n)] = ipv ipihl = 5 logger.info("Configure IP Header Length to {}".format(hex(ipihl))) - prx["ethhead{}_ipihl".format(n)] = ipihl + prx["gigethhead{}_ipihl".format(n)] = ipihl iplength = (npsc*4+4)+20+8 - prx["ethhead{}_iplength".format(n)] = iplength + prx["gigethhead{}_iplength".format(n)] = iplength logger.info("IP length configured to {}".format(iplength)) #ipdest=np.uint(0xa9fe0102) #bug found here --> not possible to set up uint32 to pyTango #logger.error(ipdest) - #prx["ethhead{}_ipdst".format(n)] = ipdest + #prx["gigethhead{}_ipdst".format(n)] = ipdest #logger.debug("IP dest configured to {}".format(ipdest)) ipchksum=ipheadchk_cmp(0x4500,int(hex(iplength),16),0x8011,0xa9fe,0x0101,0xa9fe,0x0102) - prx["ethhead{}_ipchksum".format(n)] = int(ipchksum) + prx["gigethhead{}_ipchksum".format(n)] = int(ipchksum) logger.info("IP chksum configured to {}".format(ipchksum)) udplength=(npsc*4+4)+8 - prx["ethhead{}_udplength".format(n)] = udplength + prx["gigethhead{}_udplength".format(n)] = udplength logger.info("UDP length configured to {}".format(udplength)) udpport=0x75317531 - prx["ethhead{}_udpport".format(n)] = int(udpport) + prx["gigethhead{}_udpport".format(n)] = int(udpport) logger.info("UDP ports (src&dest) configured to {}".format(hex(udpport))) udpchksum=0x00 - prx["ethhead{}_udpchksum".format(n)] = udpchksum + prx["gigethhead{}_udpchksum".format(n)] = int(udpchksum) logger.info("UDP ports chksum configured to {}".format(udpchksum)) logger.info("Configuration of Com GBE done on {}.".format(node_tangopath)) return True +################################################################################################### + +def cellnode_configure_ccn(node_tangopath, nbpm, npsc): + """ + Configure the ComCellNode block on a cellnode. + Automatically set the number of bpm/psc packets and MAC length. + + PARAMETERS + ---------- + node_tangopath: str + The target fofbnode tango path, ie 'ans/dg/fofb-cellnode-c09' + nbpm: + Number of BPM allowed by the filter, hence the number of expected BPM packets. + npsc: + Number of total PSC, hence the number of expected PSC packets. + + RETURN + ------ + success: boolean + True if configuration is a success + """ + + # Get device proxy + try: + prx=tango.DeviceProxy(node_tangopath) + prx.ping() + except tango.DevFailed: + logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath)) + return None + + logger.debug("{} bpm allowed in the ethernet frame on {}".format(nbpm, node_tangopath)) + logger.debug("{} psc expected in the ethernet frame on {}".format(npsc, node_tangopath)) + + maclen = 10*nbpm+10 + logger.debug("Configure packeter framesize (mac length) to {}".format(maclen)) + prx["ccnpack0_framesize"] = maclen + + logger.debug("Configure packeter npackets to {}".format(nbpm-1)) + prx["ccnpack0_npackets"] = nbpm-1 + + maclen = npsc*6+10 + logger.debug("Configure unpacketer framesize (mac length) to {}".format(maclen)) + prx["ccnunpack0_framesize"] = maclen + + logger.info("Configuration of CCN done on {}.".format(node_tangopath)) + return True + + # Get device proxy + try: + prx=tango.DeviceProxy(node_tangopath) + prx.ping() + except tango.DevFailed: + logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath)) + return None + + logger.debug("{} bpm allowed in the ethernet frame on {}".format(nbpm, node_tangopath)) + logger.debug("{} psc expected in the ethernet frame on {}".format(npsc, node_tangopath)) + + maclen = 10*nbpm+10 + logger.debug("Configure packeter framesize (mac length) to {}".format(maclen)) + prx["ccnpack0_framesize"] = maclen + + logger.debug("Configure packeter npackets to {}".format(nbpm-1)) + prx["ccnpack0_npackets"] = nbpm-1 + + maclen = npsc*6+10 + logger.debug("Configure unpacketer framesize (mac length) to {}".format(maclen)) + prx["ccnunpack0_framesize"] = maclen + + logger.info("Configuration of CCN done on {}.".format(node_tangopath)) + return True + ################################################################################################### @@ -257,8 +329,9 @@ def cellnode_configure_ccn(node_tangopath, nbpm, npsc): logger.info("Configuration of CCN done on {}.".format(node_tangopath)) return True + @trycatch_tango_devfailed -def centralnode_configure_ccn_w_gbe(node_tangopath, nbpm, npsc): +def centralnode_configure_ccn(node_tangopath, nbpm, npsc): """ Configure the ComCellNode block on the centralnode. Automatically set the number of bpm/psc packets and MAC length. @@ -286,6 +359,50 @@ def centralnode_configure_ccn_w_gbe(node_tangopath, nbpm, npsc): return None for n in range(len(nbpm)): + maclen = npsc*6+10 + logger.debug("Configure packeter {} framesize (mac length) to {}".format(n, maclen)) + prx["ccnpack{}_framesize".format(n)] = maclen + + logger.debug("Configure packeter {} npackets to {}".format(n, npsc-1)) + prx["ccnpack{}_npackets".format(n)] = npsc-1 + + maclen = 10*nbpm[n]+10 + logger.debug("Configure unpacketer {} framesize (mac length) to {}".format(n, maclen)) + prx["ccnunpack{}_framesize".format(n)] = maclen + + logger.info("Configuration of CCN done on {}.".format(node_tangopath)) + + logger.info("Configuration of CCN done on {}.".format(node_tangopath)) + return True + +@trycatch_tango_devfailed +def centralnode_configure_ccn_w_gbe(node_tangopath, nbpm, npsc): + """ + Configure the ComCellNode block on the centralnode. + Automatically set the number of bpm/psc packets and MAC length. + + PARAMETERS + ---------- + node_tangopath: str + The target fofbnode tango path, ie 'ans/dg/fofb-centralnode' + nbpm: list(int) + Number of BPM packet received on each interface. + npsc: + Number of total PSC, hence the number of expected PSC packets. + + RETURN + ------ + success: boolean + True if configuration is a success + """ + # Get device proxy + try: + prx=tango.DeviceProxy(node_tangopath) + prx.ping() + except tango.DevFailed: + logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath)) + return None + for n in range(4): maclen = npsc*4+4 logger.debug("Configure packeter {} framesize (mac length) to {}".format(n, maclen)) prx["ccnethhead{}_framesize".format(n)] = maclen diff --git a/FofbTool/Operation.py b/FofbTool/Operation.py index 769e6a2164d6ec1e4cac43bf225d1bdd3ba8ec11..cd3a01735f3205518450b84cc0fc85abeb34dcd3 100644 --- a/FofbTool/Operation.py +++ b/FofbTool/Operation.py @@ -318,7 +318,7 @@ def reset_gbe(node_tangopath, ccnif=[]): logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath)) return False if len(ccnif) == 0: - ccnif = [int(a[6]) for a in prx.get_attribute_list() if "gigeth" in a if "reset" in a] + ccnif = [int(a[6]) for a in prx.get_attribute_list() if "gigeth" in a if "reset" in a if not "error" in a] logger.info("Reset GBE on {}".format(node_tangopath)) for n in ccnif: prx["gigeth{}_reset".format(n)] = 1 @@ -357,13 +357,13 @@ def start_gbe(node_tangopath, ccnif=[]): except tango.DevFailed: logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath)) return False - if len(ccnif) == 0: - ccnif = [int(a[10]) for a in prx.get_attribute_list() if "ccnpacketh" in a if "control" in a] + #if len(ccnif) == 0: + ccnif = [int(a[10]) for a in prx.get_attribute_list() if "gigethpack" in a if "control" in a] reset_gbe(node_tangopath, ccnif) logger.info("Starting GBE on {}".format(node_tangopath)) for n in ccnif: if 'central' in node_tangopath: - prx["ccnpacketh{}_control".format(n)] = 1 + prx["gigethpack{}_control".format(n)] = 1 else: pass logger.info("COM GBE started on {}".format(node_tangopath)) @@ -395,15 +395,15 @@ def ack_gbe(node_tangopath, ccnif=[]): return False if len(ccnif) == 0: - ccnif = [int(a[10]) for a in prx.get_attribute_list() if "ccnpacketh" in a if "control" in a] + ccnif = [int(a[10]) for a in prx.get_attribute_list() if "gigethpack" in a if "control" in a] logger.info("Ack GBE error on {}".format(node_tangopath)) for n in ccnif: - prx["ccnpacketh{}_reset_error".format(n)] = 1 + prx["gigethpack{}_reset_error".format(n)] = 1 time.sleep(1) for n in ccnif: - prx["ccnpacketh{}_reset_error".format(n)] = 0 + prx["gigethpack{}_reset_error".format(n)] = 0 logger.info("ACK GBE error on {} done".format(node_tangopath)) return True @@ -424,7 +424,6 @@ def stop_gbe(node_tangopath, ccnif=[]): ------- bool: success """ - try: prx=tango.DeviceProxy(node_tangopath) prx.ping() @@ -432,11 +431,11 @@ def stop_gbe(node_tangopath, ccnif=[]): logger.error("Failed to obtain tango proxy or to ping to {}".format(node_tangopath)) return False if len(ccnif) == 0: - ccnif = [int(a[10]) for a in prx.get_attribute_list() if "ccnpacketh" in a if "control" in a] + ccnif = [int(a[10]) for a in prx.get_attribute_list() if "gigethpack" in a if "control" in a] logger.info("Stopping GBE com on {}".format(node_tangopath)) for n in ccnif: if 'central' in node_tangopath: - prx["ccnpacketh{}_control".format(n)] = False + prx["gigethpack{}_control".format(n)] = False reset_gbe(node_tangopath,ccnif) return True