Process Analysis Toolkit  (PAT) 3.5 Help  
2.5 Using C# (C/C++/Java) Code as Libraries

Sometimes, it is difficult and inefficient to write some functions (e.g., Maths calculation methods) or advanced data structures (e.g. Array, Stack, Queue and so on) using PAT's syntax. To make this easier, PAT allows user to define static functions and user defined data type in C# (C/C++/Java)language and use them in the models. These C# classes are built as DLL and loaded when models import them. Once they are defined, you can use them directly in any models.

Note: the method names are case sensitive.

PAT provides the management interface for C# libraries. Click Tool->C# Library Editor and Compiler button in the toolbar menu, the following window will pop-up. You can define your own functions. After input the functions, you can build the code and use it immediately. You can write C# codes and compile them easily in this window.

The functions of the buttons are explained as follows:

  • New Library: load the template for creating static library.
  • New Data Type: load the template for creating user defined data type.
  • Open C# Code: load an existing C# code into the editor.
  • Save: save the text in the editor into C# code.
  • Release/Debug/Contracts: the compilation choice for the code. Debug option is desired when using the System.Diagnostics.Debug.Assert method in C#. Contracts are desired when using Microsoft Code Contracts in the C#.
  • Build DLL: build the code in the editor into a DLL, the default location of the DLL will be the Lib folder under installation folder. Error messages will be shown if there is any error during the compilation.
  • Close: close the editor.

C# Library Editor and Compiler

PAT also provides another way to open the imported library. You can select the imported library path and then right click the button, choose "open import/include file" function to open it. This funcation can recognize absolute path, relative path to the current model file and  inside lib folder of pat installation. 


 
Copyright © 2007-2012 Semantic Engineering Pte. Ltd.