PI Historical Backfill and WinCC Real-Time Ingestion
Keep the WinCC front end, ingest PI historical archives and OPC DA real-time values into the same existing TDengine databases and tables, and verify continuity across tables, time, quality, and points. Quality status and digital-value conversion are especially prone to errors. Another common mistake is using current OPC DA values to fill missing history.
Where to operate: PI backfill and OPC-DA tasks in taosExplorer. The corresponding administrators perform source-side operations. Run target queries in the taosExplorer Data Browser or taos CLI.
1. Plan and Prerequisites
原实时链路:WinCC → PI Interface → PI System
历史回填:PI System → taosX PI backfill → TDengine 既有库表
新实时链路:WinCC OPC DA Server → taosX OPC DA 任务 → 同一组既有库表
Point mapping determines the target child table and its time, value, and quality columns that each WinCC Item ID continues to populate. It is not simply a way to generate new tables with similar names. First inventory the points, historical model, time sources, quality dictionary, and conversion factors. Define the test scope, historical cutoff, real-time start, old-link retention period, and rollback owner.
| Item | Conditions to confirm |
|---|---|
| Historical source | PI archives remain readable, or historical backfill is complete. Without readable archives, current OPC DA values cannot recreate missing history. |
| Windows collection host | The host that actually runs taosX or taosX-Agent has the OPC DA dependencies and can access the actual WinCC host and ProgID. This is not an OPC DA procedure for Linux. |
| Runtime identity | Source point collection, testing, and the production agent use the same authorized Windows identity. An interactive user's ability to browse does not mean the service account can read. |
| Target structure and identity | Obtain the existing databases, supertables, child tables, columns, and types. Use a read-only identity to inventory mappings, and grant separate least-privilege permissions for production writes. |
| Historical materials | PI point lists, AF XML, PI Interface configuration, original migration CSV files, and WinCC variable lists. If these are unavailable, confirm each point manually rather than infer mappings. |
| Quality and values | Historical quality status sets, Digital dictionaries, engineering units, scaling, and offsets. See below for the scope of quality conversion. |
| Supporting tools | If using a mapping tool, obtain software, help, and component registration instructions that match the on-site version from official support. It is not a built-in taosx subcommand. |
See PI for historical backfill dependencies and OPC DA for OPC DA connection dependencies. Success on one link does not remove the need to check the other link's service identity and permissions.
2. Backfill History and Save the Model Baseline
Follow Backfill a PI Time Range to migrate one point over a short window first. After confirmation, expand in batches as described in PI Historical Backfill and Real-Time Continuity. Save each batch's time window, count, representative values, and actual table structure. Identify the last verified historical timestamp. Real-time mapping can be prepared in parallel, but confirm that the corresponding targets exist before uploading a real-time task.
Historical backfill, mapping inventory, and real-time writes use different identities. Preparing mapping materials does not require modifying target tables. Do not delete historical databases or tables to accommodate automatic naming. If PI is offline, use only saved models and materials. “Mapping does not require online PI” does not mean “backfill is possible without archives.”
3. Collect Mapping Materials
Organize the following inventory manually, or use the taosx-opcda-map tool delivered by official support. The tool workflow below applies only to sites that have obtained a matching tool package. Check the help in the package before running commands. Do not assume that every installation package includes the tool or its commands.
Run all tool commands in Windows PowerShell from a separate working directory. For the initial registration of OPC automation components, authorized personnel must follow the package instructions and retain a record. Do not register unknown DLLs indiscriminately. Metadata collection also incurs query and browsing overhead. Limit the scope first and observe source load; read-only access does not mean zero load.
| Material | Content to save |
|---|---|
| Historical model | Databases, supertables, child tables, time/value/quality columns, types, tags, historical statuses, and engineering units |
| Real-time points | WinCC services, hosts, ProgIDs, Item IDs, types, readability, and collection identities |
| Historical associations | PI point names, AF paths, Interface configuration, conversion factors, and relationships to WinCC variables |
| Batch boundaries | Source service, agent, target instance, collection settings, and unread or failed ranges |
After obtaining the tool package, use commands in the following form. Replace file names and source services with actual on-site values. Supply passwords through a controlled runtime environment, not in DSNs or reports:
.\taosx-opcda-map.exe import-pi --excel archive_attributes.xlsx --af-xml AFDatabase_Assets.xml
.\taosx-opcda-map.exe scan-tsdb --dsn 'taos://mapping_reader@tsdb-host:6030' --database archive_backfill
.\taosx-opcda-map.exe scan-opcda --name casthouse --host wincc-host --prog-id OPCServer.WinCC.1 --browse
import-pi processes saved historical exports; skip it if no materials are available. scan-tsdb reads the target model. scan-opcda browses points on a Windows host that can access WinCC. Pass the tool package's required TAOS_PASSWORD to the process through an approved secret-injection method. Clean up the environment afterward according to on-site requirements; do not put it in shared scripts.
If the two sides are in different network zones, collect the inventories separately and consolidate them under controlled procedures. A single host does not have to reach both sides. Retain the collection identity, scope, and failure list. A scan that reaches a count limit or fails on some branches is not a full scan. Recollect affected portions after source models or points change.
4. Match and Review Manually
Run the matching command supplied by the tool package from the common working directory:
.\taosx-opcda-map.exe match
Check mapping-report.html, unresolved.csv, and target-mappings.csv as instructed by the package. Verify the matching basis, source service, target database/table/columns, types, time, quality, and units for each entry. Similar names identify candidates; they do not replace business confirmation.
| Status | Action |
|---|---|
| Acceptable | Include in this batch only if the mapping is unique and both structure and business meaning pass review. |
| Pending confirmation | Obtain additional materials or a manual decision. Do not upload before confirmation. |
| Conflict | Investigate multiple candidates or multiple sources competing for the same value column. Do not pick an arbitrary mapping to remove the conflict. |
| Incompatible | Check types, dictionaries, and connector capabilities. Resolve the issue before exporting. |
| No match | Add source information and rules. Do not generate targets by guessing. |
| Excluded | Record the business reason, approver, and impact, and retain the entry in the report. |
When a manual decision is needed, maintain decisions.csv as required by the package. Record confirmation, exclusion, or exception decisions and their reasons, then match again. Rerun matching when only rules or decisions change. Recollect first when objects on either side change. Retain the original inventories and each round of results, not just the last “successful report.”
One OPC address may continue multiple historical child tables. Do not force the unique-address count and target-mapping count to match. The same source point cannot be configured twice in one task. Implement multiple targets in separate reviewed task batches and assess the duplicate-read load on WinCC. Do not remove valid targets merely to align counts.
5. Export and Check Task Point Lists
At sites with the matching tool package, run the following after review approval:
.\taosx-opcda-map.exe export
Follow the package instructions to check task CSV files, task guides, and manifests, such as opcda-task-<服务名>-NNN.csv, task-guide.md, and task-manifest.json. Each file should identify the source service and identity, agent, target instance/database, collection parameters, and point scope. Naming, batch limits, and validation behavior depend on the delivered tool version. A file's existence does not mean it has passed on-site checks.
Whether the files are generated by a tool or manually, complete these checks:
- All target tables and their time, value, and quality columns actually exist and have compatible types. No unresolved entries are included in the task.
- Source points do not repeat within a file, and no entry points to an automatic naming template that would create a second set of tables.
- Each row's
quality_col, required dictionaries, and transformations have been reviewed. CSV quoting and column counts are correct. - No rows contain
enabled=0. This setting may delete tables; it must not mean “not included in this batch.” - After bringing offline results back on site, recheck objects, point values, and service identities. An old snapshot alone does not establish that a point list is suitable for on-site use.
After generating a point list with the tool, do not bypass the original rules by editing a row directly and uploading it. To make changes, adjust the reviewed configuration or decisions, regenerate the file, and retain the differences. For manually maintained point lists, record the same provenance and approvals. See OPC DA Point Mapping CSV for the format.
6. Handle Quality, Digital, and Numeric Values
6.1 Quality continuity
Raw OPC DA quality codes and PI digital state numbers use different encodings. For example, raw OPC DA Good quality is commonly 192, while a PI historical model may use 0 for a valid value. Do not treat real-time 192 directly as a historical state number.
For PI continuity conversion, configure quality_mode=pi_compatible_v1 in the Point list and explicitly set quality_col to the existing quality column. This conversion does not run without that mode. The mode converts by OPC quality category as follows:
| Source quality or data condition | Value column | Quality column result |
|---|---|---|
Good category with a valid value, for example raw code 192 | Retain the numeric value, or convert using the configured Digital dictionary | 0 |
Bad category, for example raw codes 0, 4, 8, 24 | NULL | 307 |
Uncertain category, for example raw codes 64, 68, 80 | NULL | 308 |
| Missing quality or reserved category | NULL | -1 |
| Good but missing value, or Digital code not found in the dictionary | NULL | -1 |
pi_compatible_v1 does not reproduce every state conversion of the original PI Interface. It does not map individual Bad substates to historical numbers such as Configure, Not Connect, or Comm Fail, and does not change the rules above based on the original interface's /SQ or /SG parameters. If the site's historical model must retain these finer semantics, confirm a suitable continuation approach first. Do not treat this mode as fully compatible.
Ask the PI administrator for the historical state sets and original interface configuration. Have the business owner confirm whether these categories meet query, alarm, and reporting requirements. States such as I/O Timeout, Intf Shut, and Shutdown generated by the original PI Interface or server itself cannot be reconstructed from OPC current values. Enable Report Abnormal Values during continuation tests; otherwise abnormal source values may be excluded before reaching the target. Verify Good, Bad, Uncertain, and missing values separately using approved test Points. Do not deliberately cause production equipment failures.
6.2 Digital dictionaries and numeric conversion
If historical Digital values are state names such as Idle and Charge, while OPC returns Boolean or integer codes, configure a business-approved JSON dictionary in CSV value_map. For example, {"0":"Idle","1":"Charge"} specifies target text for codes 0 and 1. Explicitly set the target type to NCHAR or VARCHAR. Dictionary values must be nonempty strings, and the dictionary cannot be combined with value_transform for the same Point.
Boolean keys false/true and integer keys 0/1 represent the same codes and cannot be configured twice. Codes absent from the dictionary do not default to 0 or a valid state: the value is written as NULL, quality is -1, and diagnostic information is logged. With quality conversion configured, Bad and Uncertain are handled first as shown above. They do not pass through the Digital dictionary to generate an apparently valid state value.
To restore scaling or offsets from the original PI path for ordinary numeric Points, configure value_transform using confirmed coefficients. For example, with target value column value, value * 0.1 scales by one tenth. Enter Point-list expressions directly, without the ${...} wrapper used by other mapping inputs. Coefficients must come from the original Point list or site business agreement, not guesses based on Point names or similar values. Compare input values, converted values, and historical units before approving the batch of Points.
For CSV fields and a complete two-point example, see Continue a PI Historical Model. If target history uses more detailed quality statuses, do not collapse all statuses to the same code just to make the task run. Obtain business confirmation of this semantic difference first.
7. Create a Real-Time Task and Run a Small Pilot
- Create an OPC-DA task under Data In in the target cluster's taosExplorer.
- Select the verified Windows execution agent, actual WinCC host and ProgID, and the target database used for historical backfill.
- Set the collection interval and time source according to the approved plan. Enable Report Abnormal Values and disable Dynamic Point Updates. Start with only a few confirmed points.
- Upload the batch's CSV, preview it, and compare target tables and columns. If an unexpected new model appears, stop submission or scope expansion and check the mapping first.
- Submit and start the original task. Use the actual task ID to inspect task activity and Logs and Performance, then verify the data.
Query the actual target child table in the taosExplorer Data Browser or taos CLI. For example, if the point list continues to use archive_backfill.tb_temp(ts,value,status):
DESCRIBE archive_backfill.tb_temp;
SELECT ts, value, status FROM archive_backfill.tb_temp
ORDER BY ts DESC LIMIT 20;
Check that new values enter the existing columns and that quality codes follow the agreement in section 6. For a Digital point, query its actual value column: the confirmed state name should appear, not the raw code. If actual tables or columns differ, replace them consistently. Do not create matching tables just to use the example.
8. Verify the Handoff Window and Cut Over
Save the last historical record, the real-time task start time, and the first new record. Query and compare the handoff window in the same target child table. WinCC may first return cached values with old timestamps. Confirm whether writes with the same primary key overwrite history. Do not substitute the time the task first receives data for the source timestamp.
| Check | Pass criteria |
|---|---|
| Mapping completeness | Every production mapping has a documented basis. Conflicts, excluded points, and reasons are visible. An overall success rate must not conceal missing critical points. |
| Write location | Historical and real-time data enter the same existing targets. Columns, tags, types, and time precision follow the plan. |
| Values and statuses | Representative samples pass checks for values, engineering units, quality, and Digital dictionaries. Missing quality and unknown codes are not presented as valid values. |
| One source, multiple targets | All approved targets receive new data, and duplicate reads stay within source capacity. |
| Time continuity | Overlaps or gaps in the handoff window are explained, and backfillable history has an identified source. OPC DA does not recreate archives for downtime. |
| Business regression | Trend, aggregate, status interpretation, and alarm queries pass. The old link's observation period and rollback conditions are defined. |
For gaps, first check whether PI or another archive can fill them. Do not claim that extending OPC DA polling has filled historical gaps. Expand points in batches and retain each batch's verification results. Decommissioning the old system requires separate approval after the observation period and business verification.
9. Troubleshooting and Rollback
| Symptom | Check order and next action |
|---|---|
| Interactive reads work but the service task fails | Check the actual agent service identity, COM/DCOM, and source authorization. Follow OPC DA Connection Troubleshooting. |
| Mapping report is incomplete | Check count limits, failed branches, and permissions. Narrow the scope and recollect. Do not treat partial success as complete coverage. |
| Address count differs from target count | Check one-to-many relationships and batch manifests. Do not remove targets arbitrarily. |
| New tables appear or existing tables receive no new values | Stop expanding the scope. Check the target database, templates, and explicit column names. Do not delete historical tables and retry. |
| Quality differs from history | Compare the original status set, interface parameters, and category-conversion boundaries. Confirm business semantics first rather than simply replacing a constant. |
| Digital values contain NULL and -1 | Check unknown codes, dictionary coverage, and value types. Retain raw values for diagnosis. Do not fill with a default valid status. |
| Time gap between historical and real-time data | Check the cutoff, source time, cached values, and retained archives. Record ranges that cannot be backfilled. |
If the pilot fails, retain the old link. Stop new tasks or restore the approved configuration, and let the responsible owner decide whether to roll back. Retain configuration, point lists, reports, logs, and written data. Do not delete targets without confirmation. If a supporting mapping tool or finer-grained quality continuity is needed, contact official support to confirm the delivered version and implementation plan. A supporting tool does not mean business verification is complete.