0% found this document useful (0 votes)
2 views

TestAutomationPythonModulesReference

The document is a reference guide for the Test Automation Python Modules released by dSPACE in May 2024, detailing how to interface with MATLAB and utilize various Python classes for test automation. It includes contact information for dSPACE support, safety precautions, and an overview of the modules available, along with specific instructions for using the matlablib2 module. Additionally, it emphasizes the importance of software updates and the proprietary nature of the content.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

TestAutomationPythonModulesReference

The document is a reference guide for the Test Automation Python Modules released by dSPACE in May 2024, detailing how to interface with MATLAB and utilize various Python classes for test automation. It includes contact information for dSPACE support, safety precautions, and an overview of the modules available, along with specific instructions for using the matlablib2 module. Additionally, it emphasizes the importance of software updates and the proprietary nature of the content.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

Test Automation

Python Modules Reference


Release 2024-A – May 2024
How to Contact dSPACE
Mail: dSPACE GmbH
Rathenaustraße 26
33102 Paderborn
Germany
Tel.: +49 5251 1638-0
E-mail: info@dspace.de
Web: https://www.dspace.com

How to Contact dSPACE Support


If you encounter a problem when using dSPACE products, contact your local dSPACE
representative:
§ Local dSPACE companies and distributors: https://www.dspace.com/go/locations
§ For countries not listed, contact dSPACE GmbH in Paderborn, Germany.
Tel.: +49 5251 1638-941 or e-mail: support@dspace.de

You can also use the support request form: https://www.dspace.com/go/supportrequest. If


you are logged on to mydSPACE, you are automatically identified and do not have to add
your contact details manually.

If possible, always provide the serial number of the hardware, the relevant dSPACE License
ID, or the serial number of the CmContainer in your support request.

Software Updates and Patches


dSPACE strongly recommends that you download and install the most recent patches
for your current dSPACE installation. Visit https://www.dspace.com/go/patches for the
software updates and patches themselves and for more information, such as how to
receive an automatic notification when an update or a patch is available for your dSPACE
software.

Important Notice
This publication contains proprietary information that is protected by copyright. All rights
are reserved. The publication may be printed for personal or internal use provided all the
proprietary markings are retained on all printed copies. In all other cases, the publication
must not be copied, photocopied, reproduced, translated, or reduced to any electronic
medium or machine-readable form, in whole or in part, without the prior written consent
of dSPACE GmbH.

© 1999 - 2024 by:


dSPACE GmbH
Rathenaustraße 26
33102 Paderborn
Germany

This publication and the contents hereof are subject to change without notice.

AURELION, AUTERA, ConfigurationDesk, ControlDesk, MicroAutoBox, MicroLabBox,


SCALEXIO, SIMPHERA, SYNECT, SystemDesk, TargetLink, and VEOS are registered
trademarks of dSPACE GmbH in the United States or other countries, or both. Other
brand names or product names are trademarks or registered trademarks of their respective
companies or organizations.
Contents

Contents

About this Reference 5

Safety Precautions 7
General Warning............................................................................................. 7

Overview of the Python Modules for Test Automation 9


Overview of the Test Automation Python Modules........................................... 9

Interfacing MATLAB (matlablib2) 11


Overview of the matlablib2 Module........................................................................ 12
Basic Information on the matlablib2 Module................................................. 12
MATLAB Type Conversion.............................................................................. 13

CellArray................................................................................................................ 17
CellArray Class Description............................................................................ 17
GetDimensions.............................................................................................. 19
GetItem............................................................................................ ............ 19
GetNumberOfDimensions................................................................. ............ 20
SetItem......................................................................................................... 21

Matfile................................................................................................................... 23
Matfile Class Description............................................................................... 23
Close................................................................................................ ............ 24
DeleteArray................................................................................................... 25
GetArray....................................................................................................... 26
GetDir........................................................................................................... 27
Load................................................................................................. ............ 27
Open................................................................................................ ............ 28
PutArray........................................................................................................ 30
PutArrayAsGlobal.......................................................................................... 30
Whos............................................................................................................ 31

Matlab................................................................................................................... 33
Matlab Class Description............................................................................... 33
Close................................................................................................ ............ 35
ConnectedMATLABInstallations..................................................................... 36
ExecutablePath.............................................................................................. 37
Execute......................................................................................................... 37

3
May 2024 Test Automation Python Modules Reference
Contents

GetArray....................................................................................................... 38
GetOutputs................................................................................................... 39
IsAlive........................................................................................................... 40
IsMUMatlabOpen.......................................................................................... 41
Open................................................................................................ ............ 41
ProcessArchitecture....................................................................................... 43
ProcessID....................................................................................................... 43
PutArray........................................................................................................ 44
Version.......................................................................................................... 45
WatchdogMethod......................................................................................... 45

Examples (matlablib2)............................................................................................. 47
Examples of Using matlablib2........................................................................ 47

Multiple Use of Identifiers Within the Test Automation


Python Modules 49
Close................................................................................................ ............ 50
GetArray....................................................................................................... 50
Open................................................................................................ ............ 50
PutArray........................................................................................................ 51

Index 53

4
Test Automation Python Modules Reference May 2024
About this Reference

About this Reference

Content This reference provides detailed information on the Python commands of the Test
Automation Python Modules.

It is assumed that you know the Test Automation Python Modules Guide .

Symbols dSPACE user documentation uses the following symbols:

Symbol Description
Indicates a hazardous situation that, if not avoided,
V DANGER
will result in death or serious injury.
Indicates a hazardous situation that, if not avoided,
V WARNING could result in death or serious injury.
Indicates a hazardous situation that, if not avoided,
V CAUTION could result in minor or moderate injury.
Indicates a hazard that, if not avoided, could result in
NOTICE
property damage.
Indicates important information that you should take
Note
into account to avoid malfunctions.
Indicates tips that can make your work easier.
Tip
Indicates a link that refers to a definition in the
glossary, which you can find at the end of the
document unless stated otherwise.
Follows the document title in a link that refers to
another document.

Naming conventions dSPACE user documentation uses the following naming conventions:

%name% Names enclosed in percent signs refer to environment variables for


file and path names.

<> Angle brackets contain wildcard characters or placeholders for variable


file and path names, etc.

5
May 2024 Test Automation Python Modules Reference
About this Reference

Special Windows folders Windows‑based software products use the following special folders:

Common Program Data folder A standard folder for application-specific


program data that is used by all users.
%PROGRAMDATA%\dSPACE\<InstallationGUID>\<ProductName>
or
%PROGRAMDATA%\dSPACE\<ProductName>\<VersionNumber>

Documents folder A standard folder for application‑specific files that are


