-
Notifications
You must be signed in to change notification settings - Fork 0
Add default value to nislsc python api #67
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
3bdf708
077ce2a
646ecac
7dd42d6
14f3ae7
30845a7
21b5669
e906a73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -49,18 +49,13 @@ def get_command_and_property_tree(device_name: str) -> dict: | |
| Returns: | ||
| Dictionary containing the command and property tree of the device. | ||
| """ | ||
| connection_timeout = 10.0 | ||
| reservation_access = ReservationAccess.READ_ONLY | ||
| reservation_group = "admin" | ||
| reservation_timeout = 10.0 | ||
|
|
||
| with Session.initialize_session_with_devices( | ||
| None, | ||
| device_name, | ||
| connection_timeout, | ||
| reservation_access, | ||
| reservation_group, | ||
| reservation_timeout, | ||
| ) as session: | ||
|
|
||
| data = { | ||
|
|
@@ -70,18 +65,18 @@ def get_command_and_property_tree(device_name: str) -> dict: | |
| } | ||
|
|
||
| device_commands = session.get_device_property_string_array( | ||
| device_name, | ||
| DeviceProperty.COMMANDS, | ||
| device_name, | ||
| ) | ||
|
|
||
| device_properties = session.get_device_property_string_array( | ||
| device_name, | ||
| DeviceProperty.PROPERTIES, | ||
| device_name, | ||
| ) | ||
|
|
||
| device_physical_channels = session.get_device_property_string_array( | ||
| device_name, | ||
| DeviceProperty.PHYSICAL_CHANNELS, | ||
| device_name, | ||
| ) | ||
|
|
||
| for physical_channel in device_physical_channels: | ||
|
|
@@ -138,10 +133,10 @@ def get_command_and_property_tree(device_name: str) -> dict: | |
| for physical_channel in device_physical_channels: | ||
|
|
||
| physical_channel_commands = session.get_physical_channel_property_string_array( | ||
| physical_channel, PhysicalChannelProperty.COMMANDS | ||
| PhysicalChannelProperty.COMMANDS, physical_channel | ||
| ) | ||
| physical_channel_properties = session.get_physical_channel_property_string_array( | ||
| physical_channel, PhysicalChannelProperty.PROPERTIES | ||
| PhysicalChannelProperty.PROPERTIES, physical_channel | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @bkeryan With
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I agree it seems a little weird. The approach used by other NI driver APIs for Python is to have a collection of objects (e.g. nidaqmx channels or MI repeated capabilities) that returns proxy objects with the 1st parameter bound (e.g. device). SLSC is not an IVI driver, but the new Python IVI spec also uses this approach. The collection can expose a separate property that returns a proxy that is bound to $DeviceDevices: That is a bigger API change, though. Working within the current API, I think it would be ok for (get|set)_device_xyz(), (get|set)_phys_chan_xyz(), (get|set)_nvmem_bytes(), etc. to not have a default for the "active context" (1st parameter that specifies which device/physchan/nvmem you are accessing).
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we remove the default "active context" parameter, users can still write Also, I think that defining constants for the resource aliases like DEFAULT_DEVICES_ALIAS = "$DefaultDevices" would make them more discoverable.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think there is a few ways to address it: Method2: I think method 1 is easier and straight-forward. |
||
| ) | ||
|
|
||
| for physical_channel_command in physical_channel_commands: | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.