← GQ3

Clients/GQ3/Graphics Project/GQ3_FFU_CSV_Export.md

manual
Source
10
Chunks
8
Entities
Doc
Type

Content

# GQ3 FFU Fan Speed Setpoint — CSV Export Script ## Overview This script runs inside the **Ignition Designer Script Console** and exports a single combined CSV file containing FFU fan speed setpoint snapshot data across all 17 report groups for a specified date range. It loops through every FFU group report, calls `system.report.executeReport()` to pull the data using the existing configured datasources, strips redundant headers, prepends a `GROUP` column, and writes everything to one flat CSV file. --- ## Requirements | Item | Detail | |---|---| | **Platform** | Ignition 8.3 (Jython 2.7) | | **Where to run** | Designer → Tools → Script Console | | **Reports required** | All 17 FFU Snapshot Reports must exist under `FFU REPORTS/` in the GQ3_Dashboard project | | **Datasources** | Each report's Tag Historian datasource must be wired and active in the gateway | | **Output folder** | `C:/GQ3_Exports/` must exist on the machine running Designer before execution | --- ## Data Source All 17 reports pull from: - **Tag:** `[GQ3_TAGS]REPORTING_TAGS/FFU_GROUP_1_REPORT_DT` — used as the EndDate anchor - **StartDate expression:** `dateArithmetic({[GQ3_TAGS]REPORTING_TAGS/FFU_GROUP_1_REPORT_DT}, -24, "hr")` — 24-hour lookback window - **DB:** `[GQ3_DB]ffu_parametrized_udts/ffu_N/read_run_perc_ffu` — one named query per physical FFU unit (ffu_1 through ffu_164) > **Note:** The `StartDate` / `EndDate` parameters in the script override the report's built-in date expressions at runtime, so you can request any date range regardless of what the trigger tag currently holds. --- ## Report Coverage | Report | FFUs Covered | DB Query IDs | |---|---|---| | FFU G1 | 01-01, 01-03, 01-05 | ffu_1, ffu_2, ffu_164 | | FFU G2 | 02-03 to 02-06 | ffu_3 to ffu_6 | | FFU G3.1 | 3-1 to 3-15 | ffu_10 to ffu_21, 25, 26, 30 | | FFU G3.2 | 3-16 to 3-25 | ffu_31 to ffu_38, 42, 46, 47 | | FFU G4 | 04-01 to 04-08 | *(back-referenced — visible in Designer Data tab)* | | FFU G5 | 05-01 to 05-07 | ffu_48, 50–55 | | FFU G6 | 06-01 to 06-12 | ffu_22–24, 27–29, 39–41, 43–45 | | FFU G7 | 07-01 to 07-12 | *(back-referenced — visible in Designer Data tab)* | | FFU G8 | 08-01 to 08-12 | ffu_56 to ffu_67 | | FFU G9.1 | 09-01 to 09-12 | ffu_116 to ffu_127 | | FFU G9.2 | 09-13 to 09-24 | ffu_128 to ffu_139 | | FFU G9.3 | 09-25 to 09-36 | ffu_140 to ffu_151 | | FFU G10 | 10-01 to 10-12 | ffu_68 to ffu_79 | | FFU G11 | 11-01 to 11-12 | ffu_80 to ffu_91 | | FFU G12 | 12-01 to 12-12 | ffu_92 to ffu_103 | | FFU G13 | 13-01 to 13-12 | ffu_152 to ffu_163 | | FFU G14 | 14-01 to 14-12 | ffu_104 to ffu_115 | **Total FFUs: ~164** (160 fully mapped + 20 in G4/G7 with back-referenced serialization) --- ## Output CSV Format ``` GROUP, FFU NAME, DATE, PERCENT SETPOINT FFU G1, FFU 01-01, Mar 24, 2026, 85.00 FFU G1, FFU 01-03, Mar 24, 2026, 82.50 ... FFU G14, FFU 14-12, Mar 24, 2026, 90.00 ``` - One row per FFU per timestamp snapshot - `GROUP` column prepended to identify which report group the row came from - Single header row at the top (subsequent report headers are suppressed) - Empty/blank rows and comma-only rows are filtered out --- ## Script ```python # ============================================================ # GQ3 FFU Snapshot — One-Time CSV Export for 2026-03-24 # Run this in: Designer → Tools → Script Console # ============================================================ import system # --- Date range --- start_dt = system.date.parse("2026-03-24 00:00:00", "yyyy-MM-dd HH:mm:ss") end_dt = system.date.parse("2026-03-24 23:59:59", "yyyy-MM-dd HH:mm:ss") params = {"StartDate": start_dt, "EndDate": end_dt} project = "GQ3_Dashboard" base = "FFU REPORTS" reports = [ "FFU G1 SNAPSHOT REPORT", "FFU G2 SNAPSHOT REPORT", "FFU G3.1 SNAPSHOT REPORT", "FFU G3.2 SNAPSHOT REPORT", "FFU G4 SNAPSHOT REPORT", "FFU G5 SNAPSHOT REPORT", "FFU G6 SNAPSHOT REPORT", "FFU G7 SNAPSHOT REPORT", "FFU G8 SNAPSHOT REPORT", "FFU G9.1 SNAPSHOT REPORT", "FFU G9.2 SNAPSHOT REPORT", "FFU G9.3 SNAPSHOT REPORT", "FFU G10 SNAPSHOT REPORT", "FFU G11 SNAPSHOT REPORT", "FFU G12 SNAPSHOT REPORT", "FFU G13 SNAPSHOT REPORT", "FFU G14 SNAPSHOT REPORT", ] out_file = "C:/GQ3_Exports/FFU_Snapshot_2026-03-24.csv" all_lines = [] header_written = False errors = [] for report_name in reports: path = base + "/" + report_name try: csv_bytes = system.report.executeReport( path = path, project = project, parameters = params, fileType = "csv" ) # Decode Java byte array directly — system.string does not exist in Ignition Jython csv_text = csv_bytes.tostring().decode("UTF-8") lines = [l for l in csv_text.splitlines() if l.strip()] if not lines: errors.append(report_name + ": returned empty output") continue if not header_written: all_lines.append("GROUP," + lines[0]) header_written = True group_label = report_name.replace(" SNAPSHOT REPORT", "") for line in lines[1:]: if line.strip() and not line.startswith(",,,"): all_lines.append(group_label + "," + line) print("OK: " + report_name + " (" + str(len(lines) - 1) + " rows)") except Exception as e: errors.append(report_name + ": " + str(e)) print("ERROR: " + report_name + " — " + str(e)) # system.file.writeFile accepts a plain string — no toBytes needed combined = "\n".join(all_lines) system.file.writeFile(out_file, combined) print("") print("Written to: " + out_file) print("Total data lines: " + str(len(all_lines) - 1)) if errors: print("") print("=== ERRORS (" + str(len(errors)) + ") ===") for e in errors: print(" " + e) ``` --- ## How to Run 1. Open **Ignition Designer** and connect to the GQ3_Dashboard gateway 2. Go to **Tools → Script Console** 3. Paste the full script into the Multiline Buffer (left pane) 4. Update the two lines that need changing for your target date: ```python start_dt = system.date.parse("YYYY-MM-DD 00:00:00", "yyyy-MM-dd HH:mm:ss") end_dt = system.date.parse("YYYY-MM-DD 23:59:59", "yyyy-MM-dd HH:mm:ss") out_file = "C:/GQ3_Exports/FFU_Snapshot_YYYY-MM-DD.csv" ``` 5. Make sure `C:/GQ3_Exports/` exists on the machine running Designer 6. Click **Execute** 7. Watch the Interactive Interpreter (right pane) — each report prints `OK` or `ERROR` --- ## Adapting for Daily Scheduled Export To run this automatically every day instead of manually, move the logic into a **Gateway Timer Script**: 1. Designer → Project Browser → Scripting → Gateway Events → Timer → New Script 2. Set **Delay** to `86400000` (24 hours in ms), **Delay Type** to `Fixed Delay` 3. Replace the hardcoded date with dynamic expressions: ```python now = system.date.now() yesterday = system.date.addDays(now, -1) start_dt = system.date.midnight(yesterday) end_dt = system.date.addSeconds(system.date.midnight(now), -1) date_str = system.date.format(yesterday, "yyyy-MM-dd") out_file = "C:/GQ3_Exports/FFU_Snapshot_" + date_str + ".csv" ``` --- ## Known Issues / Notes | Issue | Detail | |---|---| | `system.string` does not exist | Ignition Jython does not have `system.string.fromBytes` or `system.string.toBytes`. Use `csv_bytes.tostring().decode("UTF-8")` and pass a plain string to `writeFile` instead. | | G4 and G7 DB query IDs unknown from binary | Their IDs are stored as back-references in the serialized report binary and can't be read externally. The reports still execute correctly via `executeReport()` since the datasources are live in the gateway. To inspect the IDs: open either report in Designer → Data tab. | | `ffu_164` in G1 | Appears to be a template/unused UDT entry. It is mapped to FFU 01-05 in the report but may warrant verification. | | Output folder must exist | `system.file.writeFile` will throw if the directory doesn't exist. Create `C:/GQ3_Exports/` manually first, or add `system.file.mkdir("C:/GQ3_Exports")` at the top of the script. |