used by the current user.
%USERPROFILE%\Documents\dSPACE\<ProductName>\<VersionNumber>

Local Program Data folder A standard folder for application-specific


program data that is used by the current user.
%USERPROFILE%\AppData\Local\dSPACE\<InstallationGUID>\
<ProductName>

Accessing dSPACE Help and After you install and decrypt Windows‑based dSPACE software, the
PDF files documentation for the installed products is available in dSPACE Help and as PDF
files.

dSPACE Help (local) You can open your local installation of dSPACE Help:
§ On its home page via Windows Start Menu
§ On specific content using context-sensitive help via F1

PDF files You can access PDF files via the icon in dSPACE Help. The PDF
opens on the first page.

dSPACE Help (Web) Independently of the software installation, you can


access the Web version of dSPACE Help at https://www.dspace.com/go/help.
To access the Web version, you must have a mydSPACE account.
For more information on the mydSPACE registration process, refer to
https://www.dspace.com/faq?097.

6
Test Automation Python Modules Reference May 2024
Safety Precautions

Safety Precautions

Introduction To avoid risk of injury and/or property damage, read and ensure compliance with
the safety precautions given.

General Warning

Danger potential Using dSPACE software can be dangerous. You must observe the following
safety instructions and the relevant instructions in the user documentation.

Improper or negligent use can result in serious personal injury and/or


property damage
Using the dSPACE software can have a direct effect on technical systems
(electrical, hydraulic, mechanical) connected to it.
The risk of property damage or personal injury also exists when the dSPACE
software is controlled via an automation interface. The dSPACE software is then
part of an overall system and may not be visible to the end user. It nevertheless
produces a direct effect on the technical system via the controlling application
that uses the automation interface.
§ Only persons who are qualified to use dSPACE software, and who have been
informed of the above dangers and possible consequences, are permitted to
use this software.
§ All applications where malfunctions or operating errors involve the danger
of injury or death must be examined for potential hazards by the user, who
must if necessary take additional measures for protection (for example, an
emergency off switch).

Liability It is your responsibility to adhere to instructions and warnings. Any unskilled


operation or other improper use of this product in violation of the respective
safety instructions, warnings, or other instructions contained in the user
documentation constitutes contributory negligence, which may lead to a
limitation of liability by dSPACE GmbH, its representatives, agents and regional
dSPACE companies, to the point of total exclusion, as the case may be. Any

7
May 2024 Test Automation Python Modules Reference
Safety Precautions

exclusion or limitation of liability according to other applicable regulations,


individual agreements, and applicable general terms and conditions remain
unaffected.

Data loss during operating The shutdown procedure of Microsoft Windows operating systems causes some
system shutdown required processes to be aborted although they are still being used by dSPACE
software. To avoid data loss, the dSPACE software must be terminated manually
before a PC shutdown is performed.

8
Test Automation Python Modules Reference May 2024
Overview of the Python Modules for Test Automation

Overview of the Python Modules for Test


Automation

Overview of the Test Automation Python Modules

Introduction The Test Automation Python Modules include specific Python modules used for
automating tests.

These modules allow the remote control of MATLAB.

Overview The illustration gives an overview of the modules and classes provided by the Test
Automation Python Modules.

The table provides descriptions of the modules:

Module Description
matlablib2 To exchange data between MATLAB and the Python Interpreter,
invoke MATLAB functions or to access files in the MATLAB file
format. See Interfacing MATLAB (matlablib2) on page 11.

With Release 2021‑B, the rs232lib2 Python module is discontinued. As an


alternative, you can use the standard Python serial port extension pyserial.

Packaging and licences For more information on packages and licences, refer to Introduction to
the Python Modules for Test Automation (Test Automation Python Modules
Guide ).

9
May 2024 Test Automation Python Modules Reference
Overview of the Python Modules for Test Automation

Quick reference For the Test Automation Python Modules, an introduction is available. The object
information is summarized in a set of compact tables, each of which provides
a quick overview of the available objects, object dependencies, attributes and
methods. For a printable version of the quick reference, refer to dSPACE Help.

Multiple identifiers In the Test Automation Python Modules, some method and class identifiers are
multiply used. For easier access to the related documentation in dSPACE Help,
see Multiple Use of Identifiers Within the Test Automation Python Modules on
page 49.

Related topics References

Interfacing MATLAB (matlablib2).............................................................................................. 11


Introduction (Test Automation Python Modules Quick Reference )

10
Test Automation Python Modules Reference May 2024
Interfacing MATLAB (matlablib2)

Interfacing MATLAB (matlablib2)

Where to go from here Information in this section

Overview of the matlablib2 Module......................................................... 12

CellArray................................................................................................. 17

Matfile.................................................................................................... 23

Matlab.................................................................................................... 33

Examples (matlablib2).............................................................................. 47

11
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)

Overview of the matlablib2 Module


Where to go from here Information in this section

Basic Information on the matlablib2 Module............................................ 12

MATLAB Type Conversion........................................................................ 13

Basic Information on the matlablib2 Module

Introduction The matlablib2 module provides access to MATLAB. Using the class Matlab,
you can exchange data between MATLAB and the Python Interpreter or
invoke MATLAB functions (use existing m-scripts, for example). matlablib2 also
provides access to the MATLAB file format (MAT files) via the class Matfile. For
information on how to use matlablib2, refer to Working with MATLAB (Test
Automation Python Modules Guide ).

Classes The matlablib2 module defines the following classes:

Purpose Refer to
(CaptureData class)1)
CellArray class
To provide a Python representation of CellArray on page 17
the MATLAB cell array type.
Matfile class
To create an instance of the class Matfile. Matfile on page 23
Matlab class
To create an instance of the class Matlab. Matlab on page 33
1) Discontinued as of dSPACE Release 2021‑A.

Exception matlablibError

12
Test Automation Python Modules Reference May 2024
Overview of the matlablib2 Module

Constants The following table shows the constants and their description:

Constant Description
CellArrayType The type of a CellArray instance

Examples For examples, refer to Examples of Using matlablib2 on page 47.

MATLAB Type Conversion

MATLAB type conversion MATLAB’s array classes are mapped to the Python types int, long, float, string,
complex, list (of lists), dictionary and CellArray instances when reading from a
MAT file or the MATLAB Workspace. Vice versa these Python types are mapped
to MATLAB array classes when writing to a MAT file or the MATLAB Workspace.

The following table shows some examples of type conversions that apply to both
directions:

MATLAB Array Class Python Type


