Monday, August 4, 2025

Accessing Automation Desk With XIL API via Python:

Quick Overview :

Replace the HIL API Python import directive with calls to clr.AddReference() (a command of the Python for .NET package), by using the required ASAM XIL API .NET assemblies.

Create a TestbenchFactory and a vendor-specific Testbench

Replace all HIL API Python constructor calls with the equivalent factory class call from the XIL API .NET.

Replace the code for HIL API MAPort creation using a configuration dictionary with code that uses the new XIL API concept for MAPort creation using a port configuration file. 


5 Migration Examples 

This section uses specific examples to show you step by step how to convert HIL API Python commands into the classes and method calls of dSPACE XIL API .NET. In each case, a short section of the HIL API Python code is compared to an equivalent section that uses XIL API .NET. 

5.1 Importing the XIL API .NET Assemblies 

For any .NET services and components, you have to import or reference the required assembly into the Python workspace

This requires the Python for .NET command clr.AddReference(). 


5.2 Using the .NET Framework  

XIL API .NET expects .NET data types. You therefore have to use them explicitly. The following example shows a .NET dictionary:


5.3 Creating dSPACE XIL API TestbenchFactory and Testbench 

XIL API .NET uses the factory pattern for creating all kinds of Testbench-specific objects. At first, you need to create a TestbenchFactory and a VendorSpecificTestbench:

 


In the next step, you have to create an instance of the MAPort class to access the values of the realtime application

The platform identifier as it appears in ControlDesk 4.x or later after successful registration

5.4 Creating and Configuring MAPorts  

In the XIL API, the configuration dictionary of the HIL API MAPort was replaced by a port configuration file


5.4.1 Example of a dSPACE XIL API MAPort Configuration File

you can access the real‑time application that is specified in the variable description file (SDF file) running on a modular system based on DS1005.

In the PlatformName key, you have to enter the platform name that you specified when you registered the platform.


  For details, refer to dSPACE XIL API Implementation Guide > Implementing an MAPort Application > Basics on the MAPort > Configuring the MAPort

5.5 Reading and Writing Values

while in HIL API a constructor was used, in XIL API a factory function of the Testbench's ValueFactory must be called instead. 



5.6 Measuring Variables

 Measure variables, the Start method of the Capture instance requires a capture result writer object to be passed as an argument

XIL API you have to replace the constructor of the capture result writer with a factory method of the capturing factory

The following example shows the creation of a CaptureResultMemoryWriter object using HIL API Python





5.7 Triggered Measurements 

Watcher objects used for triggering a measurement by using a WatcherFactory instead of constructors for the ConditionWatcher and the DurationWatcher objects. 


5.8 Creating Stimulus Signals  

To create the signals and symbols of the stimulus domain of the XIL API, use the SignalFactory and SymbolFactory classes instead of constructors. 




5.9 Generating Stimulus Signals 

All classes from the Common.SignalGenerator namespace are constructed via methods of the SignalGeneratorFactory class in the XIL API. 




6 Additional Information on Using dSPACE XIL API .NET in Python 

Typical HIL API Python script can be ported to XIL API .NET.

The following sections describe a few points in greater detail; points you must consider when using the dSPACE XIL API .NET server

6.1 Referencing the XIL API .NET assemblies 

.NET assemblies must be loaded to Python before you can use them.

This requires using the Python for .NET command clr.AddReference().

The following .NET assemblies are needed for using the dSPACE XIL API .NET server:
  •  ASAM.XIL.Interfaces.dll 
  • ASAM.XIL.Implementation.TestbenchFactory.dll 
For the above assemblies, the relevant Python code is:


Because the XIL API .NET assemblies are in the Global Assembly Cache (GAC), you do not have to specify path information. To determine the fully qualified assembly name, you can use Windows PowerShell with the following command:


6.2 Namespaces
In .NET, using namespaces is common. All classes of .NET frameworks are organized like this. The XIL API .NET is also divided into namespaces.

Example: In XIL API .NET, the TestbenchFactory class is located in the namespace ASAM.XIL.Implementation.TestbenchFactory.Testbench.

 In Python, you can create a new instance of the TestbenchFactory class as follows: 


You can use the import directive in Python so you do not have to write the complete namespace each time you create a new instance:

 
 6.3 Generic Collections from the .NET Framework
 This section shows you how to create such a dictionary, which is required for creating a XIL API ConditionWatcher.

The dictionary must have keys of the data type string; the values that are assigned to each key must also have the data type string.

For any class that belongs to the .NET Framework, the corresponding namespace needs to be referenced first before it can be used: 


6.5 Scaling Information in the Variable Description File

The variable description file defines whether a source value on a dSPACE platform

A specific parameter of some fixed point data type in the real-time application might be represented as a real world physical value in the test scenario. 

