def __init__(self, name='TimeToolRx', **kwargs): rogue.interfaces.stream.Slave.__init__(self) pr.Device.__init__(self, name=name, **kwargs) self.add( pr.LocalVariable(name='frameCount', value=0, mode='RO', pollInterval=1)) self.add( pr.LocalVariable(name='lengthErrors', value=0, mode='RO', pollInterval=1)) self.add( pr.LocalVariable(name='dataErrors', value=0, mode='RO', pollInterval=1)) self.my_h5_file = h5py.File("first_test.h5", 'w') self.to_save_to_h5 = [] for i in range(8): self.add( pr.LocalVariable(name='byteError{}'.format(i), disp='{:#x}', value=0, mode='RO', pollInterval=1))
def __init__(self, name, device, **kwargs): pyrogue.Device.__init__(self, name=name, description='SMuRF Data Downsampler', **kwargs) self.device = device # Add "Disable" variable self.add( pyrogue.LocalVariable( name='Disable', description= 'Disable the processing block. Data will just pass thorough to the next slave.', mode='RW', value=False, localSet=lambda value: self.device.setDownsamplerDisable(value ), localGet=self.device.getDownsamplerDisable)) # Add the filter order variable self.add( pyrogue.LocalVariable( name='Factor', description='Downsampling factor', mode='RW', value=20, localSet=lambda value: self.device.setFactor(value), localGet=self.device.getFactor))
def __init__(self, name="DataFromFile", description="Data from file source", **kwargs): pyrogue.Device.__init__(self, name=name, description=description, **kwargs) self._data_master = DataMaster() self.add( pyrogue.LocalVariable(name='FileName', description='Path to the data file', mode='RW', value='/tmp/fw/x.dat')) self.add( pyrogue.LocalVariable(name='FrameCnt', description='Number of sent frames', mode='RO', value=0, localGet=self._data_master.get_frame_cnt)) self.add( pyrogue.LocalCommand(name='SendData', description='Send data', function=self._send_data))
def __init__(self, **kwargs): pyrogue.Device.__init__(self, **kwargs) self._reader = rogue.utilities.fileio.StreamReader() self.add(pyrogue.LocalVariable(name='dataFile', description='Data File', base='string', mode='RW', value='')) self.add(pyrogue.LocalVariable(name='open', description='Data file open state', bitSize=1, bitOffset=0, base='bool', mode='RW', localSet=self._setOpen))
def __init__(self, **kwargs): pyrogue.Device.__init__(self, name="SmurfApplication", description='SMuRF Application Container', **kwargs) self.add(pyrogue.LocalVariable( name='SmurfVersion', description='PySMuRF Version', mode='RO', value=pysmurf.__version__)) self.add(pyrogue.LocalVariable( name='SmurfDirectory', description='Path to the PySMuRF Python Files', value=os.path.dirname(pysmurf.__file__), mode='RO')) self.add(pyrogue.LocalVariable( name='StartupScript', description='PySMuRF Server Startup Script', value=sys.argv[0], mode='RO')) self.add(pyrogue.LocalVariable( name='StartupArguments', description='PySMuRF Server Startup Arguments', value=' '.join(sys.argv[1:]), mode='RO')) self.add(pyrogue.LocalVariable( name='SomePySmurfVariable', description='PySMuRF Variable Example', mode='RW', value=0, # Initial value determine variable type, (int, float, list, etc) )) # This variable will hold a list of the enabled bays. We set here the initial # value as a list of 2 elements, which will be its maximum size (as we have at # most 2 enabled bays). Its EPICS PV will be created with the initial size of # this list. This will generated an EPICS PV of size 2 in all cases, as currently # a bug in rogue does not allow to read list of size 1; also on the client side, # epics.caget will always return an numpy array even when only 1 bay is enabled. # We fill the list will invalid values; the list will be updated after the rogue # root is started (to wait for the PV to be created) with the correct values. self.add(pyrogue.LocalVariable( name='EnabledBays', description='List of bays that are enabled', value=[2, 2], mode='RO')) self.add(pyrogue.LocalVariable( name='ConfiguringInProgress', description='The system configuration sequence is in progress', mode='RO', value=False)) self.add(pyrogue.LocalVariable( name='SystemConfigured', description='The system was configured correctly', mode='RO', value=False))
def __init__(self, *, hidden=True, rates=None, states=None, cmd=None, **kwargs): """Initialize device class""" if rates is None: rates = {1: '1 Hz', 10: '10 Hz'} if states is None: states = {0: 'Stopped', 1: 'Running'} pr.Device.__init__(self, hidden=hidden, **kwargs) value = [k for k, v in states.items()][0] self._thread = None self._cmd = cmd self.add( pr.LocalVariable(name='runState', value=value, mode='RW', disp=states, localSet=self._setRunState, description='Run state of the system.')) value = [k for k, v in rates.items()][0] self.add( pr.LocalVariable(name='runRate', value=value, mode='RW', disp=rates, localSet=self._setRunRate, description='Run rate of the system.')) self.add( pr.LocalVariable(name='runCount', value=0, typeStr='UInt32', mode='RO', pollInterval=1, description='Run Counter updated by run thread.'))
def __init__(self, name="StreamDataSource", description="SMURF Data Source", **kwargs): pyrogue.Device.__init__(self, name=name, description=description, **kwargs) self._source = smurf.core.emulators.StreamDataSource() self.add( pyrogue.LocalVariable( name='SourceEnable', description='Frame generation enable', mode='RW', value=False, localGet=lambda: self._source.getSourceEnable(), localSet=lambda value: self._source.setSourceEnable(value))) self.add( pyrogue.LocalVariable( name='Period', description='Frame generation period in S', mode='RW', value=0.0, localGet=lambda: self._source.getSourcePeriod() / 1e6, localSet=lambda value: self._source.setSourcePeriod( int(value * 1e6)))) self.add( pyrogue.LocalVariable( name='CrateId', description='Frame generation crate ID', mode='RW', value=0, localGet=lambda: self._source.getCrateId(), localSet=lambda value: self._source.setCrateId(value))) self.add( pyrogue.LocalVariable( name='SlotNum', description='Frame generation slot #', mode='RW', value=0, localGet=lambda: self._source.getSlotNum(), localSet=lambda value: self._source.setSlotNum(value)))
def __init__(self, *, name, description, maxDepth=0, trimSize=0, noCopy=False, **kwargs): pyrogue.Device.__init__(self, name=name, description=description, **kwargs) self._fifo = rogue.interfaces.stream.Fifo(maxDepth, trimSize, noCopy) # Maximum Depth self.add( pyrogue.LocalVariable(name='MaxDepth', description='Maximum depth of the Fifo', mode='RO', value=maxDepth)) # Number of elements in the Fifo self.add( pyrogue.LocalVariable(name='Size', description='Number of elements in the Fifo', mode='RO', value=0, typeStr='UInt64', pollInterval=1, localGet=self._fifo.size)) # Number of dropped frames self.add( pyrogue.LocalVariable(name='FrameDropCnt', description='Number of dropped frames', mode='RO', value=0, typeStr='UInt64', pollInterval=1, localGet=self._fifo.dropCnt)) # Command to clear all the counters self.add( pyrogue.LocalCommand(name='ClearCnt', description='Clear all counters', function=self._fifo.clearCnt))
def __init__(self, **kwargs): super().__init__(**kwargs) for i in range(4096): b = (i // 100) * 100 t = (i // 100) * 100 + 99 self.add(pyrogue.LocalVariable( name = f'TestValue[{i}]', mode = 'RW', guiGroup=f'TestLargeGroup[{b}-{t}]', value = 0))
def __init__(self, name, **kwargs): self._header2smurf = smurf.core.conventers.Header2Smurf() pyrogue.Device.__init__(self, name=name, description='Convert the frame header to the SMuRF server', **kwargs) # Add "Disable" variable self.add(pyrogue.LocalVariable( name='Disable', description='Disable the processing block. Data will just pass thorough to the next slave.', mode='RW', value=False, localSet=lambda value: self._header2smurf.setDisable(value), localGet=self._header2smurf.getDisable))
def __init__(self): pyrogue.Root.__init__(self,name='evalBoard',description='Evaluation Board') # File writer dataWriter = pyrogue.utilities.fileio.StreamWriter(name='dataWriter') self.add(dataWriter) # Create the PGP interfaces udp = pyrogue.protocols.UdpRssiPack(host='192.168.2.194',port=8192,size=1400) # Create and Connect SRP to VC0 srp = rogue.protocols.srp.SrpV3() pyrogue.streamConnectBiDir(srp,udp.application(0)) # Add configuration stream to file as channel 0 pyrogue.streamConnect(self,dataWriter.getChannel(0x0)) pyrogue.streamConnect(udp.application(1),dataWriter.getChannel(0x1)) # PRBS Receiver as secdonary receiver for VC1 #prbsRx = pyrogue.utilities.prbs.PrbsRx('prbsRx') #pyrogue.streamTap(udp.application(1),prbsRx) #self.add(prbsRx) # Add Devices self.add(surf.axi.AxiVersion(memBase=srp,offset=0x0,expand=False)) #self.add(surf.protocols.ssi.SsiPrbsTx(memBase=srp,offset=0x40000)) self.add(pyrogue.LocalVariable(name='list',value=([0] * 10))) self.smem = pyrogue.smem.SMemControl(group='rogueTest',root=self) # Run control self.add(pyrogue.RunControl(name='runControl' , rates={1:'1 Hz', 10:'10 Hz',30:'30 Hz'})) #cmd=self.SsiPrbsTx.oneShot())) # Export remote objects #self.start(pollEn=True,pyroGroup='rogueTest',pyroHost='134.79.229.11',pyroNs='134.79.229.11') #self.start(pollEn=True,pyroGroup='rogueTest',pyroHost='134.79.229.11') #self.start(pollEn=True,pyroGroup='rogueTest') self.start(pollEn=True,pyroGroup='rogueTest') # Create epics node pvMap = {'evalBoard.AxiVersion.UpTimeCnt':'testCnt', 'evalBoard.AxiVersion.ScratchPad':'testPad'} pvMap = None # Comment out to enable map self.epics = pyrogue.epics.EpicsCaServer(base='rogueTest',root=self,pvMap=pvMap) self.epics.start() self.mysql = pyrogue.mysql.MysqlGw(dbHost='localhost',dbName='rogue',dbUser='******',dbPass='******',root=self) self.mysql.start()
def __init__(self, **kwargs): super(self.__class__, self).__init__(**kwargs) # Create the PyRogue software variables for col in range(32): for row in range(128): # Add the software variables self.add( pr.LocalVariable(name=f'Pixel[{col}][{row}]', description='Pixel Configuration', mode='RW', value=0x3f))
def __init__(self, **kwargs): pyrogue.Device.__init__(self, name="SmurfApplication", description='SMuRF Application Container', **kwargs) self.add( pyrogue.LocalVariable(name='SmurfVersion', description='PySMuRF Version', mode='RO', value=pysmurf.__version__)) self.add( pyrogue.LocalVariable( name='SmurfDirectory', description='Path to the PySMuRF Python Files', value=os.path.dirname(pysmurf.__file__), mode='RO')) self.add( pyrogue.LocalVariable(name='StartupScript', description='PySMuRF Server Startup Script', value=sys.argv[0], mode='RO')) self.add( pyrogue.LocalVariable( name='StartupArguments', description='PySMuRF Server Startup Arguments', value=' '.join(sys.argv[1:]), mode='RO')) self.add( pyrogue.LocalVariable( name='SomePySmurfVariable', description='PySMuRF Variable Example', mode='RW', value= 0, # Initial value determine variable type, (int, float, list, etc) ))
def __init__(self, name, device, **kwargs): pyrogue.Device.__init__(self, name=name, description='SMuRF Channel Mapper', **kwargs) self.device = device # Add the number of enabled channels variable self.add( pyrogue.LocalVariable(name='NumChannels', description='Number enabled channels', mode='RO', value=0, pollInterval=1, localGet=self.device.getNumCh)) # Add "payloadSize" variable self.add( pyrogue.LocalVariable( name='PayloadSize', description= 'Define a fixed payload size. If 0, the payload will hold the number of mapped channels', mode='RW', value=528, localSet=lambda value: self.device.setPayloadSize(value), localGet=self.device.getPayloadSize)) # Add variable to set the mapping mask # Rogue doesn't allow to have an empty list here. Also, the EPICS PV is created # with the initial size of this list, and can not be changed later, so we are doing # it big enough at this point using the maximum number of channels self.add( pyrogue.LocalVariable( name='Mask', description='Set the mapping mask', mode='RW', value=[0] * 4096, localSet=lambda value: self.device.setMask(value), localGet=self.device.getMask))
def __init__(self, name='TimeToolRx', **kwargs): print("Initializing TimeToolRx") rogue.interfaces.stream.Slave.__init__(self) pr.Device.__init__(self,name=name,**kwargs) self.add(pr.LocalVariable( name = 'frameCount', value = 0, mode = 'RO', pollInterval= 1, )) self.add(pr.LocalVariable( name = 'lengthErrors', value = 0, mode = 'RO', pollInterval= 1, )) self.add(pr.LocalVariable( name = 'dataErrors', value = 0, mode = 'RO', pollInterval= 1, )) self.add(pr.LocalVariable( name = 'frameLength', description = 'frameLength = 2052 # sn : medium mode, 8 bit, frameLength = 4100 # sn : medium mode, 12 bit', value = 2052, mode = 'RW', )) self.dsp_plotting = dsp_plotting() self.to_save_to_h5 = [] for i in range(8): self.add(pr.LocalVariable( name='byteError{}'.format(i), disp='{:#x}', value=0, mode='RO', pollInterval=1))
def __init__(self, name="DataToFile", description="Data to file writer", **kwargs): pyrogue.Device.__init__(self, name=name, description=description, **kwargs) self._data_slave = DataSlave() self._meta_slave = MetaSlave() self.add(pyrogue.LocalVariable( name='FileName', description='Path to the data file', mode='RW', value='/tmp/fw/y.dat')) self.add(pyrogue.LocalCommand( name='WriteData', description='Write data to disk', function=self._write_data))
def __init__(self, **kwargs): pyrogue.Device.__init__(self, **kwargs) self._reader = rogue.utilities.fileio.StreamReader() self.add( pyrogue.LocalVariable(name='DataFile', description='Data File', mode='RW', value='')) self.add( pyrogue.LocalCommand(name='Open', function=self._open, description='Open data file.')) self.add( pyrogue.LocalCommand(name='Close', function=self._close, description='Close data file.')) self.add( pyrogue.LocalVariable(name='isOpen', function=self._isOpen, description='Data file is open.'))
def __init__(self, name, **kwargs): pyrogue.Device.__init__(self, name=name, description='SMuRF Data BaseTransmitter', **kwargs) self._transmitter = smurf.core.transmitters.BaseTransmitter() # Add "Disable" variable self.add(pyrogue.LocalVariable( name='Disable', description='Disable the processing block. Data will just pass thorough to the next slave.', mode='RW', value=False, localSet=lambda value: self._transmitter.setDisable(value), localGet=self._transmitter.getDisable)) # Add the data dropped counter variable self.add(pyrogue.LocalVariable( name='dataDropCnt', description='Number of data frame dropped', mode='RO', value=0, pollInterval=1, localGet=self._transmitter.getDataDropCnt)) # Add the metaData dropped counter variable self.add(pyrogue.LocalVariable( name='metaDropCnt', description='Number of metadata frame dropped', mode='RO', value=0, pollInterval=1, localGet=self._transmitter.getMetaDropCnt)) # Command to clear all the counters self.add(pyrogue.LocalCommand( name='clearCnt', description='Clear all counters', function=self._transmitter.clearCnt))
def __init__(self, writeEn=False, **kwargs): super().__init__(**kwargs) self.add(pr.LocalVariable( name="WriteEn", mode="RO", value=writeEn, )) self.add( pr.RemoteVariable( name='HardwareReset', offset=0x000, bitSize=1, mode='RW', )) self.add( amphenol.LeapXcvrLowerPage( name='RxLower', isTx=False, writeEn=writeEn, offset=0x000, )) self.add( amphenol.LeapXcvrUpperRxPage01( name='RxUpperPage01', offset=0x400, )) self.add( amphenol.LeapXcvrLowerPage( name='TxLower', isTx=True, writeEn=writeEn, offset=0x800, )) self.add( amphenol.LeapXcvrUpperPage00( name='TxRxUpperPage00', offset=0x800, ))
def __init__(self, **kwargs): super().__init__(**kwargs) self._localValue = 0 self.add( pr.RemoteVariable( name="TestRemote", offset=0x1c, bitSize=32, bitOffset=0x00, base=pr.UInt, mode="RW", )) self.add( pr.RemoteVariable( name="TestRemoteNoVerify", offset=0x08, verify=False, bitSize=32, bitOffset=0x00, base=pr.UInt, mode="RW", )) self.add( pr.LocalVariable( name="TestLocal", mode="RW", value=0, localGet=self._localGet, localSet=self._localSet, )) self.add( pr.LinkVariable( name="TestLink", mode="RW", linkedSet=self._linkedSet, linkedGet=self._linkedGet, ))
def __init__(self, name, device, **kwargs): pyrogue.Device.__init__(self, name=name, description='SMuRF Data Unwrapper', **kwargs) self.device = device # Add "Disable" variable self.add( pyrogue.LocalVariable( name='Disable', description= 'Disable the processing block. Data will just pass thorough to the next slave.', mode='RW', value=False, localSet=lambda value: self.device.setUnwrapperDisable(value), localGet=self.device.getUnwrapperDisable)) # Command to reset the unwrapper self.add( pyrogue.LocalCommand(name='reset', description='Reset the unwrapper', function=self.device.resetUnwrapper))
def __init__(self, typeStr='UInt8[np]', hideData=True, value=numpy.zeros(shape=1, dtype=numpy.uint8, order='C'), **kwargs): pr.Device.__init__(self, **kwargs) ris.Slave.__init__(self) self.add( pr.LocalVariable(name='RxEnable', value=True, description='Frame Rx Enable')) self.add( pr.LocalVariable(name='FrameCount', value=0, pollInterval=1, description='Frame Rx Counter')) self.add( pr.LocalVariable(name='ErrorCount', value=0, pollInterval=1, description='Frame Error Counter')) self.add( pr.LocalVariable(name='ByteCount', value=0, pollInterval=1, description='Byte Rx Counter')) self.add( pr.LocalVariable(name='Updated', value=False, description='Data has been updated flag')) self.add( pr.LocalVariable(name='Data', typeStr=typeStr, value=value, hidden=hideData, description='Data Frame Container'))
def __init__(self, name="AppTop", description="Common Application Top Level", numRxLanes=[0, 0], numTxLanes=[0, 0], enJesdDrp=False, numSigGen=[0, 0], sizeSigGen=[0, 0], modeSigGen=[False, False], numWaveformBuffers=4, **kwargs): super().__init__(name=name, description=description, **kwargs) ############################## # Variables ############################## self._numRxLanes = numRxLanes self._numTxLanes = numTxLanes self._numSigGen = numSigGen self._sizeSigGen = sizeSigGen self._init = False self.add( pr.LocalVariable( name="BypassSysRefMinMax", description= "Used to override the SysRefPeriodmin != SysRefPeriodmax error flag", mode="RW", value=False, )) self.add( pr.LocalVariable( name='JesdHealthStatus', mode='RO', localGet=lambda: self.JesdHealth(), value=False, pollInterval= 0, # 0 by default for SMuRF because already have a function to check this status which is called from the high level application )) ############################## # Devices ############################## for i in range(2): self.add( daqMuxV2.DaqMuxV2( name=f'DaqMuxV2[{i}]', offset=0x20000000 + (i * 0x10000000), numBuffers=numWaveformBuffers, expand=False, )) for i in range(2): if ((numRxLanes[i] > 0) or (numTxLanes[i] > 0)): self.add( AppTopJesd( name=f'AppTopJesd[{i}]', offset=0x40000000 + (i * 0x10000000), numRxLanes=numRxLanes[i], numTxLanes=numTxLanes[i], enJesdDrp=enJesdDrp, expand=True, )) for i in range(2): if ((numSigGen[i] > 0) and (sizeSigGen[i] > 0)): self.add( dacSigGen.DacSigGen( name=f'DacSigGen[{i}]', offset=0x60000000 + (i * 0x10000000), numOfChs=numSigGen[i], buffSize=sizeSigGen[i], fillMode=modeSigGen[i], expand=False, )) @self.command(value='', description="AppTop JesdHealth() cmd") def JesdHealth(arg): ############# # Get devices ############# jesdRxDevices = self.find(typ=jesd.JesdRx) jesdTxDevices = self.find(typ=jesd.JesdTx) dacDevices = self.find(typ=ti.Dac38J84) dacEnables = [dac.enable.get() for dac in dacDevices] ################## ## Local Variables ################## maxRxCnt = 4 if (self._init) else 0 ########################### # JESD Link Health Checking ########################### linkLock = True if (self._init): for en, dac in zip(dacEnables, dacDevices): dac.enable.set(True) for ch in dac.LinkErrCnt: ###################################################################### if (dac.LinkErrCnt[ch].get() != 0): print( f'AppTop.Init(): {dac.path}.LinkErrCnt[{ch}] = {dac.LinkErrCnt[ch].value()}' ) linkLock = False ###################################################################### if (dac.ReadFifoEmpty[ch].get() != 0): print( f'AppTop.Init(): {dac.path}.ReadFifoEmpty[{ch}] = {dac.ReadFifoEmpty[ch].value()}' ) linkLock = False ###################################################################### if (dac.ReadFifoUnderflow[ch].get() != 0): print( f'AppTop.Init(): {dac.path}.ReadFifoUnderflow[{ch}] = {dac.ReadFifoUnderflow[ch].value()}' ) linkLock = False ###################################################################### if (dac.ReadFifoFull[ch].get() != 0): print( f'AppTop.Init(): {dac.path}.ReadFifoFull[{ch}] = {dac.ReadFifoFull[ch].value()}' ) linkLock = False ###################################################################### if (dac.ReadFifoOverflow[ch].get() != 0): print( f'AppTop.Init(): {dac.path}.ReadFifoOverflow[{ch}] = {dac.ReadFifoOverflow[ch].value()}' ) linkLock = False ###################################################################### if (dac.DispErr[ch].get() != 0): print( f'AppTop.Init(): {dac.path}.DispErr[{ch}] = {dac.DispErr[ch].value()}' ) linkLock = False ###################################################################### if (dac.NotitableErr[ch].get() != 0): print( f'AppTop.Init(): {dac.path}.NotitableErr[{ch}] = {dac.NotitableErr[ch].value()}' ) linkLock = False ###################################################################### if (dac.CodeSyncErr[ch].get() != 0): print( f'AppTop.Init(): {dac.path}.CodeSyncErr[{ch}] = {dac.CodeSyncErr[ch].value()}' ) linkLock = False ###################################################################### if (dac.FirstDataMatchErr[ch].get() != 0): print( f'AppTop.Init(): {dac.path}.FirstDataMatchErr[{ch}] = {dac.FirstDataMatchErr[ch].value()}' ) linkLock = False ###################################################################### if (dac.ElasticBuffOverflow[ch].get() != 0): print( f'AppTop.Init(): {dac.path}.ElasticBuffOverflow[{ch}] = {dac.ElasticBuffOverflow[ch].value()}' ) linkLock = False ###################################################################### if (dac.LinkConfigErr[ch].get() != 0): print( f'AppTop.Init(): {dac.path}.LinkConfigErr[{ch}] = {dac.LinkConfigErr[ch].value()}' ) linkLock = False ###################################################################### if (dac.FrameAlignErr[ch].get() != 0): print( f'AppTop.Init(): {dac.path}.FrameAlignErr[{ch}] = {dac.FrameAlignErr[ch].value()}' ) linkLock = False ###################################################################### if (dac.MultiFrameAlignErr[ch].get() != 0): print( f'AppTop.Init(): {dac.path}.MultiFrameAlignErr[{ch}] = {dac.MultiFrameAlignErr[ch].value()}' ) linkLock = False ###################################################################### dac.enable.set(en) if (self._init): time.sleep(2.000) for tx in jesdTxDevices: ###################################################################### if (tx.SysRefPeriodmin.get() != tx.SysRefPeriodmax.get()): if self.BypassSysRefMinMax.value() is False: print( f'AppTop.Init().{tx.path}: Link Not Locked: SysRefPeriodmin = {tx.SysRefPeriodmin.value()}, SysRefPeriodmax = {tx.SysRefPeriodmax.value()}' ) linkLock = False else: print( f'AppTop.Init().{tx.path}: Warning: SysRefPeriodmin = {tx.SysRefPeriodmin.value()}, SysRefPeriodmax = {tx.SysRefPeriodmax.value()}' ) ###################################################################### if (tx.DataValid.get() != tx.Enable.get()): print( f'AppTop.Init(): Link Not Locked: {tx.path}.DataValid = {tx.DataValid.value()} ' ) linkLock = False ###################################################################### if (self._init): ################################################################## for ch in tx.StatusValidCnt: if (tx.StatusValidCnt[ch].get() > 0): print( f'AppTop.Init(): {tx.path}.StatusValidCnt[{ch}] = {tx.StatusValidCnt[ch].value()}' ) linkLock = False ################################################################## tx.CmdClearErrors() ################################################################## ###################################################################### for rx in jesdRxDevices: ###################################################################### if (rx.SysRefPeriodmin.get() != rx.SysRefPeriodmax.get()): if self.BypassSysRefMinMax.value() is False: print( f'AppTop.Init().{rx.path}: Link Not Locked: SysRefPeriodmin = {rx.SysRefPeriodmin.value()}, SysRefPeriodmax = {rx.SysRefPeriodmax.value()}' ) linkLock = False else: print( f'AppTop.Init().{rx.path}: Warning: SysRefPeriodmin = {rx.SysRefPeriodmin.value()}, SysRefPeriodmax = {rx.SysRefPeriodmax.value()}' ) ###################################################################### if (rx.DataValid.get() != rx.Enable.get()): print( f'AppTop.Init(): Link Not Locked: {rx.path}.DataValid = {rx.DataValid.value()} ' ) linkLock = False ###################################################################### if (self._init): ################################################################## if (rx.PositionErr.get() != 0) or (rx.AlignErr.get() != 0): print( f'AppTop.Init().{rx.path}: Link Not Locked: PositionErr = {rx.PositionErr.value()}, AlignErr = {rx.AlignErr.value()}' ) linkLock = False ################################################################## for ch in rx.StatusValidCnt: if (rx.StatusValidCnt[ch].get() > maxRxCnt): print( f'AppTop.Init(): {rx.path}.StatusValidCnt[{ch}] = {rx.StatusValidCnt[ch].value()}' ) linkLock = False ################################################################## rx.CmdClearErrors() ################################################################## ###################################################################### # Return the result return linkLock @self.command(description="AppTop Init() cmd") def Init(): print(f'{self.path}.Init()') self._init = True ############# # Get devices ############# jesdRxDevices = self.find(typ=jesd.JesdRx) jesdTxDevices = self.find(typ=jesd.JesdTx) dacDevices = self.find(typ=ti.Dac38J84) sigGenDevices = self.find(typ=dacSigGen.DacSigGen) appCore = self.find(typ=AppCore) rxEnables = [rx.Enable.get() for rx in jesdRxDevices] txEnables = [tx.Enable.get() for tx in jesdTxDevices] dacEnables = [dac.enable.get() for dac in dacDevices] retryCnt = 0 retryCntMax = 8 while (retryCnt < retryCntMax): for rx in jesdRxDevices: rx.Enable.set(0) for tx in jesdTxDevices: tx.Enable.set(0) for core in appCore: core.Init() for rx in jesdRxDevices: rx.ResetGTs.set( 1) # tx.ResetGTs/rx.ResetGTs OR'd together in FW for tx in jesdTxDevices: tx.ResetGTs.set( 1) # tx.ResetGTs/rx.ResetGTs OR'd together in FW time.sleep(1.000) for tx in jesdTxDevices: tx.ResetGTs.set( 0) # tx.ResetGTs/rx.ResetGTs OR'd together in FW for rx in jesdRxDevices: rx.ResetGTs.set( 0) # tx.ResetGTs/rx.ResetGTs OR'd together in FW time.sleep(1.000) for en, tx in zip(txEnables, jesdTxDevices): tx.Enable.set(en) for en, rx in zip(rxEnables, jesdRxDevices): rx.CmdClearErrors() rx.Enable.set(en) time.sleep(2.000) for en, dac in zip(dacEnables, dacDevices): dac.enable.set(True) dac.Init() dac.ClearAlarms() dac.NcoSync() dac.ClearAlarms() dac.enable.set(en) for tx in jesdTxDevices: tx.CmdClearErrors() time.sleep(2.000) if (self.JesdHealth()): self._init = False break else: retryCnt += 1 if (retryCnt == retryCntMax): self._init = False raise pr.DeviceError( 'AppTop.Init(): Too many retries and giving up on retries' ) else: print( f'Re-executing AppTop.Init(): retryCnt = {retryCnt}' ) # Load the DAC signal generator for sigGen in sigGenDevices: if (sigGen.CsvFilePath.get() != ""): sigGen.LoadCsvFile("")
def __init__(self, simpleDisplay=True, advanceUser=False, **kwargs): super().__init__(size=(0x1000 << 2), **kwargs) self.add( pr.LocalVariable( name="CsvFilePath", description="Used if command's argument is empty", mode="RW", value="", )) ############################## # Commands ############################## @self.command( value='', description="Load the .CSV from CBPro.", ) def LoadCsvFile(arg): # Check if non-empty argument if (arg != ""): path = arg else: # Use the variable path instead path = self.CsvFilePath.get() # Check for .csv file if fnmatch.fnmatch(path, '*.csv'): click.secho(f'{self.path}.LoadCsvFile(): {path}', fg='green') else: click.secho(f'{self.path}.LoadCsvFile(): {path} is not .csv', fg='red') return # Power down during the configuration load self.Page0.PDN.set(True) # Open the .CSV file with open(path) as csvfile: reader = csv.reader(csvfile, delimiter=',', quoting=csv.QUOTE_NONE) # Loop through the rows in the CSV file for row in reader: if (row[0] != 'Address'): self._rawWrite( offset=(int(row[0], 16) << 2), data=int(row[1], 16), ) # Update local RemoteVariables and verify conflagration self.readBlocks(recurse=True) self.checkBlocks(recurse=True) # Execute the Page5.BW_UPDATE_PLL command self._rawWrite((0x500 << 2) | (0x14 << 2), 0x1) self._rawWrite((0x500 << 2) | (0x14 << 2), 0x0) # Power Up after the configuration load self.Page0.PDN.set(False) # Clear the internal error flags self.Page0.ClearIntErrFlag() ############################## # Devices ############################## self.add( silabs.Si5345Page0(offset=(0x000 << 2), simpleDisplay=simpleDisplay, expand=False)) self.add( pr.LinkVariable(name='Locked', description='Inverse of LOL', mode='RO', dependencies=[self.Page0.LOL], linkedGet=lambda: (False if self.Page0.LOL.value() else True)))
def __init__(self, name='AxiVersion', description='AXI-Lite Version Module', numUserConstants=0, **kwargs): super().__init__(name=name, description=description, **kwargs) ############################## # Variables ############################## self.add( pr.RemoteVariable( name='FpgaVersion', description='FPGA Firmware Version Number', offset=0x00, bitSize=32, bitOffset=0x00, base=pr.UInt, mode='RO', disp='{:#08x}', )) self.add( pr.RemoteVariable(name='ScratchPad', description='Register to test reads and writes', offset=0x04, bitSize=32, bitOffset=0x00, base=pr.UInt, mode='RW', disp='{:#08x}')) self.add( pr.RemoteVariable(name='UpTimeCnt', description='Number of seconds since last reset', hidden=True, offset=0x08, bitSize=32, bitOffset=0x00, base=pr.UInt, mode='RO', disp='{:d}', units='seconds', pollInterval=1)) self.add( pr.LinkVariable( name='UpTime', mode='RO', dependencies=[self.UpTimeCnt], linkedGet=lambda: str( datetime.timedelta(seconds=self.UpTimeCnt.value())))) self.add( pr.RemoteVariable( name='FpgaReloadHalt', description='Used to halt automatic reloads via AxiVersion', offset=0x100, bitSize=1, bitOffset=0x00, base=pr.UInt, mode='RW', )) self.add( pr.RemoteCommand( name='FpgaReload', description='Optional Reload the FPGA from the attached PROM', offset=0x104, bitSize=1, bitOffset=0x00, base=pr.UInt, function=lambda cmd: cmd.post(1))) self.add( pr.RemoteVariable( name='FpgaReloadAddress', description='Reload start address', offset=0x108, bitSize=32, bitOffset=0x00, base=pr.UInt, mode='RW', )) @self.command(hidden=True) def FpgaReloadAtAddress(arg): self.FpgaReloadAddress.set(arg) self.FpgaReload() self.add( pr.RemoteVariable( name='UserReset', description='Optional User Reset', offset=0x10C, bitSize=1, bitOffset=0x00, base=pr.UInt, mode='RW', )) self.add( pr.RemoteVariable( name='FdSerial', description='Board ID value read from DS2411 chip', offset=0x300, bitSize=64, bitOffset=0x00, base=pr.UInt, mode='RO', )) self.addRemoteVariables( name='UserConstants', description='Optional user input values', offset=0x400, bitSize=32, bitOffset=0x00, base=pr.UInt, mode='RO', number=numUserConstants, stride=4, hidden=True, ) self.add( pr.RemoteVariable( name='DeviceId', description='Device Identification (configued by generic)', offset=0x500, bitSize=32, bitOffset=0x00, base=pr.UInt, mode='RO', )) self.add( pr.RemoteVariable( name='GitHash', description='GIT SHA-1 Hash', offset=0x600, bitSize=160, bitOffset=0x00, base=pr.UInt, mode='RO', hidden=True, )) self.add( pr.LinkVariable(name='GitHashShort', dependencies=[self.GitHash], disp='{:07x}', linkedGet=lambda: self.GitHash.value() >> 132)) self.add( pr.RemoteVariable( name='DeviceDna', description='Xilinx Device DNA value burned into FPGA', offset=0x700, bitSize=128, bitOffset=0x00, base=pr.UInt, mode='RO', )) self.add( pr.RemoteVariable( name='BuildStamp', description='Firmware Build String', offset=0x800, bitSize=8 * 256, bitOffset=0x00, base=pr.String, mode='RO', hidden=True, )) def parseBuildStamp(var, value, disp): p = parse.parse( "{ImageName}: {BuildEnv}, {BuildServer}, Built {BuildDate} by {Builder}", value.strip()) if p is not None: for k, v in p.named.items(): self.node(k).set(v) self.add(pr.LocalVariable(name='ImageName', mode='RO', value='')) self.add(pr.LocalVariable(name='BuildEnv', mode='RO', value='')) self.add(pr.LocalVariable(name='BuildServer', mode='RO', value='')) self.add(pr.LocalVariable(name='BuildDate', mode='RO', value='')) self.add(pr.LocalVariable(name='Builder', mode='RO', value='')) self.BuildStamp.addListener(parseBuildStamp)
def __init__(self, *, width=None, checkPayload=True, taps=None, stream=None, **kwargs): pyrogue.Device.__init__(self, description='PRBS Software Receiver', **kwargs) self._prbs = rogue.utilities.Prbs() if width is not None: self._prbs.setWidth(width) if taps is not None: self._prbs.setTaps(taps) if stream is not None: pyrogue.streamConnect(stream, self) self.add( pyrogue.LocalVariable( name='rxEnable', description='RX Enable', mode='RW', value=True, localGet=lambda: self._prbs.getRxEnable(), localSet=lambda value: self._prbs.setRxEnable(value))) self.add( pyrogue.LocalVariable(name='rxErrors', description='RX Error Count', mode='RO', pollInterval=1, value=0, typeStr='UInt32', localGet=self._prbs.getRxErrors)) self.add( pyrogue.LocalVariable(name='rxCount', description='RX Count', mode='RO', pollInterval=1, value=0, typeStr='UInt32', localGet=self._prbs.getRxCount)) self.add( pyrogue.LocalVariable(name='rxBytes', description='RX Bytes', mode='RO', pollInterval=1, value=0, typeStr='UInt32', localGet=self._prbs.getRxBytes)) self.add( pyrogue.LocalVariable(name='rxRate', description='RX Rate', disp="{:.3e}", mode='RO', pollInterval=1, value=0.0, units='Frames/s', localGet=self._prbs.getRxRate)) self.add( pyrogue.LocalVariable(name='rxBw', description='RX BW', disp="{:.3e}", mode='RO', pollInterval=1, value=0.0, units='Bytes/s', localGet=self._prbs.getRxBw)) self.add( pyrogue.LocalVariable(name='checkPayload', description='Payload Check Enable', mode='RW', value=checkPayload, localSet=self._plEnable))
def __init__(self, name, device, **kwargs): pyrogue.Device.__init__(self, name=name, description='SMuRF Data GeneralAnalogFilter', **kwargs) self.device = device # Add "Disable" variable self.add( pyrogue.LocalVariable( name='Disable', description= 'Disable the processing block. Data will just pass thorough to the next slave.', mode='RW', value=False, localSet=lambda value: self.device.setFilterDisable(value), localGet=self.device.getFilterDisable)) # Add the filter order variable self.add( pyrogue.LocalVariable( name='Order', description='Filter order', mode='RW', value=4, localSet=lambda value: self.device.setOrder(value), localGet=self.device.getOrder)) # Add the filter gain variable self.add( pyrogue.LocalVariable( name='Gain', description='Filter gain', mode='RW', value=1.0, localSet=lambda value: self.device.setGain(value), localGet=self.device.getGain)) # Add the filter a coefficients variable # Rogue doesn't allow to have an empty list here. Also, the EPICS PV is created # with the initial size of this list, and can not be changed later, so we are doing # it big enough at this point (we are probably not going to use an order > 10) self.add( pyrogue.LocalVariable( name='A', description='Filter a coefficients', mode='RW', value=[1.0, -3.74145562, 5.25726624, -3.28776591, 0.77203984] + [0] * 11, localSet=lambda value: self.device.setA(value), localGet=self.device.getA)) # Add the filter b coefficients variable # Rogue doesn't allow to have an empty list here. Also, the EPICS PV is created # with the initial size of this list, and can not be changed later, so we are doing # it big enough at this point (we are probably not going to use an order > 10) self.add( pyrogue.LocalVariable( name='B', description='Filter b coefficients', mode='RW', value=[ 5.28396689e-06, 2.11358676e-05, 3.17038014e-05, 2.11358676e-05, 5.28396689e-06 ] + [0] * 11, localSet=lambda value: self.device.setB(value), localGet=self.device.getB)) # Command to reset the filter self.add( pyrogue.LocalCommand(name='reset', description='Reset the unwrapper', function=self.device.resetFilter))
def __init__(self, *, host, port, size=None, jumbo=False, wait=True, packVer=1, pollInterval=1, **kwargs): super(self.__class__, self).__init__(**kwargs) self._host = host self._port = port if size is not None: self._log.critical("Size arg is deprecated. Use jumbo arg instead") self._udp = rogue.protocols.udp.Client(host, port, jumbo) self._rssi = rogue.protocols.rssi.Client(self._udp.maxPayload()) self._udp.setRxBufferCount(self._rssi.getRemMaxSegment()) if packVer == 2: self._pack = rogue.protocols.packetizer.CoreV2( False, True) # ibCRC = False, obCRC = True else: self._pack = rogue.protocols.packetizer.Core() self._udp._setSlave(self._rssi.transport()) self._rssi.transport()._setSlave(self._udp) self._rssi.application()._setSlave(self._pack.transport()) self._pack.transport()._setSlave(self._rssi.application()) if wait: curr = int(time.time()) last = curr while not self._rssi.getOpen(): time.sleep(.0001) curr = int(time.time()) if last != curr: self._log.warning( "host=%s, port=%d -> Establishing link ..." % (host, port)) last = curr # Add variables self.add( pr.LocalVariable( name='rssiOpen', mode='RO', value=False, localGet=lambda: self._rssi.getOpen(), pollInterval=pollInterval, )) self.add( pr.LocalVariable( name='rssiDownCount', mode='RO', value=0, localGet=lambda: self._rssi.getDownCount(), pollInterval=pollInterval, )) self.add( pr.LocalVariable( name='rssiDropCount', mode='RO', value=0, localGet=lambda: self._rssi.getDropCount(), pollInterval=pollInterval, )) self.add( pr.LocalVariable( name='rssiRetranCount', mode='RO', value=0, localGet=lambda: self._rssi.getRetranCount(), pollInterval=pollInterval, )) self.add( pr.LocalVariable( name='locBusy', mode='RO', value=False, localGet=lambda: self._rssi.getLocBusy(), hidden=True, pollInterval=pollInterval, )) self.add( pr.LocalVariable( name='locBusyCnt', mode='RO', value=0, localGet=lambda: self._rssi.getLocBusyCnt(), pollInterval=pollInterval, )) self.add( pr.LocalVariable( name='remBusy', mode='RO', value=False, localGet=lambda: self._rssi.getRemBusy(), hidden=True, pollInterval=pollInterval, )) self.add( pr.LocalVariable( name='remBusyCnt', mode='RO', value=0, localGet=lambda: self._rssi.getRemBusyCnt(), pollInterval=pollInterval, )) self.add( pr.LocalVariable( name='maxRetran', mode='RO', value=0, localGet=lambda: self._rssi.getMaxRetran(), pollInterval=pollInterval, )) self.add( pr.LocalVariable( name='remMaxBuffers', mode='RO', value=0, localGet=lambda: self._rssi.getRemMaxBuffers(), pollInterval=pollInterval, )) self.add( pr.LocalVariable( name='remMaxSegment', mode='RO', value=0, localGet=lambda: self._rssi.getRemMaxSegment(), units='Bytes', pollInterval=pollInterval, )) self.add( pr.LocalVariable( name='retranTout', mode='RO', value=0, localGet=lambda: self._rssi.getRetranTout(), units='ms', pollInterval=pollInterval, )) self.add( pr.LocalVariable( name='cumAckTout', mode='RO', value=0, localGet=lambda: self._rssi.getCumAckTout(), units='ms', pollInterval=pollInterval, )) self.add( pr.LocalVariable( name='nullTout', mode='RO', value=0, localGet=lambda: self._rssi.getNullTout(), units='ms', pollInterval=pollInterval, )) self.add( pr.LocalVariable( name='maxCumAck', mode='RO', value=0, localGet=lambda: self._rssi.getMaxCumAck(), pollInterval=pollInterval, )) self.add( pr.LocalVariable( name='segmentSize', mode='RO', value=0, localGet=lambda: self._rssi.getSegmentSize(), units='Bytes', pollInterval=pollInterval, ))
def __init__(self): self._scnt = 0 self._sdata = np.zeros(100, dtype=np.float64) pyrogue.Root.__init__(self, name='dummyTree', description="Dummy tree for example", timeout=2.0, pollEn=True, serverPort=0) # Use a memory space emulator sim = rogue.interfaces.memory.Emulate(4, 0x1000) sim.setName("SimSlave") self.addInterface(sim) # Add Device self.add( test_device.AxiVersion(memBase=sim, guiGroup='TestGroup', offset=0x0)) self.add(test_large.TestLarge(guiGroup='TestGroup')) # Add Data Writer self._prbsTx = pyrogue.utilities.prbs.PrbsTx() self.add(self._prbsTx) self._fw = pyrogue.utilities.fileio.StreamWriter() self.add(self._fw) self._prbsTx >> self._fw.getChannel(0) # Add Data Receiver drx = pyrogue.DataReceiver() self._prbsTx >> drx self.add(drx) # Add Run Control self.add(pyrogue.RunControl()) # Add process controller p = pyrogue.Process() p.add(pyrogue.LocalVariable(name='Test1', value='')) p.add(pyrogue.LocalVariable(name='Test2', value='')) self.add(p) #self.AxiVersion.AlarmTest.addToGroup('NoServe') self.add( pyrogue.LocalVariable(name='TestPlot', mode='RO', pollInterval=1.0, localGet=self._mySin, minimum=-1.0, maximum=1.0, disp='{:1.2f}', value=0.0)) self.add( pyrogue.LocalVariable(name='TestXAxis', mode='RO', pollInterval=1.0, localGet=self._myXAxis, disp='{:1.2f}', value=1.0)) self.add( pyrogue.LocalVariable(name='TestArray', mode='RO', pollInterval=1.0, localGet=self._myArray, disp='{:1.2f}')) #value = np.zeros(100,dtype=np.float64))) #self.add(pyrogue.LocalVariable( # name = 'Test/Slash', # mode = 'RW', # value = '')) #self.add(pyrogue.LocalVariable( # name = 'Test.Dot', # mode = 'RW', # value = '')) #self.add(pyrogue.LocalVariable( # name = 'Test\BackSlash', # mode = 'RW', # value = '')) #self.add(pyrogue.LocalVariable( # name = 'Test&And', # mode = 'RW', # value = '')) #self.rudpServer = pyrogue.protocols.UdpRssiPack( # name = 'UdpServer', # port = 8192, # jumbo = True, # server = True, # expand = False, # ) #self.add(self.rudpServer) # Create the ETH interface @ IP Address = args.dev #self.rudpClient = pyrogue.protocols.UdpRssiPack( # name = 'UdpClient', # host = "127.0.0.1", # port = 8192, # jumbo = True, # expand = False, # ) #self.add(self.rudpClient) #self.prbsTx = pyrogue.utilities.prbs.PrbsTx() #self.add(self.prbsTx) #pyrogue.streamConnect(self.prbsTx,self.rudpClient.application(0)) if args.epics3: self._epics = pyrogue.protocols.epics.EpicsCaServer(base="test", root=self) self.addProtocol(self._epics) if args.epics4: self._epics4 = pyrogue.protocols.epicsV4.EpicsPvServer( base="test", root=self, incGroups=None, excGroups=None) self.addProtocol(self._epics4)
def __init__(self, *, sendCount=False, width=None, taps=None, stream=None, **kwargs): pyrogue.Device.__init__(self, description='PRBS Software Transmitter', **kwargs) self._prbs = rogue.utilities.Prbs() if width is not None: self._prbs.setWidth(width) if taps is not None: self._prbs.setTaps(taps) if stream is not None: pyrogue.streamConnect(self, stream) self._prbs.sendCount(sendCount) self.add( pyrogue.LocalVariable(name='txSize', description='PRBS Frame Size', units='Bytes', localSet=self._txSize, mode='RW', value=1024, typeStr='UInt32')) self.add( pyrogue.LocalVariable(name='txEnable', description='PRBS Run Enable', mode='RW', value=False, localSet=self._txEnable)) self.add( pyrogue.LocalCommand(name='genFrame', description='Generate n frames', value=1, function=self._genFrame)) self.add( pyrogue.LocalVariable(name='txErrors', description='TX Error Count', mode='RO', pollInterval=1, value=0, typeStr='UInt32', localGet=self._prbs.getTxErrors)) self.add( pyrogue.LocalVariable(name='txCount', description='TX Count', mode='RO', pollInterval=1, value=0, typeStr='UInt32', localGet=self._prbs.getTxCount)) self.add( pyrogue.LocalVariable(name='txBytes', description='TX Bytes', mode='RO', pollInterval=1, value=0, typeStr='UInt32', localGet=self._prbs.getTxBytes)) self.add( pyrogue.LocalVariable(name='genPayload', description='Payload Generate Enable', mode='RW', value=True, localSet=self._plEnable)) self.add( pyrogue.LocalVariable(name='txRate', description='TX Rate', disp="{:.3e}", mode='RO', pollInterval=1, value=0.0, units='Frames/s', localGet=self._prbs.getTxRate)) self.add( pyrogue.LocalVariable(name='txBw', description='TX BW', disp="{:.3e}", mode='RO', pollInterval=1, value=0.0, units='Bytes/s', localGet=self._prbs.getTxBw))