tamaki.mes.backup.compare
The configuration-backup comparison engine. Given two MES configuration backups: as produced by
system.mes.util.backup() or uploaded as a ZIP: these functions identify which entities were added,
removed, or changed between them, and turn the result into Ignition datasets for display.
Entities are matched by their key fields (for example a location is identified by its path). The
package defines two module-level constants:
recognizedFileNames: the JSON file names produced inside a configuration-backup ZIP (e.g.locations.json,materials.json,oeeModes.json).entityTypesToKeyFields: maps each entity type to the field(s) that uniquely identify it.
A typical flow is:
- Extract the JSON from each backup with
extractJsonFromZiporextractJsonFromBytes. - Compare the two with
compareEntityLists. - Turn the result into datasets with
resultsToDataSets.
Class
ResultRow
Represents a single change (an entity or field that was added, removed, or updated).
Extraction
extractJsonFromZip
Extracts the JSON files from an uploaded ZIP (Perspective File Upload component).
extractJsonFromBytes
Extracts the JSON files from a backup ZIP supplied as a byte array.
Comparison
compareEntityLists
Compares two dictionaries of entity lists and reports added/removed/updated entities per entity type.
genericCompareEntities
Compares two lists of entities of one type, matching by key fields.
compareEntityFields
Compares two entities field by field, reporting removed, added, and changed fields.
equalValues
Compares two scalar values for equality, treating close numbers as equal.
isClose
Returns whether two numbers are within a relative/absolute tolerance.
getKey
Builds a unique string key from an entity's key-field values.
getKeyFields
Returns the key field names for a given entity type.
Flattening
flattenEntities
Flattens all nested structures (the orchestrator for the functions below).
flattenLocations
Lifts location property values into their own list.
flattenMaterials
Lifts material property values into their own list.
flattenDashboardWidgets
Lifts dashboard widget parameters into their own list.
flattenProductionOrders
Lifts production-order property values and bills of materials into their own lists.
Output
createSummaryDataSet
Builds the summary dataset of change counts per entity type.
resultsToDataSets
Builds the summary and per-entity-type detail datasets from a comparison result.