The SIL Easy Transform is a template that provides an easy way to create a custom Transform using Visual Studio. With MxTransIt you can use the Transform in a Test Harness that can be very simple or complex. For an example of a SIL Easy project, examine the SILEasyCruiseControl sample provided with the MxSuite.

Some features of the SIL Easy Transform are:

It allows any number of inputs and outputs.

The functionality of the Transform can be written in C, C++, or C#.

The Transform is built from Visual Studio project. A default project is provided.

The default Transform has examples of discrete, continuous, and message Signals.

For more information, see Choosing a Transform Type.

Use this procedure to create a SIL Easy Transform:

1.Start MxVDev.

2.Select File->New->Project from the main menu.

3.When you see the following form, select Custom and click Start MxTransIt on Finish.

SelectSUT

Note: Although we are doing SIL testing, we are creating a Custom SUT.

4.Click the Finish button to launch MxTransIt.

5.In MxTransIt, select SIL Easy from the Toolbox and drag it into the harness (center) window. Notice, at this point it has no visible ports.

6.Click the transform to select it and display its properties:

SE_properties

Note: The IsSUT property defines whether your transform is ticked as a Connector Transform (True) or a Signal Processing Transform (False). You can change this property based on the purpose of your Transform.

7.Enter an appropriate name for your transform in the Name field. In the figure above we used Sil Easy Example.

8.Click the Create New Project verb (blue link) at the bottom of the Properties box.

9.Select a folder for your project. Normally this is the same folder you used when you created your MxVDev project.
 
Visual Studio opens.

10.You can examine the source code at this point:

There are four code files provided by SIL Easy:

omain.h

omain.c

oSilHarnessIntegration.hpp

oSilHarness.cpp

The ports are defined in SilHarness.cpp:

void LoadHarness()

{

  ISetGetMethods* setGetMethods = 0;

  setGetMethods;//eliminate compiler warning

 

  /* Example of Discrete Ports (booleans/integers etc) */

  /* variable, name, dataFlow, min, max, init */

  gSil.AddDiscrete(&Bool, L"Bool", DataFlowEnum::Input, 0, 1, 0);

  gSil.AddDiscrete(&Invert, L"Invert", DataFlowEnum::Output, 0, 1, 0);

 

  /* Example of Continuous Ports (floats/doubles) */

  /* variable, name, dataFlow, min, max, init, units */

  gSil.AddContinuous(&Number, L"Number", DataFlowEnum::Input, 0, 10, 0, L"unit");

  gSil.AddContinuous(&Double, L"Double", DataFlowEnum::Output, 0, 10, 0, L"unit");

 

  /* Example of Message Ports (array of bytes) */

  /* variable, name, dataFlow, max length, actual length, variable length flag */

  /* Input message can be defined as variable length, in that case actual length

     of copied data is located in 'actual length' parameter */

   

  gSil.AddMessage (bufferIn, L"Buffer In", DataFlowEnum::Input, 20, &actualLength, false);

  gSil.AddMessage(bufferOut, L"Buffer Out", DataFlowEnum::Output, 20, &len2, false);

}

 

You can modify this code to add, delete, or change ports. See Making Changes to Ports. If you are a beginner, we recommend you complete a successful build before changing the code.

In the main.c file, you can view the three default functions:

oSilInitialize() - This function is called once when the project is loaded. When a Scenario is rewound and run again, the project is unloaded and reloaded, consequently SilInitialize is called again.

oSilTick() -  SilTick is called periodically during the test according to the Tick Period property of the SIL Easy transform. See Tick Period.

oSilFinalize() -  This function is called when the project is unloaded, that is, when the Scenario is rewound or MxVDev is closed. It is NOT called when the Scenario completes execution.

/* called on start of scenario*/

void SilInitialize(void)

{

  actualLength = 0;

  Bool = 0;

  Number = 0.0;

}

 

 

 

/* called periodically */

void SilTick(void)

{

  int i=0;

 

  /* example int */

  Invert = (Bool == 0)? 1 : 0;

  /* example double */

  Double = 2.0 * Number;

  /* example message */

  for(i=0; i<20; i++)

  {

    /* reverse incoming message */

    bufferOut[i] = bufferIn[19-i];

  }

}

The sample code shows simple operations on three kinds of signals. You can write your own code to perform more extensive signal processing.

Notes:

The input RAM variables (in this example: Bool, Number, and bufferIn) are only written to when the value changes.

For output Message signals, a transition is generated on the output port at any time any bit in the output message changes.

11.Select Build ‑> Build Solution from the Visual Studio main menu.  If there are no errors, Visual Studio displays:
 
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

12.In MxTransIt, click on your Transform to select it and display the Properties form.

13.Click the Connect/Reconnect verb at the bottom of the Properties form to display the predefined ports on your transform:

SE_ports

You are now ready to customize the Test Harness. You can add, remove, or change ports by modifying the C++ code.  You can connect it to other Transforms. To define the behavior of the SIL Easy Transform, add code to the Visual Studio project. (Click the Launch Project verb to open Visual Studio. Rebuild the project after you change the code.) You can debug your code in Visual Studio by attaching to the MxVGUI executable. See Attaching to the Process.

When you are ready, use the procedure below to connect the harness to MxVDev for testing.

hmtoggle_plus1Connecting the Harness to Mx-VDev
hmtoggle_plus1Attaching to the Process
hmtoggle_plus1Reading and Transmitting from Ports
hmtoggle_plus1Accessing the Scenario Name or Path
hmtoggle_plus1Automatic Compilation
hmtoggle_plus1Troubleshooting

 

Related Topics:

User-Defined Transforms

Sample Projects—SIL

Tick Period

MxTransIt Model—Tick Order

An Example Using the C# Snippet Transform

Using SIL Easy to Test CAN Signals