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

Updated the TestStand sequence of NI DCPower measurement to make it simpler #249

Merged
merged 13 commits into from
Apr 28, 2023

Conversation

Tharun-Sundar
Copy link
Contributor

What does this Pull Request accomplish?

  • Updates the TestStand sequence in the DC-Power example measurement to make it simpler by moving the process setup and process cleanup steps to the main sequence.
  • Combines the logic for registering pin map into a single step in the Setup section. Previously this was handled in three steps.

Why should this Pull Request be merged?

Based on the feedback discussed in this Teams post, moving the process setup and process cleanup steps to the main sequence will simplify the example sequence as the user will only need to run the main sequence to get the expected result. Though this sequence is not efficient for multi-site use case, this change is encouraged as the example sequence is expected to be tailored to users who are beginners in TestStand.

What testing has been done?

Manually executed the TestStand example sequence with a simulated DC-Power instrument and verified the result.

…the pin map and session registration steps

Signed-off-by: Tharun Sundar Balasubramanian <tharun.balasubramanian@ni.com>
Signed-off-by: Tharun Sundar Balasubramanian <tharun.balasubramanian@ni.com>
@Tharun-Sundar
Copy link
Contributor Author

@bkeryan When executing the TestStand sequence, the pin map file is not found even if it is available in the sequence directory. I updated the code as shown below to make sure that the logic is similar to the LabVIEW example sequence.

sequence_file = self._sequence_context.SequenceFile
(_, file_path, _, _, _) = self._sequence_context.Engine.FindFileEx(file_name, searchContext=sequence_file)
return file_path

But it is not having any impact in the search. Please share your thoughts on this.

examples/nidcpower_source_dc_voltage/_helpers.py Outdated Show resolved Hide resolved
examples/nidcpower_source_dc_voltage/_helpers.py Outdated Show resolved Hide resolved
examples/nidcpower_source_dc_voltage/_helpers.py Outdated Show resolved Hide resolved
examples/nidcpower_source_dc_voltage/_helpers.py Outdated Show resolved Hide resolved
examples/nidcpower_source_dc_voltage/_helpers.py Outdated Show resolved Hide resolved
examples/nidcpower_source_dc_voltage/_helpers.py Outdated Show resolved Hide resolved
examples/nidcpower_source_dc_voltage/teststand_fixture.py Outdated Show resolved Hide resolved
@vigkre vigkre requested a review from bkeryan April 27, 2023 15:59
@bkeryan
Copy link
Collaborator

bkeryan commented Apr 28, 2023

@bkeryan When executing the TestStand sequence, the pin map file is not found even if it is available in the sequence directory. I updated the code as shown below to make sure that the logic is similar to the LabVIEW example sequence.

sequence_file = self._sequence_context.SequenceFile
(_, file_path, _, _, _) = self._sequence_context.Engine.FindFileEx(file_name, searchContext=sequence_file)
return file_path

But it is not having any impact in the search. Please share your thoughts on this.

@Tharun-Sundar @vigkre

The first time you call FindFileEx, the win32com module dynamically generates this code:

"def FindFileEx(self, fileToFind=pythoncom.Missing, absolutePath=pythoncom.Missing, srchDirType=pythoncom.Missing, searchDirectoryIndex=pythoncom.Missing\n\t\t\t, userCancelled=pythoncom.Missing, promptOption=1, srchListOption=1, isCommand=False, searchContext=pythoncom.Missing\n\t\t\t, reserved=pythoncom.Missing):\n\treturn self._ApplyTypes_(1050, 1, (11, 0), ((8, 1), (16392, 2), (16387, 2), (16387, 2), (16395, 2), (3, 49), (3, 49), (11, 49), (12, 17), (12, 17)), 'FindFileEx', None,fileToFind\n\t\t\t, absolutePath, srchDirType, searchDirectoryIndex, userCancelled, promptOption\n\t\t\t, srchListOption, isCommand, searchContext, reserved)\n"

When you call FindFileEx(file_name, searchContext=sequence_file), this leaves absolutePath, srchDirType, etc. unspecified, so they default to pythoncom.Missing.

The problem is that PyIDispatch stops passing parameters when it encounters pythoncom.Missing: https://github.com/mhammond/pywin32/blob/main/com/win32com/src/PyIDispatch.cpp#L369

Passing None for the output parameters seems to work. I initially tried it with positional arguments:

        (_, file_path, _, _, _) = self._sequence_context.Engine.FindFileEx(
            file_name, # fileToFind
            None, # absolutePath
            None, # srchDirType
            None, # searchDirectoryIndex
            None, # userCancelled
            1, # promptOption=FindFile_PromptHonorUserPreference
            1, # srchListOption=FindFile_SrchAskUser
            False, # isCommand
            self._sequence_context.SequenceFile, # searchContext
        )
        return file_path

Using keyword arguments allows us to leave promptOption, srchListOption, and isCommand unspecified. Their default values are defined in TestStand's IDL, so leaving them unspecified does the right thing.

Let's do this:

        (_, file_path, _, _, _) = self._sequence_context.Engine.FindFileEx(
            fileToFind=file_name,
            absolutePath=None,
            srchDirType=None,
            searchDirectoryIndex=None,
            userCancelled=None,
            searchContext=self._sequence_context.SequenceFile,
        )
        return file_path

examples/nidcpower_source_dc_voltage/_helpers.py Outdated Show resolved Hide resolved
examples/nidcpower_source_dc_voltage/_helpers.py Outdated Show resolved Hide resolved
Signed-off-by: Brad Keryan <brad.keryan@ni.com>
Signed-off-by: Brad Keryan <brad.keryan@ni.com>
Signed-off-by: Brad Keryan <brad.keryan@ni.com>
Signed-off-by: Brad Keryan <brad.keryan@ni.com>
Signed-off-by: Brad Keryan <brad.keryan@ni.com>
@bkeryan bkeryan merged commit b05fe8f into main Apr 28, 2023
vigkre added a commit that referenced this pull request May 4, 2023
…impler (#249)

* Updated the TestStand sequence of NI DCPower measurement to simplify the pin map and session registration steps

Signed-off-by: Tharun Sundar Balasubramanian <tharun.balasubramanian@ni.com>

* Fix lint errors

Signed-off-by: Tharun Sundar Balasubramanian <tharun.balasubramanian@ni.com>

* Add new function to get pin map id stored in temporary variable

* Pass searchcontext with sequence file path

* Update python adaptoer consistently

* Resolve PR comments

* Specifies the return type for COM object

* File formatted using black

* examples: Update type annotations and docstrings

Signed-off-by: Brad Keryan <brad.keryan@ni.com>

* examples: Rename TestStandSupport methods

Signed-off-by: Brad Keryan <brad.keryan@ni.com>

* examples: Fix resolve_file_path

Signed-off-by: Brad Keryan <brad.keryan@ni.com>

* examples: Uncheck "Use adapter settings for Python interpreter"

Signed-off-by: Brad Keryan <brad.keryan@ni.com>

* examples: Update PinMapClient naming/comments

Signed-off-by: Brad Keryan <brad.keryan@ni.com>

---------

Signed-off-by: Tharun Sundar Balasubramanian <tharun.balasubramanian@ni.com>
Signed-off-by: Brad Keryan <brad.keryan@ni.com>
Co-authored-by: Vikram Avudaiappan <vikram.avudaiappan@ni.com>
Co-authored-by: Brad Keryan <brad.keryan@ni.com>
@dixonjoel dixonjoel deleted the users/tharun/simplify-teststand-example branch May 9, 2023 14:29
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.

4 participants