1x1 int32 array int
1x1 double array float
1x1 double array (complex) complex
1xN char array string
1x1 struct array dictionary
1xN int32 array list of int
1xN double array list of float
1xN double array (complex) list of complex
MxN char array list of string
1xN struct array list of dictionary
MxN int32 array list of list of int
MxN double array list of list of float
MxN double array (complex) list of list of complex
MxNxO char array list of list of string
MxN struct array list of list of dictionary
MxN cell array CellArray instance (MxN)

Lists of dimension > 2 are converted to the appropriate multi- dimensional


MATLAB array class.

13
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)

The following table shows the exact type conversion rules for MATLAB basic
types while reading from a MAT file or the MATLAB Workspace:

From MATLAB Array Class To Python Type Description


0x0 double array ListType Empty list
1x1 double array FloatType -
1xN double array ListType List of values of type FloatType
MxN double array ListType List of values of type ListType, each of the inner lists
containing values of type FloatType
MxNx... double array ListType List of lists of lists of … type FloatType
1xN char array StringType -
MxN char array ListType List of values of type StringType
MxNx... char array ListType List of lists of … StringType
1x1 struct array DictionaryType Keys of type StringType, values of appropriate types
1xN struct array ListType List of values of type DictionaryType, keys of type
StringType, values of appropriate types
MxN struct array ListType List of lists of values of type DictionaryType, keys of
type StringType, values of appropriate types
MxNx... struct array ListType List of lists of lists of … type DictionaryType, keys of
type StringType, values of appropriate types
0x0 cell array CellArrayType Empty cell array
1x1 cell array CellArrayType Each cell contains a value of appropriate Python
type
1xN cell array CellArrayType Each cell contains a value of appropriate Python
type
MxN cell array CellArrayType Each cell contains a value of appropriate Python
type
MxNx... cell array CellArrayType Each cell contains a value of appropriate Python
type
1x1 double array (complex) ComplexType -
1xN double array (complex) ListType List of values of type ComplexType
MxN double array (complex) ListType List of values of type ListType, each of the inner lists
containing values of type ComplexType
MxNx... double array (complex) ListType List of lists of lists of … type ComplexType
1x1 single array FloatType -
1xN single array see row: 1xN double array -
MxN single array see row: MxN double array -
MxNx... single array see row: MxNx... double array -
1x1 int8 array IntType -
1xN int8 array ListType List of values of type IntType
MxN int8 array ListType List of values of type ListType, each of the inner lists
containing values of type IntType
MxNx... int8 array ListType List of lists of lists of … type IntType
1x1 int16 array IntType -

14
Test Automation Python Modules Reference May 2024
Overview of the matlablib2 Module

From MATLAB Array Class To Python Type Description


1xN int16 array see row: 1xN int8 array -
MxN int16 array see row: MxN int8 array -
MxNx... int16 array see row: MxNx... int8 array -
1x1 int32 array IntType -
1xN int32 array see row: 1xN int8 array -
MxN int32 array see row: MxN int8 array -
MxNx... int32 array see row: MxNx... int8 array -
1x1 uint8 array IntType -
1xN uint8 array see row: 1xN int8 array -
MxN uint8 array see row: MxN int8 array -
MxNx... uint8 array see row: MxNx... int8 array -
1x1 uint16 array IntType -
1xN uint16 array see row: 1xN int8 array -
MxN uint16 array see row: MxN int8 array -
MxNx... uint16 array see row: MxNx... int8 array -
1x1 uint32 array LongType -
1xN uint32 array ListType List of values of type LongType
MxN uint32 array ListType List of values of type ListType, each of the inner lists
containing values of type LongType
MxNx... uint32 array ListType List of lists of lists of … type LongType

The following table shows the exact type conversion rules for Python basic types
while writing to a MAT file or the MATLAB Workspace:

From Python Type To MATLAB Array Class Description


FloatType 1x1 double array -
IntType 1x1 int32 array -
LongType 1x1 int32 array If long value <= 2^31-1
ComplexType 1x1 double array (complex) -
StringType 1xN char array -
UnicodeType 1xN char array -
DictionaryType 1x1 struct array All keys of the dictionary must be of type
StringType
ListType 0x0 double array If list is empty
1xN array of the class double, int32, If list contains values of the basic Python types
complex, char or struct float, int, long, complex, string, unicode object, or
MxNx... array of the class double, int32, dictionary, resp.
complex, char or struct Multidimensional MATLAB array of appropriate
type
CellArrayType 0x0 cell array If Python CellArray is empty
MxNx... cell array else

15
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)

The following examples show how to specifiy row or column vectors, matrices
and cell arrays in Python:

1x1 vector (a plain value) 1.0 = [1.0] = [[1.0]]


1x3 row vector [1.0, 2.0, 3.0] = [[1.0, 2.0, 3.0]]
3x1 column vector [[1.0], [2.0], [3.0]]
2x3 matrix [[1.0, 2.0, 3.0], [4.0, 5.0, 6.0]]
1x1 integer vector 1 = [1] = [[1]]
1x3 integer row vector [1, 2, 3] = [[1, 2, 3]]
3x1 integer column vector [[1], [2], [3]]
2x3 integer matrix [[1, 2, 3], [4, 5, 6]]
2x2 cell array c1 = CellArray(2,2)
c1.SetItem(0,0, [1.0,2.0])
c1.SetItem(0,1, "dSPACE")
c1.SetItem(1,0, [1])
c2 = CellArray(1,2)
c2.SetItem(0,0, [1])
c2.SetItem(0,1, [2.0,4.0])
c1.SetItem(1,1, c2)

In MATLAB all arrays are at least two-dimensional. As one can see from the
examples and Interfacing MATLAB (matlablib2), it is possible to put plain values
to MATLAB via PutArray() as an abbreviation for specifying a list containing a list
that contains a single value (see example 1x1 vector above). The same approach
applies to row vectors: one can simply specify a Python list containing the values
as an abbreviation for a list containing a single list containing the column values
(see example 1x3 row vector above).

16
Test Automation Python Modules Reference May 2024
CellArray

CellArray
Where to go from here Information in this section

CellArray Class Description...................................................................... 17

GetDimensions........................................................................................ 19

GetItem................................................................................................... 19

GetNumberOfDimensions........................................................................ 20

SetItem.................................................................................................... 21

CellArray Class Description

Module matlablib2

Syntax Two possibilities:


OBJ = matlablib2.CellArray(ListOfDimensionSizes)

or
OBJ = matlablib2.CellArray([N1 [,N2 [,N3]]])

Example import matlablib2


c1 = matlablib2.CellArray(2,2)

Purpose To provide a Python representation of the MATLAB cell array type.

