A method for automatically rendering DCS screens into real-time database screens
By using multi-format parsing technology and virtual graphics device interfaces, real-time database screens are automatically drawn, solving the problem of graphics interoperability between DCS systems and real-time database systems. This enables efficient and accurate screen migration and dynamic logic inheritance, improving the maintenance efficiency and user experience of industrial monitoring systems.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NINGBO EASTSEA LINEFAN TECH CO LTD
- Filing Date
- 2026-02-13
- Publication Date
- 2026-05-05
AI Technical Summary
In the automation systems of process industries such as petrochemicals and power, there is a lack of a common graphical interoperability interface between DCS systems and real-time database systems. This results in low efficiency, high error rate, and inconsistent styles when manually drawing real-time database screens, making it difficult to meet the requirements of industrial monitoring systems for screen accuracy and maintenance efficiency.
By employing multi-format parsing technology to be compatible with heterogeneous DCS source files, capturing drawing instructions through the virtual graphics device interface, and combining document object model traversal, discrete static geometric flow and dynamic logic data are extracted. An affine transformation matrix is constructed to achieve coordinate normalization, and the control script is reconstructed using an abstract syntax tree. Combined with spatial grid indexing and geometric feature recognition technology, pipeline topology is automatically repaired, and finally, a monitoring screen file conforming to real-time database standards is generated.
It enables cross-vendor and cross-hardware platform migration of screen data, shortens the construction cycle of real-time database screens, ensures the accuracy of primitive spatial positions and the complete inheritance of dynamic interaction logic, reduces maintenance costs, and improves the delivery quality of screens and the consistency of user experience.
Smart Images