Extracted Entities

TypeKeyValueConfidenceEvidence
server Database query example [GQ3_DB]ffu_parametrized_udts/ffu_N/read_run_perc_ffu 100% DB: `[GQ3_DB]ffu_parametrized_udts/ffu_N/read_run_perc_ffu`
server Output folder path C:/GQ3_Exports/ 100% `C:/GQ3_Exports/` must exist on the machine running Designer
server Output CSV file C:/GQ3_Exports/FFU_Snapshot_2026-03-24.csv 100% out_file = "C:/GQ3_Exports/FFU_Snapshot_2026-03-24.csv"
server Report base folder FFU REPORTS 100% base = "FFU REPORTS"
server Tag Historian datasource example [GQ3_TAGS]REPORTING_TAGS/FFU_GROUP_1_REPORT_DT 100% Tag: `[GQ3_TAGS]REPORTING_TAGS/FFU_GROUP_1_REPORT_DT` — used as the EndDate anchor
site Project name GQ3_Dashboard 100% project = "GQ3_Dashboard"
system Ignition Platform Ignition 8.3 100% Platform | Ignition 8.3 (Jython 2.7)
task Scheduled export interval 86400000 100% Set Delay to `86400000` (24 hours in ms), Delay Type to Fixed Delay
File: Clients/GQ3/Graphics Project/GQ3_FFU_CSV_Export.md
Updated: 2026-03-26 21:32:37.251613