Description The Python representation of a MATLAB cell array is an instance of the class
CellArray, defined in module matlablib2. The constructor of CellArray may be
used in one of two ways:
§ The first form takes a list as argument, containing the number of elements
for each dimension of the resulting CellArray instance. The length of the list
determines the dimension of the CellArray. Due to limitations in MATLAB,
the dimension is at least 2. Therefore, if the constructor argument is [], the
resulting CellArray has size 0x0, if the argument is [N1], the resulting CellArray
has size N1x0. if the argument is [N1, N2], the resulting CellArray has size
N1xN2, and so on.
§ As a abbreviation, the second form takes up to three arguments of type int. If
no argument is given, an instance of an empty cell array is created (dimension

17
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)

2, 0x0). If only N1 is given, the resulting CellArray instance has dimension 2


(N1x0). If in addition to N1 an argument N2 is given, the resulting CellArray
instance also has dimension 2 (N1xN2). If (in addition to N1 and N2) N3 is
given the resulting CellArray instance has dimension 3 (N1xN2xN3).

Parameters The following parameters are used:

Parameter Type Description


ListOfDimensionSizes List To set a list containing the size of each dimension of the CellArray instance to be
created.
N1 Int To set the size of the first dimension.
N2 Int To set the size of the second dimension.
N3 Int To set the size of the third dimension.

Return value The following object is returned:

Return Value Type Description


OBJ CellArray The created CellArray object

Exception The following exception may be raised:

Exception Description
matlablibError On any error of this method, matlablibError is returned.

Attributes –

Methods The class CellArray provides the following methods:

Method Purpose
GetDimensions To get the size of each dimension. See
GetDimensions on page 19.
GetItem To get a cell array item. See GetItem on page 19.
GetNumberOfDimensions To get the number of dimensions. See
GetNumberOfDimensions on page 20.
SetItem To set a cell array item. See SetItem on page 21.

18
Test Automation Python Modules Reference May 2024
CellArray

GetDimensions

Class CellArray

Syntax [Result = ] OBJ.GetDimensions()

Purpose To get the size of each dimension.

Description This method returns a list containing the sizes for each dimension.

Parameters –

Return value The method returns a value of the following type:

Type Description
List A list containing the size of each dimension. The length of the list is at
least 2.

Exception This method may raise the following exception:

Exception Description
matlablibError On any error of this method, matlablibError is returned.

Related methods GetNumberOfDimensions on page 20

GetItem

Class CellArray

Syntax [Result = ] OBJ.GetItem(IndexList)

[Result = ] OBJ.GetItem(I1, I2 [,I3])

Purpose To get a cell array item.

19
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)

Description The content of the cell at the indices specified by IndexList is returned.

As an abbreviation, the second form of GetItem takes 2 or 3 arguments of type


int.

Parameters The method uses the following parameters:

Parameter Type Description


IndexList List of Int The list of indices specifying the cell to return. This list
must contain values of type Int. Since a CellArray is at
least 2-dimensional, the length of the list must be at
least 2.
I1 Int First dimension index of cell to be returned
I2 Int Second dimension index of cell to be returned
I3 Int Third dimension index of cell to be returned

Return value The method returns a value of the following type:

Type Description
Various The Python representation of the cell array. See Interfacing MATLAB
(matlablib2) on page 11 for a detailed description of valid Python
value types.

Exception This method may raise the following exception:

Exception Description
matlablibError On any error of this method, matlablibError is returned.

Related methods SetItem on page 21

GetNumberOfDimensions

Class CellArray

Syntax [Result = ] OBJ.GetNumberOfDimensions()

Purpose To get the number of dimensions.

20
Test Automation Python Modules Reference May 2024
CellArray

Description This method returns the number of dimensions of the CellArray instance. Due to
MATLAB’s representation of arrays, this number is at least 2.

Parameters –

Return value The method returns a value of the following type:

Type Description
Int The number of dimensions

Exception This method may raise the following exception:

Exception Description
matlablibError On any error of this method, matlablibError is returned.

Related methods GetDimensions on page 19

SetItem

Class CellArray

Syntax OBJ.SetItem(IndexList, Value)

OBJ.SetItem(I1, I2 [,I3], Value)

Purpose To set a cell array item.

Description The content of the cell at the indices specified by IndexList is set.

As an abbreviation, the second form of SetItem takes 2 or 3 index arguments of


type int (and the value to set).

Parameters The method uses the following parameters:

Parameter Type Description


IndexList List of Int The list of indices specifying the cell to be set. This list
must contain values of type int. Since a MATLAB cell

21
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)

Parameter Type Description


array is at least 2-dimensional, the length of the list
must be at least 2.
I1 Int First dimension index of cell to be set
I2 Int Second dimension index of cell to be set
I3 Int Third dimension index of cell to be set
Value Various Python representation of the cell content to be set

Return value –

Exception This method may raise the following exception:

Exception Description
matlablibError On any error of this method, matlablibError is returned.

Related methods –

22
Test Automation Python Modules Reference May 2024
Matfile

Matfile
Where to go from here Information in this section

Matfile Class Description......................................................................... 23

Close....................................................................................................... 24

DeleteArray............................................................................................. 25

GetArray................................................................................................. 26

GetDir..................................................................................................... 27

Load........................................................................................................ 27

Open....................................................................................................... 28

PutArray.................................................................................................. 30

PutArrayAsGlobal.................................................................................... 30

Whos...................................................................................................... 31

Matfile Class Description

Module matlablib2

Syntax OBJ = matlablib2.Matfile()

Example import matlablib2


MyMatfile = matlablib2.Matfile()

Purpose To create an instance of the class Matfile.

Description An instance of the class Matfile can be used to access MAT files. While reading a
MAT file, MATLAB’s array classes are converted to Python types. While writing a
MAT file, certain Python types are converted to MATLAB arrays.

See Interfacing MATLAB (matlablib2) on page 11 for a detailed list of


supported MATLAB array classes and their conversion to an appropriate Python
representation.

23
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)

Parameters –

Return value The following object is returned:

Return Value Type Description


OBJ Matfile The created Matfile object

Exception The following exception may be raised:

Exception Description
matlablibError On any error of this method, matlablibError is returned.

Attributes –

Methods The class Matfile provides the following methods:

Method Purpose
Close To close a MAT file. See Close on page 24.
DeleteArray To delete an array from a MAT file. See DeleteArray on
page 25.
GetArray To get an array from a MAT file. See GetArray on page 26.
GetDir To get the directory of a MAT file. See GetDir on page 27.
Load To load the whole MAT file and assign all contained arrays
to variables in the global namespace with the same names.
See Load on page 27.
Open To open a MAT file. See Open on page 28.
PutArray To put an array represented as Python object to a MAT file.
See PutArray on page 30.
PutArrayAsGlobal To put an array represented as Python object to a MAT file
as global. See PutArrayAsGlobal on page 30.
Whos To list variables in the MAT file in long form. See Whos on
page 31.

