Designing Shift Reports with 8-Hour Statistical Calculations (Avg, Min, Max) in WinCC Report Designer

Designing Shift Reports with 8-Hour Statistical Calculations (Avg, Min, Max) in WinCC Report Designer

In SIMATIC PCS 7 WinCC, generating automated 8-hour shift reports containing statistical evaluations (Average, Minimum, and Maximum) of archive tags requires configuring WinCC Report Designer and Tag Logging Table objects. In Report Designer, create a Page Layout containing a WinCC Tag Logging Table configured for statistical evaluation over a relative time range of 8 hours. Because standard WinCC Print Jobs only provide hourly, daily, weekly, or monthly cyclic triggers, triggering an 8-hour shift print job requires executing a cyclic C-action in Global Script (using RPTJobPrint) scheduled at shift changeovers (e.g., 06:00, 14:00, 22:00), or triggering on a PLC shift pulse tag.

Table of Contents

Architecture of WinCC Report Designer and Statistical Archiving

In industrial facilities running SIMATIC PCS 7, shift supervisors require automated end-of-shift documentation summarizing operational performance. An 8-hour shift report typically aggregates critical process measurements—such as boiler steam flow, reactor temperature, and furnace pressure—calculating the Average (Mean), Minimum, and Maximum values across the completed 8-hour window.

WinCC provides the Report Designer subsystem to manage printable documentation:
* Page Layouts (.rpl): Graphical report layout templates defining page headers, company logos, table grids, trend curves, and page footers.
* Print Jobs: Execution profiles defining printer destination (physical printer, PDF printer, or EMF file), page orientation, and execution triggers (event-driven, cyclic, or on-demand).
* Tag Logging Runtime Connector: A native reporting object that connects directly to the local WinCC Tag Logging database, executing SQL aggregation functions without requiring custom database scripting.

Configuring Tag Logging Table Objects for Statistical Calculations

To display statistical metrics in Report Designer, engineers utilize the WinCC Tag Logging Runtime Table control:

  1. Table Object Placement: In the Page Layout editor, the engineer drags a Tag Logging Table object onto the report canvas.
  2. Column Customization:
    In the table properties, columns are configured to represent statistical aggregates:
    * Column 1: Tag Name / Technological Description
    * Column 2: Minimum Value (Min)
    * Column 3: Average Value (Average / Mean)
    * Column 4: Maximum Value (Max)
    * Column 5: Unit of Measurement (e.g., deg C, bar, kg/h)
  3. Internal Statistical Processing:
    The WinCC reporting engine queries the Tag Logging SQL database over the requested interval and evaluates:
    $$\text{Average} = \frac{1}{N} \sum_{i=1}^{N} X_i$$
    It automatically excludes invalid or bad-quality samples (Quality Code != 0x80), ensuring statistical accuracy.

Relative Time Range Configuration for 8-Hour Shift Windows

Configuring the report's time boundary is critical for shift reporting:

  • Absolute vs Relative Time: Absolute time ranges (e.g., "October 10, 2016 06:00 to 14:00") require manual parameter input before every print. For fully autonomous shift reports, the table must use Relative Time Ranges.
  • The 8-Hour Relative Range Setting:
    In the Tag Logging Table properties > Time Range:
  • Select Relative Time Range.
  • Set the duration to 8 Hours.
  • Set the reference point to Current Time minus Duration (i.e., Start = Now - 8 Hours, End = Now).
  • When the print job triggers at the end of the shift (e.g., exactly at 14:00:00), the engine evaluates data logged between 06:00:00 and 14:00:00.

Overcoming the Cyclic Print Job Limitation: 8-Hour Scheduling via C-Script

In WinCC Explorer, opening Print Jobs > Properties reveals a significant architectural constraint:
* Available Standard Cycles: The cyclic trigger dropdown only offers Hourly, Daily, Weekly, Monthly, and Yearly.
* Missing Multi-Hour Cycles: There is no native setting for an "Every 8 Hours" or "Every 4 Hours" cyclic print job.

The Engineering Solution (Global Script C-Action):
To trigger the print job at specific shift changeover times (e.g., 06:00, 14:00, 22:00):
1. Create a cyclic C-action in WinCC Global Script scheduled to execute once per hour (or on a 1-minute cycle).
2. Inspect the system local hour (time.h in C).
3. When the hour matches a shift boundary, invoke the standard WinCC reporting function RPTJobPrint():
```c
#include "apdefap.h"
void Trigger_Shift_Report()
{
time_t rawtime;
struct tm *timeinfo;
time(&rawtime);
timeinfo = localtime(&rawtime);

   // Check for shift changeover hours: 06:00, 14:00, 22:00
   if ((timeinfo->tm_hour == 6 || timeinfo->tm_hour == 14 || timeinfo->tm_hour == 22) && timeinfo->tm_min == 0)
   {
       RPTJobPrint("@Shift_Report_8Hours");
   }

}
```
4. Alternatively, use a digital tag generated by the S7-400 CPU (e.g., an OB35 clock pulse at shift transition) to trigger the print job upon tag state change.

Comparison Table: WinCC Reporting Engines and Statistical Methods

The following table contrasts different reporting architectures available in SIMATIC PCS 7:

