The Scripting Reference provides comprehensive documentation for developing custom logic in FrameworX 10.1. With support for multiple programming languages including C#, VB.NET, Python, and JavaScript, you can implement complex calculations, automation logic, and integrations. This guide covers syntax, APIs, best practices, and practical examples for all scripting scenarios.
...
Language | Use Cases | Performance | Learning Curve | Key Features |
---|---|---|---|---|
C# | Complex logic, performance-critical | Excellent | Moderate | Full .NET access, strongly typed |
VB.NET | Legacy systems, simple logic | Excellent | Easy | Familiar syntax, .NET access |
Python | Data analysis, ML, scripting | Good | Easy | Libraries, readable syntax |
JavaScript | Client-side, expressions ,HTML5 (*1) | Good | Easy | Web integration, JSON |
Info | ||
---|---|---|
| ||
JavaScript is available only in HTML5-only, displays. Prefer always to the Portable Pages, which allows the configuration on Desktop Rich Clients (.NET WPF) and Web/Mobile clients (WebAssembly). Keep JavaScript and HTML5 only required for code compatibility or use of external HTML5 controls. |
Decision Tree:
Need maximum performance? ??? => C#
Need higher level of runtime security & Reliably => C#
Legacy VB code? ???=> VB.NET
Data science/ML? ???=> Python
Client-side logic? ??? JavaScript
=> C# & Python server classes
Simple expressions? ??? Any language=> any language. Platform expression editor can parse different languages.
...
Tasks execute on schedules or triggers:
csharp
// C# Task Example
public class ProductionTask : TaskScript
{
public override void Execute()
{
// Read current values
double production = @Tag.Production.Counter;
DateTime shiftStart = @Tag.Shift.StartTime;
// Calculate metrics
double ratehours = CalculateRate(production,(DateTime.Now - shiftStart).TotalHours;
double rate = // Update tags
@Tag.KPI.ProductionRate = rate;
count / hours;
@Tag.KPI.LastUpdate = DateTime.Now;
// Log to database
// Update LogToDatabase(rate);tags
}
@Tag.KPI.ProductionRate = rate;
private double CalculateRate(double count, DateTime start) @Tag.KPI.LastUpdate = DateTime.Now;
{
double hours = (DateTime.Now - start).TotalHours;
// Log to database
return count / hours @Script.Class.Util.LogToDatabase(rate);
}
}
Classes provide reusable functions:
csharp
// C# Class Library
public static class : EngineeringCalcs
{
// Flow calculation
public static double CalculateFlow(double dp, double k)
{
return k * Math.Sqrt(dp);
}
// Temperature conversion
public static double CelsiusToFahrenheit(double celsius)
{
return (celsius * 9.0 / 5.0) + 32;
}
// Pressure conversion
public static double PSIToBar(double psi)
{
return psi * 0.0689476;
}
// Tank volume
public static double CylindricalTankVolume(double diameter, double level)
{
double radius = diameter / 2;
return Math.PI * radius * radius * level;
}
}
Expressions are single-line calculations:
javascript
// JavaScript Expressions
// Conditional logic
@Tag.Pump.Status = @Tag.Pump.Running ? "Running" : "Stopped"
// Mathematical calculation
@Tag.Tank.Volume = Math.PI * Math.pow(@Tag.Tank.Radius, 2) * @Tag.Tank.Level
// String manipulation
@Tag.Display.Message = "Temperature: " + @Tag.Temp.Value.toFixed(1) + "°C"
// Date/time calculation
@Tag.Batch.Duration = (Date.now() - @Tag.Batch.StartTime) / 1000 / 60
Scripts triggered by UI events:
csharp
// C# Display Script
public void OnButtonClick(object sender, EventArgs e)
{
// Validate user input
if (!ValidatePermissions())
{
ShowMessage("Access Denied");
return;
}
// Execute command
@Tag.Equipment.StartCommand = true;
// Log action
LogUserAction("Start button pressed");
// Update display
RefreshDisplay();
}
private bool ValidatePermissions()
{
return @Tag.Security.UserLevel >= 2;
}
...