Close

Class Matfile

Syntax OBJ.Close()

24
Test Automation Python Modules Reference May 2024
Matfile

Purpose To close a MAT file.

Description This method closes the previously opened MAT file.

Parameters –

Return value –

Exception This method may raise the following exception:

Exception Description
matlablibError The file could not be closed.

Related methods Load on page 27,

Open on page 28

DeleteArray

Class Matfile

Syntax OBJ.DeleteArray(NameOfArray)

Purpose To delete an array from a MAT file.

Description This method deletes the array with the specified name from the MAT file.

Parameters The method uses the following parameter:

Parameter Type Description


NameOfArray String The name of the array to be deleted.
Unicode

Return value –

25
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)

Exception This method may raise the following exception:

Exception Description
matlablibError On any error of this method, matlablibError is returned.

Related methods GetArray on page 26

GetArray

Class Matfile

Syntax [Result =] OBJ.GetArray(NameOfArray)

Purpose To get an array from a MAT file.

Description This method gets the array with the specified name from the MAT file and
returns its Python representation.

Parameters The method uses the following parameters:

Parameter Type Description


NameOfArray String The name of the array to be retrieved.
Unicode

Return value The method returns a value of the following type:

Type Description
Various The Python representation of the MATLAB-array. See Interfacing
MATLAB (matlablib2) on page 11 for a detailed description of valid
Python value types.

Exception This method may raise the following exception:

Exception Description
matlablibError On any error of this method, matlablibError is returned.

26
Test Automation Python Modules Reference May 2024
Matfile

Related methods DeleteArray on page 25

GetDir

Class Matfile

Syntax [Result =] OBJ.GetDir()

Purpose To get the directory of a MAT file.

Description This method gets the directory of a MAT file and returns a list of name strings of
all of the arrays contained in the file.

Parameters –

Return value The method returns a value of the following type:

Type Description
List A list of array name strings

Exception This method may raise the following exception:

Exception Description
matlablibError On any error of this method, matlablibError is returned.

Load

Class Matfile

Syntax OBJ.Load()

Purpose To load the whole MAT file and assign all contained arrays to variables in the
global namespace with the same names.

27
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)

Description This method loads each array contained in the MAT file. Each array is assigned
to a variable with the same name in the top-level script environment (the global
namespace). This method is similar to MATLAB’s load command.

Note

Existing variables with the same name are overwritten without notice. Be
sure not to overwrite variables that are needed for the currently running
script.

Parameters –

Return value –

Exception This method may raise the following exception:

Exception Description
matlablibError On any error of this method, matlablibError is returned.

Related methods Close on page 24,

Open on page 28

Open

Class Matfile

Syntax OBJ.Open(FileName, Mode [, ConvertToDouble=0])

Purpose To open a MAT file.

Description This method allows you to open MAT files for reading and writing.

28
Test Automation Python Modules Reference May 2024
Matfile

Parameters The method uses the following parameters:

Parameter Type Description


FileName String The name of the file to open.
Unicode
Mode String The file opening mode.
Unicode
ConvertToDouble Boolean If this optional parameter is set to 1:
§ All subsequent calls to PutArray convert Python
integer types like int and long to the MATLAB
type double.
§ All subsequent calls to GetArray convert
MATLAB integer types to Python float.
The default for this parameter is 0 (false).

The following table shows all possible values for the Mode parameter:

Mode Description
String
"r" Opens the file for reading only; determines the current version of the MAT file by inspecting the files
and preserves the current version.
"u" Opens the file for update, both reading and writing, but does not create the file if the file does
not exist (equivalent to the "r+"-mode of fopen); determines the current version of the MAT file by
inspecting the files and preserves the current version.
"w" Opens the file for writing only; deletes previous contents, if any.
"w4" Creates a MAT file that is compatible with MATLAB version 4 and earlier.
"wL" Opens the file for writing character data using the default character set for your system. The resulting
MAT file can be read with MATLAB version 6 or 6.5. If you do not use the wL mode switch, MATLAB
writes character data to the MAT file using Unicode encoding by default.
"wz" Opens the file for writing compressed data. The same compression ratio is applied than by saving
workspace variables to a MAT file.
"w7.3" Creates a MAT file in an HDF5‑based data format. This file format can store objects that require more
than 2 GB. This is the default file format that can be read with MATLAB version 7.3 and later.

Return value –

Exception This method may raise the following exception:

Exception Description
matlablibError The file could not be opened.

Related methods Close on page 24,

Load on page 27

29
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)

PutArray

Class Matfile

Syntax OBJ.PutArray(NameOfArray, Value)

Purpose To put an array represented as Python object to a MAT file.

Description This method puts the array with the specified name and value, represented as
Python object, to the MAT file.

Parameters The method uses the following parameters:

Parameter Type Description


NameOfArray String The name of the array to be written.
Unicode
Value The Python representation of the MATLAB-array. See
Interfacing MATLAB (matlablib2) on page 11 for a
detailed description of valid Python value types.

Return value –

Exception This method may raise the following exception:

Exception Description
matlablibError On any error of this method, matlablibError is returned.

Related methods PutArrayAsGlobal on page 30

PutArrayAsGlobal

Class Matfile

Syntax OBJ.PutArrayAsGlobal(NameOfArray, Value)

30
Test Automation Python Modules Reference May 2024
Matfile

Purpose To put an array represented as Python object to a MAT file as global.

Description This method puts the array with the specified name and value, represented
as Python object, to the MAT file. It is similar to PutArray(), except the array
is loaded by MATLAB into the global workspace and a reference to it is
set in the local workspace. If you write to a MATLAB 4 format MAT file,
PutArrayAsGlobal does not load it as global, and acts the same as PutArray.

Parameters The method uses the following parameters:

Parameter Type Description


NameOfArray String The name of the array to be written
Unicode
Value Various The Python representation of the MATLAB-array. See
Interfacing MATLAB (matlablib2) on page 11 for a
detailed description of valid Python value types.

Return value –

Exception This method may raise the following exception:

Exception Description
matlablibError On any error of this method, matlablibError is returned.

Related methods PutArray on page 30

Whos

Class Matfile

Syntax [Result =] OBJ.Whos()

Purpose To list variables in the MAT file in long form.

Description This method lists all the variables in the MAT file, together with information
about their size, bytes, class, etc., and returns this information as a string. The

31
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)

method’s behavior is very similar to MATLAB’s command whos, except for the
summary line. Unfortunately, due to lacks of the MATLAB MAT file API, the size
of struct arrays can only be determinated as a rough approximation of the real
value.

Note

