diff --git a/.clang-format b/.clang-format index 319be06cf..c7881cb4e 100644 --- a/.clang-format +++ b/.clang-format @@ -15,6 +15,7 @@ AlignConsecutiveAssignments: true AlignConsecutiveMacros: true AccessModifierOffset: -2 SortIncludes: true +IndentPPDirectives: BeforeHash IncludeBlocks: Regroup IncludeCategories: # Rogue Directives.h goes first diff --git a/.github/workflows/rogue_ci.yml b/.github/workflows/rogue_ci.yml index 81487af53..2ed6874eb 100644 --- a/.github/workflows/rogue_ci.yml +++ b/.github/workflows/rogue_ci.yml @@ -34,20 +34,26 @@ jobs: cache: 'pip' cache-dependency-path: 'pip_requirements.txt' + # Install dependencies - name: Install dependencies run: | sudo apt-get update sudo apt-get install doxygen doxygen-doc libzmq3-dev libboost-all-dev pip install -r pip_requirements.txt - # Flake 8 check - - name: Flake8 Tests + # Python Linter + - name: Python Linter run: | python -m compileall -f ./python/ flake8 --count ./python/ python -m compileall -f ./tests flake8 --count ./tests/ + # C++ Linter + - name: C++ Linter + run: | + find . -name '*.h' -o -name '*.cpp' | xargs cpplint + # Rogue - name: Build Rogue run: | @@ -99,6 +105,8 @@ jobs: github_token: ${{ secrets.GH_TOKEN }} publish_dir: docs/build/html +# ---------------------------------------------------------------------------- + small_build_test: name: Small Build Test runs-on: ubuntu-20.04 @@ -122,126 +130,34 @@ jobs: make -j4 install +# ---------------------------------------------------------------------------- + gen_release: - name: Generate Release - runs-on: ubuntu-20.04 needs: [full_build_test, small_build_test] - if: startsWith(github.ref, 'refs/tags/') - steps: + uses: slaclab/ruckus/.github/workflows/gen_release.yml@main + with: + version: '1.0.0' + secrets: + GH_TOKEN: ${{ secrets.GH_TOKEN }} - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - uses: actions/setup-python@v4 - with: - python-version: 3.8 - - - name: Get Image Information - id: get_image_info - run: | - echo tag=`git describe --tags` >> ${GITHUB_OUTPUT} - - - name: Get Ruckus - run: | - git clone https://github.com/slaclab/ruckus.git - python -m pip install --upgrade pip - pip install -r ruckus/scripts/pip_requirements.txt - - - name: Gen Release - env: - TRAVIS_REPO_SLUG: ${{ github.repository }} - TRAVIS_TAG: ${{ steps.get_image_info.outputs.tag }} - GH_REPO_TOKEN: ${{ secrets.GH_TOKEN }} - run: | - python ruckus/scripts/releaseGen.py +# ---------------------------------------------------------------------------- - conda_build: - name: Anaconda Build + conda_build_lib: needs: [full_build_test, small_build_test] - if: startsWith(github.ref, 'refs/tags/') - runs-on: ubuntu-20.04 - steps: - - # This step checks out a copy of your repository. - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - uses: actions/setup-python@v4 - with: - python-version: 3.8 - - - name: Setup anaconda - run: | - cd ${HOME} - wget -O miniconda.sh https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh - bash miniconda.sh -b -p ${HOME}/miniconda - export PATH="${HOME}/miniconda/bin:$PATH" - source ${HOME}/miniconda/etc/profile.d/conda.sh - conda config --set always_yes yes - conda config --set channel_priority strict - conda install -n base conda-libmamba-solver - conda config --set solver libmamba - conda install conda-build anaconda-client conda-verify - conda update -q conda conda-build - conda update --all - - - name: Get Image Information - id: get_image_info - env: - CONDA_UPLOAD_TOKEN_TAG: ${{ secrets.CONDA_UPLOAD_TOKEN_TAG }} - run: | - echo token=${CONDA_UPLOAD_TOKEN_TAG} >> ${GITHUB_OUTPUT} - - - name: Build - run: | - export PATH="${HOME}/miniconda/bin:$PATH" - source ${HOME}/miniconda/etc/profile.d/conda.sh - conda build conda-recipe --output-folder bld-dir -c conda-forge + uses: slaclab/ruckus/.github/workflows/conda_build_lib.yml@main + with: + version: '1.0.0' + secrets: + CONDA_UPLOAD_TOKEN_TAG: ${{ secrets.CONDA_UPLOAD_TOKEN_TAG }} - - name: Upload - run: | - export PATH="${HOME}/miniconda/bin:$PATH" - source ${HOME}/miniconda/etc/profile.d/conda.sh - anaconda -t ${{ steps.get_image_info.outputs.token }} upload --force bld-dir/*/*.tar.bz2 +# ---------------------------------------------------------------------------- - docker_build: - name: Docker Build - runs-on: ubuntu-20.04 + docker_build_lib: needs: [full_build_test, small_build_test] - if: startsWith(github.ref, 'refs/tags/') - steps: - - # This step checks out a copy of your repository. - - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Get Image Information - id: get_image_info - run: | - echo tag=`git describe --tags` >> ${GITHUB_OUTPUT} - echo branch=`echo ${GITHUB_REF} | awk 'BEGIN { FS = "/" } ; { print $3 }'` >> ${GITHUB_OUTPUT} - - # Setup docker build environment - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v1 - - # Login to Dockerhub - - name: Login to Dockerhub - uses: docker/login-action@v1 - with: - username: tidair - password: ${{ secrets.DOCKERHUB_TOKEN }} - - # Build and push the docker image - - name: Build and push image to Dockerhub - uses: docker/build-push-action@v2 - with: - context: . - file: ./Dockerfile - push: true - tags: tidair/rogue:${{ steps.get_image_info.outputs.tag }}, tidair/rogue:latest - build-args: branch=${{ steps.get_image_info.outputs.branch }} + uses: slaclab/ruckus/.github/workflows/docker_build_lib.yml@main + with: + version: '1.0.0' + secrets: + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} +# ---------------------------------------------------------------------------- diff --git a/CMakeLists.txt b/CMakeLists.txt index ec0182829..ca4ee1cc1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,7 @@ if (DEFINED ENV{CONDA_PREFIX}) endif() # Check cmake version -cmake_minimum_required(VERSION 3.5) +cmake_minimum_required(VERSION 3.15) include(InstallRequiredSystemLibraries) # Set default release type @@ -45,8 +45,10 @@ SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH FALSE) # Boost + Python ##################################### if ( NOT NO_PYTHON ) - find_package(PythonInterp 3 QUIET REQUIRED) - find_package(PythonLibs 3 QUIET REQUIRED) + + # Find newest python interpreter first + set(Python3_FIND_STRATEGY "LOCATION") + find_package(Python3 QUIET REQUIRED COMPONENTS Interpreter Development) # Find Numpy execute_process( @@ -66,21 +68,17 @@ if ( NOT NO_PYTHON ) # Hint for boost on anaconda if (DEFINED ENV{CONDA_PREFIX}) - set(BOOST_ROOT $ENV{CONDA_PREFIX}) - - # SLAC AFS custom path - elseif (DEFINED ENV{BOOST_PATH}) - set(BOOST_ROOT $ENV{BOOST_PATH}) + set(Boost_ROOT $ENV{CONDA_PREFIX}) endif() # libboost_python3.7 style libraries - message("Looking for libboost_python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}") - FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}) + message("Looking for libboost_python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}") + FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}) # libboost_python3 style libraries if (NOT Boost_FOUND) - message("Looking for libboost_python${PYTHON_VERSION_MAJOR}") - FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python${PYTHON_VERSION_MAJOR}) + message("Looking for libboost_python${Python3_VERSION_MAJOR}") + FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python${Python3_VERSION_MAJOR}) endif() # libboost_python style libraries @@ -91,14 +89,14 @@ if ( NOT NO_PYTHON ) # libboost_python-py37 style libraries if (NOT Boost_FOUND) - message("Looking for libboost_python-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}") - FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}) + message("Looking for libboost_python-py${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}") + FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python-py${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}) endif() # libboost_python3-py37 style libraries if (NOT Boost_FOUND) - message("Looking for libboost_python3-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}") - FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python3-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}) + message("Looking for libboost_python3-py${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}") + FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python3-py${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}) endif() # Nothing worked @@ -233,7 +231,7 @@ configure_file ( include_directories(${PROJECT_SOURCE_DIR}/include) include_directories(${PROJECT_BINARY_DIR}) include_directories(system ${Boost_INCLUDE_DIRS}) -include_directories(system ${PYTHON_INCLUDE_DIRS}) +include_directories(system ${Python3_INCLUDE_DIRS}) include_directories(system ${Python3_NumPy_INCLUDE_DIRS}) include_directories(system ${ZeroMQ_INCLUDE_DIR}) include_directories(system ${BZIP2_INCLUDE_DIR}) @@ -267,7 +265,7 @@ TARGET_LINK_LIBRARIES(rogue-core-shared PUBLIC ${BZIP2_LIBRARIES}) if (APPLE) set_target_properties(rogue-core-shared PROPERTIES LINK_FLAGS "-undefined dynamic_lookup") else() - TARGET_LINK_LIBRARIES(rogue-core-shared PUBLIC ${PYTHON_LIBRARIES}) + TARGET_LINK_LIBRARIES(rogue-core-shared PUBLIC ${Python3_LIBRARIES}) TARGET_LINK_LIBRARIES(rogue-core-shared PUBLIC rt) endif() @@ -281,7 +279,7 @@ if(STATIC_LIB) TARGET_LINK_LIBRARIES(rogue-core-static PUBLIC ${ZeroMQ_LIBRARY}) TARGET_LINK_LIBRARIES(rogue-core-static PUBLIC ${EPICS_LIBRARIES}) TARGET_LINK_LIBRARIES(rogue-core-static PUBLIC ${BZIP2_LIBRARIES}) - TARGET_LINK_LIBRARIES(rogue-core-static PUBLIC ${PYTHON_LIBRARIES}) + TARGET_LINK_LIBRARIES(rogue-core-static PUBLIC ${Python3_LIBRARIES}) TARGET_LINK_LIBRARIES(rogue-core-static PUBLIC rt) endif() @@ -417,7 +415,7 @@ else() message("-- Found boost: ${Boost_INCLUDE_DIRS}") message("-- Found boost: ${Boost_LIBRARIES}") message("") - message("-- Found python: ${PYTHON_LIBRARIES}") + message("-- Found python: ${Python3_LIBRARIES}") message("-- Found numpy: ${Python3_NumPy_INCLUDE_DIRS}") endif() diff --git a/CPPLINT.cfg b/CPPLINT.cfg new file mode 100644 index 000000000..6ae4030a8 --- /dev/null +++ b/CPPLINT.cfg @@ -0,0 +1,34 @@ +####################################################### +# CPPLINT.cfg +####################################################### + +# Increase the max number of characters on a given line +linelength=250 + +# List of filters to apply +filter=-legal/copyright + +# Suppress the warning for unapproved C++11 headers +# Required for " is an unapproved C++11 header" +filter=-build/c++11 + +# Disable the build/include_order check +# Required for #include "rogue/Directives.h" to be at start +filter=-build/include_order + +# Disable the build/header_guard check +# Note changing header guard has wrong style +# E.g. from __ROGUE_UTILITIES_FILEIO_MODULE_H__ to INCLUDE_ROGUE_UTILITIES_MODULE_H_ +filter=-build/header_guard + +# Disable whitespace/indent check +# private/public: indent will be based on .clang-format format" +filter=-whitespace/indent + +# Disable runtime/arrays +# TODO: We should fix in the future +filter=-runtime/arrays + +# Disable runtime/references +# TODO: We should fix in the future +filter=-runtime/references diff --git a/LICENSE.txt b/LICENSE.txt index 833255764..ae08fda9d 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,4 +1,4 @@ -Copyright (c) 2023, The Board of Trustees of the Leland Stanford Junior +Copyright (c) 2024, The Board of Trustees of the Leland Stanford Junior University, through SLAC National Accelerator Laboratory (subject to receipt of any required approvals from the U.S. Dept. of Energy). All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/buildroot-2019.08-x86_64.cmake b/buildroot-2019.08-x86_64.cmake index 96fdc994b..4eafe41f9 100644 --- a/buildroot-2019.08-x86_64.cmake +++ b/buildroot-2019.08-x86_64.cmake @@ -1,31 +1,35 @@ set(CMAKE_SYSTEM_NAME Generic) set(CMAKE_SYSTEM_PROCESSOR x86_64) -set(CMAKE_C_COMPILER_AR /afs/slac/package/linuxRT/buildroot-2019.08/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-ar) -set(CMAKE_ASM_COMPILER /afs/slac/package/linuxRT/buildroot-2019.08/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-gcc) -set(CMAKE_C_COMPILER /afs/slac/package/linuxRT/buildroot-2019.08/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-gcc) -set(CMAKE_CXX_COMPILER /afs/slac/package/linuxRT/buildroot-2019.08/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-g++) -set(CMAKE_LINKER /afs/slac/package/linuxRT/buildroot-2019.08/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-ld) -set(CMAKE_OBJCOPY /afs/slac/package/linuxRT/buildroot-2019.08/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-objcopy) -set(CMAKE_C_COMPILER_RANLIB /afs/slac/package/linuxRT/buildroot-2019.08/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-ranlib) -set(CMAKE_SIZE /afs/slac/package/linuxRT/buildroot-2019.08/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-size) -set(CMAKE_STRIP /afs/slac/package/linuxRT/buildroot-2019.08/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-strip) +if (NOT DEFINED BUILDROOT_TOP) + set(BUILDROOT_TOP "/sdf/sw/epics/package/linuxRT/buildroot-2019.08") +endif() + +set(CMAKE_C_COMPILER_AR "${BUILDROOT_TOP}/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-ar") +set(CMAKE_ASM_COMPILER "${BUILDROOT_TOP}/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-gcc") +set(CMAKE_C_COMPILER "${BUILDROOT_TOP}/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-gcc") +set(CMAKE_CXX_COMPILER "${BUILDROOT_TOP}/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-g++") +set(CMAKE_LINKER "${BUILDROOT_TOP}/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-ld") +set(CMAKE_OBJCOPY "${BUILDROOT_TOP}/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-objcopy") +set(CMAKE_C_COMPILER_RANLIB "${BUILDROOT_TOP}/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-ranlib") +set(CMAKE_SIZE "${BUILDROOT_TOP}/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-size") +set(CMAKE_STRIP "${BUILDROOT_TOP}/host/linux-x86_64/x86_64/usr/bin/x86_64-linux-strip") set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) # Define location of BZIP2 (cross-compiled) -set(BZIP2_LIBRARIES /afs/slac/g/lcls/package/bzip2/1.0.6/buildroot-2019.08-x86_64/lib/libbz2.a) -set(BZIP2_INCLUDE_DIR /afs/slac/g/lcls/package/bzip2/1.0.6/buildroot-2019.08-x86_64/include) +set(BZIP2_LIBRARIES "$ENV{PACKAGE_TOP}/bzip2/1.0.6/buildroot-2019.08-x86_64/lib/libbz2.a") +set(BZIP2_INCLUDE_DIR "$ENV{PACKAGE_TOP}/bzip2/1.0.6/buildroot-2019.08-x86_64/include") # Define the location of ZMQ (cross-compiled) -set(ZeroMQ_LIBRARY /afs/slac/g/lcls/package/libzmq/zeromq-4.3.4/buildroot-2019.08-x86_64/lib/libzmq.a) -set(ZeroMQ_INCLUDE_DIR /afs/slac/g/lcls/package/libzmq/zeromq-4.3.4/buildroot-2019.08-x86_64/include) +set(ZeroMQ_LIBRARY "$ENV{PACKAGE_TOP}/libzmq/zeromq-4.3.4/buildroot-2019.08-x86_64/lib/libzmq.a") +set(ZeroMQ_INCLUDE_DIR "$ENV{PACKAGE_TOP}/libzmq/zeromq-4.3.4/buildroot-2019.08-x86_64/include") # Define the location of python3 (cross-compiled) -set(PYTHON_LIBRARY /afs/slac/g/lcls/package/python/3.6.1/buildroot-2019.08-x86_64/lib/libpython3.6m.so) -set(PYTHON_INCLUDE_DIR /afs/slac/g/lcls/package/python/3.6.1/buildroot-2019.08-x86_64/include/python3.6m) +set(Python3_LIBRARY "$ENV{PACKAGE_TOP}/python/3.6.1/buildroot-2019.08-x86_64/lib/libpython3.6m.so") +set(Python3_INCLUDE_DIR "$ENV{PACKAGE_TOP}/python/3.6.1/buildroot-2019.08-x86_64/include/python3.6m") # Define the location of boost (cross-compiled) -set(BOOST_ROOT /afs/slac/g/lcls/package/boost/1.64.0/buildroot-2019.08-x86_64) +set(BOOST_ROOT "$ENV{PACKAGE_TOP}/boost/1.64.0/buildroot-2019.08-x86_64") diff --git a/conda.yml b/conda.yml index 9c1831db5..f7ea8c9f8 100644 --- a/conda.yml +++ b/conda.yml @@ -27,3 +27,4 @@ dependencies: - matplotlib - pytest - pytest-cov + - pyqt=5.12 diff --git a/docker/rogue-anaconda/Dockerfile b/docker/rogue-anaconda/Dockerfile new file mode 100644 index 000000000..5ee89f3ae --- /dev/null +++ b/docker/rogue-anaconda/Dockerfile @@ -0,0 +1,19 @@ +FROM continuumio/anaconda3 + +RUN apt-get update && \ + apt-get install -y \ + g++ \ + gcc \ + git \ + cmake \ + make + +RUN conda config --set channel_priority strict &&\ + conda install -n base conda-libmamba-solver &&\ + conda config --set solver libmamba + +RUN conda create -n rogue_tag -c tidair-tag -c conda-forge rogue + +RUN echo "source activate rogue_tag" > ~/.bashrc + +ENV PATH /opt/conda/envs/rogue_tag/bin:$PATH diff --git a/Dockerfile b/docker/rogue/Dockerfile similarity index 96% rename from Dockerfile rename to docker/rogue/Dockerfile index 4afd12ed3..b0e02b969 100644 --- a/Dockerfile +++ b/docker/rogue/Dockerfile @@ -1,4 +1,4 @@ -FROM ubuntu:22.10 +FROM ubuntu:22.04 # Install system tools RUN apt-get update && apt-get install -y \ @@ -21,7 +21,7 @@ RUN pip3 install PyYAML parse click ipython pyzmq packaging matplotlib numpy p4p RUN pip3 install pydm>=1.18.0 # Install Rogue -ARG branch +ARG branch=main WORKDIR /usr/local/src RUN git clone https://github.com/slaclab/rogue.git -b $branch WORKDIR rogue diff --git a/docs/src/index.rst b/docs/src/index.rst index 0a00fb990..d3fa72760 100644 --- a/docs/src/index.rst +++ b/docs/src/index.rst @@ -15,6 +15,7 @@ branch of Rogue. New documentation is being added incrementally over time. :caption: Contents: installing/index + pyrogue_tree/index interfaces/index utilities/index hardware/index diff --git a/docs/src/installing/anaconda.rst b/docs/src/installing/anaconda.rst index f0c77f4a2..a66a8aca1 100644 --- a/docs/src/installing/anaconda.rst +++ b/docs/src/installing/anaconda.rst @@ -58,7 +58,7 @@ Alternatively you can install a specific released version of Rogue: .. code:: - $ conda create -n rogue_v6.0.0 -c conda-forge -c tidair-tag rogue=v6.0.0 + $ conda create -n rogue_v6.1.3 -c conda-forge -c tidair-tag rogue=v6.1.3 Using Rogue In Anaconda ======================= @@ -71,7 +71,7 @@ To activate: $ conda activate rogue_tag -Replace rogue_tag with the name you used when creating your environment (e.g. rogue_v6.0.0). +Replace rogue_tag with the name you used when creating your environment (e.g. rogue_v6.1.3). To deactivate: diff --git a/docs/src/installing/petalinux.rst b/docs/src/installing/petalinux.rst index b7ad42d37..0a406ac7e 100644 --- a/docs/src/installing/petalinux.rst +++ b/docs/src/installing/petalinux.rst @@ -18,24 +18,23 @@ You will want to replace the file project-spec/meta-user/recipes-apps/rogue/rogu .. code:: - ROGUE_VERSION = "6.0.0" - ROGUE_MD5SUM = "42d6ffe9894c10a5d0e4c43834878e73" - + ROGUE_VERSION = "6.4.0" + ROGUE_MD5SUM = "acbd2b178af84776efbd78cdf3f5db7d" + SUMMARY = "Recipe to build Rogue" HOMEPAGE ="https://github.com/slaclab/rogue" LICENSE = "MIT" LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302" - + SRC_URI = "https://github.com/slaclab/rogue/archive/v${ROGUE_VERSION}.tar.gz" SRC_URI[md5sum] = "${ROGUE_MD5SUM}" - + S = "${WORKDIR}/rogue-${ROGUE_VERSION}" PROVIDES = "rogue" EXTRA_OECMAKE += "-DROGUE_INSTALL=system -DROGUE_VERSION=v${ROGUE_VERSION}" - # Note: distutils3 is depreciated in petalinux 2023.1 and need to switch to setuptools3 - inherit cmake python3native distutils3 - + inherit cmake python3native setuptools3 + DEPENDS += " \ python3 \ python3-native \ @@ -52,7 +51,7 @@ You will want to replace the file project-spec/meta-user/recipes-apps/rogue/rogu boost \ cmake \ " - + RDEPENDS:${PN} += " \ python3-numpy \ python3-pyzmq \ @@ -64,28 +63,35 @@ You will want to replace the file project-spec/meta-user/recipes-apps/rogue/rogu python3-json \ python3-logging \ " - + FILES:${PN}-dev += "/usr/include/rogue/*" FILES:${PN} += "/usr/lib/*" - + do_configure:prepend() { cmake_do_configure bbplain $(cp -vH ${WORKDIR}/build/setup.py ${S}/.) bbplain $(sed -i "s/..\/python/python/" ${S}/setup.py) } - + do_install:prepend() { cmake_do_install } -Update the ROGUE_VERSION line for an updated version when appropriate (min version is 5.6.1). You will need to first download the tar.gz file and compute the MD5SUM using the following commands if you update the ROGUE_VERSION line: + do_install:append() { + # Ensure the target directory exists + install -d ${D}${PYTHON_SITEPACKAGES_DIR} + # Install the rogue.so file into the Python site-packages directory + install -m 0755 ${S}/python/rogue.so ${D}${PYTHON_SITEPACKAGES_DIR} + } + +Update the ROGUE_VERSION line for an updated version when appropriate. You will need to first download the tar.gz file and compute the MD5SUM using the following commands if you update the ROGUE_VERSION line: .. code:: > wget https://github.com/slaclab/rogue/archive/vx.x.x.tar.gz > md5sum vx.x.x.tar.gz -If your rogue application requires additional python libraries you can add them to the DEPENDS += line in the above text. +RDEPENDS is the Runtime Dependencies. If your rogue application requires additional python libraries you can add them to the RDEPENDS += line in the above text. To enable compilation and installation of the rogue package in your petalinux project execute the following command: @@ -99,8 +105,8 @@ In order to install the rogue headers you will need to enable the rogue-dev pack .. code:: - CONFIG_rogue=y - CONFIG_rogue-dev=y + echo CONFIG_rogue=y >> project-spec/configs/rootfs_config + echo CONFIG_rogue-dev=y >> project-spec/configs/rootfs_config You can then build the rogue package with the following command: diff --git a/docs/src/interfaces/clients/virtual.rst b/docs/src/interfaces/clients/virtual.rst index e032b7c94..bb7a05cab 100644 --- a/docs/src/interfaces/clients/virtual.rst +++ b/docs/src/interfaces/clients/virtual.rst @@ -77,7 +77,7 @@ The VariableWait helper function can also be used. .. code-block:: python # Wait for the uptime to be greater than 1000 seconds - VariableWait(root.AxiVersion.UpTime, lambda varValues: varValues['root.UpTime'].value > 1000) + VariableWait([root.AxiVersion.UpTime], lambda varValues: varValues[0].value > 1000) The VirtualClient maintains a connection to the Rogue core. The status of this connection can be directly accessed through the linked attribute. Additionally a callback function diff --git a/docs/src/interfaces/stream/usingTcp.rst b/docs/src/interfaces/stream/usingTcp.rst index 9d3edf248..d1bf1b236 100644 --- a/docs/src/interfaces/stream/usingTcp.rst +++ b/docs/src/interfaces/stream/usingTcp.rst @@ -28,9 +28,9 @@ on the client. The Python server is able to interface with either a Python or C+ # Local receiver dst = MyCustomSlave() - # Start a TCP Bridge Server, Listen on ports 8000 & 8001 on all interfaces + # Start a TCP Bridge Server, Listen on ports 8000 & 8001 on localhost # Pass an address of 192.168.1.1 to listen on only that specific interface - tcp = rogue.interfaces.stream.TcpServer("*",8000) + tcp = rogue.interfaces.stream.TcpServer("127.0.0.1",8000) # Connect the transmitter and the receiver src >> tcp >> dst @@ -77,9 +77,9 @@ on the client. The C++ server is able to interface with either a Python or C++ // Local receiver MyCustomSlavePtr dst = MyCustomSlave::create() - // Start a TCP Bridge Server, Listen on all interfaces, ports 8000 & 8001. + // Start a TCP Bridge Server, Listen on localhost, ports 8000 & 8001. // Pass an address of 192.168.1.1 to listen on only that specific interface - rogue::interfaces::stream::TcpServerPtr tcp = rogue::interfaces::stream::TcpServer::create("*",8000) + rogue::interfaces::stream::TcpServerPtr tcp = rogue::interfaces::stream::TcpServer::create("127.0.0.1",8000) // Connect the transmitter *( *src >> tcp ) >> dst; diff --git a/docs/src/migration/rogue_v6.rst b/docs/src/migration/rogue_v6.rst index c5a348b1b..98402ae40 100644 --- a/docs/src/migration/rogue_v6.rst +++ b/docs/src/migration/rogue_v6.rst @@ -13,22 +13,22 @@ This biggest impacting change in Rogue V6 is to remove the ZmqServer feature fro Similiarly the previous feature which allowed the user to pass the root class to pydm to figure out the server port no longer works. Below is an example of including the ZmqServer in your root class and then using it with pydm. -.. code:: +.. code-block:: python class ExampleRoot(pyrogue.Root): def __init__(self): - pyrogue.Root.__init__(self, - description="Example Root", - timeout=2.0, - pollEn=True) + pyrogue.Root.__init__(self, + description="Example Root", + timeout=2.0, + pollEn=True) - # Add zmq server, keep it as an attribute so we can access it later - self.zmqServer = pyrogue.interfaces.ZmqServer(root=self, addr='*', port=0) - self.addInterface(self.zmqServer) + # Add zmq server, keep it as an attribute so we can access it later + self.zmqServer = pyrogue.interfaces.ZmqServer(root=self, addr='127.0.0.1', port=0) + self.addInterface(self.zmqServer) with ExampleRoot() as root: - pyrogue.pydm.runPyDM(serverList=root.zmqServer.address,title='Test UI',sizeX=1000,sizeY=500) + pyrogue.pydm.runPyDM(serverList=root.zmqServer.address,title='Test UI',sizeX=1000,sizeY=500) More information can be found int he ZmqServer class documenation (TBD). @@ -39,18 +39,18 @@ SqlLogger Similiar to the zmqServer, the sql logger is now removed to be an external interface. See below for example usage of the sql logger: -.. code:: +.. code-block:: python class ExampleRoot(pyrogue.Root): def __init__(self): - pyrogue.Root.__init__(self, - description="Example Root", - timeout=2.0, - pollEn=True) + pyrogue.Root.__init__(self, + description="Example Root", + timeout=2.0, + pollEn=True) - # Add sql logger - self.addInterface(pyrogue.interfaces.SqlLogger(root=self, url='sqlite:///test.db')) + # Add sql logger + self.addInterface(pyrogue.interfaces.SqlLogger(root=self, url='sqlite:///test.db')) More information can be found int he SqlLogger class documenation (TBD). @@ -61,22 +61,22 @@ Root Configuration Streaming In previous versions of rogue the Root class automatically supported the ability to stream configuration changes. This allowed the Root class to be added as a stream source to the StreamWriter class allow for configuration changes and status updates to be logged alongside the event data. In RogueV6 this feature is removed from the Root class with a new Variable streaming class which provides the same functionality. See below for an example of using this new class to stream configuration changes to the StreamWriter. This new method continues to support dumping the current status to the file immediatly after opening and right before closing:. -.. code:: +.. code-block:: python class ExampleRoot(pyrogue.Root): def __init__(self): - pyrogue.Root.__init__(self, - description="Example Root", - timeout=2.0, - pollEn=True) + pyrogue.Root.__init__(self, + description="Example Root", + timeout=2.0, + pollEn=True) - # Create configuration stream - stream = pyrogue.interfaces.stream.Variable(root=self) + # Create configuration stream + stream = pyrogue.interfaces.stream.Variable(root=self) - # Create StreamWriter with the configuration stream included as channel 1 - sw = pyrogue.utilities.fileio.StreamWriter(configStream={1: stream}) - self.add(sw) + # Create StreamWriter with the configuration stream included as channel 1 + sw = pyrogue.utilities.fileio.StreamWriter(configStream={1: stream}) + self.add(sw) EPICS Version 3 Channel Access Server @@ -84,18 +84,18 @@ EPICS Version 3 Channel Access Server Epics version 3 channel access server is removed from Rogue V6. Please use the epics 4 pv access server (P4P) instead: -.. code:: +.. code-block:: python class ExampleRoot(pyrogue.Root): def __init__(self): - pyrogue.Root.__init__(self, - description="Example Root", - timeout=2.0, - pollEn=True) + pyrogue.Root.__init__(self, + description="Example Root", + timeout=2.0, + pollEn=True) - pvserv = pyrogue.protocols.epicsV4.EpicsPvServer(base="test", root=self,incGroups=None,excGroups=None) - self.addProtocol(pvserv) + pvserv = pyrogue.protocols.epicsV4.EpicsPvServer(base="test", root=self,incGroups=None,excGroups=None) + self.addProtocol(pvserv) RawWrite and RawRead @@ -103,6 +103,112 @@ RawWrite and RawRead The deprecated rawWrite and rawRead calls are removed from Rogue V6. The new array variables added in Rogue V5 make these calls no longer needed. The user should no longer pass a 'size' arg to the Device class and then use rawWrite and rawRead to access memory space. Instead a array Variable should be used with the appropriate similiar size. The large Variables can then be configured to be excluded from the bulk read and write transactions and can also have other smaller Variables mapped to specific locations in the overall register space. See below for an example of how a Device can be upgraded to use list Variables instead of the rawWrite and rawRead calls: +The ``_rawWrite(address, wrValue)`` and ``rdValue = _rawRead(address)`` can be replaced as following. +For a single write/read: +.. code-block:: python + # Declare register + self.add( + pr.RemoteVariable( + name='egReg', + description='Example', + offset=address, + bitSize=32, + bitOffset=0, + base=pr.UInt, + mode='RW', + ) + ) + + # Write + self.egReg.set(wrValue) + + # Read + rdValue = self.egReg.get() + +For a block write: + +.. code-block:: python + + # Declare ram register + ## bitSize: ram size in bits (e.g.: 1024 words of 32b) + ## numValues: number of words (e.g.: 1024 words) + ## valueBits: word size (e.g.: 32bits) + ## valueStride: word size (e.g.: 32bits) + + self.add(pr.RemoteVariable( + name = 'ramReg', + description = 'Example', + offset = address, + bitSize = 32*1024, + bitOffset = 0, + numValues = 1024, + valueBits = 32, + valueStride = 32, + bulkOpEn = False, # FALSE for large variables + base = pr.Int, + mode = "RW", + )) + + # For the example, a random array of 1024 words is generated + values = np.random.rand(1024) + + # Loop through the values + for idx in range(len(values)): + self.ramReg.set(value=values[idx], index=idx, write=False) + + # Send the write command + self.ramReg.write() + + + +Setting pollInterval +==================== + +There API for setting a Variable's pollInterval has +changed. Previously, it could be set directly: + +.. code-block:: python + + someVar.pollInterval = 5 # Poll someVar every 5 seconds + +This has been deprecated in favor of: + +.. code-block:: python + + someVar.setPollInterval(5) # Poll someVar every 5 seconds + + +The reasoning is that a lot happens behind the scences when changing a +poll interval, and masking this with a setter decorator gives the user +the impression that it is much simpler than it is. + +Previously Deprecated Legacy GUI has Been Removed +================================================= + +The legacy GUI has been removed. You can no longer use the following +code to launch a generic tree GUI. + +.. code-block:: python + + import pyrogue.gui + + with Root(...) as root: + appTop = pyrogue.gui.application(sys.argv) + guiTop = pyrogue.gui.GuiTop() + guiTop.addTree(root) + guiTop.resize(800, 800) + appTop.exec_() + +Instead, use the new PyDM GUI + +.. code-block:: python + + import pyrogue.pydm + + with Root(...) as root: + pyrogue.pydm.runPyDM( + serverList=root.zmqServer.address, + title='GUI Window Title') diff --git a/docs/src/pyrogue_tree/index.rst b/docs/src/pyrogue_tree/index.rst new file mode 100644 index 000000000..0b8c09e6a --- /dev/null +++ b/docs/src/pyrogue_tree/index.rst @@ -0,0 +1,14 @@ +.. _pyrogue_tree: + +================ +PyRogue Tree +================ + +The PyRogue Tree implements a tree structure for the hierarchical organization of devices ... + +.. toctree:: + :maxdepth: 1 + :caption: Using Nodes In The PyRogue Tree: + + node/index + diff --git a/docs/src/pyrogue_tree/node/command/index.rst b/docs/src/pyrogue_tree/node/command/index.rst new file mode 100644 index 000000000..bc0eecac0 --- /dev/null +++ b/docs/src/pyrogue_tree/node/command/index.rst @@ -0,0 +1,49 @@ +.. _pyrogue_tree_node_command: + +======= +Command +======= + +The Command class ... + +In this example ... + +Python Command Example +====================== + +Below is an example of creating a Command which ... + +.. code-block:: python + + import pyrogue + + # Create a subclass of a command + class MyCommand(...): + +C++ Command Example +=================== + +Below is an example of creating a Command device in C++. + +.. code-block:: c + + #include + #include + + // Create a subclass of a command + class MyCommand : public rogue:: ... { + public: + + protected: + + }; + +A few notes on the above examples ... + +.. toctree:: + :maxdepth: 1 + :caption: Types Of Commands In The PyRogue Tree: + + local_command/index + remote_command/index + diff --git a/docs/src/pyrogue_tree/node/command/local_command/index.rst b/docs/src/pyrogue_tree/node/command/local_command/index.rst new file mode 100644 index 000000000..f6bf2179e --- /dev/null +++ b/docs/src/pyrogue_tree/node/command/local_command/index.rst @@ -0,0 +1,42 @@ +.. _pyrogue_tree_node_command_local_command: + +============ +LocalCommand +============ + +The LocalCommand class ... + +In this example ... + +Python LocalCommand Example +=========================== + +Below is an example of creating a LocalCommand which ... + +.. code-block:: python + + import pyrogue + + # Create a subclass of a LocalCommand + class MyLocalCommand(...): + +C++ LocalCommand Example +======================== + +Below is an example of creating a LocalCommand device in C++. + +.. code-block:: c + + #include + #include + + // Create a subclass of a LocalCommand + class MyLocalCommand : public rogue:: ... { + public: + + protected: + + }; + +A few notes on the above examples ... + diff --git a/docs/src/pyrogue_tree/node/command/remote_command/index.rst b/docs/src/pyrogue_tree/node/command/remote_command/index.rst new file mode 100644 index 000000000..9d59642b0 --- /dev/null +++ b/docs/src/pyrogue_tree/node/command/remote_command/index.rst @@ -0,0 +1,42 @@ +.. _pyrogue_tree_node_command_remote_command: + +============= +RemoteCommand +============= + +The RemoteCommand class ... + +In this example ... + +Python RemoteCommand Example +============================ + +Below is an example of creating a RemoteCommand which ... + +.. code-block:: python + + import pyrogue + + # Create a subclass of a RemoteCommand + class MyRemoteCommand(...): + +C++ RemoteCommand Example +========================= + +Below is an example of creating a RemoteCommand device in C++. + +.. code-block:: c + + #include + #include + + // Create a subclass of a RemoteCommand + class MyRemoteCommand : public rogue:: ... { + public: + + protected: + + }; + +A few notes on the above examples ... + diff --git a/docs/src/pyrogue_tree/node/device/index.rst b/docs/src/pyrogue_tree/node/device/index.rst new file mode 100644 index 000000000..6764b04a6 --- /dev/null +++ b/docs/src/pyrogue_tree/node/device/index.rst @@ -0,0 +1,42 @@ +.. _pyrogue_tree_node_device: + +====== +Device +====== + +The Device class ... + +In this example ... + +Python Device Example +===================== + +Below is an example of creating a Device which ... + +.. code-block:: python + + import pyrogue + + # Create a subclass of a Device + class MyDevice(...): + +C++ Device Example +================== + +Below is an example of creating a Device class in C++. + +.. code-block:: c + + #include + #include + + // Create a subclass of a Device + class MyDevice : public rogue:: ... { + public: + + protected: + + }; + +A few notes on the above examples ... + diff --git a/docs/src/pyrogue_tree/node/index.rst b/docs/src/pyrogue_tree/node/index.rst new file mode 100644 index 000000000..0fe0d2124 --- /dev/null +++ b/docs/src/pyrogue_tree/node/index.rst @@ -0,0 +1,17 @@ +.. _pyrogue_tree_node: + +==== +Node +==== + +The Node class is the base class of all devices ... + +.. toctree:: + :maxdepth: 1 + :caption: Types Of Nodes In The PyRogue Tree: + + root/index + device/index + command/index + variable/index + diff --git a/docs/src/pyrogue_tree/node/root/index.rst b/docs/src/pyrogue_tree/node/root/index.rst new file mode 100644 index 000000000..4f344bbcf --- /dev/null +++ b/docs/src/pyrogue_tree/node/root/index.rst @@ -0,0 +1,42 @@ +.. _pyrogue_tree_node_root: + +==== +Root +==== + +The Root class ... + +In this example ... + +Python Root Example +=================== + +Below is an example of creating a root which ... + +.. code-block:: python + + import pyrogue + + # Create a subclass of a root + class MyRoot(...): + +C++ Root Example +================ + +Below is an example of creating a root device in C++. + +.. code-block:: c + + #include + #include + + // Create a subclass of a root + class MyRoot : public rogue:: ... { + public: + + protected: + + }; + +A few notes on the above examples ... + diff --git a/docs/src/pyrogue_tree/node/variable/index.rst b/docs/src/pyrogue_tree/node/variable/index.rst new file mode 100644 index 000000000..7a3bd359b --- /dev/null +++ b/docs/src/pyrogue_tree/node/variable/index.rst @@ -0,0 +1,49 @@ +.. _pyrogue_tree_node_variable: + +======== +Variable +======== + +The Variable class ... + +In this example ... + +Python Variable Example +======================= + +Below is an example of creating a Variable which ... + +.. code-block:: python + + import pyrogue + + # Create a subclass of a Variable + class MyVariable(...): + +C++ Variable Example +==================== + +Below is an example of creating a Variable device in C++. + +.. code-block:: c + + #include + #include + + // Create a subclass of a Variable + class MyVariable : public rogue:: ... { + public: + + protected: + + }; + +A few notes on the above examples ... + +.. toctree:: + :maxdepth: 1 + :caption: Types Of Variables In The PyRogue Tree: + + link_variable/index + local_variable/index + remote_variable/index diff --git a/docs/src/pyrogue_tree/node/variable/link_variable/index.rst b/docs/src/pyrogue_tree/node/variable/link_variable/index.rst new file mode 100644 index 000000000..5cf1d2b68 --- /dev/null +++ b/docs/src/pyrogue_tree/node/variable/link_variable/index.rst @@ -0,0 +1,42 @@ +.. _pyrogue_tree_node_variable_link_variable: + +============ +LinkVariable +============ + +The LinkVariable class ... + +In this example ... + +Python LinkVariable Example +=========================== + +Below is an example of creating a LinkVariable which ... + +.. code-block:: python + + import pyrogue + + # Create a subclass of a LinkVariable + class MyLinkVariable(...): + +C++ LinkVariable Example +======================== + +Below is an example of creating a LinkVariable device in C++. + +.. code-block:: c + + #include + #include + + // Create a subclass of a LinkVariable + class MyLinkVariable : public rogue:: ... { + public: + + protected: + + }; + +A few notes on the above examples ... + diff --git a/docs/src/pyrogue_tree/node/variable/local_variable/index.rst b/docs/src/pyrogue_tree/node/variable/local_variable/index.rst new file mode 100644 index 000000000..df71bf319 --- /dev/null +++ b/docs/src/pyrogue_tree/node/variable/local_variable/index.rst @@ -0,0 +1,42 @@ +.. _pyrogue_tree_node_variable_local_variable: + +============= +LocalVariable +============= + +The LocalVariable class ... + +In this example ... + +Python LocalVariable Example +============================ + +Below is an example of creating a LocalVariable which ... + +.. code-block:: python + + import pyrogue + + # Create a subclass of a LocalVariable + class MyLocalVariable(...): + +C++ LocalVariable Example +========================= + +Below is an example of creating a LocalVariable device in C++. + +.. code-block:: c + + #include + #include + + // Create a subclass of a LocalVariable + class MyLocalVariable : public rogue:: ... { + public: + + protected: + + }; + +A few notes on the above examples ... + diff --git a/docs/src/pyrogue_tree/node/variable/remote_variable/index.rst b/docs/src/pyrogue_tree/node/variable/remote_variable/index.rst new file mode 100644 index 000000000..1e38d8268 --- /dev/null +++ b/docs/src/pyrogue_tree/node/variable/remote_variable/index.rst @@ -0,0 +1,42 @@ +.. _pyrogue_tree_node_variable_remote_variable: + +============== +RemoteVariable +============== + +The RemoteVariable class ... + +In this example ... + +Python RemoteVariable Example +============================= + +Below is an example of creating a RemoteVariable which ... + +.. code-block:: python + + import pyrogue + + # Create a subclass of a RemoteVariable + class MyRemoteVariable(...): + +C++ RemoteVariable Example +========================== + +Below is an example of creating a RemoteVariable device in C++. + +.. code-block:: c + + #include + #include + + // Create a subclass of a RemoteVariable + class MyRemoteVariable : public rogue:: ... { + public: + + protected: + + }; + +A few notes on the above examples ... + diff --git a/include/rogue/Directives.h b/include/rogue/Directives.h index eba2e103f..3f4f5cf65 100644 --- a/include/rogue/Directives.h +++ b/include/rogue/Directives.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Common Directives * ---------------------------------------------------------------------------- - * File : Directives.h - * Created : 2023-02-13 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Common Directives For Rogue @@ -27,7 +24,7 @@ #define CRCPP_USE_CPP11 #ifndef __STDC_FORMAT_MACROS -#define __STDC_FORMAT_MACROS + #define __STDC_FORMAT_MACROS #endif #endif diff --git a/include/rogue/EnableSharedFromThis.h b/include/rogue/EnableSharedFromThis.h index 6c54897a7..7113e97ed 100644 --- a/include/rogue/EnableSharedFromThis.h +++ b/include/rogue/EnableSharedFromThis.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Common virtual class to enable shared_from_this() calls. * ---------------------------------------------------------------------------- - * File : EnableSharedFromThis.h - * Created : 2019-11-15 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * This is a common parent class that must be used instead of std::enable_shared_from_this diff --git a/include/rogue/GeneralError.h b/include/rogue/GeneralError.h index 1b05d3a5d..c24a5a2fb 100644 --- a/include/rogue/GeneralError.h +++ b/include/rogue/GeneralError.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : General Error * ---------------------------------------------------------------------------- - * File : GeneralError.h - * Created : 2017-12-05 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * General exception for Rogue @@ -28,7 +25,7 @@ #include #ifndef NO_PYTHON -#include + #include #endif namespace rogue { diff --git a/include/rogue/GilRelease.h b/include/rogue/GilRelease.h index 32148ada0..fe4e53764 100644 --- a/include/rogue/GilRelease.h +++ b/include/rogue/GilRelease.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Release GIL within scope. * ---------------------------------------------------------------------------- - * File : GilRelease.h - * Created : 2017-02-28 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Release GIL for the scope of this class. @@ -23,7 +20,7 @@ #include #ifndef NO_PYTHON -#include + #include #endif namespace rogue { diff --git a/include/rogue/Helpers.h b/include/rogue/Helpers.h index 5cfcc476a..eb66c093b 100644 --- a/include/rogue/Helpers.h +++ b/include/rogue/Helpers.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Helpful Functions * ---------------------------------------------------------------------------- - * File : Helpers.h - * Created : 2018-11-28 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Helper functions for Rogue diff --git a/include/rogue/Logging.h b/include/rogue/Logging.h index aeed6efa2..e7a55b6c1 100644 --- a/include/rogue/Logging.h +++ b/include/rogue/Logging.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Logging interface * ---------------------------------------------------------------------------- - * File : Logging.h - * Created : 2017-02-28 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Logging interface for pyrogue @@ -73,7 +70,7 @@ class Logging { static std::shared_ptr create(std::string name, bool quiet = false); - Logging(std::string name, bool quiet = false); + explicit Logging(std::string name, bool quiet = false); ~Logging(); static void setLevel(uint32_t level); diff --git a/include/rogue/Queue.h b/include/rogue/Queue.h index 4b26a468a..27680b51d 100644 --- a/include/rogue/Queue.h +++ b/include/rogue/Queue.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : General Queue * ---------------------------------------------------------------------------- - * File : Queue.h - * Created : 2017-01-18 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * General queue for Rogue diff --git a/include/rogue/ScopedGil.h b/include/rogue/ScopedGil.h index 373a659a1..371400de2 100644 --- a/include/rogue/ScopedGil.h +++ b/include/rogue/ScopedGil.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Scoped GIL * ---------------------------------------------------------------------------- - * File : ScopedGil.h - * Created : 2017-02-28 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Acquire the GIL for the scope of this class. @@ -22,7 +19,7 @@ #include "rogue/Directives.h" #ifndef NO_PYTHON -#include + #include #endif namespace rogue { diff --git a/include/rogue/Version.h b/include/rogue/Version.h index 383b4ad71..be2fde8b3 100644 --- a/include/rogue/Version.h +++ b/include/rogue/Version.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Rogue Version * ---------------------------------------------------------------------------- - * File : Version.h - * Created : 2017-05-17 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Version helpers for Rogue diff --git a/include/rogue/hardware/MemMap.h b/include/rogue/hardware/MemMap.h index dfbd1775d..661d9d7cf 100644 --- a/include/rogue/hardware/MemMap.h +++ b/include/rogue/hardware/MemMap.h @@ -1,9 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : Raw Memory Mapped Access * ---------------------------------------------------------------------------- - * File : MemMap.h - * Created : 2019-11-18 + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- + * Description: + * Raw Memory Mapped Access * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory diff --git a/include/rogue/hardware/axi/AxiMemMap.h b/include/rogue/hardware/axi/AxiMemMap.h index 3374a531e..02a8df38f 100644 --- a/include/rogue/hardware/axi/AxiMemMap.h +++ b/include/rogue/hardware/axi/AxiMemMap.h @@ -1,9 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : AXI Memory Mapped Access * ---------------------------------------------------------------------------- - * File : AxiMemMap.h - * Created : 2017-03-21 + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- + * Description: + * AXI Memory Mapped Access * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory @@ -22,6 +22,7 @@ #include #include +#include #include #include "rogue/Logging.h" @@ -69,7 +70,7 @@ class AxiMemMap : public rogue::interfaces::memory::Slave { static void setup_python(); // Class Creator - AxiMemMap(std::string path); + explicit AxiMemMap(std::string path); // Destructor ~AxiMemMap(); diff --git a/include/rogue/hardware/axi/AxiStreamDma.h b/include/rogue/hardware/axi/AxiStreamDma.h index bd02ee5d4..4031dedbc 100644 --- a/include/rogue/hardware/axi/AxiStreamDma.h +++ b/include/rogue/hardware/axi/AxiStreamDma.h @@ -1,6 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : AxiStreamDma Interface Class + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- + * Description: + * AxiStreamDma Interface Class * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory @@ -19,6 +22,7 @@ #include #include +#include #include #include "rogue/Logging.h" @@ -32,7 +36,7 @@ namespace axi { //! Storage class for shared memory buffers class AxiStreamDmaShared { public: - AxiStreamDmaShared(std::string path); + explicit AxiStreamDmaShared(std::string path); //! Shared FD int32_t fd; @@ -199,6 +203,51 @@ class AxiStreamDma : public rogue::interfaces::stream::Master, public rogue::int // Process Buffer Return void retBuffer(uint8_t* data, uint32_t meta, uint32_t rawSize); + + //! Get the DMA Driver's Git Version + std::string getGitVersion(); + + //! Get the DMA Driver's API Version + uint32_t getApiVersion(); + + //! Get the size of buffers (RX/TX) + uint32_t getBuffSize(); + + //! Get the number of RX buffers + uint32_t getRxBuffCount(); + + //! Get RX buffer in User count + uint32_t getRxBuffinUserCount(); + + //! Get RX buffer in HW count + uint32_t getRxBuffinHwCount(); + + //! Get RX buffer in Pre-HW Queue count + uint32_t getRxBuffinPreHwQCount(); + + //! Get RX buffer in SW Queue count + uint32_t getRxBuffinSwQCount(); + + //! Get RX buffer missing count + uint32_t getRxBuffMissCount(); + + //! Get the number of TX buffers + uint32_t getTxBuffCount(); + + //! Get TX buffer in User count + uint32_t getTxBuffinUserCount(); + + //! Get TX buffer in HW count + uint32_t getTxBuffinHwCount(); + + //! Get TX buffer in Pre-HW Queue count + uint32_t getTxBuffinPreHwQCount(); + + //! Get TX buffer in SW Queue count + uint32_t getTxBuffinSwQCount(); + + //! Get TX buffer missing count + uint32_t getTxBuffMissCount(); }; //! Alias for using shared pointer as AxiStreamDmaPtr diff --git a/include/rogue/hardware/axi/module.h b/include/rogue/hardware/axi/module.h index d4be7c5b2..893a83370 100644 --- a/include/rogue/hardware/axi/module.h +++ b/include/rogue/hardware/axi/module.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module * ---------------------------------------------------------------------------- - * File : module.h - * Created : 2017-03-21 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/include/rogue/hardware/drivers/AxisDriver.h b/include/rogue/hardware/drivers/AxisDriver.h index cefe829b0..21107b3d5 100644 --- a/include/rogue/hardware/drivers/AxisDriver.h +++ b/include/rogue/hardware/drivers/AxisDriver.h @@ -1,9 +1,14 @@ /** *----------------------------------------------------------------------------- - * Title : AXIS DMA Driver, Shared Header + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: - * Definitions and inline functions for interacting with AXIS driver. + * This file contains definitions and inline functions for interacting + * with the AXIS driver as part of the aes_stream_drivers package. + * + * It includes functionalities for setting flags within the AXIS protocol + * and performing specific actions such as acknowledging reads and indicating + * missed write requests. * ---------------------------------------------------------------------------- * This file is part of the aes_stream_drivers package. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory @@ -14,46 +19,88 @@ * contained in the LICENSE.txt file. * ---------------------------------------------------------------------------- **/ + #ifndef __ASIS_DRIVER_H__ #define __ASIS_DRIVER_H__ #include "DmaDriver.h" -// Commands -#define AXIS_Read_Ack 0x2001 +// Command definitions +#define AXIS_Read_Ack 0x2001 // Command to acknowledge read +#define AXIS_Write_ReqMissed 0x2002 // Command to indicate a missed write request -// Everything below is hidden during kernel module compile +// Only define the following if not compiling for kernel space #ifndef DMA_IN_KERNEL -// Set flags -// static constexpr inline uint32_t axisSetFlags(uint32_t fuser, uint32_t luser, uint32_t cont) { -// return ( ((cont & 0x1) << 16) | ((luser & 0xFF) << 8) | ((fuser & 0xFF) << 0) ); -//} - +/** + * Set flags for AXIS transactions. + * + * @param fuser First user-defined flag. + * @param luser Last user-defined flag. + * @param cont Continuation flag. + * + * @return The combined flags value. + */ static inline uint32_t axisSetFlags(uint32_t fuser, uint32_t luser, uint32_t cont) { uint32_t flags; - flags = fuser & 0xFF; - flags += (luser << 8) & 0xFF00; - flags += (cont << 16) & 0x10000; - return (flags); + // Set flags based on input parameters, ensuring each is in its correct position + flags = fuser & 0xFF; // First user-defined flag + flags |= (luser << 8) & 0xFF00; // Last user-defined flag + flags |= (cont << 16) & 0x10000; // Continuation flag + + return flags; } +/** + * Extract the first user-defined flag from the combined flags. + * + * @param flags The combined flags value. + * + * @return The first user-defined flag. + */ static inline uint32_t axisGetFuser(uint32_t flags) { - return (flags & 0xFF); + return flags & 0xFF; } +/** + * Extract the last user-defined flag from the combined flags. + * + * @param flags The combined flags value. + * + * @return The last user-defined flag. + */ static inline uint32_t axisGetLuser(uint32_t flags) { - return ((flags >> 8) & 0xFF); + return (flags >> 8) & 0xFF; } +/** + * Extract the continuation flag from the combined flags. + * + * @param flags The combined flags value. + * + * @return The continuation flag. + */ static inline uint32_t axisGetCont(uint32_t flags) { - return ((flags >> 16) & 0x1); + return (flags >> 16) & 0x1; } -// Read ACK +/** + * Acknowledge a read operation. + * + * @param fd File descriptor for the AXIS device. + */ static inline void axisReadAck(int32_t fd) { ioctl(fd, AXIS_Read_Ack, 0); } -#endif -#endif +/** + * Indicate a missed write request. + * + * @param fd File descriptor for the AXIS device. + */ +static inline void axisWriteReqMissed(int32_t fd) { + ioctl(fd, AXIS_Write_ReqMissed, 0); +} + +#endif // !DMA_IN_KERNEL +#endif // __ASIS_DRIVER_H__ diff --git a/include/rogue/hardware/drivers/DmaDriver.h b/include/rogue/hardware/drivers/DmaDriver.h index b16bdeba6..71fd6cc26 100644 --- a/include/rogue/hardware/drivers/DmaDriver.h +++ b/include/rogue/hardware/drivers/DmaDriver.h @@ -1,12 +1,13 @@ /** *----------------------------------------------------------------------------- - * Title : DMA Driver, Common Header - * ---------------------------------------------------------------------------- - * File : DmaDriver.h - * Created : 2016-08-08 - * ---------------------------------------------------------------------------- + * Company: SLAC National Accelerator Laboratory + *----------------------------------------------------------------------------- * Description: - * Defintions and inline functions for interacting drivers. + * This header file defines the interfaces and data structures used by + * DMA (Direct Memory Access) drivers in the aes_stream_drivers package. + * These drivers facilitate efficient data transfer between memory and + * devices without requiring CPU intervention, improving throughput and + * reducing latency for I/O operations. * ---------------------------------------------------------------------------- * This file is part of the aes_stream_drivers package. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory @@ -17,25 +18,28 @@ * contained in the LICENSE.txt file. * ---------------------------------------------------------------------------- **/ + #ifndef __DMA_DRIVER_H__ #define __DMA_DRIVER_H__ #ifdef DMA_IN_KERNEL -#include + #include #else -#include + #include + + #include #endif -// API Version +/* API Version */ #define DMA_VERSION 0x06 -// Error values +/* Error values */ #define DMA_ERR_FIFO 0x01 #define DMA_ERR_LEN 0x02 #define DMA_ERR_MAX 0x04 #define DMA_ERR_BUS 0x08 -// Commands +/* Commands */ #define DMA_Get_Buff_Count 0x1001 #define DMA_Get_Buff_Size 0x1002 #define DMA_Set_Debug 0x1003 @@ -54,12 +58,30 @@ #define DMA_Get_TxBuffinPreHWQ_Count 0x1011 #define DMA_Get_TxBuffinSWQ_Count 0x1012 #define DMA_Get_TxBuffMiss_Count 0x1013 - -// Mask size +#define DMA_Get_RxBuffinUser_Count 0x1014 +#define DMA_Get_RxBuffinHW_Count 0x1015 +#define DMA_Get_RxBuffinPreHWQ_Count 0x1016 +#define DMA_Get_RxBuffinSWQ_Count 0x1017 +#define DMA_Get_RxBuffMiss_Count 0x1018 +#define DMA_Get_GITV 0x1019 + +/* Mask size */ #define DMA_MASK_SIZE 512 -// TX Structure -// Size = 0 for return index +/** + * struct DmaWriteData - Structure representing a DMA write operation. + * @data: Physical address of the data to be written. + * @dest: Destination address within the device. + * @flags: Flags to control the write operation. + * @index: Index of the buffer to be used for the write operation. + * @size: Size of the data to be written. + * @is32: Flag indicating whether the system uses 32-bit addressing. + * @pad: Padding to align the structure to 64 bits. + * + * This structure is used to initiate a DMA write operation. It contains + * information about the data to be written, the destination, and various + * control flags. + */ struct DmaWriteData { uint64_t data; uint32_t dest; @@ -70,8 +92,21 @@ struct DmaWriteData { uint32_t pad; }; -// RX Structure -// Data = 0 for read index +/** + * struct DmaReadData - Structure representing a DMA read operation. + * @data: Physical address where the read data will be stored. + * @dest: Source address within the device. + * @flags: Flags to control the read operation. + * @index: Index of the buffer to be used for the read operation. + * @error: Error code returned by the read operation. + * @size: Size of the data to be read. + * @is32: Flag indicating whether the system uses 32-bit addressing. + * @ret: The return value of the read operation, typically the size of the data read. + * + * This structure is used to initiate a DMA read operation. It contains + * information about where to store the read data, the source of the data, + * and various control flags. + */ struct DmaReadData { uint64_t data; uint32_t dest; @@ -83,26 +118,47 @@ struct DmaReadData { int32_t ret; }; -// Register data +/** + * struct DmaRegisterData - Register data structure. + * @address: Memory address. + * @data: Data to be written. + * + * This structure holds the data necessary to perform a register write operation + * within a DMA context. + */ struct DmaRegisterData { uint64_t address; uint32_t data; }; -// Everything below is hidden during kernel module compile +// Conditional inclusion for non-kernel environments #ifndef DMA_IN_KERNEL -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -// Write Frame + #include + #include + #include + #include + #include + #include + #include + #include + #include + #include + +/** + * dmaWrite - Writes data to a DMA channel. + * @fd: File descriptor for the DMA device. + * @buf: Pointer to the data buffer. + * @size: Size of the data to write. + * @flags: Flags for the write operation. + * @dest: Destination address for the write. + * + * This function writes a single frame of data to a DMA channel, specified by the + * file descriptor @fd. The data to be written is pointed to by @buf, with a specified + * size of @size. Additional parameters include flags (@flags) and a destination address + * (@dest). + * + * Return: Number of bytes written, or a negative error code on failure. + */ static inline ssize_t dmaWrite(int32_t fd, const void* buf, size_t size, uint32_t flags, uint32_t dest) { struct DmaWriteData w; @@ -116,7 +172,20 @@ static inline ssize_t dmaWrite(int32_t fd, const void* buf, size_t size, uint32_ return (write(fd, &w, sizeof(struct DmaWriteData))); } -// Write Frame, memory mapped +/** + * dmaWriteIndex - Writes data to a DMA channel using an index. + * @fd: File descriptor for the DMA device. + * @index: Index of the data buffer. + * @size: Size of the data to write. + * @flags: Flags for the write operation. + * @dest: Destination address for the write. + * + * Similar to dmaWrite, but uses an index (@index) to specify the data buffer + * instead of a direct pointer. This is useful for memory-mapped I/O operations + * where data buffers are identified by indexes. + * + * Return: Number of bytes written, or a negative error code on failure. + */ static inline ssize_t dmaWriteIndex(int32_t fd, uint32_t index, size_t size, uint32_t flags, uint32_t dest) { struct DmaWriteData w; @@ -130,7 +199,24 @@ static inline ssize_t dmaWriteIndex(int32_t fd, uint32_t index, size_t size, uin return (write(fd, &w, sizeof(struct DmaWriteData))); } -// Write frame from iovector +/** + * dmaWriteVector - Writes an array of data frames to a DMA channel. + * @fd: File descriptor for the DMA device. + * @iov: Pointer to the array of iovec structures. + * @iovlen: Number of elements in the iov array. + * @begFlags: Flags for the beginning of the data stream. + * @midFlags: Flags for the middle of the data stream. + * @endFlags: Flags for the end of the data stream. + * @dest: Destination address for the write. + * + * This function writes multiple data frames to a DMA channel, where each frame is + * specified by an iovec structure in the array pointed to by @iov. The number of + * frames to write is specified by @iovlen. Flags for the beginning, middle, and end + * of the data stream are specified by @begFlags, @midFlags, and @endFlags, respectively. + * The destination address for the write operation is specified by @dest. + * + * Return: Total number of bytes written, or a negative error code on failure. + */ static inline ssize_t dmaWriteVector(int32_t fd, struct iovec* iov, size_t iovlen, @@ -167,7 +253,21 @@ static inline ssize_t dmaWriteVector(int32_t fd, return (ret); } -// Write Frame, memory mapped from iovector +/** + * dmaWriteIndexVector - Write Frame, memory mapped from iovector. + * @fd: File descriptor for DMA operation. + * @iov: Pointer to array of iovec structures. + * @iovlen: Length of the iov array. + * @begFlags: Flags to use for the beginning of the DMA transaction. + * @midFlags: Flags to use for the middle of the DMA transaction. + * @endFlags: Flags to use for the end of the DMA transaction. + * @dest: Destination address for the DMA write. + * + * This function writes a frame to a device, using DMA, where the frame data + * is described by an array of iovec structures. + * + * Return: Total number of bytes written, or negative on failure. + */ static inline ssize_t dmaWriteIndexVector(int32_t fd, struct iovec* iov, size_t iovlen, @@ -204,7 +304,19 @@ static inline ssize_t dmaWriteIndexVector(int32_t fd, return (ret); } -// Receive Frame +/** + * dmaRead - Receive Frame. + * @fd: File descriptor for DMA operation. + * @buf: Buffer to store received data. + * @maxSize: Maximum size to read. + * @flags: Pointer to store flags after reading. + * @error: Pointer to store error code if any. + * @dest: Pointer to store destination address. + * + * This function reads a frame from a device using DMA. + * + * Return: Size of the data received, or negative on failure. + */ static inline ssize_t dmaRead(int32_t fd, void* buf, size_t maxSize, uint32_t* flags, uint32_t* error, uint32_t* dest) { struct DmaReadData r; ssize_t ret; @@ -225,8 +337,19 @@ static inline ssize_t dmaRead(int32_t fd, void* buf, size_t maxSize, uint32_t* f return (r.ret); } -// Receive Frame, access memory mapped buffer -// Returns receive size +/** + * dmaReadIndex - Receive Frame, access memory mapped buffer. + * @fd: File descriptor for DMA operation. + * @index: Pointer to store the index of the received data. + * @flags: Pointer to store flags after reading. + * @error: Pointer to store error code if any. + * @dest: Pointer to store destination address. + * + * This function reads a frame from a device using DMA, specifically accessing + * the memory-mapped buffer and retrieves the index of the received data. + * + * Return: Size of the data received, or negative on failure. + */ static inline ssize_t dmaReadIndex(int32_t fd, uint32_t* index, uint32_t* flags, uint32_t* error, uint32_t* dest) { struct DmaReadData r; size_t ret; @@ -245,8 +368,22 @@ static inline ssize_t dmaReadIndex(int32_t fd, uint32_t* index, uint32_t* flags, return (r.ret); } -// Receive Frame, access memory mapped buffer -// Returns receive size +/** + * dmaReadBulkIndex - Receive frame and access memory-mapped buffer. + * @fd: File descriptor to read from. + * @count: Number of elements in the buffers. + * @ret: Pointer to store the return values. + * @index: Buffer to store the indices of the DMA read operations. + * @flags: Buffer to store flags of the DMA read operations. + * @error: Buffer to store error codes of the DMA read operations. + * @dest: Buffer to store destination addresses of the DMA read operations. + * + * This function reads bulk data from a DMA channel and extracts the metadata + * associated with each read operation, including return values, indices, + * flags, error codes, and destination addresses. + * + * Returns: The number of bytes read. + */ static inline ssize_t dmaReadBulkIndex(int32_t fd, uint32_t count, int32_t* ret, @@ -273,46 +410,258 @@ static inline ssize_t dmaReadBulkIndex(int32_t fd, return (res); } -// Post Index +/** + * dmaRetIndex - Post an index back to the DMA. + * @fd: File descriptor to use. + * @index: Index to be returned. + * + * This function posts a single index back to the DMA, indicating that + * the buffer associated with this index can be reused. + * + * Returns: Result of the IOCTL operation. + */ static inline ssize_t dmaRetIndex(int32_t fd, uint32_t index) { uint32_t cmd = DMA_Ret_Index | 0x10000; return (ioctl(fd, cmd, &index)); } -// Post Index List +/** + * dmaRetIndexes - Post multiple indices back to the DMA. + * @fd: File descriptor to use. + * @count: Number of indices to be returned. + * @indexes: Array of indices to be returned. + * + * This function posts multiple indices back to the DMA, indicating that + * the buffers associated with these indices can be reused. + * + * Returns: Result of the IOCTL operation. + */ static inline ssize_t dmaRetIndexes(int32_t fd, uint32_t count, uint32_t* indexes) { uint32_t cmd = DMA_Ret_Index | ((count << 16) & 0xFFFF0000); return (ioctl(fd, cmd, indexes)); } -// Get write buffer index +/** + * dmaGetIndex - Get the current write buffer index. + * @fd: File descriptor to use. + * + * This function retrieves the current index for writing to the DMA buffer. + * + * Returns: The current write buffer index. + */ static inline uint32_t dmaGetIndex(int32_t fd) { return (ioctl(fd, DMA_Get_Index, 0)); } -// Get read ready status +/** + * dmaReadReady - Check if read is ready. + * @fd: File descriptor to use. + * + * This function checks if the DMA is ready for reading. + * + * Returns: Result of the IOCTL operation, indicating read readiness. + */ static inline ssize_t dmaReadReady(int32_t fd) { return (ioctl(fd, DMA_Read_Ready, 0)); } -// get rx buffer count +/** + * dmaGetRxBuffCount - Get the receive buffer count. + * @fd: File descriptor to use. + * + * This function retrieves the count of receive buffers available. + * + * Returns: The count of receive buffers. + */ static inline ssize_t dmaGetRxBuffCount(int32_t fd) { return (ioctl(fd, DMA_Get_RxBuff_Count, 0)); } -// get tx buffer count +/** + * dmaGetRxBuffinUserCount - Get the receive buffer count in user + * @fd: File descriptor to use. + * + * This function retrieves the count of receive buffers in user. + * + * Returns: The count of receive buffers in user + */ +static inline ssize_t dmaGetRxBuffinUserCount(int32_t fd) { + return (ioctl(fd, DMA_Get_RxBuffinUser_Count, 0)); +} + +/** + * dmaGetRxBuffinHwCount - Get the receive buffer count in hardware + * @fd: File descriptor to use. + * + * This function retrieves the count of receive buffers in hardware. + * + * Returns: The count of receive buffers in hardware + */ +static inline ssize_t dmaGetRxBuffinHwCount(int32_t fd) { + return (ioctl(fd, DMA_Get_RxBuffinHW_Count, 0)); +} + +/** + * dmaGetRxBuffinPreHwQCount - Get the receive buffer count in pre-hardware queue + * @fd: File descriptor to use. + * + * This function retrieves the count of receive buffers in pre-hardware queue + * + * Returns: The count of receive buffers in pre-hardware queue + */ +static inline ssize_t dmaGetRxBuffinPreHwQCount(int32_t fd) { + return (ioctl(fd, DMA_Get_RxBuffinPreHWQ_Count, 0)); +} + +/** + * dmaGetRxBuffinSwQCount - Get the receive buffer count in software queue + * @fd: File descriptor to use. + * + * This function retrieves the count of receive buffers in software queue + * + * Returns: The count of receive buffers in software queue + */ +static inline ssize_t dmaGetRxBuffinSwQCount(int32_t fd) { + return (ioctl(fd, DMA_Get_RxBuffinSWQ_Count, 0)); +} + +/** + * dmaGetRxBuffMissCount - Get the receive buffer missing count + * @fd: File descriptor to use. + * + * This function retrieves the count of receive buffer missing + * + * Returns: The count of receive buffers missing + */ +static inline ssize_t dmaGetRxBuffMissCount(int32_t fd) { + return (ioctl(fd, DMA_Get_RxBuffMiss_Count, 0)); +} + +/** + * dmaGetTxBuffCount - Get the transmit buffer count. + * @fd: File descriptor to use. + * + * This function retrieves the count of transmit buffers available. + * + * Returns: The count of transmit buffers. + */ static inline ssize_t dmaGetTxBuffCount(int32_t fd) { return (ioctl(fd, DMA_Get_TxBuff_Count, 0)); } -// get buffer size +/** + * dmaGetTxBuffinUserCount - Get the transmit buffer count in user + * @fd: File descriptor to use. + * + * This function retrieves the count of transmit buffers in user. + * + * Returns: The count of transmit buffers in user + */ +static inline ssize_t dmaGetTxBuffinUserCount(int32_t fd) { + return (ioctl(fd, DMA_Get_TxBuffinUser_Count, 0)); +} + +/** + * dmaGetTxBuffinHwCount - Get the transmit buffer count in hardware + * @fd: File descriptor to use. + * + * This function retrieves the count of transmit buffers in hardware. + * + * Returns: The count of transmit buffers in hardware + */ +static inline ssize_t dmaGetTxBuffinHwCount(int32_t fd) { + return (ioctl(fd, DMA_Get_TxBuffinHW_Count, 0)); +} + +/** + * dmaGetTxBuffinPreHwQCount - Get the transmit buffer count in pre-hardware queue + * @fd: File descriptor to use. + * + * This function retrieves the count of transmit buffers in pre-hardware queue + * + * Returns: The count of transmit buffers in pre-hardware queue + */ +static inline ssize_t dmaGetTxBuffinPreHwQCount(int32_t fd) { + return (ioctl(fd, DMA_Get_TxBuffinPreHWQ_Count, 0)); +} + +/** + * dmaGetTxBuffinSwQCount - Get the transmit buffer count in software queue + * @fd: File descriptor to use. + * + * This function retrieves the count of transmit buffers in software queue + * + * Returns: The count of transmit buffers in software queue + */ +static inline ssize_t dmaGetTxBuffinSwQCount(int32_t fd) { + return (ioctl(fd, DMA_Get_TxBuffinSWQ_Count, 0)); +} + +/** + * dmaGetTxBuffMissCount - Get the transmit buffer missing count + * @fd: File descriptor to use. + * + * This function retrieves the count of transmit buffer missing + * + * Returns: The count of transmit buffers missing + */ +static inline ssize_t dmaGetTxBuffMissCount(int32_t fd) { + return (ioctl(fd, DMA_Get_TxBuffMiss_Count, 0)); +} + +/** + * dmaGetBuffSize - Get the buffer size. + * @fd: File descriptor to use. + * + * This function retrieves the size of DMA buffers. + * + * Returns: The size of DMA buffers. + */ static inline ssize_t dmaGetBuffSize(int32_t fd) { return (ioctl(fd, DMA_Get_Buff_Size, 0)); } -// Return user space mapping to dma buffers +/** + * dmaGetBuffCount - Get the buffer count. + * @fd: File descriptor to use. + * + * This function retrieves the count of DMA buffers. + * + * Returns: The count of DMA buffers. + */ +static inline ssize_t dmaGetBuffCount(int32_t fd) { + return (ioctl(fd, DMA_Get_Buff_Count, 0)); +} + +/** + * dmaGetGitVersion - Get the DMA Driver's Git Version + * @fd: File descriptor to use. + * + * This function retrieves the DMA Driver's Git Version string + * + * Returns: The DMA Driver's Git Version string + */ +static inline std::string dmaGetGitVersion(int32_t fd) { + char gitv[32] = {0}; // Initialize with zeros to ensure null-termination + if (ioctl(fd, DMA_Get_GITV, gitv) < 0) { + return ""; + } + gitv[32 - 1] = '\0'; // Ensure null-termination + return std::string(gitv); +} + +/** + * dmaMapDma - Map user space to DMA buffers. + * @fd: File descriptor to use. + * @count: Pointer to store the count of buffers. + * @size: Pointer to store the size of each buffer. + * + * This function maps DMA buffers into user space, allowing direct access. + * + * Returns: Pointer to an array of pointers to the mapped buffers, or NULL on failure. + */ static inline void** dmaMapDma(int32_t fd, uint32_t* count, uint32_t* size) { void* temp; void** ret; @@ -327,7 +676,7 @@ static inline void** dmaMapDma(int32_t fd, uint32_t* count, uint32_t* size) { if (count != NULL) *count = bCount; if (size != NULL) *size = bSize; - if ((ret = (void**)malloc(sizeof(void*) * bCount)) == 0) return (NULL); + if ((ret = reinterpret_cast(malloc(sizeof(void*) * bCount))) == 0) return (NULL); // Attempt to map gCount = 0; @@ -347,7 +696,15 @@ static inline void** dmaMapDma(int32_t fd, uint32_t* count, uint32_t* size) { return (ret); } -// Free space mapping to dma buffers +/** + * dmaUnMapDma - Unmap user space from DMA buffers. + * @fd: File descriptor to use. + * @buffer: Array of pointers to the mapped buffers. + * + * This function unmaps DMA buffers from user space, releasing the resources. + * + * Returns: 0 on success. + */ static inline ssize_t dmaUnMapDma(int32_t fd, void** buffer) { uint32_t bCount; uint32_t bSize; @@ -362,12 +719,29 @@ static inline ssize_t dmaUnMapDma(int32_t fd, void** buffer) { return (0); } -// Set debug +/** + * dmaSetDebug - Set debugging level for DMA operations. + * @fd: File descriptor for the DMA device. + * @level: Debugging level to be set. + * + * This function sets the specified debugging level for DMA operations + * using an IOCTL command. + * + * Return: Result from the IOCTL call. + */ static inline ssize_t dmaSetDebug(int32_t fd, uint32_t level) { return (ioctl(fd, DMA_Set_Debug, level)); } -// Assign interrupt handler +/** + * dmaAssignHandler - Assign a signal handler for asynchronous DMA operations. + * @fd: File descriptor for the DMA device. + * @handler: Function pointer to the signal handler. + * + * This function sets up a signal action structure to handle SIGIO signals + * with the specified handler function. It also sets the file descriptor to + * receive signals for asynchronous I/O. + */ static inline void dmaAssignHandler(int32_t fd, void (*handler)(int32_t)) { struct sigaction act; int32_t oflags; @@ -382,17 +756,37 @@ static inline void dmaAssignHandler(int32_t fd, void (*handler)(int32_t)) { fcntl(fd, F_SETFL, oflags | FASYNC); } -// set mask +/** + * dmaSetMask - Set DMA mask. + * @fd: File descriptor for the DMA device. + * @mask: DMA mask to be set. + * + * Sets a DMA mask using an IOCTL command. + * + * Return: Result from the IOCTL call. + */ static inline ssize_t dmaSetMask(int32_t fd, uint32_t mask) { return (ioctl(fd, DMA_Set_Mask, mask)); } -// Init mask byte array +/** + * dmaInitMaskBytes - Initialize DMA mask byte array. + * @mask: Pointer to the DMA mask byte array. + * + * Initializes the DMA mask byte array to zeros. + */ static inline void dmaInitMaskBytes(uint8_t* mask) { memset(mask, 0, DMA_MASK_SIZE); } -// Add destination to mask byte array +/** + * dmaAddMaskBytes - Add a destination to the DMA mask byte array. + * @mask: Pointer to the DMA mask byte array. + * @dest: Destination index to set in the mask. + * + * Adds a destination to the DMA mask byte array by setting the appropriate + * bit based on the destination index. + */ static inline void dmaAddMaskBytes(uint8_t* mask, uint32_t dest) { uint32_t byte; uint32_t bit; @@ -404,19 +798,55 @@ static inline void dmaAddMaskBytes(uint8_t* mask, uint32_t dest) { } } -// set mask byte array to driver +/** + * dmaSetMaskBytes - Set mask byte array to the driver. + * @fd: File descriptor for the DMA device. + * @mask: Pointer to the DMA mask byte array. + * + * Sets the DMA mask byte array using an IOCTL command. + * + * Return: Result from the IOCTL call. + */ static inline ssize_t dmaSetMaskBytes(int32_t fd, uint8_t* mask) { return (ioctl(fd, DMA_Set_MaskBytes, mask)); } -// Check API version, return negative on error +/** + * dmaCheckVersion - Check API version of the DMA driver. + * @fd: File descriptor for the DMA device. + * + * Checks the API version of the DMA driver to ensure compatibility. + * + * Return: 0 if the version matches, -1 otherwise. + */ static inline ssize_t dmaCheckVersion(int32_t fd) { int32_t version; version = ioctl(fd, DMA_Get_Version); - return ((version == DMA_VERSION) ? -0 : -1); + return ((version == DMA_VERSION) ? 0 : -1); } -// Write Register +/** + * dmaGetApiVersion - Get API version of the DMA driver. + * @fd: File descriptor for the DMA device. + * + * Get the API version of the DMA driver + * + * Return: The API version of the DMA driver + */ +static inline ssize_t dmaGetApiVersion(int32_t fd) { + return (ioctl(fd, DMA_Get_Version, 0)); +} + +/** + * dmaWriteRegister - Write to a DMA register. + * @fd: File descriptor for the DMA device. + * @address: Register address. + * @data: Data to write. + * + * Writes data to a specified register address using an IOCTL command. + * + * Return: Result from the IOCTL call. + */ static inline ssize_t dmaWriteRegister(int32_t fd, uint64_t address, uint32_t data) { struct DmaRegisterData reg; @@ -425,40 +855,78 @@ static inline ssize_t dmaWriteRegister(int32_t fd, uint64_t address, uint32_t da return (ioctl(fd, DMA_Write_Register, ®)); } -// Read Register +/** + * dmaReadRegister - Read a value from a DMA register. + * @fd: File descriptor for the DMA device. + * @address: The address of the register to be read. + * @data: Pointer to store the read data. + * + * This function reads a 32-bit value from a specified DMA register address. + * The read value is stored in the location pointed to by @data if @data is not NULL. + * + * Return: The result of the ioctl operation, indicating success or failure. + */ static inline ssize_t dmaReadRegister(int32_t fd, uint64_t address, uint32_t* data) { struct DmaRegisterData reg; ssize_t res; + // Initialize register data structure reg.address = address; reg.data = 0; - res = ioctl(fd, DMA_Read_Register, ®); + // Perform ioctl to read the register + res = ioctl(fd, DMA_Read_Register, ®); + + // If data pointer is valid, update it with the read value if (data != NULL) *data = reg.data; - return (res); + return res; } -// Return user space mapping to a relative register space +/** + * dmaMapRegister - Map a DMA register space to user space. + * @fd: File descriptor for the DMA device. + * @offset: Offset from the start of the register space to be mapped. + * @size: Size of the memory region to map. + * + * This function calculates an internal offset based on the buffer size and count + * obtained from the DMA device. It then attempts to map a region of memory into + * the user space corresponding to this calculated offset plus the specified @offset. + * + * Return: A pointer to the mapped memory region in user space, or MAP_FAILED on failure. + */ static inline void* dmaMapRegister(int32_t fd, off_t offset, uint32_t size) { - uint32_t bCount; uint32_t bSize; + uint32_t bCount; off_t intOffset; + // Obtain buffer size and count from the DMA device bSize = ioctl(fd, DMA_Get_Buff_Size, 0); bCount = ioctl(fd, DMA_Get_Buff_Count, 0); + // Calculate internal offset intOffset = (bSize * bCount) + offset; - // Attempt to map - return (mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, intOffset)); + // Attempt to map the memory region into user space + return mmap(0, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd, intOffset); } -// Free space mapping to dma buffers +/** + * dmaUnMapRegister - Unmap a DMA register space from user space. + * @fd: File descriptor for the DMA device. (Unused in this function, but kept for symmetry with map function) + * @ptr: Pointer to the start of the mapped memory region. + * @size: Size of the memory region to unmap. + * + * This function unmaps a previously mapped region of memory from the user space. + * The @fd parameter is not used but is included for symmetry with the dmaMapRegister function. + * + * Return: Always returns 0 indicating success. + */ static inline ssize_t dmaUnMapRegister(int32_t fd, void* ptr, uint32_t size) { + // Unmap the memory region munmap(ptr, size); - return (0); + return 0; } -#endif -#endif +#endif // !DMA_IN_KERNEL +#endif // __DMA_DRIVER_H__ diff --git a/include/rogue/hardware/drivers/PgpDriver.h b/include/rogue/hardware/drivers/PgpDriver.h deleted file mode 100644 index 575d48b27..000000000 --- a/include/rogue/hardware/drivers/PgpDriver.h +++ /dev/null @@ -1,329 +0,0 @@ -/** - *----------------------------------------------------------------------------- - * Title : PGP Card Driver, Shared Header - * ---------------------------------------------------------------------------- - * Description: - * Definitions and inline functions for interacting with PGP driver. - * ---------------------------------------------------------------------------- - * This file is part of the aes_stream_drivers package. It is subject to - * the license terms in the LICENSE.txt file found in the top-level directory - * of this distribution and at: - * https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. - * No part of the aes_stream_drivers package, including this file, may be - * copied, modified, propagated, or distributed except according to the terms - * contained in the LICENSE.txt file. - * ---------------------------------------------------------------------------- - **/ -#ifndef __PGP_DRIVER_H__ -#define __PGP_DRIVER_H__ -#include "DmaDriver.h" - -//! PGP Card Info -struct PgpInfo { - //! PGP Card Serial # - uint64_t serial; - - //! PGP Card Type - uint32_t type; - - //! PGP Card Version - uint32_t version; - - //! PGP Card Lane Mask - uint32_t laneMask; - - //! PGP Card VCs per Lane Mask - uint32_t vcPerMask; - - //! PGP Card Line Rate - uint32_t pgpRate; - - //! PGP Card Prom Programming Support Flag - uint32_t promPrgEn; - - //! PGP Card EVR Support Flag - uint32_t evrSupport; - - uint32_t pad; - - char buildStamp[256]; -}; - -//! PCI Status -struct PciStatus { - //! PCI Express Command Field - uint32_t pciCommand; - - //! PCI Express Status Field - uint32_t pciStatus; - - //! PCI Express D Command Field - uint32_t pciDCommand; - - //! PCI Express D Status Field - uint32_t pciDStatus; - - //! PCI Express L Command Field - uint32_t pciLCommand; - - //! PCI Express L Status Field - uint32_t pciLStatus; - - //! PCI Express Link State - uint32_t pciLinkState; - - //! PCI Express Function Number - uint32_t pciFunction; - - //! PCI Express Device Number - uint32_t pciDevice; - - //! PCI Express Bus Number - uint32_t pciBus; - - //! Number Of PCI Lanes - uint32_t pciLanes; - - uint32_t pad; -}; - -//! PGP Lane Status -struct PgpStatus { - //! Lane number associated with this record - uint32_t lane; - - //! Lane loopback status - uint32_t loopBack; - - //! Lane local link ready status - uint32_t locLinkReady; - - //! Lane remote link ready status - uint32_t remLinkReady; - - //! Lane receive PLL ready status - uint32_t rxReady; - - //! Lane transmit PLL ready status - uint32_t txReady; - - //! Lane receive frame counter - uint32_t rxCount; - - //! Lane cell error counter - uint32_t cellErrCnt; - - //! Lane link lost transition counter - uint32_t linkDownCnt; - - //! Lane link error counter - uint32_t linkErrCnt; - - //! Lane FIFO error counter - uint32_t fifoErr; - - //! Lane current received remote sideband data - uint32_t remData; - - //! Lane remote buffer status - uint32_t remBuffStatus; - - uint32_t pad; -}; - -//! EVR Control, one per lane -struct PgpEvrControl { - //! Lane number associated with this record - uint32_t lane; - - //! Global EVR enable for all lanes, 1 = enable, 0 = disabled - uint32_t evrEnable; // Global flag - - //! Run trigger enable for this lane, 1 = enable, 0 = disable - uint32_t laneRunMask; // 1 = Run trigger enable - - //! EVR Sync enable, 1 = start, 0 = stop - uint32_t evrSyncEn; // 1 = Start, 0 = Stop - - //! Sync select, 0 = async, 1 = sync for start/stop - uint32_t evrSyncSel; // 0 = async, 1 = sync for start/stop - - //! Header checking mask, 1 enable bit for each of 4 virtual channels. - uint32_t headerMask; // 1 = Enable header data checking, one bit per VC (4 bits) - - //! EVR Sync word, 32-bit timing fidicial to transition start/stop on - uint32_t evrSyncWord; // fiducial to transition start stop - - //! 8-bit timing code to assert run trigger - uint32_t runCode; // Run code - - //! Delay between timing code reception and assertion of run trigger - uint32_t runDelay; // Run delay - - //! 8-bit timing code to assert accept trigger - uint32_t acceptCode; // Accept code - - //! Delay between timing code reception and assertion of accept trigger - uint32_t acceptDelay; // Accept delay - - uint32_t pad; -}; - -//! EVR Status, one per lane -struct PgpEvrStatus { - //! Lane number associated with this record - uint32_t lane; - - //! EVR link error counter - uint32_t linkErrors; - - //! EVR link up state, 0 = down, 1 = up - uint32_t linkUp; - - //! EVR running status, 0 = stopped, 1 = running - uint32_t runStatus; // 1 = Running, 0 = Stopped - - //! Current distributed timing seconds value - uint32_t evrSeconds; - - //! Number of run triggers received - uint32_t runCounter; - - //! Number of accepts triggers received - uint32_t acceptCounter; - - uint32_t pad; -}; - -// Card Types -#define PGP_NONE 0x00 -#define PGP_GEN1 0x01 -#define PGP_GEN2 0x02 -#define PGP_GEN2_VCI 0x12 -#define PGP_GEN3 0x03 -#define PGP_GEN3_VCI 0x13 - -// Error values -#define PGP_ERR_EOFE 0x10 - -// Commands -#define PGP_Read_Info 0x2001 -#define PGP_Read_Pci 0x2002 -#define PGP_Read_Status 0x2003 -#define PGP_Set_Loop 0x2004 -#define PGP_Count_Reset 0x2005 -#define PGP_Send_OpCode 0x2006 -#define PGP_Set_Data 0x2007 -#define PGP_Set_Evr_Cntrl 0x3001 -#define PGP_Get_Evr_Cntrl 0x3002 -#define PGP_Get_Evr_Status 0x3003 -#define PGP_Rst_Evr_Count 0x3004 - -// Everything below is hidden during kernel module compile -#ifndef DMA_IN_KERNEL - -static inline uint32_t pgpSetDest(uint32_t lane, uint32_t vc) { - uint32_t dest; - - dest = lane * 4; - dest += vc; - return (dest); -} - -static inline uint32_t pgpSetFlags(uint32_t cont) { - return (cont & 0x1); -} - -static inline uint32_t pgpGetLane(uint32_t dest) { - return (dest / 4); -} - -static inline uint32_t pgpGetVc(uint32_t dest) { - return (dest % 4); -} - -static inline uint32_t pgpGetCont(uint32_t flags) { - return (flags & 0x1); -} - -// Read Card Info -static inline ssize_t pgpGetInfo(int32_t fd, struct PgpInfo* info) { - return (ioctl(fd, PGP_Read_Info, info)); -} - -// Read PCI Status -static inline ssize_t pgpGetPci(int32_t fd, struct PciStatus* status) { - return (ioctl(fd, PGP_Read_Pci, status)); -} - -// Read Lane Status -static inline ssize_t pgpGetStatus(int32_t fd, uint32_t lane, struct PgpStatus* status) { - status->lane = lane; - return (ioctl(fd, PGP_Read_Status, status)); -} - -// Set Loopback State For Lane -static inline ssize_t pgpSetLoop(int32_t fd, uint32_t lane, uint32_t state) { - uint32_t temp; - - temp = lane & 0xFF; - temp |= ((state << 8) & 0x100); - - return (ioctl(fd, PGP_Set_Loop, temp)); -} - -// Reset counters -static inline ssize_t pgpCountReset(int32_t fd) { - return (ioctl(fd, PGP_Count_Reset, 0)); -} - -// Set Sideband Data -static inline ssize_t pgpSetData(int32_t fd, uint32_t lane, uint32_t data) { - uint32_t temp; - - temp = lane & 0xFF; - temp |= ((data << 8) & 0xFF00); - - return (ioctl(fd, PGP_Set_Data, temp)); -} - -// Send OpCode -static inline ssize_t pgpSendOpCode(int32_t fd, uint32_t code) { - return (ioctl(fd, PGP_Send_OpCode, code)); -} - -// Set EVR Control -static inline ssize_t pgpSetEvrControl(int32_t fd, uint32_t lane, struct PgpEvrControl* control) { - control->lane = lane; - return (ioctl(fd, PGP_Set_Evr_Cntrl, control)); -} - -// Get EVR Control -static inline ssize_t pgpGetEvrControl(int32_t fd, uint32_t lane, struct PgpEvrControl* control) { - control->lane = lane; - return (ioctl(fd, PGP_Get_Evr_Cntrl, control)); -} - -// Get EVR Status -static inline ssize_t pgpGetEvrStatus(int32_t fd, uint32_t lane, struct PgpEvrStatus* status) { - status->lane = lane; - return (ioctl(fd, PGP_Get_Evr_Status, status)); -} - -// Reset EVR Counters -static inline ssize_t pgpResetEvrCount(int32_t fd, uint32_t lane) { - return (ioctl(fd, PGP_Rst_Evr_Count, lane)); -} - -// Add destination to mask byte array -static inline void pgpAddMaskBytes(uint8_t* mask, uint32_t lane, uint32_t vc) { - dmaAddMaskBytes(mask, lane * 4 + vc); -} - -// set lane/vc rx mask, one bit per vc -static inline ssize_t pgpSetMask(int32_t fd, uint32_t lane, uint32_t vc) { - return (dmaSetMask(fd, lane * 4 + vc)); -} - -#endif -#endif diff --git a/include/rogue/hardware/module.h b/include/rogue/hardware/module.h index 7e8ece178..7995233f1 100644 --- a/include/rogue/hardware/module.h +++ b/include/rogue/hardware/module.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/include/rogue/interfaces/ZmqClient.h b/include/rogue/interfaces/ZmqClient.h index 45c7c6356..02e9ab673 100644 --- a/include/rogue/interfaces/ZmqClient.h +++ b/include/rogue/interfaces/ZmqClient.h @@ -1,9 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : Rogue ZMQ Control Interface * ---------------------------------------------------------------------------- - * File : ZmqClient.h - * Created : 2019-05-02 + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- + * Description: + * Rogue ZMQ Control Interface * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory @@ -19,12 +19,13 @@ #include "rogue/Directives.h" #include +#include #include #include "rogue/Logging.h" #ifndef NO_PYTHON -#include + #include #endif namespace rogue { diff --git a/include/rogue/interfaces/ZmqServer.h b/include/rogue/interfaces/ZmqServer.h index 8a4ef7168..bae9d432d 100644 --- a/include/rogue/interfaces/ZmqServer.h +++ b/include/rogue/interfaces/ZmqServer.h @@ -1,9 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : Rogue ZMQ Control Interface * ---------------------------------------------------------------------------- - * File : ZmqServer.h - * Created : 2019-05-02 + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- + * Description: + * Rogue ZMQ Control Interface * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory @@ -19,12 +19,13 @@ #include "rogue/Directives.h" #include +#include #include #include "rogue/Logging.h" #ifndef NO_PYTHON -#include + #include #endif namespace rogue { diff --git a/include/rogue/interfaces/api/Bsp.h b/include/rogue/interfaces/api/Bsp.h index e945e3554..39296788e 100644 --- a/include/rogue/interfaces/api/Bsp.h +++ b/include/rogue/interfaces/api/Bsp.h @@ -1,9 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : C++ API Bsp * ---------------------------------------------------------------------------- - * File : Bsp.h - * Created : 2023-04-17 + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- + * Description: + * C++ API BSP (Board Support Package) * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory @@ -16,7 +16,10 @@ **/ #ifndef __ROGUE_INTERFACE_API_BSP_H__ #define __ROGUE_INTERFACE_API_BSP_H__ + #include +#include +#include #include namespace rogue { @@ -36,7 +39,7 @@ class Bsp { static std::shared_ptr create(std::string modName, std::string rootClass); //! Create the object - Bsp(boost::python::object obj); + explicit Bsp(boost::python::object obj); Bsp(std::string modName, std::string rootClass); ~Bsp(); diff --git a/include/rogue/interfaces/memory/Block.h b/include/rogue/interfaces/memory/Block.h index 41cef7ad8..5943bcef4 100644 --- a/include/rogue/interfaces/memory/Block.h +++ b/include/rogue/interfaces/memory/Block.h @@ -1,8 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Memory Block * ---------------------------------------------------------------------------- - * File : Block.h + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Interface between RemoteVariables and lower level memory transactions. @@ -23,13 +21,14 @@ #include #include +#include #include #include #include "rogue/interfaces/memory/Master.h" #ifndef NO_PYTHON -#include + #include #endif namespace rogue { @@ -49,7 +48,9 @@ template inline boost::python::list std_vector_to_py_list(std::vector vector) { typename std::vector::iterator iter; boost::python::list list; - for (iter = vector.begin(); iter != vector.end(); ++iter) { list.append(*iter); } + for (iter = vector.begin(); iter != vector.end(); ++iter) { + list.append(*iter); + } return list; } diff --git a/include/rogue/interfaces/memory/Constants.h b/include/rogue/interfaces/memory/Constants.h index 3017cf786..d54013c3e 100644 --- a/include/rogue/interfaces/memory/Constants.h +++ b/include/rogue/interfaces/memory/Constants.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Memory Master * ---------------------------------------------------------------------------- - * File : Constants.h - * Created : 2016-12-05 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Memory error and transaction constants. diff --git a/include/rogue/interfaces/memory/Emulate.h b/include/rogue/interfaces/memory/Emulate.h index 9448ddc80..3b1907c81 100644 --- a/include/rogue/interfaces/memory/Emulate.h +++ b/include/rogue/interfaces/memory/Emulate.h @@ -1,8 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Memory slave emulator * ---------------------------------------------------------------------------- - * File : Emulator.h + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * A memory space emulator. Allows user to test a Rogue tree without real hardware. @@ -30,7 +28,7 @@ #include "rogue/interfaces/memory/Slave.h" #ifndef NO_PYTHON -#include + #include #endif #define MAP_TYPE std::map @@ -50,6 +48,13 @@ class Emulate : public Slave { // Lock std::mutex mtx_; + // Total allocated memory + uint32_t totAlloc_; + uint32_t totSize_; + + //! Log + std::shared_ptr log_; + public: //! Class factory which returns a pointer to a Emulate (EmulatePtr) /** Exposed to Python as rogue.interfaces.memory.Emualte() diff --git a/include/rogue/interfaces/memory/Hub.h b/include/rogue/interfaces/memory/Hub.h index 9f09b18a9..ea027543c 100644 --- a/include/rogue/interfaces/memory/Hub.h +++ b/include/rogue/interfaces/memory/Hub.h @@ -1,10 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Hub Hub * ---------------------------------------------------------------------------- - * File : Hub.h - * Author : Ryan Herbst, rherbst@slac.stanford.edu - * Created : 2016-09-20 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * A memory interface hub. Accepts requests from multiple masters and forwards @@ -26,6 +22,8 @@ #include +#include +#include #include #include "rogue/Logging.h" @@ -33,7 +31,7 @@ #include "rogue/interfaces/memory/Slave.h" #ifndef NO_PYTHON -#include + #include #endif namespace rogue { diff --git a/include/rogue/interfaces/memory/Master.h b/include/rogue/interfaces/memory/Master.h index d2c8f0b61..fd65c3357 100644 --- a/include/rogue/interfaces/memory/Master.h +++ b/include/rogue/interfaces/memory/Master.h @@ -1,10 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Memory Master * ---------------------------------------------------------------------------- - * File : Master.h - * Author : Ryan Herbst, rherbst@slac.stanford.edu - * Created : 2016-09-20 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Memory master interface. @@ -26,13 +22,14 @@ #include #include +#include #include #include #include "rogue/Logging.h" #ifndef NO_PYTHON -#include + #include #endif namespace rogue { diff --git a/include/rogue/interfaces/memory/Slave.h b/include/rogue/interfaces/memory/Slave.h index 3ea573fab..111e22d47 100644 --- a/include/rogue/interfaces/memory/Slave.h +++ b/include/rogue/interfaces/memory/Slave.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Memory Slave * ---------------------------------------------------------------------------- - * File : Slave.h - * Created : 2016-09-20 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Memory slave interface. @@ -25,6 +22,7 @@ #include #include +#include #include #include "rogue/EnableSharedFromThis.h" @@ -32,7 +30,7 @@ #include "rogue/interfaces/memory/Transaction.h" #ifndef NO_PYTHON -#include + #include #endif namespace rogue { diff --git a/include/rogue/interfaces/memory/TcpClient.h b/include/rogue/interfaces/memory/TcpClient.h index 702bc2bb8..1870c7cb9 100644 --- a/include/rogue/interfaces/memory/TcpClient.h +++ b/include/rogue/interfaces/memory/TcpClient.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Memory Client Network Bridge * ---------------------------------------------------------------------------- - * File : TcpClient.h - * Created : 2019-01-30 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Memory Client Network Bridge @@ -24,6 +21,7 @@ #include #include +#include #include #include "rogue/Logging.h" diff --git a/include/rogue/interfaces/memory/TcpServer.h b/include/rogue/interfaces/memory/TcpServer.h index b011dcbdb..d2194d05f 100644 --- a/include/rogue/interfaces/memory/TcpServer.h +++ b/include/rogue/interfaces/memory/TcpServer.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Memory Server Network Bridge * ---------------------------------------------------------------------------- - * File : TcpServer.h - * Created : 2019-01-30 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Memory Server Network Bridge @@ -24,6 +21,7 @@ #include #include +#include #include #include "rogue/Logging.h" diff --git a/include/rogue/interfaces/memory/Transaction.h b/include/rogue/interfaces/memory/Transaction.h index 2f6908d09..a8f5c8634 100644 --- a/include/rogue/interfaces/memory/Transaction.h +++ b/include/rogue/interfaces/memory/Transaction.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Memory Transaction * ---------------------------------------------------------------------------- - * File : Transaction.h - * Created : 2019-03-08 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Memory Transaction @@ -27,13 +24,14 @@ #include #include #include +#include #include #include "rogue/EnableSharedFromThis.h" #include "rogue/Logging.h" #ifndef NO_PYTHON -#include + #include #endif namespace rogue { @@ -146,7 +144,7 @@ class Transaction : public rogue::EnableSharedFromThis transaction); // Transaction lock constructor - TransactionLock(std::shared_ptr transaction); + explicit TransactionLock(std::shared_ptr transaction); // Setup class for use in python static void setup_python(); diff --git a/include/rogue/interfaces/memory/Variable.h b/include/rogue/interfaces/memory/Variable.h index 349e5329c..cd335e39a 100644 --- a/include/rogue/interfaces/memory/Variable.h +++ b/include/rogue/interfaces/memory/Variable.h @@ -1,8 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Memory Variable * ---------------------------------------------------------------------------- - * File : Variable.h + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Base class for RemoteVariable as well as direct C++ access @@ -31,7 +29,7 @@ #include "rogue/EnableSharedFromThis.h" #ifndef NO_PYTHON -#include + #include #endif namespace rogue { @@ -67,19 +65,19 @@ class Variable { // Bit reverse flag bool bitReverse_; - // Total number of bits for this value + // Total number of used bits for this value, used for standard non list variables uint32_t bitTotal_; // Fast copy base array uint32_t* fastByte_; - // Total bytes (rounded up) for this value + // Total bytes (rounded up) for this value, based upon bitTotal_ uint32_t byteSize_; - // Variable coverage bytes + // Variable coverage bytes, regardless of if bits are used uint32_t varBytes_; - // Variable offset + // Variable offset, in bytes uint64_t offset_; // Array of bit offsets @@ -110,16 +108,10 @@ class Variable { bool verifyEn_; // Low byte value - uint32_t lowTranByte_; + uint32_t* lowTranByte_; // High byte value - uint32_t highTranByte_; - - // Low byte value for list variables - uint32_t* listLowTranByte_; - - // High byte value for list variables - uint32_t* listHighTranByte_; + uint32_t* highTranByte_; // Poiner to custom data void* customData_; diff --git a/include/rogue/interfaces/memory/module.h b/include/rogue/interfaces/memory/module.h index a1bf9fb73..ac37a9ab5 100644 --- a/include/rogue/interfaces/memory/module.h +++ b/include/rogue/interfaces/memory/module.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module For Memory Interface + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/include/rogue/interfaces/module.h b/include/rogue/interfaces/module.h index 34b7ba318..6fecddb0c 100644 --- a/include/rogue/interfaces/module.h +++ b/include/rogue/interfaces/module.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/include/rogue/interfaces/stream/Buffer.h b/include/rogue/interfaces/stream/Buffer.h index 6b357e29f..0ebe0d823 100644 --- a/include/rogue/interfaces/stream/Buffer.h +++ b/include/rogue/interfaces/stream/Buffer.h @@ -1,13 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : Stream Buffer Container * ---------------------------------------------------------------------------- - * File : Buffer.h - * Author : Ryan Herbst, rherbst@slac.stanford.edu + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Stream frame container - * Some concepts borrowed from CPSW by Till Straumann * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory diff --git a/include/rogue/interfaces/stream/Fifo.h b/include/rogue/interfaces/stream/Fifo.h index 7c0f71bd8..cc19038a5 100644 --- a/include/rogue/interfaces/stream/Fifo.h +++ b/include/rogue/interfaces/stream/Fifo.h @@ -1,11 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : AXI Stream FIFO * ---------------------------------------------------------------------------- - * File : Fifo.h - * Author : Ryan Herbst - * Created : 02/02/2018 - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * AXI Stream FIFO *----------------------------------------------------------------------------- diff --git a/include/rogue/interfaces/stream/Filter.h b/include/rogue/interfaces/stream/Filter.h index 98762bb5d..5e883236b 100644 --- a/include/rogue/interfaces/stream/Filter.h +++ b/include/rogue/interfaces/stream/Filter.h @@ -1,11 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : SLAC Stream Filter * ---------------------------------------------------------------------------- - * File : Filter.h - * Author : Ryan Herbst - * Created : 11/01/2018 - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * AXI Stream Filter *----------------------------------------------------------------------------- diff --git a/include/rogue/interfaces/stream/Frame.h b/include/rogue/interfaces/stream/Frame.h index 138206663..a1598a7d6 100644 --- a/include/rogue/interfaces/stream/Frame.h +++ b/include/rogue/interfaces/stream/Frame.h @@ -1,14 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : Stream frame container * ---------------------------------------------------------------------------- - * File : Frame.h - * Author : Ryan Herbst, rherbst@slac.stanford.edu - * Created : 2016-09-16 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Stream frame container - * Some concepts borrowed from CPSW by Till Straumann * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory @@ -33,7 +28,7 @@ #include "rogue/EnableSharedFromThis.h" #ifndef NO_PYTHON -#include + #include #endif namespace rogue { diff --git a/include/rogue/interfaces/stream/FrameAccessor.h b/include/rogue/interfaces/stream/FrameAccessor.h index 22acf9eb8..e457bb638 100644 --- a/include/rogue/interfaces/stream/FrameAccessor.h +++ b/include/rogue/interfaces/stream/FrameAccessor.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Stream frame accessor * ---------------------------------------------------------------------------- - * File : FrameAccessor.h - * Created : 2018-03-06 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Stream frame iterator @@ -46,7 +43,7 @@ class FrameAccessor { public: //! Creator FrameAccessor(rogue::interfaces::stream::FrameIterator& iter, uint32_t size) { - data_ = (T*)iter.ptr(); + data_ = reinterpret_cast(iter.ptr()); size_ = size; if (size * sizeof(T) > iter.remBuffer()) diff --git a/include/rogue/interfaces/stream/FrameIterator.h b/include/rogue/interfaces/stream/FrameIterator.h index ef34d6e78..896e3af32 100644 --- a/include/rogue/interfaces/stream/FrameIterator.h +++ b/include/rogue/interfaces/stream/FrameIterator.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Stream frame iterator * ---------------------------------------------------------------------------- - * File : FrameIterator.h - * Created : 2018-03-06 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Stream frame iterator diff --git a/include/rogue/interfaces/stream/FrameLock.h b/include/rogue/interfaces/stream/FrameLock.h index a248668c4..677f1d52d 100644 --- a/include/rogue/interfaces/stream/FrameLock.h +++ b/include/rogue/interfaces/stream/FrameLock.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Memory Frame Lock * ---------------------------------------------------------------------------- - * File : FrameLock.h - * Created : 2018-03-16 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Memory Frame lock @@ -54,7 +51,7 @@ class FrameLock { std::shared_ptr frame); // Frame lock constructor - FrameLock(std::shared_ptr frame); + explicit FrameLock(std::shared_ptr frame); // Setup class for use in python static void setup_python(); diff --git a/include/rogue/interfaces/stream/Master.h b/include/rogue/interfaces/stream/Master.h index 10ceb5c35..f64316074 100644 --- a/include/rogue/interfaces/stream/Master.h +++ b/include/rogue/interfaces/stream/Master.h @@ -1,10 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Stream interface master * ---------------------------------------------------------------------------- - * File : Master.h - * Author : Ryan Herbst, rherbst@slac.stanford.edu - * Created : 2016-09-16 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Stream interface master @@ -34,7 +30,7 @@ #include "rogue/EnableSharedFromThis.h" #ifndef NO_PYTHON -#include + #include #endif namespace rogue { diff --git a/include/rogue/interfaces/stream/Pool.h b/include/rogue/interfaces/stream/Pool.h index f3772949a..0f037ea3b 100644 --- a/include/rogue/interfaces/stream/Pool.h +++ b/include/rogue/interfaces/stream/Pool.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Stream memory pool * ---------------------------------------------------------------------------- - * File : Pool.h - * Created : 2016-09-16 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Stream memory pool @@ -24,6 +21,7 @@ #include #include +#include #include #include "rogue/EnableSharedFromThis.h" diff --git a/include/rogue/interfaces/stream/RateDrop.h b/include/rogue/interfaces/stream/RateDrop.h index e423d3360..b3c5d42dc 100644 --- a/include/rogue/interfaces/stream/RateDrop.h +++ b/include/rogue/interfaces/stream/RateDrop.h @@ -1,11 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : SLAC Stream Interface Rate Drop * ---------------------------------------------------------------------------- - * File : RateDrop.h - * Author : Ryan Herbst - * Created : 08/25/2020 - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * Drops frames at a specified rate. *----------------------------------------------------------------------------- diff --git a/include/rogue/interfaces/stream/Slave.h b/include/rogue/interfaces/stream/Slave.h index 029d44b1e..09ecd55b0 100644 --- a/include/rogue/interfaces/stream/Slave.h +++ b/include/rogue/interfaces/stream/Slave.h @@ -1,10 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Stream interface slave * ---------------------------------------------------------------------------- - * File : Slave.h - * Author : Ryan Herbst, rherbst@slac.stanford.edu - * Created : 2016-09-16 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Stream interface slave @@ -25,6 +21,7 @@ #include #include +#include #include #include "rogue/EnableSharedFromThis.h" @@ -32,7 +29,7 @@ #include "rogue/interfaces/stream/Pool.h" #ifndef NO_PYTHON -#include + #include #endif namespace rogue { diff --git a/include/rogue/interfaces/stream/TcpClient.h b/include/rogue/interfaces/stream/TcpClient.h index a3a67313e..69056134d 100644 --- a/include/rogue/interfaces/stream/TcpClient.h +++ b/include/rogue/interfaces/stream/TcpClient.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Stream Network Client * ---------------------------------------------------------------------------- - * File : TcpClient.h - * Created : 2019-01-30 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Stream Network Client @@ -24,6 +21,7 @@ #include #include +#include #include #include "rogue/Logging.h" diff --git a/include/rogue/interfaces/stream/TcpCore.h b/include/rogue/interfaces/stream/TcpCore.h index c2adbcb2d..53a89e4a0 100644 --- a/include/rogue/interfaces/stream/TcpCore.h +++ b/include/rogue/interfaces/stream/TcpCore.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Stream Network Core * ---------------------------------------------------------------------------- - * File : TcpCore.h - * Created : 2019-01-30 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Stream Network Core @@ -24,6 +21,7 @@ #include #include +#include #include #include "rogue/Logging.h" diff --git a/include/rogue/interfaces/stream/TcpServer.h b/include/rogue/interfaces/stream/TcpServer.h index f6813d980..06fc498b3 100644 --- a/include/rogue/interfaces/stream/TcpServer.h +++ b/include/rogue/interfaces/stream/TcpServer.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Stream Network Server * ---------------------------------------------------------------------------- - * File : TcpServer.h - * Created : 2019-01-30 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Stream Network Server @@ -24,6 +21,7 @@ #include #include +#include #include #include "rogue/Logging.h" diff --git a/include/rogue/interfaces/stream/module.h b/include/rogue/interfaces/stream/module.h index b49708bc4..cd07f3221 100644 --- a/include/rogue/interfaces/stream/module.h +++ b/include/rogue/interfaces/stream/module.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module For Stream Interface + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/include/rogue/module.h b/include/rogue/module.h index 8daddb871..ac45ffa45 100644 --- a/include/rogue/module.h +++ b/include/rogue/module.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/include/rogue/protocols/batcher/CoreV1.h b/include/rogue/protocols/batcher/CoreV1.h index fbae38d76..d75b46e63 100644 --- a/include/rogue/protocols/batcher/CoreV1.h +++ b/include/rogue/protocols/batcher/CoreV1.h @@ -1,13 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : SLAC Batcher Version 1, Core * ---------------------------------------------------------------------------- - * File : Core.h - * Author : Ryan Herbst - * Created : 10/26/2018 - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : - * AXI Batcher V1 + * SLAC AXI Batcher V1 *----------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory @@ -26,6 +22,7 @@ #include #include +#include #include "rogue/Logging.h" #include "rogue/interfaces/stream/Frame.h" diff --git a/include/rogue/protocols/batcher/Data.h b/include/rogue/protocols/batcher/Data.h index e5b8c6b16..630576479 100644 --- a/include/rogue/protocols/batcher/Data.h +++ b/include/rogue/protocols/batcher/Data.h @@ -1,11 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : SLAC Batcher Data Container * ---------------------------------------------------------------------------- - * File : Data.h - * Author : Ryan Herbst - * Created : 02/08/2019 - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * AXI Batcher Data *----------------------------------------------------------------------------- diff --git a/include/rogue/protocols/batcher/InverterV1.h b/include/rogue/protocols/batcher/InverterV1.h index d10b8372a..ddeff44df 100644 --- a/include/rogue/protocols/batcher/InverterV1.h +++ b/include/rogue/protocols/batcher/InverterV1.h @@ -1,13 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : SLAC Inverter Version 1 * ---------------------------------------------------------------------------- - * File : InverterV1.h - * Author : Ryan Herbst - * Created : 10/26/2018 - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : - * AXI Inverter V1 + * SLAC AXI Inverter V1 *----------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory diff --git a/include/rogue/protocols/batcher/SplitterV1.h b/include/rogue/protocols/batcher/SplitterV1.h index 6c521de3a..41d1f063d 100644 --- a/include/rogue/protocols/batcher/SplitterV1.h +++ b/include/rogue/protocols/batcher/SplitterV1.h @@ -1,13 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : SLAC Splitter Version 1 * ---------------------------------------------------------------------------- - * File : SplitterV1.h - * Author : Ryan Herbst - * Created : 10/26/2018 - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : - * AXI Splitter V1 + * SLAC AXI Splitter V1 *----------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory diff --git a/include/rogue/protocols/batcher/module.h b/include/rogue/protocols/batcher/module.h index a9a8a7aca..3e5bc4f77 100644 --- a/include/rogue/protocols/batcher/module.h +++ b/include/rogue/protocols/batcher/module.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/include/rogue/protocols/module.h b/include/rogue/protocols/module.h index 3604bf99f..62235fec9 100644 --- a/include/rogue/protocols/module.h +++ b/include/rogue/protocols/module.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/include/rogue/protocols/packetizer/Application.h b/include/rogue/protocols/packetizer/Application.h index b054cc6b6..ad80ea2a8 100644 --- a/include/rogue/protocols/packetizer/Application.h +++ b/include/rogue/protocols/packetizer/Application.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Packetizer Application Class + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Packetizer Application Interface @@ -58,7 +58,7 @@ class Application : public rogue::interfaces::stream::Master, public rogue::inte static void setup_python(); //! Creator - Application(uint8_t id); + explicit Application(uint8_t id); //! Destructor ~Application(); diff --git a/include/rogue/protocols/packetizer/CRC.h b/include/rogue/protocols/packetizer/CRC.h index 4bec680b7..e9862039d 100644 --- a/include/rogue/protocols/packetizer/CRC.h +++ b/include/rogue/protocols/packetizer/CRC.h @@ -60,71 +60,71 @@ #include // Includes CHAR_BIT #ifdef CRCPP_USE_CPP11 -#include // Includes ::std::size_t -#include // Includes ::std::uint8_t, ::std::uint16_t, ::std::uint32_t, ::std::uint64_t + #include // Includes ::std::size_t + #include // Includes ::std::uint8_t, ::std::uint16_t, ::std::uint32_t, ::std::uint64_t #else -#include // Includes size_t -#include // Includes uint8_t, uint16_t, uint32_t, uint64_t + #include // Includes size_t + #include // Includes uint8_t, uint16_t, uint32_t, uint64_t #endif #include // Includes ::std::numeric_limits #include // Includes ::std::move #ifndef crcpp_uint8 -#ifdef CRCPP_USE_CPP11 -/// @brief Unsigned 8-bit integer definition, used primarily for parameter definitions. -#define crcpp_uint8 ::std::uint8_t -#else -/// @brief Unsigned 8-bit integer definition, used primarily for parameter definitions. -#define crcpp_uint8 uint8_t -#endif + #ifdef CRCPP_USE_CPP11 + /// @brief Unsigned 8-bit integer definition, used primarily for parameter definitions. + #define crcpp_uint8 ::std::uint8_t + #else + /// @brief Unsigned 8-bit integer definition, used primarily for parameter definitions. + #define crcpp_uint8 uint8_t + #endif #endif #ifndef crcpp_uint16 -#ifdef CRCPP_USE_CPP11 -/// @brief Unsigned 16-bit integer definition, used primarily for parameter definitions. -#define crcpp_uint16 ::std::uint16_t -#else -/// @brief Unsigned 16-bit integer definition, used primarily for parameter definitions. -#define crcpp_uint16 uint16_t -#endif + #ifdef CRCPP_USE_CPP11 + /// @brief Unsigned 16-bit integer definition, used primarily for parameter definitions. + #define crcpp_uint16 ::std::uint16_t + #else + /// @brief Unsigned 16-bit integer definition, used primarily for parameter definitions. + #define crcpp_uint16 uint16_t + #endif #endif #ifndef crcpp_uint32 -#ifdef CRCPP_USE_CPP11 -/// @brief Unsigned 32-bit integer definition, used primarily for parameter definitions. -#define crcpp_uint32 ::std::uint32_t -#else -/// @brief Unsigned 32-bit integer definition, used primarily for parameter definitions. -#define crcpp_uint32 uint32_t -#endif + #ifdef CRCPP_USE_CPP11 + /// @brief Unsigned 32-bit integer definition, used primarily for parameter definitions. + #define crcpp_uint32 ::std::uint32_t + #else + /// @brief Unsigned 32-bit integer definition, used primarily for parameter definitions. + #define crcpp_uint32 uint32_t + #endif #endif #ifndef crcpp_uint64 -#ifdef CRCPP_USE_CPP11 -/// @brief Unsigned 64-bit integer definition, used primarily for parameter definitions. -#define crcpp_uint64 ::std::uint64_t -#else -/// @brief Unsigned 64-bit integer definition, used primarily for parameter definitions. -#define crcpp_uint64 uint64_t -#endif + #ifdef CRCPP_USE_CPP11 + /// @brief Unsigned 64-bit integer definition, used primarily for parameter definitions. + #define crcpp_uint64 ::std::uint64_t + #else + /// @brief Unsigned 64-bit integer definition, used primarily for parameter definitions. + #define crcpp_uint64 uint64_t + #endif #endif #ifndef crcpp_size -#ifdef CRCPP_USE_CPP11 -/// @brief Unsigned size definition, used for specifying data sizes. -#define crcpp_size ::std::size_t -#else -/// @brief Unsigned size definition, used for specifying data sizes. -#define crcpp_size size_t -#endif + #ifdef CRCPP_USE_CPP11 + /// @brief Unsigned size definition, used for specifying data sizes. + #define crcpp_size ::std::size_t + #else + /// @brief Unsigned size definition, used for specifying data sizes. + #define crcpp_size size_t + #endif #endif #ifdef CRCPP_USE_CPP11 -/// @brief Compile-time expression definition. -#define crcpp_constexpr constexpr + /// @brief Compile-time expression definition. + #define crcpp_constexpr constexpr #else -/// @brief Compile-time expression definition. -#define crcpp_constexpr const + /// @brief Compile-time expression definition. + #define crcpp_constexpr const #endif #ifdef CRCPP_USE_NAMESPACE @@ -165,10 +165,10 @@ class CRC { template struct Table { // Constructors are intentionally NOT marked explicit. - Table(const Parameters& parameters); + Table(const Parameters& parameters); // NOLINT #ifdef CRCPP_USE_CPP11 - Table(Parameters&& parameters); + Table(Parameters&& parameters); // NOLINT #endif const Parameters& GetParameters() const; @@ -273,11 +273,11 @@ class CRC { #endif #ifdef CRCPP_USE_CPP11 - CRC() = delete; - CRC(const CRC& other) = delete; + CRC() = delete; + CRC(const CRC& other) = delete; CRC& operator=(const CRC& other) = delete; CRC(CRC&& other) = delete; - CRC& operator=(CRC&& other) = delete; + CRC& operator=(CRC&& other) = delete; #endif private: @@ -553,7 +553,9 @@ inline CRCType CRC::Finalize(CRCType remainder, CRCType finalXOR, bool reflectOu static crcpp_constexpr CRCType BIT_MASK = (CRCType(1) << (CRCWidth - CRCType(1))) | ((CRCType(1) << (CRCWidth - CRCType(1))) - CRCType(1)); - if (reflectOutput) { remainder = Reflect(remainder, CRCWidth); } + if (reflectOutput) { + remainder = Reflect(remainder, CRCWidth); + } return (remainder ^ finalXOR) & BIT_MASK; } @@ -583,7 +585,9 @@ inline CRCType CRC::UndoFinalize(CRCType crc, CRCType finalXOR, bool reflectOutp crc = (crc & BIT_MASK) ^ finalXOR; - if (reflectOutput) { crc = Reflect(crc, CRCWidth); } + if (reflectOutput) { + crc = Reflect(crc, CRCWidth); + } return crc; } @@ -722,15 +726,15 @@ inline CRCType CRC::CalculateRemainder(const void* data, if (lookupTable.GetParameters().reflectInput) { while (size--) { #if defined(WIN32) || defined(_WIN32) || defined(WINCE) - // Disable warning about data loss when doing (remainder >> CHAR_BIT) when - // remainder is one byte long. The algorithm is still correct in this case, - // though it's possible that one additional machine instruction will be executed. -#pragma warning(push) -#pragma warning(disable : 4333) + // Disable warning about data loss when doing (remainder >> CHAR_BIT) when + // remainder is one byte long. The algorithm is still correct in this case, + // though it's possible that one additional machine instruction will be executed. + #pragma warning(push) + #pragma warning(disable : 4333) #endif remainder = (remainder >> CHAR_BIT) ^ lookupTable[static_cast(remainder ^ *current++)]; #if defined(WIN32) || defined(_WIN32) || defined(WINCE) -#pragma warning(pop) + #pragma warning(pop) #endif } } else if (CRCWidth >= CHAR_BIT) { @@ -1658,7 +1662,7 @@ inline const CRC::Parameters& CRC::CRC_64() { #endif // CRCPP_INCLUDE_ESOTERIC_CRC_DEFINITIONS #ifdef CRCPP_USE_NAMESPACE -} +} // NOLINT #endif #endif // CRCPP_CRC_H_ diff --git a/include/rogue/protocols/packetizer/Controller.h b/include/rogue/protocols/packetizer/Controller.h index b3e331cc3..780ab098c 100644 --- a/include/rogue/protocols/packetizer/Controller.h +++ b/include/rogue/protocols/packetizer/Controller.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Packetizer Controller Class + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Packetizer Controller diff --git a/include/rogue/protocols/packetizer/ControllerV1.h b/include/rogue/protocols/packetizer/ControllerV1.h index 367e4db16..334d123f7 100644 --- a/include/rogue/protocols/packetizer/ControllerV1.h +++ b/include/rogue/protocols/packetizer/ControllerV1.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Packetizer Controller V1 Class * ---------------------------------------------------------------------------- - * File : ControllerV1.h - * Created : 2018-02-02 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Packetizer Controller, Version 1 diff --git a/include/rogue/protocols/packetizer/ControllerV2.h b/include/rogue/protocols/packetizer/ControllerV2.h index f0c5db841..7fc158774 100644 --- a/include/rogue/protocols/packetizer/ControllerV2.h +++ b/include/rogue/protocols/packetizer/ControllerV2.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Packetizer Controller V2 Class * ---------------------------------------------------------------------------- - * File : ControllerV2.h - * Created : 2018-02-02 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Packetizer Controller, Version 2 diff --git a/include/rogue/protocols/packetizer/Core.h b/include/rogue/protocols/packetizer/Core.h index e1403430b..a75cb1465 100644 --- a/include/rogue/protocols/packetizer/Core.h +++ b/include/rogue/protocols/packetizer/Core.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Packetizer Core Class + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Packetizer Core @@ -50,7 +50,7 @@ class Core { static void setup_python(); //! Creator - Core(bool enSsi); + explicit Core(bool enSsi); //! Destructor ~Core(); diff --git a/include/rogue/protocols/packetizer/CoreV2.h b/include/rogue/protocols/packetizer/CoreV2.h index 3e322b2a9..04d3f1aad 100644 --- a/include/rogue/protocols/packetizer/CoreV2.h +++ b/include/rogue/protocols/packetizer/CoreV2.h @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Packetizer Core Class * ---------------------------------------------------------------------------- - * File : CoreV2.h - * Created : 2018-02-02 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Packetizer Core, Version 2 diff --git a/include/rogue/protocols/packetizer/Transport.h b/include/rogue/protocols/packetizer/Transport.h index 4ade68780..a771bfaaf 100644 --- a/include/rogue/protocols/packetizer/Transport.h +++ b/include/rogue/protocols/packetizer/Transport.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Packetizer Transport Class + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Packetizer Transport diff --git a/include/rogue/protocols/packetizer/module.h b/include/rogue/protocols/packetizer/module.h index a50ea6067..6dcc0485e 100644 --- a/include/rogue/protocols/packetizer/module.h +++ b/include/rogue/protocols/packetizer/module.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/include/rogue/protocols/rssi/Application.h b/include/rogue/protocols/rssi/Application.h index 4b13e7cd1..8253c6666 100644 --- a/include/rogue/protocols/rssi/Application.h +++ b/include/rogue/protocols/rssi/Application.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : RSSI Application Class + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * RSSI Application diff --git a/include/rogue/protocols/rssi/Client.h b/include/rogue/protocols/rssi/Client.h index 17eac4c65..f84185e8d 100644 --- a/include/rogue/protocols/rssi/Client.h +++ b/include/rogue/protocols/rssi/Client.h @@ -1,9 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : RSSI Client Class + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: - * UDP Client + * RSSI Client Class * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory @@ -50,7 +50,7 @@ class Client { static void setup_python(); //! Creator - Client(uint32_t segSize); + explicit Client(uint32_t segSize); //! Destructor ~Client(); diff --git a/include/rogue/protocols/rssi/Controller.h b/include/rogue/protocols/rssi/Controller.h index 0e877e188..5c50a9114 100644 --- a/include/rogue/protocols/rssi/Controller.h +++ b/include/rogue/protocols/rssi/Controller.h @@ -1,12 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : RSSI Controller Class * ---------------------------------------------------------------------------- - * File : Controller.h - * Created : 2017-01-07 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: - * RSSI Controller + * RSSI Controller Class * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory diff --git a/include/rogue/protocols/rssi/Header.h b/include/rogue/protocols/rssi/Header.h index 9c4c905fd..5421d062c 100644 --- a/include/rogue/protocols/rssi/Header.h +++ b/include/rogue/protocols/rssi/Header.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : RSSI Header Class + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * RSSI header @@ -21,6 +21,7 @@ #include #include +#include #include "rogue/interfaces/stream/Frame.h" @@ -66,7 +67,7 @@ class Header { std::shared_ptr frame); //! Creator - Header(std::shared_ptr frame); + explicit Header(std::shared_ptr frame); //! Destructor ~Header(); diff --git a/include/rogue/protocols/rssi/Server.h b/include/rogue/protocols/rssi/Server.h index dee2837eb..f2236ab70 100644 --- a/include/rogue/protocols/rssi/Server.h +++ b/include/rogue/protocols/rssi/Server.h @@ -1,9 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : RSSI Server Class * ---------------------------------------------------------------------------- - * File : Server.h - * Created : 2017-06-13 + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- + * Description: + * RSSI Server Class * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory @@ -50,7 +50,7 @@ class Server { static void setup_python(); //! Creator - Server(uint32_t segSize); + explicit Server(uint32_t segSize); //! Destructor ~Server(); diff --git a/include/rogue/protocols/rssi/Transport.h b/include/rogue/protocols/rssi/Transport.h index ee6a78bff..2e477f545 100644 --- a/include/rogue/protocols/rssi/Transport.h +++ b/include/rogue/protocols/rssi/Transport.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : RSSI Transport Class + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * RSSI Transport diff --git a/include/rogue/protocols/rssi/module.h b/include/rogue/protocols/rssi/module.h index 884b5f703..c04318224 100644 --- a/include/rogue/protocols/rssi/module.h +++ b/include/rogue/protocols/rssi/module.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/include/rogue/protocols/srp/Cmd.h b/include/rogue/protocols/srp/Cmd.h index 7a12f3472..1b7618e03 100644 --- a/include/rogue/protocols/srp/Cmd.h +++ b/include/rogue/protocols/srp/Cmd.h @@ -1,9 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : SLAC Command Protocol - *----------------------------------------------------------------------------- + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : - * CMD Version 0 + * SLAC Command Protocol, Version 0 *----------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory diff --git a/include/rogue/protocols/srp/SrpV0.h b/include/rogue/protocols/srp/SrpV0.h index 58d1b5932..63783b3b3 100644 --- a/include/rogue/protocols/srp/SrpV0.h +++ b/include/rogue/protocols/srp/SrpV0.h @@ -1,9 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : SLAC Register Protocol (SRP) SrpV0 - *----------------------------------------------------------------------------- + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : - * SRP Version 0 + * SLAC Register Protocol (SRP) SrpV0 *----------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory diff --git a/include/rogue/protocols/srp/SrpV3.h b/include/rogue/protocols/srp/SrpV3.h index 90959acf2..ce5fc4045 100644 --- a/include/rogue/protocols/srp/SrpV3.h +++ b/include/rogue/protocols/srp/SrpV3.h @@ -1,9 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : SLAC Register Protocol (SRP) SrpV3 - *----------------------------------------------------------------------------- + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : - * SRP Version 3 + * SLAC Register Protocol (SRP) SrpV3 *----------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory diff --git a/include/rogue/protocols/srp/module.h b/include/rogue/protocols/srp/module.h index 869a1ba7a..b5c3aa524 100644 --- a/include/rogue/protocols/srp/module.h +++ b/include/rogue/protocols/srp/module.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/include/rogue/protocols/udp/Client.h b/include/rogue/protocols/udp/Client.h index af2e3d665..c4715abae 100644 --- a/include/rogue/protocols/udp/Client.h +++ b/include/rogue/protocols/udp/Client.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : UDP Client Class + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * UDP Client @@ -25,6 +25,7 @@ #include #include +#include #include #include "rogue/Logging.h" diff --git a/include/rogue/protocols/udp/Core.h b/include/rogue/protocols/udp/Core.h index 8f0291a78..edce206ad 100644 --- a/include/rogue/protocols/udp/Core.h +++ b/include/rogue/protocols/udp/Core.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : UDP Common Functions + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * UDP Common @@ -69,7 +69,7 @@ class Core { static void setup_python(); //! Creator - Core(bool jumbo); + explicit Core(bool jumbo); //! Destructor ~Core(); diff --git a/include/rogue/protocols/udp/Server.h b/include/rogue/protocols/udp/Server.h index a1f4c1c58..4371f97fe 100644 --- a/include/rogue/protocols/udp/Server.h +++ b/include/rogue/protocols/udp/Server.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : UDP Server Class + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * UDP Server diff --git a/include/rogue/protocols/udp/module.h b/include/rogue/protocols/udp/module.h index 9ed4b0a5f..f5980d427 100644 --- a/include/rogue/protocols/udp/module.h +++ b/include/rogue/protocols/udp/module.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/include/rogue/protocols/xilinx/JtagDriver.h b/include/rogue/protocols/xilinx/JtagDriver.h index 80ccc6344..cecb8c5c6 100644 --- a/include/rogue/protocols/xilinx/JtagDriver.h +++ b/include/rogue/protocols/xilinx/JtagDriver.h @@ -1,18 +1,19 @@ -//----------------------------------------------------------------------------- -// Title : JTAG Support -//----------------------------------------------------------------------------- -// Company : SLAC National Accelerator Laboratory -//----------------------------------------------------------------------------- -// Description: JtagDriver.h -//----------------------------------------------------------------------------- -// This file is part of 'SLAC Firmware Standard Library'. -// It is subject to the license terms in the LICENSE.txt file found in the -// top-level directory of this distribution and at: -// https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. -// No part of 'SLAC Firmware Standard Library', including this file, -// may be copied, modified, propagated, or distributed except according to -// the terms contained in the LICENSE.txt file. -//----------------------------------------------------------------------------- +/** + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- + * Description: + * JTAG Support + * ---------------------------------------------------------------------------- + * This file is part of the rogue software platform. It is subject to + * the license terms in the LICENSE.txt file found in the top-level directory + * of this distribution and at: + * https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. + * No part of the rogue software platform, including this file, may be + * copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE.txt file. + * ---------------------------------------------------------------------------- + **/ #ifndef __ROGUE_PROTOCOLS_XILINX_JTAG_DRIVER_H__ #define __ROGUE_PROTOCOLS_XILINX_JTAG_DRIVER_H__ @@ -131,7 +132,7 @@ class JtagDriver { static Xid getXid(Header x); static uint32_t getCmd(Header x); static unsigned getErr(Header x); - static unsigned long getLen(Header x); + static uint64_t getLen(Header x); // returns error message or NULL (unknown error) static const char* getMsg(unsigned error); @@ -168,7 +169,7 @@ class JtagDriver { //! Setup class in python static void setup_python(); - JtagDriver(uint16_t port); + explicit JtagDriver(uint16_t port); // initialization after full construction virtual void init(); @@ -191,7 +192,7 @@ class JtagDriver { // if 0 then no the target does not have memory and if // there is reliable transport there is no limit to vector // length. - virtual unsigned long query(); + virtual uint64_t query(); // Max. vector size (in bytes) this driver supports - may be different // from what the target supports and the minimum will be used... @@ -199,7 +200,7 @@ class JtagDriver { // must handle typically contains two vectors and a header, so // the driver must consider this when computing the max. supported // vector size) - virtual unsigned long getMaxVectorSize() { + virtual uint64_t getMaxVectorSize() { return 0; } @@ -207,7 +208,7 @@ class JtagDriver { // send tms and tdi vectors of length numBits (each) and receive tdo // little-endian (first send/received at lowest offset) - virtual void sendVectors(unsigned long numBits, uint8_t* tms, uint8_t* tdi, uint8_t* tdo); + virtual void sendVectors(uint64_t numBits, uint8_t* tms, uint8_t* tdi, uint8_t* tdo); virtual void dumpInfo(FILE* f = stdout); diff --git a/include/rogue/protocols/xilinx/Xvc.h b/include/rogue/protocols/xilinx/Xvc.h index 1d2454c43..f87649205 100644 --- a/include/rogue/protocols/xilinx/Xvc.h +++ b/include/rogue/protocols/xilinx/Xvc.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : XVC Server Class + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Rogue implementation of the XVC Server @@ -71,7 +71,7 @@ class Xvc : public rogue::interfaces::stream::Master, static void setup_python(); //! Creator - Xvc(uint16_t port); + explicit Xvc(uint16_t port); //! Destructor ~Xvc(); @@ -85,14 +85,14 @@ class Xvc : public rogue::interfaces::stream::Master, // Receive frame void acceptFrame(std::shared_ptr frame); - virtual unsigned long getMaxVectorSize() final; + uint64_t getMaxVectorSize() final; - virtual int xfer(uint8_t* txBuffer, - unsigned txBytes, - uint8_t* hdBuffer, - unsigned hdBytes, - uint8_t* rxBuffer, - unsigned rxBytes) final; + int xfer(uint8_t* txBuffer, + unsigned txBytes, + uint8_t* hdBuffer, + unsigned hdBytes, + uint8_t* rxBuffer, + unsigned rxBytes) final; }; // Convenience diff --git a/include/rogue/protocols/xilinx/XvcConnection.h b/include/rogue/protocols/xilinx/XvcConnection.h index 7055267c9..831410083 100644 --- a/include/rogue/protocols/xilinx/XvcConnection.h +++ b/include/rogue/protocols/xilinx/XvcConnection.h @@ -1,18 +1,19 @@ -//----------------------------------------------------------------------------- -// Title : JTAG Support -//----------------------------------------------------------------------------- -// Company : SLAC National Accelerator Laboratory -//----------------------------------------------------------------------------- -// Description: XvcConnection.h -//----------------------------------------------------------------------------- -// This file is part of 'SLAC Firmware Standard Library'. -// It is subject to the license terms in the LICENSE.txt file found in the -// top-level directory of this distribution and at: -// https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. -// No part of 'SLAC Firmware Standard Library', including this file, -// may be copied, modified, propagated, or distributed except according to -// the terms contained in the LICENSE.txt file. -//----------------------------------------------------------------------------- +/** + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- + * Description: + * JTAG Support + * ---------------------------------------------------------------------------- + * This file is part of the rogue software platform. It is subject to + * the license terms in the LICENSE.txt file found in the top-level directory + * of this distribution and at: + * https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. + * No part of the rogue software platform, including this file, may be + * copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE.txt file. + * ---------------------------------------------------------------------------- + **/ #ifndef __ROGUE_PROTOCOLS_XILINX_XVC_CONNECTION_H__ #define __ROGUE_PROTOCOLS_XILINX_XVC_CONNECTION_H__ @@ -21,6 +22,8 @@ #include #include +#include + #include "rogue/GeneralError.h" #include "rogue/protocols/xilinx/JtagDriver.h" @@ -39,25 +42,25 @@ class XvcConnection { uint8_t* rp_; vector rxb_; - unsigned long rl_; - unsigned long tl_; + uint64_t rl_; + uint64_t tl_; vector txb_; - unsigned long maxVecLen_; - unsigned long supVecLen_; - unsigned long chunk_; + uint64_t maxVecLen_; + uint64_t supVecLen_; + uint64_t chunk_; public: - XvcConnection(int sd, JtagDriver* drv, unsigned long maxVecLen_ = 32768); + XvcConnection(int sd, JtagDriver* drv, uint64_t maxVecLen_ = 32768); // fill rx buffer to 'n' octets (from TCP connection) - virtual void fill(unsigned long n); + virtual void fill(uint64_t n); // send tx buffer to TCP connection virtual void flush(); // discard 'n' octets from rx buffer (mark as consumed) - virtual void bump(unsigned long n); + virtual void bump(uint64_t n); // (re)allocated buffers virtual void allocBufs(); diff --git a/include/rogue/protocols/xilinx/XvcServer.h b/include/rogue/protocols/xilinx/XvcServer.h index 81bc58bb3..a14e89ad6 100644 --- a/include/rogue/protocols/xilinx/XvcServer.h +++ b/include/rogue/protocols/xilinx/XvcServer.h @@ -1,18 +1,19 @@ -//----------------------------------------------------------------------------- -// Title : JTAG Support -//----------------------------------------------------------------------------- -// Company : SLAC National Accelerator Laboratory -//----------------------------------------------------------------------------- -// Description: XvcServer.h -//----------------------------------------------------------------------------- -// This file is part of 'SLAC Firmware Standard Library'. -// It is subject to the license terms in the LICENSE.txt file found in the -// top-level directory of this distribution and at: -// https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. -// No part of 'SLAC Firmware Standard Library', including this file, -// may be copied, modified, propagated, or distributed except according to -// the terms contained in the LICENSE.txt file. -//----------------------------------------------------------------------------- +/** + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- + * Description: + * JTAG Support + * ---------------------------------------------------------------------------- + * This file is part of the rogue software platform. It is subject to + * the license terms in the LICENSE.txt file found in the top-level directory + * of this distribution and at: + * https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. + * No part of the rogue software platform, including this file, may be + * copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE.txt file. + * ---------------------------------------------------------------------------- + **/ #ifndef __ROGUE_PROTOCOLS_XILINX_XVC_SERVER_H__ #define __ROGUE_PROTOCOLS_XILINX_XVC_SERVER_H__ diff --git a/include/rogue/protocols/xilinx/module.h b/include/rogue/protocols/xilinx/module.h index 657fa35e5..0b554ee4d 100644 --- a/include/rogue/protocols/xilinx/module.h +++ b/include/rogue/protocols/xilinx/module.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/include/rogue/utilities/Prbs.h b/include/rogue/utilities/Prbs.h index d7e90be6f..b5a87d68e 100644 --- a/include/rogue/utilities/Prbs.h +++ b/include/rogue/utilities/Prbs.h @@ -1,7 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : PRBS Receive And Transmit Class - *----------------------------------------------------------------------------- + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * Class used to generate and receive PRBS test data. *----------------------------------------------------------------------------- @@ -36,7 +36,7 @@ namespace utilities { */ class Prbs : public rogue::interfaces::stream::Slave, public rogue::interfaces::stream::Master { //! Max size - const static uint32_t MaxBytes = 64; + static const uint32_t MaxBytes = 64; //! PRBS taps uint8_t* taps_; diff --git a/include/rogue/utilities/StreamUnZip.h b/include/rogue/utilities/StreamUnZip.h index e66195936..b6126ffc0 100644 --- a/include/rogue/utilities/StreamUnZip.h +++ b/include/rogue/utilities/StreamUnZip.h @@ -1,9 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : Rogue stream de-compressor * ---------------------------------------------------------------------------- - * File : StreamUnZip.h - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * Stream modules to decompress a data stream *----------------------------------------------------------------------------- diff --git a/include/rogue/utilities/StreamZip.h b/include/rogue/utilities/StreamZip.h index e626eac2f..8774dddec 100644 --- a/include/rogue/utilities/StreamZip.h +++ b/include/rogue/utilities/StreamZip.h @@ -1,9 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : Rogue stream compressor * ---------------------------------------------------------------------------- - * File : StreamZip.h - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * Stream modules to compress a data stream *----------------------------------------------------------------------------- diff --git a/include/rogue/utilities/fileio/LegacyStreamReader.h b/include/rogue/utilities/fileio/LegacyStreamReader.h index 78fca560f..46aa47a6f 100644 --- a/include/rogue/utilities/fileio/LegacyStreamReader.h +++ b/include/rogue/utilities/fileio/LegacyStreamReader.h @@ -1,7 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : Data file reader utility. - *----------------------------------------------------------------------------- + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * Class to read data files. *----------------------------------------------------------------------------- @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "rogue/interfaces/stream/Master.h" diff --git a/include/rogue/utilities/fileio/LegacyStreamWriter.h b/include/rogue/utilities/fileio/LegacyStreamWriter.h index 881a349a8..5a146e58e 100644 --- a/include/rogue/utilities/fileio/LegacyStreamWriter.h +++ b/include/rogue/utilities/fileio/LegacyStreamWriter.h @@ -1,7 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : Data file writer utility. - *----------------------------------------------------------------------------- + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * Class to coordinate data file writing. * This class writes files using the legacy data format of XmlDaq diff --git a/include/rogue/utilities/fileio/StreamReader.h b/include/rogue/utilities/fileio/StreamReader.h index b1250b096..a8653b076 100644 --- a/include/rogue/utilities/fileio/StreamReader.h +++ b/include/rogue/utilities/fileio/StreamReader.h @@ -1,7 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : Data file reader utility. - *----------------------------------------------------------------------------- + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * Class to read data files. *----------------------------------------------------------------------------- @@ -24,6 +24,7 @@ #include #include #include +#include #include #include "rogue/interfaces/stream/Master.h" diff --git a/include/rogue/utilities/fileio/StreamWriter.h b/include/rogue/utilities/fileio/StreamWriter.h index 3b3ddc66e..a7680fdb1 100644 --- a/include/rogue/utilities/fileio/StreamWriter.h +++ b/include/rogue/utilities/fileio/StreamWriter.h @@ -1,7 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : Data file writer utility. - *----------------------------------------------------------------------------- + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * Class to coordinate data file writing. * This class supports multiple stream slaves, each with the ability to @@ -38,6 +38,7 @@ #include #include #include +#include #include #include "rogue/EnableSharedFromThis.h" diff --git a/include/rogue/utilities/fileio/StreamWriterChannel.h b/include/rogue/utilities/fileio/StreamWriterChannel.h index 183a8d308..cd456413d 100644 --- a/include/rogue/utilities/fileio/StreamWriterChannel.h +++ b/include/rogue/utilities/fileio/StreamWriterChannel.h @@ -1,7 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : Data file writer utility. Channel interface. - *----------------------------------------------------------------------------- + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * Class to act as a slave interface to the StreamWriter. Each * slave is associated with a tag. The tag is included in the bank header diff --git a/include/rogue/utilities/fileio/module.h b/include/rogue/utilities/fileio/module.h index d43c8491e..cec9f63d8 100644 --- a/include/rogue/utilities/fileio/module.h +++ b/include/rogue/utilities/fileio/module.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/include/rogue/utilities/module.h b/include/rogue/utilities/module.h index c7d14e537..4c96b6dd6 100644 --- a/include/rogue/utilities/module.h +++ b/include/rogue/utilities/module.h @@ -1,6 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/pip_requirements.txt b/pip_requirements.txt index e3f5afab4..f771b2b90 100644 --- a/pip_requirements.txt +++ b/pip_requirements.txt @@ -15,6 +15,7 @@ sqlalchemy pyserial numpy flake8 +cpplint gitpython pygithub pydm diff --git a/python/pyrogue/_Block.py b/python/pyrogue/_Block.py index cb167c233..289894b5d 100644 --- a/python/pyrogue/_Block.py +++ b/python/pyrogue/_Block.py @@ -1,7 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue base module - Block Class +# Company : SLAC National Accelerator Laboratory #----------------------------------------------------------------------------- -# File : pyrogue/_Block.py +# Description: +# PyRogue base module - Block Class #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/python/pyrogue/_Command.py b/python/pyrogue/_Command.py index 46cf33cc0..86bb741c5 100644 --- a/python/pyrogue/_Command.py +++ b/python/pyrogue/_Command.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue base module - Command Class +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue base module - Command Class #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/python/pyrogue/_DataReceiver.py b/python/pyrogue/_DataReceiver.py index 39e284e2b..9bb431c62 100644 --- a/python/pyrogue/_DataReceiver.py +++ b/python/pyrogue/_DataReceiver.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue base module - Data Receiver Device +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue base module - Data Receiver Device #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory @@ -35,27 +38,31 @@ def __init__(self, self.add(pr.LocalVariable(name='FrameCount', value=0, + mode = 'RO', pollInterval=1, description='Frame Rx Counter')) self.add(pr.LocalVariable(name='ErrorCount', value=0, + mode = 'RO', pollInterval=1, description='Frame Error Counter')) self.add(pr.LocalVariable(name='ByteCount', value=0, + mode = 'RO', pollInterval=1, description='Byte Rx Counter')) self.add(pr.LocalVariable(name='Updated', value=False, + mode = 'RO', description='Data has been updated flag')) self.add(pr.LocalVariable(name='Data', typeStr=typeStr, disp='', - groups=['NoState','NoStream'], + groups=['NoState','NoStream', 'NoConfig'], value=value, hidden=hideData, description='Data Frame Container')) diff --git a/python/pyrogue/_DataWriter.py b/python/pyrogue/_DataWriter.py index 1097c97a9..4aa8d2fb0 100644 --- a/python/pyrogue/_DataWriter.py +++ b/python/pyrogue/_DataWriter.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue base module - Data Writer Class +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue base module - Data Writer Class #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/python/pyrogue/_Device.py b/python/pyrogue/_Device.py index 2450613e1..cc0bde492 100644 --- a/python/pyrogue/_Device.py +++ b/python/pyrogue/_Device.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue base module - Device Class +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue base module - Device Class #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory @@ -442,7 +445,7 @@ def setPollInterval(self, interval, variables=None): variables = [k for k,v in self.variables.items() if v.pollInterval != 0] for x in variables: - self.node(x).pollInterval = interval + self.node(x).setPollInterval(interval) def hideVariables(self, hidden, variables=None): """ @@ -709,10 +712,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 = [] @@ -1010,7 +1016,7 @@ def __init__(self, *, arrayClass, number, stride=0, arrayArgs=None, **kwargs): if arrayArgs is None: arrayArgs = [{} for x in range(number)] elif isinstance(arrayArgs, dict): - arrayArgs = [arrayArgs for x in range(number)] + arrayArgs = [arrayArgs.copy() for x in range(number)] for i in range(number): args = arrayArgs[i] diff --git a/python/pyrogue/_HelperFunctions.py b/python/pyrogue/_HelperFunctions.py index 7fb2df430..631f8fd22 100644 --- a/python/pyrogue/_HelperFunctions.py +++ b/python/pyrogue/_HelperFunctions.py @@ -1,4 +1,9 @@ #----------------------------------------------------------------------------- +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# +#----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory # of this distribution and at: diff --git a/python/pyrogue/_Model.py b/python/pyrogue/_Model.py index a90c6d234..78feb7905 100644 --- a/python/pyrogue/_Model.py +++ b/python/pyrogue/_Model.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue base module - Model Class +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue base module - Model Class #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory @@ -430,7 +433,7 @@ def fromString(self, string): def minValue(self): """ """ - return -1 * ((2**(self.bitSize-1))-1) + return -1 * (2**(self.bitSize-1)) def maxValue(self): """ """ @@ -699,7 +702,7 @@ class Fixed(Model): def __init__(self, bitSize, binPoint): super().__init__(bitSize,binPoint) - self.name = f'Fixed_{self.bitSize-self.binPoint-1}_{self.binPoint}' + self.name = f'Fixed_{self.bitSize}_{self.binPoint}' self.ndType = np.dtype(np.float64) class UFixed(Model): @@ -721,5 +724,5 @@ class UFixed(Model): def __init__(self, bitSize, binPoint): super().__init__(bitSize,binPoint) - self.name = f'UFixed_{self.bitSize-self.binPoint-1}_{self.binPoint}' + self.name = f'UFixed_{self.bitSize}_{self.binPoint}' self.ndType = np.dtype(np.float64) diff --git a/python/pyrogue/_Node.py b/python/pyrogue/_Node.py index 6a4576258..4e21e9f64 100644 --- a/python/pyrogue/_Node.py +++ b/python/pyrogue/_Node.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue base module - Node Classes +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue base module - Node Classes #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory @@ -154,6 +157,7 @@ class Node(object): ------- """ + _nodeCount = 0 def __init__(self, *, name, description="", expand=True, hidden=False, groups=None, guiGroup=None): """ @@ -183,6 +187,7 @@ def __init__(self, *, name, description="", expand=True, hidden=False, groups=No ------- """ + pr.Node._nodeCount += 1 # Public attributes self._name = name @@ -213,6 +218,10 @@ def __init__(self, *, name, description="", expand=True, hidden=False, groups=No def __repr__(self): return f'{self.__class__} - {self.path}' + @property + def nodeCount(self): + return pr.Node._nodeCount + @property def name(self): """ @@ -559,7 +568,7 @@ def addNodes(self, nodeClass, number, stride, **kwargs): def nodeList(self): """Get a recursive list of nodes.""" lst = [] - for key,value in self.nodes.items(): + for key,value in self._nodes.items(): lst.append(value) lst.extend(value.nodeList) return lst diff --git a/python/pyrogue/_PollQueue.py b/python/pyrogue/_PollQueue.py index 0b4670127..5b95cfba5 100644 --- a/python/pyrogue/_PollQueue.py +++ b/python/pyrogue/_PollQueue.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue base module - PollQueue Class +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue base module - PollQueue Class #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/python/pyrogue/_Process.py b/python/pyrogue/_Process.py index 5f8ec7982..be211fdee 100644 --- a/python/pyrogue/_Process.py +++ b/python/pyrogue/_Process.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue base module - Process Device Class +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue base module - Process Device Class #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory @@ -77,10 +80,6 @@ def __init__(self, *, argVariable=None, returnVariable=None, function=None, **kw value = 1, description = "Total number of loops steps for the process")) - @self.command(hidden=True) - def Advance(arg): - self._incrementSteps(1) - # Add arg variable if not already added if self._argVar is not None and self._argVar not in self: self.add(self._argVar) @@ -169,10 +168,11 @@ def _process(self): # No function run example process else: self.Message.setDisp("Started") + self.TotalSteps.set(100) for i in range(101): if self._runEn is False: break time.sleep(1) - self.Progress.set(i/100) + self._setSteps(i+1) self.Message.setDisp(f"Running for {i} seconds.") self.Message.setDisp("Done") diff --git a/python/pyrogue/_Root.py b/python/pyrogue/_Root.py index 581b39c05..f13b82218 100644 --- a/python/pyrogue/_Root.py +++ b/python/pyrogue/_Root.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue base module - Root Class +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue base module - Root Class #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/python/pyrogue/_RunControl.py b/python/pyrogue/_RunControl.py index 63a07d626..cc4801d97 100644 --- a/python/pyrogue/_RunControl.py +++ b/python/pyrogue/_RunControl.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue base module - Run Control Device Class +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue base module - Run Control Device Class #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/python/pyrogue/_Variable.py b/python/pyrogue/_Variable.py index 06ea016c9..28c4b3f11 100644 --- a/python/pyrogue/_Variable.py +++ b/python/pyrogue/_Variable.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue base module - Variable Class +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue base module - Variable Class #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory @@ -31,11 +34,19 @@ def VariableWait(varList, testFunction, timeout=0): """ Wait for a number of variable conditions to be true. Pass a variable or list of variables, and a test function. - The test function is passed a dictionary containing the current - variableValue state index by variable path + The test function is passed a list containing the current + variableValue state indexed by position as passed in the wait list. + Each variableValue entry has an additional field updated which indicates + if the variable has refreshed while waiting. This can be used to trigger + on any update to the variable, regardless of value. + + i.e. w = VariableWait([root.device.var1,root.device.var2], + lambda varValues: varValues[0].value >= 10 and \ + varValues[1].value >= 20) + i.e. w = VariableWait([root.device.var1,root.device.var2], - lambda varValues: varValues['root.device.var1'].value >= 10 and \ - varValues['root.device.var1'].value >= 20) + lambda varValues: varValues[0].updated and \ + varValues[1].updated) Parameters ---------- @@ -53,13 +64,6 @@ def VariableWait(varList, testFunction, timeout=0): # Container class class varStates(object): - """ - - - - - """ - def __init__(self): self.vlist = odict() self.cv = threading.Condition() @@ -68,7 +72,6 @@ def __init__(self): def varUpdate(self,path,varValue): """ - Parameters ---------- path : @@ -84,6 +87,7 @@ def varUpdate(self,path,varValue): with self.cv: if path in self.vlist: self.vlist[path] = varValue + self.vlist[path].updated = True self.cv.notify() # Convert single variable to a list @@ -98,6 +102,7 @@ def varUpdate(self,path,varValue): for v in varList: v.addListener(states.varUpdate) states.vlist[v.path] = v.getVariableValue(read=False) + states.vlist[v.path].updated = False # Go into wait loop ret = False @@ -122,8 +127,8 @@ def varUpdate(self,path,varValue): class VariableValue(object): """ """ - def __init__(self, var, read=False): - self.value = var.get(read=read) + def __init__(self, var, read=False, index=-1): + self.value = var.get(read=read,index=index) self.valueDisp = var.genDisp(self.value) self.disp = var.disp self.enum = var.enum @@ -567,7 +572,7 @@ def write(self, *, verify=True, check=True): pass @pr.expose - def getVariableValue(self,read=True): + def getVariableValue(self,read=True,index=-1): """ Return the value after performing a read from hardware if applicable. Hardware read is blocking. An error will result in a logged exception. @@ -577,6 +582,8 @@ def getVariableValue(self,read=True): ---------- read : bool (Default value = True) + index : int + (Default value = -1) Returns ------- @@ -585,7 +592,7 @@ def getVariableValue(self,read=True): Listeners will be informed of the update. """ - return VariableValue(self,read=read) + return VariableValue(self,read=read,index=index) @pr.expose def value(self, index=-1): @@ -1035,7 +1042,7 @@ def __init__(self, *, raise VariableError(f'ValueBits {valueBits} is greater than valueStrude {valueStride}') # Override the bitSize - bitSize[0] = numValues * valueStride + bitSize[0] = numValues * valueBits if self._ndType is None: raise VariableError(f'Invalid base type {self._base} with numValues = {numValues}') @@ -1323,7 +1330,7 @@ def _genDocs(self,file): """ BaseVariable._genDocs(self,file) - for a in ['offset', 'numValues', 'bitSize', 'bitOffset', 'verify', 'varBytes']: + for a in ['offset', 'numValues', 'bitSize', 'bitOffset', 'verifyEn', 'varBytes']: astr = str(getattr(self,a)) if astr != 'None': diff --git a/python/pyrogue/__init__.py b/python/pyrogue/__init__.py index 9180c393f..e54855d67 100644 --- a/python/pyrogue/__init__.py +++ b/python/pyrogue/__init__.py @@ -1,4 +1,6 @@ #----------------------------------------------------------------------------- +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory # of this distribution and at: diff --git a/python/pyrogue/__main__.py b/python/pyrogue/__main__.py index 438187421..cbaafa6b6 100644 --- a/python/pyrogue/__main__.py +++ b/python/pyrogue/__main__.py @@ -1,4 +1,6 @@ #----------------------------------------------------------------------------- +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory # of this distribution and at: diff --git a/python/pyrogue/examples/_AxiVersion.py b/python/pyrogue/examples/_AxiVersion.py index cd30592f9..2c35c4627 100644 --- a/python/pyrogue/examples/_AxiVersion.py +++ b/python/pyrogue/examples/_AxiVersion.py @@ -1,8 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue AXI-Lite Version Module Test +# Company : SLAC National Accelerator Laboratory #----------------------------------------------------------------------------- # Description: -# PyRogue AXI-Lite Version Module +# PyRogue AXI-Lite Version Module Test #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/python/pyrogue/examples/_ExampleRoot.py b/python/pyrogue/examples/_ExampleRoot.py index 36357b3e3..880f428ca 100755 --- a/python/pyrogue/examples/_ExampleRoot.py +++ b/python/pyrogue/examples/_ExampleRoot.py @@ -1,12 +1,15 @@ #!/usr/bin/env python3 #----------------------------------------------------------------------------- -# Title : Example Root +# Company : SLAC National Accelerator Laboratory #----------------------------------------------------------------------------- -# This file is part of the rogue_example software. It is subject to +# Description: +# Example Root +#----------------------------------------------------------------------------- +# This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory # of this distribution and at: # https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. -# No part of the rogue_example software, including this file, may be +# No part of the rogue software platform, including this file, may be # copied, modified, propagated, or distributed except according to the terms # contained in the LICENSE.txt file. #----------------------------------------------------------------------------- @@ -73,7 +76,7 @@ def __init__(self, epics4En=False): self.add(pyrogue.RunControl()) # Add zmq server - self.zmqServer = pyrogue.interfaces.ZmqServer(root=self, addr='*', port=0) + self.zmqServer = pyrogue.interfaces.ZmqServer(root=self, addr='127.0.0.1', port=0) self.addInterface(self.zmqServer) # Add sql logger diff --git a/python/pyrogue/examples/_LargeDevice.py b/python/pyrogue/examples/_LargeDevice.py index 366037a3f..4876a424f 100755 --- a/python/pyrogue/examples/_LargeDevice.py +++ b/python/pyrogue/examples/_LargeDevice.py @@ -1,12 +1,15 @@ #!/usr/bin/env python3 #----------------------------------------------------------------------------- -# Title : Large Device Test Group +# Company : SLAC National Accelerator Laboratory #----------------------------------------------------------------------------- -# This file is part of the rogue_example software. It is subject to +# Description: +# Large Device Test Group +#----------------------------------------------------------------------------- +# This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory # of this distribution and at: # https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. -# No part of the rogue_example software, including this file, may be +# No part of the rogue software platform, including this file, may be # copied, modified, propagated, or distributed except according to the terms # contained in the LICENSE.txt file. #----------------------------------------------------------------------------- diff --git a/python/pyrogue/examples/__init__.py b/python/pyrogue/examples/__init__.py index f7c1e299d..65950fb91 100644 --- a/python/pyrogue/examples/__init__.py +++ b/python/pyrogue/examples/__init__.py @@ -1,4 +1,6 @@ #----------------------------------------------------------------------------- +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory # of this distribution and at: diff --git a/python/pyrogue/examples/__main__.py b/python/pyrogue/examples/__main__.py index 5883ae339..29471d938 100755 --- a/python/pyrogue/examples/__main__.py +++ b/python/pyrogue/examples/__main__.py @@ -1,12 +1,15 @@ #!/usr/bin/env python3 #----------------------------------------------------------------------------- -# Title : Example server test script +# Company : SLAC National Accelerator Laboratory #----------------------------------------------------------------------------- -# This file is part of the rogue_example software. It is subject to +# Description: +# Example server test script +#----------------------------------------------------------------------------- +# This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory # of this distribution and at: # https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. -# No part of the rogue_example software, including this file, may be +# No part of the rogue software platform, including this file, may be # copied, modified, propagated, or distributed except according to the terms # contained in the LICENSE.txt file. #----------------------------------------------------------------------------- diff --git a/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py b/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py new file mode 100644 index 000000000..9434aaf39 --- /dev/null +++ b/python/pyrogue/hardware/axi/_AxiStreamDmaMon.py @@ -0,0 +1,199 @@ +#----------------------------------------------------------------------------- +# Company: SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: Module for monitoring the DMA kernel driver +#----------------------------------------------------------------------------- +# This file is part of the rogue software platform. It is subject to +# the license terms in the LICENSE.txt file found in the top-level directory +# of this distribution and at: +# https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. +# No part of the rogue software platform, including this file, may be +# copied, modified, propagated, or distributed except according to the terms +# contained in the LICENSE.txt file. +#----------------------------------------------------------------------------- + +import pyrogue as pr + +class AxiStreamDmaMonRx(pr.Device): + def __init__(self, axiStreamDma, pollInterval=1, **kwargs): + super(self.__class__, self).__init__(**kwargs) + + # Create a pointer to the AXI Stream DMA object + self._dma = axiStreamDma + + # Add variables + self.add(pr.LocalVariable( + name = 'BuffCount', + description = 'Get the number of RX buffers', + mode = 'RO', + value = 0, + typeStr = 'UInt32', + localGet = lambda: self._dma.getRxBuffCount(), + )) + + self.add(pr.LocalVariable( + name = 'BuffinUserCount', + description = 'RX buffer in User count', + mode = 'RO', + value = 0, + typeStr = 'UInt32', + localGet = lambda: self._dma.getRxBuffinUserCount(), + pollInterval= pollInterval, + )) + + self.add(pr.LocalVariable( + name = 'BuffinHwCount', + description = 'RX buffer in HW count', + mode = 'RO', + value = 0, + typeStr = 'UInt32', + localGet = lambda: self._dma.getRxBuffinHwCount(), + pollInterval= pollInterval, + )) + + self.add(pr.LocalVariable( + name = 'BuffinPreHwQCount', + description = 'RX buffer in Pre-HW Queue count', + mode = 'RO', + value = 0, + typeStr = 'UInt32', + localGet = lambda: self._dma.getRxBuffinPreHwQCount(), + pollInterval= pollInterval, + )) + + self.add(pr.LocalVariable( + name = 'BuffinSwQCount', + description = 'RX buffer in SW Queue count', + mode = 'RO', + value = 0, + typeStr = 'UInt32', + localGet = lambda: self._dma.getRxBuffinSwQCount(), + pollInterval= pollInterval, + )) + + self.add(pr.LocalVariable( + name = 'BuffMissCount', + description = 'RX buffer missing count', + mode = 'RO', + value = 0, + typeStr = 'UInt32', + localGet = lambda: self._dma.getRxBuffMissCount(), + pollInterval= pollInterval, + )) + +class AxiStreamDmaMonTx(pr.Device): + def __init__(self, axiStreamDma, pollInterval=1, **kwargs): + super(self.__class__, self).__init__(**kwargs) + + # Create a pointer to the AXI Stream DMA object + self._dma = axiStreamDma + + # Add variables + self.add(pr.LocalVariable( + name = 'BuffCount', + description = 'Get the number of TX buffers', + mode = 'RO', + value = 0, + typeStr = 'UInt32', + localGet = lambda: self._dma.getTxBuffCount(), + )) + + self.add(pr.LocalVariable( + name = 'BuffinUserCount', + description = 'TX buffer in User count', + mode = 'RO', + value = 0, + typeStr = 'UInt32', + localGet = lambda: self._dma.getTxBuffinUserCount(), + pollInterval= pollInterval, + )) + + self.add(pr.LocalVariable( + name = 'BuffinHwCount', + description = 'TX buffer in HW count', + mode = 'RO', + value = 0, + typeStr = 'UInt32', + localGet = lambda: self._dma.getTxBuffinHwCount(), + pollInterval= pollInterval, + )) + + self.add(pr.LocalVariable( + name = 'BuffinPreHwQCount', + description = 'TX buffer in Pre-HW Queue count', + mode = 'RO', + value = 0, + typeStr = 'UInt32', + localGet = lambda: self._dma.getTxBuffinPreHwQCount(), + pollInterval= pollInterval, + )) + + self.add(pr.LocalVariable( + name = 'BuffinSwQCount', + description = 'TX buffer in SW Queue count', + mode = 'RO', + value = 0, + typeStr = 'UInt32', + localGet = lambda: self._dma.getTxBuffinSwQCount(), + pollInterval= pollInterval, + )) + + self.add(pr.LocalVariable( + name = 'BuffMissCount', + description = 'TX buffer missing count', + mode = 'RO', + value = 0, + typeStr = 'UInt32', + localGet = lambda: self._dma.getTxBuffMissCount(), + pollInterval= pollInterval, + )) + +class AxiStreamDmaMon(pr.Device): + def __init__(self, axiStreamDma, pollInterval=1, **kwargs): + super(self.__class__, self).__init__(**kwargs) + + # Create a pointer to the AXI Stream DMA object + 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)', + mode = 'RO', + value = 0x0, + typeStr = 'UInt32', + units = 'Bytes', + disp = '{:#x}', + localGet = lambda: self._dma.getBuffSize(), + )) + + self.add(AxiStreamDmaMonRx( + name = 'Rx', + axiStreamDma = axiStreamDma, + pollInterval = pollInterval, + )) + + self.add(AxiStreamDmaMonTx( + name = 'Tx', + axiStreamDma = axiStreamDma, + pollInterval = pollInterval, + )) diff --git a/python/pyrogue/hardware/axi/__init__.py b/python/pyrogue/hardware/axi/__init__.py new file mode 100644 index 000000000..01de67d9f --- /dev/null +++ b/python/pyrogue/hardware/axi/__init__.py @@ -0,0 +1,12 @@ +#----------------------------------------------------------------------------- +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# This file is part of the rogue software platform. It is subject to +# the license terms in the LICENSE.txt file found in the top-level directory +# of this distribution and at: +# https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. +# No part of the rogue software platform, including this file, may be +# copied, modified, propagated, or distributed except according to the terms +# contained in the LICENSE.txt file. +#----------------------------------------------------------------------------- +from pyrogue.hardware.axi._AxiStreamDmaMon import * diff --git a/python/pyrogue/interfaces/_SimpleClient.py b/python/pyrogue/interfaces/_SimpleClient.py index 66b305600..3370c8219 100644 --- a/python/pyrogue/interfaces/_SimpleClient.py +++ b/python/pyrogue/interfaces/_SimpleClient.py @@ -1,6 +1,7 @@ #----------------------------------------------------------------------------- -# Title : PyRogue Simple ZMQ Client for Rogue +# Company : SLAC National Accelerator Laboratory #----------------------------------------------------------------------------- +# Description: # To use in Matlab first you need the zmq package in your # python installation: # diff --git a/python/pyrogue/interfaces/_SqlLogging.py b/python/pyrogue/interfaces/_SqlLogging.py index 51755afec..ba0f92c85 100644 --- a/python/pyrogue/interfaces/_SqlLogging.py +++ b/python/pyrogue/interfaces/_SqlLogging.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue - SQL Logging Module +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue - SQL Logging Module #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/python/pyrogue/interfaces/_Virtual.py b/python/pyrogue/interfaces/_Virtual.py index 6a0ccdbd1..75b702593 100644 --- a/python/pyrogue/interfaces/_Virtual.py +++ b/python/pyrogue/interfaces/_Virtual.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue base module - Virtual Classes +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue base module - Virtual Classes #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/python/pyrogue/interfaces/_ZmqServer.py b/python/pyrogue/interfaces/_ZmqServer.py index 6f8b0246d..c45595801 100644 --- a/python/pyrogue/interfaces/_ZmqServer.py +++ b/python/pyrogue/interfaces/_ZmqServer.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue ZMQ Server +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue ZMQ Server #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory @@ -20,12 +23,16 @@ class ZmqServer(rogue.interfaces.ZmqServer): def __init__(self,*,root,addr,port,incGroups=None, excGroups=['NoServe']): rogue.interfaces.ZmqServer.__init__(self,addr,port) self._root = root + self._addr = addr self._root.addVarListener(func=self._varUpdate, done=self._varDone, incGroups=incGroups, excGroups=excGroups) self._updateList = {} @property def address(self): - return f"localhost:{self.port()}" + if self._addr == "*": + return f"127.0.0.1:{self.port()}" + else: + return f"{self._addr}:{self.port()}" def _doOperation(self,d): path = d['path'] if 'path' in d else None diff --git a/python/pyrogue/interfaces/__init__.py b/python/pyrogue/interfaces/__init__.py index 161d21a0d..8ee2ad179 100644 --- a/python/pyrogue/interfaces/__init__.py +++ b/python/pyrogue/interfaces/__init__.py @@ -1,4 +1,6 @@ #----------------------------------------------------------------------------- +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory # of this distribution and at: diff --git a/python/pyrogue/interfaces/simulation.py b/python/pyrogue/interfaces/simulation.py index fc1a19900..f92a07ac7 100644 --- a/python/pyrogue/interfaces/simulation.py +++ b/python/pyrogue/interfaces/simulation.py @@ -1,5 +1,5 @@ #----------------------------------------------------------------------------- -# Title : PyRogue simulation support +# Company : SLAC National Accelerator Laboratory #----------------------------------------------------------------------------- # Description: # Module containing simulation support classes and routines diff --git a/python/pyrogue/interfaces/stream/_Fifo.py b/python/pyrogue/interfaces/stream/_Fifo.py index bcd3a6e1b..55ad2e497 100644 --- a/python/pyrogue/interfaces/stream/_Fifo.py +++ b/python/pyrogue/interfaces/stream/_Fifo.py @@ -1,5 +1,5 @@ #----------------------------------------------------------------------------- -# Title : AXI Stream FIFO +# Company : SLAC National Accelerator Laboratory #----------------------------------------------------------------------------- # Description: # Python wrapper for the AXI Stream FIFO C++ device. diff --git a/python/pyrogue/interfaces/stream/_Variable.py b/python/pyrogue/interfaces/stream/_Variable.py index a6064c294..d6cf9852d 100644 --- a/python/pyrogue/interfaces/stream/_Variable.py +++ b/python/pyrogue/interfaces/stream/_Variable.py @@ -1,5 +1,5 @@ #----------------------------------------------------------------------------- -# Title : Variable Update Streamer +# Company : SLAC National Accelerator Laboratory #----------------------------------------------------------------------------- # Description: # Class to generate variable update streams diff --git a/python/pyrogue/interfaces/stream/__init__.py b/python/pyrogue/interfaces/stream/__init__.py index 25c570d90..d879b5683 100644 --- a/python/pyrogue/interfaces/stream/__init__.py +++ b/python/pyrogue/interfaces/stream/__init__.py @@ -1,4 +1,6 @@ #----------------------------------------------------------------------------- +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory # of this distribution and at: diff --git a/python/pyrogue/protocols/_Network.py b/python/pyrogue/protocols/_Network.py index a4827f719..83d475c81 100644 --- a/python/pyrogue/protocols/_Network.py +++ b/python/pyrogue/protocols/_Network.py @@ -1,8 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue protocols / Network wrappers +# Company : SLAC National Accelerator Laboratory #----------------------------------------------------------------------------- # Description: -# Module containing protocol modules +# PyRogue protocols / Network wrappers #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory @@ -28,10 +28,10 @@ def __init__(self,*, port, host='127.0.0.1', jumbo=False, wait=True, packVer=1, if server: self._udp = rogue.protocols.udp.Server(port,jumbo) - self._rssi = rogue.protocols.rssi.Server(self._udp.maxPayload()) + self._rssi = rogue.protocols.rssi.Server(self._udp.maxPayload()-8) else: self._udp = rogue.protocols.udp.Client(host,port,jumbo) - self._rssi = rogue.protocols.rssi.Client(self._udp.maxPayload()) + self._rssi = rogue.protocols.rssi.Client(self._udp.maxPayload()-8) if packVer == 2: self._pack = rogue.protocols.packetizer.CoreV2(False,True,enSsi) # ibCRC = False, obCRC = True diff --git a/python/pyrogue/protocols/__init__.py b/python/pyrogue/protocols/__init__.py index 8a450a84c..0b26e85c0 100644 --- a/python/pyrogue/protocols/__init__.py +++ b/python/pyrogue/protocols/__init__.py @@ -1,4 +1,6 @@ #----------------------------------------------------------------------------- +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory # of this distribution and at: diff --git a/python/pyrogue/protocols/_uart.py b/python/pyrogue/protocols/_uart.py index c3d19362e..2623593b3 100644 --- a/python/pyrogue/protocols/_uart.py +++ b/python/pyrogue/protocols/_uart.py @@ -1,8 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue protocols / UART register protocol +# Company : SLAC National Accelerator Laboratory #----------------------------------------------------------------------------- # Description: -# Module containing protocol modules +# PyRogue protocols / UART register protocol #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/python/pyrogue/protocols/epicsV4.py b/python/pyrogue/protocols/epicsV4.py index 9ac333673..a70fea63a 100644 --- a/python/pyrogue/protocols/epicsV4.py +++ b/python/pyrogue/protocols/epicsV4.py @@ -1,11 +1,11 @@ #----------------------------------------------------------------------------- -# Title : PyRogue epics support +# Company : SLAC National Accelerator Laboratory #----------------------------------------------------------------------------- # Description: # Module containing epics support classes and routines # TODO: # Not clear on to force a read on get -#----------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory # of this distribution and at: @@ -13,7 +13,7 @@ # No part of the rogue software platform, including this file, may be # copied, modified, propagated, or distributed except according to the terms # contained in the LICENSE.txt file. -#----------------------------------------------------------------------------- +# ----------------------------------------------------------------------------- import pyrogue import time @@ -30,22 +30,22 @@ def EpicsConvStatus(varValue): if varValue.status == "AlarmLoLo": - return 5 # epicsAlarmLoLo + return 5 # epicsAlarmLoLo elif varValue.status == "AlarmLow": - return 6 # epicsAlarmLow + return 6 # epicsAlarmLow elif varValue.status == "AlarmHiHi": - return 3 # epicsAlarmHiHi + return 3 # epicsAlarmHiHi elif varValue.status == "AlarmHigh": - return 4 # epicsAlarmHigh + return 4 # epicsAlarmHigh else: return 0 def EpicsConvSeverity(varValue): if varValue.severity == "AlarmMinor": - return 1 # epicsSevMinor + return 1 # epicsSevMinor elif varValue.severity == "AlarmMajor": - return 2 # epicsSevMajor + return 2 # epicsSevMajor else: return 0 @@ -53,11 +53,12 @@ def EpicsConvSeverity(varValue): class EpicsPvHandler(p4p.server.thread.Handler): def __init__(self, valType, var, log): self._valType = valType - self._var = var - self._log = log + self._var = var + self._log = log def put(self, pv, op): - if self._var.isVariable and (self._var.mode == 'RW' or self._var.mode == 'WO'): + if self._var.isVariable and ( + self._var.mode == 'RW' or self._var.mode == 'WO'): try: if self._valType == 'enum': self._var.setDisp(str(op.value())) @@ -92,7 +93,8 @@ def rpc(self, pv, op): if ret is None: ret = 'None' - v = p4p.Value(p4p.Type([('value',self._valType)]), {'value':ret}) + v = p4p.Value( + p4p.Type([('value', self._valType)]), {'value': ret}) op.done(value=(v)) except Exception as msg: @@ -101,21 +103,21 @@ def rpc(self, pv, op): else: op.done(error='Rpc Not Supported On Variables') - def onFirstConnect(self, pv): # may be omitted - #print(f"PV First connect called pv={pv}") + def onFirstConnect(self, pv): # may be omitted + # print(f"PV First connect called pv={pv}") pass - def onLastDisconnect(self, pv): # may be omitted - #print(f"PV Last Disconnect called pv={pv}") + def onLastDisconnect(self, pv): # may be omitted + # print(f"PV Last Disconnect called pv={pv}") pass class EpicsPvHolder(object): - def __init__(self,provider,name,var,log): - self._var = var + def __init__(self, provider, name, var, log): + self._var = var self._name = name - self._log = log - self._pv = None + self._log = log + self._pv = None if self._var.isCommand: typeStr = self._var.retTypeStr @@ -125,7 +127,7 @@ def __init__(self,provider,name,var,log): # Convert valType if var.nativeType is np.ndarray: self._valType = 'ndarray' - #self._valType = 's' + # self._valType = 's' elif self._var.disp == 'enum': self._valType = 'enum' elif typeStr is None or var.nativeType is list or var.nativeType is dict: @@ -134,7 +136,7 @@ def __init__(self,provider,name,var,log): # Unsigned if 'UInt' in typeStr: - m = re.search('^UInt(\\d+)\\.*',typeStr) + m = re.search('^UInt(\\d+)\\.*', typeStr) if m is not None and m.lastindex == 1: bits = int(m[1]) @@ -154,7 +156,7 @@ def __init__(self,provider,name,var,log): # Signed elif 'int' in typeStr or 'Int' in typeStr: - m = re.search('^Int(\\d+)\\.*',typeStr) + m = re.search('^Int(\\d+)\\.*', typeStr) if m is not None and m.lastindex == 1: bits = int(m[1]) @@ -191,37 +193,66 @@ def __init__(self,provider,name,var,log): if varVal.valueDisp is None: varVal.valueDisp = '' - self._log.info("Adding {} with type {} init={}".format(self._name,self._valType,varVal.valueDisp)) + self._log.info( + "Adding {} with type {} init={}".format( + self._name, + self._valType, + varVal.valueDisp)) try: if self._valType == 'ndarray': - nt = p4p.nt.NTNDArray() - #iv = nt.wrap(varVal.value) + # If a 1D array is encountered, use a NTScalar. Note, if an + # NTScalar is used, the values will be automatically converted + # to doubles. + if varVal.value.ndim == 1: + nt = p4p.nt.NTScalar('ad') + else: + nt = p4p.nt.NTNDArray() iv = varVal.value elif self._valType == 'enum': - nt = p4p.nt.NTEnum(display=False, control=False, valueAlarm=False) + nt = p4p.nt.NTEnum( + display=False, + control=False, + valueAlarm=False) enum = list(self._var.enum.values()) - iv = {'choices':enum, 'index':enum.index(varVal.valueDisp)} + iv = {'choices': enum, 'index': enum.index(varVal.valueDisp)} elif self._valType == 's': - nt = p4p.nt.NTScalar(self._valType, display=False, control=False, valueAlarm=False) + nt = p4p.nt.NTScalar( + self._valType, + display=False, + control=False, + valueAlarm=False) iv = nt.wrap(varVal.valueDisp) else: - nt = p4p.nt.NTScalar(self._valType, display=True, control=True, valueAlarm=True) - #print(f"Setting value {varVal.value} to {self._name}") + nt = p4p.nt.NTScalar( + self._valType, + display=True, + control=True, + valueAlarm=True) + # print(f"Setting value {varVal.value} to {self._name}") iv = nt.wrap(varVal.value) except Exception as e: - raise Exception("Failed to add {} with type {} ndtype={} init={}. Error={}".format(self._name,self._valType,self._var.ndType,varVal.valueDisp,e)) + raise Exception( + "Failed to add {} with type {} ndtype={} init={}. Error={}".format( + self._name, + self._valType, + self._var.ndType, + varVal.valueDisp, + e)) # Setup variable try: - self._pv = p4p.server.thread.SharedPV(queue=None, - handler=EpicsPvHandler(self._valType,self._var,self._log), - initial=iv, - nt=nt, - options={}) + self._pv = p4p.server.thread.SharedPV(queue=None, handler=EpicsPvHandler( + self._valType, self._var, self._log), initial=iv, nt=nt, options={}) except Exception as e: - raise Exception("Failed to start {} with type {} ndtype={} init={}. Error={}".format(self._name,self._valType,self._var.ndType,varVal.valueDisp,e)) - - provider.add(self._name,self._pv) + raise Exception( + "Failed to start {} with type {} ndtype={} init={}. Error={}".format( + self._name, + self._valType, + self._var.ndType, + varVal.valueDisp, + e)) + + provider.add(self._name, self._pv) self._var.addListener(self._varUpdated) # Update fields in numeric types @@ -232,36 +263,37 @@ def __init__(self,provider,name,var,log): curr.raw.alarm.severity = EpicsConvSeverity(varVal) curr.raw.display.description = self._var.description - if self._var.units is not None: - curr.raw.display.units = self._var.units - if self._var.maximum is not None: + if self._var.units is not None: + curr.raw.display.units = self._var.units + if self._var.maximum is not None: curr.raw.display.limitHigh = self._var.maximum - if self._var.minimum is not None: - curr.raw.display.limitLow = self._var.minimum + if self._var.minimum is not None: + curr.raw.display.limitLow = self._var.minimum - if self._var.lowWarning is not None: - curr.raw.valueAlarm.lowWarningLimit = self._var.lowWarning - if self._var.lowAlarm is not None: - curr.raw.valueAlarm.lowAlarmLimit = self._var.lowAlarm + if self._var.lowWarning is not None: + curr.raw.valueAlarm.lowWarningLimit = self._var.lowWarning + if self._var.lowAlarm is not None: + curr.raw.valueAlarm.lowAlarmLimit = self._var.lowAlarm if self._var.highWarning is not None: - curr.raw.valueAlarm.highWarningLimit = self._var.highWarning - if self._var.highAlarm is not None: - curr.raw.valueAlarm.highAlarmLimit = self._var.highAlarm + curr.raw.valueAlarm.highWarningLimit = self._var.highWarning + if self._var.highAlarm is not None: + curr.raw.valueAlarm.highAlarmLimit = self._var.highAlarm # Precision ? self._pv.post(curr) - def _varUpdated(self,path,value): + def _varUpdated(self, path, value): if self._valType == 'enum' or self._valType == 's': self._pv.post(value.valueDisp) elif self._valType == 'ndarray': self._pv.post(value.value) else: curr = self._pv.current() - curr.raw.value = value.value - curr.raw.alarm.status = EpicsConvStatus(value) + curr.raw.value = value.value + curr.raw.alarm.status = EpicsConvStatus(value) curr.raw.alarm.severity = EpicsConvSeverity(value) - curr.raw['timeStamp.secondsPastEpoch'], curr.raw['timeStamp.nanoseconds'] = divmod(float(time.time_ns()), 1.0e9) + curr.raw['timeStamp.secondsPastEpoch'], curr.raw['timeStamp.nanoseconds'] = divmod( + float(time.time_ns()), 1.0e9) self._pv.post(curr) @@ -269,15 +301,16 @@ class EpicsPvServer(object): """ Class to contain an epics PV server """ - def __init__(self,*,base,root,incGroups,excGroups,pvMap=None): - self._root = root - self._base = base - self._log = pyrogue.logInit(cls=self) - self._server = None + + def __init__(self, *, base, root, incGroups, excGroups, pvMap=None): + self._root = root + self._base = base + self._log = pyrogue.logInit(cls=self) + self._server = None self._incGroups = incGroups self._excGroups = excGroups - self._pvMap = pvMap - self._started = False + self._pvMap = pvMap + self._started = False self._provider = p4p.server.StaticProvider(__name__) @@ -296,7 +329,8 @@ def _start(self): self._list = {} if not self._root.running: - raise Exception("Epics can not be setup on a tree which is not started") + raise Exception( + "Epics can not be setup on a tree which is not started") # Figure out mapping mode if self._pvMap is None: @@ -310,35 +344,36 @@ def _start(self): eName = None if doAll: - if v.filterByGroup(self._incGroups,self._excGroups): - eName = self._base + ':' + v.path.replace('.',':') + if v.filterByGroup(self._incGroups, self._excGroups): + eName = self._base + ':' + v.path.replace('.', ':') self._pvMap[v.path] = eName elif v.path in self._pvMap: eName = self._pvMap[v.path] if eName is not None: - pvh = EpicsPvHolder(self._provider,eName,v,self._log) + pvh = EpicsPvHolder(self._provider, eName, v, self._log) self._list[v] = pvh # Check for missing map entries if len(self._pvMap) != len(self._list): - for k,v in self._pvMap.items(): + for k, v in self._pvMap.items(): if k not in self._list: - self._log.error(f"Failed to find {k} from P4P mapping in Rogue tree!") + self._log.error( + f"Failed to find {k} from P4P mapping in Rogue tree!") self._server = p4p.server.Server(providers=[self._provider]) def list(self): return self._pvMap - def dump(self,fname=None): + def dump(self, fname=None): if fname is not None: try: - with open(fname,'w') as f: - for k,v in self._pvMap.items(): - print("{} -> {}".format(v,k),file=f) + with open(fname, 'w') as f: + for k, v in self._pvMap.items(): + print("{} -> {}".format(v, k), file=f) except Exception: raise Exception("Failed to dump epics map to {}".format(fname)) else: - for k,v in self._pvMap.items(): - print("{} -> {}".format(v,k)) + for k, v in self._pvMap.items(): + print("{} -> {}".format(v, k)) diff --git a/python/pyrogue/protocols/gpib.py b/python/pyrogue/protocols/gpib.py index 7d8d25d1d..f9f6a2a67 100644 --- a/python/pyrogue/protocols/gpib.py +++ b/python/pyrogue/protocols/gpib.py @@ -1,5 +1,5 @@ #----------------------------------------------------------------------------- -# Title : PyRogue protocols / GPIB register protocol +# Company : SLAC National Accelerator Laboratory #----------------------------------------------------------------------------- # Description: # Module to interface to GPIB devices diff --git a/python/pyrogue/pydm/TimePlotTop.py b/python/pyrogue/pydm/TimePlotTop.py index cb4b45d8d..628b02668 100644 --- a/python/pyrogue/pydm/TimePlotTop.py +++ b/python/pyrogue/pydm/TimePlotTop.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM Top Level GUI +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue PyDM Top Level GUI #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory @@ -9,7 +12,6 @@ # copied, modified, propagated, or distributed except according to the terms # contained in the LICENSE.txt file. #----------------------------------------------------------------------------- - import os from pyrogue.pydm.widgets import TimePlotter diff --git a/python/pyrogue/pydm/__init__.py b/python/pyrogue/pydm/__init__.py index da246ef3c..77c5d3b0d 100644 --- a/python/pyrogue/pydm/__init__.py +++ b/python/pyrogue/pydm/__init__.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM Package, Function to start default Rogue PyDM GUI +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue PyDM Package, Function to start default Rogue PyDM GUI #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory @@ -11,20 +14,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 +47,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() - diff --git a/python/pyrogue/pydm/data_plugins/__init__.py b/python/pyrogue/pydm/data_plugins/__init__.py index c05eacec2..c361b28de 100644 --- a/python/pyrogue/pydm/data_plugins/__init__.py +++ b/python/pyrogue/pydm/data_plugins/__init__.py @@ -1,5 +1,5 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM data plug-in package +# Company : SLAC National Accelerator Laboratory #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/python/pyrogue/pydm/data_plugins/rogue_plugin.py b/python/pyrogue/pydm/data_plugins/rogue_plugin.py index 67efaa506..a48156caf 100644 --- a/python/pyrogue/pydm/data_plugins/rogue_plugin.py +++ b/python/pyrogue/pydm/data_plugins/rogue_plugin.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM data plug-in +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue PyDM data plug-in #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory @@ -30,10 +33,10 @@ def parseAddress(address): - # "rogue://index//" + # "rogue://index///" # or - # "rogue://host:port//" - # Mode: 'Value', 'Disp', 'Name' or 'Path' + # "rogue://host:port///" + # Mode: 'value', 'disp', 'name' or 'path' envList = os.getenv('ROGUE_SERVERS') if envList is None: @@ -55,12 +58,13 @@ def parseAddress(address): port = int(data_server[1]) path = data[1] mode = 'value' if (len(data) < 3) else data[2] + index = -1 if (len(data) < 4) else int(data[3]) - return (host,port,path,mode) + return (host,port,path,mode,index) def nodeFromAddress(address): - host, port, path, mode = parseAddress(address) + host, port, path, mode, index = parseAddress(address) client = VirtualClient(host, port) return client.root.getNode(path) @@ -72,7 +76,7 @@ def __init__(self, channel, address, protocol=None, parent=None): self.app = QApplication.instance() - self._host, self._port, self._path, self._mode = parseAddress(channel.address) + self._host, self._port, self._path, self._mode, self._index = parseAddress(channel.address) self._cmd = False self._int = False @@ -111,6 +115,10 @@ def linkState(self, state): def _updateVariable(self,path,varValue): + + if self._index != -1: + varValue = self._node.getVariableValue(read=False, index=self._index) + if self._mode == 'name': self.new_value_signal[str].emit(self._node.name) elif self._mode == 'path': @@ -150,7 +158,7 @@ def put_value(self, new_value): if self._cmd: self._node.__call__(val) else: - self._node.setDisp(val) + self._node.setDisp(val,index=self._index) def add_listener(self, channel): @@ -201,7 +209,7 @@ def add_listener(self, channel): self.new_value_signal[str].emit(self._node.path) else: self.write_access_signal.emit(self._cmd or self._node.mode!='RO') - self._updateVariable(self._node.path,self._node.getVariableValue(read=False)) + self._updateVariable(self._node.path,self._node.getVariableValue(read=False, index=self._index)) else: self.new_value_signal[str].emit(self._node.name) diff --git a/python/pyrogue/pydm/examples/rogue_plugin_test.ui b/python/pyrogue/pydm/examples/rogue_plugin_test.ui index 2d572a956..2ddcfc6e5 100644 --- a/python/pyrogue/pydm/examples/rogue_plugin_test.ui +++ b/python/pyrogue/pydm/examples/rogue_plugin_test.ui @@ -19,7 +19,7 @@ - 4 + 0 @@ -105,7 +105,7 @@ - {"name": "Axis 1", "orientation": "left", "label": "Test Plot Scatter", "minRange": -1.0, "maxRange": 1.0, "autoRange": true, "logMode": false} + {"name": "Axis 1", "orientation": "left", "label": "Test Plot Scatter", "minRange": -1.04, "maxRange": 1.04, "autoRange": true, "logMode": false} @@ -125,7 +125,7 @@ - {"name": "Axis 1", "orientation": "left", "label": "Test Plot Time", "minRange": -1.0, "maxRange": 1.0, "autoRange": true, "logMode": null} + {"name": "Axis 1", "orientation": "left", "label": "Test Plot Time", "minRange": -1.04, "maxRange": 1.04, "autoRange": true, "logMode": null} @@ -151,7 +151,7 @@ - {"name": "Axis 1", "orientation": "left", "label": "Test Array Waveform", "minRange": -1.0, "maxRange": 1.0, "autoRange": true, "logMode": false} + {"name": "Axis 1", "orientation": "left", "label": "Test Array Waveform", "minRange": -1.04, "maxRange": 1.04, "autoRange": true, "logMode": false} diff --git a/python/pyrogue/pydm/pydmTop.py b/python/pyrogue/pydm/pydmTop.py index a35d6163d..61603bc52 100644 --- a/python/pyrogue/pydm/pydmTop.py +++ b/python/pyrogue/pydm/pydmTop.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM Top Level GUI +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue PyDM Top Level GUI #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory @@ -9,7 +12,6 @@ # copied, modified, propagated, or distributed except according to the terms # contained in the LICENSE.txt file. #----------------------------------------------------------------------------- - import os from pydm import Display from qtpy.QtWidgets import (QVBoxLayout, QTabWidget) diff --git a/python/pyrogue/pydm/rogue_plugin.py b/python/pyrogue/pydm/rogue_plugin.py index 4e14c3fb6..1ac34ae4a 100644 --- a/python/pyrogue/pydm/rogue_plugin.py +++ b/python/pyrogue/pydm/rogue_plugin.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM Designer Plug-in Load +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue PyDM Designer Plug-in Load #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/python/pyrogue/pydm/tools/__init__.py b/python/pyrogue/pydm/tools/__init__.py index 4884d4cd0..c361b28de 100644 --- a/python/pyrogue/pydm/tools/__init__.py +++ b/python/pyrogue/pydm/tools/__init__.py @@ -1,5 +1,5 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM tools directory +# Company : SLAC National Accelerator Laboratory #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/python/pyrogue/pydm/tools/generic_file_tool.py b/python/pyrogue/pydm/tools/generic_file_tool.py index 900c68315..259eaf19b 100644 --- a/python/pyrogue/pydm/tools/generic_file_tool.py +++ b/python/pyrogue/pydm/tools/generic_file_tool.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM Generic File Browser +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue PyDM Generic File Browser #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory @@ -38,7 +41,7 @@ def __init__(self,save=False): ExternalTool.__init__(self, icon=icon, name=name, group=group, use_with_widgets=use_with_widgets) def call(self, channels, sender): - addr, port, path, mode = parseAddress(channels[0].address) + addr, port, path, mode, index = parseAddress(channels[0].address) self._client = VirtualClient(addr, port) node = self._client.root.getNode(path) diff --git a/python/pyrogue/pydm/tools/node_info_tool.py b/python/pyrogue/pydm/tools/node_info_tool.py index b616bab10..5b83534ea 100644 --- a/python/pyrogue/pydm/tools/node_info_tool.py +++ b/python/pyrogue/pydm/tools/node_info_tool.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM Node Info Tool +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue PyDM Node Info Tool #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory @@ -33,7 +36,7 @@ def __init__(self): ExternalTool.__init__(self, icon=icon, name=name, group=group, use_with_widgets=use_with_widgets) def call(self, channels, sender): - addr, port, path, mode = parseAddress(channels[0].address) + addr, port, path, mode, index = parseAddress(channels[0].address) self._client = VirtualClient(addr, port) node = self._client.root.getNode(path) diff --git a/python/pyrogue/pydm/tools/read_node_tool.py b/python/pyrogue/pydm/tools/read_node_tool.py index ef21fca8d..349145969 100644 --- a/python/pyrogue/pydm/tools/read_node_tool.py +++ b/python/pyrogue/pydm/tools/read_node_tool.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM Read Node Tool +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue PyDM Read Node Tool #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory @@ -31,7 +34,7 @@ def __init__(self): ExternalTool.__init__(self, icon=icon, name=name, group=group, use_with_widgets=use_with_widgets) def call(self, channels, sender): - addr, port, path, mode = parseAddress(channels[0].address) + addr, port, path, mode, index = parseAddress(channels[0].address) self._client = VirtualClient(addr, port) node = self._client.root.getNode(path) diff --git a/python/pyrogue/pydm/tools/read_recursive_tool.py b/python/pyrogue/pydm/tools/read_recursive_tool.py index 0ae2669f8..feb6fd76f 100644 --- a/python/pyrogue/pydm/tools/read_recursive_tool.py +++ b/python/pyrogue/pydm/tools/read_recursive_tool.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM Read Recursive Tool +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue PyDM Read Recursive Tool #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory @@ -31,7 +34,7 @@ def __init__(self): ExternalTool.__init__(self, icon=icon, name=name, group=group, use_with_widgets=use_with_widgets) def call(self, channels, sender): - addr, port, path, mode = parseAddress(channels[0].address) + addr, port, path, mode, index = parseAddress(channels[0].address) self._client = VirtualClient(addr, port) node = self._client.root.getNode(path) diff --git a/python/pyrogue/pydm/tools/write_node_tool.py b/python/pyrogue/pydm/tools/write_node_tool.py index 438115f2a..25fda74bd 100644 --- a/python/pyrogue/pydm/tools/write_node_tool.py +++ b/python/pyrogue/pydm/tools/write_node_tool.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM Write Variable Tool +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue PyDM Write Variable Tool #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory @@ -31,7 +34,7 @@ def __init__(self): ExternalTool.__init__(self, icon=icon, name=name, group=group, use_with_widgets=use_with_widgets) def call(self, channels, sender): - addr, port, path, mode = parseAddress(channels[0].address) + addr, port, path, mode, index = parseAddress(channels[0].address) self._client = VirtualClient(addr, port) node = self._client.root.getNode(path) diff --git a/python/pyrogue/pydm/tools/write_recursive_tool.py b/python/pyrogue/pydm/tools/write_recursive_tool.py index 4c4211da6..06f460d59 100644 --- a/python/pyrogue/pydm/tools/write_recursive_tool.py +++ b/python/pyrogue/pydm/tools/write_recursive_tool.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM Write Variable Tool +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue PyDM Write Variable Tool #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory @@ -9,7 +12,6 @@ # copied, modified, propagated, or distributed except according to the terms # contained in the LICENSE.txt file. #----------------------------------------------------------------------------- - import logging from pydm.tools import ExternalTool from pydm.utilities.iconfont import IconFont @@ -31,7 +33,7 @@ def __init__(self): ExternalTool.__init__(self, icon=icon, name=name, group=group, use_with_widgets=use_with_widgets) def call(self, channels, sender): - addr, port, path, mode = parseAddress(channels[0].address) + addr, port, path, mode, index = parseAddress(channels[0].address) self._client = VirtualClient(addr, port) node = self._client.root.getNode(path) diff --git a/python/pyrogue/pydm/widgets/__init__.py b/python/pyrogue/pydm/widgets/__init__.py index a4f24b290..e99c71ef1 100644 --- a/python/pyrogue/pydm/widgets/__init__.py +++ b/python/pyrogue/pydm/widgets/__init__.py @@ -1,6 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM Widgets Package +# Company : SLAC National Accelerator Laboratory #----------------------------------------------------------------------------- +# Description: +# PyRogue PyDM Widgets Package #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/python/pyrogue/pydm/widgets/data_writer.py b/python/pyrogue/pydm/widgets/data_writer.py index 0b2a6ae9c..a6a8f5df6 100644 --- a/python/pyrogue/pydm/widgets/data_writer.py +++ b/python/pyrogue/pydm/widgets/data_writer.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM Data Writer Widget +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue PyDM Data Writer Widget #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/python/pyrogue/pydm/widgets/debug_tree.py b/python/pyrogue/pydm/widgets/debug_tree.py index 72a5944d0..44bc43af8 100644 --- a/python/pyrogue/pydm/widgets/debug_tree.py +++ b/python/pyrogue/pydm/widgets/debug_tree.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM Debug Tree Widget +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue PyDM Debug Tree Widget #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/python/pyrogue/pydm/widgets/designer.py b/python/pyrogue/pydm/widgets/designer.py index 0747408d6..3de46ad39 100644 --- a/python/pyrogue/pydm/widgets/designer.py +++ b/python/pyrogue/pydm/widgets/designer.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM Designer Setup +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue PyDM Designer Setup #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/python/pyrogue/pydm/widgets/label.py b/python/pyrogue/pydm/widgets/label.py index abe13c942..cede5c79b 100644 --- a/python/pyrogue/pydm/widgets/label.py +++ b/python/pyrogue/pydm/widgets/label.py @@ -1,3 +1,17 @@ +#----------------------------------------------------------------------------- +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# +#----------------------------------------------------------------------------- +# This file is part of the rogue software platform. It is subject to +# the license terms in the LICENSE.txt file found in the top-level directory +# of this distribution and at: +# https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. +# No part of the rogue software platform, including this file, may be +# copied, modified, propagated, or distributed except according to the terms +# contained in the LICENSE.txt file. +#----------------------------------------------------------------------------- from pydm.widgets import PyDMLabel from qtpy.QtCore import Qt from qtpy.QtWidgets import QHBoxLayout diff --git a/python/pyrogue/pydm/widgets/line_edit.py b/python/pyrogue/pydm/widgets/line_edit.py index 0e9f6a7de..023f9259a 100644 --- a/python/pyrogue/pydm/widgets/line_edit.py +++ b/python/pyrogue/pydm/widgets/line_edit.py @@ -1,3 +1,17 @@ +#----------------------------------------------------------------------------- +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# +#----------------------------------------------------------------------------- +# This file is part of the rogue software platform. It is subject to +# the license terms in the LICENSE.txt file found in the top-level directory +# of this distribution and at: +# https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. +# No part of the rogue software platform, including this file, may be +# copied, modified, propagated, or distributed except according to the terms +# contained in the LICENSE.txt file. +#----------------------------------------------------------------------------- import locale import numpy as np import ast diff --git a/python/pyrogue/pydm/widgets/plot.py b/python/pyrogue/pydm/widgets/plot.py index 6cc30033c..222ed7e6e 100644 --- a/python/pyrogue/pydm/widgets/plot.py +++ b/python/pyrogue/pydm/widgets/plot.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM Plot Window +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue PyDM Plot Window #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/python/pyrogue/pydm/widgets/process.py b/python/pyrogue/pydm/widgets/process.py index 0c71e8e72..1556b4b9a 100644 --- a/python/pyrogue/pydm/widgets/process.py +++ b/python/pyrogue/pydm/widgets/process.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM Process Widget +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue PyDM Process Widget #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory @@ -114,6 +117,11 @@ def connection_changed(self, connected): w.showStepExponent = False w.writeOnPress = True + elif v.isCommand and not v.arg: + w = PyDMPushButton(label='Exec', + pressValue=1, + init_channel=self._path + '.{}/disp'.format(v.name)) + else: w = PyRogueLineEdit(parent=None, init_channel=self._path + '.{}/disp'.format(v.name)) w.showUnits = True diff --git a/python/pyrogue/pydm/widgets/root_control.py b/python/pyrogue/pydm/widgets/root_control.py index 6aba6601e..b5442cfe5 100644 --- a/python/pyrogue/pydm/widgets/root_control.py +++ b/python/pyrogue/pydm/widgets/root_control.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM Root Control Widget +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue PyDM Root Control Widget #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/python/pyrogue/pydm/widgets/run_control.py b/python/pyrogue/pydm/widgets/run_control.py index f050eade2..a0ebc42e2 100644 --- a/python/pyrogue/pydm/widgets/run_control.py +++ b/python/pyrogue/pydm/widgets/run_control.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM Run Control Widget +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue PyDM Run Control Widget #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/python/pyrogue/pydm/widgets/system_log.py b/python/pyrogue/pydm/widgets/system_log.py index 42c16a391..2db3e5e25 100644 --- a/python/pyrogue/pydm/widgets/system_log.py +++ b/python/pyrogue/pydm/widgets/system_log.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM System Log Widget +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue PyDM System Log Widget #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/python/pyrogue/pydm/widgets/system_window.py b/python/pyrogue/pydm/widgets/system_window.py index 819945e48..81b0da138 100644 --- a/python/pyrogue/pydm/widgets/system_window.py +++ b/python/pyrogue/pydm/widgets/system_window.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM System Window Widget +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue PyDM System Window Widget #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/python/pyrogue/pydm/widgets/time_plotter.py b/python/pyrogue/pydm/widgets/time_plotter.py index d795d994b..842fa496a 100644 --- a/python/pyrogue/pydm/widgets/time_plotter.py +++ b/python/pyrogue/pydm/widgets/time_plotter.py @@ -1,5 +1,8 @@ #----------------------------------------------------------------------------- -# Title : PyRogue PyDM Debug Tree Widget +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- +# Description: +# PyRogue PyDM Debug Tree Widget #----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory @@ -9,7 +12,6 @@ # copied, modified, propagated, or distributed except according to the terms # contained in the LICENSE.txt file. #----------------------------------------------------------------------------- - import pyrogue from pyrogue.pydm.data_plugins.rogue_plugin import nodeFromAddress from pyrogue.pydm.widgets.debug_tree import makeVariableViewWidget diff --git a/python/pyrogue/utilities/__init__.py b/python/pyrogue/utilities/__init__.py index 9adea634f..c361b28de 100644 --- a/python/pyrogue/utilities/__init__.py +++ b/python/pyrogue/utilities/__init__.py @@ -1,4 +1,6 @@ #----------------------------------------------------------------------------- +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory # of this distribution and at: diff --git a/python/pyrogue/utilities/cpsw.py b/python/pyrogue/utilities/cpsw.py index 64df37d04..d6ef3bc97 100644 --- a/python/pyrogue/utilities/cpsw.py +++ b/python/pyrogue/utilities/cpsw.py @@ -1,5 +1,5 @@ #----------------------------------------------------------------------------- -# Title : PyRogue CPSW Export Utilities +# Company : SLAC National Accelerator Laboratory #----------------------------------------------------------------------------- # Description: # Tools to export Rogue modules to CPSW diff --git a/python/pyrogue/utilities/fileio/_FileReader.py b/python/pyrogue/utilities/fileio/_FileReader.py index 62c2ba822..0bb482c3c 100644 --- a/python/pyrogue/utilities/fileio/_FileReader.py +++ b/python/pyrogue/utilities/fileio/_FileReader.py @@ -1,5 +1,5 @@ #----------------------------------------------------------------------------- -# Title : PyRogue FileIO - File Reader +# Company : SLAC National Accelerator Laboratory #----------------------------------------------------------------------------- # Description: # Module for reading file data. diff --git a/python/pyrogue/utilities/fileio/_StreamReader.py b/python/pyrogue/utilities/fileio/_StreamReader.py index e761d837d..726bc2cd4 100644 --- a/python/pyrogue/utilities/fileio/_StreamReader.py +++ b/python/pyrogue/utilities/fileio/_StreamReader.py @@ -1,5 +1,5 @@ #----------------------------------------------------------------------------- -# Title : PyRogue FileIO - Stream Reader +# Company : SLAC National Accelerator Laboratory #----------------------------------------------------------------------------- # Description: # Module for reading stream data. diff --git a/python/pyrogue/utilities/fileio/_StreamWriter.py b/python/pyrogue/utilities/fileio/_StreamWriter.py index 13689667d..2282eeed3 100644 --- a/python/pyrogue/utilities/fileio/_StreamWriter.py +++ b/python/pyrogue/utilities/fileio/_StreamWriter.py @@ -1,5 +1,5 @@ #----------------------------------------------------------------------------- -# Title : PyRogue FileIO - Stream Writer +# Company : SLAC National Accelerator Laboratory #----------------------------------------------------------------------------- # Description: # Module for writing stream data. diff --git a/python/pyrogue/utilities/fileio/__init__.py b/python/pyrogue/utilities/fileio/__init__.py index b4a1cdb9b..dedf9920a 100644 --- a/python/pyrogue/utilities/fileio/__init__.py +++ b/python/pyrogue/utilities/fileio/__init__.py @@ -1,4 +1,6 @@ #----------------------------------------------------------------------------- +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory # of this distribution and at: diff --git a/python/pyrogue/utilities/hls/_RegInterfParser.py b/python/pyrogue/utilities/hls/_RegInterfParser.py index ab3a4769c..415c88ed4 100644 --- a/python/pyrogue/utilities/hls/_RegInterfParser.py +++ b/python/pyrogue/utilities/hls/_RegInterfParser.py @@ -1,4 +1,6 @@ #----------------------------------------------------------------------------- +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- # This file is part of the rogue library utilities. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory # of this distribution and at: diff --git a/python/pyrogue/utilities/hls/__init__.py b/python/pyrogue/utilities/hls/__init__.py index be5240fe4..d19c1201a 100644 --- a/python/pyrogue/utilities/hls/__init__.py +++ b/python/pyrogue/utilities/hls/__init__.py @@ -1,4 +1,6 @@ #----------------------------------------------------------------------------- +# Company : SLAC National Accelerator Laboratory +#----------------------------------------------------------------------------- # This file is part of the rogue software platform. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory # of this distribution and at: diff --git a/python/pyrogue/utilities/prbs.py b/python/pyrogue/utilities/prbs.py index 6baebad3f..36cb78db0 100644 --- a/python/pyrogue/utilities/prbs.py +++ b/python/pyrogue/utilities/prbs.py @@ -1,5 +1,5 @@ #----------------------------------------------------------------------------- -# Title : PyRogue Utilities base module +# Company : SLAC National Accelerator Laboratory #----------------------------------------------------------------------------- # Description: # Module containing the utilities module class and methods diff --git a/scripts/updateDrivers.sh b/scripts/updateDrivers.sh index 8619b128a..1d94cea5a 100755 --- a/scripts/updateDrivers.sh +++ b/scripts/updateDrivers.sh @@ -1,10 +1,12 @@ #!/bin/bash # ---------------------------------------------------------------------------- -# This file is part of the rogue software platform. It is subject to +# Company : SLAC National Accelerator Laboratory +# ---------------------------------------------------------------------------- +# This file is part of the rogue software package. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory # of this distribution and at: # https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. -# No part of the rogue software platform, including this file, may be +# No part of the rogue software package, including this file, may be # copied, modified, propagated, or distributed except according to the terms # contained in the LICENSE.txt file. # ---------------------------------------------------------------------------- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 34e9952d8..7161ea2c5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,9 +1,6 @@ # ---------------------------------------------------------------------------- # Title : ROGUE CMAKE Control # ---------------------------------------------------------------------------- -# File : src/CMakeLists.txt -# Created : 2018-02-27 -# ---------------------------------------------------------------------------- # This file is part of the rogue software package. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory # of this distribution and at: diff --git a/src/package.cpp b/src/package.cpp index 0dde0a8fc..2832749df 100644 --- a/src/package.cpp +++ b/src/package.cpp @@ -1,11 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Package * ---------------------------------------------------------------------------- - * File : package.cpp - * Author : Ryan Herbst, rherbst@slac.stanford.edu - * Created : 2016-08-08 - * Last update: 2016-08-08 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python package setup diff --git a/src/rogue/CMakeLists.txt b/src/rogue/CMakeLists.txt index b0dcb98d4..8921a9989 100644 --- a/src/rogue/CMakeLists.txt +++ b/src/rogue/CMakeLists.txt @@ -1,8 +1,5 @@ # ---------------------------------------------------------------------------- -# Title : ROGUE CMAKE Control -# ---------------------------------------------------------------------------- -# File : src/rogue/CMakeLists.txt -# Created : 2018-02-27 +# Company : SLAC National Accelerator Laboratory # ---------------------------------------------------------------------------- # This file is part of the rogue software package. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/src/rogue/GeneralError.cpp b/src/rogue/GeneralError.cpp index 8c5c21299..aa349c417 100644 --- a/src/rogue/GeneralError.cpp +++ b/src/rogue/GeneralError.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : General Error * ---------------------------------------------------------------------------- - * File : GeneralError.cpp - * Created : 2017-12-05 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * General exception for Rogue @@ -24,7 +21,7 @@ #include #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; PyObject* rogue::generalErrorObj = 0; @@ -55,7 +52,7 @@ void rogue::GeneralError::setup_python() { bp::class_("GeneralError", bp::init()); - PyObject* typeObj = PyErr_NewException((char*)"rogue.GeneralError", PyExc_Exception, 0); + PyObject* typeObj = PyErr_NewException(const_cast("rogue.GeneralError"), PyExc_Exception, 0); bp::scope().attr("GeneralError") = bp::handle<>(bp::borrowed(typeObj)); rogue::generalErrorObj = typeObj; diff --git a/src/rogue/GilRelease.cpp b/src/rogue/GilRelease.cpp index 36dcce827..35e3d1563 100644 --- a/src/rogue/GilRelease.cpp +++ b/src/rogue/GilRelease.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Release GIL within scope. * ---------------------------------------------------------------------------- - * File : GilRelease.cpp - * Created : 2017-02-28 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Release GIL for the scope of this class. @@ -24,7 +21,7 @@ #include #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif diff --git a/src/rogue/Logging.cpp b/src/rogue/Logging.cpp index cf824be02..658d23395 100644 --- a/src/rogue/Logging.cpp +++ b/src/rogue/Logging.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Logging interface * ---------------------------------------------------------------------------- - * File : Logging.cpp - * Created : 2017-02-28 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Logging interface for pyrogue @@ -24,20 +21,19 @@ #include #include #include -#include #include #include #include #if defined(__linux__) -#include + #include #elif defined(__APPLE__) && defined(__MACH__) -#include + #include #endif #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -105,7 +101,7 @@ void rogue::Logging::intLog(uint32_t level, const char* fmt, va_list args) { struct timeval tme; char buffer[1000]; - vsnprintf(buffer, 1000, fmt, args); + vsnprintf(buffer, sizeof(buffer), fmt, args); gettimeofday(&tme, NULL); printf("%l" PRIi32 ".%06l" PRIi32 ":%s: %s\n", tme.tv_sec, tme.tv_usec, name_.c_str(), buffer); } diff --git a/src/rogue/ScopedGil.cpp b/src/rogue/ScopedGil.cpp index f03a5da15..f5e2b83a3 100644 --- a/src/rogue/ScopedGil.cpp +++ b/src/rogue/ScopedGil.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Scoped GIL * ---------------------------------------------------------------------------- - * File : ScopedGil.h - * Created : 2017-06-08 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Acquire the GIL for the scope of this class. diff --git a/src/rogue/Version.cpp b/src/rogue/Version.cpp index 24128c661..92e07721d 100644 --- a/src/rogue/Version.cpp +++ b/src/rogue/Version.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Rogue Version * ---------------------------------------------------------------------------- - * File : Version.cpp - * Created : 2017-05-17 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Version helpers for Rogue @@ -32,7 +29,7 @@ #include "rogue/GilRelease.h" #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif diff --git a/src/rogue/hardware/CMakeLists.txt b/src/rogue/hardware/CMakeLists.txt index e9186a15a..e7cc8aca7 100644 --- a/src/rogue/hardware/CMakeLists.txt +++ b/src/rogue/hardware/CMakeLists.txt @@ -1,8 +1,5 @@ # ---------------------------------------------------------------------------- -# Title : ROGUE CMAKE Control -# ---------------------------------------------------------------------------- -# File : src/rogue/hardware/CMakeLists.txt -# Created : 2018-02-27 +# Company : SLAC National Accelerator Laboratory # ---------------------------------------------------------------------------- # This file is part of the rogue software package. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/src/rogue/hardware/MemMap.cpp b/src/rogue/hardware/MemMap.cpp index b39168c6a..33fe8c8d1 100644 --- a/src/rogue/hardware/MemMap.cpp +++ b/src/rogue/hardware/MemMap.cpp @@ -1,9 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : Raw Memory Mapped Access * ---------------------------------------------------------------------------- - * File : MemMap.cpp - * Created : 2019-11-18 + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- + * Description: + * Raw Memory Mapped Access * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory @@ -40,7 +40,7 @@ namespace rh = rogue::hardware; namespace rim = rogue::interfaces::memory; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -60,7 +60,8 @@ rh::MemMap::MemMap(uint64_t base, uint32_t size) : rim::Slave(4, 0xFFFFFFFF) { if (fd_ < 0) throw(rogue::GeneralError::create("MemMap::MemMap", "Failed to open device file: %s", MAP_DEVICE)); - if ((map_ = (uint8_t*)mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd_, base)) == (void*)-1) + if ((map_ = reinterpret_cast(mmap(NULL, size, PROT_READ | PROT_WRITE, MAP_SHARED, fd_, base))) == + reinterpret_cast(-1)) throw(rogue::GeneralError::create("MemMap::MemMap", "Failed to map memory to user space.")); log_->debug("Created map to 0x%" PRIx64 " with size 0x%" PRIx32, base, size); @@ -81,7 +82,7 @@ void rh::MemMap::stop() { threadEn_ = false; queue_.stop(); thread_->join(); - munmap((void*)map_, size_); + munmap(reinterpret_cast(const_cast(map_)), size_); ::close(fd_); } } @@ -129,8 +130,8 @@ void rh::MemMap::runThread() { continue; } - tPtr = (uint32_t*)tran->begin(); - mPtr = (uint32_t*)(map_ + tran->address()); + tPtr = reinterpret_cast(tran->begin()); + mPtr = const_cast(reinterpret_cast(map_ + tran->address())); while (count != tran->size()) { // Write or post diff --git a/src/rogue/hardware/axi/AxiMemMap.cpp b/src/rogue/hardware/axi/AxiMemMap.cpp index 213d93d57..2be33d6d2 100644 --- a/src/rogue/hardware/axi/AxiMemMap.cpp +++ b/src/rogue/hardware/axi/AxiMemMap.cpp @@ -1,9 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : AXI Memory Mapped Access * ---------------------------------------------------------------------------- - * File : AxiMemMap.cpp - * Created : 2017-03-21 + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- + * Description: + * AXI Memory Mapped Access * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory @@ -41,7 +41,7 @@ namespace rha = rogue::hardware::axi; namespace rim = rogue::interfaces::memory; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -58,13 +58,23 @@ rha::AxiMemMap::AxiMemMap(std::string path) : rim::Slave(4, 0xFFFFFFFF) { if (fd_ < 0) throw(rogue::GeneralError::create("AxiMemMap::AxiMemMap", "Failed to open device file: %s", path.c_str())); - // Check driver version - if (dmaCheckVersion(fd_) < 0) + // Check driver version ( ApiVersion 0x05 (or less) is the 32-bit address version) + if (dmaGetApiVersion(fd_) < 0x06) { throw(rogue::GeneralError("AxiMemMap::AxiMemMap", - "Bad kernel driver version detected. Please re-compile kernel driver.\n \ - Note that aes-stream-driver (v5.15.2 or earlier) and rogue (v5.11.1 or earlier) are compatible with the 32-bit address API. \ - To use later versions (64-bit address API),, you will need to upgrade both rogue and aes-stream-driver at the same time to:\n \ - \t\taes-stream-driver = v5.16.0 (or later)\n\t\trogue = v5.13.0 (or later)")); + R"(Bad kernel driver version detected. Please re-compile kernel driver. + Note that aes-stream-driver (v5.15.2 or earlier) and rogue (v5.11.1 or earlier) are compatible with the 32-bit address API. + To use later versions (64-bit address API),, you will need to upgrade both rogue and aes-stream-driver at the same time to: + \t\taes-stream-driver = v5.16.0 (or later) + \t\trogue = v5.13.0 (or later))")); + } + + // Check for mismatch in the rogue/loaded_driver API versions + if (dmaCheckVersion(fd_) < 0) { + ::close(fd_); + throw(rogue::GeneralError( + "AxiMemMap::AxiMemMap", + "Rogue DmaDriver.h API Version (DMA_VERSION) does not match the aes-stream-driver API version")); + } // Start read thread threadEn_ = true; @@ -105,7 +115,7 @@ void rha::AxiMemMap::runThread() { uint8_t* ptr; dataSize = sizeof(uint32_t); - ptr = (uint8_t*)(&data); + ptr = reinterpret_cast(&data); log_->logThreadId(); diff --git a/src/rogue/hardware/axi/AxiStreamDma.cpp b/src/rogue/hardware/axi/AxiStreamDma.cpp index d7330925a..40111d6a7 100644 --- a/src/rogue/hardware/axi/AxiStreamDma.cpp +++ b/src/rogue/hardware/axi/AxiStreamDma.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : AXI DMA Interface Class * ---------------------------------------------------------------------------- - * File : AxiStreamDma.h - * Created : 2017-03-21 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Class for interfacing to AxiStreamDma Driver. @@ -38,7 +35,7 @@ namespace rha = rogue::hardware::axi; namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -63,10 +60,9 @@ rha::AxiStreamDmaSharedPtr rha::AxiStreamDma::openShared(std::string path, rogue if ((it = sharedBuffers_.find(path)) != sharedBuffers_.end()) { ret = it->second; log->debug("Reusing existing shared file descriptor for %s", path.c_str()); - } - // Create new record - else { + // Create new record + } else { ret = std::make_shared(path); log->debug("Opening new shared file descriptor for %s", path.c_str()); } @@ -88,20 +84,30 @@ rha::AxiStreamDmaSharedPtr rha::AxiStreamDma::openShared(std::string path, rogue if ((ret->fd = ::open(path.c_str(), O_RDWR)) < 0) throw(rogue::GeneralError::create("AxiStreamDma::openShared", "Failed to open device file: %s", path.c_str())); - if (dmaCheckVersion(ret->fd) < 0) { + // Check driver version ( ApiVersion 0x05 (or less) is the 32-bit address version) + if (dmaGetApiVersion(ret->fd) < 0x06) { ::close(ret->fd); throw(rogue::GeneralError("AxiStreamDma::openShared", - "Bad kernel driver version detected. Please re-compile kernel driver.\n \ - Note that aes-stream-driver (v5.15.2 or earlier) and rogue (v5.11.1 or earlier) are compatible with the 32-bit address API. \ - To use later versions (64-bit address API),, you will need to upgrade both rogue and aes-stream-driver at the same time to:\n \ - \t\taes-stream-driver = v5.16.0 (or later)\n\t\trogue = v5.13.0 (or later)")); + R"(Bad kernel driver version detected. Please re-compile kernel driver. + Note that aes-stream-driver (v5.15.2 or earlier) and rogue (v5.11.1 or earlier) are compatible with the 32-bit address API. + To use later versions (64-bit address API),, you will need to upgrade both rogue and aes-stream-driver at the same time to: + \t\taes-stream-driver = v5.16.0 (or later) + \t\trogue = v5.13.0 (or later))")); + } + + // Check for mismatch in the rogue/loaded_driver API versions + if (dmaCheckVersion(ret->fd) < 0) { + ::close(ret->fd); + throw(rogue::GeneralError( + "AxiStreamDma::openShared", + "Rogue DmaDriver.h API Version (DMA_VERSION) does not match the aes-stream-driver API version")); } // Result may be that rawBuff = NULL // Should this just be a warning? ret->rawBuff = dmaMapDma(ret->fd, &(ret->bCount), &(ret->bSize)); if (ret->rawBuff == NULL) { - ret->bCount = ioctl(ret->fd, DMA_Get_Buff_Count, 0); + ret->bCount = dmaGetBuffCount(ret->fd); // New map limit should be 8K more than the total number of buffers we require uint32_t mapSize = ret->bCount + 8192; @@ -124,7 +130,9 @@ void rha::AxiStreamDma::closeShared(rha::AxiStreamDmaSharedPtr desc) { desc->openCount--; if (desc->openCount == 0) { - if (desc->rawBuff != NULL) { dmaUnMapDma(desc->fd, desc->rawBuff); } + if (desc->rawBuff != NULL) { + dmaUnMapDma(desc->fd, desc->rawBuff); + } ::close(desc->fd); desc->fd = -1; @@ -271,10 +279,9 @@ ris::FramePtr rha::AxiStreamDma::acceptReq(uint32_t size, bool zeroCopyEn) { // Zero copy is disabled. Allocate from memory. if (zeroCopyEn == false || desc_->rawBuff == NULL) { frame = reqLocalFrame(size, false); - } - // Allocate zero copy buffers from driver - else { + // Allocate zero copy buffers from driver + } else { rogue::GilRelease noGil; // Create empty frame @@ -345,17 +352,17 @@ void rha::AxiStreamDma::acceptFrame(ris::FramePtr frame) { if (it == frame->beginBuffer()) { fuser = frame->getFirstUser(); if (enSsi_) fuser |= 0x2; - } else + } else { fuser = 0; + } // Last Buffer if (it == (frame->endBuffer() - 1)) { cont = 0; luser = frame->getLastUser(); - } - // Continue flag is set if this is not the last (*it)er - else { + // Continue flag is set if this is not the last (*it)er + } else { cont = 1; luser = 0; } @@ -382,10 +389,9 @@ void rha::AxiStreamDma::acceptFrame(ris::FramePtr frame) { meta |= 0x40000000; (*it)->setMeta(meta); } - } - // Write to pgp with (*it)er copy in driver - else { + // Write to pgp with (*it)er copy in driver + } else { // Keep trying since select call can fire // but write fails because we did not win the (*it)er lock do { @@ -410,10 +416,7 @@ void rha::AxiStreamDma::acceptFrame(ris::FramePtr frame) { throw(rogue::GeneralError("AxiStreamDma::acceptFrame", "AXIS Write Call Failed!!!!")); } } - } - - // Exit out if return flag was set false - while (res == 0); + } while (res == 0); // Exit out if return flag was set false } } @@ -443,8 +446,8 @@ void rha::AxiStreamDma::retBuffer(uint8_t* data, uint32_t meta, uint32_t size) { if ( count > 100 ) count = 100; for (x=0; x < count; x++) ret[x] = retQueue_.pop() & 0x3FFFFFFF; - if ( dmaRetIndexes(fd_,count,ret) < 0 ) - throw(rogue::GeneralError("AxiStreamDma::retBuffer","AXIS Return Buffer Call Failed!!!!")); + if ( dmaRetIndexes(fd_, count, ret) < 0 ) + throw(rogue::GeneralError("AxiStreamDma::retBuffer", "AXIS Return Buffer Call Failed!!!!")); decCounter(size*count); printf("Return done\n"); @@ -457,11 +460,11 @@ void rha::AxiStreamDma::retBuffer(uint8_t* data, uint32_t meta, uint32_t size) { #endif } decCounter(size); - } - // Buffer is allocated from Pool class - else + // Buffer is allocated from Pool class + } else { Pool::retBuffer(data, meta, size); + } } //! Run thread @@ -515,10 +518,9 @@ void rha::AxiStreamDma::runThread(std::weak_ptr lockPtr) { rxCount = rxSize[0]; else rxCount = 1; - } - // Zero copy read - else { + // Zero copy read + } else { // Attempt read, dest is not needed since only one lane/vc is open rxCount = dmaReadBulkIndex(fd_, RxBufferCount, rxSize, meta, rxFlags, rxError, NULL); @@ -566,6 +568,81 @@ void rha::AxiStreamDma::runThread(std::weak_ptr lockPtr) { } } +//! Get the DMA Driver's Git Version +std::string rha::AxiStreamDma::getGitVersion() { + return dmaGetGitVersion(fd_); +} + +//! Get the DMA Driver's API Version +uint32_t rha::AxiStreamDma::getApiVersion() { + return dmaGetApiVersion(fd_); +} + +//! Get the size of buffers (RX/TX) +uint32_t rha::AxiStreamDma::getBuffSize() { + return dmaGetBuffSize(fd_); +} + +//! Get the number of RX buffers +uint32_t rha::AxiStreamDma::getRxBuffCount() { + return dmaGetRxBuffCount(fd_); +} + +//! Get RX buffer in User count +uint32_t rha::AxiStreamDma::getRxBuffinUserCount() { + return dmaGetRxBuffinUserCount(fd_); +} + +//! Get RX buffer in HW count +uint32_t rha::AxiStreamDma::getRxBuffinHwCount() { + return dmaGetRxBuffinHwCount(fd_); +} + +//! Get RX buffer in Pre-HW Queue count +uint32_t rha::AxiStreamDma::getRxBuffinPreHwQCount() { + return dmaGetRxBuffinPreHwQCount(fd_); +} + +//! Get RX buffer in SW Queue count +uint32_t rha::AxiStreamDma::getRxBuffinSwQCount() { + return dmaGetRxBuffinSwQCount(fd_); +} + +//! Get RX buffer missing count +uint32_t rha::AxiStreamDma::getRxBuffMissCount() { + return dmaGetRxBuffMissCount(fd_); +} + +//! Get the number of TX buffers +uint32_t rha::AxiStreamDma::getTxBuffCount() { + return dmaGetTxBuffCount(fd_); +} + +//! Get TX buffer in User count +uint32_t rha::AxiStreamDma::getTxBuffinUserCount() { + return dmaGetTxBuffinUserCount(fd_); +} + +//! Get TX buffer in HW count +uint32_t rha::AxiStreamDma::getTxBuffinHwCount() { + return dmaGetTxBuffinHwCount(fd_); +} + +//! Get TX buffer in Pre-HW Queue count +uint32_t rha::AxiStreamDma::getTxBuffinPreHwQCount() { + return dmaGetTxBuffinPreHwQCount(fd_); +} + +//! Get TX buffer in SW Queue count +uint32_t rha::AxiStreamDma::getTxBuffinSwQCount() { + return dmaGetTxBuffinSwQCount(fd_); +} + +//! Get TX buffer missing count +uint32_t rha::AxiStreamDma::getTxBuffMissCount() { + return dmaGetTxBuffMissCount(fd_); +} + void rha::AxiStreamDma::setup_python() { #ifndef NO_PYTHON @@ -575,6 +652,21 @@ void rha::AxiStreamDma::setup_python() { .def("setDriverDebug", &rha::AxiStreamDma::setDriverDebug) .def("dmaAck", &rha::AxiStreamDma::dmaAck) .def("setTimeout", &rha::AxiStreamDma::setTimeout) + .def("getGitVersion", &rha::AxiStreamDma::getGitVersion) + .def("getApiVersion", &rha::AxiStreamDma::getApiVersion) + .def("getBuffSize", &rha::AxiStreamDma::getBuffSize) + .def("getRxBuffCount", &rha::AxiStreamDma::getRxBuffCount) + .def("getRxBuffinUserCount", &rha::AxiStreamDma::getRxBuffinUserCount) + .def("getRxBuffinHwCount", &rha::AxiStreamDma::getRxBuffinHwCount) + .def("getRxBuffinPreHwQCount", &rha::AxiStreamDma::getRxBuffinPreHwQCount) + .def("getRxBuffinSwQCount", &rha::AxiStreamDma::getRxBuffinSwQCount) + .def("getRxBuffMissCount", &rha::AxiStreamDma::getRxBuffMissCount) + .def("getTxBuffCount", &rha::AxiStreamDma::getTxBuffCount) + .def("getTxBuffinUserCount", &rha::AxiStreamDma::getTxBuffinUserCount) + .def("getTxBuffinHwCount", &rha::AxiStreamDma::getTxBuffinHwCount) + .def("getTxBuffinPreHwQCount", &rha::AxiStreamDma::getTxBuffinPreHwQCount) + .def("getTxBuffinSwQCount", &rha::AxiStreamDma::getTxBuffinSwQCount) + .def("getTxBuffMissCount", &rha::AxiStreamDma::getTxBuffMissCount) .def("zeroCopyDisable", &rha::AxiStreamDma::zeroCopyDisable); bp::implicitly_convertible(); diff --git a/src/rogue/hardware/axi/CMakeLists.txt b/src/rogue/hardware/axi/CMakeLists.txt index 2e5a0231e..112608603 100644 --- a/src/rogue/hardware/axi/CMakeLists.txt +++ b/src/rogue/hardware/axi/CMakeLists.txt @@ -1,8 +1,5 @@ # ---------------------------------------------------------------------------- -# Title : ROGUE CMAKE Control -# ---------------------------------------------------------------------------- -# File : src/rogue/hardware/axi/CMakeLists.txt -# Created : 2018-02-27 +# Company : SLAC National Accelerator Laboratory # ---------------------------------------------------------------------------- # This file is part of the rogue software package. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/src/rogue/hardware/axi/module.cpp b/src/rogue/hardware/axi/module.cpp index 0ae5fbf9b..dc27cc1ff 100644 --- a/src/rogue/hardware/axi/module.cpp +++ b/src/rogue/hardware/axi/module.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module * ---------------------------------------------------------------------------- - * File : module.cpp - * Created : 2017-03-21 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/src/rogue/hardware/module.cpp b/src/rogue/hardware/module.cpp index 2ca409cda..5cc45ecc2 100644 --- a/src/rogue/hardware/module.cpp +++ b/src/rogue/hardware/module.cpp @@ -1,11 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module * ---------------------------------------------------------------------------- - * File : module.cpp - * Author : Ryan Herbst, rherbst@slac.stanford.edu - * Created : 2016-08-08 - * Last update: 2016-08-08 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/src/rogue/interfaces/CMakeLists.txt b/src/rogue/interfaces/CMakeLists.txt index 0bf1155a3..8ee5c9bfa 100644 --- a/src/rogue/interfaces/CMakeLists.txt +++ b/src/rogue/interfaces/CMakeLists.txt @@ -1,8 +1,5 @@ # ---------------------------------------------------------------------------- -# Title : ROGUE CMAKE Control -# ---------------------------------------------------------------------------- -# File : src/rogue/interfaces/CMakeLists.txt -# Created : 2018-02-27 +# Company : SLAC National Accelerator Laboratory # ---------------------------------------------------------------------------- # This file is part of the rogue software package. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/src/rogue/interfaces/ZmqClient.cpp b/src/rogue/interfaces/ZmqClient.cpp index f496a760b..cc37bf36e 100644 --- a/src/rogue/interfaces/ZmqClient.cpp +++ b/src/rogue/interfaces/ZmqClient.cpp @@ -1,9 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : Rogue ZMQ Control Interface * ---------------------------------------------------------------------------- - * File : ZmqClient.cpp - * Created : 2019-05-02 + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- + * Description: + * Rogue ZMQ Control Interface * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory @@ -30,7 +30,7 @@ #include "rogue/ScopedGil.h" #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -74,7 +74,7 @@ rogue::interfaces::ZmqClient::ZmqClient(std::string addr, uint16_t port, bool do temp = "tcp://"; temp.append(addr); temp.append(":"); - temp.append(std::to_string(static_cast(port))); + temp.append(std::to_string(static_cast(port))); if (zmq_setsockopt(this->zmqSub_, ZMQ_SUBSCRIBE, "", 0) != 0) throw(rogue::GeneralError("ZmqClient::ZmqClient", "Failed to set socket subscribe")); @@ -90,14 +90,15 @@ rogue::interfaces::ZmqClient::ZmqClient(std::string addr, uint16_t port, bool do addr.c_str())); reqPort = port + 1; - } else + } else { reqPort = port + 2; + } // Setup request port temp = "tcp://"; temp.append(addr); temp.append(":"); - temp.append(std::to_string(static_cast(reqPort))); + temp.append(std::to_string(static_cast(reqPort))); waitRetry_ = false; // Don't keep waiting after timeout timeout_ = 1000; // 1 second @@ -183,19 +184,22 @@ std::string rogue::interfaces::ZmqClient::sendString(std::string path, std::stri rogue::GilRelease noGil; zmq_send(this->zmqReq_, snd.c_str(), snd.size(), 0); - while (1) { - zmq_msg_init(&msg); - if ( zmq_recvmsg(this->zmqReq_,&msg,0) <= 0 ) { - seconds += (float)timeout_ / 1000.0; - if ( waitRetry_ ) { - log_->error("Timeout waiting for response after %f Seconds, server may be busy! Waiting...", seconds); - zmq_msg_close(&msg); - } - else - throw rogue::GeneralError::create("ZmqClient::sendString","Timeout waiting for response after %f Seconds.",seconds); - } - else break; - } + while (1) { + zmq_msg_init(&msg); + if (zmq_recvmsg(this->zmqReq_, &msg, 0) <= 0) { + seconds += static_cast(timeout_) / 1000.0; + if (waitRetry_) { + log_->error("Timeout waiting for response after %f Seconds, server may be busy! Waiting...", seconds); + zmq_msg_close(&msg); + } else { + throw rogue::GeneralError::create("ZmqClient::sendString", + "Timeout waiting for response after %f Seconds.", + seconds); + } + } else { + break; + } + } if (seconds != 0) log_->error("Finally got response from server after %f seconds!", seconds); @@ -245,18 +249,20 @@ bp::object rogue::interfaces::ZmqClient::send(bp::object value) { while (1) { zmq_msg_init(&rxMsg); if (zmq_recvmsg(this->zmqReq_, &rxMsg, 0) <= 0) { - seconds += (float)timeout_ / 1000.0; + seconds += static_cast(timeout_) / 1000.0; if (waitRetry_) { log_->error("Timeout waiting for response after %f Seconds, server may be busy! Waiting...", seconds); zmq_msg_close(&rxMsg); - } else + } else { throw rogue::GeneralError::create( "ZmqClient::send", "Timeout waiting for response after %f Seconds, server may be busy!", seconds); - } else + } + } else { break; + } } } @@ -282,7 +288,9 @@ void rogue::interfaces::ZmqClientWrap::doUpdate(bp::object data) { if (bp::override f = this->get_override("_doUpdate")) { try { f(data); - } catch (...) { PyErr_Print(); } + } catch (...) { + PyErr_Print(); + } } rogue::interfaces::ZmqClient::doUpdate(data); } diff --git a/src/rogue/interfaces/ZmqServer.cpp b/src/rogue/interfaces/ZmqServer.cpp index eb5359189..d7a967b52 100644 --- a/src/rogue/interfaces/ZmqServer.cpp +++ b/src/rogue/interfaces/ZmqServer.cpp @@ -1,9 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : Rogue ZMQ Control Interface * ---------------------------------------------------------------------------- - * File : ZmqServer.cpp - * Created : 2019-05-02 + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- + * Description: + * Rogue ZMQ Control Interface * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory @@ -30,7 +30,7 @@ #include "rogue/ScopedGil.h" #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -82,8 +82,9 @@ void rogue::interfaces::ZmqServer::start() { res = this->tryConnect(); if (res) break; } - } else + } else { res = this->tryConnect(); + } if (!res) { if (port == 0) @@ -162,7 +163,7 @@ bool rogue::interfaces::ZmqServer::tryConnect() { temp = "tcp://"; temp.append(this->addr_); temp.append(":"); - temp.append(std::to_string(static_cast(this->basePort_))); + temp.append(std::to_string(static_cast(this->basePort_))); if (zmq_bind(this->zmqPub_, temp.c_str()) < 0) { zmq_close(this->zmqPub_); @@ -176,7 +177,7 @@ bool rogue::interfaces::ZmqServer::tryConnect() { temp = "tcp://"; temp.append(this->addr_); temp.append(":"); - temp.append(std::to_string(static_cast(this->basePort_ + 1))); + temp.append(std::to_string(static_cast(this->basePort_ + 1))); if (zmq_bind(this->zmqRep_, temp.c_str()) < 0) { zmq_close(this->zmqPub_); @@ -190,7 +191,7 @@ bool rogue::interfaces::ZmqServer::tryConnect() { temp = "tcp://"; temp.append(this->addr_); temp.append(":"); - temp.append(std::to_string(static_cast(this->basePort_ + 2))); + temp.append(std::to_string(static_cast(this->basePort_ + 2))); if (zmq_bind(this->zmqStr_, temp.c_str()) < 0) { zmq_close(this->zmqPub_); @@ -242,7 +243,9 @@ bp::object rogue::interfaces::ZmqServerWrap::doRequest(bp::object data) { if (bp::override f = this->get_override("_doRequest")) { try { return (f(data)); - } catch (...) { PyErr_Print(); } + } catch (...) { + PyErr_Print(); + } } return (rogue::interfaces::ZmqServer::doRequest(data)); } @@ -257,7 +260,9 @@ std::string rogue::interfaces::ZmqServerWrap::doString(std::string data) { if (bp::override f = this->get_override("_doString")) { try { return (f(data)); - } catch (...) { PyErr_Print(); } + } catch (...) { + PyErr_Print(); + } } } return (rogue::interfaces::ZmqServer::doString(data)); diff --git a/src/rogue/interfaces/api/Bsp.cpp b/src/rogue/interfaces/api/Bsp.cpp index bb8a8df5d..b4b8d3066 100644 --- a/src/rogue/interfaces/api/Bsp.cpp +++ b/src/rogue/interfaces/api/Bsp.cpp @@ -1,9 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : C++ API Bsp * ---------------------------------------------------------------------------- - * File : Bsp.cpp - * Created : 2023-04-18 + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- + * Description: + * C++ API BSP (Board Support Package) * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory @@ -55,7 +55,9 @@ ria::Bsp::Bsp(std::string modName, std::string rootClass) { } ria::Bsp::~Bsp() { - if (this->_isRoot) { this->_obj.attr("stop")(); } + if (this->_isRoot) { + this->_obj.attr("stop")(); + } } void ria::Bsp::addVarListener(void (*func)(std::string, std::string), void (*done)()) { @@ -109,14 +111,18 @@ std::shared_ptr ria::Bsp::getNode(std::string name) std::string ria::Bsp::operator()(std::string arg) { try { return (std::string(bp::extract(this->_obj.attr("callDisp")(arg)))); - } catch (...) { throw(rogue::GeneralError::create("Bsp::()", "Error executing node %s", this->_name.c_str())); } + } catch (...) { + throw(rogue::GeneralError::create("Bsp::()", "Error executing node %s", this->_name.c_str())); + } } //! Execute command operator without arg std::string ria::Bsp::operator()() { try { return (std::string(bp::extract(this->_obj.attr("callDisp")()))); - } catch (...) { throw(rogue::GeneralError::create("Bsp::()", "Error executing node %s", this->_name.c_str())); } + } catch (...) { + throw(rogue::GeneralError::create("Bsp::()", "Error executing node %s", this->_name.c_str())); + } } //! Execute command diff --git a/src/rogue/interfaces/api/CMakeLists.txt b/src/rogue/interfaces/api/CMakeLists.txt index cd80d6a03..a518fc724 100644 --- a/src/rogue/interfaces/api/CMakeLists.txt +++ b/src/rogue/interfaces/api/CMakeLists.txt @@ -1,8 +1,5 @@ # ---------------------------------------------------------------------------- -# Title : ROGUE CMAKE Control -# ---------------------------------------------------------------------------- -# File : src/rogue/interfaces/api/CMakeLists.txt -# Created : 2023-04-17 +# Company : SLAC National Accelerator Laboratory # ---------------------------------------------------------------------------- # This file is part of the rogue software package. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/src/rogue/interfaces/memory/Block.cpp b/src/rogue/interfaces/memory/Block.cpp index 5e3a106e5..2c81292ea 100644 --- a/src/rogue/interfaces/memory/Block.cpp +++ b/src/rogue/interfaces/memory/Block.cpp @@ -1,11 +1,9 @@ -/* - *----------------------------------------------------------------------------- - * Title : Memory Block +/** * ---------------------------------------------------------------------------- - * File : Block.cpp + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: - * Interface between RemoteVariables and lower level memory transactions. + * Interface between RemoteVariables and lower level memory transactions. * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory @@ -42,10 +40,10 @@ namespace rim = rogue::interfaces::memory; #ifndef NO_PYTHON -#include -#include + #include + #include -#include + #include namespace bp = boost::python; #endif @@ -99,13 +97,13 @@ rim::Block::Block(uint64_t offset, uint32_t size) { verifyBase_ = 0; // Verify Range verifySize_ = 0; // Verify Range - blockData_ = (uint8_t*)malloc(size_); + blockData_ = reinterpret_cast(malloc(size_)); memset(blockData_, 0, size_); - verifyData_ = (uint8_t*)malloc(size_); + verifyData_ = reinterpret_cast(malloc(size_)); memset(verifyData_, 0, size_); - verifyMask_ = (uint8_t*)malloc(size_); + verifyMask_ = reinterpret_cast(malloc(size_)); memset(verifyMask_, 0, size_); } @@ -148,7 +146,7 @@ uint64_t rim::Block::offset() { // Get full address of this Block uint64_t rim::Block::address() { - return (reqAddress() | offset_); + return (reqAddress() + offset_); } // Get size of this block in bytes. @@ -174,11 +172,10 @@ void rim::Block::intStartTransaction(uint32_t type, bool forceWr, bool check, ri std::vector::iterator vit; // Check for valid combinations - if ((type == rim::Write and ((mode_ == "RO") || (!stale_ && !forceWr))) || - (type == rim::Post and (mode_ == "RO")) || (type == rim::Read and ((mode_ == "WO") || stale_)) || - (type == rim::Verify and ((mode_ == "WO") || (mode_ == "RO") || stale_ || !verifyReq_))) + if ((type == rim::Write && ((mode_ == "RO") || (!stale_ && !forceWr))) || (type == rim::Post && (mode_ == "RO")) || + (type == rim::Read && ((mode_ == "WO") || stale_)) || + (type == rim::Verify && ((mode_ == "WO") || (mode_ == "RO") || stale_ || !verifyReq_))) return; - { rogue::GilRelease noGil; std::lock_guard lock(mtx_); @@ -191,16 +188,23 @@ void rim::Block::intStartTransaction(uint32_t type, bool forceWr, bool check, ri highByte = size_ - 1; if (type == rim::Write || type == rim::Post) { stale_ = false; - for (vit = variables_.begin(); vit != variables_.end(); ++vit) { (*vit)->stale_ = false; } + for (vit = variables_.begin(); vit != variables_.end(); ++vit) { + (*vit)->stale_ = false; + } } } else { if (type == rim::Read || type == rim::Verify) { if (index < 0 || index >= var->numValues_) { - lowByte = var->lowTranByte_; - highByte = var->highTranByte_; + lowByte = var->lowTranByte_[0]; + + if ( var->numValues_ == 0 ) { + highByte = var->highTranByte_[0]; + } else { + highByte = var->highTranByte_[var->numValues_-1]; + } } else { - lowByte = var->listLowTranByte_[index]; - highByte = var->listHighTranByte_[index]; + lowByte = var->lowTranByte_[index]; + highByte = var->highTranByte_[index]; } } else { lowByte = var->staleLowByte_; @@ -229,10 +233,9 @@ void rim::Block::intStartTransaction(uint32_t type, bool forceWr, bool check, ri tSize = verifySize_; tData = verifyData_ + verifyBase_; verifyInp_ = true; - } - // Not a verify transaction - else { + // Not a verify transaction + } else { // Derive offset and size based upon min transaction size tOff = lowByte; tSize = (highByte - lowByte) + 1; @@ -277,10 +280,7 @@ void rim::Block::startTransaction(uint32_t type, bool forceWr, bool check, rim:: try { if (check || retryCount_ > 0) checkTransaction(); - - // Success - count = retryCount_; - + count = retryCount_; // Success } catch (rogue::GeneralError err) { fWr = true; // Stale state is now lost @@ -320,10 +320,7 @@ void rim::Block::startTransactionPy(uint32_t type, bool forceWr, bool check, rim try { if (check || retryCount_ > 0) upd = checkTransaction(); - - // Success - count = retryCount_; - + count = retryCount_; // Success } catch (rogue::GeneralError err) { fWr = true; // Stale state is now lost @@ -474,38 +471,84 @@ void rim::Block::addVariables(std::vector variables) { // If variable modes mismatch, set block to read/write if (mode_ != (*vit)->mode_) mode_ = "RW"; - // Update variable masks - for (x = 0; x < (*vit)->bitOffset_.size(); x++) { - // Variable allows overlaps, add to overlap enable mask - if ((*vit)->overlapEn_) setBits(oleMask, (*vit)->bitOffset_[x], (*vit)->bitSize_[x]); + // Update variable masks for standard variable + if ((*vit)->numValues_ == 0) { + for (x = 0; x < (*vit)->bitOffset_.size(); x++) { + // Variable allows overlaps, add to overlap enable mask + if ((*vit)->overlapEn_) { + setBits(oleMask, (*vit)->bitOffset_[x], (*vit)->bitSize_[x]); - // Otherwise add to exclusive mask and check for existing mapping - else { - if (anyBits(excMask, (*vit)->bitOffset_[x], (*vit)->bitSize_[x])) - throw(rogue::GeneralError::create("Block::addVariables", - "Variable bit overlap detected for block %s with address 0x%.8x", - path_.c_str(), - address())); + // Otherwise add to exclusive mask and check for existing mapping + } else { + if (anyBits(excMask, (*vit)->bitOffset_[x], (*vit)->bitSize_[x])) + throw(rogue::GeneralError::create( + "Block::addVariables", + "Variable bit overlap detected for block %s with address 0x%.8x and variable %s", + path_.c_str(), + address(), + (*vit)->name_.c_str())); + + setBits(excMask, (*vit)->bitOffset_[x], (*vit)->bitSize_[x]); + } - setBits(excMask, (*vit)->bitOffset_[x], (*vit)->bitSize_[x]); - } + // update verify mask + if ((*vit)->mode_ == "RW" && (*vit)->verifyEn_) { + verifyEn_ = true; + setBits(verifyMask_, (*vit)->bitOffset_[x], (*vit)->bitSize_[x]); + } - // update verify mask - if ((*vit)->mode_ == "RW" && (*vit)->verifyEn_) { - verifyEn_ = true; - setBits(verifyMask_, (*vit)->bitOffset_[x], (*vit)->bitSize_[x]); + bLog_->debug( + "Adding variable %s to block %s at offset 0x%.8x, bitIdx=%i, bitOffset %i, bitSize %i, mode %s, " + "verifyEn " + "%d " PRIx64, + (*vit)->name_.c_str(), + path_.c_str(), + offset_, + x, + (*vit)->bitOffset_[x], + (*vit)->bitSize_[x], + (*vit)->mode_.c_str(), + (*vit)->verifyEn_); } - bLog_->debug( - "Adding variable %s to block %s at offset 0x%.8x, bitOffset %i, bitSize %i, mode %s, verifyEn " - "%d " PRIx64, - (*vit)->name_.c_str(), - path_.c_str(), - offset_, - (*vit)->bitOffset_[x], - (*vit)->bitSize_[x], - (*vit)->mode_.c_str(), - (*vit)->verifyEn_); + // List variables + } else { + for (x = 0; x < (*vit)->numValues_; x++) { + // Variable allows overlaps, add to overlap enable mask + if ((*vit)->overlapEn_) { + setBits(oleMask, x * (*vit)->valueStride_ + (*vit)->bitOffset_[0], (*vit)->valueBits_); + + // Otherwise add to exclusive mask and check for existing mapping + } else { + if (anyBits(excMask, x * (*vit)->valueStride_ + (*vit)->bitOffset_[0], (*vit)->valueBits_)) + throw(rogue::GeneralError::create( + "Block::addVariables", + "Variable bit overlap detected for block %s with address 0x%.8x and variable %s", + path_.c_str(), + address(), + (*vit)->name_.c_str())); + + setBits(excMask, x * (*vit)->valueStride_ + (*vit)->bitOffset_[0], (*vit)->valueBits_); + } + + // update verify mask + if ((*vit)->mode_ == "RW" && (*vit)->verifyEn_) { + verifyEn_ = true; + setBits(verifyMask_, x * (*vit)->valueStride_ + (*vit)->bitOffset_[0], (*vit)->valueBits_); + } + + bLog_->debug( + "Adding variable %s to block %s at offset 0x%.8x, index=%i, valueOffset=%i, valueBits %i, mode %s, " + "verifyEn %d", + (*vit)->name_.c_str(), + path_.c_str(), + offset_, + x, + x * (*vit)->valueStride_ + (*vit)->bitOffset_[0], + (*vit)->valueBits_, + (*vit)->mode_.c_str(), + (*vit)->verifyEn_); + } } } @@ -513,7 +556,7 @@ void rim::Block::addVariables(std::vector variables) { for (x = 0; x < size_; x++) { if (oleMask[x] & excMask[x]) throw(rogue::GeneralError::create("Block::addVariables", - "Variable bit overlap detected for block %s with address 0x%.8x", + "Variable bit mask overlap detected for block %s with address 0x%.8x", path_.c_str(), address())); } @@ -591,11 +634,12 @@ void rim::Block::setBytes(const uint8_t* data, rim::Variable* var, uint32_t inde // Change byte order, need to make a copy if (var->byteReverse_) { - buff = (uint8_t*)malloc(var->valueBytes_); + buff = reinterpret_cast(malloc(var->valueBytes_)); memcpy(buff, data, var->valueBytes_); reverseBytes(buff, var->valueBytes_); - } else - buff = (uint8_t*)data; + } else { + buff = const_cast(reinterpret_cast(data)); + } // List variable if (var->numValues_ != 0) { @@ -614,29 +658,27 @@ void rim::Block::setBytes(const uint8_t* data, rim::Variable* var, uint32_t inde copyBits(blockData_, var->bitOffset_[0] + (index * var->valueStride_), buff, 0, var->valueBits_); if (var->stale_) { - if (var->listLowTranByte_[index] < var->staleLowByte_) var->staleLowByte_ = var->listLowTranByte_[index]; + if (var->lowTranByte_[index] < var->staleLowByte_) var->staleLowByte_ = var->lowTranByte_[index]; - if (var->listHighTranByte_[index] > var->staleHighByte_) - var->staleHighByte_ = var->listHighTranByte_[index]; + if (var->highTranByte_[index] > var->staleHighByte_) var->staleHighByte_ = var->highTranByte_[index]; } else { - var->staleLowByte_ = var->listLowTranByte_[index]; - var->staleHighByte_ = var->listHighTranByte_[index]; + var->staleLowByte_ = var->lowTranByte_[index]; + var->staleHighByte_ = var->highTranByte_[index]; } - } - // Standard variable - else { - var->staleLowByte_ = var->lowTranByte_; - var->staleHighByte_ = var->highTranByte_; + // Standard variable + } else { + var->staleLowByte_ = var->lowTranByte_[0]; + var->staleHighByte_ = var->highTranByte_[0]; // Fast copy - if (var->fastByte_ != NULL) + if (var->fastByte_ != NULL) { memcpy(blockData_ + var->fastByte_[0], buff, var->valueBytes_); - else if (var->bitOffset_.size() == 1) + } else if (var->bitOffset_.size() == 1) { copyBits(blockData_, var->bitOffset_[0], buff, 0, var->bitSize_[0]); - else { + } else { srcBit = 0; for (x = 0; x < var->bitOffset_.size(); x++) { copyBits(blockData_, var->bitOffset_[x], buff, srcBit, var->bitSize_[x]); @@ -671,17 +713,16 @@ void rim::Block::getBytes(uint8_t* data, rim::Variable* var, uint32_t index) { else copyBits(data, 0, blockData_, var->bitOffset_[0] + (index * var->valueStride_), var->valueBits_); - } - else { + } else { // Fast copy - if (var->fastByte_ != NULL) + if (var->fastByte_ != NULL) { memcpy(data, blockData_ + var->fastByte_[0], var->valueBytes_); - else if (var->bitOffset_.size() == 1) + } else if (var->bitOffset_.size() == 1) { copyBits(data, 0, blockData_, var->bitOffset_[0], var->bitSize_[0]); - else { + } else { dstBit = 0; for (x = 0; x < var->bitOffset_.size(); x++) { copyBits(data, dstBit, blockData_, var->bitOffset_[x], var->bitSize_[x]); @@ -691,7 +732,9 @@ void rim::Block::getBytes(uint8_t* data, rim::Variable* var, uint32_t index) { } // Change byte order - if (var->byteReverse_) { reverseBytes(data, var->valueBytes_); } + if (var->byteReverse_) { + reverseBytes(data, var->valueBytes_); + } } ////////////////////////////////////////// @@ -713,10 +756,9 @@ void rim::Block::setPyFunc(bp::object& value, rim::Variable* var, int32_t index) throw(rogue::GeneralError::create("Block::setPyFunc", "Passing ndarray not supported for %s", var->name_.c_str())); - } - // Is passed value a list - else if (PyList_Check(value.ptr())) { + // Is passed value a list + } else if (PyList_Check(value.ptr())) { bp::list vl = bp::extract(value); uint32_t vlen = len(vl); @@ -738,13 +780,12 @@ void rim::Block::setPyFunc(bp::object& value, rim::Variable* var, int32_t index) "Failed to extract byte array for %s", var->name_.c_str())); - setBytes((uint8_t*)valueBuf.buf, var, index + x); + setBytes(reinterpret_cast(valueBuf.buf), var, index + x); PyBuffer_Release(&valueBuf); } - } - // Single value - else { + // Single value + } else { // Call python function bp::object ret = ((rim::VariableWrap*)var)->toBytes(value); @@ -753,7 +794,7 @@ void rim::Block::setPyFunc(bp::object& value, rim::Variable* var, int32_t index) "Failed to extract byte array from pyFunc return value for %s", var->name_.c_str())); - setBytes((uint8_t*)valueBuf.buf, var, index); + setBytes(reinterpret_cast(valueBuf.buf), var, index); PyBuffer_Release(&valueBuf); } } @@ -768,10 +809,8 @@ bp::object rim::Block::getPyFunc(rim::Variable* var, int32_t index) { "Accessing unindexed value not support for %s", var->name_.c_str())); - } - - // Single value - else { + // Single value + } else { memset(getBuffer, 0, var->valueBytes_); getBytes(getBuffer, var, index); @@ -809,7 +848,7 @@ void rim::Block::setByteArrayPy(bp::object& value, rim::Variable* var, int32_t i "Failed to extract byte array for %s", var->name_.c_str())); - setBytes((uint8_t*)valueBuf.buf, var, index); + setBytes(reinterpret_cast(valueBuf.buf), var, index); PyBuffer_Release(&valueBuf); } @@ -886,15 +925,14 @@ void rim::Block::setUIntPy(bp::object& value, rim::Variable* var, int32_t index) } else if (PyArray_TYPE(arr) == NPY_UINT32) { uint32_t* src = reinterpret_cast(PyArray_DATA(arr)); for (x = 0; x < dims[0]; x++) setUInt(src[x], var, index + x); - } else + } else { throw(rogue::GeneralError::create("Block::setUIntPy", "Passed nparray is not of type (uint64 or uint32) for %s", var->name_.c_str())); + } - } - - // Is passed value a list - else if (PyList_Check(value.ptr())) { + // Is passed value a list + } else if (PyList_Check(value.ptr())) { bp::list vl = bp::extract(value); uint32_t vlen = len(vl); @@ -917,10 +955,9 @@ void rim::Block::setUIntPy(bp::object& value, rim::Variable* var, int32_t index) setUInt(tmp, var, index + x); } - } - // Passed scalar numpy value - else if (PyArray_CheckScalar(value.ptr())) { + // Passed scalar numpy value + } else if (PyArray_CheckScalar(value.ptr())) { if (PyArray_DescrFromScalar(value.ptr())->type_num == NPY_UINT64) { uint64_t val; PyArray_ScalarAsCtype(value.ptr(), &val); @@ -929,9 +966,10 @@ void rim::Block::setUIntPy(bp::object& value, rim::Variable* var, int32_t index) uint32_t val; PyArray_ScalarAsCtype(value.ptr(), &val); setUInt(val, var, index); - } else + } else { throw( rogue::GeneralError::create("Block::setUIntPy", "Failed to extract value for %s.", var->name_.c_str())); + } } else { bp::extract tmp(value); @@ -993,14 +1031,14 @@ void rim::Block::setUInt(const uint64_t& val, rim::Variable* var, int32_t index) var->minValue_, var->maxValue_)); - setBytes((uint8_t*)&val, var, index); + setBytes(reinterpret_cast(const_cast(&val)), var, index); } // Get data using unsigned int uint64_t rim::Block::getUInt(rim::Variable* var, int32_t index) { uint64_t tmp = 0; - getBytes((uint8_t*)&tmp, var, index); + getBytes(reinterpret_cast(&tmp), var, index); return tmp; } @@ -1045,15 +1083,14 @@ void rim::Block::setIntPy(bp::object& value, rim::Variable* var, int32_t index) } else if (PyArray_TYPE(arr) == NPY_INT32) { int32_t* src = reinterpret_cast(PyArray_DATA(arr)); for (x = 0; x < dims[0]; x++) setInt(src[x], var, index + x); - } else + } else { throw(rogue::GeneralError::create("Block::setIntPy", "Passed nparray is not of type (int64 or int32) for %s", var->name_.c_str())); + } - } - - // Is passed value a list - else if (PyList_Check(value.ptr())) { + // Is passed value a list + } else if (PyList_Check(value.ptr())) { bp::list vl = bp::extract(value); uint32_t vlen = len(vl); @@ -1076,10 +1113,9 @@ void rim::Block::setIntPy(bp::object& value, rim::Variable* var, int32_t index) setInt(tmp, var, index + x); } - } - // Passed scalar numpy value - else if (PyArray_CheckScalar(value.ptr())) { + // Passed scalar numpy value + } else if (PyArray_CheckScalar(value.ptr())) { if (PyArray_DescrFromScalar(value.ptr())->type_num == NPY_INT64) { int64_t val; PyArray_ScalarAsCtype(value.ptr(), &val); @@ -1088,9 +1124,10 @@ void rim::Block::setIntPy(bp::object& value, rim::Variable* var, int32_t index) int32_t val; PyArray_ScalarAsCtype(value.ptr(), &val); setInt(val, var, index); - } else + } else { throw( rogue::GeneralError::create("Block::setIntPy", "Failed to extract value for %s.", var->name_.c_str())); + } } else { bp::extract tmp(value); @@ -1153,14 +1190,14 @@ void rim::Block::setInt(const int64_t& val, rim::Variable* var, int32_t index) { var->maxValue_)); // This works because all bits between the msb and bit 64 are set to '1' for a negative value - setBytes((uint8_t*)&val, var, index); + setBytes(reinterpret_cast(const_cast(&val)), var, index); } // Get data using int int64_t rim::Block::getInt(rim::Variable* var, int32_t index) { int64_t tmp = 0; - getBytes((uint8_t*)&tmp, var, index); + getBytes(reinterpret_cast(&tmp), var, index); if (var->valueBits_ != 64) { if (tmp >= (uint64_t)pow(2, var->valueBits_ - 1)) tmp -= (uint64_t)pow(2, var->valueBits_); @@ -1205,15 +1242,14 @@ void rim::Block::setBoolPy(bp::object& value, rim::Variable* var, int32_t index) if (PyArray_TYPE(arr) == NPY_BOOL) { bool* src = reinterpret_cast(PyArray_DATA(arr)); for (x = 0; x < dims[0]; x++) setBool(src[x], var, index + x); - } else + } else { throw(rogue::GeneralError::create("Block::setBoolPy", "Passed nparray is not of type (bool) for %s", var->name_.c_str())); + } - } - - // Is passed value a list - else if (PyList_Check(value.ptr())) { + // Is passed value a list + } else if (PyList_Check(value.ptr())) { bp::list vl = bp::extract(value); uint32_t vlen = len(vl); @@ -1236,17 +1272,17 @@ void rim::Block::setBoolPy(bp::object& value, rim::Variable* var, int32_t index) setBool(tmp, var, index + x); } - } - // Passed scalar numpy value - else if (PyArray_CheckScalar(value.ptr())) { + // Passed scalar numpy value + } else if (PyArray_CheckScalar(value.ptr())) { if (PyArray_DescrFromScalar(value.ptr())->type_num == NPY_BOOL) { bool val; PyArray_ScalarAsCtype(value.ptr(), &val); setBool(val, var, index); - } else + } else { throw( rogue::GeneralError::create("Block::setBoolPy", "Failed to extract value for %s.", var->name_.c_str())); + } } else { bp::extract tmp(value); @@ -1275,9 +1311,8 @@ bp::object rim::Block::getBoolPy(rim::Variable* var, int32_t index) { boost::python::handle<> handle(obj); ret = bp::object(handle); - } - else { + } else { bp::handle<> handle(bp::borrowed(getBool(var, index) ? Py_True : Py_False)); ret = bp::object(handle); } @@ -1289,14 +1324,14 @@ bp::object rim::Block::getBoolPy(rim::Variable* var, int32_t index) { // Set data using bool void rim::Block::setBool(const bool& value, rim::Variable* var, int32_t index) { uint8_t val = (uint8_t)value; - setBytes((uint8_t*)&val, var, index); + setBytes(reinterpret_cast(&val), var, index); } // Get data using bool bool rim::Block::getBool(rim::Variable* var, int32_t index) { uint8_t tmp = 0; - getBytes((uint8_t*)&tmp, var, index); + getBytes(reinterpret_cast(&tmp), var, index); return tmp ? true : false; } @@ -1355,7 +1390,7 @@ void rim::Block::setString(const std::string& value, rim::Variable* var, int32_t memset(getBuffer, 0, var->valueBytes_); - strncpy((char*)getBuffer, value.c_str(), var->valueBytes_ - 1); + strncpy(reinterpret_cast(getBuffer), value.c_str(), var->valueBytes_ - 1); setBytes(getBuffer, var, index); } @@ -1373,7 +1408,7 @@ void rim::Block::getString(rim::Variable* var, std::string& retString, int32_t i memset(getBuffer, 0, var->valueBytes_ + 1); - getBytes((uint8_t*)getBuffer, var, index); + getBytes(reinterpret_cast(getBuffer), var, index); retString = getBuffer; } @@ -1415,14 +1450,14 @@ void rim::Block::setFloatPy(bp::object& value, rim::Variable* var, int32_t index if (PyArray_TYPE(arr) == NPY_FLOAT32) { float* src = reinterpret_cast(PyArray_DATA(arr)); for (x = 0; x < dims[0]; x++) setFloat(src[x], var, index + x); - } else + } else { throw(rogue::GeneralError::create("Block::setFLoatPy", "Passed nparray is not of type (float32) for %s", var->name_.c_str())); - } + } - // Is passed value a list - else if (PyList_Check(value.ptr())) { + // Is passed value a list + } else if (PyList_Check(value.ptr())) { bp::list vl = bp::extract(value); uint32_t vlen = len(vl); @@ -1445,18 +1480,18 @@ void rim::Block::setFloatPy(bp::object& value, rim::Variable* var, int32_t index setFloat(tmp, var, index + x); } - } - // Passed scalar numpy value - else if (PyArray_CheckScalar(value.ptr())) { + // Passed scalar numpy value + } else if (PyArray_CheckScalar(value.ptr())) { if (PyArray_DescrFromScalar(value.ptr())->type_num == NPY_FLOAT32) { float val; PyArray_ScalarAsCtype(value.ptr(), &val); setFloat(val, var, index); - } else + } else { throw(rogue::GeneralError::create("Block::setFloatPy", "Failed to extract value for %s.", var->name_.c_str())); + } } else { bp::extract tmp(value); @@ -1486,9 +1521,8 @@ bp::object rim::Block::getFloatPy(rim::Variable* var, int32_t index) { boost::python::handle<> handle(obj); ret = bp::object(handle); - } - else { + } else { PyObject* val = Py_BuildValue("f", getFloat(var, index)); if (val == NULL) throw(rogue::GeneralError::create("Block::getFloatPy", "Failed to generate Float")); @@ -1512,14 +1546,14 @@ void rim::Block::setFloat(const float& val, rim::Variable* var, int32_t index) { var->minValue_, var->maxValue_)); - setBytes((uint8_t*)&val, var, index); + setBytes(reinterpret_cast(const_cast(&val)), var, index); } // Get data using float float rim::Block::getFloat(rim::Variable* var, int32_t index) { float tmp = 0; - getBytes((uint8_t*)&tmp, var, index); + getBytes(reinterpret_cast(&tmp), var, index); return tmp; } @@ -1561,15 +1595,14 @@ void rim::Block::setDoublePy(bp::object& value, rim::Variable* var, int32_t inde if (PyArray_TYPE(arr) == NPY_FLOAT64) { double* src = reinterpret_cast(PyArray_DATA(arr)); for (x = 0; x < dims[0]; x++) setDouble(src[x], var, index + x); - } else + } else { throw(rogue::GeneralError::create("Block::setFLoatPy", "Passed nparray is not of type (double) for %s", var->name_.c_str())); + } - } - - // Is passed value a list - else if (PyList_Check(value.ptr())) { + // Is passed value a list + } else if (PyList_Check(value.ptr())) { bp::list vl = bp::extract(value); uint32_t vlen = len(vl); @@ -1592,18 +1625,18 @@ void rim::Block::setDoublePy(bp::object& value, rim::Variable* var, int32_t inde setDouble(tmp, var, index + x); } - } - // Passed scalar numpy value - else if (PyArray_CheckScalar(value.ptr())) { + // Passed scalar numpy value + } else if (PyArray_CheckScalar(value.ptr())) { if (PyArray_DescrFromScalar(value.ptr())->type_num == NPY_FLOAT64) { double val; PyArray_ScalarAsCtype(value.ptr(), &val); setDouble(val, var, index); - } else + } else { throw(rogue::GeneralError::create("Block::setDoublePy", "Failed to extract value for %s.", var->name_.c_str())); + } } else { bp::extract tmp(value); @@ -1633,9 +1666,8 @@ bp::object rim::Block::getDoublePy(rim::Variable* var, int32_t index) { boost::python::handle<> handle(obj); ret = bp::object(handle); - } - else { + } else { PyObject* val = Py_BuildValue("d", getDouble(var, index)); if (val == NULL) throw(rogue::GeneralError::create("Block::getDoublePy", "Failed to generate Double")); @@ -1659,14 +1691,14 @@ void rim::Block::setDouble(const double& val, rim::Variable* var, int32_t index) var->minValue_, var->maxValue_)); - setBytes((uint8_t*)&val, var, index); + setBytes(reinterpret_cast(const_cast(&val)), var, index); } // Get data using double double rim::Block::getDouble(rim::Variable* var, int32_t index) { double tmp = 0; - getBytes((uint8_t*)&tmp, var, index); + getBytes(reinterpret_cast(&tmp), var, index); return tmp; } @@ -1708,15 +1740,14 @@ void rim::Block::setFixedPy(bp::object& value, rim::Variable* var, int32_t index if (PyArray_TYPE(arr) == NPY_FLOAT64) { double* src = reinterpret_cast(PyArray_DATA(arr)); for (x = 0; x < dims[0]; x++) setFixed(src[x], var, index + x); - } else + } else { throw(rogue::GeneralError::create("Block::setFixedPy", "Passed nparray is not of type (double) for %s", var->name_.c_str())); + } - } - - // Is passed value a list - else if (PyList_Check(value.ptr())) { + // Is passed value a list + } else if (PyList_Check(value.ptr())) { bp::list vl = bp::extract(value); uint32_t vlen = len(vl); @@ -1739,18 +1770,18 @@ void rim::Block::setFixedPy(bp::object& value, rim::Variable* var, int32_t index setFixed(tmp, var, index + x); } - } - // Passed scalar numpy value - else if (PyArray_CheckScalar(value.ptr())) { + // Passed scalar numpy value + } else if (PyArray_CheckScalar(value.ptr())) { if (PyArray_DescrFromScalar(value.ptr())->type_num == NPY_FLOAT64) { double val; PyArray_ScalarAsCtype(value.ptr(), &val); setFixed(val, var, index); - } else + } else { throw(rogue::GeneralError::create("Block::setFixedPy", "Failed to extract value for %s.", var->name_.c_str())); + } } else { bp::extract tmp(value); @@ -1780,9 +1811,8 @@ bp::object rim::Block::getFixedPy(rim::Variable* var, int32_t index) { boost::python::handle<> handle(obj); ret = bp::object(handle); - } - else { + } else { PyObject* val = Py_BuildValue("d", getFixed(var, index)); if (val == NULL) throw(rogue::GeneralError::create("Block::getFixedPy", "Failed to generate Fixed")); @@ -1810,8 +1840,10 @@ void rim::Block::setFixed(const double& val, rim::Variable* var, int32_t index) int64_t fPoint = (int64_t)round(val * pow(2, var->binPoint_)); // Check for positive edge case uint64_t mask = 1 << (var->valueBits_ - 1); - if (val > 0 && ((fPoint & mask) != 0)) { fPoint -= 1; } - setBytes((uint8_t*)&fPoint, var, index); + if (val > 0 && ((fPoint & mask) != 0)) { + fPoint -= 1; + } + setBytes(reinterpret_cast(&fPoint), var, index); } // Get data using fixed point @@ -1819,12 +1851,14 @@ double rim::Block::getFixed(rim::Variable* var, int32_t index) { int64_t fPoint = 0; double tmp; - getBytes((uint8_t*)&fPoint, var, index); + getBytes(reinterpret_cast(&fPoint), var, index); // Do two-complement if negative - if ((fPoint & (1 << (var->valueBits_ - 1))) != 0) { fPoint = fPoint - (1 << var->valueBits_); } + if ((fPoint & (1 << (var->valueBits_ - 1))) != 0) { + fPoint = fPoint - (1 << var->valueBits_); + } // Convert to float - tmp = (double)fPoint; + tmp = static_cast(fPoint); tmp = tmp / pow(2, var->binPoint_); return tmp; } @@ -1860,7 +1894,7 @@ void rim::Block::rateTest() { gettimeofday(&etime, NULL); timersub(&etime, &stime, &dtime); - durr = dtime.tv_sec + (float)dtime.tv_usec / 1.0e6; + durr = dtime.tv_sec + static_cast(dtime.tv_usec) / 1.0e6; rate = count / durr; printf("\nBlock c++ raw: Read %" PRIu64 " times in %f seconds. Rate = %f\n", count, durr, rate); @@ -1868,13 +1902,13 @@ void rim::Block::rateTest() { gettimeofday(&stime, NULL); waitTransaction(0); for (x = 0; x < count; ++x) { - reqTransaction(0, 4, (uint8_t*)&count, rim::Write); + reqTransaction(0, 4, reinterpret_cast(&count), rim::Write); waitTransaction(0); } gettimeofday(&etime, NULL); timersub(&etime, &stime, &dtime); - durr = dtime.tv_sec + (float)dtime.tv_usec / 1.0e6; + durr = dtime.tv_sec + static_cast(dtime.tv_usec) / 1.0e6; rate = count / durr; printf("\nBlock c++ raw: Wrote %" PRIu64 " times in %f seconds. Rate = %f\n", count, durr, rate); diff --git a/src/rogue/interfaces/memory/CMakeLists.txt b/src/rogue/interfaces/memory/CMakeLists.txt index b213e434c..d1b18961e 100644 --- a/src/rogue/interfaces/memory/CMakeLists.txt +++ b/src/rogue/interfaces/memory/CMakeLists.txt @@ -1,8 +1,5 @@ # ---------------------------------------------------------------------------- -# Title : ROGUE CMAKE Control -# ---------------------------------------------------------------------------- -# File : src/rogue/interfaces/memory/CMakeLists.txt -# Created : 2018-02-27 +# Company : SLAC National Accelerator Laboratory # ---------------------------------------------------------------------------- # This file is part of the rogue software package. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/src/rogue/interfaces/memory/Emulate.cpp b/src/rogue/interfaces/memory/Emulate.cpp index e873d2304..0cdce91d9 100644 --- a/src/rogue/interfaces/memory/Emulate.cpp +++ b/src/rogue/interfaces/memory/Emulate.cpp @@ -1,8 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Memory slave emulator * ---------------------------------------------------------------------------- - * File : Emulator.pp + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * A memory space emulator. Allows user to test a Rogue tree without real hardware. @@ -35,7 +33,7 @@ namespace rim = rogue::interfaces::memory; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -46,7 +44,11 @@ rim::EmulatePtr rim::Emulate::create(uint32_t min, uint32_t max) { } //! Create an block -rim::Emulate::Emulate(uint32_t min, uint32_t max) : Slave(min, max) {} +rim::Emulate::Emulate(uint32_t min, uint32_t max) : Slave(min, max) { + totAlloc_ = 0; + totSize_ = 0; + log_ = rogue::Logging::create("memory.Emulate"); +} //! Destroy a block rim::Emulate::~Emulate() { @@ -82,17 +84,21 @@ void rim::Emulate::doTransaction(rim::TransactionPtr tran) { size -= size4k; addr += size4k; - if (memMap_.find(addr4k) == memMap_.end()) memMap_.insert(std::make_pair(addr4k, (uint8_t*)malloc(0x1000))); + if (memMap_.find(addr4k) == memMap_.end()) { + memMap_.insert(std::make_pair(addr4k, reinterpret_cast(malloc(0x1000)))); + totSize_ += 0x1000; + totAlloc_++; + log_->debug("Allocating block at 0x%x. Total Blocks %i, Total Size = %i", addr4k, totAlloc_, totSize_); + } // Write or post if (tran->type() == rogue::interfaces::memory::Write || tran->type() == rogue::interfaces::memory::Post) { // printf("Write data to 4k=0x%" PRIx64 ", offset=0x%" PRIx64 ", size=%" PRIu64 "\n", addr4k, off4k, // size4k); memcpy(memMap_[addr4k] + off4k, ptr, size4k); - } - // Read or verify - else { + // Read or verify + } else { // printf("Read data from 4k=0x%" PRIx64 ", offset=0x%" PRIx64 ", size=%" PRIu64 "\n", addr4k, off4k, // size4k); memcpy(ptr, memMap_[addr4k] + off4k, size4k); diff --git a/src/rogue/interfaces/memory/Hub.cpp b/src/rogue/interfaces/memory/Hub.cpp index 1f572c318..742f15cc5 100644 --- a/src/rogue/interfaces/memory/Hub.cpp +++ b/src/rogue/interfaces/memory/Hub.cpp @@ -1,11 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Hub * ---------------------------------------------------------------------------- - * File : Hub.cpp - * Author : Ryan Herbst, rherbst@slac.stanford.edu - * Created : 2016-09-20 - * Last update: 2016-09-20 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * A memory interface hub. Accepts requests from multiple masters and forwards @@ -37,7 +32,7 @@ namespace rim = rogue::interfaces::memory; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -64,7 +59,7 @@ uint64_t rim::Hub::getOffset() { //! Get address uint64_t rim::Hub::getAddress() { - return (reqAddress() | offset_); + return (reqAddress() + offset_); } //! Return id to requesting master @@ -105,7 +100,7 @@ uint64_t rim::Hub::doAddress() { if (root_) return (0); else - return (reqAddress() | offset_); + return (reqAddress() + offset_); } //! Post a transaction. Master will call this method with the access attributes. @@ -113,7 +108,7 @@ void rim::Hub::doTransaction(rim::TransactionPtr tran) { uint32_t maxAccess = getSlave()->doMaxAccess(); // Adjust address - tran->address_ |= offset_; + tran->address_ += offset_; // Split into smaller transactions if necessary if (tran->size() > maxAccess) { @@ -125,7 +120,7 @@ void rim::Hub::doTransaction(rim::TransactionPtr tran) { for (unsigned int i = 0; i < numberOfTransactions; ++i) { rim::TransactionPtr subTran = tran->createSubTransaction(); - subTran->iter_ = (uint8_t*)(tran->begin() + i * maxAccess); + subTran->iter_ = reinterpret_cast(tran->begin() + i * maxAccess); if (tran->size() >= ((i + 1) * maxAccess)) { subTran->size_ = maxAccess; } else { @@ -185,7 +180,9 @@ void rim::HubWrap::doTransaction(rim::TransactionPtr transaction) { try { pb(transaction); return; - } catch (...) { PyErr_Print(); } + } catch (...) { + PyErr_Print(); + } } } rim::Hub::doTransaction(transaction); diff --git a/src/rogue/interfaces/memory/Master.cpp b/src/rogue/interfaces/memory/Master.cpp index 33ef620f4..e4c9e84ac 100644 --- a/src/rogue/interfaces/memory/Master.cpp +++ b/src/rogue/interfaces/memory/Master.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Memory Master * ---------------------------------------------------------------------------- - * File : Master.cpp - * Created : 2016-09-20 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Memory master interface. @@ -38,7 +35,7 @@ namespace rim = rogue::interfaces::memory; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -155,7 +152,7 @@ void rim::Master::setTimeout(uint64_t timeout) { uint32_t rim::Master::reqTransaction(uint64_t address, uint32_t size, void* data, uint32_t type) { rim::TransactionPtr tran = rim::Transaction::create(sumTime_); - tran->iter_ = (uint8_t*)data; + tran->iter_ = reinterpret_cast(data); tran->size_ = size; tran->address_ = address; tran->type_ = type; @@ -197,7 +194,7 @@ uint32_t rim::Master::reqTransactionPy(uint64_t address, } tran->pyValid_ = true; - tran->iter_ = ((uint8_t*)tran->pyBuf_.buf) + offset; + tran->iter_ = reinterpret_cast(tran->pyBuf_.buf) + offset; tran->type_ = type; tran->address_ = address; @@ -247,8 +244,9 @@ void rim::Master::waitTransaction(uint32_t id) { if (it != tranMap_.end()) { tran = it->second; tranMap_.erase(it); - } else + } else { break; + } } // Outside of lock @@ -280,10 +278,9 @@ void rim::Master::copyBits(uint8_t* dstData, uint32_t dstLsb, uint8_t* srcData, dstByte += bytes; srcByte += bytes; rem -= (bytes * 8); - } - // Not aligned - else { + // Not aligned + } else { dstData[dstByte] &= ((0x1 << dstBit) ^ 0xFF); dstData[dstByte] |= ((srcData[srcByte] >> srcBit) & 0x1) << dstBit; srcByte += (++srcBit / 8); @@ -335,7 +332,7 @@ void rim::Master::copyBitsPy(boost::python::object dst, srcBuf.len * 8)); } - copyBits((uint8_t*)dstBuf.buf, dstLsb, (uint8_t*)srcBuf.buf, srcLsb, size); + copyBits(reinterpret_cast(dstBuf.buf), dstLsb, reinterpret_cast(srcBuf.buf), srcLsb, size); PyBuffer_Release(&srcBuf); PyBuffer_Release(&dstBuf); @@ -362,10 +359,9 @@ void rim::Master::setBits(uint8_t* dstData, uint32_t lsb, uint32_t size) { memset(&(dstData[dstByte]), 0xFF, bytes); dstByte += bytes; rem -= (bytes * 8); - } - // Not aligned - else { + // Not aligned + } else { dstData[dstByte] |= (0x1 << dstBit); dstByte += (++dstBit / 8); dstBit %= 8; @@ -393,7 +389,7 @@ void rim::Master::setBitsPy(boost::python::object dst, uint32_t lsb, uint32_t si dstBuf.len * 8)); } - setBits((uint8_t*)dstBuf.buf, lsb, size); + setBits(reinterpret_cast(dstBuf.buf), lsb, size); PyBuffer_Release(&dstBuf); } @@ -421,10 +417,9 @@ bool rim::Master::anyBits(uint8_t* dstData, uint32_t lsb, uint32_t size) { if (dstData[dstByte] != 0) ret = true; dstByte += 1; rem -= 8; - } - // Not aligned - else { + // Not aligned + } else { if ((dstData[dstByte] & (0x1 << dstBit)) != 0) ret = true; dstByte += (++dstBit / 8); dstBit %= 8; @@ -455,7 +450,7 @@ bool rim::Master::anyBitsPy(boost::python::object dst, uint32_t lsb, uint32_t si dstBuf.len * 8)); } - ret = anyBits((uint8_t*)dstBuf.buf, lsb, size); + ret = anyBits(reinterpret_cast(dstBuf.buf), lsb, size); PyBuffer_Release(&dstBuf); return ret; @@ -468,10 +463,11 @@ void rim::Master::rshiftPy(bp::object p) { boost::python::extract get_slave(p); // Test extraction - if (get_slave.check()) slv = get_slave(); + if (get_slave.check()) { + slv = get_slave(); - // Otherwise look for indirect call - else if (PyObject_HasAttrString(p.ptr(), "_getMemorySlave")) { + // Otherwise look for indirect call + } else if (PyObject_HasAttrString(p.ptr(), "_getMemorySlave")) { // Attempt to convert returned object to slave pointer boost::python::extract get_slave(p.attr("_getMemorySlave")()); diff --git a/src/rogue/interfaces/memory/Slave.cpp b/src/rogue/interfaces/memory/Slave.cpp index 5754ae993..709e7e709 100644 --- a/src/rogue/interfaces/memory/Slave.cpp +++ b/src/rogue/interfaces/memory/Slave.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Memory Slave * ---------------------------------------------------------------------------- - * File : Slave.cpp - * Created : 2016-09-20 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Memory slave interface. @@ -31,7 +28,7 @@ #include "rogue/interfaces/memory/Transaction.h" #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -102,7 +99,9 @@ rim::TransactionPtr rim::Slave::getTransaction(uint32_t index) { // Clean up if we found an expired transaction, overtime this will clean up // the list, even if it deletes one expired transaction per call - if (exp != tranMap_.end()) { tranMap_.erase(exp); } + if (exp != tranMap_.end()) { + tranMap_.erase(exp); + } } return ret; } @@ -190,7 +189,9 @@ uint32_t rim::SlaveWrap::doMinAccess() { if (boost::python::override pb = this->get_override("_doMinAccess")) { try { return (pb()); - } catch (...) { PyErr_Print(); } + } catch (...) { + PyErr_Print(); + } } } return (rim::Slave::doMinAccess()); @@ -209,7 +210,9 @@ uint32_t rim::SlaveWrap::doMaxAccess() { if (boost::python::override pb = this->get_override("_doMaxAccess")) { try { return (pb()); - } catch (...) { PyErr_Print(); } + } catch (...) { + PyErr_Print(); + } } } return (rim::Slave::doMaxAccess()); @@ -228,7 +231,9 @@ uint64_t rim::SlaveWrap::doAddress() { if (boost::python::override pb = this->get_override("_doAddress")) { try { return (pb()); - } catch (...) { PyErr_Print(); } + } catch (...) { + PyErr_Print(); + } } } return (rim::Slave::doAddress()); @@ -248,7 +253,9 @@ void rim::SlaveWrap::doTransaction(rim::TransactionPtr transaction) { try { pb(transaction); return; - } catch (...) { PyErr_Print(); } + } catch (...) { + PyErr_Print(); + } } } rim::Slave::doTransaction(transaction); @@ -266,10 +273,11 @@ void rim::Slave::lshiftPy(boost::python::object p) { boost::python::extract get_master(p); // Test extraction - if (get_master.check()) mst = get_master(); + if (get_master.check()) { + mst = get_master(); - // Otherwise look for indirect call - else if (PyObject_HasAttrString(p.ptr(), "_getMemoryMaster")) { + // Otherwise look for indirect call + } else if (PyObject_HasAttrString(p.ptr(), "_getMemoryMaster")) { // Attempt to convert returned object to master pointer boost::python::extract get_master(p.attr("_getMemoryMaster")()); diff --git a/src/rogue/interfaces/memory/TcpClient.cpp b/src/rogue/interfaces/memory/TcpClient.cpp index 682a3865d..9d451024f 100644 --- a/src/rogue/interfaces/memory/TcpClient.cpp +++ b/src/rogue/interfaces/memory/TcpClient.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Memory Client Network Bridge * ---------------------------------------------------------------------------- - * File : TcpClient.cpp - * Created : 2019-01-30 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Memory Client Network Bridge @@ -38,7 +35,7 @@ namespace rim = rogue::interfaces::memory; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -75,8 +72,8 @@ rim::TcpClient::TcpClient(std::string addr, uint16_t port) : rim::Slave(4, 0xFFF if (zmq_setsockopt(this->zmqReq_, ZMQ_IMMEDIATE, &opt, sizeof(int32_t)) != 0) throw(rogue::GeneralError("memory::TcpClient::TcpClient", "Failed to set socket immediate")); - this->respAddr_.append(std::to_string(static_cast(port + 1))); - this->reqAddr_.append(std::to_string(static_cast(port))); + this->respAddr_.append(std::to_string(static_cast(port + 1))); + this->reqAddr_.append(std::to_string(static_cast(port))); this->bridgeLog_->debug("Creating response client port: %s", this->respAddr_.c_str()); @@ -175,11 +172,11 @@ void rim::TcpClient::doTransaction(rim::TransactionPtr tran) { msgCnt = 5; zmq_msg_init_size(&(msg[4]), size); std::memcpy(zmq_msg_data(&(msg[4])), tran->begin(), size); - } - // Read transaction - else + // Read transaction + } else { msgCnt = 4; + } bridgeLog_->debug("Requested transaction id=%" PRIu32 ", addr=0x%" PRIx64 ", size=%" PRIu32 ", type=%" PRIu32 ", cnt=%" PRIu32 ", port: %s", @@ -237,8 +234,9 @@ void rim::TcpClient::runThread() { more = 0; moreSize = 8; zmq_getsockopt(this->zmqResp_, ZMQ_RCVMORE, &more, &moreSize); - } else + } else { more = 1; + } } while (threadEn_ && more); // Proper message received @@ -258,7 +256,7 @@ void rim::TcpClient::runThread() { std::memcpy(&type, zmq_msg_data(&(msg[3])), 4); memset(result, 0, 1000); - std::strncpy(result, (char*)zmq_msg_data(&(msg[5])), zmq_msg_size(&(msg[5]))); + std::strncpy(result, reinterpret_cast(zmq_msg_data(&(msg[5]))), zmq_msg_size(&(msg[5]))); // Find Transaction if ((tran = getTransaction(id)) == NULL) { diff --git a/src/rogue/interfaces/memory/TcpServer.cpp b/src/rogue/interfaces/memory/TcpServer.cpp index 8a96ed785..77eb287a7 100644 --- a/src/rogue/interfaces/memory/TcpServer.cpp +++ b/src/rogue/interfaces/memory/TcpServer.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Memory Server Network Bridge * ---------------------------------------------------------------------------- - * File : TcpServer.cpp - * Created : 2019-01-30 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Memory Server Network Bridge @@ -36,7 +33,7 @@ namespace rim = rogue::interfaces::memory; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -68,8 +65,8 @@ rim::TcpServer::TcpServer(std::string addr, uint16_t port) { this->zmqResp_ = zmq_socket(this->zmqCtx_, ZMQ_PUSH); this->zmqReq_ = zmq_socket(this->zmqCtx_, ZMQ_PULL); - this->respAddr_.append(std::to_string(static_cast(port + 1))); - this->reqAddr_.append(std::to_string(static_cast(port))); + this->respAddr_.append(std::to_string(static_cast(port + 1))); + this->reqAddr_.append(std::to_string(static_cast(port))); this->bridgeLog_->debug("Creating response client port: %s", this->respAddr_.c_str()); @@ -162,8 +159,9 @@ void rim::TcpServer::runThread() { more = 0; moreSize = 8; zmq_getsockopt(this->zmqReq_, ZMQ_RCVMORE, &more, &moreSize); - } else + } else { more = 1; + } } while (threadEn_ && more); // Proper message received @@ -189,11 +187,12 @@ void rim::TcpServer::runThread() { for (x = 0; x < msgCnt; x++) zmq_msg_close(&(msg[x])); continue; // while (1) } - } else + } else { zmq_msg_init_size(&(msg[4]), size); + } // Data pointer - data = (uint8_t*)zmq_msg_data(&(msg[4])); + data = reinterpret_cast(zmq_msg_data(&(msg[4]))); bridgeLog_->debug("Starting transaction id=%" PRIu32 ", addr=0x%" PRIx64 ", size=%" PRIu32 ", type=%" PRIu32, @@ -223,8 +222,9 @@ void rim::TcpServer::runThread() { // Send message for (x = 0; x < 6; x++) zmq_sendmsg(this->zmqResp_, &(msg[x]), (x == 5) ? 0 : ZMQ_SNDMORE); - } else + } else { for (x = 0; x < msgCnt; x++) zmq_msg_close(&(msg[x])); + } } } diff --git a/src/rogue/interfaces/memory/Transaction.cpp b/src/rogue/interfaces/memory/Transaction.cpp index 872964269..f5962d1b2 100644 --- a/src/rogue/interfaces/memory/Transaction.cpp +++ b/src/rogue/interfaces/memory/Transaction.cpp @@ -1,11 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Memory Transaction * ---------------------------------------------------------------------------- - * File : Transaction.cpp - * Author : Ryan Herbst, rherbst@slac.stanford.edu - * Created : 2016-09-20 - * Last update: 2016-09-20 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Memory master interface. @@ -39,7 +34,7 @@ namespace rim = rogue::interfaces::memory; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -112,7 +107,9 @@ rim::TransactionLockPtr rim::Transaction::lock() { //! Get expired state bool rim::Transaction::expired() { bool done = false; - if (isSubTransaction_) { done = parentTransaction_.expired(); } + if (isSubTransaction_) { + done = parentTransaction_.expired(); + } return done || (iter_ == NULL || done_); } @@ -174,7 +171,7 @@ void rim::Transaction::done() { parentTran->subTranMap_.erase(id_); // If this is the last sub-transaction, notify parent transaction it is all done - if (parentTran->subTranMap_.empty() and parentTran->doneCreatingSubTransactions_) parentTran->done(); + if (parentTran->subTranMap_.empty() && parentTran->doneCreatingSubTransactions_) parentTran->done(); } } } @@ -203,7 +200,7 @@ void rim::Transaction::errorStr(std::string error) { parentTran->subTranMap_.erase(id_); // If this is the last sub-transaction, notify parent transaction it is all done - if (parentTran->subTranMap_.empty() and parentTran->doneCreatingSubTransactions_) + if (parentTran->subTranMap_.empty() && parentTran->doneCreatingSubTransactions_) parentTran->error("Transaction error. Subtransaction %" PRIu32 " failed with error: %s.\n", id_, error.c_str()); @@ -217,7 +214,7 @@ void rim::Transaction::error(const char* fmt, ...) { char buffer[10000]; va_start(args, fmt); - vsnprintf(buffer, 10000, fmt, args); + vsnprintf(buffer, sizeof(buffer), fmt, args); va_end(args); errorStr(std::string(buffer)); @@ -241,8 +238,9 @@ std::string rim::Transaction::wait() { id_, address_, size_); - } else + } else { cond_.wait_for(lock, std::chrono::microseconds(1000)); + } } // Reset @@ -270,9 +268,9 @@ void rim::Transaction::refreshTimer(rim::TransactionPtr ref) { if (ref == NULL || timercmp(&startTime_, &(ref->startTime_), >=)) { timeradd(&currTime, &timeout_, &endTime_); - if (warnTime_.tv_sec == 0 && warnTime_.tv_usec == 0) + if (warnTime_.tv_sec == 0 && warnTime_.tv_usec == 0) { warnTime_ = endTime_; - else if (timercmp(&warnTime_, &currTime, >=)) { + } else if (timercmp(&warnTime_, &currTime, >=)) { log_->warning("Transaction timer refresh! Possible slow link! type=%" PRIu32 " id=%" PRIu32 ", address=0x%016" PRIx64 ", size=%" PRIu32, type_, @@ -317,7 +315,7 @@ void rim::Transaction::setData(boost::python::object p, uint32_t offset) { size_)); } - std::memcpy(begin() + offset, (uint8_t*)pyBuf.buf, count); + std::memcpy(begin() + offset, reinterpret_cast(pyBuf.buf), count); PyBuffer_Release(&pyBuf); } @@ -340,7 +338,7 @@ void rim::Transaction::getData(boost::python::object p, uint32_t offset) { size_)); } - std::memcpy((uint8_t*)pyBuf.buf, begin() + offset, count); + std::memcpy(reinterpret_cast(pyBuf.buf), begin() + offset, count); PyBuffer_Release(&pyBuf); } diff --git a/src/rogue/interfaces/memory/TransactionLock.cpp b/src/rogue/interfaces/memory/TransactionLock.cpp index 228ea2339..67706fe4c 100644 --- a/src/rogue/interfaces/memory/TransactionLock.cpp +++ b/src/rogue/interfaces/memory/TransactionLock.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Memory Transaction Lock * ---------------------------------------------------------------------------- - * File : TransactionLock.cpp - * Created : 2018-03-16 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Memory Transaction lock @@ -29,7 +26,7 @@ namespace rim = rogue::interfaces::memory; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif diff --git a/src/rogue/interfaces/memory/Variable.cpp b/src/rogue/interfaces/memory/Variable.cpp index 01934be9b..3bb928625 100644 --- a/src/rogue/interfaces/memory/Variable.cpp +++ b/src/rogue/interfaces/memory/Variable.cpp @@ -1,8 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Memory Variable * ---------------------------------------------------------------------------- - * File : Variable.cpp + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Interface between RemoteVariables and lower level memory transactions. @@ -38,73 +36,70 @@ namespace rim = rogue::interfaces::memory; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif //! Class factory which returns a pointer to a Variable (VariablePtr) -rim::VariablePtr rim::Variable::create( - std::string name, - std::string mode, - double minimum, - double maximum, - uint64_t offset, - std::vector bitOffset, - std::vector bitSize, - bool overlapEn, - bool verify, - bool bulkOpEn, - bool updateNotify, - uint32_t modelId, - bool byteReverse, - bool bitReverse, - uint32_t binPoint, - uint32_t numValues, - uint32_t valueBits, - uint32_t valueStride, - uint32_t retryCount) { - rim::VariablePtr v = std::make_shared( - name, - mode, - minimum, - maximum, - offset, - bitOffset, - bitSize, - overlapEn, - verify, - bulkOpEn, - updateNotify, - modelId, - byteReverse, - bitReverse, - binPoint, - numValues, - valueBits, - valueStride, - retryCount); +rim::VariablePtr rim::Variable::create(std::string name, + std::string mode, + double minimum, + double maximum, + uint64_t offset, + std::vector bitOffset, + std::vector bitSize, + bool overlapEn, + bool verify, + bool bulkOpEn, + bool updateNotify, + uint32_t modelId, + bool byteReverse, + bool bitReverse, + uint32_t binPoint, + uint32_t numValues, + uint32_t valueBits, + uint32_t valueStride, + uint32_t retryCount) { + rim::VariablePtr v = std::make_shared(name, + mode, + minimum, + maximum, + offset, + bitOffset, + bitSize, + overlapEn, + verify, + bulkOpEn, + updateNotify, + modelId, + byteReverse, + bitReverse, + binPoint, + numValues, + valueBits, + valueStride, + retryCount); return (v); } // Setup class for use in python void rim::Variable::setup_python() { #ifndef NO_PYTHON - bp::class_( - "Variable", - bp::init()) + bp::class_("Variable", + bp::init()) .def("_varBytes", &rim::Variable::varBytes) .def("_offset", &rim::Variable::offset) .def("_shiftOffsetDown", &rim::Variable::shiftOffsetDown) @@ -170,64 +165,59 @@ rim::Variable::Variable(std::string name, valueStride_ = valueStride; retryCount_ = retryCount; - // Compute bit total - bitTotal_ = bitSize_[0]; - for (x = 1; x < bitSize_.size(); x++) bitTotal_ += bitSize_[x]; + // Not a list variable + if (numValues_ == 0) { + // Compute bit total + bitTotal_ = bitSize_[0]; + for (x = 1; x < bitSize_.size(); x++) bitTotal_ += bitSize_[x]; - // Compute rounded up byte size - byteSize_ = (int)std::ceil((float)bitTotal_ / 8.0); + // Compute rounded up byte size + byteSize_ = static_cast(std::ceil(static_cast(bitTotal_) / 8.0)); - // Compute total bit range of accessed bits - varBytes_ = (int)std::ceil((float)(bitOffset_[bitOffset_.size() - 1] + bitSize_[bitSize_.size() - 1]) / 8.0); + lowTranByte_ = reinterpret_cast(malloc(sizeof(uint32_t))); + highTranByte_ = reinterpret_cast(malloc(sizeof(uint32_t))); - // Compute the lowest byte - lowTranByte_ = (int)std::floor((float)bitOffset_[0] / 8.0); + // Init remaining fields + valueBytes_ = byteSize_; + valueBits_ = bitTotal_; + valueStride_ = bitTotal_; - // Compute the highest byte - highTranByte_ = varBytes_ - 1; + // List variables + } else { + // Compute bit total + bitTotal_ = bitSize_[0]; - // Init stale - stale_ = false; - staleLowByte_ = lowTranByte_; - staleHighByte_ = highTranByte_; + // Compute rounded up byte size + byteSize_ = static_cast(std::ceil(static_cast(bitTotal_) / 8.0)); - // Variable can use fast copies - fastByte_ = NULL; + // Compute total bit range of accessed bits + valueBytes_ = static_cast(std::ceil(static_cast(valueBits_) / 8.0)); - if (numValues_ == 0) { - valueBits_ = bitTotal_; - valueStride_ = bitTotal_; - valueBytes_ = byteSize_; - listLowTranByte_ = NULL; - listHighTranByte_ = NULL; - } else { - valueBytes_ = (uint32_t)std::ceil((float)(valueBits_) / 8.0); - listLowTranByte_ = (uint32_t*)malloc(numValues_ * sizeof(uint32_t)); - listHighTranByte_ = (uint32_t*)malloc(numValues_ * sizeof(uint32_t)); - - for (x = 0; x < numValues_; x++) { - listLowTranByte_[x] = (uint32_t)std::floor(((float)bitOffset_[0] + (float)x * (float)valueStride_) / 8.0); - listHighTranByte_[x] = - (uint32_t)std::ceil(((float)bitOffset_[0] + (float)(x + 1) * (float)valueStride_) / 8.0) - 1; - } + // High and low byte tracking + lowTranByte_ = reinterpret_cast(malloc(numValues_ * sizeof(uint32_t))); + highTranByte_ = reinterpret_cast(malloc(numValues_ * sizeof(uint32_t))); } + // Byte array for fast copies + fastByte_ = NULL; + + // Determine if fast byte copies can be utilized // Bit offset vector must have one entry, the offset must be byte aligned and the total number of bits must be byte // aligned if ((bitOffset_.size() == 1) && (bitOffset_[0] % 8 == 0) && (bitSize_[0] % 8 == 0)) { // Standard variable if (numValues_ == 0) { - fastByte_ = (uint32_t*)malloc(sizeof(uint32_t)); - fastByte_[0] = bitOffset_[0] / 8; - } - - // List variable - else if ((valueBits_ % 8) == 0 && (valueStride_ % 8) == 0) { - fastByte_ = (uint32_t*)malloc(numValues_ * sizeof(uint32_t)); + fastByte_ = reinterpret_cast(malloc(sizeof(uint32_t))); - for (x = 0; x < numValues_; x++) fastByte_[x] = (bitOffset_[0] + (valueStride_ * x)) / 8; + // List variable + } else if ((valueBits_ % 8) == 0 && (valueStride_ % 8) == 0) { + fastByte_ = reinterpret_cast(malloc(numValues_ * sizeof(uint32_t))); } } + stale_ = false; + + // Call aligning function to init values + shiftOffsetDown(0, 1); // Custom data is NULL for now customData_ = NULL; @@ -449,8 +439,8 @@ rim::Variable::Variable(std::string name, // Destroy the variable rim::Variable::~Variable() { - if (listLowTranByte_ != NULL) free(listLowTranByte_); - if (listHighTranByte_ != NULL) free(listHighTranByte_); + if (lowTranByte_ != NULL) free(lowTranByte_); + if (highTranByte_ != NULL) free(highTranByte_); if (fastByte_ != NULL) free(fastByte_); } @@ -463,37 +453,56 @@ void rim::Variable::shiftOffsetDown(uint32_t shift, uint32_t minSize) { for (x = 0; x < bitOffset_.size(); x++) bitOffset_[x] += shift * 8; } - // Compute total bit range of accessed bits, aligned to min size - varBytes_ = (int)std::ceil((float)(bitOffset_[bitOffset_.size() - 1] + bitSize_[bitSize_.size() - 1]) / - ((float)minSize * 8.0)) * - minSize; - - // Compute the lowest byte, aligned to min access - lowTranByte_ = (int)std::floor((float)bitOffset_[0] / ((float)minSize * 8.0)) * minSize; + // Standard variable + if (numValues_ == 0) { + // Compute total bit range of accessed bytes + varBytes_ = static_cast(std::ceil( + static_cast(bitOffset_[bitOffset_.size() - 1] + bitSize_[bitSize_.size() - 1]) / + (static_cast(minSize) * 8.0))) * + minSize; + + // Compute the lowest byte, aligned to min access + lowTranByte_[0] = + static_cast(std::floor(static_cast(bitOffset_[0]) / (static_cast(minSize) * 8.0))) * + minSize; - // Compute the highest byte, aligned to min access - highTranByte_ = varBytes_ - 1; + // Compute the highest byte, aligned to min access + highTranByte_[0] = varBytes_ - 1; + staleHighByte_ = highTranByte_[0]; // List variable - for (x = 0; x < numValues_; x++) { - listLowTranByte_[x] = - (uint32_t)std::floor(((float)bitOffset_[0] + (float)x * (float)valueStride_) / ((float)minSize * 8.0)) * - minSize; - listHighTranByte_[x] = (uint32_t)std::ceil(((float)bitOffset_[0] + (float)(x + 1) * (float)valueStride_) / - ((float)minSize * 8.0)) * + } else { + for (x = 0; x < numValues_; x++) { + lowTranByte_[x] = + static_cast(std::floor( + (static_cast(bitOffset_[0]) + static_cast(x) * static_cast(valueStride_)) / + (static_cast(minSize) * 8.0))) * + minSize; + highTranByte_[x] = static_cast( + std::ceil((static_cast(bitOffset_[0]) + + static_cast(x) * static_cast(valueStride_) + valueBits_) / + (static_cast(minSize) * 8.0))) * minSize - 1; + } + + // Compute total bit range of accessed bytes + varBytes_ = highTranByte_[numValues_ - 1] + 1; + staleHighByte_ = highTranByte_[numValues_ - 1]; } // Adjust fast copy locations if (fastByte_ != NULL) { - if (numValues_ == 0) fastByte_[0] = bitOffset_[0] / 8; + if (numValues_ == 0) { + fastByte_[0] = bitOffset_[0] / 8; - // List variable - else { + // List variable + } else { for (x = 0; x < numValues_; x++) fastByte_[x] = (bitOffset_[0] + (valueStride_ * x)) / 8; } } + + staleLowByte_ = lowTranByte_[0]; } void rim::Variable::updatePath(std::string path) { @@ -611,7 +620,9 @@ void rim::VariableWrap::queueUpdate() { try { pb(); return; - } catch (...) { PyErr_Print(); } + } catch (...) { + PyErr_Print(); + } } } @@ -640,21 +651,25 @@ void rim::Variable::rateTest() { uint32_t ret; gettimeofday(&stime, NULL); - for (x = 0; x < count; ++x) { ret = getUInt(); } + for (x = 0; x < count; ++x) { + ret = getUInt(); + } gettimeofday(&etime, NULL); timersub(&etime, &stime, &dtime); - durr = dtime.tv_sec + (float)dtime.tv_usec / 1.0e6; + durr = dtime.tv_sec + static_cast(dtime.tv_usec) / 1.0e6; rate = count / durr; printf("\nVariable c++ get: Read %" PRIu64 " times in %f seconds. Rate = %f\n", count, durr, rate); gettimeofday(&stime, NULL); - for (x = 0; x < count; ++x) { setUInt(x); } + for (x = 0; x < count; ++x) { + setUInt(x); + } gettimeofday(&etime, NULL); timersub(&etime, &stime, &dtime); - durr = dtime.tv_sec + (float)dtime.tv_usec / 1.0e6; + durr = dtime.tv_sec + static_cast(dtime.tv_usec) / 1.0e6; rate = count / durr; printf("\nVariable c++ set: Wrote %" PRIu64 " times in %f seconds. Rate = %f\n", count, durr, rate); @@ -704,8 +719,9 @@ std::string rim::Variable::getDumpValue(bool read) { ret << "0x"; for (x = 0; x < valueBytes_; x++) ret << std::setfill('0') << std::setw(2) << std::hex << (uint32_t)byteData[x]; - } else + } else { ret << (block_->*getUInt_)(this, index); + } break; case rim::Int: @@ -714,8 +730,9 @@ std::string rim::Variable::getDumpValue(bool read) { ret << "0x"; for (x = 0; x < valueBytes_; x++) ret << std::setfill('0') << std::setw(2) << std::hex << (uint32_t)byteData[x]; - } else + } else { ret << (block_->*getInt_)(this, index); + } break; case rim::Bool: @@ -850,9 +867,9 @@ std::string rim::Variable::getString(int32_t index) { } void rim::Variable::getValue(std::string& retString, int32_t index) { - if (getString_ == NULL) + if (getString_ == NULL) { throw(rogue::GeneralError::create("Variable::getValue", "Wrong get type for variable %s", path_.c_str())); - else { + } else { block_->read(this, index); block_->getValue(this, retString, index); } diff --git a/src/rogue/interfaces/memory/module.cpp b/src/rogue/interfaces/memory/module.cpp index 5cb0f7d84..e83bf5027 100644 --- a/src/rogue/interfaces/memory/module.cpp +++ b/src/rogue/interfaces/memory/module.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module * ---------------------------------------------------------------------------- - * File : module.cpp - * Created : 2016-08-08 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/src/rogue/interfaces/module.cpp b/src/rogue/interfaces/module.cpp index 2d9192799..42003b546 100644 --- a/src/rogue/interfaces/module.cpp +++ b/src/rogue/interfaces/module.cpp @@ -1,11 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module * ---------------------------------------------------------------------------- - * File : module.cpp - * Author : Ryan Herbst, rherbst@slac.stanford.edu - * Created : 2016-08-08 - * Last update: 2016-08-08 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/src/rogue/interfaces/stream/Buffer.cpp b/src/rogue/interfaces/stream/Buffer.cpp index aec737b89..8608f8202 100644 --- a/src/rogue/interfaces/stream/Buffer.cpp +++ b/src/rogue/interfaces/stream/Buffer.cpp @@ -1,15 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : Stream Buffer Container * ---------------------------------------------------------------------------- - * File : Buffer.h - * Author : Ryan Herbst, rherbst@slac.stanford.edu - * Created : 2016-09-16 - * Last update: 2016-09-16 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Stream frame container - * Some concepts borrowed from CPSW by Till Straumann * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory @@ -48,7 +42,7 @@ ris::BufferPtr ris::Buffer::create(ris::PoolPtr source, void* data, uint32_t met */ ris::Buffer::Buffer(ris::PoolPtr source, void* data, uint32_t meta, uint32_t size, uint32_t alloc) { source_ = source; - data_ = (uint8_t*)data; + data_ = reinterpret_cast(data); meta_ = meta; rawSize_ = size; allocSize_ = alloc; diff --git a/src/rogue/interfaces/stream/CMakeLists.txt b/src/rogue/interfaces/stream/CMakeLists.txt index 22c5bf590..2d570e172 100644 --- a/src/rogue/interfaces/stream/CMakeLists.txt +++ b/src/rogue/interfaces/stream/CMakeLists.txt @@ -1,8 +1,5 @@ # ---------------------------------------------------------------------------- -# Title : ROGUE CMAKE Control -# ---------------------------------------------------------------------------- -# File : src/rogue/interfaces/stream/CMakeLists.txt -# Created : 2018-02-27 +# Company : SLAC National Accelerator Laboratory # ---------------------------------------------------------------------------- # This file is part of the rogue software package. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/src/rogue/interfaces/stream/Fifo.cpp b/src/rogue/interfaces/stream/Fifo.cpp index 175163c01..220093cdd 100644 --- a/src/rogue/interfaces/stream/Fifo.cpp +++ b/src/rogue/interfaces/stream/Fifo.cpp @@ -1,11 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : AXI Stream FIFO * ---------------------------------------------------------------------------- - * File : Fifo.cpp - * Author : Ryan Herbst - * Created : 02/02/2018 - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * AXI Stream FIFO *----------------------------------------------------------------------------- @@ -39,7 +35,7 @@ namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -92,7 +88,7 @@ ris::Fifo::~Fifo() { //! Return the number of elements in the Fifo std::size_t ris::Fifo::size() { return queue_.size(); -}; +} //! Return the number of dropped frames std::size_t ris::Fifo::dropCnt() const { @@ -121,9 +117,9 @@ void ris::Fifo::acceptFrame(ris::FramePtr frame) { ris::FrameLockPtr lock = frame->lock(); // Do we copy the frame? - if (noCopy_) + if (noCopy_) { nFrame = frame; - else { + } else { // Get size, adjust if trim is enabled size = frame->getPayload(); if (trimSize_ != 0 && trimSize_ < size) size = trimSize_; diff --git a/src/rogue/interfaces/stream/Filter.cpp b/src/rogue/interfaces/stream/Filter.cpp index e6b9dfebc..8755fe9a9 100644 --- a/src/rogue/interfaces/stream/Filter.cpp +++ b/src/rogue/interfaces/stream/Filter.cpp @@ -1,11 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : SLAC Register Protocol (SRP) Filter * ---------------------------------------------------------------------------- - * File : Filter.cpp - * Author : Ryan Herbst - * Created : 11/01/2018 - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * AXI Stream Filter *----------------------------------------------------------------------------- @@ -35,7 +31,7 @@ namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif diff --git a/src/rogue/interfaces/stream/Frame.cpp b/src/rogue/interfaces/stream/Frame.cpp index f0ca5e8a3..aeaa74fad 100644 --- a/src/rogue/interfaces/stream/Frame.cpp +++ b/src/rogue/interfaces/stream/Frame.cpp @@ -1,13 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : Stream frame container * ---------------------------------------------------------------------------- - * File : Frame.h - * Created : 2016-09-16 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Stream frame container - * Some concepts borrowed from CPSW by Till Straumann * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory @@ -34,10 +30,10 @@ namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include -#include + #include + #include -#include + #include namespace bp = boost::python; #endif @@ -184,16 +180,16 @@ void ris::Frame::setPayload(uint32_t pSize) { size_ += loc; // Beyond the fill point, empty buffer - if (lSize == 0) (*it)->setPayloadEmpty(); + if (lSize == 0) { + (*it)->setPayloadEmpty(); - // Size exists in current buffer - else if (lSize <= loc) { + // Size exists in current buffer + } else if (lSize <= loc) { (*it)->setPayload(lSize); lSize = 0; - } - // Size is beyond current buffer - else { + // Size is beyond current buffer + } else { lSize -= loc; (*it)->setPayloadFull(); } @@ -370,7 +366,7 @@ void ris::Frame::readPy(boost::python::object p, uint32_t offset) { } ris::FrameIterator beg = this->begin() + offset; - ris::fromFrame(beg, count, (uint8_t*)pyBuf.buf); + ris::fromFrame(beg, count, reinterpret_cast(pyBuf.buf)); PyBuffer_Release(&pyBuf); } @@ -396,7 +392,7 @@ void ris::Frame::writePy(boost::python::object p, uint32_t offset) { minPayload(offset + count); ris::FrameIterator beg = this->begin() + offset; - ris::toFrame(beg, count, (uint8_t*)pyBuf.buf); + ris::toFrame(beg, count, reinterpret_cast(pyBuf.buf)); PyBuffer_Release(&pyBuf); } @@ -437,7 +433,9 @@ void ris::Frame::putNumpy(boost::python::object p, uint32_t offset) { PyObject* obj = p.ptr(); // Check that this is a PyArrayObject - if (!PyArray_Check(obj)) { throw(rogue::GeneralError("Frame::putNumpy", "Object is not a numpy array")); } + if (!PyArray_Check(obj)) { + throw(rogue::GeneralError("Frame::putNumpy", "Object is not a numpy array")); + } // Cast to an array object and check that the numpy array // data buffer is write-able and contiguous @@ -445,7 +443,9 @@ void ris::Frame::putNumpy(boost::python::object p, uint32_t offset) { PyArrayObject* arr = reinterpret_cast(obj); int flags = PyArray_FLAGS(arr); bool ctg = flags & (NPY_ARRAY_C_CONTIGUOUS | NPY_ARRAY_F_CONTIGUOUS); - if (!ctg) { arr = PyArray_GETCONTIGUOUS(arr); } + if (!ctg) { + arr = PyArray_GETCONTIGUOUS(arr); + } // Get the number of bytes in both the source and destination buffers uint32_t size = getSize(); @@ -471,7 +471,9 @@ void ris::Frame::putNumpy(boost::python::object p, uint32_t offset) { ris::toFrame(beg, count, src); // If were forced to make a temporary copy, release it - if (!ctg) { Py_XDECREF(arr); } + if (!ctg) { + Py_XDECREF(arr); + } return; } diff --git a/src/rogue/interfaces/stream/FrameIterator.cpp b/src/rogue/interfaces/stream/FrameIterator.cpp index daa166019..bfc345178 100644 --- a/src/rogue/interfaces/stream/FrameIterator.cpp +++ b/src/rogue/interfaces/stream/FrameIterator.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Stream iterator container * ---------------------------------------------------------------------------- - * File : FrameIterator.h - * Created : 2018-03-06 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Stream frame iterator @@ -59,10 +56,9 @@ void ris::FrameIterator::increment(int32_t diff) { buffEnd_ = frameSize_; buff_ = frame_->endBuffer(); data_ = NULL; - } - // Move forward in buffer chain - else { + // Move forward in buffer chain + } else { // Increment current buffer until we find the location of the data position // Iterator always contains one extra buffer index while (framePos_ >= buffEnd_) { @@ -91,10 +87,9 @@ void ris::FrameIterator::decrement(int32_t diff) { buffEnd_ = frameSize_; buff_ = frame_->endBuffer(); data_ = NULL; - } - // Move backwards in buffer chain - else { + // Move backwards in buffer chain + } else { // Decrement current buffer until the desired frame position is greater than // the bottom of the buffer while (framePos_ < buffBeg_) { diff --git a/src/rogue/interfaces/stream/FrameLock.cpp b/src/rogue/interfaces/stream/FrameLock.cpp index 856bf790a..361e37703 100644 --- a/src/rogue/interfaces/stream/FrameLock.cpp +++ b/src/rogue/interfaces/stream/FrameLock.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Frame Lock * ---------------------------------------------------------------------------- - * File : FrameLock.cpp - * Created : 2018-03-16 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Frame lock @@ -29,7 +26,7 @@ namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif diff --git a/src/rogue/interfaces/stream/Master.cpp b/src/rogue/interfaces/stream/Master.cpp index 9d1482f25..3fdb9927e 100644 --- a/src/rogue/interfaces/stream/Master.cpp +++ b/src/rogue/interfaces/stream/Master.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Stream interface master * ---------------------------------------------------------------------------- - * File : Master.h - * Created : 2016-09-16 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Stream interface master @@ -34,7 +31,7 @@ namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -92,20 +89,20 @@ void ris::Master::sendFrame(FramePtr frame) { // Ensure passed frame is a single buffer bool ris::Master::ensureSingleBuffer(ris::FramePtr& frame, bool reqEn) { // Frame is a single buffer - if (frame->bufferCount() == 1) + if (frame->bufferCount() == 1) { return true; - else if (!reqEn) + } else if (!reqEn) { return false; - else { + } else { uint32_t size = frame->getPayload(); ris::FramePtr nFrame = reqFrame(size, true); - if (nFrame->bufferCount() != 1) + if (nFrame->bufferCount() != 1) { return false; - else { + } else { nFrame->setPayload(size); ris::FrameIterator srcIter = frame->begin(); @@ -149,30 +146,36 @@ void ris::Master::equalsPy(boost::python::object p) { boost::python::extract get_master(p); // Test extraction - if (get_master.check()) rMst = get_master(); + if (get_master.check()) { + rMst = get_master(); - // Otherwise look for indirect call - else if (PyObject_HasAttrString(p.ptr(), "_getStreamMaster")) { + // Otherwise look for indirect call + } else if (PyObject_HasAttrString(p.ptr(), "_getStreamMaster")) { // Attempt to convert returned object to master pointer boost::python::extract get_master(p.attr("_getStreamMaster")()); // Test extraction - if (get_master.check()) rMst = get_master(); + if (get_master.check()) { + rMst = get_master(); + } } // Attempt to access object as a stream slave boost::python::extract get_slave(p); // Test extraction - if (get_slave.check()) rSlv = get_slave(); + if (get_slave.check()) { + rSlv = get_slave(); - // Otherwise look for indirect call - else if (PyObject_HasAttrString(p.ptr(), "_getStreamSlave")) { + // Otherwise look for indirect call + } else if (PyObject_HasAttrString(p.ptr(), "_getStreamSlave")) { // Attempt to convert returned object to slave pointer boost::python::extract get_slave(p.attr("_getStreamSlave")()); // Test extraction - if (get_slave.check()) rSlv = get_slave(); + if (get_slave.check()) { + rSlv = get_slave(); + } } if (rMst == NULL || rSlv == NULL || lSlv == NULL) @@ -191,15 +194,18 @@ bp::object ris::Master::rshiftPy(bp::object p) { boost::python::extract get_slave(p); // Test extraction - if (get_slave.check()) slv = get_slave(); + if (get_slave.check()) { + slv = get_slave(); - // Otherwise look for indirect call - else if (PyObject_HasAttrString(p.ptr(), "_getStreamSlave")) { + // Otherwise look for indirect call + } else if (PyObject_HasAttrString(p.ptr(), "_getStreamSlave")) { // Attempt to convert returned object to slave pointer boost::python::extract get_slave(p.attr("_getStreamSlave")()); // Test extraction - if (get_slave.check()) slv = get_slave(); + if (get_slave.check()) { + slv = get_slave(); + } } if (slv != NULL) diff --git a/src/rogue/interfaces/stream/Pool.cpp b/src/rogue/interfaces/stream/Pool.cpp index aaadae803..e7a918a46 100644 --- a/src/rogue/interfaces/stream/Pool.cpp +++ b/src/rogue/interfaces/stream/Pool.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Stream memory pool * ---------------------------------------------------------------------------- - * File : Pool.cpp - * Created : 2016-09-16 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Stream memory pool @@ -37,7 +34,7 @@ namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -52,7 +49,9 @@ ris::Pool::Pool() { //! Destructor ris::Pool::~Pool() { - while (!dataQ_.empty()) { free(dataQ_.front()); } + while (!dataQ_.empty()) { + free(dataQ_.front()); + } } //! Get allocated memory @@ -159,9 +158,10 @@ ris::BufferPtr ris::Pool::allocBuffer(uint32_t size, uint32_t* total) { if (dataQ_.size() > 0) { data = dataQ_.front(); dataQ_.pop(); - } else if ((data = (uint8_t*)malloc(bAlloc)) == NULL) + } else if ((data = reinterpret_cast(malloc(bAlloc))) == NULL) { throw( rogue::GeneralError::create("Pool::allocBuffer", "Failed to allocate buffer with size = %" PRIu32, bAlloc)); + } // Only use lower 24 bits of meta. // Upper 8 bits may have special meaning to sub-class diff --git a/src/rogue/interfaces/stream/RateDrop.cpp b/src/rogue/interfaces/stream/RateDrop.cpp index 757047e96..34773d223 100644 --- a/src/rogue/interfaces/stream/RateDrop.cpp +++ b/src/rogue/interfaces/stream/RateDrop.cpp @@ -1,11 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : SLAC Stream Interface Rate Drop * ---------------------------------------------------------------------------- - * File : RateDrop.cpp - * Author : Ryan Herbst - * Created : 08/25/2020 - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * Drops frames at a specified rate. *----------------------------------------------------------------------------- @@ -35,7 +31,7 @@ namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -90,10 +86,9 @@ void ris::RateDrop::acceptFrame(ris::FramePtr frame) { sendFrame(frame); dropCount_ = 0; } - } - // Dropping based upon time - else { + // Dropping based upon time + } else { gettimeofday(&currTime, NULL); if (timercmp(&currTime, &(nextPeriod_), >)) { diff --git a/src/rogue/interfaces/stream/Slave.cpp b/src/rogue/interfaces/stream/Slave.cpp index 3ba5107c7..ccbba1fe6 100644 --- a/src/rogue/interfaces/stream/Slave.cpp +++ b/src/rogue/interfaces/stream/Slave.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Stream interface slave * ---------------------------------------------------------------------------- - * File : Slave.cpp - * Created : 2016-09-16 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Stream interface slave @@ -43,7 +40,7 @@ namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -88,7 +85,7 @@ void ris::Slave::acceptFrame(ris::FramePtr frame) { char buffer[1000]; log_->critical("Got Size=%" PRIu32 ", Error=%" PRIu8 ", Data:", frame->getPayload(), frame->getError()); - sprintf(buffer, " "); + snprintf(buffer, sizeof(buffer), " "); count = 0; for (it = frame->begin(); (count < debug_) && (it != frame->end()); ++it) { @@ -98,7 +95,7 @@ void ris::Slave::acceptFrame(ris::FramePtr frame) { snprintf(buffer + strlen(buffer), 1000 - strlen(buffer), " 0x%.2x", val); if (((count + 1) % 8) == 0) { log_->critical(buffer); - sprintf(buffer, " "); + snprintf(buffer, sizeof(buffer), " "); } } @@ -117,7 +114,9 @@ void ris::SlaveWrap::acceptFrame(ris::FramePtr frame) { try { pb(frame); return; - } catch (...) { PyErr_Print(); } + } catch (...) { + PyErr_Print(); + } } } ris::Slave::acceptFrame(frame); @@ -143,20 +142,20 @@ uint64_t ris::Slave::getByteCount() { // Ensure passed frame is a single buffer bool ris::Slave::ensureSingleBuffer(ris::FramePtr& frame, bool reqEn) { // Frame is a single buffer - if (frame->bufferCount() == 1) + if (frame->bufferCount() == 1) { return true; - else if (!reqEn) + } else if (!reqEn) { return false; - else { + } else { uint32_t size = frame->getPayload(); ris::FramePtr nFrame = reqLocalFrame(size, true); - if (nFrame->bufferCount() != 1) + if (nFrame->bufferCount() != 1) { return false; - else { + } else { nFrame->setPayload(size); ris::FrameIterator srcIter = frame->begin(); @@ -171,7 +170,7 @@ bool ris::Slave::ensureSingleBuffer(ris::FramePtr& frame, bool reqEn) { // Process a local frame request ris::FramePtr ris::Slave::reqLocalFrame(uint32_t size, bool zeroCopyEn) { - return ris::Pool::acceptReq(size,zeroCopyEn); + return ris::Pool::acceptReq(size, zeroCopyEn); } void ris::Slave::setup_python() { @@ -205,10 +204,11 @@ bp::object ris::Slave::lshiftPy(bp::object p) { boost::python::extract get_master(p); // Test extraction - if (get_master.check()) mst = get_master(); + if (get_master.check()) { + mst = get_master(); - // Otherwise look for indirect call - else if (PyObject_HasAttrString(p.ptr(), "_getStreamMaster")) { + // Otherwise look for indirect call + } else if (PyObject_HasAttrString(p.ptr(), "_getStreamMaster")) { // Attempt to convert returned object to master pointer boost::python::extract get_master(p.attr("_getStreamMaster")()); diff --git a/src/rogue/interfaces/stream/TcpClient.cpp b/src/rogue/interfaces/stream/TcpClient.cpp index d3459e6cc..0de7abde3 100644 --- a/src/rogue/interfaces/stream/TcpClient.cpp +++ b/src/rogue/interfaces/stream/TcpClient.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Stream Network Client * ---------------------------------------------------------------------------- - * File : TcpClient.h - * Created : 2019-01-30 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Stream Network Client @@ -36,7 +33,7 @@ namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif diff --git a/src/rogue/interfaces/stream/TcpCore.cpp b/src/rogue/interfaces/stream/TcpCore.cpp index 2a5d91b4a..9e15ef204 100644 --- a/src/rogue/interfaces/stream/TcpCore.cpp +++ b/src/rogue/interfaces/stream/TcpCore.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Stream Network Core * ---------------------------------------------------------------------------- - * File : TcpCore.h - * Created : 2019-01-30 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Stream Network Core @@ -38,7 +35,7 @@ namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -92,8 +89,8 @@ ris::TcpCore::TcpCore(std::string addr, uint16_t port, bool server) { // Server mode if (server) { - this->pullAddr_.append(std::to_string(static_cast(port))); - this->pushAddr_.append(std::to_string(static_cast(port + 1))); + this->pullAddr_.append(std::to_string(static_cast(port))); + this->pushAddr_.append(std::to_string(static_cast(port + 1))); this->bridgeLog_->debug("Creating pull server port: %s", this->pullAddr_.c_str()); @@ -112,12 +109,11 @@ ris::TcpCore::TcpCore(std::string addr, uint16_t port, bool server) { " at address %s, another process may be using this port", port + 1, addr.c_str())); - } - // Client mode - else { - this->pullAddr_.append(std::to_string(static_cast(port + 1))); - this->pushAddr_.append(std::to_string(static_cast(port))); + // Client mode + } else { + this->pullAddr_.append(std::to_string(static_cast(port + 1))); + this->pushAddr_.append(std::to_string(static_cast(port))); this->bridgeLog_->debug("Creating pull client port: %s", this->pullAddr_.c_str()); @@ -203,7 +199,7 @@ void ris::TcpCore::acceptFrame(ris::FramePtr frame) { // Copy data ris::FrameIterator iter = frame->begin(); - data = (uint8_t*)zmq_msg_data(&(msg[3])); + data = reinterpret_cast(zmq_msg_data(&(msg[3]))); ris::fromFrame(iter, frame->getPayload(), data); // Send data @@ -248,8 +244,9 @@ void ris::TcpCore::runThread() { more = 0; moreSize = 8; zmq_getsockopt(this->zmqPull_, ZMQ_RCVMORE, &more, &moreSize); - } else + } else { more = 1; + } } while (threadEn_ && more); // Proper message received @@ -267,7 +264,7 @@ void ris::TcpCore::runThread() { std::memcpy(&err, zmq_msg_data(&(msg[2])), 1); // Get message info - data = (uint8_t*)zmq_msg_data(&(msg[3])); + data = reinterpret_cast(zmq_msg_data(&(msg[3]))); size = zmq_msg_size(&(msg[3])); // Generate frame diff --git a/src/rogue/interfaces/stream/TcpServer.cpp b/src/rogue/interfaces/stream/TcpServer.cpp index f2e86ee44..b680b4dd8 100644 --- a/src/rogue/interfaces/stream/TcpServer.cpp +++ b/src/rogue/interfaces/stream/TcpServer.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Stream Network Server * ---------------------------------------------------------------------------- - * File : TcpServer.h - * Created : 2019-01-30 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Stream Network Server @@ -36,7 +33,7 @@ namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif diff --git a/src/rogue/interfaces/stream/module.cpp b/src/rogue/interfaces/stream/module.cpp index 66db30678..fb3ac84a7 100644 --- a/src/rogue/interfaces/stream/module.cpp +++ b/src/rogue/interfaces/stream/module.cpp @@ -1,11 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module For Stream Interface * ---------------------------------------------------------------------------- - * File : module.cpp - * Author : Ryan Herbst, rherbst@slac.stanford.edu - * Created : 2016-08-08 - * Last update: 2016-08-08 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/src/rogue/module.cpp b/src/rogue/module.cpp index 0f2d9f4ed..583a1a26d 100644 --- a/src/rogue/module.cpp +++ b/src/rogue/module.cpp @@ -1,11 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module * ---------------------------------------------------------------------------- - * File : module.cpp - * Author : Ryan Herbst, rherbst@slac.stanford.edu - * Created : 2016-08-08 - * Last update: 2016-08-08 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/src/rogue/protocols/CMakeLists.txt b/src/rogue/protocols/CMakeLists.txt index ff1ad7f50..0b8ff5dcb 100644 --- a/src/rogue/protocols/CMakeLists.txt +++ b/src/rogue/protocols/CMakeLists.txt @@ -1,8 +1,5 @@ # ---------------------------------------------------------------------------- -# Title : ROGUE CMAKE Control -# ---------------------------------------------------------------------------- -# File : src/rogue/protocols/CMakeLists.txt -# Created : 2018-02-27 +# Company : SLAC National Accelerator Laboratory # ---------------------------------------------------------------------------- # This file is part of the rogue software package. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/src/rogue/protocols/batcher/CMakeLists.txt b/src/rogue/protocols/batcher/CMakeLists.txt index 2a1a3b44a..cb49f2f23 100644 --- a/src/rogue/protocols/batcher/CMakeLists.txt +++ b/src/rogue/protocols/batcher/CMakeLists.txt @@ -1,8 +1,5 @@ # ---------------------------------------------------------------------------- -# Title : ROGUE CMAKE Control -# ---------------------------------------------------------------------------- -# File : src/rogue/protocols/CMakeLists.txt -# Created : 2018-02-27 +# Company : SLAC National Accelerator Laboratory # ---------------------------------------------------------------------------- # This file is part of the rogue software package. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/src/rogue/protocols/batcher/CoreV1.cpp b/src/rogue/protocols/batcher/CoreV1.cpp index 537790bd9..fff5014f2 100644 --- a/src/rogue/protocols/batcher/CoreV1.cpp +++ b/src/rogue/protocols/batcher/CoreV1.cpp @@ -1,11 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : SLAC Batcher Core, Version 1 * ---------------------------------------------------------------------------- - * File : CoreV1.h - * Author : Ryan Herbst - * Created : 10/26/2018 - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * AXI Batcher V1 (https://confluence.slac.stanford.edu/x/th1SDg) * diff --git a/src/rogue/protocols/batcher/Data.cpp b/src/rogue/protocols/batcher/Data.cpp index 555762adc..579c2d8f4 100644 --- a/src/rogue/protocols/batcher/Data.cpp +++ b/src/rogue/protocols/batcher/Data.cpp @@ -1,19 +1,18 @@ /** - *----------------------------------------------------------------------------- - * Title : SLAC Batcher Data * ---------------------------------------------------------------------------- - * File : Data.h - * Author : Ryan Herbst - * Created : 02/08/2019 - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- + * Description: + * SLAC Batcher Data + * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory * of this distribution and at: - * https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. + * https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. * No part of the rogue software platform, including this file, may be * copied, modified, propagated, or distributed except according to the terms * contained in the LICENSE.txt file. - *----------------------------------------------------------------------------- + * ---------------------------------------------------------------------------- **/ #include "rogue/protocols/batcher/Data.h" diff --git a/src/rogue/protocols/batcher/InverterV1.cpp b/src/rogue/protocols/batcher/InverterV1.cpp index 6e53d8ea9..56aed6007 100644 --- a/src/rogue/protocols/batcher/InverterV1.cpp +++ b/src/rogue/protocols/batcher/InverterV1.cpp @@ -1,19 +1,18 @@ /** - *----------------------------------------------------------------------------- - * Title : SLAC Inverter Version 1 * ---------------------------------------------------------------------------- - * File : InverterV1.h - * Author : Ryan Herbst - * Created : 10/26/2018 - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- + * Description: + * SLAC Inverter Version 1 + * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory * of this distribution and at: - * https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. + * https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. * No part of the rogue software platform, including this file, may be * copied, modified, propagated, or distributed except according to the terms * contained in the LICENSE.txt file. - *----------------------------------------------------------------------------- + * ---------------------------------------------------------------------------- **/ #include "rogue/Directives.h" @@ -39,7 +38,7 @@ namespace rpb = rogue::protocols::batcher; namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif diff --git a/src/rogue/protocols/batcher/SplitterV1.cpp b/src/rogue/protocols/batcher/SplitterV1.cpp index 096f6f268..df8a82b07 100644 --- a/src/rogue/protocols/batcher/SplitterV1.cpp +++ b/src/rogue/protocols/batcher/SplitterV1.cpp @@ -1,19 +1,18 @@ /** - *----------------------------------------------------------------------------- - * Title : SLAC Splitter Version 1 * ---------------------------------------------------------------------------- - * File : SplitterV1.h - * Author : Ryan Herbst - * Created : 10/26/2018 - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- + * Description: + * SLAC Splitter Version 1 + * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory * of this distribution and at: - * https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. + * https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. * No part of the rogue software platform, including this file, may be * copied, modified, propagated, or distributed except according to the terms * contained in the LICENSE.txt file. - *----------------------------------------------------------------------------- + * ---------------------------------------------------------------------------- **/ #include "rogue/Directives.h" @@ -39,7 +38,7 @@ namespace rpb = rogue::protocols::batcher; namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif diff --git a/src/rogue/protocols/batcher/module.cpp b/src/rogue/protocols/batcher/module.cpp index 35a804b22..f683bf45f 100644 --- a/src/rogue/protocols/batcher/module.cpp +++ b/src/rogue/protocols/batcher/module.cpp @@ -1,11 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module * ---------------------------------------------------------------------------- - * File : module.cpp - * Author : Ryan Herbst, rherbst@slac.stanford.edu - * Created : 2016-08-08 - * Last update: 2016-08-08 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/src/rogue/protocols/module.cpp b/src/rogue/protocols/module.cpp index 3f4de6726..467718b09 100644 --- a/src/rogue/protocols/module.cpp +++ b/src/rogue/protocols/module.cpp @@ -1,11 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module * ---------------------------------------------------------------------------- - * File : module.cpp - * Author : Ryan Herbst, rherbst@slac.stanford.edu - * Created : 2016-08-08 - * Last update: 2016-08-08 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/src/rogue/protocols/packetizer/Application.cpp b/src/rogue/protocols/packetizer/Application.cpp index 02cc49631..5d41d19c4 100644 --- a/src/rogue/protocols/packetizer/Application.cpp +++ b/src/rogue/protocols/packetizer/Application.cpp @@ -1,10 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Packetizer Application Port * ---------------------------------------------------------------------------- - * File : Application.h - * Created : 2017-01-07 - * Last update: 2017-01-07 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Packetizer Application Port @@ -35,7 +31,7 @@ namespace rpp = rogue::protocols::packetizer; namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif diff --git a/src/rogue/protocols/packetizer/CMakeLists.txt b/src/rogue/protocols/packetizer/CMakeLists.txt index 1d6fd4974..38abd2672 100644 --- a/src/rogue/protocols/packetizer/CMakeLists.txt +++ b/src/rogue/protocols/packetizer/CMakeLists.txt @@ -1,8 +1,5 @@ # ---------------------------------------------------------------------------- -# Title : ROGUE CMAKE Control -# ---------------------------------------------------------------------------- -# File : src/rogue/protocols/packetizer/CMakeLists.txt -# Created : 2018-02-27 +# Company : SLAC National Accelerator Laboratory # ---------------------------------------------------------------------------- # This file is part of the rogue software package. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/src/rogue/protocols/packetizer/Controller.cpp b/src/rogue/protocols/packetizer/Controller.cpp index b85c272e9..a70d0d99c 100644 --- a/src/rogue/protocols/packetizer/Controller.cpp +++ b/src/rogue/protocols/packetizer/Controller.cpp @@ -1,10 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Packetizer Controller * ---------------------------------------------------------------------------- - * File : Controller.h - * Created : 2017-01-07 - * Last update: 2017-01-07 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Packetizer Controller diff --git a/src/rogue/protocols/packetizer/ControllerV1.cpp b/src/rogue/protocols/packetizer/ControllerV1.cpp index 622003aec..880b29e4e 100644 --- a/src/rogue/protocols/packetizer/ControllerV1.cpp +++ b/src/rogue/protocols/packetizer/ControllerV1.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Packetizer Controller Version 1 * ---------------------------------------------------------------------------- - * File : ControllerV1.cpp - * Created : 2018-02-02 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Packetizer Controller V1 @@ -168,13 +165,16 @@ void rpp::ControllerV1::transportRx(ris::FramePtr frame) { if (tmpEof) { tranFrame_[0]->setLastUser(tmpLuser); tranCount_[0] = 0; - if (app_[tranDest_]) { app_[tranDest_]->pushFrame(tranFrame_[0]); } + if (app_[tranDest_]) { + app_[tranDest_]->pushFrame(tranFrame_[0]); + } tranFrame_[0].reset(); // Detect SSI error if (enSsi_ & (tmpLuser & 0x1)) tranFrame_[tmpDest]->setError(0x80); - } else + } else { tranCount_[0]++; + } } //! Frame received at application interface diff --git a/src/rogue/protocols/packetizer/ControllerV2.cpp b/src/rogue/protocols/packetizer/ControllerV2.cpp index 84b4019af..87fd38462 100644 --- a/src/rogue/protocols/packetizer/ControllerV2.cpp +++ b/src/rogue/protocols/packetizer/ControllerV2.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Packetizer Controller Version 1 * ---------------------------------------------------------------------------- - * File : ControllerV2.cpp - * Created : 2018-02-02 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Packetizer Controller V1 @@ -144,8 +141,9 @@ void rpp::ControllerV2::transportRx(ris::FramePtr frame) { crc_[tmpDest] = CRC::Calculate(data, size - 4, crcTable_, crc_[tmpDest]); crcErr = (tmpCrc != crc_[tmpDest]); - } else + } else { crcErr = false; + } log_->debug("transportRx: Raw header: 0x%" PRIx8 ", 0x%" PRIx8 ", 0x%" PRIx8 ", 0x%" PRIx8 ", 0x%" PRIx8 ", 0x%" PRIx8 ", 0x%" PRIx8 ", 0x%" PRIx8, @@ -236,7 +234,8 @@ void rpp::ControllerV2::transportRx(ris::FramePtr frame) { transSof_[tmpDest] = true; tranCount_[tmpDest] = 0; if (app_[tmpDest]) { - app_[tmpDest]->pushFrame(tranFrame_[tmpDest]); } + app_[tmpDest]->pushFrame(tranFrame_[tmpDest]); + } tranFrame_[tmpDest].reset(); // Detect SSI error @@ -359,7 +358,7 @@ void rpp::ControllerV2::applicationRx(ris::FramePtr frame, uint8_t tDest) { fUser, tDest, segment, - data[7]>>7, + data[7] >> 7, lUser, data[size - 7], last); diff --git a/src/rogue/protocols/packetizer/Core.cpp b/src/rogue/protocols/packetizer/Core.cpp index c2c87b9e3..2d2dd9425 100644 --- a/src/rogue/protocols/packetizer/Core.cpp +++ b/src/rogue/protocols/packetizer/Core.cpp @@ -1,10 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Packetizer Core Class * ---------------------------------------------------------------------------- - * File : Core.h - * Created : 2017-01-07 - * Last update: 2017-01-07 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Packetizer Core @@ -34,7 +30,7 @@ namespace rpp = rogue::protocols::packetizer; namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -50,9 +46,7 @@ void rpp::Core::setup_python() { bp::class_("Core", bp::init()) .def("transport", &rpp::Core::transport) .def("application", &rpp::Core::application) - .def("getDropCount", &rpp::Core::getDropCount) - - ; + .def("getDropCount", &rpp::Core::getDropCount); #endif } diff --git a/src/rogue/protocols/packetizer/CoreV2.cpp b/src/rogue/protocols/packetizer/CoreV2.cpp index f44daf56f..e4849cdbf 100644 --- a/src/rogue/protocols/packetizer/CoreV2.cpp +++ b/src/rogue/protocols/packetizer/CoreV2.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Packetizer Core Class * ---------------------------------------------------------------------------- - * File : CoreV2.cpp - * Created : 2018-02-02 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Packetizer Core V2 @@ -33,7 +30,7 @@ namespace rpp = rogue::protocols::packetizer; namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -49,9 +46,7 @@ void rpp::CoreV2::setup_python() { bp::class_("CoreV2", bp::init()) .def("transport", &rpp::CoreV2::transport) .def("application", &rpp::CoreV2::application) - .def("getDropCount", &rpp::CoreV2::getDropCount) - - ; + .def("getDropCount", &rpp::CoreV2::getDropCount); #endif } diff --git a/src/rogue/protocols/packetizer/Transport.cpp b/src/rogue/protocols/packetizer/Transport.cpp index 311bf71cb..9b2c4e447 100644 --- a/src/rogue/protocols/packetizer/Transport.cpp +++ b/src/rogue/protocols/packetizer/Transport.cpp @@ -1,10 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Packetizer Transport Port * ---------------------------------------------------------------------------- - * File : Transport.h - * Created : 2017-01-07 - * Last update: 2017-01-07 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Packetizer Transport Port @@ -35,7 +31,7 @@ namespace rpp = rogue::protocols::packetizer; namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif diff --git a/src/rogue/protocols/packetizer/module.cpp b/src/rogue/protocols/packetizer/module.cpp index d5632105f..c4647fa7d 100644 --- a/src/rogue/protocols/packetizer/module.cpp +++ b/src/rogue/protocols/packetizer/module.cpp @@ -1,11 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module * ---------------------------------------------------------------------------- - * File : module.cpp - * Author : Ryan Herbst, rherbst@slac.stanford.edu - * Created : 2016-08-08 - * Last update: 2016-08-08 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/src/rogue/protocols/rssi/Application.cpp b/src/rogue/protocols/rssi/Application.cpp index a2970f5a0..48ae2e990 100644 --- a/src/rogue/protocols/rssi/Application.cpp +++ b/src/rogue/protocols/rssi/Application.cpp @@ -1,10 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : RSSI Application Port * ---------------------------------------------------------------------------- - * File : Application.h - * Created : 2017-01-07 - * Last update: 2017-01-07 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * RSSI Application Port @@ -35,7 +31,7 @@ namespace rpr = rogue::protocols::rssi; namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif diff --git a/src/rogue/protocols/rssi/CMakeLists.txt b/src/rogue/protocols/rssi/CMakeLists.txt index ebbcb8da3..1b5d86938 100644 --- a/src/rogue/protocols/rssi/CMakeLists.txt +++ b/src/rogue/protocols/rssi/CMakeLists.txt @@ -1,8 +1,5 @@ # ---------------------------------------------------------------------------- -# Title : ROGUE CMAKE Control -# ---------------------------------------------------------------------------- -# File : src/rogue/protocols/rssi/CMakeLists.txt -# Created : 2018-02-27 +# Company : SLAC National Accelerator Laboratory # ---------------------------------------------------------------------------- # This file is part of the rogue software package. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/src/rogue/protocols/rssi/Client.cpp b/src/rogue/protocols/rssi/Client.cpp index 822baf670..dd9e41c64 100644 --- a/src/rogue/protocols/rssi/Client.cpp +++ b/src/rogue/protocols/rssi/Client.cpp @@ -1,13 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : RSSI Client Class * ---------------------------------------------------------------------------- - * File : Client.h - * Created : 2017-01-07 - * Last update: 2017-01-07 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: - * UDP Client + * RSSI Client Class * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory @@ -34,7 +30,7 @@ namespace rpr = rogue::protocols::rssi; namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif diff --git a/src/rogue/protocols/rssi/Controller.cpp b/src/rogue/protocols/rssi/Controller.cpp index 7957d9d5e..7a8e73a1d 100644 --- a/src/rogue/protocols/rssi/Controller.cpp +++ b/src/rogue/protocols/rssi/Controller.cpp @@ -1,11 +1,6 @@ - /** - *----------------------------------------------------------------------------- - * Title : RSSI Controller * ---------------------------------------------------------------------------- - * File : Controller.h - * Created : 2017-01-07 - * Last update: 2017-01-07 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * RSSI Controller @@ -240,21 +235,21 @@ void rpr::Controller::transportRx(ris::FramePtr frame) { // Reset if (head->rst) { - if (state_ == StOpen || state_ == StWaitSyn) { stQueue_.push(head); } - } + if (state_ == StOpen || state_ == StWaitSyn) { + stQueue_.push(head); + } - // Syn frame goes to state machine if state = open - // or we are waiting for ack replay - else if (head->syn) { + // Syn frame goes to state machine if state = open + // or we are waiting for ack replay + } else if (head->syn) { if (state_ == StOpen || state_ == StWaitSyn) { lastSeqRx_ = head->sequence; nextSeqRx_ = lastSeqRx_ + 1; stQueue_.push(head); } - } - // Data or NULL in the correct sequence go to application - else if (state_ == StOpen && (head->nul || frame->getPayload() > rpr::Header::HeaderSize)) { + // Data or NULL in the correct sequence go to application + } else if (state_ == StOpen && (head->nul || frame->getPayload() > rpr::Header::HeaderSize)) { if (head->sequence == nextSeqRx_) { // log_->warning("Data or NULL in the correct sequence go to application: nextSeqRx_=0x%" PRIx8, // nextSeqRx_); @@ -293,22 +288,20 @@ void rpr::Controller::transportRx(ris::FramePtr frame) { // Notify after the last sequence update stCond_.notify_all(); - } - // Check if received frame is already in out of order queue - else if ((it = oooQueue_.find(head->sequence)) != oooQueue_.end()) { + // Check if received frame is already in out of order queue + } else if ((it = oooQueue_.find(head->sequence)) != oooQueue_.end()) { log_->warning("Dropped duplicate frame. server=%" PRIu8 ", head->sequence=%" PRIu32 ", next sequence=%" PRIu32, server_, head->sequence, nextSeqRx_); dropCount_++; - } - // Add to out of order queue in case things arrive out of order - // Make sure received sequence is in window. There may be a better way - // to do this while handling the 8 bit rollover - else { + // Add to out of order queue in case things arrive out of order + // Make sure received sequence is in window. There may be a better way + // to do this while handling the 8 bit rollover + } else { uint8_t x = nextSeqRx_; uint8_t windowEnd = (nextSeqRx_ + curMaxBuffers_ + 1); @@ -359,9 +352,9 @@ ris::FramePtr rpr::Controller::applicationTx() { if (head->nul) { head.reset(); frame.reset(); - } else + } else { (*(frame->beginBuffer()))->adjustHeader(rpr::Header::HeaderSize); - + } } while (!frame); return (frame); @@ -396,7 +389,9 @@ void rpr::Controller::applicationRx(ris::FramePtr frame) { flock->unlock(); // Connection is closed - if (state_ != StOpen) return; + if (state_ != StOpen) { + return; + } // Wait while busy either by flow control or buffer starvation while (txListCount_ >= curMaxBuffers_) { @@ -703,7 +698,7 @@ int8_t rpr::Controller::retransmit(uint8_t id) { //! Convert rssi time to microseconds void rpr::Controller::convTime(struct timeval& tme, uint32_t rssiTime) { float units = std::pow(10, -TimeoutUnit); - float value = units * (float)rssiTime; + float value = units * static_cast(rssiTime); uint32_t usec = (uint32_t)(value / 1e-6); @@ -782,10 +777,9 @@ struct timeval& rpr::Controller::stateClosedWait() { if (head->rst) { state_ = StClosed; log_->warning("Closing link. Server=%" PRIu8, server_); - } - // Syn ack - else if (head->syn && (head->ack || server_)) { + // Syn ack + } else if (head->syn && (head->ack || server_)) { curMaxBuffers_ = head->maxOutstandingSegments; curMaxSegment_ = head->maxSegmentSize; curCumAckTout_ = head->cumulativeAckTimeout; @@ -804,13 +798,13 @@ struct timeval& rpr::Controller::stateClosedWait() { if (server_) { state_ = StSendSynAck; return (zeroTme_); - } else + } else { state_ = StSendSeqAck; + } gettimeofday(&stTime_, NULL); - } - // reset counters - else { + // reset counters + } else { curMaxBuffers_ = locMaxBuffers_; curMaxSegment_ = locMaxSegment_; curCumAckTout_ = locCumAckTout_; @@ -819,10 +813,9 @@ struct timeval& rpr::Controller::stateClosedWait() { curMaxRetran_ = locMaxRetran_; curMaxCumAck_ = locMaxCumAck_; } - } - // Generate syn after try period passes - else if ((!server_) && timePassed(stTime_, tryPeriodD1_)) { + // Generate syn after try period passes + } else if ((!server_) && timePassed(stTime_, tryPeriodD1_)) { // Allocate frame head = rpr::Header::create(tran_->reqFrame(rpr::Header::SynSize, false)); @@ -845,8 +838,9 @@ struct timeval& rpr::Controller::stateClosedWait() { // Update state gettimeofday(&stTime_, NULL); state_ = StWaitSyn; - } else if (server_) + } else if (server_) { state_ = StWaitSyn; + } return (tryPeriodD4_); } diff --git a/src/rogue/protocols/rssi/Header.cpp b/src/rogue/protocols/rssi/Header.cpp index 4cb157933..1958412b9 100644 --- a/src/rogue/protocols/rssi/Header.cpp +++ b/src/rogue/protocols/rssi/Header.cpp @@ -1,10 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : RSII Header Class * ---------------------------------------------------------------------------- - * File : Header.h - * Created : 2017-01-07 - * Last update: 2017-01-07 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * RSSI Header @@ -40,22 +36,22 @@ namespace ris = rogue::interfaces::stream; //! Set 16-bit uint value void rpr::Header::setUInt16(uint8_t* data, uint8_t byte, uint16_t value) { - *((uint16_t*)(&(data[byte]))) = htons(value); + *reinterpret_cast(&data[byte]) = htons(value); } //! Get 16-bit uint value uint16_t rpr::Header::getUInt16(uint8_t* data, uint8_t byte) { - return (ntohs(*((uint16_t*)(&(data[byte]))))); + return ntohs(*reinterpret_cast(&data[byte])); } //! Set 32-bit uint value void rpr::Header::setUInt32(uint8_t* data, uint8_t byte, uint32_t value) { - *((uint32_t*)(&(data[byte]))) = htonl(value); + *reinterpret_cast(&(data[byte])) = htonl(value); } //! Get 32-bit uint value uint32_t rpr::Header::getUInt32(uint8_t* data, uint8_t byte) { - return (ntohl(*((uint32_t*)(&(data[byte]))))); + return ntohl(*reinterpret_cast(&(data[byte]))); } //! compute checksum diff --git a/src/rogue/protocols/rssi/Server.cpp b/src/rogue/protocols/rssi/Server.cpp index 423006a1b..7dead35fa 100644 --- a/src/rogue/protocols/rssi/Server.cpp +++ b/src/rogue/protocols/rssi/Server.cpp @@ -1,9 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : RSSI Server Class * ---------------------------------------------------------------------------- - * File : Server.h - * Created : 2017-06-13 + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- + * Description: + * * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory @@ -30,7 +30,7 @@ namespace rpr = rogue::protocols::rssi; namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif diff --git a/src/rogue/protocols/rssi/Transport.cpp b/src/rogue/protocols/rssi/Transport.cpp index bdf5d4c57..6c026704a 100644 --- a/src/rogue/protocols/rssi/Transport.cpp +++ b/src/rogue/protocols/rssi/Transport.cpp @@ -1,10 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : RSSI Transport Port * ---------------------------------------------------------------------------- - * File : Transport.h - * Created : 2017-01-07 - * Last update: 2017-01-07 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * RSSI Transport Port @@ -35,7 +31,7 @@ namespace rpr = rogue::protocols::rssi; namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif diff --git a/src/rogue/protocols/rssi/module.cpp b/src/rogue/protocols/rssi/module.cpp index e142515ba..0085be5f2 100644 --- a/src/rogue/protocols/rssi/module.cpp +++ b/src/rogue/protocols/rssi/module.cpp @@ -1,11 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module * ---------------------------------------------------------------------------- - * File : module.cpp - * Author : Ryan Herbst, rherbst@slac.stanford.edu - * Created : 2016-08-08 - * Last update: 2016-08-08 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/src/rogue/protocols/srp/CMakeLists.txt b/src/rogue/protocols/srp/CMakeLists.txt index f8aba1edc..593f678d7 100644 --- a/src/rogue/protocols/srp/CMakeLists.txt +++ b/src/rogue/protocols/srp/CMakeLists.txt @@ -1,8 +1,5 @@ # ---------------------------------------------------------------------------- -# Title : ROGUE CMAKE Control -# ---------------------------------------------------------------------------- -# File : src/rogue/protocols/srp/CMakeLists.txt -# Created : 2018-02-27 +# Company : SLAC National Accelerator Laboratory # ---------------------------------------------------------------------------- # This file is part of the rogue software package. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/src/rogue/protocols/srp/Cmd.cpp b/src/rogue/protocols/srp/Cmd.cpp index 08ca8ce2d..870ea1881 100644 --- a/src/rogue/protocols/srp/Cmd.cpp +++ b/src/rogue/protocols/srp/Cmd.cpp @@ -1,12 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : SLAC Register Protocol (SRP) SrpV0 * ---------------------------------------------------------------------------- - * File : SrpV0.cpp - * Author : Ryan Herbst - * Created : 09/17/2016 - * Last update : 09/17/2016 - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * CMD protocol bridge, Version 0 *----------------------------------------------------------------------------- @@ -36,7 +31,7 @@ namespace rps = rogue::protocols::srp; namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif diff --git a/src/rogue/protocols/srp/SrpV0.cpp b/src/rogue/protocols/srp/SrpV0.cpp index 037d19d9a..ff9a71742 100644 --- a/src/rogue/protocols/srp/SrpV0.cpp +++ b/src/rogue/protocols/srp/SrpV0.cpp @@ -1,12 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : SLAC Register Protocol (SRP) SrpV0 * ---------------------------------------------------------------------------- - * File : SrpV0.cpp - * Author : Ryan Herbst - * Created : 09/17/2016 - * Last update : 09/17/2016 - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * SRP protocol bridge, Version 0 *----------------------------------------------------------------------------- @@ -47,7 +42,7 @@ namespace rim = rogue::interfaces::memory; namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif diff --git a/src/rogue/protocols/srp/SrpV3.cpp b/src/rogue/protocols/srp/SrpV3.cpp index aba1cd15d..754e56902 100644 --- a/src/rogue/protocols/srp/SrpV3.cpp +++ b/src/rogue/protocols/srp/SrpV3.cpp @@ -1,12 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : SLAC Register Protocol (SRP) SrpV3 * ---------------------------------------------------------------------------- - * File : SrpV3.cpp - * Author : Ryan Herbst - * Created : 09/17/2016 - * Last update : 09/17/2016 - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * SRP protocol bridge, Version 3 *----------------------------------------------------------------------------- @@ -47,7 +42,7 @@ namespace rim = rogue::interfaces::memory; namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif diff --git a/src/rogue/protocols/srp/module.cpp b/src/rogue/protocols/srp/module.cpp index f6a59a89d..1ea316b5b 100644 --- a/src/rogue/protocols/srp/module.cpp +++ b/src/rogue/protocols/srp/module.cpp @@ -1,11 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module * ---------------------------------------------------------------------------- - * File : module.cpp - * Author : Ryan Herbst, rherbst@slac.stanford.edu - * Created : 2016-08-08 - * Last update: 2016-08-08 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/src/rogue/protocols/udp/CMakeLists.txt b/src/rogue/protocols/udp/CMakeLists.txt index 20d170194..f0fc97d7f 100644 --- a/src/rogue/protocols/udp/CMakeLists.txt +++ b/src/rogue/protocols/udp/CMakeLists.txt @@ -1,8 +1,5 @@ # ---------------------------------------------------------------------------- -# Title : ROGUE CMAKE Control -# ---------------------------------------------------------------------------- -# File : src/rogue/protocols/udp/CMakeLists.txt -# Created : 2018-02-27 +# Company : SLAC National Accelerator Laboratory # ---------------------------------------------------------------------------- # This file is part of the rogue software package. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/src/rogue/protocols/udp/Client.cpp b/src/rogue/protocols/udp/Client.cpp index 579079d8a..f5a88c2a4 100644 --- a/src/rogue/protocols/udp/Client.cpp +++ b/src/rogue/protocols/udp/Client.cpp @@ -1,10 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : UDP Client Class * ---------------------------------------------------------------------------- - * File : Client.h - * Created : 2017-01-07 - * Last update: 2017-01-07 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * UDP Client @@ -41,7 +37,7 @@ namespace rpu = rogue::protocols::udp; namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -173,12 +169,10 @@ void rpu::Client::acceptFrame(ris::FramePtr frame) { timeout_.tv_sec, timeout_.tv_usec); res = 0; - } else if ((res = sendmsg(fd_, &msg, 0)) < 0) + } else if ((res = sendmsg(fd_, &msg, 0)) < 0) { udpLog_->warning("UDP Write Call Failed"); - } - - // Continue while write result was zero - while (res == 0); + } + } while (res == 0); // Continue while write result was zero } } @@ -207,9 +201,9 @@ void rpu::Client::runThread(std::weak_ptr lockPtr) { if (res > 0) { // Message was too big - if (res > avail) - udpLog_->warning("Receive data was too large. Dropping."); - else { + if (res > avail) { + udpLog_->warning("Receive data was too large. Rx=%i, avail=%i Dropping.", res, avail); + } else { buff->setPayload(res); sendFrame(frame); } diff --git a/src/rogue/protocols/udp/Core.cpp b/src/rogue/protocols/udp/Core.cpp index fb2395382..0df6a7d6a 100644 --- a/src/rogue/protocols/udp/Core.cpp +++ b/src/rogue/protocols/udp/Core.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : UDP Core Class * ---------------------------------------------------------------------------- - * File : Core.h - * Created : 2018-03-02 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * UDP Core @@ -31,7 +28,7 @@ namespace rpu = rogue::protocols::udp; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -57,7 +54,7 @@ bool rpu::Core::setRxBufferCount(uint32_t count) { uint32_t per = (jumbo_) ? (JumboMTU) : (StdMTU); uint32_t size = count * per; - setsockopt(fd_, SOL_SOCKET, SO_RCVBUF, (char*)&size, sizeof(size)); + setsockopt(fd_, SOL_SOCKET, SO_RCVBUF, reinterpret_cast(&size), sizeof(size)); getsockopt(fd_, SOL_SOCKET, SO_RCVBUF, &rwin, &rwin_size); if (size > rwin) { diff --git a/src/rogue/protocols/udp/Server.cpp b/src/rogue/protocols/udp/Server.cpp index 03fec128a..5b201ce5d 100644 --- a/src/rogue/protocols/udp/Server.cpp +++ b/src/rogue/protocols/udp/Server.cpp @@ -1,9 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : UDP Server Class * ---------------------------------------------------------------------------- - * File : Server.h - * Created : 2018-03-02 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * UDP Server @@ -41,7 +38,7 @@ namespace rpu = rogue::protocols::udp; namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -174,12 +171,10 @@ void rpu::Server::acceptFrame(ris::FramePtr frame) { timeout_.tv_sec, timeout_.tv_usec); res = 0; - } else if ((res = sendmsg(fd_, &msg, 0)) < 0) + } else if ((res = sendmsg(fd_, &msg, 0)) < 0) { udpLog_->warning("UDP Write Call Failed"); - } - - // Continue while write result was zero - while (res == 0); + } + } while (res == 0); // Continue while write result was zero } } @@ -211,9 +206,9 @@ void rpu::Server::runThread(std::weak_ptr lockPtr) { if (res > 0) { // Message was too big - if (res > avail) + if (res > avail) { udpLog_->warning("Receive data was too large. Dropping."); - else { + } else { buff->setPayload(res); sendFrame(frame); } diff --git a/src/rogue/protocols/udp/module.cpp b/src/rogue/protocols/udp/module.cpp index 97e8f8558..f9dea7081 100644 --- a/src/rogue/protocols/udp/module.cpp +++ b/src/rogue/protocols/udp/module.cpp @@ -1,11 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module * ---------------------------------------------------------------------------- - * File : module.cpp - * Author : Ryan Herbst, rherbst@slac.stanford.edu - * Created : 2016-08-08 - * Last update: 2016-08-08 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/src/rogue/protocols/xilinx/CMakeLists.txt b/src/rogue/protocols/xilinx/CMakeLists.txt index 47c3a02ed..9b68ae6f0 100644 --- a/src/rogue/protocols/xilinx/CMakeLists.txt +++ b/src/rogue/protocols/xilinx/CMakeLists.txt @@ -1,8 +1,5 @@ # ---------------------------------------------------------------------------- -# Title : ROGUE CMAKE Control -# ---------------------------------------------------------------------------- -# File : src/rogue/CMakeLists.txt -# Created : 2018-02-27 +# Company : SLAC National Accelerator Laboratory # ---------------------------------------------------------------------------- # This file is part of the rogue software package. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/src/rogue/protocols/xilinx/JtagDriver.cpp b/src/rogue/protocols/xilinx/JtagDriver.cpp index 5db8816e2..28232cca3 100644 --- a/src/rogue/protocols/xilinx/JtagDriver.cpp +++ b/src/rogue/protocols/xilinx/JtagDriver.cpp @@ -1,18 +1,19 @@ -//----------------------------------------------------------------------------- -// Title : JTAG Support -//----------------------------------------------------------------------------- -// Company : SLAC National Accelerator Laboratory -//----------------------------------------------------------------------------- -// Description: JtagDriver.cpp -//----------------------------------------------------------------------------- -// This file is part of 'SLAC Firmware Standard Library'. -// It is subject to the license terms in the LICENSE.txt file found in the -// top-level directory of this distribution and at: -// https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. -// No part of 'SLAC Firmware Standard Library', including this file, -// may be copied, modified, propagated, or distributed except according to -// the terms contained in the LICENSE.txt file. -//----------------------------------------------------------------------------- +/** + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- + * Description: + * JtagDriver.cpp + * ---------------------------------------------------------------------------- + * This file is part of the rogue software platform. It is subject to + * the license terms in the LICENSE.txt file found in the top-level directory + * of this distribution and at: + * https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. + * No part of the rogue software platform, including this file, may be + * copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE.txt file. + * ---------------------------------------------------------------------------- + **/ #include "rogue/Directives.h" @@ -30,7 +31,7 @@ namespace rpx = rogue::protocols::xilinx; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -82,7 +83,7 @@ unsigned rpx::JtagDriver::getErr(Header x) { return (x & ERR_MASK) >> ERR_SHIFT; } -unsigned long rpx::JtagDriver::getLen(Header x) { +uint64_t rpx::JtagDriver::getLen(Header x) { if (getCmd(x) != CMD_S) throw( rogue::GeneralError::create("JtagDriver::getLen()", "Cannot extract length from non-shift command header")); @@ -129,9 +130,11 @@ uint32_t rpx::JtagDriver::cvtPerNs(Header reply) { unsigned rawVal = (reply >> XID_SHIFT) & 0xff; double tmp; - if (0 == rawVal) { return UNKNOWN_PERIOD; } + if (0 == rawVal) { + return UNKNOWN_PERIOD; + } - tmp = ((double)rawVal) * 4.0 / 256.0; + tmp = static_cast(rawVal) * 4.0 / 256.0; return (uint32_t)round(pow(10.0, tmp) * 1.0E9 / REF_FREQ_HZ()); } @@ -147,7 +150,9 @@ unsigned rpx::JtagDriver::getMemDepth() { rpx::JtagDriver::Header rpx::JtagDriver::getHdr(uint8_t* buf) { Header hdr; memcpy(&hdr, buf, sizeof(hdr)); - if (!isLE()) { hdr = ntohl(hdr); } + if (!isLE()) { + hdr = ntohl(hdr); + } return hdr; } @@ -197,7 +202,9 @@ int rpx::JtagDriver::xferRel(uint8_t* txb, unsigned txBytes, Header* phdr, uint8 throw(rogue::GeneralError::create("JtagDriver::xferRel()", "Protocol error")); } if (xid == XID_ANY || xid == getXid(hdr)) { - if (phdr) { *phdr = hdr; } + if (phdr) { + *phdr = hdr; + } return got; } } catch (rogue::GeneralError&) {} @@ -207,7 +214,7 @@ int rpx::JtagDriver::xferRel(uint8_t* txb, unsigned txBytes, Header* phdr, uint8 return (0); } -unsigned long rpx::JtagDriver::query() { +uint64_t rpx::JtagDriver::query() { Header hdr; unsigned siz; @@ -228,7 +235,7 @@ unsigned long rpx::JtagDriver::query() { log_->debug("Query result: wordSize %" PRId32 ", memDepth %" PRId32 ", period %l" PRId32 "ns\n", wordSize_, memDepth_, - (unsigned long)periodNs_); + (uint64_t)periodNs_); if (0 == memDepth_) retry_ = 0; @@ -255,9 +262,9 @@ uint32_t rpx::JtagDriver::setPeriodNs(uint32_t requestedPeriod) { return UNKNOWN_PERIOD == currentPeriod ? requestedPeriod : currentPeriod; } -void rpx::JtagDriver::sendVectors(unsigned long bits, uint8_t* tms, uint8_t* tdi, uint8_t* tdo) { +void rpx::JtagDriver::sendVectors(uint64_t bits, uint8_t* tms, uint8_t* tdi, uint8_t* tdo) { unsigned wsz = getWordSize(); - unsigned long bytesCeil = (bits + 8 - 1) / 8; + uint64_t bytesCeil = (bits + 8 - 1) / 8; unsigned wholeWords = bytesCeil / wsz; unsigned wholeWordBytes = wholeWords * wsz; unsigned wordCeilBytes = ((bytesCeil + wsz - 1) / wsz) * wsz; @@ -292,7 +299,7 @@ void rpx::JtagDriver::dumpInfo(FILE* f) { fprintf(f, "Word size: %d\n", getWordSize()); fprintf(f, "Target Memory Depth (bytes) %d\n", getWordSize() * getMemDepth()); fprintf(f, "Max. Vector Length (bytes) %ld\n", getMaxVectorSize()); - fprintf(f, "TCK Period (ns) %ld\n", (unsigned long)getPeriodNs()); + fprintf(f, "TCK Period (ns) %ld\n", (uint64_t)getPeriodNs()); } void rpx::JtagDriver::setup_python() { diff --git a/src/rogue/protocols/xilinx/Xvc.cpp b/src/rogue/protocols/xilinx/Xvc.cpp index 35259cf5b..b56545f59 100644 --- a/src/rogue/protocols/xilinx/Xvc.cpp +++ b/src/rogue/protocols/xilinx/Xvc.cpp @@ -1,10 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : XVC Server Wrapper Class * ---------------------------------------------------------------------------- - * File : Xvc.h - * Created : 2022-03-23 - * Last update: 2022-03-23 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * XVC Server Wrapper Class @@ -41,7 +37,7 @@ namespace rpx = rogue::protocols::xilinx; namespace ris = rogue::interfaces::stream; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -121,9 +117,9 @@ void rpx::Xvc::acceptFrame(ris::FramePtr frame) { // All we need to do is ensure that as soon as the new frame comes in, it's stored in the queue. } -unsigned long rpx::Xvc::getMaxVectorSize() { +uint64_t rpx::Xvc::getMaxVectorSize() { // MTU lim; 2*vector size + header must fit! - unsigned long mtuLim = (mtu_ - getWordSize()) / 2; + uint64_t mtuLim = (mtu_ - getWordSize()) / 2; return mtuLim; } diff --git a/src/rogue/protocols/xilinx/XvcConnection.cpp b/src/rogue/protocols/xilinx/XvcConnection.cpp index c534bc16a..b69458794 100644 --- a/src/rogue/protocols/xilinx/XvcConnection.cpp +++ b/src/rogue/protocols/xilinx/XvcConnection.cpp @@ -1,18 +1,19 @@ -//----------------------------------------------------------------------------- -// Title : JTAG Support -//----------------------------------------------------------------------------- -// Company : SLAC National Accelerator Laboratory -//----------------------------------------------------------------------------- -// Description: -//----------------------------------------------------------------------------- -// This file is part of 'SLAC Firmware Standard Library'. -// It is subject to the license terms in the LICENSE.txt file found in the -// top-level directory of this distribution and at: -// https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. -// No part of 'SLAC Firmware Standard Library', including this file, -// may be copied, modified, propagated, or distributed except according to -// the terms contained in the LICENSE.txt file. -//----------------------------------------------------------------------------- +/** + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- + * Description: + * JTAG support + * ---------------------------------------------------------------------------- + * This file is part of the rogue software platform. It is subject to + * the license terms in the LICENSE.txt file found in the top-level directory + * of this distribution and at: + * https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. + * No part of the rogue software platform, including this file, may be + * copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE.txt file. + * ---------------------------------------------------------------------------- + **/ #include "rogue/protocols/xilinx/XvcConnection.h" @@ -22,7 +23,7 @@ namespace rpx = rogue::protocols::xilinx; -rpx::XvcConnection::XvcConnection(int sd, JtagDriver* drv, unsigned long maxVecLen) +rpx::XvcConnection::XvcConnection(int sd, JtagDriver* drv, uint64_t maxVecLen) : drv_(drv), maxVecLen_(maxVecLen), supVecLen_(0) { @@ -67,10 +68,10 @@ ssize_t rpx::XvcConnection::readTo(void* buf, size_t count) { } // fill rx buffer to 'n' octets -void rpx::XvcConnection::fill(unsigned long n) { +void rpx::XvcConnection::fill(uint64_t n) { uint8_t* p = rp_ + rl_; int got; - unsigned long k = n; + uint64_t k = n; if (n <= rl_) return; @@ -87,15 +88,17 @@ void rpx::XvcConnection::fill(unsigned long n) { } // mark 'n' octets as 'consumed' -void rpx::XvcConnection::bump(unsigned long n) { +void rpx::XvcConnection::bump(uint64_t n) { rp_ += n; rl_ -= n; - if (rl_ == 0) { rp_ = &rxb_[0]; } + if (rl_ == 0) { + rp_ = &rxb_[0]; + } } void rpx::XvcConnection::allocBufs() { - unsigned long tgtVecLen; - unsigned long overhead = 128; // headers and such; + uint64_t tgtVecLen; + uint64_t overhead = 128; // headers and such; // Determine the vector size supported by the target tgtVecLen = drv_->query(); @@ -142,9 +145,9 @@ void rpx::XvcConnection::flush() { void rpx::XvcConnection::run() { int got; uint32_t bits, bitsLeft, bitsSent; - unsigned long bytes; - unsigned long vecLen; - unsigned long off; + uint64_t bytes; + uint64_t vecLen; + uint64_t off; allocBufs(); @@ -164,7 +167,7 @@ void rpx::XvcConnection::run() { drv_->query(); // informs the driver that there is a new connection - tl_ = sprintf((char*)&txb_[0], "xvcServer_v1.0:%ld\n", maxVecLen_); + tl_ = snprintf(reinterpret_cast(&txb_[0]), sizeof(txb_), "xvcServer_v1.0:%ld\n", maxVecLen_); bump(8); } else if (0 == ::memcmp(rp_, "se", 2)) { @@ -189,7 +192,9 @@ void rpx::XvcConnection::run() { fill(10); bits = 0; - for (got = 9; got >= 6; got--) { bits = (bits << 8) | rp_[got]; } + for (got = 9; got >= 6; got--) { + bits = (bits << 8) | rp_[got]; + } bytes = (bits + 7) / 8; if (bytes > maxVecLen_) @@ -206,16 +211,18 @@ void rpx::XvcConnection::run() { // bother...). for (off = 0, bitsLeft = bits; bitsLeft > 0; bitsLeft -= bitsSent, off += vecLen) { bitsSent = 8 * vecLen; - if (bitsLeft < bitsSent) { bitsSent = bitsLeft; } + if (bitsLeft < bitsSent) { + bitsSent = bitsLeft; + } drv_->sendVectors(bitsSent, rp_ + off, rp_ + bytes + off, &txb_[0] + off); } tl_ = bytes; bump(2 * bytes); - } else + } else { throw(rogue::GeneralError::create("XvcConnection::run()", "Unsupported message received")); - + } flush(); /* Repeat until all the characters from the first chunk are exhausted* (most likely the chunk just contained diff --git a/src/rogue/protocols/xilinx/XvcServer.cpp b/src/rogue/protocols/xilinx/XvcServer.cpp index 357c80457..b7c8bca86 100644 --- a/src/rogue/protocols/xilinx/XvcServer.cpp +++ b/src/rogue/protocols/xilinx/XvcServer.cpp @@ -1,18 +1,19 @@ -//----------------------------------------------------------------------------- -// Title : JTAG Support -//----------------------------------------------------------------------------- -// Company : SLAC National Accelerator Laboratory -//----------------------------------------------------------------------------- -// Description: -//----------------------------------------------------------------------------- -// This file is part of 'SLAC Firmware Standard Library'. -// It is subject to the license terms in the LICENSE.txt file found in the -// top-level directory of this distribution and at: -// https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. -// No part of 'SLAC Firmware Standard Library', including this file, -// may be copied, modified, propagated, or distributed except according to -// the terms contained in the LICENSE.txt file. -//----------------------------------------------------------------------------- +/** + * ---------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- + * Description: + * + * ---------------------------------------------------------------------------- + * This file is part of the rogue software platform. It is subject to + * the license terms in the LICENSE.txt file found in the top-level directory + * of this distribution and at: + * https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. + * No part of the rogue software platform, including this file, may be + * copied, modified, propagated, or distributed except according to the terms + * contained in the LICENSE.txt file. + * ---------------------------------------------------------------------------- + **/ #include "rogue/protocols/xilinx/XvcServer.h" @@ -74,7 +75,9 @@ void rpx::XvcServer::run(bool& threadEn, rogue::LoggingPtr log) { try { XvcConnection conn(sd_, drv_, maxMsgSize_); conn.run(); - } catch (rogue::GeneralError& e) { log->debug("Sub-connection failed"); } + } catch (rogue::GeneralError& e) { + log->debug("Sub-connection failed"); + } } } } diff --git a/src/rogue/protocols/xilinx/module.cpp b/src/rogue/protocols/xilinx/module.cpp index aecdb9701..c83741c49 100644 --- a/src/rogue/protocols/xilinx/module.cpp +++ b/src/rogue/protocols/xilinx/module.cpp @@ -1,11 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module * ---------------------------------------------------------------------------- - * File : module.cpp - * Author : Ryan Herbst, rherbst@slac.stanford.edu - * Created : 2016-08-08 - * Last update: 2016-08-08 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/src/rogue/utilities/CMakeLists.txt b/src/rogue/utilities/CMakeLists.txt index 321bd6294..4d317906c 100644 --- a/src/rogue/utilities/CMakeLists.txt +++ b/src/rogue/utilities/CMakeLists.txt @@ -1,8 +1,5 @@ # ---------------------------------------------------------------------------- -# Title : ROGUE CMAKE Control -# ---------------------------------------------------------------------------- -# File : src/rogue/utilities/CMakeLists.txt -# Created : 2018-02-27 +#Company : SLAC National Accelerator Laboratory # ---------------------------------------------------------------------------- # This file is part of the rogue software package. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/src/rogue/utilities/Prbs.cpp b/src/rogue/utilities/Prbs.cpp index ed25b97e7..45dceffdd 100644 --- a/src/rogue/utilities/Prbs.cpp +++ b/src/rogue/utilities/Prbs.cpp @@ -1,12 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : PRBS Receive And Transmit Class * ---------------------------------------------------------------------------- - * File : Prbs.cpp - * Author : Ryan Herbst - * Created : 09/17/2016 - * Last update : 09/17/2016 - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * Class used to generate and receive PRBS test data. *----------------------------------------------------------------------------- @@ -45,7 +40,7 @@ namespace ris = rogue::interfaces::stream; namespace ru = rogue::utilities; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -81,7 +76,7 @@ ru::Prbs::Prbs() { // Init 4 taps tapCnt_ = 4; - taps_ = (uint8_t*)malloc(sizeof(uint8_t) * tapCnt_); + taps_ = reinterpret_cast(malloc(sizeof(uint8_t) * tapCnt_)); taps_[0] = 1; taps_[1] = 2; taps_[2] = 6; @@ -121,11 +116,11 @@ double ru::Prbs::updateTime(struct timeval* last) { timersub(&now, last, &per); if (timercmp(&per, &cmp, >)) { - ret = (float)per.tv_sec + (float(per.tv_usec) / 1e6); + ret = static_cast(per.tv_sec) + static_cast(per.tv_usec) / 1e6; gettimeofday(last, NULL); - } else + } else { ret = 0.0; - + } return ret; } @@ -149,7 +144,7 @@ void ru::Prbs::setTaps(uint32_t tapCnt, uint8_t* taps) { free(taps_); tapCnt_ = tapCnt; - taps_ = (uint8_t*)malloc(sizeof(uint8_t) * tapCnt); + taps_ = reinterpret_cast(malloc(sizeof(uint8_t) * tapCnt)); for (i = 0; i < tapCnt_; i++) taps_[i] = taps[i]; } @@ -163,7 +158,7 @@ void ru::Prbs::setTapsPy(boost::python::object p) { if (PyObject_GetBuffer(p.ptr(), &pyBuf, PyBUF_SIMPLE) < 0) throw(rogue::GeneralError("Prbs::setTapsPy", "Python Buffer Error")); - setTaps(pyBuf.len, (uint8_t*)pyBuf.buf); + setTaps(pyBuf.len, reinterpret_cast(pyBuf.buf)); PyBuffer_Release(&pyBuf); } @@ -202,7 +197,9 @@ void ru::Prbs::flfsr(uint8_t* data) { void ru::Prbs::runThread() { txLog_->logThreadId(); - while (threadEn_) { genFrame(txSize_); } + while (threadEn_) { + genFrame(txSize_); + } } //! Auto run data generation @@ -369,9 +366,9 @@ void ru::Prbs::genFrame(uint32_t size) { // Generate payload while (frIter != frEnd) { - if (sendCount_) + if (sendCount_) { ris::toFrame(frIter, byteWidth_, wCount); - else { + } else { flfsr(data); ris::toFrame(frIter, byteWidth_, data); } @@ -387,8 +384,8 @@ void ru::Prbs::genFrame(uint32_t size) { txBytes_ += size; if ((per = updateTime(&lastTxTime_)) > 0.0) { - txRate_ = (float)(txCount_ - lastTxCount_) / per; - txBw_ = (float)(txBytes_ - lastTxBytes_) / per; + txRate_ = static_cast(txCount_ - lastTxCount_) / per; + txBw_ = static_cast(txBytes_ - lastTxBytes_) / per; lastTxCount_ = txCount_; lastTxBytes_ = txBytes_; } @@ -412,7 +409,7 @@ void ru::Prbs::acceptFrame(ris::FramePtr frame) { rogue::GilRelease noGil; - while (not rxEnable_) usleep(10000); + while (!rxEnable_) usleep(10000); ris::FrameLockPtr fLock = frame->lock(); std::lock_guard lock(pMtx_); @@ -471,19 +468,22 @@ void ru::Prbs::acceptFrame(ris::FramePtr frame) { flfsr(expData); if (!std::equal(frIter, frIter + byteWidth_, expData)) { - sprintf(debugA, - "Bad value at index %" PRIu32 ". count=%" PRIu32 ", size=%" PRIu32, - pos, - rxCount_, - (size / byteWidth_) - 1); + snprintf(debugA, + sizeof(debugA), + "Bad value at index %" PRIu32 ". count=%" PRIu32 ", size=%" PRIu32, + pos, + rxCount_, + (size / byteWidth_) - 1); + for (x = 0; x < byteWidth_; x++) { - sprintf(debugB, - "\n %" PRIu32 ":%" PRIu32 " Got=0x%" PRIx8 " Exp=0x%" PRIx8, - pos, - x, - *(frIter + x), - *(expData + x)); - strcat(debugA, debugB); + snprintf(debugB, + sizeof(debugB), + "\n %" PRIu32 ":%" PRIu32 " Got=0x%" PRIx8 " Exp=0x%" PRIx8, + pos, + x, + *(frIter + x), + *(expData + x)); + snprintf(debugA + strlen(debugA), sizeof(debugA) - strlen(debugA), "%s", debugB); } rxLog_->warning(debugA); rxErrCount_++; @@ -498,8 +498,8 @@ void ru::Prbs::acceptFrame(ris::FramePtr frame) { rxBytes_ += size; if ((per = updateTime(&lastRxTime_)) > 0.0) { - rxRate_ = (float)(rxCount_ - lastRxCount_) / per; - rxBw_ = (float)(rxBytes_ - lastRxBytes_) / per; + rxRate_ = static_cast(rxCount_ - lastRxCount_) / per; + rxBw_ = static_cast(rxBytes_ - lastRxBytes_) / per; lastRxCount_ = rxCount_; lastRxBytes_ = rxBytes_; } diff --git a/src/rogue/utilities/StreamUnZip.cpp b/src/rogue/utilities/StreamUnZip.cpp index f8afb7715..af01e1cec 100644 --- a/src/rogue/utilities/StreamUnZip.cpp +++ b/src/rogue/utilities/StreamUnZip.cpp @@ -1,9 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : Rogue stream decompressor * ---------------------------------------------------------------------------- - * File : StreamUnZip.cpp - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * Stream modules to decompress a data stream *----------------------------------------------------------------------------- @@ -39,7 +37,7 @@ namespace ris = rogue::interfaces::stream; namespace ru = rogue::utilities; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -80,11 +78,11 @@ void ru::StreamUnZip::acceptFrame(ris::FramePtr frame) { // Setup decompression pointers rBuff = frame->beginBuffer(); - strm.next_in = (char*)(*rBuff)->begin(); + strm.next_in = reinterpret_cast((*rBuff)->begin()); strm.avail_in = (*rBuff)->getPayload(); wBuff = newFrame->beginBuffer(); - strm.next_out = (char*)(*wBuff)->begin(); + strm.next_out = reinterpret_cast((*wBuff)->begin()); strm.avail_out = (*wBuff)->getAvailable(); // Use the iterators to move data @@ -99,7 +97,7 @@ void ru::StreamUnZip::acceptFrame(ris::FramePtr frame) { // Update read buffer if necessary if (strm.avail_in == 0) { ++rBuff; - strm.next_in = (char*)(*rBuff)->begin(); + strm.next_in = reinterpret_cast((*rBuff)->begin()); strm.avail_in = (*rBuff)->getPayload(); } @@ -109,10 +107,10 @@ void ru::StreamUnZip::acceptFrame(ris::FramePtr frame) { if ((wBuff + 1) == newFrame->endBuffer()) { ris::FramePtr tmpFrame = this->reqFrame(frame->getPayload(), true); wBuff = newFrame->appendFrame(tmpFrame); - } else + } else { ++wBuff; - - strm.next_out = (char*)(*wBuff)->begin(); + } + strm.next_out = reinterpret_cast((*wBuff)->begin()); strm.avail_out = (*wBuff)->getAvailable(); } } while (1); diff --git a/src/rogue/utilities/StreamZip.cpp b/src/rogue/utilities/StreamZip.cpp index f81509178..994709e52 100644 --- a/src/rogue/utilities/StreamZip.cpp +++ b/src/rogue/utilities/StreamZip.cpp @@ -1,9 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : Rogue stream compressor * ---------------------------------------------------------------------------- - * File : StreamZip.cpp - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * Stream modules to compress a data stream *----------------------------------------------------------------------------- @@ -39,7 +37,7 @@ namespace ris = rogue::interfaces::stream; namespace ru = rogue::utilities; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -80,11 +78,11 @@ void ru::StreamZip::acceptFrame(ris::FramePtr frame) { // Setup decompression pointers rBuff = frame->beginBuffer(); - strm.next_in = (char*)(*rBuff)->begin(); + strm.next_in = reinterpret_cast((*rBuff)->begin()); strm.avail_in = (*rBuff)->getPayload(); wBuff = newFrame->beginBuffer(); - strm.next_out = (char*)(*wBuff)->begin(); + strm.next_out = reinterpret_cast((*wBuff)->begin()); strm.avail_out = (*wBuff)->getAvailable(); // Use the iterators to move data @@ -96,10 +94,11 @@ void ru::StreamZip::acceptFrame(ris::FramePtr frame) { // Update read buffer if necessary if (strm.avail_in == 0 && (!done)) { if (++rBuff != frame->endBuffer()) { - strm.next_in = (char*)(*rBuff)->begin(); + strm.next_in = reinterpret_cast((*rBuff)->begin()); strm.avail_in = (*rBuff)->getPayload(); - } else + } else { done = true; + } } // Update write buffer if necessary @@ -108,10 +107,10 @@ void ru::StreamZip::acceptFrame(ris::FramePtr frame) { if ((wBuff + 1) == newFrame->endBuffer()) { ris::FramePtr tmpFrame = this->reqFrame(frame->getPayload(), true); wBuff = newFrame->appendFrame(tmpFrame); - } else + } else { ++wBuff; - - strm.next_out = (char*)(*wBuff)->begin(); + } + strm.next_out = reinterpret_cast((*wBuff)->begin()); strm.avail_out = (*wBuff)->getAvailable(); } } while (ret != BZ_STREAM_END); diff --git a/src/rogue/utilities/fileio/CMakeLists.txt b/src/rogue/utilities/fileio/CMakeLists.txt index 91b118690..d7dd8195f 100644 --- a/src/rogue/utilities/fileio/CMakeLists.txt +++ b/src/rogue/utilities/fileio/CMakeLists.txt @@ -1,8 +1,5 @@ # ---------------------------------------------------------------------------- -# Title : ROGUE CMAKE Control -# ---------------------------------------------------------------------------- -# File : src/rogue/utilities/fileio/CMakeLists.txt -# Created : 2018-02-27 +# Company : SLAC National Accelerator Laboratory # ---------------------------------------------------------------------------- # This file is part of the rogue software package. It is subject to # the license terms in the LICENSE.txt file found in the top-level directory diff --git a/src/rogue/utilities/fileio/LegacyStreamReader.cpp b/src/rogue/utilities/fileio/LegacyStreamReader.cpp index 62c163105..b2ed5ebff 100644 --- a/src/rogue/utilities/fileio/LegacyStreamReader.cpp +++ b/src/rogue/utilities/fileio/LegacyStreamReader.cpp @@ -1,9 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : Data file reader utility. * ---------------------------------------------------------------------------- - * File : LegacyStreamReader.cpp - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * Class to read data files generated using LegacyFileWriter *----------------------------------------------------------------------------- @@ -41,7 +39,7 @@ namespace ris = rogue::interfaces::stream; namespace ruf = rogue::utilities::fileio; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -112,9 +110,9 @@ bool ruf::LegacyStreamReader::nextFile() { if (fd_ >= 0) { ::close(fd_); fd_ = -1; - } else + } else { return (false); - + } if (fdIdx_ == 0) return (false); fdIdx_++; @@ -178,7 +176,9 @@ void ruf::LegacyStreamReader::runThread() { size = header & 0x0FFFFFFF; chan = header >> 28; - if (chan == 0) { size = size * 4; } + if (chan == 0) { + size = size * 4; + } // cout << "Frame with size" << size << "and channel" << chan; log.info("Got frame with header %" PRIx32 ", size %" PRIu32 " and channel %" PRIu8, header, size, chan); diff --git a/src/rogue/utilities/fileio/LegacyStreamWriter.cpp b/src/rogue/utilities/fileio/LegacyStreamWriter.cpp index 059043d92..0cb59b6ed 100644 --- a/src/rogue/utilities/fileio/LegacyStreamWriter.cpp +++ b/src/rogue/utilities/fileio/LegacyStreamWriter.cpp @@ -1,12 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : Data file writer utility. * ---------------------------------------------------------------------------- - * File : LegacyStreamWriter.cpp - * Author : Ryan Herbst - * Created : 09/28/2016 - * Last update : 09/28/2016 - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * Class to coordinate data file writing. * This class supports multiple stream slaves, each with the ability to @@ -55,7 +50,7 @@ namespace ris = rogue::interfaces::stream; namespace ruf = rogue::utilities::fileio; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -101,7 +96,7 @@ void ruf::LegacyStreamWriter::writeFile(uint8_t channel, std::shared_ptrgetPayload() == 0) return; - if (channel != RawData and channel != YamlData) { + if (channel != RawData && channel != YamlData) { throw(rogue::GeneralError("LegacyStreamWriter::writeFile", "Invalid channel")); } diff --git a/src/rogue/utilities/fileio/StreamReader.cpp b/src/rogue/utilities/fileio/StreamReader.cpp index c612992e6..40e15c1c5 100644 --- a/src/rogue/utilities/fileio/StreamReader.cpp +++ b/src/rogue/utilities/fileio/StreamReader.cpp @@ -1,12 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : Data file reader utility. * ---------------------------------------------------------------------------- - * File : StreamReader.cpp - * Author : Ryan Herbst - * Created : 09/28/2016 - * Last update : 09/28/2016 - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * Class to read data files. *----------------------------------------------------------------------------- @@ -42,7 +37,7 @@ namespace ris = rogue::interfaces::stream; namespace ruf = rogue::utilities::fileio; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -113,9 +108,9 @@ bool ruf::StreamReader::nextFile() { if (fd_ >= 0) { ::close(fd_); fd_ = -1; - } else + } else { return (false); - + } if (fdIdx_ == 0) return (false); fdIdx_++; diff --git a/src/rogue/utilities/fileio/StreamWriter.cpp b/src/rogue/utilities/fileio/StreamWriter.cpp index 955a73596..230c27570 100644 --- a/src/rogue/utilities/fileio/StreamWriter.cpp +++ b/src/rogue/utilities/fileio/StreamWriter.cpp @@ -1,12 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : Data file writer utility. * ---------------------------------------------------------------------------- - * File : StreamWriter.h - * Author : Ryan Herbst - * Created : 09/28/2016 - * Last update : 09/28/2016 - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * Class to coordinate data file writing. * This class supports multiple stream slaves, each with the ability to @@ -58,7 +53,7 @@ namespace ris = rogue::interfaces::stream; namespace ruf = rogue::utilities::fileio; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif @@ -177,7 +172,7 @@ void ruf::StreamWriter::setBufferSize(uint32_t size) { // Buffer is enabled if (size != 0) { // Create new buffer - if ((buffer_ = (uint8_t*)malloc(size)) == NULL) + if ((buffer_ = reinterpret_cast(malloc(size))) == NULL) throw(rogue::GeneralError::create("StreamWriter::setBufferSize", "Failed to allocate buffer with size = %" PRIu32, size)); @@ -311,10 +306,8 @@ void ruf::StreamWriter::intWrite(void* data, uint32_t size) { } currSize_ += size; totSize_ += size; - } - - // Append to buffer if non zero - else if (buffSize_ > 0 && size > 0) { + // Append to buffer if non zero + } else if (buffSize_ > 0 && size > 0) { std::memcpy(buffer_ + currBuffer_, data, size); currBuffer_ += size; } diff --git a/src/rogue/utilities/fileio/StreamWriterChannel.cpp b/src/rogue/utilities/fileio/StreamWriterChannel.cpp index dcc7e3019..9b646bd05 100644 --- a/src/rogue/utilities/fileio/StreamWriterChannel.cpp +++ b/src/rogue/utilities/fileio/StreamWriterChannel.cpp @@ -1,12 +1,7 @@ /** - *----------------------------------------------------------------------------- - * Title : Data file writer utility. Channel interface. * ---------------------------------------------------------------------------- - * File : StreamWriterChannel.cpp - * Author : Ryan Herbst - * Created : 09/28/2016 - * Last update : 09/28/2016 - *----------------------------------------------------------------------------- + * Company : SLAC National Accelerator Laboratory + * ---------------------------------------------------------------------------- * Description : * Class to act as a slave interface to the StreamWriterChannel. Each * slave is associated with a tag. The tag is included in the bank header @@ -40,7 +35,7 @@ namespace ris = rogue::interfaces::stream; namespace ruf = rogue::utilities::fileio; #ifndef NO_PYTHON -#include + #include namespace bp = boost::python; #endif diff --git a/src/rogue/utilities/fileio/module.cpp b/src/rogue/utilities/fileio/module.cpp index 03655a773..9d1550874 100644 --- a/src/rogue/utilities/fileio/module.cpp +++ b/src/rogue/utilities/fileio/module.cpp @@ -1,14 +1,9 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module For Stream Interface * ---------------------------------------------------------------------------- - * File : module.cpp - * Author : Ryan Herbst, rherbst@slac.stanford.edu - * Created : 2016-08-08 - * Last update: 2016-08-08 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: - * Python module setup + * Python Module For Stream Interface * ---------------------------------------------------------------------------- * This file is part of the rogue software platform. It is subject to * the license terms in the LICENSE.txt file found in the top-level directory diff --git a/src/rogue/utilities/module.cpp b/src/rogue/utilities/module.cpp index b962b2a54..b5efc6e16 100644 --- a/src/rogue/utilities/module.cpp +++ b/src/rogue/utilities/module.cpp @@ -1,11 +1,6 @@ /** - *----------------------------------------------------------------------------- - * Title : Python Module For Stream Interface * ---------------------------------------------------------------------------- - * File : module.cpp - * Author : Ryan Herbst, rherbst@slac.stanford.edu - * Created : 2016-08-08 - * Last update: 2016-08-08 + * Company : SLAC National Accelerator Laboratory * ---------------------------------------------------------------------------- * Description: * Python module setup diff --git a/templates/RogueConfig.cmake.in b/templates/RogueConfig.cmake.in index e7f902ad1..6d891b227 100644 --- a/templates/RogueConfig.cmake.in +++ b/templates/RogueConfig.cmake.in @@ -26,8 +26,10 @@ set(NO_PYTHON @NO_PYTHON@) # Boost + Python ##################################### if ( NOT NO_PYTHON ) - find_package(PythonInterp 3 QUIET REQUIRED) - find_package(PythonLibs 3 QUIET REQUIRED) + + # Find newest python interpreter first + set(Python3_FIND_STRATEGY "LOCATION") + find_package(Python3 QUIET REQUIRED COMPONENTS Interpreter Development) # Find Numpy execute_process( @@ -47,21 +49,17 @@ if ( NOT NO_PYTHON ) # Hint for boost on anaconda if (DEFINED ENV{CONDA_PREFIX}) - set(BOOST_ROOT $ENV{CONDA_PREFIX}) - - # SLAC AFS custom path - elseif (DEFINED ENV{BOOST_PATH}) - set(BOOST_ROOT $ENV{BOOST_PATH}) + set(Boost_ROOT $ENV{CONDA_PREFIX}) endif() # libboost_python3.7 style libraries - message("Looking for libboost_python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}") - FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}) + message("Looking for libboost_python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}") + FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}) # libboost_python3 style libraries if (NOT Boost_FOUND) - message("Looking for libboost_python${PYTHON_VERSION_MAJOR}") - FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python${PYTHON_VERSION_MAJOR}) + message("Looking for libboost_python${Python3_VERSION_MAJOR}") + FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python${Python3_VERSION_MAJOR}) endif() # libboost_python style libraries @@ -72,14 +70,14 @@ if ( NOT NO_PYTHON ) # libboost_python-py37 style libraries if (NOT Boost_FOUND) - message("Looking for libboost_python-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}") - FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}) + message("Looking for libboost_python-py${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}") + FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python-py${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}) endif() # libboost_python3-py37 style libraries if (NOT Boost_FOUND) - message("Looking for libboost_python3-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}") - FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python3-py${PYTHON_VERSION_MAJOR}${PYTHON_VERSION_MINOR}) + message("Looking for libboost_python3-py${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}") + FIND_PACKAGE(Boost 1.58 QUIET COMPONENTS python3-py${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR}) endif() # Nothing worked @@ -87,6 +85,7 @@ if ( NOT NO_PYTHON ) message("") message(FATAL_ERROR "Failed to find boost libraries!") endif() + else() add_definitions( -DNO_PYTHON ) endif() @@ -145,8 +144,8 @@ endif() # These variables are now defined # ${Boost_INCLUDE_DIRS} # ${Boost_LIBRARIES} -# ${PYTHON_INCLUDE_DIRS} -# ${PYTHON_LIBRARIES} +# ${Python3_INCLUDE_DIRS} +# ${Python3_LIBRARIES} # ${ZeroMQ_INCLUDE_DIR} # ${ZeroMQ_LIBRARY} # ${BZIP2_INCLUDE_DIR} @@ -163,7 +162,7 @@ set(ROGUE_LIBRARIES_ONLY @CONF_LIBRARIES@) # Rogue Include paths set(ROGUE_INCLUDE_DIRS @CONF_INCLUDE_DIRS@ ${Boost_INCLUDE_DIRS} - ${PYTHON_INCLUDE_DIRS} + ${Python3_INCLUDE_DIRS} ${Python3_NumPy_INCLUDE_DIRS} ${ZeroMQ_INCLUDE_DIR} ${BZIP2_INCLUDE_DIR} @@ -172,7 +171,7 @@ set(ROGUE_INCLUDE_DIRS @CONF_INCLUDE_DIRS@ # Rogue libraries set(ROGUE_LIBRARIES @CONF_LIBRARIES@ ${Boost_LIBRARIES} - ${PYTHON_LIBRARIES} + ${Python3_LIBRARIES} ${ZeroMQ_LIBRARY} ${BZIP2_LIBRARIES} ${EPICS_LIBRARIES}) @@ -200,7 +199,7 @@ else() message("-- Found boost: ${Boost_INCLUDE_DIRS}") message("-- Found boost: ${Boost_LIBRARIES}") message("") - message("-- Found python: ${PYTHON_LIBRARIES}") + message("-- Found python: ${Python3_LIBRARIES}") message("-- Found numpy: ${Python3_NumPy_INCLUDE_DIRS}") endif() diff --git a/tests/.gitignore b/tests/.gitignore new file mode 100644 index 000000000..1cda54be9 --- /dev/null +++ b/tests/.gitignore @@ -0,0 +1 @@ +*.yml diff --git a/tests/api_test/src/api_test.cpp b/tests/api_test/src/api_test.cpp index 6cfbb78d6..2f1fb9f70 100644 --- a/tests/api_test/src/api_test.cpp +++ b/tests/api_test/src/api_test.cpp @@ -9,7 +9,7 @@ * ---------------------------------------------------------------------------- **/ -#include +#include "rogue/interfaces/api/Bsp.h" void varListener(std::string path, std::string value) { printf("Var Listener: %s = %s\n", path.c_str(), value.c_str()); @@ -20,42 +20,40 @@ void varDone() { } int main(int argc, char** argv) { - try { - - rogue::interfaces::api::Bsp bsp("pyrogue.examples", "ExampleRoot"); - bsp.addVarListener(&varListener, &varDone); - - // Get running uptime clock - printf("LocalTime = %s\n", bsp["LocalTime"].get().c_str()); - - // Set and get scratchpad - bsp["AxiVersion"]["ScratchPad"].setWrite("0x1111"); - printf("ScratchPad = %s\n", bsp["AxiVersion"]["ScratchPad"].readGet().c_str()); - - // Get object as a pointer using full path, and get scratchpad - printf("ScratchPad = %s\n", bsp.getNode("ExampleRoot.AxiVersion.ScratchPad")->get().c_str()); - - // Get yaml config - std::string cfg = bsp["GetYamlConfig"]("True"); - printf("Config = %s\n", cfg.c_str()); - - // Set yaml config, example - // bsp["SetYamlConfig"]("Some Yaml String"); - - // Write Entrire Tree - bsp["WriteAll"](); - - // Read Entrire Tree - bsp["ReadAll"](); - - Py_BEGIN_ALLOW_THREADS; - sleep(60); - Py_END_ALLOW_THREADS; - - } catch (...) { - fprintf(stderr, "Found error running API example:\n"); - PyErr_Print(); - return -1; - } - return 0; + try { + rogue::interfaces::api::Bsp bsp("pyrogue.examples", "ExampleRoot"); + bsp.addVarListener(&varListener, &varDone); + + // Get running uptime clock + printf("LocalTime = %s\n", bsp["LocalTime"].get().c_str()); + + // Set and get scratchpad + bsp["AxiVersion"]["ScratchPad"].setWrite("0x1111"); + printf("ScratchPad = %s\n", bsp["AxiVersion"]["ScratchPad"].readGet().c_str()); + + // Get object as a pointer using full path, and get scratchpad + printf("ScratchPad = %s\n", bsp.getNode("ExampleRoot.AxiVersion.ScratchPad")->get().c_str()); + + // Get yaml config + std::string cfg = bsp["GetYamlConfig"]("True"); + printf("Config = %s\n", cfg.c_str()); + + // Set yaml config, example + // bsp["SetYamlConfig"]("Some Yaml String"); + + // Write Entrire Tree + bsp["WriteAll"](); + + // Read Entrire Tree + bsp["ReadAll"](); + + Py_BEGIN_ALLOW_THREADS; + sleep(60); + Py_END_ALLOW_THREADS; + } catch (...) { + fprintf(stderr, "Found error running API example:\n"); + PyErr_Print(); + return -1; + } + return 0; } diff --git a/tests/test_block_overlap.py b/tests/test_block_overlap.py index 4025ea20c..68acab9ff 100644 --- a/tests/test_block_overlap.py +++ b/tests/test_block_overlap.py @@ -13,6 +13,24 @@ #rogue.Logging.setLevel(rogue.Logging.Debug) +class SimpleVarDevice(pr.Device): + def __init__(self, **kwargs): + super().__init__(**kwargs) + + self.add(pr.RemoteVariable( + name = 'Var1', + offset = 0x0, + bitSize = 32, + bitOffset = 0, + )) + + self.add(pr.RemoteVariable( + name = 'Var2', + offset = 0x4, + bitSize = 32, + bitOffset = 0, + )) + class BlockDevice(pr.Device): def __init__(self, **kwargs): super().__init__(**kwargs) @@ -23,7 +41,6 @@ def __init__(self, **kwargs): name = "DataBlock", description = "Large Data Block", offset = 0, - bitSize = 32 * numRegs, bitOffset = 0, numValues = numRegs, valueBits = 32, @@ -52,7 +69,6 @@ def __init__(self, **kwargs): name = "ListVar", description = "List Variable", offset = (numRegs//2)*4, - bitSize = 32 * numRegs//2, bitOffset = 0, numValues = numRegs//2, valueBits = 32, @@ -85,7 +101,12 @@ def __init__(self): self.addInterface(sim) self.add(BlockDevice( - offset = 0, + offset = 0x0000, + memBase = sim, + )) + + self.add(SimpleVarDevice( + offset = 0xF034, # non-4kB aligned base offset memBase = sim, )) diff --git a/tests/test_list_memory.py b/tests/test_list_memory.py index 01e1dba11..8e4c80e2e 100644 --- a/tests/test_list_memory.py +++ b/tests/test_list_memory.py @@ -16,7 +16,7 @@ import numpy as np import random -#rogue.Logging.setLevel(rogue.Logging.Warning) +#rogue.Logging.setLevel(rogue.Logging.Debug) #import logging #logger = logging.getLogger('pyrogue') #logger.setLevel(logging.DEBUG) @@ -42,7 +42,6 @@ def __init__( self.add(pr.RemoteVariable( name = 'UInt32List', offset = 0x0000, - bitSize = 32 * 32, bitOffset = 0x0000, base = pr.UInt, mode = 'RW', @@ -55,7 +54,6 @@ def __init__( self.add(pr.RemoteVariable( name = 'Int32List', offset = 0x1000, - bitSize = 32 * 32, bitOffset = 0x0000, base = pr.Int, mode = 'RW', @@ -68,7 +66,6 @@ def __init__( self.add(pr.RemoteVariable( name = 'UInt48List', offset = 0x2000, - bitSize = 48 * 32, bitOffset = 0x0000, base = pr.UInt, mode = 'RW', @@ -81,7 +78,6 @@ def __init__( self.add(pr.RemoteVariable( name = 'FloatList', offset = 0x3000, - bitSize = 32 * 32, bitOffset = 0x0000, base = pr.Float, mode = 'RW', @@ -94,7 +90,6 @@ def __init__( self.add(pr.RemoteVariable( name = 'DoubleList', offset = 0x4000, - bitSize = 64 * 32, bitOffset = 0x0000, base = pr.Double, mode = 'RW', @@ -107,7 +102,6 @@ def __init__( self.add(pr.RemoteVariable( name = 'UInt16List', offset = 0x5000, - bitSize = 16 * 32, bitOffset = 0x0000, base = pr.UInt, mode = 'RW', @@ -118,9 +112,32 @@ def __init__( )) self.add(pr.RemoteVariable( - name = 'UInt21List', + name = 'UInt16Pack0', + offset = 0x6000, + bitOffset = 0x0000, + base = pr.UInt, + mode = 'RW', + disp = '{}', + numValues = 32, + valueBits = 16, + valueStride = 32 + )) + + self.add(pr.RemoteVariable( + name = 'UInt16Pack1', offset = 0x6000, - bitSize = 32 * 32, + bitOffset = 16, + base = pr.UInt, + mode = 'RW', + disp = '{}', + numValues = 32, + valueBits = 16, + valueStride = 32 + )) + + self.add(pr.RemoteVariable( + name = 'UInt21List', + offset = 0x7000, bitOffset = 0x0000, base = pr.UInt, mode = 'RW', @@ -132,8 +149,7 @@ def __init__( self.add(pr.RemoteVariable( name = 'BoolList', - offset = 0x7000, - bitSize = 32, + offset = 0x8000, bitOffset = 0x0000, base = pr.Bool, mode = 'RW', @@ -163,32 +179,38 @@ def __init__(self): def test_memory(): - UInt32ListARaw = [int(random.random()*1000) for i in range(32)] - Int32ListARaw = [int(random.random()*1000) for i in range(32)] - UInt48ListARaw = [int(random.random()*1000) for i in range(32)] - FloatListARaw = [random.random()*1000 for i in range(32)] - DoubleListARaw = [random.random()*1000 for i in range(32)] - UInt16ListARaw = [int(random.random()*1000) for i in range(32)] - UInt21ListARaw = [int(random.random()*1000) for i in range(32)] - BoolListARaw = [int(random.random()*1000)%2==0 for i in range(32)] - - UInt32ListA = np.array(UInt32ListARaw,np.uint32) - Int32ListA = np.array(Int32ListARaw,np.int32) - UInt48ListA = np.array(UInt48ListARaw,np.uint64) - FloatListA = np.array(FloatListARaw,np.float32) - DoubleListA = np.array(DoubleListARaw,np.float64) - UInt16ListA = np.array(UInt16ListARaw,np.uint32) - UInt21ListA = np.array(UInt21ListARaw,np.uint32) - BoolListA = np.array(BoolListARaw,bool) - - UInt32ListB = [int(random.random()*1000) for i in range(32)] - Int32ListB = [int(random.random()*1000) for i in range(32)] - UInt48ListB = [int(random.random()*1000) for i in range(32)] - FloatListB = [random.random()*1000 for i in range(32)] - DoubleListB = [random.random()*1000 for i in range(32)] - UInt16ListB = [int(random.random()*1000) for i in range(32)] - UInt21ListB = [int(random.random()*1000) for i in range(32)] - BoolListB = [int(random.random()*1000)%2==0 for i in range(32)] + UInt32ListARaw = [int(random.random()*1000) for i in range(32)] + Int32ListARaw = [int(random.random()*1000) for i in range(32)] + UInt48ListARaw = [int(random.random()*1000) for i in range(32)] + FloatListARaw = [random.random()*1000 for i in range(32)] + DoubleListARaw = [random.random()*1000 for i in range(32)] + UInt16ListARaw = [int(random.random()*1000) for i in range(32)] + UInt16Pack0ARaw = [int(random.random()*1000) for i in range(32)] + UInt16Pack1ARaw = [int(random.random()*1000) for i in range(32)] + UInt21ListARaw = [int(random.random()*1000) for i in range(32)] + BoolListARaw = [int(random.random()*1000)%2==0 for i in range(32)] + + UInt32ListA = np.array(UInt32ListARaw,np.uint32) + Int32ListA = np.array(Int32ListARaw,np.int32) + UInt48ListA = np.array(UInt48ListARaw,np.uint64) + FloatListA = np.array(FloatListARaw,np.float32) + DoubleListA = np.array(DoubleListARaw,np.float64) + UInt16ListA = np.array(UInt16ListARaw,np.uint32) + UInt16Pack0A = np.array(UInt16Pack0ARaw,np.uint32) + UInt16Pack1A = np.array(UInt16Pack1ARaw,np.uint32) + UInt21ListA = np.array(UInt21ListARaw,np.uint32) + BoolListA = np.array(BoolListARaw,bool) + + UInt32ListB = [int(random.random()*1000) for i in range(32)] + Int32ListB = [int(random.random()*1000) for i in range(32)] + UInt48ListB = [int(random.random()*1000) for i in range(32)] + FloatListB = [random.random()*1000 for i in range(32)] + DoubleListB = [random.random()*1000 for i in range(32)] + UInt16ListB = [int(random.random()*1000) for i in range(32)] + UInt16Pack0B = [int(random.random()*1000) for i in range(32)] + UInt16Pack1B = [int(random.random()*1000) for i in range(32)] + UInt21ListB = [int(random.random()*1000) for i in range(32)] + BoolListB = [int(random.random()*1000)%2==0 for i in range(32)] with DummyTree() as root: @@ -199,36 +221,44 @@ def test_memory(): root.ListDevice.FloatList.set(FloatListARaw) root.ListDevice.DoubleList.set(DoubleListARaw) root.ListDevice.UInt16List.set(UInt16ListARaw) + root.ListDevice.UInt16Pack0.set(UInt16Pack0ARaw) + root.ListDevice.UInt16Pack1.set(UInt16Pack1ARaw) root.ListDevice.UInt21List.set(UInt21ListARaw) root.ListDevice.BoolList.set(BoolListARaw) - UInt32ListAA = root.ListDevice.UInt32List.get() - Int32ListAA = root.ListDevice.Int32List.get() - UInt48ListAA = root.ListDevice.UInt48List.get() - FloatListAA = root.ListDevice.FloatList.get() - DoubleListAA = root.ListDevice.DoubleList.get() - UInt16ListAA = root.ListDevice.UInt16List.get() - UInt21ListAA = root.ListDevice.UInt21List.get() - BoolListAA = root.ListDevice.BoolList.get() - - UInt32ListAB = np.array([0] * 32,np.uint32) - Int32ListAB = np.array([0] * 32,np.int32) - UInt48ListAB = np.array([0] * 32,np.uint64) - FloatListAB = np.array([0] * 32,np.float32) - DoubleListAB = np.array([0] * 32,np.float64) - UInt16ListAB = np.array([0] * 32,np.uint32) - UInt21ListAB = np.array([0] * 32,np.uint32) - BoolListAB = np.array([0] * 32,bool) + UInt32ListAA = root.ListDevice.UInt32List.get() + Int32ListAA = root.ListDevice.Int32List.get() + UInt48ListAA = root.ListDevice.UInt48List.get() + FloatListAA = root.ListDevice.FloatList.get() + DoubleListAA = root.ListDevice.DoubleList.get() + UInt16ListAA = root.ListDevice.UInt16List.get() + UInt16Pack0AA = root.ListDevice.UInt16Pack0.get() + UInt16Pack1AA = root.ListDevice.UInt16Pack1.get() + UInt21ListAA = root.ListDevice.UInt21List.get() + BoolListAA = root.ListDevice.BoolList.get() + + UInt32ListAB = np.array([0] * 32,np.uint32) + Int32ListAB = np.array([0] * 32,np.int32) + UInt48ListAB = np.array([0] * 32,np.uint64) + FloatListAB = np.array([0] * 32,np.float32) + DoubleListAB = np.array([0] * 32,np.float64) + UInt16ListAB = np.array([0] * 32,np.uint32) + UInt16Pack0AB = np.array([0] * 32,np.uint32) + UInt16Pack1AB = np.array([0] * 32,np.uint32) + UInt21ListAB = np.array([0] * 32,np.uint32) + BoolListAB = np.array([0] * 32,bool) for i in range(32): - UInt32ListAB[i] = root.ListDevice.UInt32List.get(index=i) - Int32ListAB[i] = root.ListDevice.Int32List.get(index=i) - UInt48ListAB[i] = root.ListDevice.UInt48List.get(index=i) - FloatListAB[i] = root.ListDevice.FloatList.get(index=i) - DoubleListAB[i] = root.ListDevice.DoubleList.get(index=i) - UInt16ListAB[i] = root.ListDevice.UInt16List.get(index=i) - UInt21ListAB[i] = root.ListDevice.UInt21List.get(index=i) - BoolListAB[i] = root.ListDevice.BoolList.get(index=i) + UInt32ListAB[i] = root.ListDevice.UInt32List.get(index=i) + Int32ListAB[i] = root.ListDevice.Int32List.get(index=i) + UInt48ListAB[i] = root.ListDevice.UInt48List.get(index=i) + FloatListAB[i] = root.ListDevice.FloatList.get(index=i) + DoubleListAB[i] = root.ListDevice.DoubleList.get(index=i) + UInt16ListAB[i] = root.ListDevice.UInt16List.get(index=i) + UInt16Pack0AB[i] = root.ListDevice.UInt16Pack0.get(index=i) + UInt16Pack1AB[i] = root.ListDevice.UInt16Pack1.get(index=i) + UInt21ListAB[i] = root.ListDevice.UInt21List.get(index=i) + BoolListAB[i] = root.ListDevice.BoolList.get(index=i) for i in range(32): if UInt32ListAA[i] != UInt32ListA[i]: @@ -249,6 +279,12 @@ def test_memory(): if UInt16ListAA[i] != UInt16ListA[i]: raise AssertionError(f'Verification Failure for UInt16ListAA at position {i}') + if UInt16Pack0AA[i] != UInt16Pack0A[i]: + raise AssertionError(f'Verification Failure for UInt16Pack0AA at position {i}') + + if UInt16Pack1AA[i] != UInt16Pack1A[i]: + raise AssertionError(f'Verification Failure for UInt16Pack1AA at position {i}') + if UInt21ListAA[i] != UInt21ListA[i]: raise AssertionError(f'Verification Failure for UInt21ListAA at position {i}') @@ -270,6 +306,12 @@ def test_memory(): if UInt16ListAB[i] != UInt16ListA[i]: raise AssertionError(f'Verification Failure for UInt16ListAB at position {i}') + if UInt16Pack0AB[i] != UInt16Pack0A[i]: + raise AssertionError(f'Verification Failure for UInt16Pack0AB at position {i}') + + if UInt16Pack1AB[i] != UInt16Pack1A[i]: + raise AssertionError(f'Verification Failure for UInt16Pack1AB at position {i}') + if UInt21ListAB[i] != UInt21ListA[i]: raise AssertionError(f'Verification Failure for UInt21ListAB at position {i}') @@ -283,36 +325,44 @@ def test_memory(): root.ListDevice.FloatList.set(FloatListB[i],index=i) root.ListDevice.DoubleList.set(DoubleListB[i],index=i) root.ListDevice.UInt16List.set(UInt16ListB[i],index=i) + root.ListDevice.UInt16Pack0.set(UInt16Pack0B[i],index=i) + root.ListDevice.UInt16Pack1.set(UInt16Pack1B[i],index=i) root.ListDevice.UInt21List.set(UInt21ListB[i],index=i) root.ListDevice.BoolList.set(BoolListB[i],index=i) - UInt32ListBA = root.ListDevice.UInt32List.get() - Int32ListBA = root.ListDevice.Int32List.get() - UInt48ListBA = root.ListDevice.UInt48List.get() - FloatListBA = root.ListDevice.FloatList.get() - DoubleListBA = root.ListDevice.DoubleList.get() - UInt16ListBA = root.ListDevice.UInt16List.get() - UInt21ListBA = root.ListDevice.UInt21List.get() - BoolListBA = root.ListDevice.BoolList.get() - - UInt32ListBB = np.array([0] * 32,np.uint32) - Int32ListBB = np.array([0] * 32,np.int32) - UInt48ListBB = np.array([0] * 32,np.uint64) - FloatListBB = np.array([0] * 32,np.float32) - DoubleListBB = np.array([0] * 32,np.float64) - UInt16ListBB = np.array([0] * 32,np.uint32) - UInt21ListBB = np.array([0] * 32,np.uint32) - BoolListBB = np.array([0] * 32,bool) + UInt32ListBA = root.ListDevice.UInt32List.get() + Int32ListBA = root.ListDevice.Int32List.get() + UInt48ListBA = root.ListDevice.UInt48List.get() + FloatListBA = root.ListDevice.FloatList.get() + DoubleListBA = root.ListDevice.DoubleList.get() + UInt16ListBA = root.ListDevice.UInt16List.get() + UInt16Pack0BA = root.ListDevice.UInt16Pack0.get() + UInt16Pack1BA = root.ListDevice.UInt16Pack1.get() + UInt21ListBA = root.ListDevice.UInt21List.get() + BoolListBA = root.ListDevice.BoolList.get() + + UInt32ListBB = np.array([0] * 32,np.uint32) + Int32ListBB = np.array([0] * 32,np.int32) + UInt48ListBB = np.array([0] * 32,np.uint64) + FloatListBB = np.array([0] * 32,np.float32) + DoubleListBB = np.array([0] * 32,np.float64) + UInt16ListBB = np.array([0] * 32,np.uint32) + UInt16Pack0BB = np.array([0] * 32,np.uint32) + UInt16Pack1BB = np.array([0] * 32,np.uint32) + UInt21ListBB = np.array([0] * 32,np.uint32) + BoolListBB = np.array([0] * 32,bool) for i in range(32): - UInt32ListBB[i] = root.ListDevice.UInt32List.get(index=i) - Int32ListBB[i] = root.ListDevice.Int32List.get(index=i) - UInt48ListBB[i] = root.ListDevice.UInt48List.get(index=i) - FloatListBB[i] = root.ListDevice.FloatList.get(index=i) - DoubleListBB[i] = root.ListDevice.DoubleList.get(index=i) - UInt16ListBB[i] = root.ListDevice.UInt16List.get(index=i) - UInt21ListBB[i] = root.ListDevice.UInt21List.get(index=i) - BoolListBB[i] = root.ListDevice.BoolList.get(index=i) + UInt32ListBB[i] = root.ListDevice.UInt32List.get(index=i) + Int32ListBB[i] = root.ListDevice.Int32List.get(index=i) + UInt48ListBB[i] = root.ListDevice.UInt48List.get(index=i) + FloatListBB[i] = root.ListDevice.FloatList.get(index=i) + DoubleListBB[i] = root.ListDevice.DoubleList.get(index=i) + UInt16ListBB[i] = root.ListDevice.UInt16List.get(index=i) + UInt16Pack0BB[i] = root.ListDevice.UInt16Pack0.get(index=i) + UInt16Pack1BB[i] = root.ListDevice.UInt16Pack1.get(index=i) + UInt21ListBB[i] = root.ListDevice.UInt21List.get(index=i) + BoolListBB[i] = root.ListDevice.BoolList.get(index=i) for i in range(32): if UInt32ListBA[i] != UInt32ListB[i]: @@ -333,6 +383,12 @@ def test_memory(): if UInt16ListBA[i] != UInt16ListB[i]: raise AssertionError(f'Verification Failure for UInt16ListBA at position {i}') + if UInt16Pack0BA[i] != UInt16Pack0B[i]: + raise AssertionError(f'Verification Failure for UInt16Pack0BA at position {i}') + + if UInt16Pack1BA[i] != UInt16Pack1B[i]: + raise AssertionError(f'Verification Failure for UInt16Pack1BA at position {i}') + if UInt21ListBA[i] != UInt21ListB[i]: raise AssertionError(f'Verification Failure for UInt21ListBA at position {i}') @@ -351,6 +407,12 @@ def test_memory(): if UInt16ListBB[i] != UInt16ListB[i]: raise AssertionError(f'Verification Failure for UInt16ListBB at position {i}') + if UInt16Pack0BB[i] != UInt16Pack0B[i]: + raise AssertionError(f'Verification Failure for UInt16Pack0BB at position {i}') + + if UInt16Pack1BB[i] != UInt16Pack1B[i]: + raise AssertionError(f'Verification Failure for UInt16Pack1BB at position {i}') + if UInt21ListBB[i] != UInt21ListB[i]: raise AssertionError(f'Verification Failure for UInt21ListBB at position {i}')