From 21a3678b2be06e6a29e2f63d27a1540252073cff Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Wed, 24 Jul 2024 16:14:21 -0700 Subject: [PATCH 1/8] Added configurations for basic linting and formatting checks --- .gitignore | 13 ++++++++++ .pre-commit-config.yaml | 45 +++++++++++++++++++++++++++++++++ LICENSE.md | 1 - README.md | 6 ++--- pyproject.toml | 55 +++++++++++++++++++++++++++++++++++++++++ 5 files changed, 116 insertions(+), 4 deletions(-) create mode 100644 .gitignore create mode 100644 .pre-commit-config.yaml create mode 100644 pyproject.toml diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..904c6cd --- /dev/null +++ b/.gitignore @@ -0,0 +1,13 @@ +# Ignore IDE config folders +.idea/ +.vscode/ + +# Ignore caches and binaries +.ruff_cache/ +__pycache__/ +*.py[cod] +.tox/ + +# Ignore virtual environments +*env*/ +*venv*/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..3df902c --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,45 @@ +--- +default_install_hook_types: [pre-commit] +default_stages: [pre-commit] +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.6.0 + hooks: + - id: check-yaml + args: [--unsafe] + - id: check-toml + - id: check-json + - id: check-xml + - id: requirements-txt-fixer +# - id: trailing-whitespace # TODO: enable +# - id: end-of-file-fixer # TODO: enable + - id: check-case-conflict + - id: check-merge-conflict + - id: forbid-submodules + - repo: https://github.com/Lucas-C/pre-commit-hooks + rev: v1.5.5 + hooks: + - id: remove-tabs + - id: forbid-tabs + - repo: https://github.com/python-jsonschema/check-jsonschema + rev: 0.29.0 + hooks: + - id: check-github-workflows + args: [--verbose] + - repo: https://github.com/pappasam/toml-sort + rev: v0.23.1 + hooks: + - id: toml-sort-fix + - repo: https://github.com/astral-sh/ruff-pre-commit + rev: v0.5.4 + hooks: + - id: ruff +# args: [--fix, --exit-non-zero-on-fix] + - id: ruff-format + args: [--check, --diff] + - repo: https://github.com/PyCQA/docformatter + rev: v1.7.5 + hooks: + - id: docformatter + additional_dependencies: [tomli] + args: [--check, --diff] diff --git a/LICENSE.md b/LICENSE.md index daa3d66..f1ec83b 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -9,4 +9,3 @@ TEKTRONIX SAMPLE SOURCE CODE LICENSE AGREEMENT Source code written by Tektronix, Inc. or its affiliates ("Tektronix") that is designated as a "sample," "example," "sample code," or any similar designation will be considered "Sample Source Code." Tektronix grants you a license to download, reproduce, display, distribute, modify, and create derivative works of Tektronix Sample Source Code, only for use in or with Tektronix products. You may not remove or alter any copyright notices or trademarks. SAMPLE SOURCE CODE IS PROVIDED "AS-IS," WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES OF ANY KIND, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT OF INTELLECTUAL PROPERTY. IN NO EVENT SHALL TEKTRONIX, ITS AFFILIATES, OFFICERS, EMPLOYEES, DIRECTORS, AGENTS, SUPPLIERS, OR OTHER THIRD PARTIES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, PUNITIVE, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THIS SAMPLE SOURCE CODE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - diff --git a/README.md b/README.md index e633bb6..7977fd7 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Tek Logo -# Programmatic Control Examples +# Programmatic Control Examples [![CodeFactor](https://www.codefactor.io/repository/github/tektronix/programmatic-control-examples/badge)](https://www.codefactor.io/repository/github/tektronix/programmatic-control-examples) > Code examples sorted by instrument, including examples taken from the User's Manuals. This is a good place to start off learning about programming for an instrument. @@ -52,7 +52,7 @@ You may also recognize some of these examples from the [Tektronix and Keithley W If you don't want to clone this entire repository, it's still possible to take individual files. Navigate to the directory holding the file you want and right-click the file to select _Save link as..._ or some variation on that depending on your browser. The file name will automatically populate and you can save the file where you'd like. Alternatively, you can open the file you want on GitHub and right-click "Raw" at the top of the file to accomplish the same thing. ## Maintainers -Tektronix Product Line Marketing and Application Engineers: +Tektronix Product Line Marketing and Application Engineers: + Jeffrey Miller: [bit-lift](https://github.com/bit-lift) + Carl Murdock: [cbmurdock](https://github.com/cbmurdock) @@ -61,7 +61,7 @@ Tektronix Product Line Marketing and Application Engineers: Licensed under the [Tektronix Sample License](https://www.tek.com/sample-license). ## Contributing -First, please consult the Tektronix [Code of Conduct](https://github.com/tektronix/.github/blob/main/CODE_OF_CONDUCT.md). Contributions in the form of new examples or bug fixes are welcome! Please contribute using [Github Flow](https://guides.github.com/introduction/flow/) and make sure you create your own branch from the `master` branch, and when you are ready to push your changes, just submit a pull request with your changes against the `master` branch. If you see something you're not sure is a bug, or if you'd like to request an example, please submit an Issue via GitHub. +First, please consult the Tektronix [Code of Conduct](https://github.com/tektronix/.github/blob/main/CODE_OF_CONDUCT.md). Contributions in the form of new examples or bug fixes are welcome! Please contribute using [Github Flow](https://guides.github.com/introduction/flow/) and make sure you create your own branch from the `master` branch, and when you are ready to push your changes, just submit a pull request with your changes against the `master` branch. If you see something you're not sure is a bug, or if you'd like to request an example, please submit an Issue via GitHub. If you'd like help from a Tektronix engineer in developing an example, please submit a pull request with what you have so far placed in the proper part of the repository, including any new directories your example may need. diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..25e2296 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,55 @@ +[tool.docformatter] +close-quotes-on-newline = true +in-place = true +recursive = true +wrap-descriptions = 100 +wrap-summaries = 0 + +[tool.ruff] +line-length = 100 +target-version = "py38" # always generate Python 3.8 compatible code + +[tool.ruff.lint] +fixable = ["ALL"] +flake8-quotes = {docstring-quotes = "double"} +ignore = [ + "T201" # `print` found +] +pydocstyle = {convention = "google"} +# https://beta.ruff.rs/docs/rules/ +select = [ + "ALL" +] + +[tool.ruff.lint.isort] +force-sort-within-sections = false +lines-between-types = 1 +order-by-type = false + +[tool.tomlsort] +all = true +in_place = true +spaces_before_inline_comment = 2 + +[tool.tox] +legacy_tox_ini = """ +[tox] +requires = tox>4 +no_package = True +envlist = py38,py39,py310,py311,py312 +skip_missing_interpreters = True + +[gh-actions] +python = + 3.8: py38 + 3.9: py39 + 3.10: py310 + 3.11: py311 + 3.12: py312 + +[testenv] +deps = + pre-commit +commands = + pre-commit run --all-files +""" From 4637c66923429feab97c68da9796d239ae814134 Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Wed, 24 Jul 2024 16:16:37 -0700 Subject: [PATCH 2/8] whitespace changes on files (removing tabs and replacing with spaces) --- .../SaveHardcopyExample/save_hardcopy_c++.c | 138 ++-- .../CurvestreamExample-IVI-VISA.NET.sln | 26 +- .../app.config | 6 +- .../CurvestreamExample.sln | 26 +- .../CurvestreamExample/app.config | 16 +- ...0SX_UltrasyncTimeSyncModeControlExample.py | 626 +++++++++--------- .../ExtractTriggerExample/WFM-Timestamp.sln | 32 +- .../Save_Frames_Individually.sln | 40 +- .../Tek5k7k70k_CheckClippingStatus.py | 10 +- .../CurveQueryWinforms.sln | 32 +- .../src/CSharpHelloScope/HelloScope.sln | 32 +- .../dpt_test_example.py | 14 +- .../PWS4000_sourcevoltage_measure_example.cpp | 112 ++-- .../matlab/AFG31k_send_arb.m | 4 +- .../rf_generic_data_marker.py | 2 +- .../SignalVuExamples/C++/main.cpp | 112 ++-- ...Sweep_Plot_Trace_with_Basic_Find_Peaks_c.m | 2 +- .../MATLAB/RSA6100A_PeakFinder/rtslid.m | 72 +- .../dotNet/TekVISAExamples.sln | 50 +- .../TekVISANetExample/TekVISANetExample.cs | 4 +- .../VbTekVISANetExample.vb | 88 +-- .../VbTekVISASocketExample.vb | 88 +-- 22 files changed, 766 insertions(+), 766 deletions(-) diff --git a/Examples/Oscilloscopes/MidrangeScopes/src/SaveHardcopyExample/save_hardcopy_c++.c b/Examples/Oscilloscopes/MidrangeScopes/src/SaveHardcopyExample/save_hardcopy_c++.c index 5cb6a0f..77047e1 100644 --- a/Examples/Oscilloscopes/MidrangeScopes/src/SaveHardcopyExample/save_hardcopy_c++.c +++ b/Examples/Oscilloscopes/MidrangeScopes/src/SaveHardcopyExample/save_hardcopy_c++.c @@ -21,85 +21,85 @@ int main() { - ViStatus status; - ViSession defaultRM, instr; - ViUInt32 retCount; - ViChar buffer[80000]; + ViStatus status; + ViSession defaultRM, instr; + ViUInt32 retCount; + ViChar buffer[80000]; - // Modify the following line to configure this script for your instrument - char resourceString[] = "TCPIP::10.233.70.92::INSTR"; - ViBuf scpi; + // Modify the following line to configure this script for your instrument + char resourceString[] = "TCPIP::10.233.70.92::INSTR"; + ViBuf scpi; - // Where to save (PC side) - char target_path[] = "C:\\tempx\\"; - char target_name[] = "scope_screenshot.png"; - char full_path[256]; + // Where to save (PC side) + char target_path[] = "C:\\tempx\\"; + char target_name[] = "scope_screenshot.png"; + char full_path[256]; - // Initialize VISA session - status = viOpenDefaultRM(&defaultRM);; - if (status < VI_SUCCESS) { - printf("Failed to initialize\n"); - return -1; - } + // Initialize VISA session + status = viOpenDefaultRM(&defaultRM);; + if (status < VI_SUCCESS) { + printf("Failed to initialize\n"); + return -1; + } - // Open instrument connection - status = viOpen(defaultRM, resourceString, VI_NULL, VI_NULL, &instr); - if (status < VI_SUCCESS) { - printf("Error connecting to instrument\n"); - viStatusDesc(defaultRM, status, buffer); - printf("%s\n", buffer); - return 0; - } + // Open instrument connection + status = viOpen(defaultRM, resourceString, VI_NULL, VI_NULL, &instr); + if (status < VI_SUCCESS) { + printf("Error connecting to instrument\n"); + viStatusDesc(defaultRM, status, buffer); + printf("%s\n", buffer); + return 0; + } - // Set timeout - status = viSetAttribute(instr, VI_ATTR_TMO_VALUE, 10000); + // Set timeout + status = viSetAttribute(instr, VI_ATTR_TMO_VALUE, 10000); - // Configure scope for screenshot, see programmers manual for scope-specific syntax - // Setting where to save screenshot on scope - scpi = "SAVE:IMAGE \"C:\\screenshots\\tek.png\"\n"; - status = viWrite(instr, scpi, (ViUInt32)strlen(scpi), &retCount); - if (status < VI_SUCCESS) { - printf("Error writing to instrument\n"); - viStatusDesc(defaultRM, status, buffer); - printf("%s\n", buffer); - return 0; - } + // Configure scope for screenshot, see programmers manual for scope-specific syntax + // Setting where to save screenshot on scope + scpi = "SAVE:IMAGE \"C:\\screenshots\\tek.png\"\n"; + status = viWrite(instr, scpi, (ViUInt32)strlen(scpi), &retCount); + if (status < VI_SUCCESS) { + printf("Error writing to instrument\n"); + viStatusDesc(defaultRM, status, buffer); + printf("%s\n", buffer); + return 0; + } - // Transfer screenshot to PC - status = viWrite(instr, "FILESystem:READFile \"C:\\screenshots\\tek.png\"\n", 45, &retCount); - if (status < VI_SUCCESS) { - printf("Error writing to instrument\n"); - viStatusDesc(defaultRM, status, buffer); - printf("%s\n", buffer); - return 0; - } - status = viRead(instr, buffer, sizeof(buffer), &retCount); - if (status < VI_SUCCESS) { - printf("Error reading from instrument\n"); - viStatusDesc(defaultRM, status, buffer); - printf("%s\n", buffer); - return 0; - } + // Transfer screenshot to PC + status = viWrite(instr, "FILESystem:READFile \"C:\\screenshots\\tek.png\"\n", 45, &retCount); + if (status < VI_SUCCESS) { + printf("Error writing to instrument\n"); + viStatusDesc(defaultRM, status, buffer); + printf("%s\n", buffer); + return 0; + } + status = viRead(instr, buffer, sizeof(buffer), &retCount); + if (status < VI_SUCCESS) { + printf("Error reading from instrument\n"); + viStatusDesc(defaultRM, status, buffer); + printf("%s\n", buffer); + return 0; + } - snprintf(full_path, sizeof(full_path), "%s%s", target_path, target_name); - FILE* file = fopen(full_path, "wb"); - if (file == NULL) { - printf("Failed to open file for writing.\n"); - return -1; - } + snprintf(full_path, sizeof(full_path), "%s%s", target_path, target_name); + FILE* file = fopen(full_path, "wb"); + if (file == NULL) { + printf("Failed to open file for writing.\n"); + return -1; + } - size_t bytesWritten = fwrite(buffer, 1, retCount, file); + size_t bytesWritten = fwrite(buffer, 1, retCount, file); - // Check if the write operation was successful - if (bytesWritten != buffer) { - perror("Error writing to the file"); - fclose(file); - return 1; // Exit with an error code - } + // Check if the write operation was successful + if (bytesWritten != buffer) { + perror("Error writing to the file"); + fclose(file); + return 1; // Exit with an error code + } - fclose(file); + fclose(file); - viClose(instr); - viClose(defaultRM); - return 0; + viClose(instr); + viClose(defaultRM); + return 0; } \ No newline at end of file diff --git a/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-IVI-VISA.NET/CurvestreamExample-IVI-VISA.NET.sln b/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-IVI-VISA.NET/CurvestreamExample-IVI-VISA.NET.sln index 42f69fd..8bc4403 100644 --- a/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-IVI-VISA.NET/CurvestreamExample-IVI-VISA.NET.sln +++ b/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-IVI-VISA.NET/CurvestreamExample-IVI-VISA.NET.sln @@ -4,17 +4,17 @@ Microsoft Visual Studio Solution File, Format Version 11.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CurvestreamExample-IVI-VISA.NET", "CurvestreamExample-IVI-VISA.NET\CurvestreamExample-IVI-VISA.NET.csproj", "{09335BF5-9F20-4FD5-9948-4F88ABBE45BB}" EndProject Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Debug|x86.ActiveCfg = Debug|x86 - {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Debug|x86.Build.0 = Debug|x86 - {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Release|x86.ActiveCfg = Release|x86 - {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Debug|x86.ActiveCfg = Debug|x86 + {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Debug|x86.Build.0 = Debug|x86 + {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Release|x86.ActiveCfg = Release|x86 + {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection EndGlobal diff --git a/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-IVI-VISA.NET/CurvestreamExample-IVI-VISA.NET/app.config b/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-IVI-VISA.NET/CurvestreamExample-IVI-VISA.NET/app.config index c37450c..7c9eba5 100644 --- a/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-IVI-VISA.NET/CurvestreamExample-IVI-VISA.NET/app.config +++ b/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-IVI-VISA.NET/CurvestreamExample-IVI-VISA.NET/app.config @@ -1,6 +1,6 @@ - - - + + + diff --git a/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-NI-VISA/CurvestreamExample.sln b/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-NI-VISA/CurvestreamExample.sln index 7f2e1df..23f403f 100644 --- a/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-NI-VISA/CurvestreamExample.sln +++ b/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-NI-VISA/CurvestreamExample.sln @@ -4,17 +4,17 @@ Microsoft Visual Studio Solution File, Format Version 11.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Curve Stream Example", "CurvestreamExample\CurvestreamExample.csproj", "{09335BF5-9F20-4FD5-9948-4F88ABBE45BB}" EndProject Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Debug|x86.ActiveCfg = Debug|x86 - {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Debug|x86.Build.0 = Debug|x86 - {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Release|x86.ActiveCfg = Release|x86 - {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Debug|x86.ActiveCfg = Debug|x86 + {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Debug|x86.Build.0 = Debug|x86 + {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Release|x86.ActiveCfg = Release|x86 + {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection EndGlobal diff --git a/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-NI-VISA/CurvestreamExample/app.config b/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-NI-VISA/CurvestreamExample/app.config index 78310c9..0c0dfc3 100644 --- a/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-NI-VISA/CurvestreamExample/app.config +++ b/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-NI-VISA/CurvestreamExample/app.config @@ -1,11 +1,11 @@ - - - - - - - - + + + + + + + + diff --git a/Examples/Oscilloscopes/PerformanceScopes/src/DPO70000SX_UltrasyncTimeSyncModeControlExample/DPO70000SX_UltrasyncTimeSyncModeControlExample.py b/Examples/Oscilloscopes/PerformanceScopes/src/DPO70000SX_UltrasyncTimeSyncModeControlExample/DPO70000SX_UltrasyncTimeSyncModeControlExample.py index 0b583c6..5fb1b73 100644 --- a/Examples/Oscilloscopes/PerformanceScopes/src/DPO70000SX_UltrasyncTimeSyncModeControlExample/DPO70000SX_UltrasyncTimeSyncModeControlExample.py +++ b/Examples/Oscilloscopes/PerformanceScopes/src/DPO70000SX_UltrasyncTimeSyncModeControlExample/DPO70000SX_UltrasyncTimeSyncModeControlExample.py @@ -45,210 +45,210 @@ horizontalPosition = 20.0 # 20% trigSource = 'AUX' -trigSlope = 'RISE' # RISe|FALL|EITHER +trigSlope = 'RISE' # RISe|FALL|EITHER trigLevel = 200e-3 vertScales = { - 'master' : { 'ch1' : 50e-3, 'ch2' : 50e-3, 'ch3' : 50e-3, 'ch4' : 50e-3}, - 'extB' : { 'ch1' : 50e-3, 'ch2' : 50e-3, 'ch3' : 50e-3, 'ch4' : 50e-3}, - 'extC' : { 'ch1' : 50e-3, 'ch2' : 50e-3, 'ch3' : 50e-3, 'ch4' : 50e-3}, - 'extD' : { 'ch1' : 50e-3, 'ch2' : 50e-3, 'ch3' : 50e-3, 'ch4' : 50e-3}, + 'master' : { 'ch1' : 50e-3, 'ch2' : 50e-3, 'ch3' : 50e-3, 'ch4' : 50e-3}, + 'extB' : { 'ch1' : 50e-3, 'ch2' : 50e-3, 'ch3' : 50e-3, 'ch4' : 50e-3}, + 'extC' : { 'ch1' : 50e-3, 'ch2' : 50e-3, 'ch3' : 50e-3, 'ch4' : 50e-3}, + 'extD' : { 'ch1' : 50e-3, 'ch2' : 50e-3, 'ch3' : 50e-3, 'ch4' : 50e-3}, } # ================= class ConsoleLog: - # Simple class for printing messages to the console and logging them to a file - logfile = None - - def __init__(self, logFilePath : str) -> None: - self.logfile = open(logFileName, 'w') - self.Write('Log File Opened') - - def Write(self, msg : str, endl='\n'): - # Prints messages to the console and writes them to the console log - timestampStr = datetime.now().strftime("%Y-%m-%d %H:%M:%S - ") - print(timestampStr + str(msg), end=endl) - self.logfile.write(timestampStr + str(msg) + endl) - - def Close(self) -> None: - if self.logfile != None: - self.logfile.close() + # Simple class for printing messages to the console and logging them to a file + logfile = None + + def __init__(self, logFilePath : str) -> None: + self.logfile = open(logFileName, 'w') + self.Write('Log File Opened') + + def Write(self, msg : str, endl='\n'): + # Prints messages to the console and writes them to the console log + timestampStr = datetime.now().strftime("%Y-%m-%d %H:%M:%S - ") + print(timestampStr + str(msg), end=endl) + self.logfile.write(timestampStr + str(msg) + endl) + + def Close(self) -> None: + if self.logfile != None: + self.logfile.close() def WaitOperationComplete(vi : visa.resources.MessageBasedResource, timeoutms : int = None): - # Waits for any operations that will raise the OPC flag to complete before returning - # Use timeout to set how long to wait. If timeout is None then current timeout value for the VISA session will be used. - temp = None - if timeoutms != None: - temp = vi.timeout - vi.timeout = timeoutms - - vi.query('*OPC?') - - if timeoutms != None: - vi.timeout = temp + # Waits for any operations that will raise the OPC flag to complete before returning + # Use timeout to set how long to wait. If timeout is None then current timeout value for the VISA session will be used. + temp = None + if timeoutms != None: + temp = vi.timeout + vi.timeout = timeoutms + + vi.query('*OPC?') + + if timeoutms != None: + vi.timeout = temp def ErrorQuery(vi : visa.resources.MessageBasedResource): - return vi.query('*ESR?;ALLEV?;') + return vi.query('*ESR?;ALLEV?;') def SetRunState(vi : visa.resources.MessageBasedResource, run : bool): - # Sets the scope into the Running or the Stopped states - state = 'RUN' if run==True else 'STOP' - vi.write(f'ACQ:STATE {state}') + # Sets the scope into the Running or the Stopped states + state = 'RUN' if run==True else 'STOP' + vi.write(f'ACQ:STATE {state}') def StartAcquiring(vi : visa.resources.MessageBasedResource, waitUntilFirstAcqComplete : bool = False, waitTimeoutSec : float = 10.0): - # Functionally equivalent to pressing the Run/Stop button on the front panel to start acquisitions - # Can optionally block function call from returning until at least one acqusition is made by setting - # waitUntilFirstAcqComplete to True. waitTimeout sets how long to wait. - vi.write('ACQ:STOPAFTER RUNSTOP') - SetRunState(vi, True) - acqState = int(vi.query('ACQ:STATE?')) - while acqState != 1: - time.sleep(0.2) - acqState = int(vi.query('ACQ:STATE?')) - - if waitUntilFirstAcqComplete == True: - tWaitStart = time.perf_counter() - acqCount = int(master.query('ACQ:NUMACQ?')) - while acqCount < 1: - if time.perf_counter() - tWaitStart > waitTimeoutSec: - break - time.sleep(0.1) - acqCount = int(master.query('ACQ:NUMACQ?')) + # Functionally equivalent to pressing the Run/Stop button on the front panel to start acquisitions + # Can optionally block function call from returning until at least one acqusition is made by setting + # waitUntilFirstAcqComplete to True. waitTimeout sets how long to wait. + vi.write('ACQ:STOPAFTER RUNSTOP') + SetRunState(vi, True) + acqState = int(vi.query('ACQ:STATE?')) + while acqState != 1: + time.sleep(0.2) + acqState = int(vi.query('ACQ:STATE?')) + + if waitUntilFirstAcqComplete == True: + tWaitStart = time.perf_counter() + acqCount = int(master.query('ACQ:NUMACQ?')) + while acqCount < 1: + if time.perf_counter() - tWaitStart > waitTimeoutSec: + break + time.sleep(0.1) + acqCount = int(master.query('ACQ:NUMACQ?')) def StopAcquiring(vi : visa.resources.MessageBasedResource): - # Functionally equivalent to pressing the Run/Stop button on the front panel to stop acquisitions - SetRunState(vi, False) - acqState = int(vi.query('ACQ:STATE?')) - while acqState != 0: - time.sleep(0.2) - acqState = int(vi.query('ACQ:STATE?')) - WaitOperationComplete(vi) + # Functionally equivalent to pressing the Run/Stop button on the front panel to stop acquisitions + SetRunState(vi, False) + acqState = int(vi.query('ACQ:STATE?')) + while acqState != 0: + time.sleep(0.2) + acqState = int(vi.query('ACQ:STATE?')) + WaitOperationComplete(vi) def WaitTriggerReady(vi : visa.resources.MessageBasedResource, timeoutSec : float = 10.0) -> bool: - # Function returns when the trigger is ready - - # Check that scope is in run state - if int(vi.query('ACQ:STATE?')) != 1: - return False - - trigReady = 0 - tWaitStart = time.perf_counter() - trigReady = int(master.query('TRIG:A:READY?')) - while trigReady != 1: - if time.perf_counter() - tWaitStart > timeoutSec: - break - time.sleep(0.1) - trigReady = int(master.query('TRIG:A:READY?')) - - if trigReady == 1: - return True - - return False + # Function returns when the trigger is ready + + # Check that scope is in run state + if int(vi.query('ACQ:STATE?')) != 1: + return False + + trigReady = 0 + tWaitStart = time.perf_counter() + trigReady = int(master.query('TRIG:A:READY?')) + while trigReady != 1: + if time.perf_counter() - tWaitStart > timeoutSec: + break + time.sleep(0.1) + trigReady = int(master.query('TRIG:A:READY?')) + + if trigReady == 1: + return True + + return False # These Single Sequence functions are the equivalent of pressing the Single button on the front panel def InitiateSingleSequnce(vi : visa.resources.MessageBasedResource): - # Starts a Single Sequence and returns - vi.write('ACQ:STOPAFTER SEQ') - vi.write('ACQ:STATE RUN') + # Starts a Single Sequence and returns + vi.write('ACQ:STOPAFTER SEQ') + vi.write('ACQ:STATE RUN') def ExcuteSingleSequence(vi : visa.resources.MessageBasedResource, timeoutms : int): - # Starts a Single Sequence and waits until the scope has triggered and the acquisition is complete before returning. - temp = vi.timeout - vi.timeout = timeoutms - vi.write('ACQ:STOPAFTER SEQ') - vi.write('ACQ:STATE RUN') - vi.query('*OPC?') - vi.timeout = temp + # Starts a Single Sequence and waits until the scope has triggered and the acquisition is complete before returning. + temp = vi.timeout + vi.timeout = timeoutms + vi.write('ACQ:STOPAFTER SEQ') + vi.write('ACQ:STATE RUN') + vi.query('*OPC?') + vi.timeout = temp def InitializeStack(vi : visa.resources.MessageBasedResource): - # Performs a Default Setup on the stack and waits for it to complete before returning. This should only be called on the Master. - master.write('*CLS') - vi.write('*RST') - vi.query('*OPC?') + # Performs a Default Setup on the stack and waits for it to complete before returning. This should only be called on the Master. + master.write('*CLS') + vi.write('*RST') + vi.query('*OPC?') def SetVerticalScale(vi : visa.resources.MessageBasedResource, channel : str, scale : float): - # Sets the vertical scale of the channel. 'channel' should be the name of the channel i.e. "CH1", "MATH1", "REF1", etc. - vi.write(f'{channel}:SCALE {scale}') + # Sets the vertical scale of the channel. 'channel' should be the name of the channel i.e. "CH1", "MATH1", "REF1", etc. + vi.write(f'{channel}:SCALE {scale}') def SetupChannels(vi : visa.resources.MessageBasedResource, ch1Scale : float, ch2Scale : float, ch3Scale : float, ch4Scale : float): - # Turns on all the channels on the scope and sets the vertical scale of each - vi.write(':SEL:CH1 ON;CH2 ON;CH3 ON;CH4 ON;') # Turn all the channels on - SetVerticalScale(vi, 'CH1', ch1Scale) - SetVerticalScale(vi, 'CH2', ch2Scale) - SetVerticalScale(vi, 'CH3', ch3Scale) - SetVerticalScale(vi, 'CH4', ch4Scale) - vi.write('*WAI') + # Turns on all the channels on the scope and sets the vertical scale of each + vi.write(':SEL:CH1 ON;CH2 ON;CH3 ON;CH4 ON;') # Turn all the channels on + SetVerticalScale(vi, 'CH1', ch1Scale) + SetVerticalScale(vi, 'CH2', ch2Scale) + SetVerticalScale(vi, 'CH3', ch3Scale) + SetVerticalScale(vi, 'CH4', ch4Scale) + vi.write('*WAI') def SetupHorizontal(vi : visa.resources.MessageBasedResource, sampleRate : float, recordLength : float, horizontalPos : float = 50): - # Configures the horizontal settings of the stack. Should only be called on the Master. - - vi.write('HOR:MODE MAN;*WAI;') - time.sleep(2) # Horizontal commands must trickle down to extensions so pace these commands - vi.write(f'HOR:MODE:SAMPLERATE {sampleRate};*WAI;') - time.sleep(2) - vi.write(f'HOR:MODE:RECORDLENGTH {recordLength};*WAI;') - time.sleep(2) - vi.write(f'HOR:POS {horizontalPos};*WAI;') - time.sleep(2) + # Configures the horizontal settings of the stack. Should only be called on the Master. + + vi.write('HOR:MODE MAN;*WAI;') + time.sleep(2) # Horizontal commands must trickle down to extensions so pace these commands + vi.write(f'HOR:MODE:SAMPLERATE {sampleRate};*WAI;') + time.sleep(2) + vi.write(f'HOR:MODE:RECORDLENGTH {recordLength};*WAI;') + time.sleep(2) + vi.write(f'HOR:POS {horizontalPos};*WAI;') + time.sleep(2) def SetupEdgeTrigger(vi : visa.resources.MessageBasedResource, trigSource : str, trigSlope : str, trigLevel : float, trigMode : str = 'AUTO'): - # Configures the trigger settings. Should only be called on the Master. Only the Master can be used to trigger in Time-sync mode - vi.write(f'TRIG:A:TYPE EDGE') - vi.write(f'TRIG:A:EDGE:SOURCE {trigSource}') - vi.write(f'TRIG:A:EDGE:SLOPE:AUX {trigSlope}') - vi.write(f'TRIG:A:LEVEL {trigLevel}') - vi.write(f'TRIG:A:MODE {trigMode}') - vi.write('*WAI') + # Configures the trigger settings. Should only be called on the Master. Only the Master can be used to trigger in Time-sync mode + vi.write(f'TRIG:A:TYPE EDGE') + vi.write(f'TRIG:A:EDGE:SOURCE {trigSource}') + vi.write(f'TRIG:A:EDGE:SLOPE:AUX {trigSlope}') + vi.write(f'TRIG:A:LEVEL {trigLevel}') + vi.write(f'TRIG:A:MODE {trigMode}') + vi.write('*WAI') def TakeScreenshot(vi : visa.resources.MessageBasedResource, localFolderPath : str, pngFileName : str): - # Takes a screenshot and transfers it to the local PC. pngFileName should include the extension ".png" - vi.write("HARDCOPY:PORT FILE") - vi.write("HARDCopy:PALETTE COLOR") - vi.write("EXPORT:FORMAT PNG") - vi.write("HARDCopy:FILEName \"C:\\Users\\Tek_local_admin\\Pictures\\Temp.png\"") - vi.write("HARDCopy STARt") - vi.query('*OPC?') - vi.write("FILESystem:READFile \"C:\\Users\\Tek_local_admin\\Pictures\\Temp.png\"") - imgData = vi.read_raw() - # Save the transfered image to the hard drive of your PC - imgFile = open(localFolderPath + pngFileName, "wb") - imgFile.write(imgData) - imgFile.close() - - # Delete the image file from the scope's hard drive. - vi.write("FILESystem:DELEte \"C:\\Users\\Tek_local_admin\\Pictures\\Temp.png\"") - return + # Takes a screenshot and transfers it to the local PC. pngFileName should include the extension ".png" + vi.write("HARDCOPY:PORT FILE") + vi.write("HARDCopy:PALETTE COLOR") + vi.write("EXPORT:FORMAT PNG") + vi.write("HARDCopy:FILEName \"C:\\Users\\Tek_local_admin\\Pictures\\Temp.png\"") + vi.write("HARDCopy STARt") + vi.query('*OPC?') + vi.write("FILESystem:READFile \"C:\\Users\\Tek_local_admin\\Pictures\\Temp.png\"") + imgData = vi.read_raw() + # Save the transfered image to the hard drive of your PC + imgFile = open(localFolderPath + pngFileName, "wb") + imgFile.write(imgData) + imgFile.close() + + # Delete the image file from the scope's hard drive. + vi.write("FILESystem:DELEte \"C:\\Users\\Tek_local_admin\\Pictures\\Temp.png\"") + return def SaveAllWfmsToDisk(vi : visa.resources.MessageBasedResource, remoteFilePath, filename, waitComplete : bool = True): - # Saves all waveforms on screen to the scope's local disk. - # "remoteFilePath" specifies the folder on the scope where the files should be saved. - # "filename" should NOT include the extention i.e. DO NOT include ".wfm" - # waitComplete will determine if the function will wait for the save operation to complete before returning - vi.write(f'SAVE:WAVEFORM ALL,"{remoteFilePath + filename}"') + # Saves all waveforms on screen to the scope's local disk. + # "remoteFilePath" specifies the folder on the scope where the files should be saved. + # "filename" should NOT include the extention i.e. DO NOT include ".wfm" + # waitComplete will determine if the function will wait for the save operation to complete before returning + vi.write(f'SAVE:WAVEFORM ALL,"{remoteFilePath + filename}"') - if waitComplete: - vi.query('*OPC?') + if waitComplete: + vi.query('*OPC?') def FetchFile(vi : visa.resources.MessageBasedResource, remoteFileFolder : str, fileName : str, localFolderPath : str): - # Fetches a file from the scope and saves it to the local PC - vi.write(f'FILESystem:READFile \"{remoteFileFolder}{fileName}\"') - fileData = vi.read_raw(2 * 1024 * 1024) + # Fetches a file from the scope and saves it to the local PC + vi.write(f'FILESystem:READFile \"{remoteFileFolder}{fileName}\"') + fileData = vi.read_raw(2 * 1024 * 1024) - # Save the transfered file to the hard drive of your PC - file = open(localFolderPath + fileName, "wb") - file.write(fileData) - file.close() + # Save the transfered file to the hard drive of your PC + file = open(localFolderPath + fileName, "wb") + file.write(fileData) + file.close() def DeleteFile(vi : visa.resources.MessageBasedResource, remoteFileFolder : str, fileName : str): - # Deletes a file from the hard drive of the scope - vi.write(f'FILESystem:DELEte \"{remoteFileFolder}{fileName}\"') + # Deletes a file from the hard drive of the scope + vi.write(f'FILESystem:DELEte \"{remoteFileFolder}{fileName}\"') def WaitForPressAnyKey(): - return msvcrt.getch() + return msvcrt.getch() #========================================================= @@ -259,170 +259,170 @@ def WaitForPressAnyKey(): saveDataPath = localDataFolder + tScriptStart.strftime("%Y-%m-%d_%H%M%S\\") pathExists = os.path.exists(saveDataPath) if not pathExists: - os.makedirs(saveDataPath) + os.makedirs(saveDataPath) logFileName = saveDataPath + tScriptStart.strftime("%Y-%m-%d_%H%M%S_Test_Log.txt") log = ConsoleLog(logFileName) log.Write('Script Started') try: - # Connect to instruments in stack - rm = visa.ResourceManager() - log.Write('Opening connections to scopes in stack') - master : visa.resources.MessageBasedResource = rm.open_resource(masterRsrcAddr) - master.timeout = defaultTimeout - log.Write('Master: ' + master.query('*IDN?').strip()) - - extB : visa.resources.MessageBasedResource = rm.open_resource(extBRsrcAddr) - log.Write('ExtenB: ' + extB.query('*IDN?').strip()) - extB.timeout = defaultTimeout - - extC : visa.resources.MessageBasedResource = rm.open_resource(extCRsrcAddr) - log.Write('ExtenC: ' + extC.query('*IDN?').strip()) - extC.timeout = defaultTimeout - - extD : visa.resources.MessageBasedResource = rm.open_resource(extDRsrcAddr) - log.Write('ExtenD: ' + extD.query('*IDN?').strip()) - extD.timeout = defaultTimeout - - - log.Write('Resetting Stack...') - InitializeStack(master) - log.Write('Reset Done') - - log.Write('Setting up stack...') - StopAcquiring(master) - - SetupChannels(master, vertScales['master']['ch1'], vertScales['master']['ch2'], vertScales['master']['ch3'], vertScales['master']['ch4']) - SetupChannels(extB, vertScales['extB']['ch1'], vertScales['extB']['ch2'], vertScales['extB']['ch3'], vertScales['extB']['ch4']) - SetupChannels(extC, vertScales['extC']['ch1'], vertScales['extC']['ch2'], vertScales['extC']['ch3'], vertScales['extC']['ch4']) - SetupChannels(extD, vertScales['extD']['ch1'], vertScales['extD']['ch2'], vertScales['extD']['ch3'], vertScales['extD']['ch4']) - - SetupHorizontal(master, sampleRate, recordLen, horizontalPosition) - SetupEdgeTrigger(master, trigSource, trigSlope, trigLevel) - - - log.Write('Setting up stack done') - - log.Write('Starting free-running acqusitions') - StartAcquiring(master, True) - log.Write('Free-running acqusitions started') - - - print('\r\nPress any key to initiate a Single Sequence...') - WaitForPressAnyKey() - StopAcquiring(master) - time.sleep(0.2) - log.Write('Initiating Single Sequence...') - InitiateSingleSequnce(master) - time.sleep(0.2) - WaitTriggerReady(master) - log.Write('Single Sequence Initiated. Scope ready for trigger event.') - WaitOperationComplete(master, 600000) # Will wait 60 seconds before timing out - timeAcqComplete = datetime.now() - log.Write('Single Sequence Complete') - - - remoteFolder = 'C:\\Users\\Tek_Local_Admin\\Tektronix\\TekScope\\Waveforms\\' - baseFileName = timeAcqComplete.strftime("%Y-%m-%d_%H%M%S") - - log.Write('Saving waveforms to .wfm files on scopes') - SaveAllWfmsToDisk(master, remoteFolder, baseFileName + '_Master_', False) - SaveAllWfmsToDisk(extB, remoteFolder, baseFileName + '_ExtB_', False) - SaveAllWfmsToDisk(extC, remoteFolder, baseFileName + '_ExtC_', False) - SaveAllWfmsToDisk(extD, remoteFolder, baseFileName + '_ExtD_', False) - - # We didn't wait for each scope to complete before instructing the next scope to save so wait for the scopes to finish now - WaitOperationComplete(master) - WaitOperationComplete(extB) - WaitOperationComplete(extC) - WaitOperationComplete(extD) - log.Write('Saving waveforms to .wfm files on scopes complete') - - - log.Write('Fetching screenshots from scopes') - TakeScreenshot(master, saveDataPath, baseFileName + '_Master_Screenshot.png') - log.Write('Fetching screenshots from Master complete') - TakeScreenshot(extB, saveDataPath, baseFileName + '_ExtB_Screenshot.png') - log.Write('Fetching screenshots from Extension B complete') - TakeScreenshot(extC, saveDataPath, baseFileName + '_ExtC_Screenshot.png') - log.Write('Fetching screenshots from Extension C complete') - TakeScreenshot(extD, saveDataPath, baseFileName + '_ExtD_Screenshot.png') - log.Write('Fetching screenshots from Extension D complete') - - remoteFilePathBase = remoteFolder + baseFileName - log.Write('Fetching .wfm files from scopes') - FetchFile(master, remoteFolder, baseFileName + '_Master_CH1.wfm', saveDataPath) - FetchFile(master, remoteFolder, baseFileName + '_Master_CH2.wfm', saveDataPath) - FetchFile(master, remoteFolder, baseFileName + '_Master_CH3.wfm', saveDataPath) - FetchFile(master, remoteFolder, baseFileName + '_Master_CH4.wfm', saveDataPath) - log.Write('Fetching .wfm files from Master complete') - - FetchFile(extB, remoteFolder, baseFileName + '_ExtB_CH1.wfm', saveDataPath) - FetchFile(extB, remoteFolder, baseFileName + '_ExtB_CH2.wfm', saveDataPath) - FetchFile(extB, remoteFolder, baseFileName + '_ExtB_CH3.wfm', saveDataPath) - FetchFile(extB, remoteFolder, baseFileName + '_ExtB_CH4.wfm', saveDataPath) - log.Write('Fetching .wfm files from Extension B complete') - - FetchFile(extC, remoteFolder, baseFileName + '_ExtC_CH1.wfm', saveDataPath) - FetchFile(extC, remoteFolder, baseFileName + '_ExtC_CH2.wfm', saveDataPath) - FetchFile(extC, remoteFolder, baseFileName + '_ExtC_CH3.wfm', saveDataPath) - FetchFile(extC, remoteFolder, baseFileName + '_ExtC_CH4.wfm', saveDataPath) - log.Write('Fetching .wfm files from Extension C complete') - - FetchFile(extD, remoteFolder, baseFileName + '_ExtD_CH1.wfm', saveDataPath) - FetchFile(extD, remoteFolder, baseFileName + '_ExtD_CH2.wfm', saveDataPath) - FetchFile(extD, remoteFolder, baseFileName + '_ExtD_CH3.wfm', saveDataPath) - FetchFile(extD, remoteFolder, baseFileName + '_ExtD_CH4.wfm', saveDataPath) - log.Write('Fetching .wfm files from Extension D complete') - - - print('Do you want to delete .wfm files from scopes?') - userInput = input('Enter \'Y\' to delete .wfms from scopes, anything else to skip deletion: ') - if userInput == 'Y': - log.Write('Deleting .wfm files on scopes') - DeleteFile(master, remoteFolder, baseFileName + '_Master_CH1.wfm') - DeleteFile(master, remoteFolder, baseFileName + '_Master_CH2.wfm') - DeleteFile(master, remoteFolder, baseFileName + '_Master_CH3.wfm') - DeleteFile(master, remoteFolder, baseFileName + '_Master_CH4.wfm') - log.Write('Deleting .wfm files on Master complete') - - DeleteFile(extB, remoteFolder, baseFileName + '_ExtB_CH1.wfm') - DeleteFile(extB, remoteFolder, baseFileName + '_ExtB_CH2.wfm') - DeleteFile(extB, remoteFolder, baseFileName + '_ExtB_CH3.wfm') - DeleteFile(extB, remoteFolder, baseFileName + '_ExtB_CH4.wfm') - log.Write('Deleting .wfm files on Extension B complete') - - DeleteFile(extC, remoteFolder, baseFileName + '_ExtC_CH1.wfm') - DeleteFile(extC, remoteFolder, baseFileName + '_ExtC_CH2.wfm') - DeleteFile(extC, remoteFolder, baseFileName + '_ExtC_CH3.wfm') - DeleteFile(extC, remoteFolder, baseFileName + '_ExtC_CH4.wfm') - log.Write('Deleting .wfm files on Extension C complete') - - DeleteFile(extD, remoteFolder, baseFileName + '_ExtD_CH1.wfm') - DeleteFile(extD, remoteFolder, baseFileName + '_ExtD_CH2.wfm') - DeleteFile(extD, remoteFolder, baseFileName + '_ExtD_CH3.wfm') - DeleteFile(extD, remoteFolder, baseFileName + '_ExtD_CH4.wfm') - log.Write('Deleting .wfm files on Extension D complete') - - log.Write(ErrorQuery(master)) + # Connect to instruments in stack + rm = visa.ResourceManager() + log.Write('Opening connections to scopes in stack') + master : visa.resources.MessageBasedResource = rm.open_resource(masterRsrcAddr) + master.timeout = defaultTimeout + log.Write('Master: ' + master.query('*IDN?').strip()) + + extB : visa.resources.MessageBasedResource = rm.open_resource(extBRsrcAddr) + log.Write('ExtenB: ' + extB.query('*IDN?').strip()) + extB.timeout = defaultTimeout + + extC : visa.resources.MessageBasedResource = rm.open_resource(extCRsrcAddr) + log.Write('ExtenC: ' + extC.query('*IDN?').strip()) + extC.timeout = defaultTimeout + + extD : visa.resources.MessageBasedResource = rm.open_resource(extDRsrcAddr) + log.Write('ExtenD: ' + extD.query('*IDN?').strip()) + extD.timeout = defaultTimeout + + + log.Write('Resetting Stack...') + InitializeStack(master) + log.Write('Reset Done') + + log.Write('Setting up stack...') + StopAcquiring(master) + + SetupChannels(master, vertScales['master']['ch1'], vertScales['master']['ch2'], vertScales['master']['ch3'], vertScales['master']['ch4']) + SetupChannels(extB, vertScales['extB']['ch1'], vertScales['extB']['ch2'], vertScales['extB']['ch3'], vertScales['extB']['ch4']) + SetupChannels(extC, vertScales['extC']['ch1'], vertScales['extC']['ch2'], vertScales['extC']['ch3'], vertScales['extC']['ch4']) + SetupChannels(extD, vertScales['extD']['ch1'], vertScales['extD']['ch2'], vertScales['extD']['ch3'], vertScales['extD']['ch4']) + + SetupHorizontal(master, sampleRate, recordLen, horizontalPosition) + SetupEdgeTrigger(master, trigSource, trigSlope, trigLevel) + + + log.Write('Setting up stack done') + + log.Write('Starting free-running acqusitions') + StartAcquiring(master, True) + log.Write('Free-running acqusitions started') + + + print('\r\nPress any key to initiate a Single Sequence...') + WaitForPressAnyKey() + StopAcquiring(master) + time.sleep(0.2) + log.Write('Initiating Single Sequence...') + InitiateSingleSequnce(master) + time.sleep(0.2) + WaitTriggerReady(master) + log.Write('Single Sequence Initiated. Scope ready for trigger event.') + WaitOperationComplete(master, 600000) # Will wait 60 seconds before timing out + timeAcqComplete = datetime.now() + log.Write('Single Sequence Complete') + + + remoteFolder = 'C:\\Users\\Tek_Local_Admin\\Tektronix\\TekScope\\Waveforms\\' + baseFileName = timeAcqComplete.strftime("%Y-%m-%d_%H%M%S") + + log.Write('Saving waveforms to .wfm files on scopes') + SaveAllWfmsToDisk(master, remoteFolder, baseFileName + '_Master_', False) + SaveAllWfmsToDisk(extB, remoteFolder, baseFileName + '_ExtB_', False) + SaveAllWfmsToDisk(extC, remoteFolder, baseFileName + '_ExtC_', False) + SaveAllWfmsToDisk(extD, remoteFolder, baseFileName + '_ExtD_', False) + + # We didn't wait for each scope to complete before instructing the next scope to save so wait for the scopes to finish now + WaitOperationComplete(master) + WaitOperationComplete(extB) + WaitOperationComplete(extC) + WaitOperationComplete(extD) + log.Write('Saving waveforms to .wfm files on scopes complete') + + + log.Write('Fetching screenshots from scopes') + TakeScreenshot(master, saveDataPath, baseFileName + '_Master_Screenshot.png') + log.Write('Fetching screenshots from Master complete') + TakeScreenshot(extB, saveDataPath, baseFileName + '_ExtB_Screenshot.png') + log.Write('Fetching screenshots from Extension B complete') + TakeScreenshot(extC, saveDataPath, baseFileName + '_ExtC_Screenshot.png') + log.Write('Fetching screenshots from Extension C complete') + TakeScreenshot(extD, saveDataPath, baseFileName + '_ExtD_Screenshot.png') + log.Write('Fetching screenshots from Extension D complete') + + remoteFilePathBase = remoteFolder + baseFileName + log.Write('Fetching .wfm files from scopes') + FetchFile(master, remoteFolder, baseFileName + '_Master_CH1.wfm', saveDataPath) + FetchFile(master, remoteFolder, baseFileName + '_Master_CH2.wfm', saveDataPath) + FetchFile(master, remoteFolder, baseFileName + '_Master_CH3.wfm', saveDataPath) + FetchFile(master, remoteFolder, baseFileName + '_Master_CH4.wfm', saveDataPath) + log.Write('Fetching .wfm files from Master complete') + + FetchFile(extB, remoteFolder, baseFileName + '_ExtB_CH1.wfm', saveDataPath) + FetchFile(extB, remoteFolder, baseFileName + '_ExtB_CH2.wfm', saveDataPath) + FetchFile(extB, remoteFolder, baseFileName + '_ExtB_CH3.wfm', saveDataPath) + FetchFile(extB, remoteFolder, baseFileName + '_ExtB_CH4.wfm', saveDataPath) + log.Write('Fetching .wfm files from Extension B complete') + + FetchFile(extC, remoteFolder, baseFileName + '_ExtC_CH1.wfm', saveDataPath) + FetchFile(extC, remoteFolder, baseFileName + '_ExtC_CH2.wfm', saveDataPath) + FetchFile(extC, remoteFolder, baseFileName + '_ExtC_CH3.wfm', saveDataPath) + FetchFile(extC, remoteFolder, baseFileName + '_ExtC_CH4.wfm', saveDataPath) + log.Write('Fetching .wfm files from Extension C complete') + + FetchFile(extD, remoteFolder, baseFileName + '_ExtD_CH1.wfm', saveDataPath) + FetchFile(extD, remoteFolder, baseFileName + '_ExtD_CH2.wfm', saveDataPath) + FetchFile(extD, remoteFolder, baseFileName + '_ExtD_CH3.wfm', saveDataPath) + FetchFile(extD, remoteFolder, baseFileName + '_ExtD_CH4.wfm', saveDataPath) + log.Write('Fetching .wfm files from Extension D complete') + + + print('Do you want to delete .wfm files from scopes?') + userInput = input('Enter \'Y\' to delete .wfms from scopes, anything else to skip deletion: ') + if userInput == 'Y': + log.Write('Deleting .wfm files on scopes') + DeleteFile(master, remoteFolder, baseFileName + '_Master_CH1.wfm') + DeleteFile(master, remoteFolder, baseFileName + '_Master_CH2.wfm') + DeleteFile(master, remoteFolder, baseFileName + '_Master_CH3.wfm') + DeleteFile(master, remoteFolder, baseFileName + '_Master_CH4.wfm') + log.Write('Deleting .wfm files on Master complete') + + DeleteFile(extB, remoteFolder, baseFileName + '_ExtB_CH1.wfm') + DeleteFile(extB, remoteFolder, baseFileName + '_ExtB_CH2.wfm') + DeleteFile(extB, remoteFolder, baseFileName + '_ExtB_CH3.wfm') + DeleteFile(extB, remoteFolder, baseFileName + '_ExtB_CH4.wfm') + log.Write('Deleting .wfm files on Extension B complete') + + DeleteFile(extC, remoteFolder, baseFileName + '_ExtC_CH1.wfm') + DeleteFile(extC, remoteFolder, baseFileName + '_ExtC_CH2.wfm') + DeleteFile(extC, remoteFolder, baseFileName + '_ExtC_CH3.wfm') + DeleteFile(extC, remoteFolder, baseFileName + '_ExtC_CH4.wfm') + log.Write('Deleting .wfm files on Extension C complete') + + DeleteFile(extD, remoteFolder, baseFileName + '_ExtD_CH1.wfm') + DeleteFile(extD, remoteFolder, baseFileName + '_ExtD_CH2.wfm') + DeleteFile(extD, remoteFolder, baseFileName + '_ExtD_CH3.wfm') + DeleteFile(extD, remoteFolder, baseFileName + '_ExtD_CH4.wfm') + log.Write('Deleting .wfm files on Extension D complete') + + log.Write(ErrorQuery(master)) except Exception as e: - log.Write('Script Terminated early due to exception.') - log.Write(e) -finally: - tScriptEnd = datetime.now() - totalTime = tScriptEnd-tScriptStart - log.Write('Script Ended') - log.Write(f'Total Time: {totalTime}') - log.Close() - if master is not None: - master.close() - if extB is not None: - extB.close() - if extD is not None: - extD.close() - if extD is not None: - extD.close() - if rm is not None: - rm.close() + log.Write('Script Terminated early due to exception.') + log.Write(e) +finally: + tScriptEnd = datetime.now() + totalTime = tScriptEnd-tScriptStart + log.Write('Script Ended') + log.Write(f'Total Time: {totalTime}') + log.Close() + if master is not None: + master.close() + if extB is not None: + extB.close() + if extD is not None: + extD.close() + if extD is not None: + extD.close() + if rm is not None: + rm.close() diff --git a/Examples/Oscilloscopes/PerformanceScopes/src/ExtractTriggerExample/WFM-Timestamp.sln b/Examples/Oscilloscopes/PerformanceScopes/src/ExtractTriggerExample/WFM-Timestamp.sln index 8a6c105..5253c35 100644 --- a/Examples/Oscilloscopes/PerformanceScopes/src/ExtractTriggerExample/WFM-Timestamp.sln +++ b/Examples/Oscilloscopes/PerformanceScopes/src/ExtractTriggerExample/WFM-Timestamp.sln @@ -6,20 +6,20 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WFM-Timestamp", "WFM-Timestamp\WFM-Timestamp.csproj", "{AF51348B-7FB1-4426-B3BC-469FE5D53D8F}" EndProject Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AF51348B-7FB1-4426-B3BC-469FE5D53D8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AF51348B-7FB1-4426-B3BC-469FE5D53D8F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AF51348B-7FB1-4426-B3BC-469FE5D53D8F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AF51348B-7FB1-4426-B3BC-469FE5D53D8F}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {916229EE-E0FF-4CD7-8D4F-1F9102E59568} - EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AF51348B-7FB1-4426-B3BC-469FE5D53D8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF51348B-7FB1-4426-B3BC-469FE5D53D8F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF51348B-7FB1-4426-B3BC-469FE5D53D8F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF51348B-7FB1-4426-B3BC-469FE5D53D8F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {916229EE-E0FF-4CD7-8D4F-1F9102E59568} + EndGlobalSection EndGlobal diff --git a/Examples/Oscilloscopes/PerformanceScopes/src/Save_Frames_Individually/Save_Frames_Individually.sln b/Examples/Oscilloscopes/PerformanceScopes/src/Save_Frames_Individually/Save_Frames_Individually.sln index b286d36..472a9c7 100644 --- a/Examples/Oscilloscopes/PerformanceScopes/src/Save_Frames_Individually/Save_Frames_Individually.sln +++ b/Examples/Oscilloscopes/PerformanceScopes/src/Save_Frames_Individually/Save_Frames_Individually.sln @@ -10,24 +10,24 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisaWrapper", "..\..\..\OneDrive - Fortive\Documents\Retrieved files from 2000-2008\TDS Stuff\TDS Control\GUI prototyping in Visual Studio\VisaWrapper\VisaWrapper.csproj", "{DD0CA08E-0836-47CF-A51A-C66C7B5CB79C}" EndProject Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B7F58C17-C9DF-41D2-BF24-6974083388E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B7F58C17-C9DF-41D2-BF24-6974083388E5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B7F58C17-C9DF-41D2-BF24-6974083388E5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B7F58C17-C9DF-41D2-BF24-6974083388E5}.Release|Any CPU.Build.0 = Release|Any CPU - {DD0CA08E-0836-47CF-A51A-C66C7B5CB79C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DD0CA08E-0836-47CF-A51A-C66C7B5CB79C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DD0CA08E-0836-47CF-A51A-C66C7B5CB79C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DD0CA08E-0836-47CF-A51A-C66C7B5CB79C}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {2C74A564-ABC1-4DD5-865F-A0A46748C697} - EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B7F58C17-C9DF-41D2-BF24-6974083388E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B7F58C17-C9DF-41D2-BF24-6974083388E5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B7F58C17-C9DF-41D2-BF24-6974083388E5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B7F58C17-C9DF-41D2-BF24-6974083388E5}.Release|Any CPU.Build.0 = Release|Any CPU + {DD0CA08E-0836-47CF-A51A-C66C7B5CB79C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DD0CA08E-0836-47CF-A51A-C66C7B5CB79C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DD0CA08E-0836-47CF-A51A-C66C7B5CB79C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DD0CA08E-0836-47CF-A51A-C66C7B5CB79C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2C74A564-ABC1-4DD5-865F-A0A46748C697} + EndGlobalSection EndGlobal diff --git a/Examples/Oscilloscopes/PerformanceScopes/src/Tek5k7k70k_CheckClippingStatus/Tek5k7k70k_CheckClippingStatus.py b/Examples/Oscilloscopes/PerformanceScopes/src/Tek5k7k70k_CheckClippingStatus/Tek5k7k70k_CheckClippingStatus.py index 525e3e1..bf286d3 100644 --- a/Examples/Oscilloscopes/PerformanceScopes/src/Tek5k7k70k_CheckClippingStatus/Tek5k7k70k_CheckClippingStatus.py +++ b/Examples/Oscilloscopes/PerformanceScopes/src/Tek5k7k70k_CheckClippingStatus/Tek5k7k70k_CheckClippingStatus.py @@ -29,10 +29,10 @@ import pyvisa as visa # https://pyvisa.readthedocs.io/en/latest/ class ClippingStatus(Enum): - NotClipping = 0 - Both = 1 - Positive = 2 - Negative = 3 + NotClipping = 0 + Both = 1 + Positive = 2 + Negative = 3 def Tek5k7k70k_CheckClipping(vi : visa.resources.MessageBasedResource, channel : str = 'CH1') -> tuple[bool, ClippingStatus]: @@ -77,4 +77,4 @@ def CheckClippingExample(): # Only run the example if this script is the main script being run if __name__ == '__main__': - CheckClippingExample() \ No newline at end of file + CheckClippingExample() \ No newline at end of file diff --git a/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/CSharpCurveQueryWinforms/CurveQueryWinforms.sln b/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/CSharpCurveQueryWinforms/CurveQueryWinforms.sln index 9d4b7dc..9e141ef 100644 --- a/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/CSharpCurveQueryWinforms/CurveQueryWinforms.sln +++ b/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/CSharpCurveQueryWinforms/CurveQueryWinforms.sln @@ -6,20 +6,20 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CurveQueryWinforms", "CurveQueryWinforms\CurveQueryWinforms.csproj", "{B1A8D030-C134-4033-A81B-78383BBFF26B}" EndProject Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B1A8D030-C134-4033-A81B-78383BBFF26B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B1A8D030-C134-4033-A81B-78383BBFF26B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B1A8D030-C134-4033-A81B-78383BBFF26B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B1A8D030-C134-4033-A81B-78383BBFF26B}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {7BF6EF49-91F5-4C81-899B-431481A360B9} - EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B1A8D030-C134-4033-A81B-78383BBFF26B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B1A8D030-C134-4033-A81B-78383BBFF26B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B1A8D030-C134-4033-A81B-78383BBFF26B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B1A8D030-C134-4033-A81B-78383BBFF26B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7BF6EF49-91F5-4C81-899B-431481A360B9} + EndGlobalSection EndGlobal diff --git a/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/CSharpHelloScope/HelloScope.sln b/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/CSharpHelloScope/HelloScope.sln index a9a6be0..05cd80b 100644 --- a/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/CSharpHelloScope/HelloScope.sln +++ b/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/CSharpHelloScope/HelloScope.sln @@ -6,20 +6,20 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloScope", "HelloScope\HelloScope.csproj", "{95B654DA-72B0-434D-876C-DA660CDB3387}" EndProject Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {95B654DA-72B0-434D-876C-DA660CDB3387}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {95B654DA-72B0-434D-876C-DA660CDB3387}.Debug|Any CPU.Build.0 = Debug|Any CPU - {95B654DA-72B0-434D-876C-DA660CDB3387}.Release|Any CPU.ActiveCfg = Release|Any CPU - {95B654DA-72B0-434D-876C-DA660CDB3387}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {F1974110-BCDD-47CC-B6BC-AADCA6FF6543} - EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {95B654DA-72B0-434D-876C-DA660CDB3387}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {95B654DA-72B0-434D-876C-DA660CDB3387}.Debug|Any CPU.Build.0 = Debug|Any CPU + {95B654DA-72B0-434D-876C-DA660CDB3387}.Release|Any CPU.ActiveCfg = Release|Any CPU + {95B654DA-72B0-434D-876C-DA660CDB3387}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F1974110-BCDD-47CC-B6BC-AADCA6FF6543} + EndGlobalSection EndGlobal diff --git a/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/DoublePulseTestExample/dpt_test_example.py b/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/DoublePulseTestExample/dpt_test_example.py index cf8c4a3..f37a1bc 100644 --- a/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/DoublePulseTestExample/dpt_test_example.py +++ b/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/DoublePulseTestExample/dpt_test_example.py @@ -18,7 +18,7 @@ # * License: https://www.tek.com/sample-license # * --------------------------------------------------------------------------------------------------------- # * Revision History -# * Date: 2023-Aug-08 +# * Date: 2023-Aug-08 # * Notes: First revision (v1.0) # * Demo guildline # * 1. Connect MSO5/6B AFG output to AFG31000 trigger input; @@ -28,25 +28,25 @@ # * 4. Modify the user input settings in scripts; # * 5. Run the scripts to start the demo # * --------------------------------------------------------------------------------------------------------- -# * Date: 2023-Oct-10 +# * Date: 2023-Oct-10 # * Notes: Revision v1.1 # * 1. Add automatical control of AFG with DPT control interface; # * 2. Tested on V2.4.4 MSO5B/6B # * --------------------------------------------------------------------------------------------------------- -# * Date: 2024-Jan-31 +# * Date: 2024-Jan-31 # * Notes: Revision v1.2 # * 1. The AFG trigger/scope acquistion stuck issue has been resolved; # * 2. Tested on V2.6.38 MSO5B/6B # * --------------------------------------------------------------------------------------------------------- -# * Date: 2024-Mar-8 +# * Date: 2024-Mar-8 # * Notes: Revision v1.3 # * 1. Modify the comments for final publication; # * --------------------------------------------------------------------------------------------------------- -# * Date: 2024-Jun-5 +# * Date: 2024-Jun-5 # * Notes: Revision v1.4 # * 1. Modify the comments and debug codes for final publication; # * --------------------------------------------------------------------------------------------------------- -# * Date: 2024-Jun-6 +# * Date: 2024-Jun-6 # * Notes: Revision v1.5 # * 1. Adding time out input to the wait_for_scope_free(time_out_sec) function; # * 2. Adding 2 time delay command (time.sleep(1)) in the beginning and end of @@ -63,7 +63,7 @@ # * r = scope.query('allev?').strip() # * 9. Put the customer settings in an order with 2 groups (basic/advanced) # * --------------------------------------------------------------------------------------------------------- -# * Date: month/day/year +# * Date: month/day/year # * Notes: # *********************************************************************************************************** diff --git a/Examples/Power_Supplies/src/SourceVoltageExample/PWS4000_sourcevoltage_measure_example.cpp b/Examples/Power_Supplies/src/SourceVoltageExample/PWS4000_sourcevoltage_measure_example.cpp index 5ca09da..700c11b 100644 --- a/Examples/Power_Supplies/src/SourceVoltageExample/PWS4000_sourcevoltage_measure_example.cpp +++ b/Examples/Power_Supplies/src/SourceVoltageExample/PWS4000_sourcevoltage_measure_example.cpp @@ -9,66 +9,66 @@ static ViUInt32 retCnt; int main() { - status = viOpenDefaultRM(&defaultRM); - if (status < VI_SUCCESS) goto Error; + status = viOpenDefaultRM(&defaultRM); + if (status < VI_SUCCESS) goto Error; - status = viOpen(defaultRM, "PWS4000", VI_NULL, VI_NULL, &vi); - if (status < VI_SUCCESS) goto Error; - - sprintf((char*)strCmd, "*RST\n"); - status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; - - sprintf((char*)strCmd, "*IDN?\n"); - status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; - status = viRead(vi, strReply, 255, &retCnt); - if (status < VI_SUCCESS) goto Error; - - // viRead() writes into the string only the data read from the instrument - // therefore you need to NULL terminate the strings manually. - strReply[retCnt] = 0; - puts((char*)strReply); + status = viOpen(defaultRM, "PWS4000", VI_NULL, VI_NULL, &vi); + if (status < VI_SUCCESS) goto Error; + + sprintf((char*)strCmd, "*RST\n"); + status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; + + sprintf((char*)strCmd, "*IDN?\n"); + status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; + status = viRead(vi, strReply, 255, &retCnt); + if (status < VI_SUCCESS) goto Error; + + // viRead() writes into the string only the data read from the instrument + // therefore you need to NULL terminate the strings manually. + strReply[retCnt] = 0; + puts((char*)strReply); - sprintf((char*)strCmd, "VOLT 5.0\n"); - status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; + sprintf((char*)strCmd, "VOLT 5.0\n"); + status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; - sprintf((char*)strCmd, "CURR 0.5\n"); - status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; - - sprintf((char*)strCmd, "OUTP ON\n"); - status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; - - sprintf((char*)strCmd, "MEAS:VOLT?\n"); - status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; - status = viRead(vi, strReply, 255, &retCnt); - if (status < VI_SUCCESS) goto Error; - strReply[retCnt] = 0; - printf("Voltage: %s", strReply); + sprintf((char*)strCmd, "CURR 0.5\n"); + status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; + + sprintf((char*)strCmd, "OUTP ON\n"); + status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; + + sprintf((char*)strCmd, "MEAS:VOLT?\n"); + status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; + status = viRead(vi, strReply, 255, &retCnt); + if (status < VI_SUCCESS) goto Error; + strReply[retCnt] = 0; + printf("Voltage: %s", strReply); - sprintf((char*)strCmd, "MEAS:CURR?\n"); - status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; - status = viRead(vi, strReply, 255, &retCnt); - if (status < VI_SUCCESS) goto Error; - strReply[retCnt] = 0; - printf("Current: %s", strReply); + sprintf((char*)strCmd, "MEAS:CURR?\n"); + status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; + status = viRead(vi, strReply, 255, &retCnt); + if (status < VI_SUCCESS) goto Error; + strReply[retCnt] = 0; + printf("Current: %s", strReply); Error: - if (status < VI_SUCCESS) - { - viStatusDesc(vi, status, (char*)strReply); - printf("VISA Error Occured:\r\n%s", strReply); - } - if (vi != VI_NULL) viClose(vi); - if (defaultRM != VI_NULL) viClose(defaultRM); - - printf("\r\nPress any key to continue ..."); - getchar(); - - return 0; + if (status < VI_SUCCESS) + { + viStatusDesc(vi, status, (char*)strReply); + printf("VISA Error Occured:\r\n%s", strReply); + } + if (vi != VI_NULL) viClose(vi); + if (defaultRM != VI_NULL) viClose(defaultRM); + + printf("\r\nPress any key to continue ..."); + getchar(); + + return 0; } diff --git a/Examples/Signal_Sources/src/AFG31k_Send_Arb_Waveform/matlab/AFG31k_send_arb.m b/Examples/Signal_Sources/src/AFG31k_Send_Arb_Waveform/matlab/AFG31k_send_arb.m index de2ea95..f8adce6 100644 --- a/Examples/Signal_Sources/src/AFG31k_Send_Arb_Waveform/matlab/AFG31k_send_arb.m +++ b/Examples/Signal_Sources/src/AFG31k_Send_Arb_Waveform/matlab/AFG31k_send_arb.m @@ -13,11 +13,11 @@ NI-VISA v19.5 AFG31000 - *********************************************************** + *********************************************************** *** Copyright 2023 Tektronix, Inc. *** *** See www.tek.com/sample-license for licensing terms. *** *********************************************************** - + Tektronix provides the following example "AS IS" without any guarantees or support. This example is for instructional guidance only. %} diff --git a/Examples/Signal_Sources/src/RFGenericCustomMarkerExample/rf_generic_data_marker.py b/Examples/Signal_Sources/src/RFGenericCustomMarkerExample/rf_generic_data_marker.py index 5c23282..4323c8d 100644 --- a/Examples/Signal_Sources/src/RFGenericCustomMarkerExample/rf_generic_data_marker.py +++ b/Examples/Signal_Sources/src/RFGenericCustomMarkerExample/rf_generic_data_marker.py @@ -90,7 +90,7 @@ sampPerSym = int(sampRate/symRate) with open(fileName) as f: - raw = f.read().strip() + raw = f.read().strip() raw = raw.split('\n') markerValues = [int(i) for i in raw] diff --git a/Examples/Spectrum_Analyzers/SignalVuExamples/C++/main.cpp b/Examples/Spectrum_Analyzers/SignalVuExamples/C++/main.cpp index fedf33f..e8f3e57 100644 --- a/Examples/Spectrum_Analyzers/SignalVuExamples/C++/main.cpp +++ b/Examples/Spectrum_Analyzers/SignalVuExamples/C++/main.cpp @@ -12,73 +12,73 @@ static ViUInt32 retCnt; int main() { - //VISA Session Setup - status = viOpenDefaultRM(&defaultRM); - if (status < VI_SUCCESS) goto Error; + //VISA Session Setup + status = viOpenDefaultRM(&defaultRM); + if (status < VI_SUCCESS) goto Error; - status = viOpen(defaultRM, "GPIB8::1::INSTR", VI_NULL, 100000, &vi); - if (status < VI_SUCCESS) goto Error; + status = viOpen(defaultRM, "GPIB8::1::INSTR", VI_NULL, 100000, &vi); + if (status < VI_SUCCESS) goto Error; - //Sending Reset and Identification Commands - sprintf_s((char*)strCmd, 6, "*RST\n"); - status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; + //Sending Reset and Identification Commands + sprintf_s((char*)strCmd, 6, "*RST\n"); + status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; - sprintf_s((char*)strCmd, 7, "*IDN?\n"); - status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; - status = viRead(vi, strReply, 255, &retCnt); - if (status < VI_SUCCESS) goto Error; + sprintf_s((char*)strCmd, 7, "*IDN?\n"); + status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; + status = viRead(vi, strReply, 255, &retCnt); + if (status < VI_SUCCESS) goto Error; - // viRead() writes into the string only the data read from the instrument - // therefore you need to NULL terminate the strings manually. - strReply[retCnt] = 0; - puts((char*)strReply); + // viRead() writes into the string only the data read from the instrument + // therefore you need to NULL terminate the strings manually. + strReply[retCnt] = 0; + puts((char*)strReply); - //General Setup - sprintf_s((char*)strCmd, BUFFER, "display:general:measview:new toverview\n"); - status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; + //General Setup + sprintf_s((char*)strCmd, BUFFER, "display:general:measview:new toverview\n"); + status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; - sprintf_s((char*)strCmd, BUFFER, "display:general:measview:new avtime\n"); - status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; - - double cf = 2.4453e9; - sprintf_s((char*)strCmd, BUFFER, "spectrum:frequency:center %f\n", cf); - status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; + sprintf_s((char*)strCmd, BUFFER, "display:general:measview:new avtime\n"); + status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; + + double cf = 2.4453e9; + sprintf_s((char*)strCmd, BUFFER, "spectrum:frequency:center %f\n", cf); + status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; - double refLevel = 0; - sprintf_s((char*)strCmd, BUFFER, "input:rlevel %f\n", refLevel); - status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; + double refLevel = 0; + sprintf_s((char*)strCmd, BUFFER, "input:rlevel %f\n", refLevel); + status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; - double aLength = 100e-6; - sprintf_s((char*)strCmd, BUFFER, "sense:analysis:length %f\n", aLength); - status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; - - //Start Acquisition - sprintf_s((char*)strCmd, BUFFER, "initiate:continuous off\n"); - status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; + double aLength = 100e-6; + sprintf_s((char*)strCmd, BUFFER, "sense:analysis:length %f\n", aLength); + status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; + + //Start Acquisition + sprintf_s((char*)strCmd, BUFFER, "initiate:continuous off\n"); + status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; - sprintf_s((char*)strCmd, BUFFER, "initiate:immediate\n"); - status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; + sprintf_s((char*)strCmd, BUFFER, "initiate:immediate\n"); + status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; Error: - if (status < VI_SUCCESS) - { - viStatusDesc(vi, status, (char*)strReply); - printf("VISA Error Occured:\r\n%s", strReply); - } - if (vi != VI_NULL) viClose(vi); - if (defaultRM != VI_NULL) viClose(defaultRM); + if (status < VI_SUCCESS) + { + viStatusDesc(vi, status, (char*)strReply); + printf("VISA Error Occured:\r\n%s", strReply); + } + if (vi != VI_NULL) viClose(vi); + if (defaultRM != VI_NULL) viClose(defaultRM); - printf("\r\nPress any key to continue ..."); - getchar(); - return 0; + printf("\r\nPress any key to continue ..."); + getchar(); + return 0; } \ No newline at end of file diff --git a/Examples/Spectrum_Analyzers/SignalVuExamples/MATLAB/RSA6100A_PeakFinder/RTSA6100__Sweep_Plot_Trace_with_Basic_Find_Peaks_c.m b/Examples/Spectrum_Analyzers/SignalVuExamples/MATLAB/RSA6100A_PeakFinder/RTSA6100__Sweep_Plot_Trace_with_Basic_Find_Peaks_c.m index 310e17f..540ec6f 100644 --- a/Examples/Spectrum_Analyzers/SignalVuExamples/MATLAB/RSA6100A_PeakFinder/RTSA6100__Sweep_Plot_Trace_with_Basic_Find_Peaks_c.m +++ b/Examples/Spectrum_Analyzers/SignalVuExamples/MATLAB/RSA6100A_PeakFinder/RTSA6100__Sweep_Plot_Trace_with_Basic_Find_Peaks_c.m @@ -37,7 +37,7 @@ %-------------------------------------------------------------------------- % Change the IP addresses to match the IP address of your RSA before % running the demo. -RTSAIPAddr = '192.168.1.113'; % Instrument TCP/IP address +RTSAIPAddr = '192.168.1.113'; % Instrument TCP/IP address % % %-------------------------------------------------------------------------- diff --git a/Examples/Spectrum_Analyzers/SignalVuExamples/MATLAB/RSA6100A_PeakFinder/rtslid.m b/Examples/Spectrum_Analyzers/SignalVuExamples/MATLAB/RSA6100A_PeakFinder/rtslid.m index 911044d..a0f799a 100644 --- a/Examples/Spectrum_Analyzers/SignalVuExamples/MATLAB/RSA6100A_PeakFinder/rtslid.m +++ b/Examples/Spectrum_Analyzers/SignalVuExamples/MATLAB/RSA6100A_PeakFinder/rtslid.m @@ -154,7 +154,7 @@ h = axes('Position',[0.03 0.1 0.03 0.8]); end - if ischar(back), % Any string wll cause the background to be 'jet' + if ischar(back), % Any string wll cause the background to be 'jet' try eval(['colormap(''',back,''');']); catch @@ -170,20 +170,20 @@ image(m); end - title(label); + title(label); % Make the slider look nice set(h,'XTick',[],'XTickLabel','','YTick',[],'YTickLabel','','YDir','normal','LineWidth',2); - set(fig,'DoubleBuffer','on'); % Double buffering required for smooth display + set(fig,'DoubleBuffer','on'); % Double buffering required for smooth display % Draw the small black box that indicates current position ind = patch([0 0 10 10],[def2-20 def2+20 def2+20 def2-20],[0.25 0.25 0.25]);axis tight; - params.mdown = 0; % Initialise mousedown state - params.ind = ind; % Save the handle to the position indicator - params.funhand{1} = f; % Save the function handle or string - params.h = h; % Save the handle to this slider - params.h2 = hh; % Save the handle to the plotting axes (for this slider) + params.mdown = 0; % Initialise mousedown state + params.ind = ind; % Save the handle to the position indicator + params.funhand{1} = f; % Save the function handle or string + params.h = h; % Save the handle to this slider + params.h2 = hh; % Save the handle to the plotting axes (for this slider) if exist('scale'), % Set the output limits params.scale{1} = scale; else @@ -215,18 +215,18 @@ % Make the slider look nice set(h,'XTick',[],'XTickLabel','','YTick',[],'YTickLabel','','YDir','normal','LineWidth',2); - set(fig,'DoubleBuffer','on'); - + set(fig,'DoubleBuffer','on'); + % Draw the small black box that indicates current position ind = patch([0 0 10 10],[def2-20 def2+20 def2+20 def2-20],[0.25 0.25 0.25]);axis tight; % Copy old parameters and concatenate new values params.mdown = [params2.mdown 0]; % Initialise new mousedown state - params.ind = [params2.ind ind]; % Save the handle to the position indicator - params.funhand = params2.funhand; % Save the function handle or string + params.ind = [params2.ind ind]; % Save the handle to the position indicator + params.funhand = params2.funhand; % Save the function handle or string params.funhand{params.noslids} = f; - params.h = [params2.h h]; % Save the handle to this slider - params.h2 = [params2.h2 hh]; % Save the handle to the plotting axes (for this slider) + params.h = [params2.h h]; % Save the handle to this slider + params.h2 = [params2.h2 hh]; % Save the handle to the plotting axes (for this slider) for l=1:(params.noslids-1), params.scale{l} = params2.scale{l}; end @@ -351,28 +351,28 @@ function butmotfcn1(in,varargin) params = get(gcf,'UserData'); % Get the saved parameters for l=1:params.noslids, - if (params.mdown(l)), % If mouse was clicked on slider l - p = get(params.h(l),'CurrentPoint'); % Get mouse position relative to the slider axis - dy = p(3)-params.old; % Calculate change in mouse position - if (abs(dy)>0), % If mouse has moved - p2 = params.current(l)+dy; % Find new slider position - params.old = p(3); % Save this new mouse position - p2=max([0 min([1000 p2])]); % Constrain position - params.current(l) = p2; % Save current slider position - scal = params.scale{l}; % Get the lower and upper limits - out = (p2*(scal(2)-scal(1))/1000); % Convert from [0 to 1000] to new scale - out = out+scal(1); - axes(params.h2(l)); % Avoid plotting on the slider axis - if ischar(params.funhand{l}), % If string passed as function - eval(params.funhand{l}); % Evaluate the string - else % Else if function handle passed - feval(params.funhand{l},out,params.h2(l)); % Perform function - end - set(params.ind(l),'YData',[p2-20 p2+20 p2+20 p2-20]);% Update position indicator - figure(params.fig); % Make sure focus returns to slider after plotting - end - end - set(gcf,'UserData',params); % Save all parameters + if (params.mdown(l)), % If mouse was clicked on slider l + p = get(params.h(l),'CurrentPoint'); % Get mouse position relative to the slider axis + dy = p(3)-params.old; % Calculate change in mouse position + if (abs(dy)>0), % If mouse has moved + p2 = params.current(l)+dy; % Find new slider position + params.old = p(3); % Save this new mouse position + p2=max([0 min([1000 p2])]); % Constrain position + params.current(l) = p2; % Save current slider position + scal = params.scale{l}; % Get the lower and upper limits + out = (p2*(scal(2)-scal(1))/1000); % Convert from [0 to 1000] to new scale + out = out+scal(1); + axes(params.h2(l)); % Avoid plotting on the slider axis + if ischar(params.funhand{l}), % If string passed as function + eval(params.funhand{l}); % Evaluate the string + else % Else if function handle passed + feval(params.funhand{l},out,params.h2(l)); % Perform function + end + set(params.ind(l),'YData',[p2-20 p2+20 p2+20 p2-20]);% Update position indicator + figure(params.fig); % Make sure focus returns to slider after plotting + end + end + set(gcf,'UserData',params); % Save all parameters end if (length(params.butmot)>0), % Evaluate any extra ButMot functions passed to rtslid eval(params.butmot); diff --git a/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/TekVISAExamples.sln b/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/TekVISAExamples.sln index dbb5602..ffacbc6 100644 --- a/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/TekVISAExamples.sln +++ b/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/TekVISAExamples.sln @@ -12,29 +12,29 @@ EndProject Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VbTekVISANetExample", "VbTekVISANetExample\VbTekVISANetExample.vbproj", "{CDC2269A-5ECB-4A24-AE88-F62D0C77BF5C}" EndProject Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {CE854A27-52BE-4F3F-9465-B6359F7A4D20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CE854A27-52BE-4F3F-9465-B6359F7A4D20}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CE854A27-52BE-4F3F-9465-B6359F7A4D20}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CE854A27-52BE-4F3F-9465-B6359F7A4D20}.Release|Any CPU.Build.0 = Release|Any CPU - {D4919D3F-CF85-42B9-87CA-7F0060C9B02A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D4919D3F-CF85-42B9-87CA-7F0060C9B02A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D4919D3F-CF85-42B9-87CA-7F0060C9B02A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D4919D3F-CF85-42B9-87CA-7F0060C9B02A}.Release|Any CPU.Build.0 = Release|Any CPU - {A66B8BB6-B5B2-4FDF-8DC4-9027D70510A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A66B8BB6-B5B2-4FDF-8DC4-9027D70510A2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A66B8BB6-B5B2-4FDF-8DC4-9027D70510A2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A66B8BB6-B5B2-4FDF-8DC4-9027D70510A2}.Release|Any CPU.Build.0 = Release|Any CPU - {CDC2269A-5ECB-4A24-AE88-F62D0C77BF5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CDC2269A-5ECB-4A24-AE88-F62D0C77BF5C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CDC2269A-5ECB-4A24-AE88-F62D0C77BF5C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CDC2269A-5ECB-4A24-AE88-F62D0C77BF5C}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CE854A27-52BE-4F3F-9465-B6359F7A4D20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CE854A27-52BE-4F3F-9465-B6359F7A4D20}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CE854A27-52BE-4F3F-9465-B6359F7A4D20}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CE854A27-52BE-4F3F-9465-B6359F7A4D20}.Release|Any CPU.Build.0 = Release|Any CPU + {D4919D3F-CF85-42B9-87CA-7F0060C9B02A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D4919D3F-CF85-42B9-87CA-7F0060C9B02A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D4919D3F-CF85-42B9-87CA-7F0060C9B02A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D4919D3F-CF85-42B9-87CA-7F0060C9B02A}.Release|Any CPU.Build.0 = Release|Any CPU + {A66B8BB6-B5B2-4FDF-8DC4-9027D70510A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A66B8BB6-B5B2-4FDF-8DC4-9027D70510A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A66B8BB6-B5B2-4FDF-8DC4-9027D70510A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A66B8BB6-B5B2-4FDF-8DC4-9027D70510A2}.Release|Any CPU.Build.0 = Release|Any CPU + {CDC2269A-5ECB-4A24-AE88-F62D0C77BF5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CDC2269A-5ECB-4A24-AE88-F62D0C77BF5C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CDC2269A-5ECB-4A24-AE88-F62D0C77BF5C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CDC2269A-5ECB-4A24-AE88-F62D0C77BF5C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection EndGlobal diff --git a/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/TekVISANetExample/TekVISANetExample.cs b/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/TekVISANetExample/TekVISANetExample.cs index 18c931f..346a738 100644 --- a/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/TekVISANetExample/TekVISANetExample.cs +++ b/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/TekVISANetExample/TekVISANetExample.cs @@ -19,11 +19,11 @@ private static void Message(string s) private static void Main(string[] args) { //const string rsaAddress = "127.0.0.1"; - const string rsaAddress = "GPIB8::1::INSTR"; + const string rsaAddress = "GPIB8::1::INSTR"; var rsa = new VISA(); try { - rsa.Open(rsaAddress); + rsa.Open(rsaAddress); //rsa.Open(string.Format("TCPIP::{0}::INSTR", rsaAddress)); if (rsa.Status != TekVISADefs.Status.SUCCESS) { diff --git a/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/VbTekVISANetExample/VbTekVISANetExample.vb b/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/VbTekVISANetExample/VbTekVISANetExample.vb index df9f6f0..2021910 100644 --- a/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/VbTekVISANetExample/VbTekVISANetExample.vb +++ b/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/VbTekVISANetExample/VbTekVISANetExample.vb @@ -8,59 +8,59 @@ Imports TekVISANet Module VbTekVISANetExample - Private Sub Message(s As String) - Console.WriteLine("[{0}] {1}", DateTime.Now, s) - End Sub + Private Sub Message(s As String) + Console.WriteLine("[{0}] {1}", DateTime.Now, s) + End Sub - Sub Main() - Const rsaIpAddress As String = "127.0.0.1" - Dim rsa = New VISA() - Try - 'rsa.Open(String.Format("TCPIP::{0}::INSTR", rsaIpAddress)) + Sub Main() + Const rsaIpAddress As String = "127.0.0.1" + Dim rsa = New VISA() + Try + 'rsa.Open(String.Format("TCPIP::{0}::INSTR", rsaIpAddress)) rsa.Open("GPIB8::1::INSTR") - If rsa.Status <> TekVISADefs.Status.SUCCESS Then - Message(String.Format("Unable to connect to RSA at ipaddr {0}", rsaIpAddress)) - Return - End If + If rsa.Status <> TekVISADefs.Status.SUCCESS Then + Message(String.Format("Unable to connect to RSA at ipaddr {0}", rsaIpAddress)) + Return + End If - ' Confirm we are connected to the RSA. - rsa.Write("*RST") - Dim retString As String = String.Empty - rsa.Query("*IDN?", retString) - Message(Convert.ToString("Connected to: ") & rsaIpAddress) - Message(Convert.ToString("*IDN? returned ") & retString) + ' Confirm we are connected to the RSA. + rsa.Write("*RST") + Dim retString As String = String.Empty + rsa.Query("*IDN?", retString) + Message(Convert.ToString("Connected to: ") & rsaIpAddress) + Message(Convert.ToString("*IDN? returned ") & retString) - ' Preset the system, set CF to 1 GHz, 1 MHz span, and turn off continous acquisitions - rsa.Write(":SYSTEM:PRESET") - Dim retVal As Integer - rsa.Query("*OPC?", retVal) - rsa.Write("*CLS") - rsa.Write("INIT:CONT OFF") - rsa.Write(":SENSE:SPEC:FREQ:CENTER 1e9") - rsa.Write(":SENSE:SPEC:FREQ:SPAN 1e6") + ' Preset the system, set CF to 1 GHz, 1 MHz span, and turn off continous acquisitions + rsa.Write(":SYSTEM:PRESET") + Dim retVal As Integer + rsa.Query("*OPC?", retVal) + rsa.Write("*CLS") + rsa.Write("INIT:CONT OFF") + rsa.Write(":SENSE:SPEC:FREQ:CENTER 1e9") + rsa.Write(":SENSE:SPEC:FREQ:SPAN 1e6") - ' Add a marker - rsa.Write("CALCulate:MARKer:ADD") + ' Add a marker + rsa.Write("CALCulate:MARKer:ADD") - ' Take one acquisition - rsa.Write("INIT") - rsa.Query("*OPC?", retVal) + ' Take one acquisition + rsa.Write("INIT") + rsa.Query("*OPC?", retVal) - ' Use marker to find max peak - rsa.Write("CALC:SPEC:MARKer0:MAX") - Dim peakLevel As Double - rsa.Query("CALC:SPEC:MARK0:Y?", peakLevel) - Message(String.Format("Peak Amplitude is {0:0.00} dBm", peakLevel)) - Finally - ' Be a good .NET citizen and explicitly close resources. - rsa.Clear() - rsa.Close() - End Try + ' Use marker to find max peak + rsa.Write("CALC:SPEC:MARKer0:MAX") + Dim peakLevel As Double + rsa.Query("CALC:SPEC:MARK0:Y?", peakLevel) + Message(String.Format("Peak Amplitude is {0:0.00} dBm", peakLevel)) + Finally + ' Be a good .NET citizen and explicitly close resources. + rsa.Clear() + rsa.Close() + End Try - Console.WriteLine("Hit enter to close...") - Dim wait = Console.ReadLine() + Console.WriteLine("Hit enter to close...") + Dim wait = Console.ReadLine() - End Sub + End Sub End Module diff --git a/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/VbTekVISASocketExample/VbTekVISASocketExample.vb b/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/VbTekVISASocketExample/VbTekVISASocketExample.vb index 72a4efb..228c146 100644 --- a/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/VbTekVISASocketExample/VbTekVISASocketExample.vb +++ b/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/VbTekVISASocketExample/VbTekVISASocketExample.vb @@ -8,61 +8,61 @@ Imports System.Net.Sockets Imports System.IO Module VbTekVISASocketExample - Private Sub Message(s As String) - Console.WriteLine("[{0}] {1}", DateTime.Now, s) - End Sub + Private Sub Message(s As String) + Console.WriteLine("[{0}] {1}", DateTime.Now, s) + End Sub - Sub Main() - Const rsaIpAddress As String = "127.0.0.1" - Dim rsaReader As StreamReader - Dim rsaWriter As StreamWriter + Sub Main() + Const rsaIpAddress As String = "127.0.0.1" + Dim rsaReader As StreamReader + Dim rsaWriter As StreamWriter - Try - Dim rsaClient = New TcpClient(rsaIpAddress, 4000) - Dim rsaStream = rsaClient.GetStream() - rsaReader = New StreamReader(rsaStream) - rsaWriter = New StreamWriter(rsaStream) With { .AutoFlush = True } + Try + Dim rsaClient = New TcpClient(rsaIpAddress, 4000) + Dim rsaStream = rsaClient.GetStream() + rsaReader = New StreamReader(rsaStream) + rsaWriter = New StreamWriter(rsaStream) With { .AutoFlush = True } Catch e As Exception - Message(String.Format("Unable to connect to RSA at ipaddr {0}\n{1}", rsaIpAddress, e.Message)) - Return - End Try + Message(String.Format("Unable to connect to RSA at ipaddr {0}\n{1}", rsaIpAddress, e.Message)) + Return + End Try - ' Confirm we are connected to the RSA. - rsaWriter.WriteLine("*IDN?") - Dim rsaInfo = rsaReader.ReadLine() - Message(String.Format("Connected to: {0}", rsaIpAddress)) - Message("*IDN? returned " + rsaInfo) + ' Confirm we are connected to the RSA. + rsaWriter.WriteLine("*IDN?") + Dim rsaInfo = rsaReader.ReadLine() + Message(String.Format("Connected to: {0}", rsaIpAddress)) + Message("*IDN? returned " + rsaInfo) - ' Preset the system, set CF to 1 GHz, 1 MHz span, and turn off continous acquisitions - rsaWriter.WriteLine(":SYSTEM:PRESET") - rsaWriter.WriteLine("*OPC?") - rsaReader.ReadLine() - rsaWriter.WriteLine("*CLS") - rsaWriter.WriteLine("INIT:CONT OFF") - rsaWriter.WriteLine(":SENSE:SPEC:FREQ:CENTER 1e9") - rsaWriter.WriteLine(":SENSE:SPEC:FREQ:SPAN 1e6") + ' Preset the system, set CF to 1 GHz, 1 MHz span, and turn off continous acquisitions + rsaWriter.WriteLine(":SYSTEM:PRESET") + rsaWriter.WriteLine("*OPC?") + rsaReader.ReadLine() + rsaWriter.WriteLine("*CLS") + rsaWriter.WriteLine("INIT:CONT OFF") + rsaWriter.WriteLine(":SENSE:SPEC:FREQ:CENTER 1e9") + rsaWriter.WriteLine(":SENSE:SPEC:FREQ:SPAN 1e6") - ' Add a marker - rsaWriter.WriteLine("CALCulate:MARKer:ADD") + ' Add a marker + rsaWriter.WriteLine("CALCulate:MARKer:ADD") - ' Take one acquisition - rsaWriter.WriteLine("INIT") - rsaWriter.WriteLine("*OPC?") - rsaReader.ReadLine() + ' Take one acquisition + rsaWriter.WriteLine("INIT") + rsaWriter.WriteLine("*OPC?") + rsaReader.ReadLine() ' Use marker to find max peak - rsaWriter.WriteLine("CALC:SPEC:MARKer0:MAX") - rsaWriter.WriteLine("CALC:SPEC:MARK0:Y?") - Dim peakLevel = Convert.ToDouble(rsaReader.ReadLine()) - Message(String.Format("Peak Amplitude is {0:0.00} dBm", peakLevel)) + rsaWriter.WriteLine("CALC:SPEC:MARKer0:MAX") + rsaWriter.WriteLine("CALC:SPEC:MARK0:Y?") + Dim peakLevel = Convert.ToDouble(rsaReader.ReadLine()) + Message(String.Format("Peak Amplitude is {0:0.00} dBm", peakLevel)) - Console.WriteLine("Hit enter to close...") - Dim wait = Console.ReadLine() + Console.WriteLine("Hit enter to close...") + Dim wait = Console.ReadLine() - ' Be a good .NET citizen and explicitly close resources. - rsaReader.Close() - rsaWriter.Close() - End Sub + ' Be a good .NET citizen and explicitly close resources. + rsaReader.Close() + rsaWriter.Close() + End Sub End Module From c500264f46af611bcbf3965aaef75cccb18c80c4 Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Thu, 25 Jul 2024 11:25:59 -0700 Subject: [PATCH 3/8] simplify the used ruff ruleset for now --- pyproject.toml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 25e2296..885614c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -18,7 +18,14 @@ ignore = [ pydocstyle = {convention = "google"} # https://beta.ruff.rs/docs/rules/ select = [ - "ALL" + # "ALL" # TODO: enable ALL + "E", + "F", + "I", + "N", + "PLE", + "Q", + "RUF" ] [tool.ruff.lint.isort] From 01470c65d00cf32e02267afb061821d9c5d4f641 Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Thu, 25 Jul 2024 11:36:47 -0700 Subject: [PATCH 4/8] Add GitHub Workflow to perform linting and show results --- .github/workflows/code-linting.yml | 25 +++++ .github/workflows/tek-repo-lint.yml | 168 +++++----------------------- pyproject.toml | 12 +- 3 files changed, 57 insertions(+), 148 deletions(-) create mode 100644 .github/workflows/code-linting.yml diff --git a/.github/workflows/code-linting.yml b/.github/workflows/code-linting.yml new file mode 100644 index 0000000..e74479c --- /dev/null +++ b/.github/workflows/code-linting.yml @@ -0,0 +1,25 @@ +--- +name: Lint Code +on: + push: + branches: [master] + pull_request: + branches: [master] +# Cancel running jobs for the same workflow and branch. +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: ${{ github.ref != 'refs/heads/master' }} +jobs: + lint-python: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Set up Python + uses: actions/setup-python@v5 + with: + python-version: x # any version + check-latest: true + - name: Install tox + run: python -m pip install tox + - name: Test + run: tox -ve linting diff --git a/.github/workflows/tek-repo-lint.yml b/.github/workflows/tek-repo-lint.yml index a88ddb9..f640ec2 100644 --- a/.github/workflows/tek-repo-lint.yml +++ b/.github/workflows/tek-repo-lint.yml @@ -1,151 +1,43 @@ +--- name: tek-repo-lint on: push: - branches: [ "main" ] + branches: [master] pull_request: - branches: [ "main" ] + branches: [master] workflow_dispatch: -# select correct state for repository -env: - # state: private - state: public - jobs: - public-or-private-repo: - runs-on: ubuntu-latest - outputs: - repostate: ${{ steps.repo-state.outputs.repostate }} - steps: - - - name: Repo state - id: repo-state - run: echo "repostate=${{env.state}}" >> $GITHUB_OUTPUT - - name: Repo public? - if: "${{ env.state == 'public' }}" - run: echo "Workflow has repo set as public. If this is incorrect, uncomment line 11." - - name: Repo private? - if: "${{ env.state == 'private' }}" - run: echo "Workflow has repo set as private. If this is incorrect, uncomment line 12." - - check-for-codeowners-file: - runs-on: ubuntu-latest - steps: - - - name: Checkout repo - uses: actions/checkout@v3 - - - name: Check for CODEOWNERS - id: codeowners_file - uses: initialstate/file-check-action@v1 - with: - file: ".github/CODEOWNERS" - - - name: CODEOWNERS file Output Test - run: echo ${{ steps.codeowners_file.outputs.file_exists }} - - - name: CODEOWNERS file exists with content - if: steps.codeowners_file.outputs.file_exists == 'true' - run: echo CODEOWNERS file exists! - - - name: CODEOWNERS file does not exist - if: steps.codeowners_file.outputs.file_exists == 'false' - run: echo CODEOWNERS file does not exist! - - check-for-readme-file: - runs-on: ubuntu-latest - steps: - - - name: Checkout repo - uses: actions/checkout@v3 - - - name: Check for README.md - id: readme_file - uses: initialstate/file-check-action@v1 - with: - file: "README" - - - name: README file Output Test - run: echo ${{ steps.readme_file.outputs.file_exists }} - - - name: README file exists with content - if: steps.readme_file.outputs.file_exists == 'true' - run: echo README file exists! - - - name: README file does not exist - if: steps.readme_file.outputs.file_exists == 'false' - run: echo README file does not exist! - - check-for-license: - needs: public-or-private-repo - if: needs.public-or-private-repo.outputs.repostate == 'public' + check-for-file: runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + filename: + - .github/CODEOWNERS + - README.@(md|rst) + - LICENSE.@(md|rst) + - .github/ISSUE_TEMPLATE/bug_report.yml + - .github/ISSUE_TEMPLATE/feature_request.yml + - .github/PULL_REQUEST_TEMPLATE.md + - .github/dependabot.yml + - .github/workflows/codeql.yml steps: - - - name: Checkout repo - uses: actions/checkout@v3 - - - name: Check for LICENSE.md - id: license_file - uses: initialstate/file-check-action@v1 + - uses: actions/checkout@v4 + - name: Ensure ${{ matrix.filename }} exists + uses: andstor/file-existence-action@v3 with: - file: "LICENSE" - - - name: LICENSE file Output Test - run: echo ${{ steps.license_file.outputs.file_exists }} - - - name: LICENSE file exists with content - if: steps.license_file.outputs.file_exists == 'true' - run: echo LICENSE file exists! - - - name: LICENSE file does not exist - if: steps.license_file.outputs.file_exists == 'false' - run: echo LICENSE file does not exist! - - check-for-dependabot-file: + files: ${{ matrix.filename }} + ignore_case: false + follow_symbolic_links: false + fail: true # Set the step to fail if the file doesn't exist + # Check that all jobs passed + check-repo-lint-passed: + if: ${{ !cancelled() }} + needs: [check-for-file] runs-on: ubuntu-latest steps: - - - name: Checkout repo - uses: actions/checkout@v3 - - - name: Check for dependabot.yml - id: dependabot_file - uses: initialstate/file-check-action@v1 + - name: Decide whether the needed jobs succeeded or failed + uses: re-actors/alls-green@release/v1 with: - file: ".github/dependabot.yml" - - - name: dependabot.yml file Output Test - run: echo ${{ steps.dependabot_file.outputs.file_exists }} - - - name: dependabot file exists with content - if: steps.dependabot_file.outputs.file_exists == 'true' - run: echo dependabot file exists! - - - name: dependabot file does not exist - if: steps.dependabot_file.outputs.file_exists == 'false' - run: echo dependabot file does not exist! - - check-for-codeql-file: - runs-on: ubuntu-latest - steps: - - - name: Checkout repo - uses: actions/checkout@v3 - - - name: Check for codeql-analysis.yml - id: codeql-analysis_file - uses: initialstate/file-check-action@v1 - with: - file: ".github/workflows/codeql-analysis.yml" - - - name: codeql-analysis.yml file Output Test - run: echo ${{ steps.codeql-analysis_file.outputs.file_exists }} - - - name: codeql-analysis file exists with content - if: steps.codeql-analysis_file.outputs.file_exists == 'true' - run: echo codeql-analysis file exists! - - - name: codeql-analysis file does not exist - if: steps.codeql-analysis_file.outputs.file_exists == 'false' - run: echo codeql-analysis file does not exist! + jobs: ${{ toJSON(needs) }} diff --git a/pyproject.toml b/pyproject.toml index 885614c..e471d6c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -43,18 +43,10 @@ legacy_tox_ini = """ [tox] requires = tox>4 no_package = True -envlist = py38,py39,py310,py311,py312 +envlist = linting skip_missing_interpreters = True -[gh-actions] -python = - 3.8: py38 - 3.9: py39 - 3.10: py310 - 3.11: py311 - 3.12: py312 - -[testenv] +[testenv:linting] deps = pre-commit commands = From da77adf390b70ad7b8726d41629a4d7d29a7196f Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Thu, 25 Jul 2024 11:38:54 -0700 Subject: [PATCH 5/8] Turn off the tab checking hooks --- .pre-commit-config.yaml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 3df902c..0152410 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,11 +16,12 @@ repos: - id: check-case-conflict - id: check-merge-conflict - id: forbid-submodules - - repo: https://github.com/Lucas-C/pre-commit-hooks - rev: v1.5.5 - hooks: - - id: remove-tabs - - id: forbid-tabs +# TODO: enable these hooks +# - repo: https://github.com/Lucas-C/pre-commit-hooks +# rev: v1.5.5 +# hooks: +# - id: remove-tabs +# - id: forbid-tabs - repo: https://github.com/python-jsonschema/check-jsonschema rev: 0.29.0 hooks: From c9dd6ba7dd9454e800e2b5295c90399768310de9 Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Thu, 25 Jul 2024 11:40:43 -0700 Subject: [PATCH 6/8] Revert "whitespace changes on files (removing tabs and replacing with spaces)" This reverts commit 4637c66923429feab97c68da9796d239ae814134. --- .../SaveHardcopyExample/save_hardcopy_c++.c | 138 ++-- .../CurvestreamExample-IVI-VISA.NET.sln | 26 +- .../app.config | 6 +- .../CurvestreamExample.sln | 26 +- .../CurvestreamExample/app.config | 16 +- ...0SX_UltrasyncTimeSyncModeControlExample.py | 626 +++++++++--------- .../ExtractTriggerExample/WFM-Timestamp.sln | 32 +- .../Save_Frames_Individually.sln | 40 +- .../Tek5k7k70k_CheckClippingStatus.py | 10 +- .../CurveQueryWinforms.sln | 32 +- .../src/CSharpHelloScope/HelloScope.sln | 32 +- .../dpt_test_example.py | 14 +- .../PWS4000_sourcevoltage_measure_example.cpp | 112 ++-- .../matlab/AFG31k_send_arb.m | 4 +- .../rf_generic_data_marker.py | 2 +- .../SignalVuExamples/C++/main.cpp | 112 ++-- ...Sweep_Plot_Trace_with_Basic_Find_Peaks_c.m | 2 +- .../MATLAB/RSA6100A_PeakFinder/rtslid.m | 72 +- .../dotNet/TekVISAExamples.sln | 50 +- .../TekVISANetExample/TekVISANetExample.cs | 4 +- .../VbTekVISANetExample.vb | 88 +-- .../VbTekVISASocketExample.vb | 88 +-- 22 files changed, 766 insertions(+), 766 deletions(-) diff --git a/Examples/Oscilloscopes/MidrangeScopes/src/SaveHardcopyExample/save_hardcopy_c++.c b/Examples/Oscilloscopes/MidrangeScopes/src/SaveHardcopyExample/save_hardcopy_c++.c index 77047e1..5cb6a0f 100644 --- a/Examples/Oscilloscopes/MidrangeScopes/src/SaveHardcopyExample/save_hardcopy_c++.c +++ b/Examples/Oscilloscopes/MidrangeScopes/src/SaveHardcopyExample/save_hardcopy_c++.c @@ -21,85 +21,85 @@ int main() { - ViStatus status; - ViSession defaultRM, instr; - ViUInt32 retCount; - ViChar buffer[80000]; + ViStatus status; + ViSession defaultRM, instr; + ViUInt32 retCount; + ViChar buffer[80000]; - // Modify the following line to configure this script for your instrument - char resourceString[] = "TCPIP::10.233.70.92::INSTR"; - ViBuf scpi; + // Modify the following line to configure this script for your instrument + char resourceString[] = "TCPIP::10.233.70.92::INSTR"; + ViBuf scpi; - // Where to save (PC side) - char target_path[] = "C:\\tempx\\"; - char target_name[] = "scope_screenshot.png"; - char full_path[256]; + // Where to save (PC side) + char target_path[] = "C:\\tempx\\"; + char target_name[] = "scope_screenshot.png"; + char full_path[256]; - // Initialize VISA session - status = viOpenDefaultRM(&defaultRM);; - if (status < VI_SUCCESS) { - printf("Failed to initialize\n"); - return -1; - } + // Initialize VISA session + status = viOpenDefaultRM(&defaultRM);; + if (status < VI_SUCCESS) { + printf("Failed to initialize\n"); + return -1; + } - // Open instrument connection - status = viOpen(defaultRM, resourceString, VI_NULL, VI_NULL, &instr); - if (status < VI_SUCCESS) { - printf("Error connecting to instrument\n"); - viStatusDesc(defaultRM, status, buffer); - printf("%s\n", buffer); - return 0; - } + // Open instrument connection + status = viOpen(defaultRM, resourceString, VI_NULL, VI_NULL, &instr); + if (status < VI_SUCCESS) { + printf("Error connecting to instrument\n"); + viStatusDesc(defaultRM, status, buffer); + printf("%s\n", buffer); + return 0; + } - // Set timeout - status = viSetAttribute(instr, VI_ATTR_TMO_VALUE, 10000); + // Set timeout + status = viSetAttribute(instr, VI_ATTR_TMO_VALUE, 10000); - // Configure scope for screenshot, see programmers manual for scope-specific syntax - // Setting where to save screenshot on scope - scpi = "SAVE:IMAGE \"C:\\screenshots\\tek.png\"\n"; - status = viWrite(instr, scpi, (ViUInt32)strlen(scpi), &retCount); - if (status < VI_SUCCESS) { - printf("Error writing to instrument\n"); - viStatusDesc(defaultRM, status, buffer); - printf("%s\n", buffer); - return 0; - } + // Configure scope for screenshot, see programmers manual for scope-specific syntax + // Setting where to save screenshot on scope + scpi = "SAVE:IMAGE \"C:\\screenshots\\tek.png\"\n"; + status = viWrite(instr, scpi, (ViUInt32)strlen(scpi), &retCount); + if (status < VI_SUCCESS) { + printf("Error writing to instrument\n"); + viStatusDesc(defaultRM, status, buffer); + printf("%s\n", buffer); + return 0; + } - // Transfer screenshot to PC - status = viWrite(instr, "FILESystem:READFile \"C:\\screenshots\\tek.png\"\n", 45, &retCount); - if (status < VI_SUCCESS) { - printf("Error writing to instrument\n"); - viStatusDesc(defaultRM, status, buffer); - printf("%s\n", buffer); - return 0; - } - status = viRead(instr, buffer, sizeof(buffer), &retCount); - if (status < VI_SUCCESS) { - printf("Error reading from instrument\n"); - viStatusDesc(defaultRM, status, buffer); - printf("%s\n", buffer); - return 0; - } + // Transfer screenshot to PC + status = viWrite(instr, "FILESystem:READFile \"C:\\screenshots\\tek.png\"\n", 45, &retCount); + if (status < VI_SUCCESS) { + printf("Error writing to instrument\n"); + viStatusDesc(defaultRM, status, buffer); + printf("%s\n", buffer); + return 0; + } + status = viRead(instr, buffer, sizeof(buffer), &retCount); + if (status < VI_SUCCESS) { + printf("Error reading from instrument\n"); + viStatusDesc(defaultRM, status, buffer); + printf("%s\n", buffer); + return 0; + } - snprintf(full_path, sizeof(full_path), "%s%s", target_path, target_name); - FILE* file = fopen(full_path, "wb"); - if (file == NULL) { - printf("Failed to open file for writing.\n"); - return -1; - } + snprintf(full_path, sizeof(full_path), "%s%s", target_path, target_name); + FILE* file = fopen(full_path, "wb"); + if (file == NULL) { + printf("Failed to open file for writing.\n"); + return -1; + } - size_t bytesWritten = fwrite(buffer, 1, retCount, file); + size_t bytesWritten = fwrite(buffer, 1, retCount, file); - // Check if the write operation was successful - if (bytesWritten != buffer) { - perror("Error writing to the file"); - fclose(file); - return 1; // Exit with an error code - } + // Check if the write operation was successful + if (bytesWritten != buffer) { + perror("Error writing to the file"); + fclose(file); + return 1; // Exit with an error code + } - fclose(file); + fclose(file); - viClose(instr); - viClose(defaultRM); - return 0; + viClose(instr); + viClose(defaultRM); + return 0; } \ No newline at end of file diff --git a/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-IVI-VISA.NET/CurvestreamExample-IVI-VISA.NET.sln b/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-IVI-VISA.NET/CurvestreamExample-IVI-VISA.NET.sln index 8bc4403..42f69fd 100644 --- a/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-IVI-VISA.NET/CurvestreamExample-IVI-VISA.NET.sln +++ b/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-IVI-VISA.NET/CurvestreamExample-IVI-VISA.NET.sln @@ -4,17 +4,17 @@ Microsoft Visual Studio Solution File, Format Version 11.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CurvestreamExample-IVI-VISA.NET", "CurvestreamExample-IVI-VISA.NET\CurvestreamExample-IVI-VISA.NET.csproj", "{09335BF5-9F20-4FD5-9948-4F88ABBE45BB}" EndProject Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Debug|x86.ActiveCfg = Debug|x86 - {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Debug|x86.Build.0 = Debug|x86 - {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Release|x86.ActiveCfg = Release|x86 - {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Debug|x86.ActiveCfg = Debug|x86 + {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Debug|x86.Build.0 = Debug|x86 + {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Release|x86.ActiveCfg = Release|x86 + {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection EndGlobal diff --git a/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-IVI-VISA.NET/CurvestreamExample-IVI-VISA.NET/app.config b/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-IVI-VISA.NET/CurvestreamExample-IVI-VISA.NET/app.config index 7c9eba5..c37450c 100644 --- a/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-IVI-VISA.NET/CurvestreamExample-IVI-VISA.NET/app.config +++ b/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-IVI-VISA.NET/CurvestreamExample-IVI-VISA.NET/app.config @@ -1,6 +1,6 @@ - - - + + + diff --git a/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-NI-VISA/CurvestreamExample.sln b/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-NI-VISA/CurvestreamExample.sln index 23f403f..7f2e1df 100644 --- a/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-NI-VISA/CurvestreamExample.sln +++ b/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-NI-VISA/CurvestreamExample.sln @@ -4,17 +4,17 @@ Microsoft Visual Studio Solution File, Format Version 11.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Curve Stream Example", "CurvestreamExample\CurvestreamExample.csproj", "{09335BF5-9F20-4FD5-9948-4F88ABBE45BB}" EndProject Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x86 = Debug|x86 - Release|x86 = Release|x86 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Debug|x86.ActiveCfg = Debug|x86 - {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Debug|x86.Build.0 = Debug|x86 - {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Release|x86.ActiveCfg = Release|x86 - {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Release|x86.Build.0 = Release|x86 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|x86 = Debug|x86 + Release|x86 = Release|x86 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Debug|x86.ActiveCfg = Debug|x86 + {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Debug|x86.Build.0 = Debug|x86 + {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Release|x86.ActiveCfg = Release|x86 + {09335BF5-9F20-4FD5-9948-4F88ABBE45BB}.Release|x86.Build.0 = Release|x86 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection EndGlobal diff --git a/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-NI-VISA/CurvestreamExample/app.config b/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-NI-VISA/CurvestreamExample/app.config index 0c0dfc3..78310c9 100644 --- a/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-NI-VISA/CurvestreamExample/app.config +++ b/Examples/Oscilloscopes/PerformanceScopes/src/CurvestreamExample/CurvestreamExample-NI-VISA/CurvestreamExample/app.config @@ -1,11 +1,11 @@ - - - - - - - - + + + + + + + + diff --git a/Examples/Oscilloscopes/PerformanceScopes/src/DPO70000SX_UltrasyncTimeSyncModeControlExample/DPO70000SX_UltrasyncTimeSyncModeControlExample.py b/Examples/Oscilloscopes/PerformanceScopes/src/DPO70000SX_UltrasyncTimeSyncModeControlExample/DPO70000SX_UltrasyncTimeSyncModeControlExample.py index 5fb1b73..0b583c6 100644 --- a/Examples/Oscilloscopes/PerformanceScopes/src/DPO70000SX_UltrasyncTimeSyncModeControlExample/DPO70000SX_UltrasyncTimeSyncModeControlExample.py +++ b/Examples/Oscilloscopes/PerformanceScopes/src/DPO70000SX_UltrasyncTimeSyncModeControlExample/DPO70000SX_UltrasyncTimeSyncModeControlExample.py @@ -45,210 +45,210 @@ horizontalPosition = 20.0 # 20% trigSource = 'AUX' -trigSlope = 'RISE' # RISe|FALL|EITHER +trigSlope = 'RISE' # RISe|FALL|EITHER trigLevel = 200e-3 vertScales = { - 'master' : { 'ch1' : 50e-3, 'ch2' : 50e-3, 'ch3' : 50e-3, 'ch4' : 50e-3}, - 'extB' : { 'ch1' : 50e-3, 'ch2' : 50e-3, 'ch3' : 50e-3, 'ch4' : 50e-3}, - 'extC' : { 'ch1' : 50e-3, 'ch2' : 50e-3, 'ch3' : 50e-3, 'ch4' : 50e-3}, - 'extD' : { 'ch1' : 50e-3, 'ch2' : 50e-3, 'ch3' : 50e-3, 'ch4' : 50e-3}, + 'master' : { 'ch1' : 50e-3, 'ch2' : 50e-3, 'ch3' : 50e-3, 'ch4' : 50e-3}, + 'extB' : { 'ch1' : 50e-3, 'ch2' : 50e-3, 'ch3' : 50e-3, 'ch4' : 50e-3}, + 'extC' : { 'ch1' : 50e-3, 'ch2' : 50e-3, 'ch3' : 50e-3, 'ch4' : 50e-3}, + 'extD' : { 'ch1' : 50e-3, 'ch2' : 50e-3, 'ch3' : 50e-3, 'ch4' : 50e-3}, } # ================= class ConsoleLog: - # Simple class for printing messages to the console and logging them to a file - logfile = None - - def __init__(self, logFilePath : str) -> None: - self.logfile = open(logFileName, 'w') - self.Write('Log File Opened') - - def Write(self, msg : str, endl='\n'): - # Prints messages to the console and writes them to the console log - timestampStr = datetime.now().strftime("%Y-%m-%d %H:%M:%S - ") - print(timestampStr + str(msg), end=endl) - self.logfile.write(timestampStr + str(msg) + endl) - - def Close(self) -> None: - if self.logfile != None: - self.logfile.close() + # Simple class for printing messages to the console and logging them to a file + logfile = None + + def __init__(self, logFilePath : str) -> None: + self.logfile = open(logFileName, 'w') + self.Write('Log File Opened') + + def Write(self, msg : str, endl='\n'): + # Prints messages to the console and writes them to the console log + timestampStr = datetime.now().strftime("%Y-%m-%d %H:%M:%S - ") + print(timestampStr + str(msg), end=endl) + self.logfile.write(timestampStr + str(msg) + endl) + + def Close(self) -> None: + if self.logfile != None: + self.logfile.close() def WaitOperationComplete(vi : visa.resources.MessageBasedResource, timeoutms : int = None): - # Waits for any operations that will raise the OPC flag to complete before returning - # Use timeout to set how long to wait. If timeout is None then current timeout value for the VISA session will be used. - temp = None - if timeoutms != None: - temp = vi.timeout - vi.timeout = timeoutms - - vi.query('*OPC?') - - if timeoutms != None: - vi.timeout = temp + # Waits for any operations that will raise the OPC flag to complete before returning + # Use timeout to set how long to wait. If timeout is None then current timeout value for the VISA session will be used. + temp = None + if timeoutms != None: + temp = vi.timeout + vi.timeout = timeoutms + + vi.query('*OPC?') + + if timeoutms != None: + vi.timeout = temp def ErrorQuery(vi : visa.resources.MessageBasedResource): - return vi.query('*ESR?;ALLEV?;') + return vi.query('*ESR?;ALLEV?;') def SetRunState(vi : visa.resources.MessageBasedResource, run : bool): - # Sets the scope into the Running or the Stopped states - state = 'RUN' if run==True else 'STOP' - vi.write(f'ACQ:STATE {state}') + # Sets the scope into the Running or the Stopped states + state = 'RUN' if run==True else 'STOP' + vi.write(f'ACQ:STATE {state}') def StartAcquiring(vi : visa.resources.MessageBasedResource, waitUntilFirstAcqComplete : bool = False, waitTimeoutSec : float = 10.0): - # Functionally equivalent to pressing the Run/Stop button on the front panel to start acquisitions - # Can optionally block function call from returning until at least one acqusition is made by setting - # waitUntilFirstAcqComplete to True. waitTimeout sets how long to wait. - vi.write('ACQ:STOPAFTER RUNSTOP') - SetRunState(vi, True) - acqState = int(vi.query('ACQ:STATE?')) - while acqState != 1: - time.sleep(0.2) - acqState = int(vi.query('ACQ:STATE?')) - - if waitUntilFirstAcqComplete == True: - tWaitStart = time.perf_counter() - acqCount = int(master.query('ACQ:NUMACQ?')) - while acqCount < 1: - if time.perf_counter() - tWaitStart > waitTimeoutSec: - break - time.sleep(0.1) - acqCount = int(master.query('ACQ:NUMACQ?')) + # Functionally equivalent to pressing the Run/Stop button on the front panel to start acquisitions + # Can optionally block function call from returning until at least one acqusition is made by setting + # waitUntilFirstAcqComplete to True. waitTimeout sets how long to wait. + vi.write('ACQ:STOPAFTER RUNSTOP') + SetRunState(vi, True) + acqState = int(vi.query('ACQ:STATE?')) + while acqState != 1: + time.sleep(0.2) + acqState = int(vi.query('ACQ:STATE?')) + + if waitUntilFirstAcqComplete == True: + tWaitStart = time.perf_counter() + acqCount = int(master.query('ACQ:NUMACQ?')) + while acqCount < 1: + if time.perf_counter() - tWaitStart > waitTimeoutSec: + break + time.sleep(0.1) + acqCount = int(master.query('ACQ:NUMACQ?')) def StopAcquiring(vi : visa.resources.MessageBasedResource): - # Functionally equivalent to pressing the Run/Stop button on the front panel to stop acquisitions - SetRunState(vi, False) - acqState = int(vi.query('ACQ:STATE?')) - while acqState != 0: - time.sleep(0.2) - acqState = int(vi.query('ACQ:STATE?')) - WaitOperationComplete(vi) + # Functionally equivalent to pressing the Run/Stop button on the front panel to stop acquisitions + SetRunState(vi, False) + acqState = int(vi.query('ACQ:STATE?')) + while acqState != 0: + time.sleep(0.2) + acqState = int(vi.query('ACQ:STATE?')) + WaitOperationComplete(vi) def WaitTriggerReady(vi : visa.resources.MessageBasedResource, timeoutSec : float = 10.0) -> bool: - # Function returns when the trigger is ready - - # Check that scope is in run state - if int(vi.query('ACQ:STATE?')) != 1: - return False - - trigReady = 0 - tWaitStart = time.perf_counter() - trigReady = int(master.query('TRIG:A:READY?')) - while trigReady != 1: - if time.perf_counter() - tWaitStart > timeoutSec: - break - time.sleep(0.1) - trigReady = int(master.query('TRIG:A:READY?')) - - if trigReady == 1: - return True - - return False + # Function returns when the trigger is ready + + # Check that scope is in run state + if int(vi.query('ACQ:STATE?')) != 1: + return False + + trigReady = 0 + tWaitStart = time.perf_counter() + trigReady = int(master.query('TRIG:A:READY?')) + while trigReady != 1: + if time.perf_counter() - tWaitStart > timeoutSec: + break + time.sleep(0.1) + trigReady = int(master.query('TRIG:A:READY?')) + + if trigReady == 1: + return True + + return False # These Single Sequence functions are the equivalent of pressing the Single button on the front panel def InitiateSingleSequnce(vi : visa.resources.MessageBasedResource): - # Starts a Single Sequence and returns - vi.write('ACQ:STOPAFTER SEQ') - vi.write('ACQ:STATE RUN') + # Starts a Single Sequence and returns + vi.write('ACQ:STOPAFTER SEQ') + vi.write('ACQ:STATE RUN') def ExcuteSingleSequence(vi : visa.resources.MessageBasedResource, timeoutms : int): - # Starts a Single Sequence and waits until the scope has triggered and the acquisition is complete before returning. - temp = vi.timeout - vi.timeout = timeoutms - vi.write('ACQ:STOPAFTER SEQ') - vi.write('ACQ:STATE RUN') - vi.query('*OPC?') - vi.timeout = temp + # Starts a Single Sequence and waits until the scope has triggered and the acquisition is complete before returning. + temp = vi.timeout + vi.timeout = timeoutms + vi.write('ACQ:STOPAFTER SEQ') + vi.write('ACQ:STATE RUN') + vi.query('*OPC?') + vi.timeout = temp def InitializeStack(vi : visa.resources.MessageBasedResource): - # Performs a Default Setup on the stack and waits for it to complete before returning. This should only be called on the Master. - master.write('*CLS') - vi.write('*RST') - vi.query('*OPC?') + # Performs a Default Setup on the stack and waits for it to complete before returning. This should only be called on the Master. + master.write('*CLS') + vi.write('*RST') + vi.query('*OPC?') def SetVerticalScale(vi : visa.resources.MessageBasedResource, channel : str, scale : float): - # Sets the vertical scale of the channel. 'channel' should be the name of the channel i.e. "CH1", "MATH1", "REF1", etc. - vi.write(f'{channel}:SCALE {scale}') + # Sets the vertical scale of the channel. 'channel' should be the name of the channel i.e. "CH1", "MATH1", "REF1", etc. + vi.write(f'{channel}:SCALE {scale}') def SetupChannels(vi : visa.resources.MessageBasedResource, ch1Scale : float, ch2Scale : float, ch3Scale : float, ch4Scale : float): - # Turns on all the channels on the scope and sets the vertical scale of each - vi.write(':SEL:CH1 ON;CH2 ON;CH3 ON;CH4 ON;') # Turn all the channels on - SetVerticalScale(vi, 'CH1', ch1Scale) - SetVerticalScale(vi, 'CH2', ch2Scale) - SetVerticalScale(vi, 'CH3', ch3Scale) - SetVerticalScale(vi, 'CH4', ch4Scale) - vi.write('*WAI') + # Turns on all the channels on the scope and sets the vertical scale of each + vi.write(':SEL:CH1 ON;CH2 ON;CH3 ON;CH4 ON;') # Turn all the channels on + SetVerticalScale(vi, 'CH1', ch1Scale) + SetVerticalScale(vi, 'CH2', ch2Scale) + SetVerticalScale(vi, 'CH3', ch3Scale) + SetVerticalScale(vi, 'CH4', ch4Scale) + vi.write('*WAI') def SetupHorizontal(vi : visa.resources.MessageBasedResource, sampleRate : float, recordLength : float, horizontalPos : float = 50): - # Configures the horizontal settings of the stack. Should only be called on the Master. - - vi.write('HOR:MODE MAN;*WAI;') - time.sleep(2) # Horizontal commands must trickle down to extensions so pace these commands - vi.write(f'HOR:MODE:SAMPLERATE {sampleRate};*WAI;') - time.sleep(2) - vi.write(f'HOR:MODE:RECORDLENGTH {recordLength};*WAI;') - time.sleep(2) - vi.write(f'HOR:POS {horizontalPos};*WAI;') - time.sleep(2) + # Configures the horizontal settings of the stack. Should only be called on the Master. + + vi.write('HOR:MODE MAN;*WAI;') + time.sleep(2) # Horizontal commands must trickle down to extensions so pace these commands + vi.write(f'HOR:MODE:SAMPLERATE {sampleRate};*WAI;') + time.sleep(2) + vi.write(f'HOR:MODE:RECORDLENGTH {recordLength};*WAI;') + time.sleep(2) + vi.write(f'HOR:POS {horizontalPos};*WAI;') + time.sleep(2) def SetupEdgeTrigger(vi : visa.resources.MessageBasedResource, trigSource : str, trigSlope : str, trigLevel : float, trigMode : str = 'AUTO'): - # Configures the trigger settings. Should only be called on the Master. Only the Master can be used to trigger in Time-sync mode - vi.write(f'TRIG:A:TYPE EDGE') - vi.write(f'TRIG:A:EDGE:SOURCE {trigSource}') - vi.write(f'TRIG:A:EDGE:SLOPE:AUX {trigSlope}') - vi.write(f'TRIG:A:LEVEL {trigLevel}') - vi.write(f'TRIG:A:MODE {trigMode}') - vi.write('*WAI') + # Configures the trigger settings. Should only be called on the Master. Only the Master can be used to trigger in Time-sync mode + vi.write(f'TRIG:A:TYPE EDGE') + vi.write(f'TRIG:A:EDGE:SOURCE {trigSource}') + vi.write(f'TRIG:A:EDGE:SLOPE:AUX {trigSlope}') + vi.write(f'TRIG:A:LEVEL {trigLevel}') + vi.write(f'TRIG:A:MODE {trigMode}') + vi.write('*WAI') def TakeScreenshot(vi : visa.resources.MessageBasedResource, localFolderPath : str, pngFileName : str): - # Takes a screenshot and transfers it to the local PC. pngFileName should include the extension ".png" - vi.write("HARDCOPY:PORT FILE") - vi.write("HARDCopy:PALETTE COLOR") - vi.write("EXPORT:FORMAT PNG") - vi.write("HARDCopy:FILEName \"C:\\Users\\Tek_local_admin\\Pictures\\Temp.png\"") - vi.write("HARDCopy STARt") - vi.query('*OPC?') - vi.write("FILESystem:READFile \"C:\\Users\\Tek_local_admin\\Pictures\\Temp.png\"") - imgData = vi.read_raw() - # Save the transfered image to the hard drive of your PC - imgFile = open(localFolderPath + pngFileName, "wb") - imgFile.write(imgData) - imgFile.close() - - # Delete the image file from the scope's hard drive. - vi.write("FILESystem:DELEte \"C:\\Users\\Tek_local_admin\\Pictures\\Temp.png\"") - return + # Takes a screenshot and transfers it to the local PC. pngFileName should include the extension ".png" + vi.write("HARDCOPY:PORT FILE") + vi.write("HARDCopy:PALETTE COLOR") + vi.write("EXPORT:FORMAT PNG") + vi.write("HARDCopy:FILEName \"C:\\Users\\Tek_local_admin\\Pictures\\Temp.png\"") + vi.write("HARDCopy STARt") + vi.query('*OPC?') + vi.write("FILESystem:READFile \"C:\\Users\\Tek_local_admin\\Pictures\\Temp.png\"") + imgData = vi.read_raw() + # Save the transfered image to the hard drive of your PC + imgFile = open(localFolderPath + pngFileName, "wb") + imgFile.write(imgData) + imgFile.close() + + # Delete the image file from the scope's hard drive. + vi.write("FILESystem:DELEte \"C:\\Users\\Tek_local_admin\\Pictures\\Temp.png\"") + return def SaveAllWfmsToDisk(vi : visa.resources.MessageBasedResource, remoteFilePath, filename, waitComplete : bool = True): - # Saves all waveforms on screen to the scope's local disk. - # "remoteFilePath" specifies the folder on the scope where the files should be saved. - # "filename" should NOT include the extention i.e. DO NOT include ".wfm" - # waitComplete will determine if the function will wait for the save operation to complete before returning - vi.write(f'SAVE:WAVEFORM ALL,"{remoteFilePath + filename}"') + # Saves all waveforms on screen to the scope's local disk. + # "remoteFilePath" specifies the folder on the scope where the files should be saved. + # "filename" should NOT include the extention i.e. DO NOT include ".wfm" + # waitComplete will determine if the function will wait for the save operation to complete before returning + vi.write(f'SAVE:WAVEFORM ALL,"{remoteFilePath + filename}"') - if waitComplete: - vi.query('*OPC?') + if waitComplete: + vi.query('*OPC?') def FetchFile(vi : visa.resources.MessageBasedResource, remoteFileFolder : str, fileName : str, localFolderPath : str): - # Fetches a file from the scope and saves it to the local PC - vi.write(f'FILESystem:READFile \"{remoteFileFolder}{fileName}\"') - fileData = vi.read_raw(2 * 1024 * 1024) + # Fetches a file from the scope and saves it to the local PC + vi.write(f'FILESystem:READFile \"{remoteFileFolder}{fileName}\"') + fileData = vi.read_raw(2 * 1024 * 1024) - # Save the transfered file to the hard drive of your PC - file = open(localFolderPath + fileName, "wb") - file.write(fileData) - file.close() + # Save the transfered file to the hard drive of your PC + file = open(localFolderPath + fileName, "wb") + file.write(fileData) + file.close() def DeleteFile(vi : visa.resources.MessageBasedResource, remoteFileFolder : str, fileName : str): - # Deletes a file from the hard drive of the scope - vi.write(f'FILESystem:DELEte \"{remoteFileFolder}{fileName}\"') + # Deletes a file from the hard drive of the scope + vi.write(f'FILESystem:DELEte \"{remoteFileFolder}{fileName}\"') def WaitForPressAnyKey(): - return msvcrt.getch() + return msvcrt.getch() #========================================================= @@ -259,170 +259,170 @@ def WaitForPressAnyKey(): saveDataPath = localDataFolder + tScriptStart.strftime("%Y-%m-%d_%H%M%S\\") pathExists = os.path.exists(saveDataPath) if not pathExists: - os.makedirs(saveDataPath) + os.makedirs(saveDataPath) logFileName = saveDataPath + tScriptStart.strftime("%Y-%m-%d_%H%M%S_Test_Log.txt") log = ConsoleLog(logFileName) log.Write('Script Started') try: - # Connect to instruments in stack - rm = visa.ResourceManager() - log.Write('Opening connections to scopes in stack') - master : visa.resources.MessageBasedResource = rm.open_resource(masterRsrcAddr) - master.timeout = defaultTimeout - log.Write('Master: ' + master.query('*IDN?').strip()) - - extB : visa.resources.MessageBasedResource = rm.open_resource(extBRsrcAddr) - log.Write('ExtenB: ' + extB.query('*IDN?').strip()) - extB.timeout = defaultTimeout - - extC : visa.resources.MessageBasedResource = rm.open_resource(extCRsrcAddr) - log.Write('ExtenC: ' + extC.query('*IDN?').strip()) - extC.timeout = defaultTimeout - - extD : visa.resources.MessageBasedResource = rm.open_resource(extDRsrcAddr) - log.Write('ExtenD: ' + extD.query('*IDN?').strip()) - extD.timeout = defaultTimeout - - - log.Write('Resetting Stack...') - InitializeStack(master) - log.Write('Reset Done') - - log.Write('Setting up stack...') - StopAcquiring(master) - - SetupChannels(master, vertScales['master']['ch1'], vertScales['master']['ch2'], vertScales['master']['ch3'], vertScales['master']['ch4']) - SetupChannels(extB, vertScales['extB']['ch1'], vertScales['extB']['ch2'], vertScales['extB']['ch3'], vertScales['extB']['ch4']) - SetupChannels(extC, vertScales['extC']['ch1'], vertScales['extC']['ch2'], vertScales['extC']['ch3'], vertScales['extC']['ch4']) - SetupChannels(extD, vertScales['extD']['ch1'], vertScales['extD']['ch2'], vertScales['extD']['ch3'], vertScales['extD']['ch4']) - - SetupHorizontal(master, sampleRate, recordLen, horizontalPosition) - SetupEdgeTrigger(master, trigSource, trigSlope, trigLevel) - - - log.Write('Setting up stack done') - - log.Write('Starting free-running acqusitions') - StartAcquiring(master, True) - log.Write('Free-running acqusitions started') - - - print('\r\nPress any key to initiate a Single Sequence...') - WaitForPressAnyKey() - StopAcquiring(master) - time.sleep(0.2) - log.Write('Initiating Single Sequence...') - InitiateSingleSequnce(master) - time.sleep(0.2) - WaitTriggerReady(master) - log.Write('Single Sequence Initiated. Scope ready for trigger event.') - WaitOperationComplete(master, 600000) # Will wait 60 seconds before timing out - timeAcqComplete = datetime.now() - log.Write('Single Sequence Complete') - - - remoteFolder = 'C:\\Users\\Tek_Local_Admin\\Tektronix\\TekScope\\Waveforms\\' - baseFileName = timeAcqComplete.strftime("%Y-%m-%d_%H%M%S") - - log.Write('Saving waveforms to .wfm files on scopes') - SaveAllWfmsToDisk(master, remoteFolder, baseFileName + '_Master_', False) - SaveAllWfmsToDisk(extB, remoteFolder, baseFileName + '_ExtB_', False) - SaveAllWfmsToDisk(extC, remoteFolder, baseFileName + '_ExtC_', False) - SaveAllWfmsToDisk(extD, remoteFolder, baseFileName + '_ExtD_', False) - - # We didn't wait for each scope to complete before instructing the next scope to save so wait for the scopes to finish now - WaitOperationComplete(master) - WaitOperationComplete(extB) - WaitOperationComplete(extC) - WaitOperationComplete(extD) - log.Write('Saving waveforms to .wfm files on scopes complete') - - - log.Write('Fetching screenshots from scopes') - TakeScreenshot(master, saveDataPath, baseFileName + '_Master_Screenshot.png') - log.Write('Fetching screenshots from Master complete') - TakeScreenshot(extB, saveDataPath, baseFileName + '_ExtB_Screenshot.png') - log.Write('Fetching screenshots from Extension B complete') - TakeScreenshot(extC, saveDataPath, baseFileName + '_ExtC_Screenshot.png') - log.Write('Fetching screenshots from Extension C complete') - TakeScreenshot(extD, saveDataPath, baseFileName + '_ExtD_Screenshot.png') - log.Write('Fetching screenshots from Extension D complete') - - remoteFilePathBase = remoteFolder + baseFileName - log.Write('Fetching .wfm files from scopes') - FetchFile(master, remoteFolder, baseFileName + '_Master_CH1.wfm', saveDataPath) - FetchFile(master, remoteFolder, baseFileName + '_Master_CH2.wfm', saveDataPath) - FetchFile(master, remoteFolder, baseFileName + '_Master_CH3.wfm', saveDataPath) - FetchFile(master, remoteFolder, baseFileName + '_Master_CH4.wfm', saveDataPath) - log.Write('Fetching .wfm files from Master complete') - - FetchFile(extB, remoteFolder, baseFileName + '_ExtB_CH1.wfm', saveDataPath) - FetchFile(extB, remoteFolder, baseFileName + '_ExtB_CH2.wfm', saveDataPath) - FetchFile(extB, remoteFolder, baseFileName + '_ExtB_CH3.wfm', saveDataPath) - FetchFile(extB, remoteFolder, baseFileName + '_ExtB_CH4.wfm', saveDataPath) - log.Write('Fetching .wfm files from Extension B complete') - - FetchFile(extC, remoteFolder, baseFileName + '_ExtC_CH1.wfm', saveDataPath) - FetchFile(extC, remoteFolder, baseFileName + '_ExtC_CH2.wfm', saveDataPath) - FetchFile(extC, remoteFolder, baseFileName + '_ExtC_CH3.wfm', saveDataPath) - FetchFile(extC, remoteFolder, baseFileName + '_ExtC_CH4.wfm', saveDataPath) - log.Write('Fetching .wfm files from Extension C complete') - - FetchFile(extD, remoteFolder, baseFileName + '_ExtD_CH1.wfm', saveDataPath) - FetchFile(extD, remoteFolder, baseFileName + '_ExtD_CH2.wfm', saveDataPath) - FetchFile(extD, remoteFolder, baseFileName + '_ExtD_CH3.wfm', saveDataPath) - FetchFile(extD, remoteFolder, baseFileName + '_ExtD_CH4.wfm', saveDataPath) - log.Write('Fetching .wfm files from Extension D complete') - - - print('Do you want to delete .wfm files from scopes?') - userInput = input('Enter \'Y\' to delete .wfms from scopes, anything else to skip deletion: ') - if userInput == 'Y': - log.Write('Deleting .wfm files on scopes') - DeleteFile(master, remoteFolder, baseFileName + '_Master_CH1.wfm') - DeleteFile(master, remoteFolder, baseFileName + '_Master_CH2.wfm') - DeleteFile(master, remoteFolder, baseFileName + '_Master_CH3.wfm') - DeleteFile(master, remoteFolder, baseFileName + '_Master_CH4.wfm') - log.Write('Deleting .wfm files on Master complete') - - DeleteFile(extB, remoteFolder, baseFileName + '_ExtB_CH1.wfm') - DeleteFile(extB, remoteFolder, baseFileName + '_ExtB_CH2.wfm') - DeleteFile(extB, remoteFolder, baseFileName + '_ExtB_CH3.wfm') - DeleteFile(extB, remoteFolder, baseFileName + '_ExtB_CH4.wfm') - log.Write('Deleting .wfm files on Extension B complete') - - DeleteFile(extC, remoteFolder, baseFileName + '_ExtC_CH1.wfm') - DeleteFile(extC, remoteFolder, baseFileName + '_ExtC_CH2.wfm') - DeleteFile(extC, remoteFolder, baseFileName + '_ExtC_CH3.wfm') - DeleteFile(extC, remoteFolder, baseFileName + '_ExtC_CH4.wfm') - log.Write('Deleting .wfm files on Extension C complete') - - DeleteFile(extD, remoteFolder, baseFileName + '_ExtD_CH1.wfm') - DeleteFile(extD, remoteFolder, baseFileName + '_ExtD_CH2.wfm') - DeleteFile(extD, remoteFolder, baseFileName + '_ExtD_CH3.wfm') - DeleteFile(extD, remoteFolder, baseFileName + '_ExtD_CH4.wfm') - log.Write('Deleting .wfm files on Extension D complete') - - log.Write(ErrorQuery(master)) + # Connect to instruments in stack + rm = visa.ResourceManager() + log.Write('Opening connections to scopes in stack') + master : visa.resources.MessageBasedResource = rm.open_resource(masterRsrcAddr) + master.timeout = defaultTimeout + log.Write('Master: ' + master.query('*IDN?').strip()) + + extB : visa.resources.MessageBasedResource = rm.open_resource(extBRsrcAddr) + log.Write('ExtenB: ' + extB.query('*IDN?').strip()) + extB.timeout = defaultTimeout + + extC : visa.resources.MessageBasedResource = rm.open_resource(extCRsrcAddr) + log.Write('ExtenC: ' + extC.query('*IDN?').strip()) + extC.timeout = defaultTimeout + + extD : visa.resources.MessageBasedResource = rm.open_resource(extDRsrcAddr) + log.Write('ExtenD: ' + extD.query('*IDN?').strip()) + extD.timeout = defaultTimeout + + + log.Write('Resetting Stack...') + InitializeStack(master) + log.Write('Reset Done') + + log.Write('Setting up stack...') + StopAcquiring(master) + + SetupChannels(master, vertScales['master']['ch1'], vertScales['master']['ch2'], vertScales['master']['ch3'], vertScales['master']['ch4']) + SetupChannels(extB, vertScales['extB']['ch1'], vertScales['extB']['ch2'], vertScales['extB']['ch3'], vertScales['extB']['ch4']) + SetupChannels(extC, vertScales['extC']['ch1'], vertScales['extC']['ch2'], vertScales['extC']['ch3'], vertScales['extC']['ch4']) + SetupChannels(extD, vertScales['extD']['ch1'], vertScales['extD']['ch2'], vertScales['extD']['ch3'], vertScales['extD']['ch4']) + + SetupHorizontal(master, sampleRate, recordLen, horizontalPosition) + SetupEdgeTrigger(master, trigSource, trigSlope, trigLevel) + + + log.Write('Setting up stack done') + + log.Write('Starting free-running acqusitions') + StartAcquiring(master, True) + log.Write('Free-running acqusitions started') + + + print('\r\nPress any key to initiate a Single Sequence...') + WaitForPressAnyKey() + StopAcquiring(master) + time.sleep(0.2) + log.Write('Initiating Single Sequence...') + InitiateSingleSequnce(master) + time.sleep(0.2) + WaitTriggerReady(master) + log.Write('Single Sequence Initiated. Scope ready for trigger event.') + WaitOperationComplete(master, 600000) # Will wait 60 seconds before timing out + timeAcqComplete = datetime.now() + log.Write('Single Sequence Complete') + + + remoteFolder = 'C:\\Users\\Tek_Local_Admin\\Tektronix\\TekScope\\Waveforms\\' + baseFileName = timeAcqComplete.strftime("%Y-%m-%d_%H%M%S") + + log.Write('Saving waveforms to .wfm files on scopes') + SaveAllWfmsToDisk(master, remoteFolder, baseFileName + '_Master_', False) + SaveAllWfmsToDisk(extB, remoteFolder, baseFileName + '_ExtB_', False) + SaveAllWfmsToDisk(extC, remoteFolder, baseFileName + '_ExtC_', False) + SaveAllWfmsToDisk(extD, remoteFolder, baseFileName + '_ExtD_', False) + + # We didn't wait for each scope to complete before instructing the next scope to save so wait for the scopes to finish now + WaitOperationComplete(master) + WaitOperationComplete(extB) + WaitOperationComplete(extC) + WaitOperationComplete(extD) + log.Write('Saving waveforms to .wfm files on scopes complete') + + + log.Write('Fetching screenshots from scopes') + TakeScreenshot(master, saveDataPath, baseFileName + '_Master_Screenshot.png') + log.Write('Fetching screenshots from Master complete') + TakeScreenshot(extB, saveDataPath, baseFileName + '_ExtB_Screenshot.png') + log.Write('Fetching screenshots from Extension B complete') + TakeScreenshot(extC, saveDataPath, baseFileName + '_ExtC_Screenshot.png') + log.Write('Fetching screenshots from Extension C complete') + TakeScreenshot(extD, saveDataPath, baseFileName + '_ExtD_Screenshot.png') + log.Write('Fetching screenshots from Extension D complete') + + remoteFilePathBase = remoteFolder + baseFileName + log.Write('Fetching .wfm files from scopes') + FetchFile(master, remoteFolder, baseFileName + '_Master_CH1.wfm', saveDataPath) + FetchFile(master, remoteFolder, baseFileName + '_Master_CH2.wfm', saveDataPath) + FetchFile(master, remoteFolder, baseFileName + '_Master_CH3.wfm', saveDataPath) + FetchFile(master, remoteFolder, baseFileName + '_Master_CH4.wfm', saveDataPath) + log.Write('Fetching .wfm files from Master complete') + + FetchFile(extB, remoteFolder, baseFileName + '_ExtB_CH1.wfm', saveDataPath) + FetchFile(extB, remoteFolder, baseFileName + '_ExtB_CH2.wfm', saveDataPath) + FetchFile(extB, remoteFolder, baseFileName + '_ExtB_CH3.wfm', saveDataPath) + FetchFile(extB, remoteFolder, baseFileName + '_ExtB_CH4.wfm', saveDataPath) + log.Write('Fetching .wfm files from Extension B complete') + + FetchFile(extC, remoteFolder, baseFileName + '_ExtC_CH1.wfm', saveDataPath) + FetchFile(extC, remoteFolder, baseFileName + '_ExtC_CH2.wfm', saveDataPath) + FetchFile(extC, remoteFolder, baseFileName + '_ExtC_CH3.wfm', saveDataPath) + FetchFile(extC, remoteFolder, baseFileName + '_ExtC_CH4.wfm', saveDataPath) + log.Write('Fetching .wfm files from Extension C complete') + + FetchFile(extD, remoteFolder, baseFileName + '_ExtD_CH1.wfm', saveDataPath) + FetchFile(extD, remoteFolder, baseFileName + '_ExtD_CH2.wfm', saveDataPath) + FetchFile(extD, remoteFolder, baseFileName + '_ExtD_CH3.wfm', saveDataPath) + FetchFile(extD, remoteFolder, baseFileName + '_ExtD_CH4.wfm', saveDataPath) + log.Write('Fetching .wfm files from Extension D complete') + + + print('Do you want to delete .wfm files from scopes?') + userInput = input('Enter \'Y\' to delete .wfms from scopes, anything else to skip deletion: ') + if userInput == 'Y': + log.Write('Deleting .wfm files on scopes') + DeleteFile(master, remoteFolder, baseFileName + '_Master_CH1.wfm') + DeleteFile(master, remoteFolder, baseFileName + '_Master_CH2.wfm') + DeleteFile(master, remoteFolder, baseFileName + '_Master_CH3.wfm') + DeleteFile(master, remoteFolder, baseFileName + '_Master_CH4.wfm') + log.Write('Deleting .wfm files on Master complete') + + DeleteFile(extB, remoteFolder, baseFileName + '_ExtB_CH1.wfm') + DeleteFile(extB, remoteFolder, baseFileName + '_ExtB_CH2.wfm') + DeleteFile(extB, remoteFolder, baseFileName + '_ExtB_CH3.wfm') + DeleteFile(extB, remoteFolder, baseFileName + '_ExtB_CH4.wfm') + log.Write('Deleting .wfm files on Extension B complete') + + DeleteFile(extC, remoteFolder, baseFileName + '_ExtC_CH1.wfm') + DeleteFile(extC, remoteFolder, baseFileName + '_ExtC_CH2.wfm') + DeleteFile(extC, remoteFolder, baseFileName + '_ExtC_CH3.wfm') + DeleteFile(extC, remoteFolder, baseFileName + '_ExtC_CH4.wfm') + log.Write('Deleting .wfm files on Extension C complete') + + DeleteFile(extD, remoteFolder, baseFileName + '_ExtD_CH1.wfm') + DeleteFile(extD, remoteFolder, baseFileName + '_ExtD_CH2.wfm') + DeleteFile(extD, remoteFolder, baseFileName + '_ExtD_CH3.wfm') + DeleteFile(extD, remoteFolder, baseFileName + '_ExtD_CH4.wfm') + log.Write('Deleting .wfm files on Extension D complete') + + log.Write(ErrorQuery(master)) except Exception as e: - log.Write('Script Terminated early due to exception.') - log.Write(e) -finally: - tScriptEnd = datetime.now() - totalTime = tScriptEnd-tScriptStart - log.Write('Script Ended') - log.Write(f'Total Time: {totalTime}') - log.Close() - if master is not None: - master.close() - if extB is not None: - extB.close() - if extD is not None: - extD.close() - if extD is not None: - extD.close() - if rm is not None: - rm.close() + log.Write('Script Terminated early due to exception.') + log.Write(e) +finally: + tScriptEnd = datetime.now() + totalTime = tScriptEnd-tScriptStart + log.Write('Script Ended') + log.Write(f'Total Time: {totalTime}') + log.Close() + if master is not None: + master.close() + if extB is not None: + extB.close() + if extD is not None: + extD.close() + if extD is not None: + extD.close() + if rm is not None: + rm.close() diff --git a/Examples/Oscilloscopes/PerformanceScopes/src/ExtractTriggerExample/WFM-Timestamp.sln b/Examples/Oscilloscopes/PerformanceScopes/src/ExtractTriggerExample/WFM-Timestamp.sln index 5253c35..8a6c105 100644 --- a/Examples/Oscilloscopes/PerformanceScopes/src/ExtractTriggerExample/WFM-Timestamp.sln +++ b/Examples/Oscilloscopes/PerformanceScopes/src/ExtractTriggerExample/WFM-Timestamp.sln @@ -6,20 +6,20 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WFM-Timestamp", "WFM-Timestamp\WFM-Timestamp.csproj", "{AF51348B-7FB1-4426-B3BC-469FE5D53D8F}" EndProject Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {AF51348B-7FB1-4426-B3BC-469FE5D53D8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {AF51348B-7FB1-4426-B3BC-469FE5D53D8F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {AF51348B-7FB1-4426-B3BC-469FE5D53D8F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {AF51348B-7FB1-4426-B3BC-469FE5D53D8F}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {916229EE-E0FF-4CD7-8D4F-1F9102E59568} - EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {AF51348B-7FB1-4426-B3BC-469FE5D53D8F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {AF51348B-7FB1-4426-B3BC-469FE5D53D8F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {AF51348B-7FB1-4426-B3BC-469FE5D53D8F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {AF51348B-7FB1-4426-B3BC-469FE5D53D8F}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {916229EE-E0FF-4CD7-8D4F-1F9102E59568} + EndGlobalSection EndGlobal diff --git a/Examples/Oscilloscopes/PerformanceScopes/src/Save_Frames_Individually/Save_Frames_Individually.sln b/Examples/Oscilloscopes/PerformanceScopes/src/Save_Frames_Individually/Save_Frames_Individually.sln index 472a9c7..b286d36 100644 --- a/Examples/Oscilloscopes/PerformanceScopes/src/Save_Frames_Individually/Save_Frames_Individually.sln +++ b/Examples/Oscilloscopes/PerformanceScopes/src/Save_Frames_Individually/Save_Frames_Individually.sln @@ -10,24 +10,24 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "VisaWrapper", "..\..\..\OneDrive - Fortive\Documents\Retrieved files from 2000-2008\TDS Stuff\TDS Control\GUI prototyping in Visual Studio\VisaWrapper\VisaWrapper.csproj", "{DD0CA08E-0836-47CF-A51A-C66C7B5CB79C}" EndProject Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B7F58C17-C9DF-41D2-BF24-6974083388E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B7F58C17-C9DF-41D2-BF24-6974083388E5}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B7F58C17-C9DF-41D2-BF24-6974083388E5}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B7F58C17-C9DF-41D2-BF24-6974083388E5}.Release|Any CPU.Build.0 = Release|Any CPU - {DD0CA08E-0836-47CF-A51A-C66C7B5CB79C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DD0CA08E-0836-47CF-A51A-C66C7B5CB79C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DD0CA08E-0836-47CF-A51A-C66C7B5CB79C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DD0CA08E-0836-47CF-A51A-C66C7B5CB79C}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {2C74A564-ABC1-4DD5-865F-A0A46748C697} - EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B7F58C17-C9DF-41D2-BF24-6974083388E5}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B7F58C17-C9DF-41D2-BF24-6974083388E5}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B7F58C17-C9DF-41D2-BF24-6974083388E5}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B7F58C17-C9DF-41D2-BF24-6974083388E5}.Release|Any CPU.Build.0 = Release|Any CPU + {DD0CA08E-0836-47CF-A51A-C66C7B5CB79C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {DD0CA08E-0836-47CF-A51A-C66C7B5CB79C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {DD0CA08E-0836-47CF-A51A-C66C7B5CB79C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {DD0CA08E-0836-47CF-A51A-C66C7B5CB79C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {2C74A564-ABC1-4DD5-865F-A0A46748C697} + EndGlobalSection EndGlobal diff --git a/Examples/Oscilloscopes/PerformanceScopes/src/Tek5k7k70k_CheckClippingStatus/Tek5k7k70k_CheckClippingStatus.py b/Examples/Oscilloscopes/PerformanceScopes/src/Tek5k7k70k_CheckClippingStatus/Tek5k7k70k_CheckClippingStatus.py index bf286d3..525e3e1 100644 --- a/Examples/Oscilloscopes/PerformanceScopes/src/Tek5k7k70k_CheckClippingStatus/Tek5k7k70k_CheckClippingStatus.py +++ b/Examples/Oscilloscopes/PerformanceScopes/src/Tek5k7k70k_CheckClippingStatus/Tek5k7k70k_CheckClippingStatus.py @@ -29,10 +29,10 @@ import pyvisa as visa # https://pyvisa.readthedocs.io/en/latest/ class ClippingStatus(Enum): - NotClipping = 0 - Both = 1 - Positive = 2 - Negative = 3 + NotClipping = 0 + Both = 1 + Positive = 2 + Negative = 3 def Tek5k7k70k_CheckClipping(vi : visa.resources.MessageBasedResource, channel : str = 'CH1') -> tuple[bool, ClippingStatus]: @@ -77,4 +77,4 @@ def CheckClippingExample(): # Only run the example if this script is the main script being run if __name__ == '__main__': - CheckClippingExample() \ No newline at end of file + CheckClippingExample() \ No newline at end of file diff --git a/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/CSharpCurveQueryWinforms/CurveQueryWinforms.sln b/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/CSharpCurveQueryWinforms/CurveQueryWinforms.sln index 9e141ef..9d4b7dc 100644 --- a/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/CSharpCurveQueryWinforms/CurveQueryWinforms.sln +++ b/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/CSharpCurveQueryWinforms/CurveQueryWinforms.sln @@ -6,20 +6,20 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CurveQueryWinforms", "CurveQueryWinforms\CurveQueryWinforms.csproj", "{B1A8D030-C134-4033-A81B-78383BBFF26B}" EndProject Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {B1A8D030-C134-4033-A81B-78383BBFF26B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B1A8D030-C134-4033-A81B-78383BBFF26B}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B1A8D030-C134-4033-A81B-78383BBFF26B}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B1A8D030-C134-4033-A81B-78383BBFF26B}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {7BF6EF49-91F5-4C81-899B-431481A360B9} - EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {B1A8D030-C134-4033-A81B-78383BBFF26B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B1A8D030-C134-4033-A81B-78383BBFF26B}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B1A8D030-C134-4033-A81B-78383BBFF26B}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B1A8D030-C134-4033-A81B-78383BBFF26B}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {7BF6EF49-91F5-4C81-899B-431481A360B9} + EndGlobalSection EndGlobal diff --git a/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/CSharpHelloScope/HelloScope.sln b/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/CSharpHelloScope/HelloScope.sln index 05cd80b..a9a6be0 100644 --- a/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/CSharpHelloScope/HelloScope.sln +++ b/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/CSharpHelloScope/HelloScope.sln @@ -6,20 +6,20 @@ MinimumVisualStudioVersion = 10.0.40219.1 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "HelloScope", "HelloScope\HelloScope.csproj", "{95B654DA-72B0-434D-876C-DA660CDB3387}" EndProject Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {95B654DA-72B0-434D-876C-DA660CDB3387}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {95B654DA-72B0-434D-876C-DA660CDB3387}.Debug|Any CPU.Build.0 = Debug|Any CPU - {95B654DA-72B0-434D-876C-DA660CDB3387}.Release|Any CPU.ActiveCfg = Release|Any CPU - {95B654DA-72B0-434D-876C-DA660CDB3387}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {F1974110-BCDD-47CC-B6BC-AADCA6FF6543} - EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {95B654DA-72B0-434D-876C-DA660CDB3387}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {95B654DA-72B0-434D-876C-DA660CDB3387}.Debug|Any CPU.Build.0 = Debug|Any CPU + {95B654DA-72B0-434D-876C-DA660CDB3387}.Release|Any CPU.ActiveCfg = Release|Any CPU + {95B654DA-72B0-434D-876C-DA660CDB3387}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {F1974110-BCDD-47CC-B6BC-AADCA6FF6543} + EndGlobalSection EndGlobal diff --git a/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/DoublePulseTestExample/dpt_test_example.py b/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/DoublePulseTestExample/dpt_test_example.py index f37a1bc..cf8c4a3 100644 --- a/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/DoublePulseTestExample/dpt_test_example.py +++ b/Examples/Oscilloscopes/TekSeriesScopes_HighSpeedDigitizers/src/DoublePulseTestExample/dpt_test_example.py @@ -18,7 +18,7 @@ # * License: https://www.tek.com/sample-license # * --------------------------------------------------------------------------------------------------------- # * Revision History -# * Date: 2023-Aug-08 +# * Date: 2023-Aug-08 # * Notes: First revision (v1.0) # * Demo guildline # * 1. Connect MSO5/6B AFG output to AFG31000 trigger input; @@ -28,25 +28,25 @@ # * 4. Modify the user input settings in scripts; # * 5. Run the scripts to start the demo # * --------------------------------------------------------------------------------------------------------- -# * Date: 2023-Oct-10 +# * Date: 2023-Oct-10 # * Notes: Revision v1.1 # * 1. Add automatical control of AFG with DPT control interface; # * 2. Tested on V2.4.4 MSO5B/6B # * --------------------------------------------------------------------------------------------------------- -# * Date: 2024-Jan-31 +# * Date: 2024-Jan-31 # * Notes: Revision v1.2 # * 1. The AFG trigger/scope acquistion stuck issue has been resolved; # * 2. Tested on V2.6.38 MSO5B/6B # * --------------------------------------------------------------------------------------------------------- -# * Date: 2024-Mar-8 +# * Date: 2024-Mar-8 # * Notes: Revision v1.3 # * 1. Modify the comments for final publication; # * --------------------------------------------------------------------------------------------------------- -# * Date: 2024-Jun-5 +# * Date: 2024-Jun-5 # * Notes: Revision v1.4 # * 1. Modify the comments and debug codes for final publication; # * --------------------------------------------------------------------------------------------------------- -# * Date: 2024-Jun-6 +# * Date: 2024-Jun-6 # * Notes: Revision v1.5 # * 1. Adding time out input to the wait_for_scope_free(time_out_sec) function; # * 2. Adding 2 time delay command (time.sleep(1)) in the beginning and end of @@ -63,7 +63,7 @@ # * r = scope.query('allev?').strip() # * 9. Put the customer settings in an order with 2 groups (basic/advanced) # * --------------------------------------------------------------------------------------------------------- -# * Date: month/day/year +# * Date: month/day/year # * Notes: # *********************************************************************************************************** diff --git a/Examples/Power_Supplies/src/SourceVoltageExample/PWS4000_sourcevoltage_measure_example.cpp b/Examples/Power_Supplies/src/SourceVoltageExample/PWS4000_sourcevoltage_measure_example.cpp index 700c11b..5ca09da 100644 --- a/Examples/Power_Supplies/src/SourceVoltageExample/PWS4000_sourcevoltage_measure_example.cpp +++ b/Examples/Power_Supplies/src/SourceVoltageExample/PWS4000_sourcevoltage_measure_example.cpp @@ -9,66 +9,66 @@ static ViUInt32 retCnt; int main() { - status = viOpenDefaultRM(&defaultRM); - if (status < VI_SUCCESS) goto Error; + status = viOpenDefaultRM(&defaultRM); + if (status < VI_SUCCESS) goto Error; - status = viOpen(defaultRM, "PWS4000", VI_NULL, VI_NULL, &vi); - if (status < VI_SUCCESS) goto Error; - - sprintf((char*)strCmd, "*RST\n"); - status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; - - sprintf((char*)strCmd, "*IDN?\n"); - status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; - status = viRead(vi, strReply, 255, &retCnt); - if (status < VI_SUCCESS) goto Error; - - // viRead() writes into the string only the data read from the instrument - // therefore you need to NULL terminate the strings manually. - strReply[retCnt] = 0; - puts((char*)strReply); + status = viOpen(defaultRM, "PWS4000", VI_NULL, VI_NULL, &vi); + if (status < VI_SUCCESS) goto Error; + + sprintf((char*)strCmd, "*RST\n"); + status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; + + sprintf((char*)strCmd, "*IDN?\n"); + status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; + status = viRead(vi, strReply, 255, &retCnt); + if (status < VI_SUCCESS) goto Error; + + // viRead() writes into the string only the data read from the instrument + // therefore you need to NULL terminate the strings manually. + strReply[retCnt] = 0; + puts((char*)strReply); - sprintf((char*)strCmd, "VOLT 5.0\n"); - status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; + sprintf((char*)strCmd, "VOLT 5.0\n"); + status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; - sprintf((char*)strCmd, "CURR 0.5\n"); - status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; - - sprintf((char*)strCmd, "OUTP ON\n"); - status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; - - sprintf((char*)strCmd, "MEAS:VOLT?\n"); - status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; - status = viRead(vi, strReply, 255, &retCnt); - if (status < VI_SUCCESS) goto Error; - strReply[retCnt] = 0; - printf("Voltage: %s", strReply); + sprintf((char*)strCmd, "CURR 0.5\n"); + status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; + + sprintf((char*)strCmd, "OUTP ON\n"); + status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; + + sprintf((char*)strCmd, "MEAS:VOLT?\n"); + status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; + status = viRead(vi, strReply, 255, &retCnt); + if (status < VI_SUCCESS) goto Error; + strReply[retCnt] = 0; + printf("Voltage: %s", strReply); - sprintf((char*)strCmd, "MEAS:CURR?\n"); - status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; - status = viRead(vi, strReply, 255, &retCnt); - if (status < VI_SUCCESS) goto Error; - strReply[retCnt] = 0; - printf("Current: %s", strReply); + sprintf((char*)strCmd, "MEAS:CURR?\n"); + status = viWrite (vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; + status = viRead(vi, strReply, 255, &retCnt); + if (status < VI_SUCCESS) goto Error; + strReply[retCnt] = 0; + printf("Current: %s", strReply); Error: - if (status < VI_SUCCESS) - { - viStatusDesc(vi, status, (char*)strReply); - printf("VISA Error Occured:\r\n%s", strReply); - } - if (vi != VI_NULL) viClose(vi); - if (defaultRM != VI_NULL) viClose(defaultRM); - - printf("\r\nPress any key to continue ..."); - getchar(); - - return 0; + if (status < VI_SUCCESS) + { + viStatusDesc(vi, status, (char*)strReply); + printf("VISA Error Occured:\r\n%s", strReply); + } + if (vi != VI_NULL) viClose(vi); + if (defaultRM != VI_NULL) viClose(defaultRM); + + printf("\r\nPress any key to continue ..."); + getchar(); + + return 0; } diff --git a/Examples/Signal_Sources/src/AFG31k_Send_Arb_Waveform/matlab/AFG31k_send_arb.m b/Examples/Signal_Sources/src/AFG31k_Send_Arb_Waveform/matlab/AFG31k_send_arb.m index f8adce6..de2ea95 100644 --- a/Examples/Signal_Sources/src/AFG31k_Send_Arb_Waveform/matlab/AFG31k_send_arb.m +++ b/Examples/Signal_Sources/src/AFG31k_Send_Arb_Waveform/matlab/AFG31k_send_arb.m @@ -13,11 +13,11 @@ NI-VISA v19.5 AFG31000 - *********************************************************** + *********************************************************** *** Copyright 2023 Tektronix, Inc. *** *** See www.tek.com/sample-license for licensing terms. *** *********************************************************** - + Tektronix provides the following example "AS IS" without any guarantees or support. This example is for instructional guidance only. %} diff --git a/Examples/Signal_Sources/src/RFGenericCustomMarkerExample/rf_generic_data_marker.py b/Examples/Signal_Sources/src/RFGenericCustomMarkerExample/rf_generic_data_marker.py index 4323c8d..5c23282 100644 --- a/Examples/Signal_Sources/src/RFGenericCustomMarkerExample/rf_generic_data_marker.py +++ b/Examples/Signal_Sources/src/RFGenericCustomMarkerExample/rf_generic_data_marker.py @@ -90,7 +90,7 @@ sampPerSym = int(sampRate/symRate) with open(fileName) as f: - raw = f.read().strip() + raw = f.read().strip() raw = raw.split('\n') markerValues = [int(i) for i in raw] diff --git a/Examples/Spectrum_Analyzers/SignalVuExamples/C++/main.cpp b/Examples/Spectrum_Analyzers/SignalVuExamples/C++/main.cpp index e8f3e57..fedf33f 100644 --- a/Examples/Spectrum_Analyzers/SignalVuExamples/C++/main.cpp +++ b/Examples/Spectrum_Analyzers/SignalVuExamples/C++/main.cpp @@ -12,73 +12,73 @@ static ViUInt32 retCnt; int main() { - //VISA Session Setup - status = viOpenDefaultRM(&defaultRM); - if (status < VI_SUCCESS) goto Error; + //VISA Session Setup + status = viOpenDefaultRM(&defaultRM); + if (status < VI_SUCCESS) goto Error; - status = viOpen(defaultRM, "GPIB8::1::INSTR", VI_NULL, 100000, &vi); - if (status < VI_SUCCESS) goto Error; + status = viOpen(defaultRM, "GPIB8::1::INSTR", VI_NULL, 100000, &vi); + if (status < VI_SUCCESS) goto Error; - //Sending Reset and Identification Commands - sprintf_s((char*)strCmd, 6, "*RST\n"); - status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; + //Sending Reset and Identification Commands + sprintf_s((char*)strCmd, 6, "*RST\n"); + status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; - sprintf_s((char*)strCmd, 7, "*IDN?\n"); - status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; - status = viRead(vi, strReply, 255, &retCnt); - if (status < VI_SUCCESS) goto Error; + sprintf_s((char*)strCmd, 7, "*IDN?\n"); + status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; + status = viRead(vi, strReply, 255, &retCnt); + if (status < VI_SUCCESS) goto Error; - // viRead() writes into the string only the data read from the instrument - // therefore you need to NULL terminate the strings manually. - strReply[retCnt] = 0; - puts((char*)strReply); + // viRead() writes into the string only the data read from the instrument + // therefore you need to NULL terminate the strings manually. + strReply[retCnt] = 0; + puts((char*)strReply); - //General Setup - sprintf_s((char*)strCmd, BUFFER, "display:general:measview:new toverview\n"); - status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; + //General Setup + sprintf_s((char*)strCmd, BUFFER, "display:general:measview:new toverview\n"); + status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; - sprintf_s((char*)strCmd, BUFFER, "display:general:measview:new avtime\n"); - status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; - - double cf = 2.4453e9; - sprintf_s((char*)strCmd, BUFFER, "spectrum:frequency:center %f\n", cf); - status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; + sprintf_s((char*)strCmd, BUFFER, "display:general:measview:new avtime\n"); + status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; + + double cf = 2.4453e9; + sprintf_s((char*)strCmd, BUFFER, "spectrum:frequency:center %f\n", cf); + status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; - double refLevel = 0; - sprintf_s((char*)strCmd, BUFFER, "input:rlevel %f\n", refLevel); - status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; + double refLevel = 0; + sprintf_s((char*)strCmd, BUFFER, "input:rlevel %f\n", refLevel); + status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; - double aLength = 100e-6; - sprintf_s((char*)strCmd, BUFFER, "sense:analysis:length %f\n", aLength); - status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; - - //Start Acquisition - sprintf_s((char*)strCmd, BUFFER, "initiate:continuous off\n"); - status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; + double aLength = 100e-6; + sprintf_s((char*)strCmd, BUFFER, "sense:analysis:length %f\n", aLength); + status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; + + //Start Acquisition + sprintf_s((char*)strCmd, BUFFER, "initiate:continuous off\n"); + status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; - sprintf_s((char*)strCmd, BUFFER, "initiate:immediate\n"); - status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); - if (status < VI_SUCCESS) goto Error; + sprintf_s((char*)strCmd, BUFFER, "initiate:immediate\n"); + status = viWrite(vi, strCmd, strlen((char*)strCmd), &retCnt); + if (status < VI_SUCCESS) goto Error; Error: - if (status < VI_SUCCESS) - { - viStatusDesc(vi, status, (char*)strReply); - printf("VISA Error Occured:\r\n%s", strReply); - } - if (vi != VI_NULL) viClose(vi); - if (defaultRM != VI_NULL) viClose(defaultRM); + if (status < VI_SUCCESS) + { + viStatusDesc(vi, status, (char*)strReply); + printf("VISA Error Occured:\r\n%s", strReply); + } + if (vi != VI_NULL) viClose(vi); + if (defaultRM != VI_NULL) viClose(defaultRM); - printf("\r\nPress any key to continue ..."); - getchar(); - return 0; + printf("\r\nPress any key to continue ..."); + getchar(); + return 0; } \ No newline at end of file diff --git a/Examples/Spectrum_Analyzers/SignalVuExamples/MATLAB/RSA6100A_PeakFinder/RTSA6100__Sweep_Plot_Trace_with_Basic_Find_Peaks_c.m b/Examples/Spectrum_Analyzers/SignalVuExamples/MATLAB/RSA6100A_PeakFinder/RTSA6100__Sweep_Plot_Trace_with_Basic_Find_Peaks_c.m index 540ec6f..310e17f 100644 --- a/Examples/Spectrum_Analyzers/SignalVuExamples/MATLAB/RSA6100A_PeakFinder/RTSA6100__Sweep_Plot_Trace_with_Basic_Find_Peaks_c.m +++ b/Examples/Spectrum_Analyzers/SignalVuExamples/MATLAB/RSA6100A_PeakFinder/RTSA6100__Sweep_Plot_Trace_with_Basic_Find_Peaks_c.m @@ -37,7 +37,7 @@ %-------------------------------------------------------------------------- % Change the IP addresses to match the IP address of your RSA before % running the demo. -RTSAIPAddr = '192.168.1.113'; % Instrument TCP/IP address +RTSAIPAddr = '192.168.1.113'; % Instrument TCP/IP address % % %-------------------------------------------------------------------------- diff --git a/Examples/Spectrum_Analyzers/SignalVuExamples/MATLAB/RSA6100A_PeakFinder/rtslid.m b/Examples/Spectrum_Analyzers/SignalVuExamples/MATLAB/RSA6100A_PeakFinder/rtslid.m index a0f799a..911044d 100644 --- a/Examples/Spectrum_Analyzers/SignalVuExamples/MATLAB/RSA6100A_PeakFinder/rtslid.m +++ b/Examples/Spectrum_Analyzers/SignalVuExamples/MATLAB/RSA6100A_PeakFinder/rtslid.m @@ -154,7 +154,7 @@ h = axes('Position',[0.03 0.1 0.03 0.8]); end - if ischar(back), % Any string wll cause the background to be 'jet' + if ischar(back), % Any string wll cause the background to be 'jet' try eval(['colormap(''',back,''');']); catch @@ -170,20 +170,20 @@ image(m); end - title(label); + title(label); % Make the slider look nice set(h,'XTick',[],'XTickLabel','','YTick',[],'YTickLabel','','YDir','normal','LineWidth',2); - set(fig,'DoubleBuffer','on'); % Double buffering required for smooth display + set(fig,'DoubleBuffer','on'); % Double buffering required for smooth display % Draw the small black box that indicates current position ind = patch([0 0 10 10],[def2-20 def2+20 def2+20 def2-20],[0.25 0.25 0.25]);axis tight; - params.mdown = 0; % Initialise mousedown state - params.ind = ind; % Save the handle to the position indicator - params.funhand{1} = f; % Save the function handle or string - params.h = h; % Save the handle to this slider - params.h2 = hh; % Save the handle to the plotting axes (for this slider) + params.mdown = 0; % Initialise mousedown state + params.ind = ind; % Save the handle to the position indicator + params.funhand{1} = f; % Save the function handle or string + params.h = h; % Save the handle to this slider + params.h2 = hh; % Save the handle to the plotting axes (for this slider) if exist('scale'), % Set the output limits params.scale{1} = scale; else @@ -215,18 +215,18 @@ % Make the slider look nice set(h,'XTick',[],'XTickLabel','','YTick',[],'YTickLabel','','YDir','normal','LineWidth',2); - set(fig,'DoubleBuffer','on'); - + set(fig,'DoubleBuffer','on'); + % Draw the small black box that indicates current position ind = patch([0 0 10 10],[def2-20 def2+20 def2+20 def2-20],[0.25 0.25 0.25]);axis tight; % Copy old parameters and concatenate new values params.mdown = [params2.mdown 0]; % Initialise new mousedown state - params.ind = [params2.ind ind]; % Save the handle to the position indicator - params.funhand = params2.funhand; % Save the function handle or string + params.ind = [params2.ind ind]; % Save the handle to the position indicator + params.funhand = params2.funhand; % Save the function handle or string params.funhand{params.noslids} = f; - params.h = [params2.h h]; % Save the handle to this slider - params.h2 = [params2.h2 hh]; % Save the handle to the plotting axes (for this slider) + params.h = [params2.h h]; % Save the handle to this slider + params.h2 = [params2.h2 hh]; % Save the handle to the plotting axes (for this slider) for l=1:(params.noslids-1), params.scale{l} = params2.scale{l}; end @@ -351,28 +351,28 @@ function butmotfcn1(in,varargin) params = get(gcf,'UserData'); % Get the saved parameters for l=1:params.noslids, - if (params.mdown(l)), % If mouse was clicked on slider l - p = get(params.h(l),'CurrentPoint'); % Get mouse position relative to the slider axis - dy = p(3)-params.old; % Calculate change in mouse position - if (abs(dy)>0), % If mouse has moved - p2 = params.current(l)+dy; % Find new slider position - params.old = p(3); % Save this new mouse position - p2=max([0 min([1000 p2])]); % Constrain position - params.current(l) = p2; % Save current slider position - scal = params.scale{l}; % Get the lower and upper limits - out = (p2*(scal(2)-scal(1))/1000); % Convert from [0 to 1000] to new scale - out = out+scal(1); - axes(params.h2(l)); % Avoid plotting on the slider axis - if ischar(params.funhand{l}), % If string passed as function - eval(params.funhand{l}); % Evaluate the string - else % Else if function handle passed - feval(params.funhand{l},out,params.h2(l)); % Perform function - end - set(params.ind(l),'YData',[p2-20 p2+20 p2+20 p2-20]);% Update position indicator - figure(params.fig); % Make sure focus returns to slider after plotting - end - end - set(gcf,'UserData',params); % Save all parameters + if (params.mdown(l)), % If mouse was clicked on slider l + p = get(params.h(l),'CurrentPoint'); % Get mouse position relative to the slider axis + dy = p(3)-params.old; % Calculate change in mouse position + if (abs(dy)>0), % If mouse has moved + p2 = params.current(l)+dy; % Find new slider position + params.old = p(3); % Save this new mouse position + p2=max([0 min([1000 p2])]); % Constrain position + params.current(l) = p2; % Save current slider position + scal = params.scale{l}; % Get the lower and upper limits + out = (p2*(scal(2)-scal(1))/1000); % Convert from [0 to 1000] to new scale + out = out+scal(1); + axes(params.h2(l)); % Avoid plotting on the slider axis + if ischar(params.funhand{l}), % If string passed as function + eval(params.funhand{l}); % Evaluate the string + else % Else if function handle passed + feval(params.funhand{l},out,params.h2(l)); % Perform function + end + set(params.ind(l),'YData',[p2-20 p2+20 p2+20 p2-20]);% Update position indicator + figure(params.fig); % Make sure focus returns to slider after plotting + end + end + set(gcf,'UserData',params); % Save all parameters end if (length(params.butmot)>0), % Evaluate any extra ButMot functions passed to rtslid eval(params.butmot); diff --git a/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/TekVISAExamples.sln b/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/TekVISAExamples.sln index ffacbc6..dbb5602 100644 --- a/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/TekVISAExamples.sln +++ b/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/TekVISAExamples.sln @@ -12,29 +12,29 @@ EndProject Project("{F184B08F-C81C-45F6-A57F-5ABD9991F28F}") = "VbTekVISANetExample", "VbTekVISANetExample\VbTekVISANetExample.vbproj", "{CDC2269A-5ECB-4A24-AE88-F62D0C77BF5C}" EndProject Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {CE854A27-52BE-4F3F-9465-B6359F7A4D20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CE854A27-52BE-4F3F-9465-B6359F7A4D20}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CE854A27-52BE-4F3F-9465-B6359F7A4D20}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CE854A27-52BE-4F3F-9465-B6359F7A4D20}.Release|Any CPU.Build.0 = Release|Any CPU - {D4919D3F-CF85-42B9-87CA-7F0060C9B02A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D4919D3F-CF85-42B9-87CA-7F0060C9B02A}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D4919D3F-CF85-42B9-87CA-7F0060C9B02A}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D4919D3F-CF85-42B9-87CA-7F0060C9B02A}.Release|Any CPU.Build.0 = Release|Any CPU - {A66B8BB6-B5B2-4FDF-8DC4-9027D70510A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A66B8BB6-B5B2-4FDF-8DC4-9027D70510A2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A66B8BB6-B5B2-4FDF-8DC4-9027D70510A2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A66B8BB6-B5B2-4FDF-8DC4-9027D70510A2}.Release|Any CPU.Build.0 = Release|Any CPU - {CDC2269A-5ECB-4A24-AE88-F62D0C77BF5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {CDC2269A-5ECB-4A24-AE88-F62D0C77BF5C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {CDC2269A-5ECB-4A24-AE88-F62D0C77BF5C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {CDC2269A-5ECB-4A24-AE88-F62D0C77BF5C}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {CE854A27-52BE-4F3F-9465-B6359F7A4D20}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CE854A27-52BE-4F3F-9465-B6359F7A4D20}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CE854A27-52BE-4F3F-9465-B6359F7A4D20}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CE854A27-52BE-4F3F-9465-B6359F7A4D20}.Release|Any CPU.Build.0 = Release|Any CPU + {D4919D3F-CF85-42B9-87CA-7F0060C9B02A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D4919D3F-CF85-42B9-87CA-7F0060C9B02A}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D4919D3F-CF85-42B9-87CA-7F0060C9B02A}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D4919D3F-CF85-42B9-87CA-7F0060C9B02A}.Release|Any CPU.Build.0 = Release|Any CPU + {A66B8BB6-B5B2-4FDF-8DC4-9027D70510A2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A66B8BB6-B5B2-4FDF-8DC4-9027D70510A2}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A66B8BB6-B5B2-4FDF-8DC4-9027D70510A2}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A66B8BB6-B5B2-4FDF-8DC4-9027D70510A2}.Release|Any CPU.Build.0 = Release|Any CPU + {CDC2269A-5ECB-4A24-AE88-F62D0C77BF5C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {CDC2269A-5ECB-4A24-AE88-F62D0C77BF5C}.Debug|Any CPU.Build.0 = Debug|Any CPU + {CDC2269A-5ECB-4A24-AE88-F62D0C77BF5C}.Release|Any CPU.ActiveCfg = Release|Any CPU + {CDC2269A-5ECB-4A24-AE88-F62D0C77BF5C}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection EndGlobal diff --git a/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/TekVISANetExample/TekVISANetExample.cs b/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/TekVISANetExample/TekVISANetExample.cs index 346a738..18c931f 100644 --- a/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/TekVISANetExample/TekVISANetExample.cs +++ b/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/TekVISANetExample/TekVISANetExample.cs @@ -19,11 +19,11 @@ private static void Message(string s) private static void Main(string[] args) { //const string rsaAddress = "127.0.0.1"; - const string rsaAddress = "GPIB8::1::INSTR"; + const string rsaAddress = "GPIB8::1::INSTR"; var rsa = new VISA(); try { - rsa.Open(rsaAddress); + rsa.Open(rsaAddress); //rsa.Open(string.Format("TCPIP::{0}::INSTR", rsaAddress)); if (rsa.Status != TekVISADefs.Status.SUCCESS) { diff --git a/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/VbTekVISANetExample/VbTekVISANetExample.vb b/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/VbTekVISANetExample/VbTekVISANetExample.vb index 2021910..df9f6f0 100644 --- a/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/VbTekVISANetExample/VbTekVISANetExample.vb +++ b/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/VbTekVISANetExample/VbTekVISANetExample.vb @@ -8,59 +8,59 @@ Imports TekVISANet Module VbTekVISANetExample - Private Sub Message(s As String) - Console.WriteLine("[{0}] {1}", DateTime.Now, s) - End Sub + Private Sub Message(s As String) + Console.WriteLine("[{0}] {1}", DateTime.Now, s) + End Sub - Sub Main() - Const rsaIpAddress As String = "127.0.0.1" - Dim rsa = New VISA() - Try - 'rsa.Open(String.Format("TCPIP::{0}::INSTR", rsaIpAddress)) + Sub Main() + Const rsaIpAddress As String = "127.0.0.1" + Dim rsa = New VISA() + Try + 'rsa.Open(String.Format("TCPIP::{0}::INSTR", rsaIpAddress)) rsa.Open("GPIB8::1::INSTR") - If rsa.Status <> TekVISADefs.Status.SUCCESS Then - Message(String.Format("Unable to connect to RSA at ipaddr {0}", rsaIpAddress)) - Return - End If + If rsa.Status <> TekVISADefs.Status.SUCCESS Then + Message(String.Format("Unable to connect to RSA at ipaddr {0}", rsaIpAddress)) + Return + End If - ' Confirm we are connected to the RSA. - rsa.Write("*RST") - Dim retString As String = String.Empty - rsa.Query("*IDN?", retString) - Message(Convert.ToString("Connected to: ") & rsaIpAddress) - Message(Convert.ToString("*IDN? returned ") & retString) + ' Confirm we are connected to the RSA. + rsa.Write("*RST") + Dim retString As String = String.Empty + rsa.Query("*IDN?", retString) + Message(Convert.ToString("Connected to: ") & rsaIpAddress) + Message(Convert.ToString("*IDN? returned ") & retString) - ' Preset the system, set CF to 1 GHz, 1 MHz span, and turn off continous acquisitions - rsa.Write(":SYSTEM:PRESET") - Dim retVal As Integer - rsa.Query("*OPC?", retVal) - rsa.Write("*CLS") - rsa.Write("INIT:CONT OFF") - rsa.Write(":SENSE:SPEC:FREQ:CENTER 1e9") - rsa.Write(":SENSE:SPEC:FREQ:SPAN 1e6") + ' Preset the system, set CF to 1 GHz, 1 MHz span, and turn off continous acquisitions + rsa.Write(":SYSTEM:PRESET") + Dim retVal As Integer + rsa.Query("*OPC?", retVal) + rsa.Write("*CLS") + rsa.Write("INIT:CONT OFF") + rsa.Write(":SENSE:SPEC:FREQ:CENTER 1e9") + rsa.Write(":SENSE:SPEC:FREQ:SPAN 1e6") - ' Add a marker - rsa.Write("CALCulate:MARKer:ADD") + ' Add a marker + rsa.Write("CALCulate:MARKer:ADD") - ' Take one acquisition - rsa.Write("INIT") - rsa.Query("*OPC?", retVal) + ' Take one acquisition + rsa.Write("INIT") + rsa.Query("*OPC?", retVal) - ' Use marker to find max peak - rsa.Write("CALC:SPEC:MARKer0:MAX") - Dim peakLevel As Double - rsa.Query("CALC:SPEC:MARK0:Y?", peakLevel) - Message(String.Format("Peak Amplitude is {0:0.00} dBm", peakLevel)) - Finally - ' Be a good .NET citizen and explicitly close resources. - rsa.Clear() - rsa.Close() - End Try + ' Use marker to find max peak + rsa.Write("CALC:SPEC:MARKer0:MAX") + Dim peakLevel As Double + rsa.Query("CALC:SPEC:MARK0:Y?", peakLevel) + Message(String.Format("Peak Amplitude is {0:0.00} dBm", peakLevel)) + Finally + ' Be a good .NET citizen and explicitly close resources. + rsa.Clear() + rsa.Close() + End Try - Console.WriteLine("Hit enter to close...") - Dim wait = Console.ReadLine() + Console.WriteLine("Hit enter to close...") + Dim wait = Console.ReadLine() - End Sub + End Sub End Module diff --git a/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/VbTekVISASocketExample/VbTekVISASocketExample.vb b/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/VbTekVISASocketExample/VbTekVISASocketExample.vb index 228c146..72a4efb 100644 --- a/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/VbTekVISASocketExample/VbTekVISASocketExample.vb +++ b/Examples/Spectrum_Analyzers/SignalVuExamples/dotNet/VbTekVISASocketExample/VbTekVISASocketExample.vb @@ -8,61 +8,61 @@ Imports System.Net.Sockets Imports System.IO Module VbTekVISASocketExample - Private Sub Message(s As String) - Console.WriteLine("[{0}] {1}", DateTime.Now, s) - End Sub + Private Sub Message(s As String) + Console.WriteLine("[{0}] {1}", DateTime.Now, s) + End Sub - Sub Main() - Const rsaIpAddress As String = "127.0.0.1" - Dim rsaReader As StreamReader - Dim rsaWriter As StreamWriter + Sub Main() + Const rsaIpAddress As String = "127.0.0.1" + Dim rsaReader As StreamReader + Dim rsaWriter As StreamWriter - Try - Dim rsaClient = New TcpClient(rsaIpAddress, 4000) - Dim rsaStream = rsaClient.GetStream() - rsaReader = New StreamReader(rsaStream) - rsaWriter = New StreamWriter(rsaStream) With { .AutoFlush = True } + Try + Dim rsaClient = New TcpClient(rsaIpAddress, 4000) + Dim rsaStream = rsaClient.GetStream() + rsaReader = New StreamReader(rsaStream) + rsaWriter = New StreamWriter(rsaStream) With { .AutoFlush = True } Catch e As Exception - Message(String.Format("Unable to connect to RSA at ipaddr {0}\n{1}", rsaIpAddress, e.Message)) - Return - End Try + Message(String.Format("Unable to connect to RSA at ipaddr {0}\n{1}", rsaIpAddress, e.Message)) + Return + End Try - ' Confirm we are connected to the RSA. - rsaWriter.WriteLine("*IDN?") - Dim rsaInfo = rsaReader.ReadLine() - Message(String.Format("Connected to: {0}", rsaIpAddress)) - Message("*IDN? returned " + rsaInfo) + ' Confirm we are connected to the RSA. + rsaWriter.WriteLine("*IDN?") + Dim rsaInfo = rsaReader.ReadLine() + Message(String.Format("Connected to: {0}", rsaIpAddress)) + Message("*IDN? returned " + rsaInfo) - ' Preset the system, set CF to 1 GHz, 1 MHz span, and turn off continous acquisitions - rsaWriter.WriteLine(":SYSTEM:PRESET") - rsaWriter.WriteLine("*OPC?") - rsaReader.ReadLine() - rsaWriter.WriteLine("*CLS") - rsaWriter.WriteLine("INIT:CONT OFF") - rsaWriter.WriteLine(":SENSE:SPEC:FREQ:CENTER 1e9") - rsaWriter.WriteLine(":SENSE:SPEC:FREQ:SPAN 1e6") + ' Preset the system, set CF to 1 GHz, 1 MHz span, and turn off continous acquisitions + rsaWriter.WriteLine(":SYSTEM:PRESET") + rsaWriter.WriteLine("*OPC?") + rsaReader.ReadLine() + rsaWriter.WriteLine("*CLS") + rsaWriter.WriteLine("INIT:CONT OFF") + rsaWriter.WriteLine(":SENSE:SPEC:FREQ:CENTER 1e9") + rsaWriter.WriteLine(":SENSE:SPEC:FREQ:SPAN 1e6") - ' Add a marker - rsaWriter.WriteLine("CALCulate:MARKer:ADD") + ' Add a marker + rsaWriter.WriteLine("CALCulate:MARKer:ADD") - ' Take one acquisition - rsaWriter.WriteLine("INIT") - rsaWriter.WriteLine("*OPC?") - rsaReader.ReadLine() + ' Take one acquisition + rsaWriter.WriteLine("INIT") + rsaWriter.WriteLine("*OPC?") + rsaReader.ReadLine() ' Use marker to find max peak - rsaWriter.WriteLine("CALC:SPEC:MARKer0:MAX") - rsaWriter.WriteLine("CALC:SPEC:MARK0:Y?") - Dim peakLevel = Convert.ToDouble(rsaReader.ReadLine()) - Message(String.Format("Peak Amplitude is {0:0.00} dBm", peakLevel)) + rsaWriter.WriteLine("CALC:SPEC:MARKer0:MAX") + rsaWriter.WriteLine("CALC:SPEC:MARK0:Y?") + Dim peakLevel = Convert.ToDouble(rsaReader.ReadLine()) + Message(String.Format("Peak Amplitude is {0:0.00} dBm", peakLevel)) - Console.WriteLine("Hit enter to close...") - Dim wait = Console.ReadLine() + Console.WriteLine("Hit enter to close...") + Dim wait = Console.ReadLine() - ' Be a good .NET citizen and explicitly close resources. - rsaReader.Close() - rsaWriter.Close() - End Sub + ' Be a good .NET citizen and explicitly close resources. + rsaReader.Close() + rsaWriter.Close() + End Sub End Module From ef8a6657680d62dbc01300b09802f77041b16e7b Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Thu, 25 Jul 2024 11:45:15 -0700 Subject: [PATCH 7/8] Reduce the necessary repo checks --- .github/workflows/tek-repo-lint.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/tek-repo-lint.yml b/.github/workflows/tek-repo-lint.yml index f640ec2..57ede3d 100644 --- a/.github/workflows/tek-repo-lint.yml +++ b/.github/workflows/tek-repo-lint.yml @@ -17,9 +17,6 @@ jobs: - .github/CODEOWNERS - README.@(md|rst) - LICENSE.@(md|rst) - - .github/ISSUE_TEMPLATE/bug_report.yml - - .github/ISSUE_TEMPLATE/feature_request.yml - - .github/PULL_REQUEST_TEMPLATE.md - .github/dependabot.yml - .github/workflows/codeql.yml steps: From d975472c09b57c4f5716ce3025fa667a2ac49289 Mon Sep 17 00:00:00 2001 From: "Felt, Nicholas" Date: Thu, 25 Jul 2024 11:47:09 -0700 Subject: [PATCH 8/8] Reduce the necessary repo checks --- .github/workflows/tek-repo-lint.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/tek-repo-lint.yml b/.github/workflows/tek-repo-lint.yml index 57ede3d..3d41262 100644 --- a/.github/workflows/tek-repo-lint.yml +++ b/.github/workflows/tek-repo-lint.yml @@ -17,7 +17,6 @@ jobs: - .github/CODEOWNERS - README.@(md|rst) - LICENSE.@(md|rst) - - .github/dependabot.yml - .github/workflows/codeql.yml steps: - uses: actions/checkout@v4