Reporting SolutionWinCC Report DesignerWinCC Information ServerWinCC OLE-DB / SQL ConnectivitySoftware ArchitectureBuilt-in WinCC subsystemCentralized web reporting serverCustom C/VBS scripts & SQL queriesStatistical SupportBuilt-in Min, Max, Avg, SumComprehensive SSRS analyticsRequires custom SQL AVG(), MIN()Trigger MechanismPrint Jobs / C-script RPTJobPrintScheduled cron / email / PDF exportScript-driven file output (CSV / Excel)Output FormatsPhysical Printer, PDF, EMFPDF, Excel, Word, HTMLCSV, TXT, ExcelLicensing RequirementIncluded in standard WinCCRequires Information Server LicenseRequires Connectivity Pack LicenseEngineering ComplexityLow to ModerateLow (drag-and-drop web templates)High (requires database programming)Recommended DeploymentStandard local shift loggingEnterprise multi-OS reportingSpecialized external IT integration

Step-by-Step Procedure to Implement Automated 8-Hour Shift Reports

Follow this verified engineering workflow to build and schedule an automated 8-hour shift report:

  1. Design the Page Layout (.rpl):
    * Open Report Designer > Layouts in WinCC Explorer.
    * Duplicate @CC_TagLogging_Table.rpl and rename it to Shift_Report_8Hours.rpl.
    * Open the file in the Report Designer Layout Editor.
    * Insert plant header text, shift title, and company logo.
  2. Configure Statistical Tag Logging Table:
    * Double-click the Tag Logging Table object to open Properties.
    * Under Selection, add the required archive tags (e.g., temperatures, pressures, flows).
    * Under Columns, select Minimum, Average, and Maximum.
    * Under Time Range, select Relative Range, configure 8 Hours, ending at current time.
    * Save and close the layout.
  3. Create the Print Job:
    * In WinCC Explorer, right-click Print Jobs > New Print Job.
    * Name: @Shift_Report_8Hours.
    * Select the Layout: Shift_Report_8Hours.rpl.
    * Under Printer Setup, select the physical network printer or Microsoft Print to PDF.
    * Set Execution to On Demand / Event-Driven.
  4. Implement Shift Changeover Trigger in Global Script:
    * Open Global Script > C-Editor.
    * Create a new project action TriggerShiftReport.pas.
    * Configure a 1-minute cyclic trigger.
    * Insert the C-code evaluating tm_hour == 6 || tm_hour == 14 || tm_hour == 22 and calling RPTJobPrint("@Shift_Report_8Hours");.
    * Compile and save the action.
  5. Verify Global Script Runtime:
    * Verify in Computer Properties > Startup that Global Script Runtime is checked.

Verification

Verify automated report generation and statistical calculations:
1. In WinCC Explorer, right-click the print job @Shift_Report_8Hours and select Print Preview; verify that the generated document displays realistic Min, Max, and Average values across all tags.
2. Manually execute RPTJobPrint("@Shift_Report_8Hours"); in a test graphic button; confirm that the document sends cleanly to the designated printer or PDF spooler without dialog errors.
3. Verify that the statistical calculations match real logged data by comparing the report's Average value against an export from WinCC Online Trend Control.
4. Check <WinCC_Project>\Diagnostics\WinCC_Sys_01.log to confirm that no print spooler or database query timeout errors occur.

Limitations and Operational Precautions

  • Print Spooler Hangs: If a physical network printer goes offline (paper jam, out of toner), Windows print spooler queues can lock up, causing background C-script execution threads to block. Always configure PDF export as the primary destination or enable print spooler timeouts.
  • Bad Quality Samples: If a field transmitter experiences a communication failure during the shift, Tag Logging records bad quality codes. Ensure the table properties are set to ignore bad quality samples so invalid values (e.g., -999.0) do not skew statistical averages.
  • Clock Synchronization: Ensure all OS servers and controllers are synchronized via NTP / SICLOCK. Discrepancies between system time and Tag Logging timestamps will shift the 8-hour reporting boundary.
  • Commercial Accuracy: Standard WinCC reporting utilizes built-in Report Designer capabilities. For enterprise web reporting across multiple servers, consider the SIMATIC Information Server package (6AV6371-1DH07-5AX0). Validate software options with an authorized Siemens distributor quotation.

Engineer FAQ

Can I export the 8-hour shift report directly to Microsoft Excel instead of printing?

Standard WinCC Report Designer outputs directly to printers, PDF files, or EMF images. To export automated shift statistics directly into formatted Microsoft Excel spreadsheets (.xlsx), use the SIMATIC Information Server or write a VBScript utilizing the WinCC OLE-DB Connectivity Pack.

How does the Average calculation handle irregular or event-driven archiving?

If a tag is archived using acyclic or event-driven logging, WinCC performs a time-weighted average (integrating value over time divided by total duration) rather than a simple arithmetic mean, guaranteeing mathematical accuracy.

Can the shift start hours (06:00, 14:00, 22:00) be adjusted by operators in WinCC Runtime?

Yes. Instead of hardcoding hours in C-scripts, link the trigger logic to WinCC internal tags (e.g., Shift1_Hour, Shift2_Hour, Shift3_Hour) editable by operators on an HMI configuration screen.

Why does my report print empty tables with 'No data available'?

This occurs when the configured relative time range points to a future time window or when the target tags are not enabled for archiving in WinCC Tag Logging.

Technical References

Related Articles

Related Tags

  • Report Designer
  • Tag Logging
  • Statistical Reports
  • Print Jobs
  • Global Script
  • Shift Reporting
6 respuestas