Adding formatted switch module example for Individual relay control.#20
Merged
bkumarng-NI merged 3 commits intoJul 15, 2026
Merged
Conversation
Adding formatted CCS switch module example for Individual relay control.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new NI-SWITCH community example script demonstrating individual relay control (open/close) on a switch module, with a small CLI wrapper and simulated-run tests consistent with other examples in this repo.
Changes:
- Introduces
niswitch_individual_relay.pyexample with CLI arguments for resource name, topology, relay, action, simulate, and reset behavior. - Implements a minimal “example / _main / main” structure plus
test_example()andtest_main()for simulated execution.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+65
to
+67
| # Convert relay_action string to niswitch.RelayAction enum | ||
| action = niswitch.RelayAction[relay_action.upper()] | ||
|
|
Comment on lines
+82
to
+84
| # -> Wait for Debounce | ||
| # - Waits until the relay has mechanically settled after the action | ||
| session.wait_for_debounce() |
Collaborator
Author
Comment on lines
+86
to
+87
| #- Print relay action result to console | ||
| print(f"Relay '{relay_name}': {relay_action.upper()} action completed.") |
Collaborator
Author
There was a problem hiding this comment.
no impact with/without suggestion.
Pushing some cosmetic changes.
Adding formatted CCS example for Switch-Software scanning.
Comment on lines
+96
to
+100
| parser.add_argument('-n', '--resource-name', default='PXI2568', help='NI-SWITCH device resource name') | ||
| parser.add_argument('-tp', '--topology', default='2568/31-SPST', help='Switch topology string') | ||
| parser.add_argument('-rn', '--relay-name', default='k0', help='Relay identifier on the switch module') | ||
| parser.add_argument('-ra', '--relay-action', default='CLOSE', choices=['CLOSE', 'OPEN'], help='Relay action to perform') | ||
| parser.add_argument('-sim', '--simulate', action='store_true', default=False, help='Run in simulation mode (no hardware required)') |
| a trigger input source, and continuous scan mode. A software trigger is then | ||
| sent to advance through the scan sequence. | ||
|
|
||
| Note : This example supports only single channel scanning, for example, |
Upatel-NI
approved these changes
Jul 15, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adding formatted CCS switch module example for Individual relay control.
python niswitch_individual_relay.py -rn "2568_Switch" -tp "2568/31-SPST" -rl "k0" -ra "OPEN"
python niswitch_individual_relay.py -sim