For variables of any class except struct arrays, only the header information is
loaded into the memory; struct arrays are loaded completely, and therefore
memory consumption may be vast depending on the size of the struct
arrays contained in the file.

Parameters –

Return value The method returns a value of the following type:

Type Description
String A string containing all variable names, dimensions, size and class
information

Exception This method may raise the following exception:

Exception Description
matlablibError On any error of this method, matlablibError is returned.

32
Test Automation Python Modules Reference May 2024
Matlab

Matlab
Where to go from here Information in this section

Matlab Class Description......................................................................... 33

Close....................................................................................................... 35

ConnectedMATLABInstallations............................................................... 36

ExecutablePath........................................................................................ 37

Execute................................................................................................... 37

GetArray................................................................................................. 38

GetOutputs............................................................................................. 39

IsAlive...................................................................................................... 40

IsMUMatlabOpen.................................................................................... 41

Open....................................................................................................... 41

ProcessArchitecture................................................................................. 43

ProcessID................................................................................................. 43

PutArray.................................................................................................. 44

Version.................................................................................................... 45

WatchdogMethod................................................................................... 45

Matlab Class Description

Module matlablib2

Syntax OBJ = matlablib2.Matlab()

Example import matlablib2


MyMatlab = matlablib2.Matlab()

Purpose To create an instance of the class Matlab.

33
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)

Description An instance of the class Matlab can be used to transport MATLAB arrays from
MATLAB to Python and vice versa, and to execute MATLAB commands. Outputs
of the MATLAB workspace can be read by Python applications. The MATLAB
Command Window can be minimized and restored.

Parameters –

Return value The following object is returned:

Return Value Type Description


OBJ Matlab The created Matlab object

Exception The following exception may be raised:

Exception Description
matlablibError On any error of this method, matlablibError is returned.

Attributes The following attributes are part of the class:

Attribute Type Description


ExecutablePath String To get the path to the executable of the connected MATLAB instance.
See ExecutablePath on page 37.
ConnectedMATLABInstallations List of To get a list of the connected MATLAB installations containing the
tuples installation paths and whether they are configured as the preferred
MATLAB instance.
See ConnectedMATLABInstallations on page 36.
IsMUMatlabOpen Tuple (Int, To get the flag of whether the connected MATLAB instance is enabled
String, for multiple use.
String) See IsMUMatlabOpen on page 41.
ProcessArchitecture Int To get the process architecture (32‑bit or 64‑bit) of the connected
MATLAB instance.
See ProcessArchitecture on page 43.
ProcessID Int To get the process identifier of the connected MATLAB instance.
See ProcessID on page 43.
Version String To get the version of the connected MATLAB instance.
See Version on page 45.
(Visible) – Discontinued as of dSPACE Release 2021‑A.
WatchdogMethod Int To get or set the method for observing the MATLAB process.
See WatchdogMethod on page 45.

34
Test Automation Python Modules Reference May 2024
Matlab

Methods The class Matlab provides the following methods:

Method Purpose
Close To end the connection to MATLAB and quit the MATLAB application.
See Close on page 35.
Execute To execute a MATLAB command.
See Execute on page 37.
GetArray To get a Python representation of a MATLAB array from a MATLAB workspace
variable.
See GetArray on page 38.
GetOutputs To return the output of the last OBJ.Execute() command that ordinarily appears in
the MATLAB Command Window.
See GetOutputs on page 39.
IsAlive To test if MATLAB is alive.
See IsAlive on page 40.
(RestoreCommandWindow) Discontinued as of dSPACE Release 2021‑A.
(MaximizeCommandWindow) Discontinued as of dSPACE Release 2021‑A.
(MinimizeCommandWindow) Discontinued as of dSPACE Release 2021‑A.
Open To open the connection to MATLAB.
See Open on page 41.
PutArray To assign an array or string to a MATLAB workspace variable.
See PutArray on page 44.

Close

Class Matlab

Syntax OBJ.Close([DisconnectOnly = False])

Purpose To end the connection to MATLAB and quit the MATLAB application.

Parameters The method provides the following parameter.

Parameter Type Description


DisconnectOnly Boolean § True: The MATLAB instance remains open.
§ False: The MATLAB instance closes if this client
started the MATLAB instance and the MATLAB
instance is not connected to another client.
The default for this parameter is False.

35
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)

Return value –

Exception This method may raise the following exception:

Exception Description
matlablibError The underlying COM call fails or if MATLAB is not accessible.

Related methods IsAlive on page 40,

Open on page 41

ConnectedMATLABInstallations

Class Matlab

Syntax [GetValue =] OBJ.ConnectedMATLABInstallations

Purpose To get a list of the connected MATLAB installations containing the installation
paths and whether they are configured as the preferred MATLAB instance.

Parameter The attribute returns a value of the following type:

Type Description
List of Each tuple consists of two values:
tuples § String: Installation path of the connected MATLAB instance, e.g.,
C:\Program Files\MATLAB\R2016a
§ Int: Shows whether the MATLAB installation is configured as the
preferred MATLAB instance during installation or afterwards by
using the dSPACE Installation Manager.
§ 0: MATLAB installation is not preferred.
§ 1: MATLAB installation is preferred.

Exception This attribute may raise the following exception:

Exception Description
matlablibError The underlying COM call fails or MATLAB is not accessible.

36
Test Automation Python Modules Reference May 2024
Matlab

Related attributes Version on page 45

ExecutablePath

Class Matlab

Syntax [GetValue =] OBJ.ExecutablePath

Purpose To get the path to the executable of the connected MATLAB instance.

Parameters The attribute returns a value of the following type:

Type Description
String Path to the executable of the connected MATLAB instance: e.g.,
C:\Program Files\MATLAB\R2016a\bin\MATLAB.exe.

Exception This attribute may raise the following exception:

Exception Description
matlablibError The underlying COM call fails or MATLAB is not accessible.

Related attributes IsMUMatlabOpen on page 41

Version on page 45

Execute

Class Matlab

Syntax OBJ.Execute(Command)

Purpose To execute a MATLAB command.

37
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)

Description Execute the MATLAB command specified by Command.

Parameter The method uses the following parameter:

Parameter Type Description


Command String The MATLAB command to be executed.
Unicode

Return value –

Exception This method may raise the following exception:

Exception Description
matlablibError § The underlying COM call fails.
§ MATLAB is not accessible.
§ The MATLAB command fails for some reason. In that case
the exception contains MATLAB’s error message as string.

Related methods GetOutputs on page 39

GetArray

Class Matlab

Syntax [Result =] OBJ.GetArray(ArrayName)

Purpose To get a Python representation of a MATLAB array from a MATLAB workspace


variable.

Description Gets a Python representation of a MATLAB array from a MATLAB workspace


