Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Reports generation tutorial, create and test a text report.

TutorialsReports| Tutorial | How-to Guide | Reference


This Tutorial Teaches

Generation (Tutorial) teaches

you to:

  • Create text reports with real-time dataExchange information with external systems using WebData.
  • Set up notificationsEnable audit trail for FDA 21 CFR Part 11 complianceautomated report generation

Prerequisites:

In this page:

Table of Contents
maxLevel2
minLevel2
indent10px
excludeStepsTutorial
stylenone



Reports → Tutorial | Concept | How-to Guide | Reference

Step 1:

1. Create a Simple Text Report

We'll create a shift report showing tank status.

  1. Navigate to Reports → Forms
  2. Click first row to add new form
  3. Configure:
    • Name: ShiftReport
    • SaveFormat: Text
    • SaveFileName: C:
\
    • /Reports
\
    • /Shift
_{Info
    • .
Date}.txt
  • Click OK
      • txt
    1. Press Enter


    Info
    titleMandatory Folder

    It is mandatory that the folder where the Report will be saved, must be created before. The system does not create folders automatically.



    2.

    Step 2:

    Design Report Content

    1. Go to Reports → Forms Editor
    2. Select Double click ShiftReport from dropdown 
    3. Enter this the report template below, then Save the report:
    ================================
        TANK FARM SHIFT REPORT
        Date: {InfoServer.DateTimeInfo.Date}
        Time: {InfoServer.DateTimeInfo.Time}
        Operator: {Client.UserName}
    ================================
    
    TANK STATUS SUMMARY
    -------------------
    Tank 1:
      Level: {Tag.TankFarm/Tank1/Level} ft
      Temperature: {Tag.TankFarm/Tank1/Temp} °F
      Pressure: {Tag.TankFarm/Tank1/Pressure} PSI
      Status: {Tag.TankFarm/Tank1/Status}
    
    Tank 2:
      Level: {Tag.TankFarm/Tank2/Level} ft
      Temperature: {Tag.TankFarm/Tank2/Temp} °F
      Pressure: {Tag.TankFarm/Tank2/Pressure} PSI
      Status: {Tag.TankFarm/Tank2/Status}
    
    PRODUCTION METRICS
    ------------------
    Total Volume: {Tag.TankFarm/Metrics/TotalVolume} gal
    Flow Rate: {Tag.TankFarm/Metrics/FlowRate} gpm
    Daily Production: {Tag.TankFarm/Metrics/DailyProduction} gal
    
    ================================
    End of Report
    1. Save the form (Ctrl+S)

    Step 3:

    3. Test Report Generation

    1. Start runtime (F5)runtime 
    2. Open Scripts → Tasks
    3. Create test script:

    csharp

    public void TestReport()
    {
        // Set some test values
        @Tag.TankFarm/Tank1/Level = 75.5;
        @Tag.TankFarm/Tank1/Temp = 68.2;
        @Tag.TankFarm/Tank1/Pressure = 14.7;
        @Tag.TankFarm/Tank1/Status = "Normal";
        
        // Generate report
        @Report.Form.ShiftReport.Save();
        
        // Show confirmation
        @Info.Trace("Report saved to: " + 
                     @Report.Form.ShiftReport.SavedFileName);
    }
    1. Run script
    2. Check C:\Reports\ for generated text file

    Step 4: Create WebData for API

    Now we'll send tank data to an external system.

    1. Navigate to Reports → WebData
    2. Click Plus to add
    3. Configure:
    4. Click OK

    Step 5: Configure JSON Structure

    1. Go to Reports → WebData Editor
    2. Select TankDataAPI
    3. Enter JSON template:

    json

    {
      "timestamp": "{Info.Date} {Info.Time}",
      "facility": "TankFarm-01",
      "tanks": [
        {
          "id": "Tank1",
          "level": {Tag.TankFarm/Tank1/Level},
          "temperature": {Tag.TankFarm/Tank1/Temp},
          "pressure": {Tag.TankFarm/Tank1/Pressure},
          "status": "{Tag.TankFarm/Tank1/Status}"
        },
        {
          "id": "Tank2", 
          "level": {Tag.TankFarm/Tank2/Level},
          "temperature": {Tag.TankFarm/Tank2/Temp},
          "pressure": {Tag.TankFarm/Tank2/Pressure},
          "status": "{Tag.TankFarm/Tank2/Status}"
        }
      ],
      "metrics": {
        "totalVolume": {Tag.TankFarm/Metrics/TotalVolume},
        "flowRate": {Tag.TankFarm/Metrics/FlowRate}
      }
    }
    1. Save the WebData

    Step 6: Test Data Exchange

    1. Create script to test WebData:

    csharp

    public async void SendTankData()
    {
        // For testing, save to file instead of API
        @Report.WebData.TankDataAPI.SaveFileName = 
            @"C:\Reports\TankData.json";
        
        // Save JSON with current tag values
        @Report.WebData.TankDataAPI.Save();
        
        @Info.Trace("JSON data saved");
    }
    1. Run script
    2. Open saved JSON file to verify structure
    1. PropertyWatch
    2. Go to List2 and type: Report.Form.ShiftReport.Save
    3. Change the value from 0 to 1
    4. Check the folder to see generated report



    4.

    Step 7:

    Schedule Automatic Reports

    Create scheduled task for shift reports:

    1. Go to Scripts Reports Tasks
    2. Create new task: ShiftReportSchedule
    3. Set trigger: Server.Hour
    4. Add code:

    csharp

    public void GenerateShiftReport()
    {
        // Generate at 6:00, 14:00, 22:00 (shift changes)
        if (@Server.Hour == 6 || @Server.Hour == 14 || @Server.Hour == 22)
        {
            // Calculate shift metrics
            @Tag.TankFarm/Metrics/DailyProduction = 
                @Tag.TankFarm/Tank1/Level * 1000 + 
                @Tag.TankFarm/Tank2/Level * 1000;
            
            // Generate report
            @Report.Form.ShiftReport.Save();
            
            // Log generation
            @Alarm.AuditTrail.AddCustomMessage(
                "Shift report generated", null, null, null, null, null, null);
        }
    }

    Step 8: Add Report Viewer

    Display the generated report:

    1. Open Displays → MainPage
    2. Add Button control:
      • Text: "View Shift Report"
      • Name: btnViewReport
    3. Double-click button for code:

    csharp

    public void btnViewReport_Click(object sender, EventArgs e)
    {
        // Open report in default text editor
        string reportPath = @Report.Form.ShiftReport.SavedFileName;
        
        if (System.IO.File.Exists(reportPath))
        {
            System.Diagnostics.Process.Start(reportPath);
        }
        else
        {
            MessageBox.Show("No report found. Generate one first.");
        }
    }
    Step 9
    1. Forms
    2. Change the SaveTrigger to: Server.Hour
    3. The report will be generated every hour once the solution is running.



    5.

    :

    Monitor Report Status

    1. During runtime, open Reports → Reports Monitor
    2. Verify report status:
      • Name: ShiftReport
      • LastStatus: Success0
      • SavedFileName: Shows generated file path
    3. Check for any errors in LastStatusMessage

    Step 10: Test Complete Workflow

    1. Start runtime (F5)
    2. Let tags update with live values
    3. Wait for scheduled generation OR
    4. Manually trigger: @Report.Form.ShiftReport.Save()
    5. Click "View Shift Report" button
    6. Verify report contains current data

    Next Steps

    • [Forms Editor] - Add tables and charts
    • [WebData POST] - Send data to real APIs
    • [PDF Reports] - Professional formatted output
    This tutorial provides a simple introduction to Reports, building on the existing tank farm tags while keeping complexity low. Students can see immediate results with text reports and understand the JSON structure for data exchange.

    Excerpt Include
    Reports Module
    Reports Module
    nopaneltrue


    In this section...

    Page Tree
    root@parent
    spaces93DRAF