Create Script Expressions, Tasks and Classes.
Tutorials → Scripts | Tutorial | How-to Guide | Reference
Field | Value |
---|---|
Object | Tag.Tank1_TempF (create as Double) |
Expression | Tag.Tank1_Temp * 1.8 + 32 |
Execution | OnChange |
Domain | Server |
Add status logic:
Field | Value |
---|---|
Object | Tag.System_Status (create as String) |
Expression | TIF(Tag.Tank1_Status = 2, "Running", "Stopped") |
Execution | OnChange |
Domain | Server |
ShiftCounter
Server.DateTimeInfo.Hour
as Trigger// Reset counter at shift change
int hour = @Server.DateTimeInfo.Hour;
if (hour == 6 || hour == 14 || hour == 22)
{
@Tag.Units_Previous = @Tag.Units_Produced;
@Tag.Units_Produced = 0;
}
TankCalculations
public double CalculateVolume(double level, double diameter)
{
double radius = diameter / 2;
return Math.PI * radius * radius * level;
}
public double CalculateFlowRate(double volumeStart, double volumeEnd, int minutes)
{
if (minutes == 0) return 0;
return (volumeEnd - volumeStart) / minutes;
}
public string GetStatusText(double value, double limit)
{
if (value > limit)
return $"High: {value:F2} (Limit: {limit:F2})";
else
return "Normal";
}
Field | Value |
---|---|
Object | Tag.Tank1_Volume |
Expression | Script.Class.TankCalculations.CalculateVolume(Tag.Tank1_Level, 10.5) |
Execution | OnChange |
Note: No @ symbol needed in expressions
→ Modules / Business Operations / Scripts Module → Tutorials / Business Operations / Scripts Module Tutorial → How-to Guides / I Business Operations / Scripts Module How-to Guide → Technical Reference / Business Operations / Scripts Module ReferenceScripts Module Links
Explanation - to understand concepts
Tutorials - to learn by doing
How-to Guides - to accomplish specific tasks
Reference - technical details