Skip to content
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

nifgen repeated capability documentation and test updates #1681

Merged
merged 13 commits into from
Jan 20, 2022
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,16 @@ All notable changes to this project will be documented in this file.
* #### Changed
* #### Removed
* ### `nifgen` (NI-FGEN)
* #### Added
* #### Added
* `data_markers` repeated capability support - [#1668](https://github.com/ni/nimi-python/issues/1668)
* #### Changed
* Addressed [#1627](https://github.com/ni/nimi-python/issues/1627) for attributes supporting the following repeated capabilities
* `channels`
* `markers`
* `data_markers`
* `script_triggers`
* Corrected multiple mistakes in repeated capability info of attribute metadata
* alters API behavior (repeated capability access of attributes) and documentation
* #### Removed
* ### `nimodinst` (NI-ModInst)
* #### Added
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@

# General information about the project.
project = 'NI Modular Instruments Python API'
copyright = '2017-2021, National Instruments'
copyright = '2017-2022, National Instruments'
author = 'National Instruments'

# The version info for the project you're documenting, acts as replacement for
Expand Down
396 changes: 333 additions & 63 deletions docs/nifgen/class.rst

Large diffs are not rendered by default.

26 changes: 26 additions & 0 deletions docs/nifgen/rep_caps.rst
Original file line number Diff line number Diff line change
Expand Up @@ -87,4 +87,30 @@ markers
passes a string of :python:`'Marker0, Marker1, Marker2'` to the set attribute function.


data_markers
------------

.. py:attribute:: nifgen.Session.data_markers[]

If no prefix is added to the items in the parameter, the correct prefix will be added when
the driver function call is made.

.. code:: python

session.data_markers['0-2'].channel_enabled = True

passes a string of :python:`'DataMarker0, DataMarker1, DataMarker2'` to the set attribute function.
Copy link
Member

Choose a reason for hiding this comment

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

This is very bad documentation, because it documents what the implementation does under the hood which is irrelevant to the Python programmer.

We should (separate PR naturally) rewrite this to be relevant to the user. @ni-jfitzger want to tackle it? I can help wordsmith.

Copy link
Collaborator Author

@ni-jfitzger ni-jfitzger Jan 15, 2022

Choose a reason for hiding this comment

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

Yeah, I'm not thrilled with this documentation either, but for a different reason. I don't like the use of channel_enabled in the example code. I understand that it just an example attribute which isn't necessarily supported. It might be confusing to users, though.

I don't mind tackling the improvement of this documentation, but I'll have to do some digging to figure out how, since it's generated.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It should just be a matter of updating rep_caps.rest.mako

Copy link
Member

Choose a reason for hiding this comment

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

Related issues, for which there appears to be a fair bit of duplication:
#1388
#1338
#1334
#1126

#1351 would be a nice one to fix too.


If an invalid repeated capability is passed to the driver, the driver will return an error.

You can also explicitly use the prefix as part of the parameter, but it must be the correct prefix
for the specific repeated capability.

.. code:: python

session.data_markers['DataMarker0-DataMarker2'].channel_enabled = True

passes a string of :python:`'DataMarker0, DataMarker1, DataMarker2'` to the set attribute function.



259 changes: 240 additions & 19 deletions generated/nifgen/nifgen/session.py

Large diffs are not rendered by default.

85 changes: 74 additions & 11 deletions src/nifgen/metadata/attributes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# This file is generated from NI-FGEN API metadata version 20.7.0d242
# This file is generated from NI-FGEN API metadata version 21.5.0d106
attributes = {
1050005: {
'access': 'read-write',
Expand Down Expand Up @@ -183,6 +183,9 @@
'enum': 'TriggerMode',
'lv_property': 'Triggers:Trigger Mode',
'name': 'TRIGGER_MODE',
'supported_rep_caps': [
'channels'
],
'type': 'ViInt32'
},
1150110: {
Expand Down Expand Up @@ -529,7 +532,9 @@
'enum': 'ScriptTriggerType',
'lv_property': 'Triggers:Script:Trigger Type',
'name': 'SCRIPT_TRIGGER_TYPE',
'repeated_capability_type': 'script_triggers',
'supported_rep_caps': [
'script_triggers'
],
'type': 'ViInt32'
},
1150291: {
Expand All @@ -539,7 +544,9 @@
},
'lv_property': 'Triggers:Script:Digital Edge:Source',
'name': 'DIGITAL_EDGE_SCRIPT_TRIGGER_SOURCE',
'repeated_capability_type': 'script_triggers',
'supported_rep_caps': [
'script_triggers'
],
'type': 'ViString'
},
1150292: {
Expand All @@ -550,7 +557,9 @@
'enum': 'ScriptTriggerDigitalEdgeEdge',
'lv_property': 'Triggers:Script:Digital Edge:Edge',
'name': 'DIGITAL_EDGE_SCRIPT_TRIGGER_EDGE',
'repeated_capability_type': 'script_triggers',
'supported_rep_caps': [
'script_triggers'
],
'type': 'ViInt32'
},
1150295: {
Expand All @@ -560,7 +569,9 @@
},
'lv_property': 'Triggers:Script:Output Terminal',
'name': 'EXPORTED_SCRIPT_TRIGGER_OUTPUT_TERMINAL',
'repeated_capability_type': 'script_triggers',
'supported_rep_caps': [
'script_triggers'
],
'type': 'ViString'
},
1150310: {
Expand All @@ -579,7 +590,9 @@
},
'lv_property': 'Events:Marker:Output Terminal',
'name': 'MARKER_EVENT_OUTPUT_TERMINAL',
'repeated_capability_type': 'markers',
'supported_rep_caps': [
'markers'
],
'type': 'ViString'
},
1150314: {
Expand Down Expand Up @@ -670,7 +683,6 @@
},
'lv_property': 'Arbitrary Waveform:Arbitrary Waveform Mode:Marker Position',
'name': 'ARB_MARKER_POSITION',
'repeated_capability_type': 'markers',
'type': 'ViInt32'
},
1150328: {
Expand Down Expand Up @@ -699,7 +711,9 @@
},
'lv_property': 'Events:Data Marker:Data Bit Number',
'name': 'DATA_MARKER_EVENT_DATA_BIT_NUMBER',
'repeated_capability_type': 'markers',
'supported_rep_caps': [
'data_markers'
],
'type': 'ViInt32'
},
1150338: {
Expand All @@ -710,7 +724,9 @@
'enum': 'DataMarkerEventLevelPolarity',
'lv_property': 'Events:Data Marker:Level:Active Level',
'name': 'DATA_MARKER_EVENT_LEVEL_POLARITY',
'repeated_capability_type': 'markers',
'supported_rep_caps': [
'data_markers'
],
'type': 'ViInt32'
},
1150339: {
Expand All @@ -720,7 +736,9 @@
},
'lv_property': 'Events:Data Marker:Output Terminal',
'name': 'DATA_MARKER_EVENT_OUTPUT_TERMINAL',
'repeated_capability_type': 'markers',
'supported_rep_caps': [
'data_markers'
],
'type': 'ViString'
},
1150344: {
Expand Down Expand Up @@ -749,6 +767,9 @@
'enum': 'TerminalConfiguration',
'lv_property': 'Output:Terminal Configuration',
'name': 'TERMINAL_CONFIGURATION',
'supported_rep_caps': [
'channels'
],
'type': 'ViInt32'
},
1150366: {
Expand All @@ -758,6 +779,9 @@
},
'lv_property': 'Output:Common Mode Offset',
'name': 'COMMON_MODE_OFFSET',
'supported_rep_caps': [
'channels'
],
'type': 'ViReal64'
},
1150367: {
Expand Down Expand Up @@ -788,6 +812,9 @@
},
'lv_property': 'Output:Channel Delay',
'name': 'CHANNEL_DELAY',
'supported_rep_caps': [
'channels'
],
'type': 'ViReal64'
},
1150373: {
Expand Down Expand Up @@ -931,6 +958,9 @@
},
'lv_property': 'Output:Output Enabled',
'name': 'OUTPUT_ENABLED',
'supported_rep_caps': [
'channels'
],
'type': 'ViBoolean'
},
1250004: {
Expand All @@ -940,6 +970,9 @@
},
'lv_property': 'Output:Output Impedance',
'name': 'OUTPUT_IMPEDANCE',
'supported_rep_caps': [
'channels'
],
'type': 'ViReal64'
},
1250101: {
Expand All @@ -950,6 +983,9 @@
'enum': 'Waveform',
'lv_property': 'Standard Function:Waveform',
'name': 'FUNC_WAVEFORM',
'supported_rep_caps': [
'channels'
],
'type': 'ViInt32'
},
1250102: {
Expand All @@ -960,6 +996,9 @@
},
'lv_property': 'Standard Function:Amplitude',
'name': 'FUNC_AMPLITUDE',
'supported_rep_caps': [
'channels'
],
'type': 'ViReal64'
},
1250103: {
Expand All @@ -969,6 +1008,9 @@
},
'lv_property': 'Standard Function:DC Offset',
'name': 'FUNC_DC_OFFSET',
'supported_rep_caps': [
'channels'
],
'type': 'ViReal64'
},
1250104: {
Expand All @@ -979,6 +1021,9 @@
},
'lv_property': 'Standard Function:Standard Function Mode:Frequency',
'name': 'FUNC_FREQUENCY',
'supported_rep_caps': [
'channels'
],
'type': 'ViReal64'
},
1250105: {
Expand All @@ -989,6 +1034,9 @@
},
'lv_property': 'Standard Function:Start Phase',
'name': 'FUNC_START_PHASE',
'supported_rep_caps': [
'channels'
],
'type': 'ViReal64'
},
1250106: {
Expand All @@ -999,15 +1047,21 @@
},
'lv_property': 'Standard Function:Duty Cycle High',
'name': 'FUNC_DUTY_CYCLE_HIGH',
'supported_rep_caps': [
'channels'
],
'type': 'ViReal64'
},
1250201: {
'access': 'read-write',
'documentation': {
'description': '\nSelects which arbitrary waveform the signal generator produces. You can create multiple arbitrary waveforms using one of the following niFgen Create Waveform functions:\nniFgen_CreateWaveformF64\nniFgen_CreateWaveformI16\nniFgen_CreateWaveformFromFileI16\nniFgen_CreateWaveformFromFileF64\nniFgen_CreateWaveformFromFileHWS\nThese functions return a handle that you can use to identify the particular waveform. To configure the signal generator to produce a particular waveform, set this attribute to the waveform handle.\nUse this attribute only when NIFGEN_ATTR_OUTPUT_MODE is set to NIFGEN_VAL_OUTPUT_ARB.\n'
'description': '\nSelects which arbitrary waveform the signal generator produces. You can create multiple arbitrary waveforms using one of the following niFgen Create Waveform functions:\nniFgen_CreateWaveformF64\nniFgen_CreateWaveformI16\nniFgen_CreateWaveformFromFileI16\nniFgen_CreateWaveformFromFileF64\nThese functions return a handle that you can use to identify the particular waveform. To configure the signal generator to produce a particular waveform, set this attribute to the waveform handle.\nUse this attribute only when NIFGEN_ATTR_OUTPUT_MODE is set to NIFGEN_VAL_OUTPUT_ARB.\n'
},
'lv_property': 'Arbitrary Waveform:Arbitrary Waveform Mode:Arbitrary Waveform Handle',
'name': 'ARB_WAVEFORM_HANDLE',
'supported_rep_caps': [
'channels'
],
'type': 'ViInt32'
},
1250202: {
Expand All @@ -1017,6 +1071,9 @@
},
'lv_property': 'Arbitrary Waveform:Gain',
'name': 'ARB_GAIN',
'supported_rep_caps': [
'channels'
],
'type': 'ViReal64'
},
1250203: {
Expand All @@ -1026,6 +1083,9 @@
},
'lv_property': 'Arbitrary Waveform:Offset',
'name': 'ARB_OFFSET',
'supported_rep_caps': [
'channels'
],
'type': 'ViReal64'
},
1250204: {
Expand Down Expand Up @@ -1080,6 +1140,9 @@
},
'lv_property': 'Arbitrary Waveform:Arbitrary Sequence Mode:Arbitrary Sequence Handle',
'name': 'ARB_SEQUENCE_HANDLE',
'supported_rep_caps': [
'channels'
],
'type': 'ViInt32'
},
1250212: {
Expand Down
8 changes: 6 additions & 2 deletions src/nifgen/metadata/config.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
# This file is generated from NI-FGEN API metadata version 20.0.0d5
# This file is generated from NI-FGEN API metadata version 21.5.0d106
config = {
'api_version': '20.0.0d5',
'api_version': '21.5.0d106',
'c_function_prefix': 'niFgen_',
'close_function': 'close',
'context_manager_name': {
Expand Down Expand Up @@ -49,6 +49,10 @@
{
'prefix': 'Marker',
'python_name': 'markers'
},
{
'prefix': 'DataMarker',
'python_name': 'data_markers'
}
],
'session_class_description': 'An NI-FGEN session to a National Instruments Signal Generator.',
Expand Down
2 changes: 1 addition & 1 deletion src/nifgen/metadata/enums.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -*- coding: utf-8 -*-
# This file is generated from NI-FGEN API metadata version 20.0.0d5
# This file is generated from NI-FGEN API metadata version 21.5.0d106
enums = {
'AnalogPath': {
'values': [
Expand Down
Loading