Application Modules provide the business logic and data processing capabilities that transform raw industrial data into actionable information. These modules handle database integration, custom scripting, and report generation - enabling you to implement complex calculations, integrate with enterprise systems, and generate documentation. Together, they form the intelligence layer that processes collected data according to your business rules and requirements.
Application Modules sit between data collection and visualization:
Connect to and interact with relational databases:
Implement custom calculations and automation:
Generate and distribute information:
Configure connections to SQL databases:
sql
-- SQL Server
Server=192.168.1.100;Database=Production;User Id=sa;Password=***;
-- MySQL
Server=localhost;Database=scada;Uid=root;Pwd=***;
-- PostgreSQL
Host=localhost;Database=historian;Username=postgres;Password=***;
-- Oracle
Data Source=ORCL;User Id=system;Password=***;
Map database tables to solution:
Create custom queries:
sql
-- Production Summary
SELECT
ProductCode,
SUM(Quantity) as TotalProduced,
AVG(CycleTime) as AvgCycle,
COUNT(*) as BatchCount
FROM Production
WHERE Timestamp >= @StartDate
AND Timestamp <= @EndDate
GROUP BY ProductCode
-- Real-time Inventory
SELECT
Location,
Material,
Quantity,
LastUpdated
FROM Inventory
WHERE Quantity < ReorderPoint
ORDER BY Location
Execute database stored procedures:
Bidirectional data sync:
Create scheduled or triggered scripts:
csharp
public void CalculateOEE()
{
// Read production counts
double goodCount = @Tag.Production.GoodCount;
double totalCount = @Tag.Production.TotalCount;
double plannedTime = @Tag.Production.PlannedTime;
double runTime = @Tag.Production.RunTime;
// Calculate OEE components
double availability = runTime / plannedTime;
double performance = totalCount / @Tag.Production.IdealCount;
double quality = goodCount / totalCount;
// Calculate overall OEE
@Tag.KPI.OEE = availability * performance * quality * 100;
// Log to database
@Dataset.Query.LogOEE.Execute();
}
python
import statistics
def analyze_batch():
# Get batch data
temperatures = @Tag.Batch.TemperatureArray
pressures = @Tag.Batch.PressureArray
# Calculate statistics
@Tag.Batch.AvgTemp = statistics.mean(temperatures)
@Tag.Batch.StdDevTemp = statistics.stdev(temperatures)
@Tag.Batch.MaxPressure = max(pressures)
# Check quality limits
if @Tag.Batch.StdDevTemp > 2.0:
@Tag.Batch.QualityFlag = "Warning"
@Alarm.Batch.QualityWarning = True
vbnet
Public Sub SendProductionReport()
Dim shift As String = @Tag.Production.CurrentShift
Dim production As Integer = @Tag.Production.ShiftTotal
Dim efficiency As Double = @Tag.KPI.Efficiency
Dim body As String = String.Format(
"Shift: {0}" & vbCrLf &
"Production: {1} units" & vbCrLf &
"Efficiency: {2:F1}%",
shift, production, efficiency)
@Report.EmailReport("Production Summary", body, "supervisor@company.com")
End Sub
Create reusable code libraries:
csharp
public class Calculations
{
public static double CelsiusToFahrenheit(double celsius)
{
return (celsius * 9/5) + 32;
}
public static double FlowTotalization(double flow, double timeSeconds)
{
return flow * timeSeconds / 3600; // Convert to hours
}
public static bool InRange(double value, double min, double max)
{
return value >= min && value <= max;
}
}
Inline calculations for tags and displays:
// Calculate tank volume
@Tag.Tank.Volume = @Tag.Tank.Level * 3.14159 * pow(@Tag.Tank.Radius, 2)
// Format production message
concat("Line ", @Tag.Line.Number, ": ", @Tag.Line.Status)
// Check multiple conditions
@Tag.System.Ready = @Tag.Motor1.Running && @Tag.Valve1.Open && !@Tag.Alarm.Active
// Time-based calculation
@Tag.Batch.Duration = DateDiff("s", @Tag.Batch.StartTime, now())
Create visual report templates:
Connect reports to data:
=================================
PRODUCTION SHIFT REPORT
{{Date}} - {{Shift}}
=================================
Production Summary:
- Total Units: {{Tag.Production.Total}}
- Good Units: {{Tag.Production.Good}}
- Reject Units: {{Tag.Production.Reject}}
- Efficiency: {{Tag.KPI.Efficiency}}%
Downtime Events:
{{Dataset.Query.DowntimeList}}
Top 5 Alarms:
{{Dataset.Query.AlarmSummary}}
Operator: {{Tag.System.CurrentUser}}
=================================
json
{
"export": {
"format": "JSON",
"schedule": "0 6 * * *",
"destination": "ftp://server/data/",
"content": {
"timestamp": "@Tag.System.Time",
"production": "@Tag.Production.*",
"quality": "@Dataset.Query.QualityMetrics"
}
}
}
Manufacturing Execution System integration:
ERP Order → Dataset → Tags → Production Logic → Dataset → ERP Feedback
↓ ↓
Work Orders Production Data
Recipe management and execution:
Real-time performance metrics:
21 CFR Part 11 compliance:
Symptom | Likely Cause | Solution |
---|---|---|
Database connection fails | Wrong credentials or server | Verify connection string and network |
Query returns no data | Incorrect SQL or empty table | Test query in database directly |
Script not executing | Trigger not firing | Check trigger configuration and logs |
Script errors | Syntax or runtime error | Review error logs and debug |
Report not generating | Missing data or template error | Check data sources and preview report |
Email not sending | SMTP configuration | Verify email server settings |
Slow query performance | Missing indexes | Analyze query plan and add indexes |
Memory growth in scripts | Objects not disposed | Implement proper disposal patterns |
<details> <summary>Structured Information for AI Tools</summary>
json
{
"module": "Application Modules",
"pillar": "Store & Process",
"purpose": "Business logic implementation and data processing",
"modules": {
"datasets": {
"purpose": "SQL database integration",
"components": ["Connections", "Tables", "Queries", "Stored Procedures"],
"databases": ["SQL Server", "MySQL", "PostgreSQL", "Oracle"],
"features": ["Real-time sync", "Connection pooling", "Transactions"]
},
"scripts": {
"purpose": "Custom business logic",
"components": ["Tasks", "Classes", "Expressions"],
"languages": ["C#", "VB.NET", "Python", "JavaScript"],
"triggers": ["Periodic", "Event", "Condition", "Startup"]
},
"reports": {
"purpose": "Document generation and data export",
"components": ["Designer", "Templates", "Schedules"],
"formats": ["PDF", "Excel", "CSV", "JSON", "XML"],
"distribution": ["Email", "File", "FTP", "Web Service"]
}
},
"commonTasks": [
"Configure database connections",
"Create SQL queries",
"Write calculation scripts",
"Schedule tasks",
"Design reports",
"Setup data export"
],
"integrationPatterns": [
"MES/ERP integration",
"Batch processing",
"KPI calculations",
"Regulatory compliance"
],
"performanceFactors": [
"Query optimization",
"Connection pooling",
"Script efficiency",
"Memory management",
"Report caching"
]
}
</details>