Skip to content

set_global_data and set_site_data do not support sessions and other classes as the data #104

@ni-erikcrank

Description

@ni-erikcrank

Using set_global_data with a PXI session reports a run-time error even though documentation for the method indicates that you can use it for sessions. Here's an example:

pxi_session = rm.open_resource('PXI0::1::BACKPLANE')
tsm_context.set_global_data('pxi_session', pxi_session)

Traceback (most recent call last):
  File "C:\Program Files\Python37\lib\site-packages\IPython\core\interactiveshell.py", line 3437, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-15-6440a5af0b4f>", line 1, in <module>
    tsm_context.set_global_data('pxi_session', pxi_session)
  File "c:\users\ysinghal\documents\ni_py_dev\nitsm-python\src\nitsm\tsmcontext.py", line 289, in set_global_data
    return self._context.SetGlobalData(data_id, data)
  File "c:\users\ysinghal\documents\ni_py_dev\nitsm-python\src\nitsm\pinmapinterfaces.py", line 900, in SetGlobalData
    , data)
TypeError: must be real number, not PXIBackplane

Because underlying TSM API is implemented with a COM interface, the TSM SetGlobalData method is limited to COM VARIANT data types. To support arbitrary data types and for best performance, set_global_data should probably store the id() of the data in a global dictionary and pass the id to TSM instead of data itself. Likewise, get_global_data should use the dictionary to find the data from the id obtained from TSM.

A similar problem exists with set_site_data.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions