MxVDev enables you to perform transformations on Signal data as it propagates from MxVDev into the Virtual Wiring Harness (or as data comes back from the Virtual Wiring Harness). These transforms have just one input port and one output port. Inline transforms on response Signals operate on Signal data as it enters MxVDev. They do not affect data transmitted to Transforms in MxTransIt.
You do not need MxTransIt to set up these transforms, you configure them directly from the Signal Dictionary. You can choose a Linear Transform which allows you to set just a scaling and offset, or a C# Snippet Transform which allows you to create quite powerful signal transformation algorithms. No external compiler is needed. MxVDev performs the compilation using built in capabilities of .Net.
To create a linear transform: 1.Select Project->Signal Dictionary from the main menu. 2.Select the Signal, and click Edit. 3.Select the Inline Transform tab. The linear transform allows you to specify a simple signal transformation in the form of y = mx + c, where m is a scale factor and c is an offset. Note that for Stimulus Signals x is the value from the Scenario and y is the value delivered to the SUT, and for Response Signals x is the value from the SUT and y is the value delivered to the Scenario. •Scaling: Scale factor. The default value for this field is 1. •Offset: The default value for this field is 0. In the example below, the Signal is a Response Signal because the data flow is from the SUT and towards the Scenario. The value from the SUT is x and the value received by the Scenario is y. |
You can implement your own Inline Transforms by entering snippets of C# code to perform the signal transformation. Adding or Editing CodeAdding new transform code can be accomplished by clicking the New button in the Inline Transforms tab. This opens the C# Signal Transform Wizard. Enter a Transform Name. This name appears in the drop-down on the first transform page after the code compilation is done. The Edit button is used to edit the existing transform code referred by the transform name in the drop-down menu. The transform source code files (.cs) are stored in the Transforms/CSharpSnippetTransform subfolder in the project folder. Define PortsGive names to the In Port and Out Port signals (Default names are x and y respectively). Be sure to select the proper signal type. This window is also displayed when the 'Edit...' button on the Transforms page is pressed. Define TransformWhen writing the Transform code make sure to: •Write the code in the User Code window. •To use a Constant in your code, select it from the Constructs pane and click the up arrow. •Click Compile to compile the code. Compilation errors, if there are any, will be displayed in the Notifications box. •Click OK to complete the process. •Click the buttons Compile, followed by OK even if the code you are Editing is not changed. Testing Your TransformAfter completing the compilation process, the transform name appears in the drop-down menu and the corresponding code appears in the User Code window. This code can be tested by entering a value in the Input Value window and clicking the '-->Test Transform-->' button. Example of a TransformA simple example of code for a Quadratic Equation "y = ax2 + bx + c" is given below. y being the OutPort signal and x being the InPort signal. int a = 1; int b = 2; int c = 4;
y = a * x * x + b * x + c; Two other examples: y = Math.Sin(t.Time_ns);
if (x == 1){y = 5;} else {y = 4;}; The TurnDoor Sample has a good example of a powerful C# Inline Transform. The LCD Bitmap Buffer Signal has an Inline Transform called VFDtoBitmap that takes the data stream of a vertically rastered image and converts it to a Windows bitmap, so that it can be displayed to the user. |