This guide walks you through configuring the Reports module to generate PDF/text reports and exchange data with external systems. You'll create report forms with real-time data, configure web data exchanges, and schedule automatic generation.
Prerequisites:
- Tags configured on UNS
- Understanding of report requirements
- External API details (if using WebData get/post)
Panel | ||||||
---|---|---|---|---|---|---|
| ||||||
|
Configuration Workflow
- Create Report Forms - Design PDF/text report layouts
- Configure WebData - Setup JSON/XML data exchange
- Add Dynamic Content - Insert tags, tables, charts
- Schedule Generation - Automate report creation
- Test and Deploy - Verify output and distribution
Step 1: Create Report Forms
Creating a New Form
- Navigate to Reports → Forms
- Click first row to add new form
- Configure properties:
Property | Description | Example |
---|---|---|
Name | Form identifier | DailyProductionReport |
SaveFormat | Output type | PDF, Text, HTML |
SaveFileName | File path | C:\Reports\Daily_{{Tag.Date}}.pdf |
SaveTrigger | When to generate | Tag.GenerateReport |
Append | Add to existing file | 0=Replace, 1=Append |
Form Editor Basics
- Go to Reports → Forms Editor
- Select form from dropdown
- Use editor like a word processor:
- Format text with toolbar
- Insert tags with
{Tag.TagName}
- Add tables and symbols
Step 2: Add Dynamic Content
Inserting Tags
Method 1: Direct Typing
Current Temperature: {Tag.Temperature} °C
Production Count: {Tag.ProductionCounter}
Operator: {Tag.OperatorName}
Method 2: Tag Browser
- Right-click toolbar Tag button
- Select tag from browser
- Tag inserted at cursor position
Adding Tables
Static Tables (Fixed rows):
- Click Table button in toolbar
- Select rows and columns
- Manually populate cells with tags
Dynamic Tables (Database queries):
Header Row: Column names for report
Data Row: {Dataset.Query.ProductionData}
Example dynamic table setup:
Report Column | Database Column |
---|---|
Product Name | ProductName |
Quantity | {Tag.Quantity} |
Quality | QualityScore |
Including Charts
- Create TrendChart in Displays
- Right-click chart → Make New Symbol
- In Forms Editor, click Symbol button
- Select your trend symbol
Step 3: Configure WebData
Setting Up Data Exchange
- Go to Reports → WebData
- Click Plus to add new WebData
- Configure:
Property | Description | Example |
---|---|---|
Name | WebData identifier | ProductionAPI |
Encoding | Data format | JSON, XML, HTML |
DefaultURL | API endpoint | https://api.example.com/data |
Authorization | Auth type | Bearer Token, Basic Auth |
WebData Editor
- Navigate to Reports → WebData Editor
- Define data structure with tag bindings:
JSON Example:
json
{
"timestamp": "{Tag.CurrentTime}",
"production": {
"line": "{Tag.ProductionLine}",
"count": {Tag.ProductionCount},
"quality": {Tag.QualityScore}
}
}
API Operations
GET Request:
csharp
// Retrieve data from API
string response = await @Report.WebData.ProductionAPI.GetRequestAsync();
@Tag.APIResponse = response;
POST Request:
csharp
// Send data to API
// Body configured in WebData Editor
await @Report.WebData.ProductionAPI.PostRequestAsync();
Step 4: Generate Reports
Manual Generation
From Scripts:
csharp
// Save report to file
@Report.Form.DailyReport.Save();
// Generate with custom filename
@Report.Form.DailyReport.SaveAs("CustomReport.pdf");
Automatic Generation
Using SaveTrigger:
- Set SaveTrigger property to a tag
- When tag changes to 1, report generates
- Reset tag to 0 for next trigger
Scheduled Generation
csharp
// In startup script
@Report.Form.DailyReport.SaveTrigger = @Tag.DailyTrigger;
// In scheduled script (runs daily at 6 AM)
@Tag.DailyTrigger = 1;
@Tag.DailyTrigger = 0;
Step 5: Display Reports
PDF Viewer Control
- In Displays → Draw
- Add PdfViewer control
- Set properties:
- FileName: Path to PDF
- AutoRefresh: Update on file change
Report Viewer Control
For rich text reports:
- Add ReportViewer control
- Set ReportName property
- Displays formatted report content
Advanced Features
Headers and Footers
- Create separate forms for header/footer
- In main report, set:
- Header: HeaderForm name
- Footer: FooterForm name
- Content repeats on all pages
Multi-Language Support
csharp
// Switch language before generation
@Client.Localization = "Spanish";
@Report.Form.DailyReport.Save();
Custom Table Formatting
Use callback function for dynamic formatting:
csharp
public void OnReportCustomTableCell(string reportName,
string columnName, DataRow row, TableCell cell)
{
if(Convert.ToDouble(row["Value"]) > 100)
{
cell.Background = Brushes.Red;
}
}
Email Distribution
csharp
// After report generation
@Script.Email.SendReport(
"recipient@example.com",
"Daily Report",
@Report.Form.DailyReport.SaveFileName
);
Common Issues
Report Not Generating
- Verify SaveTrigger tag changes
- Check file path permissions
- Confirm tags have values
- Review SaveFormat setting
Missing Data in Report
- Verify tag syntax
{Tag.Name}
- Check tag quality/communication
- Ensure queries execute before save
- Test tags in Watch window
PDF Layout Issues
- Adjust table column widths
- Check symbol sizes
- Use page breaks appropriately
- Test different paper sizes
WebData Connection Failed
- Verify URL and credentials
- Check firewall settings
- Test API in external tool
- Review authorization headers
Best Practices
? Use meaningful names - Clear identification for forms and WebData ? Test tag values - Verify data before generation ? Handle errors - Check file write permissions ? Version control - Include timestamps in filenames ? Optimize queries - Run database queries before report generation ? Document templates - Maintain template library ? Schedule wisely - Generate during low-activity periods
Integration Examples
Production Report Workflow
- Collect data throughout shift
- Calculate KPIs at shift end
- Generate PDF report
- Email to management
- Archive to network drive
API Data Exchange
- Configure WebData for REST API
- Schedule periodic POST of metrics
- Receive configuration updates via GET
- Update tags with new setpoints
Next Steps
- [PdfViewer Control →] Display generated reports
- [Scripts Module →] Automate report workflows
- [Email Notifications →] Distribute reports
In this section...
Page Tree | ||||
---|---|---|---|---|
|