Organize reusable classes for scripts.
Reference → Modules → Scripts → UI → Code Editor | Classes | Expressions | Monitor | References | Tasks
ScriptsClasses (Reference) provide a repository of reusable code libraries, methods, and functions accessible throughout your FrameworX solution. The platform automatically manages these classes as static objects with built-in exception handling.
ScriptClasses enable code reuse across:
The platform provides automatic:
Click the plus icon to create a new class. Three options are available:
| Property | Description |
|---|---|
| Name | Class identifier used in code references |
| Code | Programming language (C#, Python, VB.NET) |
| Domain | Execution location: Server (global) or Client (local) |
| ClassContent | Type: Methods or Namespace |
| Edit Security | Permission level required to modify |
| Build Order | Compilation sequence when multiple classes exist |
| Build Status | Green check (success) or Red X (errors) |
| Build Errors | Compilation error details |
| Description | Documentation for the class purpose |
CRITICAL: Do not include class declarations or namespace definitions in ScriptClasses
When creating a ScriptClass with Methods or MCP Tool:
public class MyClass { }namespace MyNamespace { }using statements directly in codeusing statementsThe platform automatically wraps your code in the appropriate class structure using the Name from the configuration table.
csharp
// Methods directly - NO class wrapper, NO using statements
public string ProcessData(double value)
{
return $"Processed: {value:F2}";
}
public int Calculate(int a, int b)
{
return a + b;
}To add using statements (C#) or Import statements (VB.NET):
using statements directly in the codeMost common type for reusable code:
@Script.Class.ClassName.MethodName()Example:
csharp
// In ScriptClass named "Calculations"
public double CalculateEfficiency(double actual, double target)
{
if (target == 0) return 0;
return (actual / target) * 100;
}
// Usage anywhere in solution:
// double eff = @Script.Class.Calculations.CalculateEfficiency(95, 100);Special class type for AI integration:
Example:
csharp
[MCPMethod(Description = "Get tank level")]
public double GetTankLevel(
[MCPParameter(Description = "Tank ID")] string tankId)
{
return @Tag[$"Tank_{tankId}_Level"];
}Advanced Feature Warning: Full Namespace is for experienced developers only. Most applications should use standard Class with Methods. This option requires manual object instantiation and exception handling like Visual Studio development.
Complete .NET namespace implementation:
Example:
csharp
namespace MyCompany.Utilities
{
public class AdvancedProcessor
{
private int counter = 0;
public void Process()
{
// Implementation
}
}
}
// Usage requires instantiation:
// var processor = new MyCompany.Utilities.AdvancedProcessor();
// processor.Process();All solutions include:
Global methods library executed on server:
ServerMain has special integration with TServer process. Additional documentation on advanced ServerMain features will be provided in future updates.
Local methods library executed on each client:
ScriptClasses can be shared between solutions using the Library feature:
Library.dbsln repositoryThe Library serves as a centralized repository for reusable components across all your solutions.
FrameworX enables calling between languages transparently:
csharp
// C# ScriptClass calling Python method
double result = @Script.Class.PythonClass.calculate_value(10, 20);python
# Python ScriptClass calling C# method
efficiency = TK.Script.Class.CSharpClass.CalculateEfficiency(95.5, 100.0)For detailed Python/.NET integration including type conversions and limitations, see [Python.NET Integration (Reference)]
ScriptClasses can directly access all solution namespaces:
csharp
public void UpdateProduction()
{
// Access Tags
double rate = @Tag.ProductionRate;
// Access Alarms
bool hasAlarm = @Alarm.HasActive("Line1");
// Access Historian
var history = @Historian.GetValues("Temperature", 100);
// Access other Script Classes
var result = @Script.Class.OtherClass.Method();
// Access Script Tasks
@Script.Task.MyTask.Run();
}To use external .NET assemblies:
using statements in code itselfAvoid circular references between classes. While not blocked by the system, they cause:
If circular references exist, temporarily comment one reference to allow compilation.
using statements in codeRed X Build Status
Methods not accessible
@Script.Class.ClassName.MethodName()Class wrapper errors
public class declarationsusing statements from code (use Namespace Declarations button)Cannot find external types