Application Modules (Store & Process)
Overview
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.
Where Application Modules Fit
Application Modules sit between data collection and visualization:
- Receive from - Process Modules and Unified Namespace
- Process with - Custom logic and business rules
- Store in - Relational databases and data warehouses
- Generate - Reports, documents, and data exports
- Send to - User interfaces and external systems
The Three Core Application Modules
Datasets Module - SQL Database Integration
Connect to and interact with relational databases:
- Multi-Database Support - SQL Server, MySQL, PostgreSQL, Oracle
- Real-Time Sync - Bidirectional data exchange
- Query Builder - Visual SQL query creation
- Stored Procedures - Execute database logic
- Connection Pooling - Optimized performance
Scripts Module - Custom Business Logic
Implement custom calculations and automation:
- Multi-Language - C#, VB.NET, Python, JavaScript
- Task Scheduling - Time and event-based execution
- Class Libraries - Reusable code components
- Expression Engine - Real-time calculations
- Debugging Tools - Breakpoints and watch windows
Reports Module - Data Exchange & Documentation
Generate and distribute information:
- Report Designer - Visual report creation
- Multiple Formats - PDF, Excel, CSV, JSON, XML
- Scheduled Generation - Automatic report creation
- Email Distribution - Automated delivery
- Template Based - Consistent formatting
Datasets Module Configuration
Database Connections
Configure connections to SQL databases:
- Navigate to Datasets → Database Connections
- Click New Connection
- Configure connection properties:
- Provider - SQL Server, MySQL, PostgreSQL, etc.
- Server - Database server address
- Database - Database name
- Authentication - Windows or SQL authentication
- Connection Pool - Min/max connections
Connection String Examples
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=***;
Tables Configuration
Map database tables to solution:
- Select connection → Browse Tables
- Select tables to include
- Configure table properties:
- Primary Key - Unique identifier
- Auto Refresh - Update interval
- Triggers - Insert/Update/Delete events
- Mapping - Column to tag mapping
Query Configuration
Create custom queries:
- Go to Datasets → Queries
- Click New Query
- Build query using:
- Visual Builder - Drag-drop interface
- SQL Editor - Direct SQL writing
- Parameters - Runtime variables
- Test Execute - Preview results
Query Examples
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
Stored Procedures
Execute database stored procedures:
- Select connection → Stored Procedures
- Browse available procedures
- Map parameters to tags:
- Input Parameters - From tag values
- Output Parameters - To tag values
- Return Values - Execution status
- Result Sets - Table data
Real-Time Synchronization
Bidirectional data sync:
- Tag to Database - Write tag changes to database
- Database to Tag - Update tags from database
- Conflict Resolution - Latest wins or priority
- Transaction Support - Atomic operations
- Error Handling - Retry and logging
Scripts Module Configuration
Script Tasks
Create scheduled or triggered scripts:
- Navigate to Scripts → Tasks
- Click New Task
- Configure task properties:
- Name - Task identifier
- Trigger - Schedule or event
- Language - C#, VB.NET, Python
- Code - Script implementation
Task Triggers
- Periodic - Fixed interval (seconds to months)
- Calendar - Specific times/dates
- Tag Change - When tag value changes
- Alarm - On alarm activation
- Startup - When runtime starts
- Condition - Expression evaluation
Script Examples
C# Production Calculation
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 Data Analysis
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
VB.NET Email Notification
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
Script Classes
Create reusable code libraries:
- Go to Scripts → Classes
- Create class with methods
- Reference from tasks or displays
- Share across solution
Class Example
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;
}
}
Expressions
Inline calculations for tags and displays:
- Math - Basic and advanced functions
- String - Text manipulation
- Date/Time - Time calculations
- Logical - Boolean operations
- Aggregate - Min, max, average
Expression Examples
// 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())
Reports Module Configuration
Report Designer
Create visual report templates:
- Navigate to Reports → Designer
- Click New Report
- Design report layout:
- Header - Title, logo, date
- Body - Tables, charts, text
- Footer - Page numbers, timestamps
Report Components
- Text - Static and dynamic text
- Tables - Data grids with formatting
- Charts - Bar, line, pie, gauge
- Images - Logos and diagrams
- Barcodes - QR codes, Code 128
- Subreports - Nested reports
Data Sources
Connect reports to data:
- Tags - Real-time values
- Datasets - Database queries
- Historian - Time-series data
- Scripts - Calculated values
- Parameters - User inputs
Report Generation
Manual Generation
- Operator initiated from displays
- On-demand with parameters
- Preview before printing
- Export to multiple formats
Scheduled Generation
- Go to Reports → Schedules
- Create schedule:
- Frequency - Daily, weekly, monthly
- Time - Specific execution time
- Format - PDF, Excel, CSV
- Distribution - Email, file share
Report Examples
Shift Report Template
=================================
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}}
=================================
Data Export Configuration
json
{
"export": {
"format": "JSON",
"schedule": "0 6 * * *",
"destination": "ftp://server/data/",
"content": {
"timestamp": "@Tag.System.Time",
"production": "@Tag.Production.*",
"quality": "@Dataset.Query.QualityMetrics"
}
}
}
Integration Patterns
Pattern 1: MES Integration
Manufacturing Execution System integration:
ERP Order → Dataset → Tags → Production Logic → Dataset → ERP Feedback
↓ ↓
Work Orders Production Data
Pattern 2: Batch Processing
Recipe management and execution:
- Load recipe from database
- Execute batch logic in scripts
- Log batch data to historian
- Generate batch report
Pattern 3: KPI Calculation
Real-time performance metrics:
- Collect raw data from devices
- Calculate KPIs in scripts
- Store results in database
- Display on dashboards
Pattern 4: Regulatory Compliance
21 CFR Part 11 compliance:
- Audit trail in database
- Electronic signatures via scripts
- Automated report generation
- Secure data storage
Runtime Behavior
Dataset Runtime
- Connection Pooling - Reuse connections
- Query Caching - Cache frequent queries
- Transaction Management - ACID compliance
- Error Recovery - Automatic retry
- Performance Monitoring - Query statistics
Script Runtime
- Task Scheduler - Manages execution
- Thread Pool - Parallel execution
- Memory Management - Garbage collection
- Error Handling - Exception logging
- Debug Support - Remote debugging
Report Runtime
- Generation Engine - Creates documents
- Distribution Service - Sends reports
- Template Cache - Faster generation
- Queue Management - Reliable delivery
- Archive Service - Historical reports
Performance Optimization
Database Performance
- Use connection pooling appropriately
- Optimize SQL queries with indexes
- Implement query result caching
- Use stored procedures for complex logic
- Monitor query execution time
Script Performance
- Minimize tag reads/writes in loops
- Use compiled scripts over expressions
- Implement error handling properly
- Avoid blocking operations
- Profile script execution time
Report Performance
- Cache static report elements
- Optimize data queries
- Use pagination for large reports
- Schedule during off-peak hours
- Archive old reports regularly
Best Practices
Database Integration
- Use parameterized queries to prevent SQL injection
- Implement connection retry logic
- Regular database maintenance
- Document all database schemas
- Test queries in development first
Script Development
- Follow coding standards consistently
- Comment complex logic thoroughly
- Use version control for scripts
- Implement comprehensive error handling
- Create unit tests for critical logic
Report Management
- Standardize report templates
- Version control report definitions
- Test distribution before production
- Monitor delivery success
- Regular review of report usage
Troubleshooting
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 |
Related Topics
- Unified Namespace - Tag configuration
- Process Modules - Data sources
- User Interface - Data visualization
- Scripting Reference - API documentation
AI Assistant Data
<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>