From 75957cae170151f863485c6a16075af2d4bed9df Mon Sep 17 00:00:00 2001 From: Larry Ruckman Date: Sat, 6 Jul 2024 14:11:46 -0700 Subject: [PATCH] adding back changes to _Device.py, _AxiStreamDmaMon.py and pydm --- python/pyrogue/_Device.py | 3 +++ .../pyrogue/hardware/axi/_AxiStreamDmaMon.py | 19 ++++++++++++++++++ python/pyrogue/pydm/__init__.py | 20 ++++++++++++++++++- 3 files changed, 41 insertions(+), 1 deletion(-) diff --git a/python/pyrogue/_Device.py b/python/pyrogue/_Device.py index efb378e7f..efaab515e 100644 --- a/python/pyrogue/_Device.py +++ b/python/pyrogue/_Device.py @@ -709,10 +709,13 @@ def _buildBlocks(self): # Align to min access, create list of remote variables elif isinstance(n,pr.RemoteVariable) and n.offset is not None: + self._log.info(f"Before Shift variable {n.name} offset={n.offset} bitSize={n.bitSize} bytes={n.varBytes}") n._updatePath(n.path) n._shiftOffsetDown(n.offset % blkSize, blkSize) remVars += [n] + self._log.info(f"Creating variable {n.name} offset={n.offset} bitSize={n.bitSize} bytes={n.varBytes}") + # Sort var list by offset, size remVars.sort(key=lambda x: (x.offset, x.varBytes)) blocks = [] diff --git a/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py b/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py index 2e79aacd6..9434aaf39 100644 --- a/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py +++ b/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py @@ -156,6 +156,25 @@ def __init__(self, axiStreamDma, pollInterval=1, **kwargs): self._dma = axiStreamDma # Add variables + self.add(pr.LocalVariable( + name = 'GitVersion', + description = 'DMA\'s Driver GIT Version string', + mode = 'RO', + value = '', + localGet = lambda: self._dma.getGitVersion(), + )) + + self.add(pr.LocalVariable( + name = 'ApiVersion', + description = 'DMA\'s Driver API Version', + mode = 'RO', + value = 0x0, + typeStr = 'UInt8', + units = 'Bytes', + disp = '{:#x}', + localGet = lambda: self._dma.getApiVersion(), + )) + self.add(pr.LocalVariable( name = 'BuffSize', description = 'Size of buffers (RX/TX)', diff --git a/python/pyrogue/pydm/__init__.py b/python/pyrogue/pydm/__init__.py index da246ef3c..e4ca62d1f 100644 --- a/python/pyrogue/pydm/__init__.py +++ b/python/pyrogue/pydm/__init__.py @@ -11,20 +11,32 @@ #----------------------------------------------------------------------------- import os import sys +import signal import pydm import pyrogue import pyrogue.pydm.data_plugins.rogue_plugin +# Define a signal handler to ensure the application quits gracefully +def pydmSignalHandler(sig, frame): + app = pydm.PyDMApplication.instance() + if app is not None: + app.closeAllWindows() + +# Function to run the PyDM application with specified parameters def runPyDM(serverList='localhost:9090', ui=None, title=None, sizeX=800, sizeY=1000, maxListExpand=5, maxListSize=100): + # Set the ROGUE_SERVERS environment variable os.environ['ROGUE_SERVERS'] = serverList + # Set the UI file to a default value if not provided if ui is None or ui == '': ui = os.path.dirname(os.path.abspath(__file__)) + '/pydmTop.py' + # Set the title to a default value if not provided if title is None: title = "Rogue Server: {}".format(os.getenv('ROGUE_SERVERS')) + # Prepare command line arguments args = [] args.append(f"sizeX={sizeX}") args.append(f"sizeY={sizeY}") @@ -32,13 +44,19 @@ def runPyDM(serverList='localhost:9090', ui=None, title=None, sizeX=800, sizeY=1 args.append(f"maxListExpand={maxListExpand}") args.append(f"maxListSize={maxListSize}") + # Initialize the PyDM application with specified parameters app = pydm.PyDMApplication(ui_file=ui, command_line_args=args, hide_nav_bar=True, hide_menu_bar=True, hide_status_bar=True) + # Setup signal handling for CTRL+C and SIGTERM for handling termination signal + signal.signal(signal.SIGINT, pydmSignalHandler) + signal.signal(signal.SIGTERM, pydmSignalHandler) + + # Print message indicating the GUI is running and how to exit print(f"Running GUI. Close window, hit cntrl-c or send SIGTERM to {os.getpid()} to exit.") + # Run the PyDM application app.exec() -