The C# Snippet transform is a quick way of creating transforms without the need for a compile/build environment.
•Useful for transforms of as many as a few dozen lines of C# code.
•A C programmer can pick up C# without too much difficulty.
•No compiler is needed. It is built into MxSuite.
When created, The Transform has one inport and one outport, both continuous floating point. Use the Verbs (links) at the bottom of the Properties box to add or remove ports. Once the classification has been set, you can use the Edit Port command to change the other properties. Event and array Signals are not supported. For message ports, see Message Signals.
Verbs
Note: Once a port has been created, you cannot change its classification. Instead, delete the port and create a new one.
Click Edit C# to open the C# Snippet dialog box:
Click the Compile button to check your code for syntax errors. Click the View Code button to see your code in context. The Execution Code is executed whenever the Transform is ticked. The Persistent Code is part of the Class definition.
To change the name or type of a port, use the Verbs to remove the old port and add a new port with the new name and type. Do not use the Edit Port dialog or the Properties Box to rename a port. Be sure to change the corresponding variables in the C# code. Spaces are not permitted in port names.
For an example using the C# Snippet, see Getting Started with a Custom Harness.
Although they are similar, do not confuse the C# Snippet Transform, which is used in MxTransIt, with the Signal Generator or the In-Line Transform, which are used in MxVDev.
To add message ports to the Transform, click the Add InPort or Add OutPort Verb in the Properties Box to open the Add/Edit Port dialog. Select a Classification of Message and specify the other properties. You can also change the name of the port. Message transitions are byte arrays. To create an output transition, add code similar to the following to the C# snippet: Example 1: A message containing a string string myCommand = “message text”; Out2 = System.Text.Encoding.ASCII.GetBytes(myCommand); Example 2: A message of numeric bytes int n; for (n=0; n < 10; n++) { Out2[n] = (byte) n; }
|
The default setting for the Enable Periodic Ticking property is False, which means the Transform is event driven and the Tick Period value is not used. The Transform is ticked when there is a transition on any of its inports. Set Enable Periodic Ticking to True to tick (execute) the Transform at the specified Tick Period.
|
Getting Started with a C# Snippet