variable. See Interfacing MATLAB (matlablib2) on page 11 for a list of supported
MATLAB array classes and their Python representation. The name of the variable
is given by ArrayName.

38
Test Automation Python Modules Reference May 2024
Matlab

Parameter The method uses the following parameter:

Parameter Type Description


ArrayName String Name of the MATLAB workspace variable
Unicode

Return value The method returns a value of the following type:

Type Description
Various A Python representation of a MATLAB array on success. See
Interfacing MATLAB (matlablib2) on page 11 for a detailed list
of supported MATLAB array classes and their conversion to an
appropriate Python representation.
None on error.

Exception This method may raise the following exception:

Exception Description
matlablibError § The underlying COM call fails.
§ MATLAB is not accessible.

Related methods PutArray on page 44

GetOutputs

Class Matlab

Syntax [Result = ] OBJ.GetOutputs()

Purpose To return the output of the last Execute command that ordinarily appears in the
MATLAB Command Window.

Parameters –

39
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)

Return value The method returns a value of the following type:

Type Description
String Output of the last Execute command

Exception This method may raise the following exception:

Exception Description
matlablibError § The underlying COM call fails
§ MATLAB is not accessible.

Related methods Execute on page 37

IsAlive

Class Matlab

Syntax [Result =] OBJ.IsAlive()

Purpose To test if MATLAB is alive.

Description IsAlive() sends an "alive" message to MATLAB and tests if access to MATLAB still
is possible.

Parameters –

Return value The method returns a value of the following type:

Type Description
Boolean A value different from 0 on success ("alive"), 0 on error ("dead").

Exception –

Related methods Close on page 35,

Open on page 41

40
Test Automation Python Modules Reference May 2024
Matlab

IsMUMatlabOpen

Class Matlab

Syntax [GetValue =] OBJ.IsMUMatlabOpen

Purpose To get the flag of whether the connected MATLAB instance is opened for
multiple use.

Parameter The attribute returns a value of the following type:

Type Description
Tuple § Int: If set to 1, the connected MATLAB instance is enabled for
(Int, multiple use.
String, § String: Path to the executable of the connected MATLAB instance:
String) e.g., C:\Program Files\MATLAB\R2016a\bin\MATLAB.exe.
§ String: Version of the connected MATLAB instance: e.g., R2016a.

Exception This attribute may raise the following exception:

Exception Description
matlablibError The underlying COM call fails or MATLAB is not accessible.

Related attributes ExecutablePath on page 37

Version on page 45

Open

Class Matlab

Syntax OBJ.Open([ConvertToDouble = 0], [StartNewMLInst = 0],


[OpenFlags = 0], [StartCommands = ""],
[MLStartupDir = ""], [MLInstallDir = ""])

Purpose To open the connection to MATLAB.

41
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)

Description MATLAB starts if it is still not running.

Parameter The method uses the following parameters:

Parameter Type Description


ConvertToDouble Boolean If this optional parameter is set to 1:
§ All subsequent calls to PutArray convert Python integer types like int and long to the
MATLAB type double.
§ All subsequent calls to GetArray convert MATLAB integer types to Python float.
The default for this parameter is 0 (false).
StartNewMLInst Int § 0: Connect to existing MATLAB instance
§ 1: Start new MATLAB instance
The default for this parameter is 0.
OpenFlags Int § matlablib2.Constants.ML_OPEN_FLAG_NOSPLASH:
no splashscreen is displayed
§ matlablib2.Constants.ML_OPEN_FLAG_NOJVM:
disable java virtual machine
§ matlablib2.Constants.ML_OPEN_FLAG_NODESKTOP:
start MATLAB without desktop, MATLAB Command Window only
The default for this parameter is 0 (no flag).
StartCommands String Command(s) to execute after starting MATLAB.
The default for this parameter is an empty string.
MLStartupDir String Lets you specify the MATLAB startup directory.
The default for this parameter is an empty string.
MLInstallDir String Lets you specify the MATLAB installation directory to start MATLAB from this directory.
The default for this parameter is an empty string.

Return value –

Exception This method may raise the following exception:

Exception Description
matlablibError The underlying COM call fails or MATLAB is not accessible.

Related methods Close on page 35,

IsAlive on page 40

42
Test Automation Python Modules Reference May 2024
Matlab

ProcessArchitecture

Class Matlab

Syntax [GetValue =] OBJ.ProcessArchitecture

Purpose To get the process architecture of the connected MATLAB instance.

Parameters The attribute returns a value of the following type:

Type Description
Int § Constants.PROC_ARCHITECTURE_32BIT:
32-bit MATLAB instance
§ Constants.PROC_ARCHITECTURE_64BIT:
64-bit MATLAB instance

Exception This attribute may raise the following exception:

Exception Description
matlablibError The underlying COM call fails or MATLAB is not accessible.

Related attributes ProcessID on page 43

ProcessID

Class Matlab

Syntax [GetValue =] OBJ.ProcessID

Purpose To get the process identifier of the connected MATLAB instance.

Parameters The attribute returns a value of the following type:

Type Description
Int Process ID of the connected MATLAB instance.

43
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)

Exception This attribute may raise the following exception:

Exception Description
matlablibError The underlying COM call fails or MATLAB is not accessible.

Related attributes ProcessArchitecture on page 43

PutArray

Class Matlab

Syntax OBJ.PutArray(ArrayName, Value)

Purpose To assign an array or string to a MATLAB workspace variable.

Description PutArray assigns an Array to a MATLAB workspace variable. The name of the
variable is given by ArrayName. The second parameter specifies the Array (or
Matrix) to be assigned to the variable. In Python, lists are used to represent a
MATLAB array. See Interfacing MATLAB (matlablib2) on page 11 for the tables of
type conversion rules.

Parameters The method uses the following parameters:

Parameter Type Description


ArrayName String Name of the MATLAB workspace variable to that the value should
Unicode be assigned to.
Value Int, Float, List, String, Unicode, Value to be assigned to the MATLAB workspace variable with name
Dictionary, or CellArray "ArrayName".

Return value –

Exception This method may raise the following exception:

Exception Description
matlablibError The underlying COM call fails or MATLAB is not accessible.

44
Test Automation Python Modules Reference May 2024
Matlab

Related methods GetArray on page 38

Version

Class Matlab

Syntax [GetValue =] OBJ.Version

Purpose To get the version of the connected MATLAB instance.

Parameters The attribute returns a value of the following type:

Type Description
String Version of the connected MATLAB instance: e.g., R2016a.

Exception This attribute may raise the following exception:

Exception Description
matlablibError The underlying COM call fails or MATLAB is not accessible.

Related attributes ExecutablePath on page 37

