Skip to content

Adding formatted switch module example for Individual relay control.#20

Merged
bkumarng-NI merged 3 commits into
mainfrom
users/bkumarng-NI/adding_switch_individualRelayCtrl
Jul 15, 2026
Merged

Adding formatted switch module example for Individual relay control.#20
bkumarng-NI merged 3 commits into
mainfrom
users/bkumarng-NI/adding_switch_individualRelayCtrl

Conversation

@bkumarng-NI

Copy link
Copy Markdown
Collaborator

Adding formatted CCS switch module example for Individual relay control.

  1. With default values, with only resource name change.
image
  1. Through custom values input through CLI:
    python niswitch_individual_relay.py -rn "2568_Switch" -tp "2568/31-SPST" -rl "k0" -ra "OPEN"
image
  1. Simulated option
    python niswitch_individual_relay.py -sim
image

Adding formatted CCS switch module example for Individual relay control.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.py example with CLI arguments for resource name, topology, relay, action, simulate, and reset behavior.
  • Implements a minimal “example / _main / main” structure plus test_example() and test_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()]

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not necessary

Comment on lines +82 to +84
# -> Wait for Debounce
# - Waits until the relay has mechanically settled after the action
session.wait_for_debounce()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this suggestion, get below error "

Image"

Comment on lines +86 to +87
#- Print relay action result to console
print(f"Relay '{relay_name}': {relay_action.upper()} action completed.")

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no impact with/without suggestion.

Pushing some cosmetic changes.
Adding formatted CCS example for Switch-Software scanning.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

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,
@bkumarng-NI
bkumarng-NI merged commit 07a00ed into main Jul 15, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants