Skip to content

Commit

Permalink
Merge 2407384 into 3e5b0e1
Browse files Browse the repository at this point in the history
  • Loading branch information
texasaggie97-zz committed Jan 7, 2020
2 parents 3e5b0e1 + 2407384 commit 13d08ee
Show file tree
Hide file tree
Showing 6 changed files with 207 additions and 8 deletions.
87 changes: 87 additions & 0 deletions docs/nidcpower/class.rst
Expand Up @@ -270,6 +270,93 @@ configure_aperture_time
:type units: :py:data:`nidcpower.ApertureTimeUnits`
create_advanced_sequence
------------------------
.. py:currentmodule:: nidcpower.Session
.. py:method:: create_advanced_sequence(sequence_name, sequence, set_as_active_sequence=True)
Test.
.. note:: Test.
:param sequence_name:
Name of sequence.
:type sequence_name: str
:param sequence:
Sequence.
:type sequence: list of int
:param set_as_active_sequence:
Specifies that this current sequence is active.
:type set_as_active_sequence: bool
delete_advanced_sequence
------------------------
.. py:currentmodule:: nidcpower.Session
.. py:method:: delete_advanced_sequence(sequence_name)
Deletes a previously created advanced sequence and all the advanced
sequence steps in the advanced sequence.
**Support for this Method**
You must set the source mode to Sequence to use this method.
Using the :py:meth:`nidcpower.Session.set_sequence` method with Advanced Sequence
methods is unsupported.
**Related Topics**:
`Advanced Sequence
Mode <REPLACE_DRIVER_SPECIFIC_URL_1(advancedsequencemode)>`__
`Programming
States <REPLACE_DRIVER_SPECIFIC_URL_1(programmingstates)>`__
.. note:: This method is not supported on all devices. Refer to `Supported
Methods by
Device <REPLACE_DRIVER_SPECIFIC_URL_2(nidcpowercref.chm',%20'supportedfunctions)>`__
for more information about supported devices.
:param sequence_name:
specifies the name of the sequence to delete.
:type sequence_name: str
disable
-------
Expand Down
37 changes: 35 additions & 2 deletions generated/nidcpower/nidcpower/session.py
Expand Up @@ -4029,8 +4029,8 @@ def _create_advanced_sequence_step(self, set_as_active_step=True):
return

@ivi_synchronized
def _delete_advanced_sequence(self, sequence_name):
r'''_delete_advanced_sequence
def delete_advanced_sequence(self, sequence_name):
r'''delete_advanced_sequence
Deletes a previously created advanced sequence and all the advanced
sequence steps in the advanced sequence.
Expand Down Expand Up @@ -4206,6 +4206,39 @@ def export_attribute_configuration_file(self, file_path):
errors.handle_error(self, error_code, ignore_warnings=False, is_error_handling=False)
return

@ivi_synchronized
def create_advanced_sequence(self, sequence_name, sequence, set_as_active_sequence=True):
'''create_advanced_sequence
Test.
Note: Test.
Args:
sequence_name (str): Name of sequence.
sequence (list of int): Sequence.
set_as_active_sequence (bool): Specifies that this current sequence is active.
'''
# First we need to get all possible properties we might be setting. The way the NI-DCPower C API is designed,
# we need to know this upfront in order to call `niDCPower_CreateAdvancedSequence`. In order to find the attribute
# ID of each property, we look at the member Attribute objects of Session.
attribute_ids_used = set()
for step in sequence:
for key in step:
attribute_ids_used.add(Session.__base__.__dict__[key]._attribute_id)

# Create the sequence with the list of attr ids we have
self._create_advanced_sequence(sequence_name, list(attribute_ids_used), set_as_active_sequence)

# Create and configure the steps
for step in sequence:
self._create_advanced_sequence_step()
for key, value in step.items():
setattr(self, key, value)

@ivi_synchronized
def get_channel_name(self, index):
r'''get_channel_name
Expand Down
47 changes: 46 additions & 1 deletion src/nidcpower/metadata/functions.py
Expand Up @@ -3104,7 +3104,6 @@
'returns': 'ViStatus'
},
'DeleteAdvancedSequence': {
'codegen_method': 'private',
'documentation': {
'description': '\nDeletes a previously created advanced sequence and all the advanced\nsequence steps in the advanced sequence.\n\n**Support for this Function**\n\nYou must set the source mode to Sequence to use this function.\n\nUsing the niDCPower_SetSequence function with Advanced Sequence\nfunctions is unsupported.\n\n**Related Topics**:\n\n`Advanced Sequence\nMode <REPLACE_DRIVER_SPECIFIC_URL_1(advancedsequencemode)>`__\n\n`Programming\nStates <REPLACE_DRIVER_SPECIFIC_URL_1(programmingstates)>`__\n',
'note': "\nThis function is not supported on all devices. Refer to `Supported\nFunctions by\nDevice <REPLACE_DRIVER_SPECIFIC_URL_2(nidcpowercref.chm',%20'supportedfunctions)>`__\nfor more information about supported devices.\n"
Expand Down Expand Up @@ -3569,6 +3568,52 @@
],
'returns': 'ViStatus'
},
'FancyCreateAdvancedSequence': {
'codegen_method': 'python-only',
'returns': 'ViStatus',
'python_name': 'create_advanced_sequence',
'method_templates': [
{ 'session_filename': 'fancy_advanced_sequence', 'documentation_filename': 'default_method', 'method_python_name_suffix': '', },
],
'parameters': [
{
'direction': 'in',
'name': 'vi',
'type': 'ViSession',
'documentation': {
'description': 'Identifies a particular instrument session. **vi** is obtained from the niDCPower_InitExtCal or niDCPower_InitializeWithChannels function.',
},
},
{
'direction': 'in',
'name': 'SequenceName',
'type': 'ViString',
'documentation': {
'description': 'Name of sequence.',
},
},
{
'direction': 'in',
'name': 'Sequence',
'type': 'ViInt32[]', # Doesn't matter here
'documentation': {
'description': 'Sequence.',
},
},
{
'direction': 'in',
'name': 'setAsActiveSequence',
'type': 'ViBoolean',
'default_value': True,
'documentation': { 'description': 'Specifies that this current sequence is active.', },
},
],
'documentation':
{
'description': 'Test.',
'note': 'Test.',
},
},
'FancyFetchMultiple': {
'codegen_method': 'python-only',
'documentation': {
Expand Down
1 change: 1 addition & 0 deletions src/nidcpower/metadata/functions_addon.py
Expand Up @@ -5,3 +5,4 @@
}



11 changes: 6 additions & 5 deletions src/nidcpower/system_tests/test_system_nidcpower.py
Expand Up @@ -269,12 +269,13 @@ def test_import_export_file(single_channel_session):


def test_create_and_delete_advanced_sequence_step(single_channel_session):
ids = [1250001] # work around #507
my_advanced_sequence = [
{"output_function": nidcpower.OutputFunction.DC_VOLTAGE, "voltage_level": 5.0},
{"output_function": nidcpower.OutputFunction.DC_CURRENT, "current_level": 0.1}
]
single_channel_session.source_mode = nidcpower.SourceMode.SEQUENCE
single_channel_session._create_advanced_sequence(sequence_name='my_sequence', attribute_ids=ids, set_as_active_sequence=True)
single_channel_session._create_advanced_sequence_step(set_as_active_step=True)
single_channel_session.voltage_level = 1
single_channel_session._delete_advanced_sequence(sequence_name='my_sequence')
single_channel_session.create_advanced_sequence(sequence_name='my_sequence', sequence=my_advanced_sequence, set_as_active_sequence=True)
single_channel_session.delete_advanced_sequence(sequence_name='my_sequence')


def test_send_software_edge_trigger_error(session):
Expand Down
32 changes: 32 additions & 0 deletions src/nidcpower/templates/session.py/fancy_advanced_sequence.py.mako
@@ -0,0 +1,32 @@
<%page args="f, config, method_template"/>\
<%
'''Implements Fancy Advanced Sequence'''
import build.helper as helper
suffix = method_template['method_python_name_suffix']
# precalculate some lists
attrs = helper.filter_codegen_attributes(config['attributes'])
%>\
def ${f['python_name']}${suffix}(${helper.get_params_snippet(f, helper.ParameterUsageOptions.SESSION_METHOD_DECLARATION)}):
'''${f['python_name']}

${helper.get_function_docstring(f, False, config, indent=8)}
'''
# First we need to get all possible properties we might be setting. The way the NI-DCPower C API is designed,
# we need to know this upfront in order to call `niDCPower_CreateAdvancedSequence`. In order to find the attribute
# ID of each property, we look at the member Attribute objects of Session.
attribute_ids_used = set()
for step in sequence:
for key in step:
attribute_ids_used.add(Session.__base__.__dict__[key]._attribute_id)

# Create the sequence with the list of attr ids we have
self._create_advanced_sequence(sequence_name, list(attribute_ids_used), set_as_active_sequence)

# Create and configure the steps
for step in sequence:
self._create_advanced_sequence_step()
for key, value in step.items():
setattr(self, key, value)

0 comments on commit 13d08ee

Please sign in to comment.