Figure CN121722396B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer graphics processing technology, specifically a method for automatically rendering DCS screens into real-time database screens. Background Technology
[0002] In the construction of automation systems in process industries such as petrochemicals and power, distributed control systems (DCS) are typically built first to ensure real-time control of the production units at the lower levels. Real-time database systems are then built to enable long-term storage, trend analysis, and remote production monitoring of historical data across the entire plant. To maintain consistency in operator visual perception and reduce the learning cost of cross-system operations, the front-end monitoring screen of the real-time database system usually needs to highly replicate the process flow diagram interface of the DCS system, including pipeline layout, equipment element styles, and dynamic data display positions.
[0003] However, since DCS systems and real-time database systems are usually developed by different vendors, their underlying graphics engine kernels, file storage formats (such as the difference between proprietary binary streams and XML text), and primitive attribute definitions (such as coordinate system origin, rendering level, and event response mechanism) are often heterogeneous, resulting in a lack of a common graphics interoperability interface between the two.
[0004] Current technologies for constructing real-time database displays generally employ a manual redrawing approach. Engineers must visually inspect the DCS screen within the real-time database's graphical configuration environment, manually constructing static backgrounds using basic drawing tools such as lines, rectangles, ellipses, and polygons, and then binding data measurement points one by one. This manual-intervention-dependent graphical construction method has significant technical drawbacks: For large devices containing numerous complex topologies and dynamic primitives, manual redrawing involves massive amounts of repetitive labor, causing system deployment cycles to lag significantly behind production needs. Furthermore, due to the lack of precise coordinate mapping and attribute conversion algorithms, manual drawing is prone to introducing positional deviations, primitive omissions, or style distortions, resulting in inconsistencies between the real-time database screen and the original DCS screen in terms of visual appearance and data display logic. In addition, when the DCS system undergoes screen changes due to process adjustments, the lack of an automated synchronization update mechanism often leads to extensive troubleshooting and rework, failing to meet the stringent requirements of industrial monitoring systems for screen accuracy and maintenance efficiency. Summary of the Invention
[0005] To address the shortcomings of existing technologies, this invention provides a method for automatically drawing DCS screens into real-time database screens. This method operates on a computer device that includes a processor, memory, and communication interface, aiming to solve the problems of low efficiency, error-proneness, and inconsistent styles in manual drawing of real-time database screens in existing technologies.
[0006] This invention utilizes multi-format parsing technology to be compatible with heterogeneous DCS source files, intercepts drawing commands using a virtual graphics device interface, and extracts discrete static geometric flows and dynamic logical data by combining document object model traversal. Coordinate normalization is achieved by constructing an affine transformation matrix, and the control script is reconstructed using an abstract syntax tree. Furthermore, this invention introduces spatial grid indexing and geometric feature recognition technology to achieve primitive clustering, and combines cost-based endpoint snapping and orthogonal routing algorithms to repair pipeline topology, ultimately generating monitoring screen files that conform to real-time database standards.
[0007] The method in this embodiment operates on a computer device that includes a processor, memory, and a communication interface. The processor executes instructions in the memory to achieve heterogeneous reconstruction from the DCS screen to the real-time database screen.
[0008] This invention first identifies the DCS source file format. For source files using publicly available text formats such as Extensible Markup Language (XML), Hypertext Markup Language (HTML), and JavaScript Object Notation (JSON), a traversal parsing method based on the Document Object Model (DOM) is employed. The system loads the source file into memory to construct a DOM tree, and maps the hierarchical structure into a flattened list of discrete nodes using depth-first traversal. During the traversal, a global transformation matrix stack is maintained. When entering a group of nodes, the local matrix is calculated and pushed onto the stack; when exiting, the node is popped from the stack. For primitive nodes, the relative coordinates are converted to absolute coordinates relative to the origin using the matrix at the top of the stack.
[0009] For DCS source files using proprietary binary encoding or encrypted formats, this invention employs a command stream interception method based on the Virtual Graphics Device Interface (GDI). The principle is to establish a virtual printing channel at the operating system layer to capture the drawing command stream (such as EMF or Page Description Language) output by the DCS software. The system reads the header of the drawing command stream and extracts the device resolution parameters and the coordinates of the upper left corner of the effective drawing area. Based on this, an inverse affine transformation model is constructed, and using the resolution scaling factor and translation components, the device coordinates are restored to logical coordinates, thereby eliminating coordinate distortion introduced by the virtual printing process.
[0010] During the parsing process, the system performs noise filtering based on geometric feature thresholds, removing invalid primitives whose size or transparency is below preset values. Simultaneously, it separates text data based on naming rules, extracting text nodes that conform to the tag naming rules into the dynamic logical data, while the rest remain in the static geometric data.
[0011] The system constructs a two-dimensional affine transformation matrix to map static geometric data to the target Cartesian coordinate system. First, it calculates the effective bounding box and origin offset of the source image, and then calculates the normalized scaling factor and translation vector based on the target image configuration. If the vertical axis definitions of the source and target coordinate systems are opposite (e.g., physical coordinate system and screen raster coordinate system), a negative vertical scaling factor is set in the scaling matrix. The system converts the geometric vertex coordinates of discrete primitives to homogeneous coordinates and multiplies them by the affine transformation matrix to complete a full remapping. For dynamic logical data, the same matrix is used to update its anchor point coordinates, and a local inverse mirror transformation is performed on text objects to prevent text inversion caused by global flipping.
[0012] To address the issue of redundant and uneven polyline primitive nodes in DCS (Distributed Control System) images, the system reconstructs curves from static geometric data. First, the Douglas-Peucker algorithm is used to traverse the polyline feature points, calculating the perpendicular distance from each feature point to the line connecting the beginning and end points, and eliminating redundant points smaller than the geometric error tolerance (e.g., 0.5 pixels). Then, a cubic Bézier curve is fitted to the retained feature point sequence using the least squares method. By minimizing the sum of squared distances from the sampling points to the curve using an objective function, the optimal control points are calculated, and the polyline is reconstructed into a vector curve path.
[0013] The system performs lexical analysis on the extracted control script, using regular expression matching and a deterministic finite automaton (DFA) to identify keywords, identifiers, and operators, generating a token stream. Subsequently, it performs syntax analysis based on context-free grammar rules, identifying conditional branches, loops, and function call logic, and constructing an abstract syntax tree (AST). In the logic mapping phase, the system loads a mapping dictionary between the source and target languages. It traverses the AST using the visitor pattern, mapping DCS-specific function nodes to standard library calls in the target language and inserting type casting nodes. For bit-signal read / write operations, the system replaces them with key-value pair queries based on cached snapshots, avoiding compatibility issues caused by direct memory addressing. Finally, the system compiles the corrected AST into the target script (such as JavaScript) and injects a runtime context object containing simulated system variables, enabling cross-platform, non-blocking execution of the logic.
[0014] To efficiently process massive amounts of graphic elements, the system constructs a spatial hash grid index. It statistically analyzes the distribution of geometric bounding box sizes for each element, calculates the side length of a baseline cell (based on the geometric mean of the width and height of all elements), and then calculates the axis-aligned bounding box for each element, determining the range of grid cell indices it covers, and constructs a hash dictionary.
[0015] Using this index, the system performs primitive clustering and recombination. The system constructs a topological feature vector by counting the number of line segments, arcs, and polygon vertices of discrete primitives, and generates geometric feature identifiers by combining these with the serialized hash values of normalized vertex data. Within the grid neighborhood, it retrieves sets of primitives with the same feature identifiers and semantically related bit names, aggregating them to generate composite symbol objects. Simultaneously, based on a globally unique identifier, the corresponding AST is attached to the event-driven interface of the composite object.
[0016] The system calculates the edge anchor points of composite icon objects and performs snap-in repair and route correction on pipeline primitives. First, the baseline anchor points defined by the composite object are mapped to effective anchor points in the world coordinate system using transformation parameters. The Euclidean distance between the pipeline endpoint and surrounding anchor points is calculated, and candidate anchor points with distances less than a threshold are selected. A weighted cost function is used to evaluate the optimal snap-in target, which comprehensively considers the Euclidean distance between the candidate anchor point and the endpoint, and the angle between the drawing direction and the anchor point's normal vector. The anchor point with the smallest cost function value is selected to correct the pipeline endpoint coordinates.
[0017] After adsorption is complete, orthogonal route correction is performed on the inclined pipeline. If the pipeline is inclined, the initial route direction is locked based on the device port normal vector associated with the endpoints (horizontal or vertical priority), and orthogonal inflection points are calculated and inserted using the Manhattan distance algorithm. At the same time, the inflection points are aligned and corrected according to the global device center coordinate set, reconstructing the inclined pipeline into an orthogonal polyline that conforms to the process specifications.
[0018] According to the real-time database display format requirements, the system instantiates a data structure skeleton in memory, including a metadata area, a graphical object area, and a script code area. It traverses the reconstructed composite symbols and pipeline objects, converting their geometric attributes, appearance attributes, and topological relationships into structured descriptive text and writing it into the graphical object area. The code generator is then invoked to compile the mapped and corrected AST into a target source code string, which is written into the script code area. During serialization, the system performs precision quantization on floating-point coordinates to compress the file size and calculates the checksum between the structured text and the source code string, writing it into the metadata area. Finally, the output is packaged as a monitoring screen file, completing the automatic rendering from the DCS screen to the real-time database screen.
[0019] This invention provides a method for automatically rendering DCS screens into real-time database screens. It has the following beneficial effects:
[0020] 1. This invention intercepts the underlying rendering command stream by establishing a virtual printing channel and combines it with a multimodal parsing strategy, enabling compatibility with publicly available text formats such as HTML and XML, as well as proprietary binary formats of DCS source files. This data acquisition method based on intercepting underlying commands effectively avoids parsing obstacles caused by the non-disclosure or encrypted storage of proprietary file formats by DCS vendors, ensuring the complete extraction of geometric primitives, text annotations, and dynamic logic data in the source image, thereby achieving cross-vendor and cross-hardware platform image data migration.
[0021] 2. This invention utilizes an affine transformation matrix to normalize the coordinates of primitives and employs an automatic snap-in and orthogonal routing algorithm based on spatial semantics to automatically repair the topology connections between pipelines and device ports. This technical feature replaces traditional manual drawing and alignment operations, shortening the construction cycle of real-time database images. Simultaneously, mathematical calculations ensure the accuracy of primitive spatial positions, avoiding common problems in manual drawing such as disconnections, scale misalignment, and positional deviations, thus improving the quality of delivered images.
[0022] 3. This invention converts the proprietary control scripts of the DCS system into a universal standard script format by constructing an abstract syntax tree, and establishes a dynamic mapping relationship between primitive attributes and real-time data tag numbers. This mechanism ensures that screen migration is not limited to the replication of static appearance, but also achieves the complete inheritance of dynamic interaction logic and data response behavior. This allows the generated real-time database screen to accurately reproduce the monitoring functions of the original DCS system, ensuring the consistency of the operation experience for maintenance personnel across different systems and reducing subsequent maintenance costs. Attached Figure Description
[0023] Figure 1 This is a schematic diagram illustrating the process from the DCS screen to the real-time database screen according to the present invention.
[0024] Figure 2 This is a schematic diagram comparing the frame rate performance of image rendering under simulated high-concurrency data burst conditions according to the present invention.
[0025] Figure 3 This is a schematic diagram of the geometric smoothing reconstruction process of pipeline primitives based on key feature point extraction according to the present invention. Detailed Implementation
[0026] The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0027] The method in this embodiment operates on a computer device (such as a personal computer, server, etc.) that includes a processor, memory, and communication interface. The processor executes instructions in the memory to achieve heterogeneous reconstruction from the DCS screen to the real-time database screen. This method does not rely on specific DCS hardware and completes the screen migration solely through software-level data processing. The system logical architecture includes a multimodal parsing module, an intermediate vector model construction module, a semantic reconstruction core module, and an output interface adaptation module, which are respectively responsible for source format adaptation, coordinate / script difference elimination, discrete data objectification restoration, and target screen generation.
[0028] Please see the appendix Figure 1 A method for automatically rendering DCS screens into real-time database screens includes the following steps:
[0029] S10, DCS Source Data Acquisition and Multimodal Parsing. Source file format identification: For public text formats such as HTML, XML, and JSON, traverse the node tree to extract primitive attributes; for private binary or encrypted formats, intercept the underlying rendering instruction stream and reverse-parse it into discrete geometry and text nodes. The final output is an independent data stream containing static geometric attributes and dynamic logical information.
[0030] S20, Intermediate Vector Model Establishment and Coordinate Normalization. A two-dimensional affine transformation matrix is constructed to perform translation, scaling, and rotation transformations on the node coordinates in the static geometric flow, eliminating the differences between the source and target images in resolution, measurement units, and origin definition, and mapping all primitives to a unified standard Cartesian coordinate system.
[0031] S30, Construction of the Abstract Syntax Tree (AST) for Dynamic Logic. Lexical analysis is performed on the DCS control script to extract bitmaps and logical operators, transforming the private script into a language-independent AST. This tree structure contains conditions, data sources, and action nodes, used to describe the logical relationships between graphical attributes and data changes.
[0032] S40, Spatial Clustering and Semantic Object Reconstruction. Geometric nodes are indexed using a spatial hash grid. Matching sets are searched within the grid neighborhood based on preset feature fingerprints, and verified using the positional semantics in the AST. After successful verification, discrete nodes are reassembled into composite symbol objects with business attributes, and the AST logic is attached to the object attribute slots.
[0033] S50, Pipeline Topology Adaptive Repair. The edge anchor points of the reconstructed object are calculated, and the Euclidean distance between the pipeline endpoint and the anchor point is detected. If the distance is less than a threshold, forced snapping is performed. Subsequently, an orthogonal routing algorithm is applied to insert vertices into inclined pipelines to ensure that the path conforms to horizontal or vertical orthogonal constraints.
[0034] S60 handles object instantiation and persistent storage. It calls the real-time database API to draw background, pipeline, and device objects hierarchically. Simultaneously, it compiles the mounted AST logic into a script format supported by the target system and injects it into event response functions, generating interactive real-time monitoring screen files.
[0035] See attached document Figure 2 For DCS source files using publicly available text formats such as Extensible Markup Language (XML), Hypertext Markup Language (HTML), and JavaScript Object Representation (JavaScript Object Model), this embodiment employs a traversal parsing method based on the Document Object Model (DOM). The principle is to map the hierarchical tree structure into a flattened list of discrete nodes, eliminating nested levels through recursive traversal, thereby extracting independent geometric and logical data. The specific parsing strategy includes the following steps:
[0036] S110, File Format Feature Recognition and Parsing Environment Initialization. The system reads the header byte stream of the DCS source file and determines the encoding format by matching it with a preset binary signature or root node tag. For example, if the root node is an SVG tag, it is recognized as SVG format; if it conforms to JSON syntax, it is recognized as JSON format. Based on this, the system loads the corresponding parsing library and constructs a document object model or object structure in memory. Simultaneously, it loads a preset external mapping configuration file, which defines the mapping relationship between source tag names and target system primitive types, serving as the basis for subsequent recognition.
[0037] S120, Node traversal and geometric attribute standardization based on matrix stack. The system performs a depth-first traversal of the DOM tree. To break down the nested hierarchical structure into a flattened set of discrete nodes, the system maintains a global transformation matrix stack during the traversal. When traversing into a group of nodes, the system reads the local transformation parameters defined for that group, constructs a local transformation matrix, multiplies it with the matrix at the top of the stack, and pushes the result onto the top of the stack as the new current transformation matrix. When exiting the group of nodes, a pop operation is performed to restore the previous level transformation matrix. When traversing child nodes, the system determines whether they belong to valid primitives based on the external mapping configuration file. Undefined tag nodes are only treated as containers. For valid primitive nodes, the system uses the current transformation matrix at the top of the stack to calculate the relative coordinates of the node, obtaining the absolute coordinates relative to the canvas origin. Subsequently, the system parses the geometric attribute fields and performs standardization processing: for path data of lines or polygons, it parses them into floating-point coordinate arrays using a string splitting algorithm; for color descriptions, it identifies hexadecimal, index, or naming formats and converts them into standard RGBA four-channel values using a lookup table or bitwise operations; for size data, it removes physical unit suffixes and converts all length values into dimensionless pixel values according to the default resolution.
[0038] S130, Dynamic Logical Attribute Stripping and Global Index Association. When traversing primitive nodes, the system maintains a list of dynamic attribute keywords containing data binding or script feature keys. If a node attribute matches this list, the corresponding value is extracted as the dynamic logical flow. To ensure a one-to-one correspondence between geometry and logic, the system generates a globally unique identifier and establishes an index association between the static geometric data extracted in S120 and the dynamic logical data in this step. This step eliminates the influence of source file reference relationships on coordinate normalization and outputs a set of discrete nodes with absolute coordinates and traceable logic.
[0039] For DCS source files that use proprietary binary encoding, are encrypted, or whose document structure cannot be directly parsed, this embodiment employs an instruction stream interception method based on the Virtual Graphics Device Interface (GDI). Its principle leverages the characteristics of the operating system's graphics rendering pipeline; that is, when DCS software prints or draws, it decomposes high-level objects into low-level primitive instructions. This method bypasses the cracking of proprietary encryption algorithms by taking over this process and obtaining the decoded, standardized vector stream. Specifically, the rendering stream interception and reverse parsing strategy includes the following steps:
[0040] S140, Virtual Print Channel Establishment and Command Stream Capture. The system registers a virtual print driver at the operating system level or intercepts print spooling services via API hooks. When the DCS software outputs a screen, the system captures the Enhanced Metafile (EMF) or Page Description Language (Page Description Language) data stream sent to the driver. The system allocates a buffer in memory to serialize and store the captured stream. This data stream consists of a series of variable-length record structures, each containing record type, size, and parameter payload, forming a complete vector drawing instruction set.
[0041] S150, Reverse Decoding of Graphical Instructions and Reconstruction of Geometric Primitives. The system sequentially traverses the record sequence in the memory buffer, identifying the instruction function based on the record type field. For instructions identifying geometric drawing (such as drawing lines, polygons, and circles), the system extracts vertex data from the parameter payload. The coordinates obtained at this time are device coordinates based on the printing device's pixel space, which are affected by the printing resolution (DPI) and page margins and cannot be directly used for reconstructing the real-time database screen. Therefore, the system first parses the header record of the instruction stream to extract the device resolution. (Unit: dots per inch), physical page size, and rectangular boundaries of the effective drawing area. ),in, This represents the x-coordinate of the left boundary of the effective drawing area in the global page coordinate system. This represents the ordinate value of the top boundary of the effective drawing area in the global page coordinate system. This represents the x-coordinate of the right boundary of the effective drawing area in the global page coordinate system. This represents the ordinate value of the bottom boundary of the effective drawing area in the global page coordinate system.
[0042] Based on the above parameters, the system constructs the inverse affine transformation matrix. Set device coordinates Restore to logical coordinates The transformation model is as follows: ; where the inverse transformation matrix Defined as:
[0043] ;
[0044] In the above formula: This represents the resolution scaling factor, determined by the ratio of the device resolution to the standard logical resolution. This represents the page margin offset, specifically the coordinates of the top-left corner of the effective drawing area. The system applies this formula to normalize the coordinate values in all geometric commands, eliminating coordinate distortion introduced during virtual printing.
[0045] S160 is a text fragment fusion algorithm based on font size adaptation. During parsing, the system encounters text fragmentation issues caused by underlying driver optimizations, where a complete string is broken down into multiple independent character drawing instructions. To restore the original semantic logic, the system executes a text fusion algorithm based on spatial neighborhood. The system first extracts font measurement information from the text drawing instructions to obtain the height of the current character. and width Set the horizontal merging threshold. and vertical alignment threshold The value range is set to , To accommodate text of different font sizes.
[0046] The system iterates through all text fragments and calculates adjacent fragments. and The spatial relationship. If the following conditions are met:
[0047] and ;
[0048] in For fragments The starting coordinates, This is the actual rendering width. When the above inequality holds, the system determines that the two fragments belong to the same string, performs a string concatenation operation, and updates the geometric properties of the text object with the bounding rectangle of the merged object. Finally, the system outputs the recombined collection of text objects as the basic data source for dynamic logic analysis.
[0049] After obtaining a mixed node set containing discrete geometry and text fragments, this embodiment employs a classification algorithm based on geometric feature thresholding and regular semantic matching. Its principle leverages the characteristics of industrial visuals, where background primitives are represented by static geometric shapes, and business data is represented by text conforming to naming conventions. Through feature separation, the mixed data stream is decoupled into a static geometric stream for constructing the base map and a dynamic logical stream for driving interaction.
[0050] In practice, the data stream classification and cleaning strategy includes the following steps:
[0051] S170, noise primitive filtering based on geometric attribute thresholds. The system traverses the mixed node set, identifying and removing invalid primitives generated during the parsing process. These primitives mainly originate from auxiliary drawing reference lines in the DCS source file, invisible logical control layers, or sub-pixel artifacts caused by coordinate floating-point conversion precision errors during virtual printing. The system filters arbitrary geometric nodes. Perform a validity check. If the following criteria are met, mark it as noise and physically remove it from the set:
[0052] ;
[0053] In the above formula: These represent the width and height of the bounding box of the geometric node, respectively; This represents the size filtering threshold, which is set according to the resolution (DPI) of the target image. The value range is usually set to [1,3] pixels, which means removing tiny spots that cannot be recognized by the human eye at normal viewing distances. The transparency channel value (normalized range [0,1]) represents the fill color or border color of the node. This is the transparency threshold, typically set to 0.05, which removes objects that are visually nearly completely transparent. In addition, the system also checks line width; line objects with a width less than 0.5 pixels and a color value identical to the canvas background color are also considered redundant data.
[0054] S180 is a text stream splitting system based on regular expression semantic matching. The system performs semantic content analysis on all text type nodes in the set to distinguish between static text used as background annotations and dynamic text representing business tag numbers. The system loads a configurable external rule file containing a tag number naming rule library for different DCS vendors. The rule library consists of several regular expression patterns. Composition. For any text node content The system sequentially performs matching operations against patterns in the rule base. If a match is successful, the system determines that the node belongs to a dynamic logic flow, separates it from the geometry rendering layer, and extracts its text string as a tag identifier. and the geometric center coordinates of the text node As spatial anchors for logical objects, they are stored in the dynamic logic flow collection. If a match fails, the node is determined to be a static label and its position is retained in the static geometry flow set. In the middle, it will be drawn uniformly as a background graphic layer.
[0055] S190, Logical Script Cleaning and Format Standardization. For the raw strings containing script code extracted in steps S140 or S160, and the tag string extracted in step S180, the system performs syntax cleaning. Due to the proprietary differences in script syntax across different DCS systems, the system uses a character segmenter to parse the strings. The system identifies specific delimiters and removes redundant system-level prefixes based on a pre-defined list of vendor prefixes. The system extracts the core tag names and logical comparison operators, reorganizing them into a standard data structure in key-value pair form. For example, the original proprietary script is cleaned into a standardized object {Tag:TIC101,Field:PV,Op:>,Threshold:50}. After this step, the system outputs a clean set of static geometric flows. With structured dynamic logic flow sets This completed the cleaning and preparation of raw, messy data into standard intermediate data.
[0056] Before establishing the intermediate vector model, this embodiment first quantitatively analyzes the spatial definition differences between the heterogeneous DCS source screen and the target real-time database screen. The principle is based on viewport mapping technology in computer graphics, that is, by calculating the linear transformation parameters from the source device coordinate system to the target logical coordinate system, the relative positions, topology, and aspect ratios of the primitives are strictly maintained without distortion when the source screen is projected onto the target canvas. Specifically, the coordinate system difference analysis strategy includes the following steps:
[0057] S210, Calculation of Effective Boundaries and Attribute Recognition in Source Coordinate Space. To address the possibility of missing or infinitely large canvas definitions in the source file header, the system employs an adaptive boundary detection mechanism based on full node traversal. The system traverses the static geometric flow set. For all coordinate points, update the extreme values of the horizontal and vertical coordinates point by point to determine the axis-aligned bounding box. The system then establishes the width and height of this bounding box as the effective width of the source image. and effective height And mark the coordinates of the bottom left (or top left) corner of the bounding box as the offset of the source logic origin. Simultaneously, the system detects the mapping mode field in the source file's metadata. If it identifies that the source coordinate system is a Cartesian coordinate system (Y-axis increases upwards) while the target Web coordinate system is a screen raster coordinate system (Y-axis increases downwards), it will vertically flip the identifier. Set to true.
[0058] S220, Target Coordinate Space Definition and Unit Standardization. The system defines the width of the target canvas based on the display standard configuration of the real-time database monitoring system. With height For cases where some DCS source files use physical units of measurement, the system performs unit normalization. The system reads the resolution attribute (DPI) of the source device, multiplies all length values recorded in physical units by a resolution factor, and converts them into dimensionless logical pixel units (px) supported by the target system, thus eliminating differences in measurement standards.
[0059] S230, Global Affine Transformation Parameter Calculation. Core parameters are calculated based on the source and target spatial definitions. To ensure complete display of the source image, the system selects the smaller of the aspect ratios of the target and source as the globally uniform scaling factor. Based on this, calculate the centering translation compensation vector. Horizontal component It is obtained by subtracting the x-coordinate of the scaled source origin from half the width difference between the target and the scaled source image. For the vertical component... ,like If false, calculate the logical level component; if If true, since the Y-axis is reversed, coordinate axis reversal compensation needs to be introduced to map the source origin to the corresponding position of the target to ensure vertical centering. This quantifies the differences in heterogeneous spaces and outputs a defined set of transformation parameters.
[0060] After obtaining the spatial difference transformation parameter set, this embodiment uses matrix operations based on homogeneous coordinates to construct a normalized affine transformation matrix. The principle is to introduce a third-dimensional virtual coordinate to transform two-dimensional nonlinear transformations (such as translation) into linear matrix multiplication. This method allows composite operations such as scaling, rotation, and translation to be combined into a single matrix, thereby ensuring the consistency and efficiency of processing massive amounts of primitives. Specifically, the matrix construction strategy includes the following steps:
[0061] S240, Generation of the normalized transformation matrix. The system reads the globally uniform scaling factor calculated in step S230. Horizontal components Vertical component and vertical flip identifier The system constructs a globally unique affine transformation matrix based on these parameters. This matrix defines a one-time, full mapping from the source device space to the target logical space. If... If false, it indicates that the source coordinate system and the target coordinate system are aligned, and the matrix is configured as a standard scaling and translation matrix; if A value of `true` indicates the existence of a coordinate axis mirroring relationship. The system sets the scaling factor in the vertical direction to a negative value to achieve geometric flipping of the Y-axis. Affine transformation matrix. The general mathematical definition is as follows:
[0062] ;
[0063] In the above formula, when When it is false, ;when When true, .
[0064] S250, full remapping of static geometric flows. The system remaps the set of static geometric flows. Perform a traversal operation to transform the affine transformation matrix. Spatial attributes applied to each geometric node in the set. For primitives defined by point coordinates (such as the vertex sequence of a polygon, the endpoints of a line), the system converts them into the form of... The homogeneous coordinate vectors are then multiplied on the left by the affine transformation matrix. The transformed target coordinates are obtained. For complex path-type primitives, the system performs a regular expression-based instruction separation operation, decomposing the path description string (d attribute) into drawing instruction characters (such as M, L, C) and a sequence of numerical parameters. The system performs matrix transformations only on the coordinate pairs in the numerical sequence, while keeping the drawing instruction characters unchanged, and then reassembles them into a path descriptor conforming to the SVG standard. Furthermore, for scalar attributes not defined by point coordinates, including the radius of a circle, the width and height of a rectangle, and the stroke width of a line, the system directly multiplies their values by a globally uniform scaling factor. To maintain the proportional scaling properties of the geometry.
[0065] S260, Dynamic Logic Flow Anchor Point Correction and Attitude Compensation. The system performs dynamic logic flow set... Perform spatial location correction. For each logical node, the system extracts the coordinates of its logical center anchor point recorded in step S10, and uses an affine transformation matrix. Calculate the new target anchor point coordinates. These new coordinates will serve as the positioning reference for dynamic components (such as numerical display boxes and level bar charts) in the real-time database screen. Specifically, when... When true, the global transformation matrix contains a vertical flip component, which can cause the text content attached to the logical node to appear mirrored. To address this, after calculating the target anchor point coordinates, the system applies a local vertical mirror inverse transformation to the logical node, i.e., flipping the Y-axis again in the node's local coordinate system. This counteracts the impact of the global flip on text readability, ensuring that the text content is always displayed horizontally and correctly relative to the screen. Through these steps, the system completes the overall migration from the source's private coordinate data to the target's standard Web coordinate data.
[0066] After the aforementioned affine transformation, the static geometric flow set G achieves spatial uniformity but still retains the original characteristics of the source file. Common DCS software often uses high-density short line segments to approximate pipes or connecting lines to reduce early hardware overhead, resulting in large nodes and a lack of smoothness. This embodiment uses discrete point denoising and parametric curve fitting algorithms to reconstruct redundant line segments into concise vector curves and uniformly convert non-standard primitives into Web standard path descriptions. Specifically, the curve fitting and standardization strategy includes the following steps:
[0067] S270, Discrete point set thinning and topological simplification. Systematic traversal of the static geometric flow set. The system identifies polyline nodes. For polyline objects containing numerous continuous small line segments, the system uses the Douglas-Peucker algorithm to extract feature points. Its principle lies in setting a vertical distance threshold. (Typically 0.5 to 1.0 pixels), based on subpixel rendering limits, it eliminates minute geometric jitter imperceptible to the human eye. The system connects the beginning and end points of the polyline to construct a baseline, and calculates the perpendicular distance from the midpoint to the baseline: if the distance is greater than... If a vertex is found to be non-existent, it is retained; otherwise, it is considered redundant and discarded. The system recursively executes this process, reducing the vertex data size while maintaining the geometric contours.
[0068] S280, Third-order Bézier curve fitting. This involves the simplified key feature point sequence from step S270. The system performs a smooth fitting operation. To construct the fitting equation, the system first performs chord length parameterization, calculating the value for each feature point. Corresponding parameter values :
[0069] ;
[0070] After obtaining the parameter correspondence, the system is constructed based on control points. , Let be the objective function with unknowns. The standard cubic Bézier curve equation is defined as:
[0071] ;
[0072] in, , Each is fixed as the starting point of the line segment. and termination point The system uses the least squares method to solve the linear equations, such that the sum of the squared distances from all sampling points to the curve is equal to the sum of the squared distances. Minimize, and thus calculate the optimal control point. and Ultimately, the system replaces the original polyline data with a vector curve description containing only four control points, and forces the tangent vectors between adjacent curve segments to be collinear to ensure that the connections are secure. Geometric continuity.
[0073] S290, Heterogeneous Primitive Path Encapsulation. DCS source files often contain non-standard geometric primitives, such as chords, pie charts, or arcs, which lack direct corresponding primitive tags in HTML5 or SVG standards. The system executes a geometric transformation algorithm to uniformly encapsulate these heterogeneous primitives into generic path description data. Specifically, the system extracts the geometric definition parameters of DCS primitives, including the center coordinates. Major and minor axis radii Starting angle and scanning angle The system uses trigonometric functions to calculate the absolute starting coordinates of the path. coordinates of the endpoint :
[0074] ;
[0075] Based on the calculated endpoint coordinates, the system constructs a path data sequence conforming to the SVG specification. First, a Move To command is generated to locate the endpoint. Then, the Elliptical Arc command is applied. This command includes a radius parameter. X-axis rotation angle, according to The large arc flag is determined by its size, the sweep flag is determined by the drawing direction, and the final endpoint coordinates are also specified. The system replaces the original geometry definitions with the generated normalized path strings and updates the static geometry flow set with the processed nodes. In this process, cross-platform rendering engine compatibility is achieved.
[0076] After completing the static geometric flow reconstruction, this embodiment processes the business scripts in the dynamic logic flow set. Since the original DCS system uses a proprietary scripting language to describe clicks, visibility, and color changes, it cannot be directly executed in a standard web environment. This step, as the front end of the compilation engine, is responsible for converting the unstructured character stream into a sequence of discrete lexical units (tokens) with syntactic meaning, laying the foundation for syntax tree construction. Specifically, the script lexical analysis and tokenization strategy includes the following steps:
[0077] S310, Script preprocessing and character stream normalization. Traversing the dynamic logic stream set. The logical nodes read the original script string. A character buffer is established to eliminate interference from non-semantic characters. Uniform formatting is performed to address syntax differences: newline characters are converted to standard newline characters; VB-style single quotes and C-style line and block comments are removed. A partitioning strategy is implemented when handling case sensitivity: string literals enclosed in quotes are preserved intact to maintain display correctness; for code outside these regions, if the source language is case-insensitive, they are uniformly converted to lowercase to ensure consistent keyword matching.
[0078] S320, Constructing a domain-specific finite state automaton. To accurately identify identifiers, keywords, operators, and literals, the system constructs a deterministic finite automaton (DFA). For the specific naming conventions of industrial control, this embodiment extends the DFA state transition logic, pre-setting regular identifier and extended tag state. When the automaton enters the identifier state, if a hyphen (-) or a period (.) is encountered, unlike the conventional approach of identifying it as an operator and truncating the token, the system checks the subsequent character based on a greedy matching strategy. If the subsequent character is still a number or letter and not in an arithmetic context, the automaton remains in the identifier state, treating the symbol as part of the tag name (e.g., recognizing TIC-101.PV as a single token); reduction operations are only performed when encountering spaces, parentheses, or explicit terminal symbols.
[0079] S330, Maximum Match Strategy and Token Stream Generation. Based on the constructed DFA model, the system scans the preprocessed character stream. The system maintains a current scan pointer and a lookahead pointer, following the Maximum Match Principle, which consumes as many characters as possible until no valid match can be found. When the automaton recognizes a complete semantic segment, it generates a standard Token object. :
[0080] ;
[0081] In the above formula: The categories of lexical units are identified, including KEYWORDs for process control (such as IF, THEN), OPERATORs for logical calculations (such as >, =, 8<), LITERALs representing numerical or string constants, IDENTIFIERs for regular variables, and the industrial tag type DCS_TAG unique to this invention. The system stores the original string fragment; `Line` and `Col` record the row and column positions of this unit in the source code for subsequent error tracking. Specifically, for character sequences that cannot be explicitly categorized using DFA rules, the system performs a secondary check by querying a pre-built vendor-reserved word dictionary. If it still cannot be identified, it is marked as UNKNOWN and a warning log is recorded, but the overall scanning process is not interrupted, ensuring that some non-critical script errors do not affect the overall screen conversion process. After this step, the original script string is converted into a structured token sequence and sent to the next stage, the syntax analysis module.
[0082] After converting the unstructured script code into a linear token stream, this embodiment further assembles these discrete lexical units into an Abstract Syntax Tree (AST) with hierarchical logical relationships. This step is based on Context-Free Grammar (CFG), which uses a recursive descent analysis algorithm to identify nested structures and computational priorities in the code, thereby transforming a flat sequence of symbols into a tree-like data structure that a computer can traverse and execute.
[0083] In practice, the syntax tree generation logic includes the following steps:
[0084] S340, Syntax Rule Definition and Production Rule Construction. The system pre-configures a set of DCS script syntax rules, clearly defining legal statement patterns. For conditional logic, a conditional statement (IfStmt) structure is defined: consisting of the IF keyword, a logical expression, an execution block led by THEN, an optional ELSE block, and ENDIF. For tag attributes, tag access rules (TagPropertyAccess) are defined: consisting of a tag identifier (TagIdentifier), a dot (DOT), and a property field (PropertyField) concatenated, used to resolve data references such as FIC101.PV. Furthermore, a recursive expression structure covering logic, arithmetic, and atoms is defined, supporting multi-level nested operations.
[0085] S350, Recursive Descent Parsing and AST Node Construction. The system instantiates a syntax parser and uses a cursor pointing to the token stream to match the syntax rules defined in step S340 from top to bottom. During parsing, operator precedence analysis and node instantiation are performed simultaneously. To handle mixed operations, the system predefines an operator precedence threshold table; when a high-precedence binary operator is encountered, the lower-level parsing function is recursively called to construct the right subtree, ensuring that high-precedence operations are at a deeper level in the syntax tree. Whenever a complete syntactic unit is matched, an AST node object is constructed, which contains a node type (NodeType), a list of child nodes (Children), and a set of attributes (Attributes). In particular, for DCS_TAG type tokens, the system instantiates a dedicated TagReference node, stores the tag information in the attribute set, and marks it as a dynamic data source, thereby completing the pre-embedding of data anchors.
[0086] S360 employs error recovery based on a synchronization symbol set. If the token stream does not match the expected syntax rules during parsing, the system triggers a synchronization recovery strategy. When a syntax error is encountered, the parser enters a panic recovery state, continuously discarding subsequent tokens until a predefined synchronization token is encountered. The system sets statement terminators (such as semicolons) or block structure terminators (such as ENDIF and NEXT) as synchronization symbols. This mechanism ensures that even if the source script contains non-critical syntax errors, the parser can bypass the error region, realign the legal structure, and continue parsing subsequent code to generate the most complete possible syntax tree, avoiding task interruption due to a single point of failure.
[0087] After generating the Abstract Syntax Tree (AST), the system converts the DCS private logic into standardized ECMAScript (JavaScript) code that can be executed by the browser. The core challenge lies in the difference in execution mechanisms: traditional DCS scripts often read hardware registers in a synchronous blocking manner, while web browsers use a single-threaded event loop, and blocking can cause stuttering. Therefore, this embodiment not only performs syntax translation but also constructs a non-blocking simulation runtime environment based on state snapshots. Specifically, the cross-platform logic mapping strategy includes the following steps:
[0088] S370, Syntax Tree Traversal and Type Correction Based on the Visitor Pattern. The system uses the visitor pattern to perform a depth-first traversal of the generated AST. The system instantiates a code generator object containing node processing functions. When a specific node is visited, a code string is generated according to the target language specification. Addressing the weakly typed nature of DCS scripts, the system performs type inference and correction during traversal. For example, when visiting a binary expression node, if the operator is an arithmetic operation, the system automatically inserts a type conversion function (such as Number()) to force the operand to be converted to a number, preventing the + sign from being misinterpreted as string concatenation, thus eliminating logical ambiguity caused by implicit type conversion.
[0089] S380, Semantic Guided Translation and Standard Code Generation. Based on the principles of semantic guided translation, the system maps AST nodes to target code fragments. When processing control flow, the system refactors BASIC-style conditional statements and loop structures into C-style code blocks. For the core tag data binding logic (TagReference), the system abandons direct memory addressing and converts it into a query call to the front-end real-time data cache. This conversion adopts a read-write separation architecture: the underlying layer asynchronously receives real-time data and updates the cache snapshot via WebSocket, and the generated script only synchronously reads the latest values from the snapshot through key-value pairs. This ensures that script execution does not involve network I / O waiting, achieving non-blocking execution of the rendering logic. Furthermore, for DCS integer color indexes, the system uses a pre-built color palette configuration table to map the index to standard RGB or hexadecimal CSS strings, ensuring consistent color reproduction.
[0090] S390 uses runtime sandboxing and context injection. To prevent variable conflicts with the global namespace and simulate the DCS environment, the system encapsulates generated code within an independent closure scope. The system constructs a runtime context object as a parameter to inject into the encapsulated function. This object simulates original DCS system variables (such as time and user) and proxies system-level functions (such as window opening and alarms). Context attributes are exposed as local variables using scope extension techniques (such as with statements or proxy mechanisms), allowing code to access simulated resources without modifying reference paths. Finally, the encapsulated function is serialized and stored in the target web configuration, compiled and executed on demand when the page loads, thus reproducing the original control logic in the web environment.
[0091] After standardizing and mapping the image data, this embodiment addresses the rendering and interaction bottlenecks caused by the high density of image primitives in industrial scenes by constructing a two-dimensional grid index structure based on spatial hashing. The principle is to discretize continuous floating-point coordinates into integer cells, and establish a direct association between location and object through hash mapping, reducing the complexity of image retrieval from a linear level. Reduced to near constant level This supports high-frequency interaction detection. In practice, the index construction strategy includes the following steps:
[0092] S410, Dynamic Calculation of Grid Cell Size. To balance memory usage and retrieval efficiency, the system needs to determine the optimal side length of the grid cell. This size is determined based on the statistical distribution characteristics of the current screen's primitive density: if the cell size is too small, a single primitive will span too many grids, causing the index table memory to expand; if the cell size is too large, a single grid will contain too many primitives, causing local retrieval to degenerate into linear traversal. The system traverses all primitive nodes in the current screen, statistically analyzes the size distribution of their geometric bounding boxes, and calculates the baseline cell side length according to the following formula. :
[0093] ;
[0094] In the above formula: This represents the total number of graphic elements in the image. and The first The width and height of each graphic element; This refers to the mesh density tuning factor. The preferred value range is 1.5 to 3.0. Its physical meaning is to ensure that the grid size is slightly larger than the average size of the primitives, so that most primitives only cover 1 to 4 cells in space, thereby achieving the optimal balance between reducing index redundancy and reducing the number of collision detections.
[0095] S420, Primitive Axis-Aligned Bounding Box Generation. The system calculates the axis-aligned bounding box (AABB) for each primitive object to be indexed. Since some primitives have undergone affine transformations such as rotation, scaling, or translation in previous steps, the system no longer uses the originally defined width and height. Instead, it calculates the spatial extrema of the transformed vertices in the world coordinate system based on the transformation matrix. The system extracts the coordinates of the four corner points of the transformed primitive, compares their x and y coordinate components, and selects the one with the smallest x coordinate. Minimum y-coordinate Maximum x-coordinate and the maximum ordinate This allows us to construct a minimum rectangular region that can completely enclose the primitive, serving as the geometric reference for subsequent spatial mapping.
[0096] S430, Grid Mapping and Hash Inverted Index Construction. Using the geometric reference obtained in step S420, the system quantizes continuous screen pixel coordinates into discrete grid row and column numbers to determine the specific location of the primitive in the spatial index. First, the system calculates the cell index range covered by the primitive:
[0097] ;
[0098] ;
[0099] In the above formula: This indicates the floor function; These represent the grid integer indices in the horizontal and vertical directions, respectively. After obtaining the coverage area, the system iterates through every cell within the coverage area. The system then performs an index insertion operation. To avoid hash collisions between different coordinates (e.g., coordinates 1,11 and 11,1, which would both result in 111 if directly concatenated), the system uses a string construction strategy with delimiters (e.g., concatenating u + "_" + v) or a high-order bitwise shift operation strategy to generate unique hash keys. The system constructs a global hash dictionary, appending the unique identifier of each element to the element list corresponding to all covered cells, forming an inverted index structure between the grid and the element list. This means that an element ID will be redundantly stored under the key values of all the grids it covers. During interactive detection, the system only needs to calculate the unique grid key value based on the mouse coordinates to directly retrieve the small set of candidate elements contained in that grid from the dictionary, without traversing the entire scene graph, thus achieving efficient spatial clipping.
[0100] After establishing the spatial index, to further optimize rendering performance, this embodiment introduces an instantiation rendering technique based on geometry reuse, targeting the characteristics of numerous repetitive primitive components (such as standardized valves, pumps, and motors) in the DCS screen. The core of this technique lies in identifying sets of primitives with the same structure but different positions, scales, or rotations in the screen, extracting them as shared templates, thereby merging numerous independent draw calls into a single batch drawing. To this end, the system needs to define a feature fingerprint that can uniquely identify the primitive topology and geometry. In specific implementation, the definition and extraction strategy of the feature fingerprint template includes the following steps:
[0101] S440, initial screening of topological feature vectors. The system performs topological structure analysis on each composite graphic object or basic graphic element in the image, generating a topological feature vector describing its composition. This vector ignores specific coordinate values and only focuses on the constituent components of the graphic element, serving as a coarse-grained classification filter to quickly remove obviously dissimilar graphic elements. For any graphic element object... The system counts the number of straight line segments it contains. Number of arcs Number of polygon vertices and the number of text tags Construct topological feature vectors :
[0102] ;
[0103] The system uses this vector to perform preliminary clustering of primitives. Only when the topological feature vectors of two primitives are completely equal will they proceed to the subsequent high-precision geometric fingerprint comparison stage, thereby significantly reducing floating-point operation overhead.
[0104] S450, Translation and Scale Normalization of Local Coordinates. To identify isomorphic primitives with different locations and scaling ratios (i.e., to achieve translation and scaling invariance), the system must transform the geometric data of the primitives from the absolute world coordinate system to a normalized unit local coordinate system. First, the system traverses all primitives to be processed. For each vertex, calculate its geometric centroid. :
[0105] ;
[0106] Subsequently, in order to eliminate the influence of size differences, the system calculates the maximum bounding radius of the primitives. That is, the maximum Euclidean distance from all vertices to the centroid. The system for each vertex... Perform translation and scaling transformations to obtain normalized coordinates. :
[0107] ;
[0108] This step ensures that, regardless of the location or size of the original primitives on the screen, their normalized vertex data is mapped to a unit circle centered at the origin (0,0) with a maximum radius of 1. This makes large-sized feed valves and small-sized discharge valves mathematically equivalent, providing a normalized geometric benchmark for subsequent template merging.
[0109] S460, Fingerprint hash calculation and template instantiation mapping. The system serializes the normalized geometric data from step S450 into a string stream. To ensure fingerprint determinism and eliminate vertex order differences, the vertices are normalized and sorted before serialization (e.g., rearranged according to lexicographical coordinate order); quantization precision is also introduced. (Preferred range 10) -4 Up to 10 -5 To tolerate floating-point errors, the system then employs a non-cryptographic hash algorithm (such as FNV-1a) to serialize the string. Perform calculations to generate characteristic fingerprints. The system queries the global template dictionary: If If the template does not exist, a new template will be registered; if it exists, an instantiated object will be created. This object only records the template reference index and unique transformation properties (the centroid position of the translation parameters). Maximum bounding radius of scaling parameters (Including the rotation angle and color attributes of primitives). This mechanism reconstructs large scenes into shared templates and lightweight instances, reducing memory usage and improving rendering efficiency.
[0110] In the preceding steps, the system has constructed an Abstract Syntax Tree (AST) describing business behaviors and a geometric instance template describing visual morphology. To enable static graphical elements to respond to real-time changes in industrial data and provide feedback on interactive operations, this embodiment establishes a bidirectional semantic mapping relationship between geometric objects and logic scripts. This process aims to build a data-driven rendering pipeline, ensuring that fluctuations in underlying data can accurately and with low latency drive updates to specific instance attributes in video memory, while user input can be accurately routed to the corresponding logic controller.
[0111] In practice, the semantic fusion strategy of geometry and logic includes the following steps:
[0112] S470 constructs a reactive dependency graph. The system traverses primitive objects and extracts the bound dynamic script logic. For each primitive instance, the system parses the associated AST nodes, identifying the tag variables (Tags) as input sources and the target visual attributes (such as background color and fill rate) as outputs. The system establishes a global dependency dictionary based on a publish-subscribe pattern: using the unique tag identifier as the index key, and the key value is a list of affected primitive information. The list items record the primitive's unique index ID in the rendering array, the target visual attribute type, and the handle of the attribute calculation function generated based on the AST. Through this graph, the system establishes a direct logical index between industrial data points and the memory addresses of the rendering pipeline, eliminating the need to traverse the entire scene graph when data is updated.
[0113] S480 updates attribute mapping based on interleaved instance buffers. Upon receiving real-time data pushes, the system triggers calculations based on the S470 dependency graph. To avoid the overhead of full reconstruction, the system maintains a typed array mapped to GPU memory, using an interleaved layout to store instance parameters. After obtaining new attribute values, the system first performs normalization: color attributes map 0-255 integer / RGB values to 0.0-1.0 floating-point numbers; rotation attributes convert angles to radians. Subsequently, the system calculates the memory write address and writes the data by multiplying the instance index by the total byte step size and adding the attribute offset. This step achieves low overhead for result transfer by directly manipulating the memory view.
[0114] S490, Reverse Event Routing Based on Spatial Index. Besides data-driven graphics, the system also needs to handle the reverse interaction from graphics to logic. When a user performs a click or hover operation, the system captures screen coordinates and uses the spatial hash grid index from step S430 to quickly filter out the set of candidate primitives within the grid where the coordinates are located. Then, a precise geometric hit test is performed on the candidate primitives: regular graphics are determined using algebraic methods; irregular polygons are determined using a ray casting algorithm to determine if a point is within the contour. After determining a unique hit primitive, its ID is used to reverse-search for the associated event script in the runtime context; if it exists, an event object containing mouse state and modifier keys is constructed, and together with the runtime context, the script sandbox is injected to trigger business logic, achieving semantic reverse parsing from geometric spatial location to the business logic entry point.
[0115] In industrial DCS screen reconstruction or automatic wiring, accurately identifying the external connection locations of equipment elements (such as valves, tanks, etc.) is a prerequisite for pipeline snapping and routing planning. Since elements may undergo arbitrary rotation, scaling, or mirror transformations, a single bounding box center cannot represent the specific interface location. This embodiment dynamically calculates the effective anchor point set and its tangential normal vector in the world coordinate system by analyzing the geometric transformation matrix and combining it with standard port definitions. The specific calculation strategy includes the following steps:
[0116] S510, Anchor point definition in local geometry. The system first defines candidate anchor points in the device's local coordinate system where no transformation has occurred. For most standard industrial equipment, the connection ports are typically located at the edge center of the geometric profile. The system uses the width defined in the primitive's original definition. and height Four sets of reference anchor points are defined: top midpoint, bottom midpoint, left midpoint, and right midpoint. Each anchor point contains not only its local coordinate position relative to the center of the primitive, but also a unit normal vector indicating the direction of material feeding or discharging. For example, for the right midpoint anchor point, its local coordinates... and normal vector Defined as:
[0117] ;
[0118] Here, the origin of the local coordinate system is defined at the geometric center of the primitive, with the positive X-axis pointing to the right and the positive Y-axis pointing downwards. For custom primitives with irregular shapes, the system parses the anchor point descriptors in their metadata and extracts the predefined relative coordinate data of the connection points.
[0119] S520, world coordinate mapping based on affine transformation. To obtain the actual connection position of the device on the current canvas, the system needs to map the local anchor points defined in S510 to the world coordinate system. This process must comprehensively consider the scaling, rotation, and translation states of the primitives in the scene. The system obtains the center coordinates of the current device primitive. Horizontal and vertical scaling factors and rotation angle (In radians, clockwise is positive). For each candidate anchor point, the system constructs a composite affine transformation matrix to convert its local coordinates to world coordinates. To fully disclose the technical details, the calculation process is expressed as follows:
[0120] ;
[0121] The above equation clearly shows that the system first performs scaling on the local coordinates, then rotation, and finally superimposes the translation, thus ensuring that regardless of how the primitive is stretched or rotated, the calculated anchor point always precisely fits the visual edge of the primitive. Simultaneously, to guide the routing direction of subsequent pipelines, the system needs to transform the normal vector of the anchor point. Since vectors are translation-invariant, and to maintain the purity of direction, the system only applies rotation transformation to the normal vector (ignoring the effects of translation and scaling on the modulus), calculating the unit normal vector in world space. :
[0122] ;
[0123] S530 employs spatial semantic-based anchor point validity filtering. Calculated geometric anchor points are filtered in conjunction with the spatial environment and business logic. The system utilizes a spatial hash grid index constructed by S430 to detect the existence of non-connected primitives (such as obstacles) within the neighborhood centered on the anchor point coordinates; if a collision exists, it is marked as a blockage. Furthermore, the system performs semantic filtering based on fluid flow direction rules. For example, for a one-way valve, the dot product of the anchor point normal vector and the preset flow direction vector is calculated: if the result is negative (i.e., facing the flow), it is determined to be an inlet; if it is positive, it is an outlet. The final set of valid anchor points is stored in the device runtime attributes as input to the automatic routing algorithm.
[0124] To address the difficulties of manual alignment and topology breakage caused by non-coincident connection points during pipeline drawing or editing, this embodiment designs an automatic snapping algorithm based on multi-dimensional weighted cost evaluation. Its principle is as follows: a local detection field is constructed in real time as the cursor moves; by quantifying the matching degree between the cursor and surrounding device anchor points in terms of spatial distance and geometric orientation, the pipeline endpoints are automatically corrected to the optimal port positions, thereby ensuring the accuracy of the topology where what you see is what you connect. In specific implementation, the algorithm execution strategy includes the following steps:
[0125] S540, candidate anchor point filtering based on adaptive threshold. When the system detects that the pipeline drawing tool is active and the cursor has moved, it obtains the real-time position of the cursor in the world coordinate system. To avoid unnecessary traversal of the entire scene data, the system utilizes the spatial hash grid index established in step S430 to quickly retrieve all primitives within a rectangular area centered on the cursor and with a preset snap-in radius as its side length. To ensure a consistent user experience across different view zoom levels, the system uses a screen physical pixel threshold (e.g., 15 pixels) divided by the current view's zoom level. Dynamically calculate the adsorption activation threshold in the world coordinate system The system iterates through the retrieved graphic element anchor points and calculates the relationship between the cursor and each anchor point. Euclidean distance between .like Less than or equal to Then add the anchor point to the candidate set. .
[0126] S550, a distance- and direction-weighted cost evaluation. When the candidate set... When multiple anchor points exist, the system needs to determine the unique optimal adsorption target. This embodiment employs a weighted cost function. To evaluate the matching quality, the system first determines whether the currently drawn node is the start point of the pipeline or a subsequent node. If it is the start point, the system only uses Euclidean distance. Sort the nodes and select the nearest anchor point; if it is a subsequent node, the system obtains the normalized drawing direction vector of the current pipeline segment. (i.e., the unit vector pointing from the previous node to the current cursor), and obtain the anchor point. unit outward normal vector The system calculates the comprehensive matching cost for each candidate anchor point using the following formula:
[0127] ;
[0128] In the above formula: This is the distance weighting coefficient. The directional weighting coefficient (preferred value range is...) ,and );item A direction penalty term is constructed using the properties of vector dot product: when the drawing direction is 180 degrees to the port normal (i.e., facing each other, the dot product is -1), this term is 0, minimizing the cost; when the two directions are the same or perpendicular, the cost increases. The system iterates through and calculates all candidate anchor points. The value is used to select the anchor point with the minimum cost as the final adsorption target. .
[0129] S560, coordinate forced correction and topology attribute binding. Once the final adsorption target is determined. The system performs the snapping operation synchronously in the rendering and logic layers. In the rendering layer, the system ignores the actual physical coordinates of the mouse cursor and sets the coordinates of the current endpoint of the pipeline. The system forcibly updates the coordinates to the world coordinates of the target anchor point and triggers visual highlighting. At the logic layer, the system reads the device primitive ID and port index number to which the target anchor point belongs, and points the connection attributes (such as ToNodeID and ToPortIndex) in the pipeline data object to that device. This step ensures that the pipeline visually fits precisely to the device edge, while simultaneously establishing reliable graph-theoretic connections in the data structure, providing an accurate topological foundation for subsequent fluid connectivity analysis.
[0130] In industrial process flow diagram drawing standards, to ensure image clarity and topology readability, pipeline routes are restricted to orthogonal horizontal or vertical forms. To address the issue of handling arbitrary diagonal lines and corners generated during freehand drawing, this embodiment proposes an orthogonal route correction algorithm based on constraint propagation. The principle is as follows: the continuous mouse trajectory is discretized into a set of alternating horizontal and vertical polylines, and based on the starting port normal vector constraint and global alignment reference line, necessary orthogonal inflection points are automatically derived and inserted to achieve automated pipeline path regularization. In specific implementation, the orthogonal route correction execution strategy includes the following steps:
[0131] S570, based on port constraints and initial direction locking of the displacement-dominant axis. When the user starts from a predetermined starting point... Drag out a new pipeline branch, and the current cursor position is... At this time, the system executes a two-level direction determination logic. The first level is a strong constraint determination: the system checks whether the starting point originates from the device port acquired in the previous step. If a port association exists, the intrinsic unit normal vector of that port is read. .like (i.e., horizontal opening), the system forcibly locks the routing mode to horizontal priority to ensure that the pipeline exit direction is collinear with the port normal; if If the starting point is a free point (without port constraints), then vertical priority will be forcibly locked. The second level is a weak constraint judgment: if the starting point is a free point (without port constraints), the system calculates the offset of the cursor relative to the starting point. and The routing mode is dynamically set based on the dominant axis tendency:
[0132] ;
[0133] S580, orthogonal inflection point interpolation calculation. After determining the routing mode, the system does not directly connect the starting point to the current cursor point, but instead calculates and inserts an intermediate orthogonal inflection point according to the L-shaped routing rules. The system calculates the inflection point coordinates using the component combination method based on the mode determined in step S570. When in horizontal priority mode, this means the first path segment must extend along the X-axis; therefore, the inflection point inherits the Y-coordinate of the starting point and the X-coordinate of the cursor point. When in vertical priority mode, the first path segment extends along the Y-axis, and the inflection points inherit the X coordinates of the starting point and the Y coordinates of the cursor point. The system draws line segments in real time at the rendering layer. and line segments A preview of the composed polyline. This mechanism ensures that the pipeline always maintains an orthogonal topology consisting of horizontal and vertical line segments, regardless of how the cursor moves.
[0134] S590, Global Reference Line Assisted Alignment. To facilitate users in accurately aligning pipelines to the center of distant equipment or other parallel pipelines, the system introduces a snap-in alignment mechanism based on a global coordinate set. The system maintains two globally ordered sets: a horizontal reference set... and vertical reference set . Stores the center point of all devices, ports, and existing horizontal pipeline segments within the current viewport. coordinate; Store the corresponding Coordinates. In calculation Before reaching its final position, the system first sets an alignment adsorption threshold. This threshold is related to the current view zoom level. Inversely proportional (e.g.) Taking X-axis alignment as an example, the system traverses the collection. Calculate the cursor's x-coordinate With each reference value in the set The absolute value of the difference. If there exists a reference value that satisfies the judgment condition. If the alignment is successful, the system will determine that the cursor's free coordinates are correct. Force replacement with the coordinates of this reference line Simultaneously, the system draws dashed auxiliary lines passing through the reference coordinates on the interface, providing clear visual feedback to the user. This step enables users to quickly draw regular pipelines that are strictly aligned with other distant primitives in the image, achieving automated constraints from local orthogonality to global standardization.
[0135] In complex industrial configuration scenes, there are strict occlusion relationships between primitives. For example, pipes must be located above the background grid, while dynamic data labels must float above pipes and equipment primitives. To ensure the visual accuracy of the rendering results and optimize the redraw performance of each frame, this embodiment adopts a layered rendering architecture combined with a deterministic depth sorting algorithm to manage all visible objects in the scene in an orderly manner.
[0136] In practice, the execution strategy for rendering hierarchy management includes the following steps:
[0137] S610 constructs a layered rendering queue. The system divides primitives into different logical layers based on their business attributes, rather than storing them in a flat array. During initialization, the system predefines a set of layers with a fixed rendering order and assigns a unique layer index value (LayerIndex). These typically include: a bottom background layer (LayerIndex=0, used for meshes and static basemaps), a main device layer (LayerIndex=1, used for pipes, valves, and containers), a dynamic data layer (LayerIndex=2, used for real-time values and dashboard pointers), and a top interactive layer (LayerIndex=3, used for checkboxes and hover tools). The system maintains a layer mapping table to assign primitives to the corresponding queues. This structure clearly defines the absolute occlusion relationship between layers; that is, higher-indexed layers automatically cover lower-indexed layers without requiring cross-layer comparisons.
[0138] S620 uses stable sorting for intra-layer depth calculation. Within the same logical layer (such as the master device layer), there are also occlusion requirements between primitives. The system assigns a user-adjustable depth attribute to each primitive object. (Integer type). To solve To address the rendering flickering issue caused by identical elements, the system employs a stable sorting strategy based on combined weights. The system defines the comparison weight calculation logic, compressing multi-dimensional sorting conditions into one-dimensional scalar values. When the system traverses the rendering queue for sorting, it calculates the value for each primitive object according to the following formula. sorting weight :
[0139] ;
[0140] In the above formula: This represents the current layer depth value of the primitive; The displacement factor set for the system must be strictly greater than the maximum number of primitives allowed by the system (e.g., 10⁶ or 10⁷) to ensure that the depth value dominates the weight calculation. A globally unique, monotonically increasing sequence number automatically assigned by the system when a primitive is created. The system uses this sequence number as a basis for calculation. The rendering queue is sorted in ascending order, implementing a deterministic painter algorithm: primitives with lower weights are drawn first, and primitives with higher weights are drawn later and overwrite the former. This mechanism ensures that even when the depth is the same, the drawing order strictly depends on the creation order, avoiding randomness.
[0141] S630 employs offscreen buffer compositing based on dirty flags. To reduce overhead, the system distinguishes between static and dynamic primitives. For static geometry that does not change over time (such as the background and main device layer), an offscreen canvas technique is introduced for pre-rendering: a bitmap buffer with the same resolution as the viewport is created, and a boolean dirty flag is maintained. During the rendering loop, if the dirty flag is true (i.e., primitive changes or viewport scaling), the buffer is cleared, and the static primitives sorted by S620 are rasterized and drawn to it, then the flag is reset to false; if it is false, the buffer is reused directly. During final compositing, offscreen data is drawn to the bottom layer of the screen through texture copying, and then dynamic primitives are overlaid. This step optimizes the repeated drawing of static primitives into a single copy, ensuring a high frame rate for high-load scenes.
[0142] To achieve deep integration between graphic attributes and underlying business data in industrial visuals, enabling graphic elements to execute complex dynamic logic (such as color flashing, position movement, and visibility switching) as their real-time tag numbers change, this embodiment constructs a lightweight script engine based on an Abstract Syntax Tree (AST). This engine is responsible for parsing business logic expressions into structured data and compiling them into high-performance executable functions, ensuring execution safety through a scope isolation mechanism. Specifically, the execution strategy for AST logic injection and script compilation includes the following steps:
[0143] S640, Lexical Analysis and Syntax Tree Construction. Upon receiving a script string containing graph primitive attributes, the system initiates the lexical analyzer, which segments the character stream into discrete lexical units (Tokens) containing identifiers, operators, literals, and delimiters according to predetermined rules. Subsequently, the parser consumes lexical units based on a recursive descent algorithm, constructing a tree-like AST structure Troot, where leaf nodes represent variables or constants, and non-leaf nodes represent computational logic. This step transforms unstructured text into a traversable graph theory structure, laying the foundation for subsequent variable binding.
[0144] S650 employs proxy-based context injection and variable resolution. To enable scripts to access real-time industrial data, the system traverses the Abstract Syntax Tree (AST) to extract all nodes of type identifier, constructing a set of dependency variables. To provide specific numerical values during script execution and prevent unauthorized access, the system constructs a runtime context object based on the Proxy Pattern. This object intercepts all read operations (Get Trap) of variables by the script. When the script attempts to read a variable... When the system resolves the value, it follows the priority formula below. :
[0145] ;
[0146] In the above formula: Cache a dictionary for real-time data; This is a security whitelist that the system allows access to (including mathematical function libraries, preset color constants, etc.). If variables... For real-time data, the system automatically performs type standardization, converting strings into floating-point numbers to support mathematical operations; if a variable is neither in the data dictionary nor in the whitelist, the system returns undefined or throws a security exception, thus achieving complete isolation from the global environment (such as the host browser's Window object).
[0147] S660, JIT (Just-In-Time) compilation and exception boundary protection. To avoid the performance overhead of repeatedly parsing the AST (Abstract Syntax Tree) during each frame rendering, the system employs JIT compilation technology. The system uses a code generator to traverse the AST and convert it into a string representing the native function body of the host language. Subsequently, the system uses a function constructor to encapsulate this string into an independent executable function. To ensure the stability of the industrial monitoring system, exception handling logic is wrapped around the generated function body. During the rendering loop of each frame, the system calls... And transmitted If a division by zero, type error, or logical overflow occurs during execution, the exception handling module will catch the error, prevent the rendering thread from crashing, and automatically return the preset default value of the attribute as a safe fallback. The final calculated attribute value is directly applied to the rendering nodes of the scene graph, achieving high-frequency and safe data-driven rendering.
[0148] To save the complex industrial configuration screens (including equipment elements, pipeline topology, script logic, and configuration parameters) built on the front end in a transmittable and reusable format, this embodiment designs a JSON-based serialization storage scheme. The principle is to convert the heterogeneous object graph containing runtime states in memory into a standardized text stream, utilizing precision quantization and redundancy removal mechanisms to reduce the size while preserving complete data, facilitating distribution in industrial networks with limited bandwidth. In specific implementation, the persistent storage execution strategy includes the following steps:
[0149] S670, recursive serialization and topological index persistence of the scene graph. Because runtime objects contain a large amount of temporary state that does not need to be persisted, the system does not directly dump memory objects, but instead performs a depth-first traversal (DFS) algorithm to scan the scene graph nodes. During traversal, the system checks and generates persistent unique identifiers (UUIDs) conforming to the RFC4122 standard for unallocated nodes, ensuring that they remain unchanged throughout the file's lifecycle. Subsequently, key configuration data is extracted based on a preset attribute whitelist. For reference primitives such as pipelines, the in-degree and out-degree object pointers of their connections are converted to UUID strings for storage. This UUID-based soft reference mechanism ensures that the topology connections can be accurately reconstructed through table lookups during deserialization loading, avoiding connection loss due to changes in memory addresses.
[0150] S680, Floating-Point Precision Quantization and Data Compression. In industrial configuration screens, element coordinates and dimensions are typically stored in memory as double-precision floating-point numbers (IEEE 754 Standard). However, for the visual presentation of the human-machine interface, it is not necessary to retain the tiny precision of more than ten decimal places. To further compress data volume, the system introduces a coordinate quantization algorithm during serialization. The system sets a quantization precision index. (The value is usually set to 2, i.e., rounded to two decimal places, because a deviation of 0.01 pixels is invisible to the naked eye at standard screen resolutions.) The system reads the raw geometric attribute values. The cutoff value for storage is calculated using the following formula. :
[0151] ;
[0152] In the above formula: This indicates a rounding down operation; the +0.5 coefficient is used to implement the rounding logic. This step converts long floating-point numbers such as 100.123456789 to 100.12, reducing character usage by approximately 40% to 60% while ensuring that the visual positional deviation is less than one physical pixel, thus improving file parsing efficiency.
[0153] S690, Integrity Verification and Metadata Encapsulation. The serialized entity data block (payload) is encapsulated into a standard file for version management. The system constructs a proprietary structure including a header, which records the protocol version, timestamp, and canvas configuration. To prevent transmission errors or malicious tampering, the system performs integrity verification: the JSON string is concatenated with a built-in obfuscation salt, a hash signature is generated using the SHA-256 algorithm, and written to the end of the file. During loading, the hash is recalculated and compared; if they do not match, loading is rejected and an alert is triggered, thus ensuring data security and reliability.
[0154] This embodiment is applied to the control system upgrade project of a 300MW thermal power plant. The original DCS system of the plant used a proprietary binary format for storage, and a single main steam flow diagram contained more than 2,000 discrete primitives. The goal was to reconstruct it into a real-time web monitoring screen that supports the HTML5 standard. The system first performs reverse parsing and coordinate reconstruction of the DCS source data. For the intercepted DCS print command stream, the system identifies the device resolution. The DPI is set to 600, while the target screen's logical resolution is set to 96 DPI, and the page margin offset is set to... , Pixels. Based on the inverse affine transformation formula in step S150, the system first calculates the resolution scaling factor. Then construct the inverse transformation matrix. Its main diagonal element is 1 / 6.25 = 0.16, and the translation component is -100. This is for the device coordinates of a key electric valve in the command flow. Substitute the system into the formula The calculation yields a result of 200 pixels; similarly... The calculated value is 400 pixels. Through this calculation, the system successfully and accurately mapped the physical coordinates, which were distorted by printing, to logical coordinates (200, 400) on the Web canvas, achieving basic alignment in the heterogeneous space.
[0155] After completing the basic coordinate mapping, the system performs a smooth reconstruction of the numerous coarse pipeline primitives in the image, which are fitted from short line segments. Please refer to the appendix. Figure 3 In the image, the gray dots represent the original polyline after coordinate reconstruction. The system first applies the Douglas-Peucker algorithm in step S270 to remove redundant jitter points with a vertical distance of less than 0.5 pixels, extracting the key feature points shown by the black squares in the image. Subsequently, in order to achieve the smooth visual effect shown by the thick black solid line in the figure, the system applies the cubic Bézier curve equation defined in step S280. The system uses the least squares method based on feature point sequences. Inverse control point solution , This minimizes the distance deviation between the fitted curve and the original feature points. This process reconstructs the jagged polyline, which originally contained dozens of vertices, into a vector curve that only requires four control points to describe it. While ensuring that the geometry of the main steam pipe remains unchanged, it improves the smoothness and rendering performance of the image when scaling on the web.
[0156] To address the interaction response latency issue in environments with massive amounts of graphical elements, the system constructs a spatial hash grid index according to steps S410 and S430. The system first calculates the average size of all graphical elements within the screen, and then uses the formula... Set density coefficient The optimal mesh side length is calculated. Pixels. For the aforementioned electric valve primitive with coordinates (200, 400), the system uses the hash mapping formula... The system registers the object in the memory bucket corresponding to hash key 4_8. When the operator hovers the mouse over the coordinates (205, 405), the system instantly locates the object in bucket 4_8 using the same integer division operation. It only needs to perform collision detection on the original 3 primitives in the bucket, without having to traverse all 2000 objects in the entire graph, thus achieving millisecond-level hover highlight response.
[0157] During the secondary editing stage of the image, when the engineer draws a new pipeline, the system triggers the automatic snapping algorithm in step S550 to ensure the accuracy of the topology connection. Assume there are two candidate anchor points around the cursor: anchor point A is a distance from the cursor... Pixels but vertical orientation ( Anchor point B distance Pixels but orientation is correct The system sets an adsorption threshold. Distance weight Directional weights According to the cost function An evaluation is conducted. The cost of anchor point A is calculated as follows: The cost of anchor point B is calculated as follows: .because The system determines that although anchor point B is slightly farther away, its geometric semantics better conform to the connection rules, and therefore forces the pipeline endpoint to snap to anchor point B. This mechanism effectively avoids the false connection problem common in traditional drawing.
[0158] Ultimately, the system-generated visuals underwent stress testing with high-concurrency data. Please refer to the appendix. Figure 2 This figure illustrates the rendering frame rate performance when 1200 analog quantity changes are concurrently pushed from the background under a simulated boiler MFT (Main Fuel Trip) condition. The solid line in the figure represents the method of this embodiment, which, thanks to the reactive dependency graph established in step S470 and the JIT (Just-In-Time) compilation technology in step S660, updates attributes by directly manipulating the video memory mapping array, ensuring the frame rate remains stable at around 60 FPS even during data bursts. In contrast, the dashed line in the figure represents the traditional DOM manipulation scheme that does not employ this method, where the frame rate drops below 30 FPS during data bursts due to triggering large-scale document reflow. This comparison verifies the efficiency and stability of this embodiment when processing complex industrial configuration screens.
Claims
1. A method for automatically rendering a DCS screen into a real-time database screen, characterized in that, Includes the following steps: The DCS source file is parsed to extract the static geometric flow containing discrete primitives and the dynamic logic flow containing control scripts. The discrete primitives include pipeline primitives. Construct an affine transformation matrix and normalize the coordinates of the discrete primitives, mapping the discrete primitives to the target Cartesian coordinate system; The control script is analyzed to construct an abstract syntax tree; Using spatial grid index clustering and position number semantics, the discrete primitives are reorganized into composite symbol objects and attached to the abstract syntax tree; Calculate the edge anchor points of the composite symbol object, perform endpoint snapping repair based on the edge anchor points on the pipeline primitive, and perform orthogonal route correction on the pipeline primitive in the tilted state. Update the geometric path coordinate data of the pipeline primitive according to the repair and correction results. According to the real-time database screen format requirements, the static layout of the screen is reconstructed using the updated geometric path coordinate data and the reconstructed composite graphic object. The abstract syntax tree is compiled into a target script and injected into the graphic event attributes corresponding to the static layout of the screen to generate a real-time database screen file.
2. The method for automatically drawing a DCS screen into a real-time database screen according to claim 1, characterized in that, The DCS source files include DCS source files in private binary or encrypted formats and DCS source files in public text formats. The step of parsing the DCS source file and extracting the static geometric flow containing discrete primitives, specifically the step of obtaining the drawing command flow using a virtual graphics device interface interception method for the proprietary binary or encrypted DCS source file, includes: A virtual printing channel is established at the operating system level to capture the drawing instruction stream output by the DCS software; Read the header binary data segment of the drawing instruction stream, and extract the device resolution parameters and the coordinates of the top left corner vertex of the effective drawing area defined in the header binary data segment; The scaling factor is calculated using the ratio of the device resolution parameter to the preset logical resolution, and the inverted value of the coordinates of the top left corner vertex is used as the translation component to construct a translation vector. The scaling factor and the translation vector are combined to generate an inverse affine transformation matrix. The device coordinates in the drawing instruction stream are restored to logical coordinates using the inverse affine transformation matrix to obtain the discrete primitives, and the static geometric flow is formed by the discrete primitives.
3. The method for automatically drawing a DCS screen into a real-time database screen according to claim 1, characterized in that, The DCS source files include DCS source files in publicly available text format; For the publicly available text-formatted DCS source file, the step of parsing the DCS source file and extracting the dynamic logic flow containing the control script, using a document object model traversal method, specifically includes: The DCS source file is loaded into the memory parser to construct the document object model tree, and the transformation matrix stack containing the identity matrix is initialized. Perform a depth-first traversal of the nodes contained in the document object model tree to identify the type of the current node; If the current node is identified as a group node, calculate the local matrix and push it onto the transformation matrix stack. After traversing all child nodes within the group node, perform a pop operation. If the current node is identified as a primitive node, the relative coordinates of the primitive node are converted to absolute coordinates relative to the origin using the current matrix at the top of the transformation matrix stack, thus obtaining the discrete primitive. Identify script definition nodes or event response attributes in the document object model tree, and extract the control script in text format contained in the script definition nodes or event response attributes; A UUID generation algorithm based on timestamps and random number seeds is invoked to generate a unique character sequence as a globally unique identifier. The globally unique identifier is then written into the attribute fields of the discrete primitives and the control script to establish an index association. Finally, the discrete primitives carrying the globally unique identifier and the control script constitute the static geometric flow and the dynamic logic flow, respectively.
4. The method for automatically drawing a DCS screen into a real-time database screen according to claim 1, characterized in that, The steps of constructing an affine transformation matrix and normalizing the coordinates of the discrete primitives to map them to a target Cartesian coordinate system specifically include: The geometric vertex coordinates of each discrete primitive in the static geometric flow are traversed, and the minimum horizontal and vertical coordinate values of the whole are filtered to determine the effective bounding box and origin offset of the source image. Based on the display configuration of the target screen, calculate the normalized scaling factor and the normalized translation vector; Based on the origin offset, the normalized scaling factor, and the normalized translation vector, the source coordinate zeroing matrix, the scaling matrix, and the target coordinate positioning matrix are constructed sequentially. If the vertical axis of the source coordinate system and the target coordinate system are detected to be opposite, a negative vertical scaling factor is set in the scaling matrix; The three matrices are concatenated to generate the affine transformation matrix, which is then applied to the coordinate data of the discrete primitives and the dynamic logic flow. The data structure is updated to complete coordinate normalization, thereby mapping the discrete primitives to the target Cartesian coordinate system.
5. A method for automatically drawing a DCS screen into a real-time database screen according to claim 1, characterized in that, After performing coordinate normalization, the process also includes curve reconstruction of the static geometric flow, specifically including: Identify discrete primitives of the polyline type in the static geometric flow and set a geometric error tolerance based on the target screen display accuracy; The Douglas-Puk algorithm is used to traverse the feature points of the discrete primitives, calculate the perpendicular distance from the feature point to the line connecting the beginning and end, and remove redundant feature points whose perpendicular distance is less than the geometric error tolerance. The control points of a cubic Bézier curve are fitted using the least squares method to the preserved feature point sequence, and the discrete primitives of the polyline type are reconstructed into vector curve paths.
6. The method for automatically drawing a DCS screen into a real-time database screen according to claim 1, characterized in that, The steps of analyzing the control script and constructing the abstract syntax tree specifically include: The control script is lexically analyzed using a regular expression matching algorithm to filter out comments and whitespace characters, and the code text is converted into a token stream containing keywords, identifiers, literals and operators. Based on the preset DCS script context-free grammar rules, the token stream is subjected to syntax analysis to identify nested logic of conditional branches, loop structures, and function calls; The corresponding syntax nodes are generated according to the nested logic, and the syntax nodes are assembled according to the operation priority and scope hierarchy to construct the abstract syntax tree.
7. A method for automatically rendering a DCS screen into a real-time database screen according to claim 6, characterized in that, After constructing the abstract syntax tree, the logical cross-platform mapping step is also included, specifically: Load the pre-built DCS source language and target language syntax mapping dictionary and built-in function comparison table; The abstract syntax tree is traversed using the visitor pattern, and DCS proprietary function nodes are mapped to standard library call nodes of the target language according to the built-in function lookup table. Based on the type differences defined in the syntax mapping dictionary, check the data type of the operand node and insert a type casting node, then perform type system mapping; Identify the nodes in the syntax nodes that represent DCS tag number read / write operations as tag number data access nodes, and map the tag number data access nodes as key-value pair query calls based on cache snapshots, and execute data interaction logic mapping; The target code is regenerated based on the abstract syntax tree that has been modified by the above mapping, and a runtime context object containing simulated system variables is injected to complete the runtime environment mapping.
8. A method for automatically drawing a DCS screen into a real-time database screen according to claim 1, characterized in that, The steps of recombining the discrete primitives into composite symbol objects using spatial grid index clustering and position semantics, and then attaching them to the abstract syntax tree, specifically include: The geometric bounding box size distribution of the discrete primitives is statistically analyzed to determine the reference cell side length of the spatial hash grid, and the axis-aligned bounding box after transformation of each discrete primitive is calculated to determine the grid cell index range covered by the discrete primitive. Traverse the range of grid cell indices, using the coordinate index of the grid cell as the key, and append the identifier of the discrete primitive to the candidate primitive list under the corresponding key as the value, thereby constructing a hash dictionary; The number of line segments, arcs, and polygon vertices of the discrete primitives are counted to construct a topological feature vector. Combined with the geometric centroid of the discrete primitives and the serialized hash value of the normalized vertex data, a geometric feature fingerprint is generated. The set of primitives in the neighborhood is retrieved using the hash dictionary. The set of primitives with the same geometric feature fingerprint and related position semantics is aggregated to generate the composite symbol object. Extract the globally unique identifier carried in the discrete primitive, retrieve the corresponding abstract syntax tree in the dynamic logic flow based on the globally unique identifier, and attach the abstract syntax tree to the event-driven interface of the composite symbol object.
9. A method for automatically drawing a DCS screen into a real-time database screen according to claim 1, characterized in that, The steps of calculating the edge anchor points of the composite symbol object, performing endpoint snapping repair based on the edge anchor points on the pipeline primitives, and performing orthogonal route correction on the pipeline primitives that are tilted specifically include: The reference anchor point and normal vector defined by the composite icon object are mapped to effective anchor points in the world coordinate system using object transformation parameters; Calculate the Euclidean distance between the endpoint of the pipeline element and the surrounding effective anchor points, filter candidate anchor points whose distance is less than the adsorption threshold, and select the candidate anchor point with the smallest weighted cost value as the adsorption target. Then, correct the endpoint coordinates of the pipeline element to the world coordinates of the adsorption target. After the endpoint adsorption is completed, it is determined whether the direction of the pipeline element is parallel to the coordinate axis, and the orthogonal route correction is completed. If the pipeline element is tilted, the initial route direction is locked based on the device port normal vector associated with the endpoint of the pipeline element. The Manhattan distance algorithm is used to calculate and insert orthogonal inflection points. At the same time, the inflection points are aligned and corrected according to the global device center coordinate set, and the tilted pipeline is reconstructed into an orthogonal polyline.
10. A method for automatically drawing a DCS screen into a real-time database screen according to claim 1, characterized in that, The steps of drawing the reconstructed composite symbol object and the pipeline primitives according to the screen format requirements of the real-time database, and compiling the abstract syntax tree into a target script to generate the real-time database screen file specifically include: Based on the file format specifications of the real-time database system, a root node object is instantiated in memory, a file header identifier and version information are written, and child node branches are created under the root node object to store attribute information, graph data and script code respectively, thereby establishing a data structure skeleton containing a metadata area, a graph object area and a script code area; Traverse the reconstructed composite symbol object and the pipeline primitive, convert the geometric attributes, appearance attributes and topological connection sequence of the composite symbol object into structured description text that conforms to the real-time database standard, and write it into the child node branch corresponding to the graphics object area; The code generator is invoked to traverse the abstract syntax tree after mapping correction, recursively print the syntax nodes as source code strings of the target scripting language, and write them into the child node branches corresponding to the script code section; The checksum of the structured description text and the source code string is calculated and written into the child node branch corresponding to the metadata area. Finally, the data structure skeleton is serialized and packaged and output as a monitoring screen file, thereby completing the automatic rendering of the DCS screen into the real-time database screen.
Citation Information
Patent Citations
Nuclear power DCS man-machine interface automatic generation method
CN109933324A
Method for automatically drawing DCS picture into real-time database picture
CN114528449A