The dSPACE HIL API uses source values by default when reading, writing or capturing variables.

. For further information on scaling, refer to Software > Test Automation > dSPACE HIL API Implementations > dSPACE HIL API Python Implementation Document > Using dSPACE HIL API Python Implementation > Specific Enhancements to the HIL API Standard > Value scaling enable/disable via TRC file. 


With the dSPACE XIL API, the behavior changed to converted values. The scaling is enabled by default. This means that the value conversion is executed as specified by the scaling attribute in the variable description file

If this behavior is not desired, it can be disabled within the MAPort configuration file. For further information, refer to Software > Test Automation > dSPACE XIL API Implementations > dSPACE XIL API Reference > Model Access Port Implementation > MAPort Configuration > EnableScaling

 




Friday, June 13, 2025

Dspace_HIL - Cluster Functional Simulation

 WorkFlow - Cluster Functional Simulation

Summary:

  • Implementing Cluster Functional Simulation

  • Creation of project in configuration desk 

  • Stimulating the signal parameters in the Control desk panel

  • Visualising the outputs in cluster ECU after physical connection


ConfigurationDesk with External Device:

  • External Device Interface

    • Creation of External Device Topology

    • Configuration of external Device interface

    • Copying and adding device blocks to the signal chain

    • Grouping device pins

  • Implementing I/O Functionality

    • Adding and Configuring function block to the signal chain

    • Assigning hardware resources to the function block

    • Mapping between device blocks and function blocks

    • Provide wiring information for the external cable harness

  • Specify model Interface

    • Add model port blocks to the signal chain

    • Adding behavior model







Configuration Desk:

Creation of new project: File → New





Registration of hardware Platform:


Click on Registered hardware - (You can click register Platform or Add predefined hardware(if already registered)).



After the hardware registration, click on create - New Project will get created as below:

Signal Addition(dbc):

Under the Buses - Add the dbc signals by clicking “Add
 
 Bus Access Assignment:

Once the dbc is added - All the node names configured under the buses (see left side of the image)

Under Bus Access Request - Right Click on “Bus Access Request” → “Automatic Bus Access Assignment”.

 

Once the Bus Access Assignment is done - it will assign as follows

 
  Bus channel Assignment:  

Once the Bus Access Request is created, do the Channel Assignment by right clicking on the DBC.










Application Process creation:

Under Tasks,

  Application process needs to be created by right clicking on it,


Bus Configuration ports - Enable Access:


Enable access needs to be given under Bus Configuration ports by the as following be selecting all:




External Device Interface:   

 

  • To create the external device topology:


Creating multiple ports dialog opens 








Rest Bus Simulation:

Build - sdf generation:

Under Build, 

Click on the “Start” button to start the building process to get the sdf file. The build results will be generated in the path shown





Control desk:

Project creation:

Once the sdf file is generated from the Configuration desk, create the new project in the control desk


Defining the experiment:

Give the name of the experiment as follows:


Platform Addition:

Select the supported platform (SCALEXIO)




Importing sdf file:

Import the sdf file generated from the configuration desk as follows:



Creation of Experiment:

Once sdf is uploaded, the experiment gets created as follows:


Variable Addition:

Under the Variables section, in the sdf path - Add the signals to the layouts required. Here, a Front speed signal is added to the layout to create the panel.


Panel creation:

Drag the signal to the Layout with the required input format (slider, knob, gauge ..etc)



Simulating online:

Once the Layout is created for the required signal , Go online for the HIL simulation as below.


Dspace HIL and CANoe - [Configuration of CAN High and Low pin from VN1611 hardware to Dspace HIL DS27043]:

Finally , the CAN high and Low of DS27043 is connected with CAN High and Low of VN1611 to establish the rest bus simulation. The pin details of both the hardware is below






OUTPUT:

     Once after the connection is made properly , we can start simulating through control desk where you can see the output log in CANoe trace as follows:

Wednesday, May 28, 2025

How to use Robot framework with CURF library(CAN ISO TP,UDS,CAN RAW Data):

 How to use Robot framework with CURF library(CAN ISO TP,UDS,CAN RAW Data):


Step-1:


Download the CURF from github


Step-2:

Load the CURF(downloaded file) via VB

Step-3:


In this folder create the Virtual environment


Step-4:


Install the Following python modules in virtual environment:


  • pip install robotframework

  • pip install python-can

  • pip install cantools

  • pip install can-isotp






Step-5:


Open can.robot file and start to write test case:




Step-6:


Run the can.robot using following command:

robot -d results test/can.robot




Step-7:

Open result folder—>log,report






Final Report:


Accessing Automation Desk With XIL API via Python:

Quick Overview : Replace the HIL API Python import directive with calls to clr.AddReference() (a command of the Python for .NET package), by...