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.
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
- ASAM.XIL.Interfaces.dll
- ASAM.XIL.Implementation.TestbenchFactory.dll
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:
No comments:
Post a Comment