IsMUMatlabOpen on page 41

WatchdogMethod

Class Matlab

Syntax OBJ.WatchdogMethod [= SetValue]

or
[GetValue =] OBJ.WatchdogMethod

Purpose To set or get whether MATLAB restarts if the watchdog timer is exceeded.

45
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)

Parameters The attribute uses a value of the following type:

Type Description
Integer § Constants.WATCHDOG_PREVENT: MATLAB is prevented from being
closed.
§ Constants.WATCHDOG_RESTART: MATLAB will be restarted if
necessary.

Exception This attribute may raise the following exception:

Exception Description
matlablibError The underlying COM call fails or MATLAB is not accessible.

Related attributes –

46
Test Automation Python Modules Reference May 2024
Examples (matlablib2)

Examples (matlablib2)

Examples of Using matlablib2

Overview of the demo scripts If you have installed dSPACE Python Extensions,
you will find the following example scripts in:
<dSPACEPythonExtensions_InstallationFolder>\Demos\Python Test
Automation\Interfacing Matlab (matlablib2):
§ ExecutingCommands\d_ExecuteMatlabCommands.py
This script creates arrays in MATLAB whose contents are plotted using the
MATLAB plot command. Also, the observation of MATLAB results from Python
is demonstrated.
§ ExchangeOfSimpleDatatypes\d_SimpleDataTypes.py
This script generates arrays of different types and sizes, puts them to
MATLAB's workspace and reads them out again. It concentrates on the more
simple datatypes in MATLAB. Use the whos command in MATLAB to observe
the results.
§ ExchangeOfComplexDatatypes\d_ComplexDataTypes.py
This script generates arrays of different types and sizes, puts them to
MATLAB's workspace and reads them out again. It concentrates on the more
complex datatypes CellArray and StructArray.
§ ReadingAndWritingMatfiles\d_ReadAndWriteMatFiles.py
This script demonstrates how to read data from and write data to MAT files. It
creates a MAT file which is then read again to copy the contents into another
MAT file. Finally, two identical MAT files exist.

To start the demo scripts, use an external Python interpreter, for example,
PythonWin. You find it in Python 3.9 - PythonWin in the Windows Start menu.

Before you start a script, read its description for further information.

Tip

You can run the demo script also in AutomationDesk by using an ExecFile
block.

Related topics References

ExecFile (AutomationDesk Basic Practices )


Interfacing MATLAB (matlablib2).............................................................................................. 11

47
May 2024 Test Automation Python Modules Reference
Interfacing MATLAB (matlablib2)

48
Test Automation Python Modules Reference May 2024
Multiple Use of Identifiers Within the Test Automation Python Modules

Multiple Use of Identifiers Within the Test


Automation Python Modules

Multiply used identifiers In the Test Automation Python Modules, some method and class identifiers
are multiply used. This does not mean that the identifiers are ambiguous. The
identifiers are unique, because each object must be fully qualified.

The table below gives an overview of the identifiers that are multiply used in the
Test Automation Python Modules.

The following topics are intended to facilitate access to the related


documentation in dSPACE Help. For each multiply used identifier there is an
overview of the different contexts and quick access to the specific help topics.

Identifier Type Concerned dSPACE Python Module


Close on page 50 Method matlablib2
Open on page 50 Method matlablib2

Where to go from here Information in this section

Close....................................................................................................... 50

GetArray................................................................................................. 50

Open....................................................................................................... 50

PutArray.................................................................................................. 51

49
May 2024 Test Automation Python Modules Reference
Multiple Use of Identifiers Within the Test Automation Python Modules

Close

Context of the identifier The identifier is used in the following contexts:

Module Context Detailed Information


Interfacing MATLAB (matlablib2)
matlablib2 Matfile class See Close on page 24.
matlablib2 Matlab class See Close on page 35.

GetArray

Context of the identifier The identifier is used in the following contexts:

Module Context Detailed Information


Interfacing MATLAB (matlablib2)
matlablib2 Matfile class See GetArray on page 26.
matlablib2 Matlab class See GetArray on page 38.

Open

Context of the identifier The identifier is used in the following contexts:

Module Context Detailed Information


Interfacing MATLAB (matlablib2)
matlablib2 Matfile class See Open on page 28.
matlablib2 Matlab class See Open on page 41.

50
Test Automation Python Modules Reference May 2024
PutArray

PutArray

Context of the identifier The identifier is used in the following contexts:

Module Context Detailed Information


Interfacing MATLAB (matlablib2)
matlablib2 Matfile class See PutArray on page 30.
matlablib2 Matlab class See PutArray on page 44.

51
May 2024 Test Automation Python Modules Reference
Multiple Use of Identifiers Within the Test Automation Python Modules

52
Test Automation Python Modules Reference May 2024
Index
Index
GetArray 26
C GetDir 27
Load 27
CellArray
Open 28
matlablib2 17
PutArray 30
CellArray class
PutArrayAsGlobal 30
GetDimensions 19
Whos 31
GetItem 19
Matlab
GetNumberOfDimensions 20
matlablib2 33
SetItem 21
Matlab class
Close
Close 35
Matfile class 24
ConnectedMATLABInstallations 36
Matlab class 35
ExecutablePath 37
Common Program Data folder 6
Execute 37
ConnectedMATLABInstallations
GetArray 38
Matlab class 36
GetOutputs 39
IsAlive 40
D IsMUMatlabOpen 41
DeleteArray ProcessArchitecture 43
Matfile class 25 ProcessID 43
Documents folder 6 PutArray 44
Version 45
WatchdogMethod 45
E
matlablib2 11
ExecutablePath example 47
Matlab class 37 Matfile 23
Execute Matlab 33
Matlab class 37

O
G
Open
GetArray Matfile class 28
Matfile class 26 Open (Matlab)
Matlab class 38 matlablib 41
GetDimensions
CellArray class 19
P
GetDir
Matfile class 27 ProcessArchitecture
GetItem Matlab class 43
CellArray class 19 ProcessID
GetNumberOfDimensions Matlab class 43
CellArray class 20 PutArray
GetOutputs Matfile class 30
Matlab class 39 Matlab class 44
PutArrayAsGlobal
Matfile class 30
I
IsAlive
S
Matlab class 40
IsMUMatlabOpen SetItem
Matlab class 41 CellArray class 21

L V
Load Version
Matfile class 27 Matlab class 45
Local Program Data folder 6
W
M WatchdogMethod
Matfile Matlab class 45
matlablib2 23 Whos
Matfile class Matfile class 31
Close 24
DeleteArray 25

53
May 2024 Test Automation Python Modules Reference
Index

54
Test Automation Python Modules Reference May 2024

You might also like