A method and system for building intelligence-oriented declarative control and AI collaboration
Patent Information
- Application Number
- CN202611044480.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-07-14
- Publication Date
- 2026-09-25
AI Technical Summary
[0004]针对现有技术中楼宇自控系统厂商锁定严重、控制策略无法跨平台复用、AI无法原生参与控制回路、运维效率低的缺陷,本发明的目的在于提供一种面向建筑智能化的声明式控制与AI协同方法和系统,基于YAML构建通用的声明式建筑控制语言,实现控制逻辑跨厂商、跨协议复用,同时实现人机协同编辑控制策略,同时配套可视化与AI生成能力,提升控制策略的开发与运维效率
采用声明式结构化文本格式描述控制逻辑,以纯文本形式呈现,从而无须专用编程工具即可阅读和修改,同时通过变量抽象层实现控制逻辑与通信协议的解耦。使同一套控制策略可在不同通信协议的设备之间迁移,进而避免厂商锁定。
Smart Images

Figure FT_1 
Figure FT_2 
Figure FT_3
Abstract
Description
Technical Field
[0001] This invention relates to the fields of declarative programming and automatic control technology, and more specifically to a declarative control and AI collaborative method and system for building intelligence. Background Technology
[0002] With the continuous improvement of building intelligence, building automation systems are increasingly widely used in large public buildings such as commercial complexes, data centers, transportation hubs, and medical buildings. Currently, building automation systems mainly use direct digital controllers (DDCs) or programmable logic controllers (PLCs) as core control devices, and control programs are written using proprietary programming tools to achieve automatic control of the underlying equipment. Existing technologies have the following problems: While existing automation systems generally feature graphical programming and monitoring interfaces, their control logic is deeply tied to the vendor, limiting maintenance personnel to limited parameter adjustments and hindering flexible secondary development and custom logic programming. Furthermore, differences in control strategies, control language standards, and storage formats among different brands of equipment prevent cross-brand and cross-device data migration, resulting in a severe vendor lock-in effect. System upgrades and equipment replacements necessitate a complete refactoring of the control logic, leading to high costs and lengthy development cycles.
[0003] Due to vendor lock-in, existing AI cannot perform native recognition and generation, limiting its role to offline analysis scenarios such as energy consumption prediction, equipment failure prediction, and load prediction. AI can only output analysis reports or optimization suggestions and cannot directly write, modify, or deploy control strategies. Summary of the Invention
[0004] To address the shortcomings of existing building automation systems, such as severe vendor lock-in, inability to reuse control strategies across platforms, inability of AI to natively participate in control loops, and low operation and maintenance efficiency, this invention aims to provide a declarative control and AI collaboration method and system for building intelligence. Based on YAML, a universal declarative building control language is constructed to enable cross-vendor and cross-protocol reuse of control logic. At the same time, it enables human-machine collaborative editing of control strategies and is equipped with visualization and AI generation capabilities to improve the development and operation and maintenance efficiency of control strategies.
[0005] To achieve the above objectives, the present invention provides the following technical solution: A declarative control and AI collaboration method for building intelligence includes the following steps: S1. The loading platform loads the control strategy of a general declarative building control language based on YAML format; the control strategy adopts a structured plain text declarative architecture, and the control strategy sets a variable abstraction layer; S2. The execution engine parses the control policy and builds a syntax tree. The execution engine executes the control policy in a loop according to a preset running cycle, generates control commands, and sends them to the underlying devices. S3. Compile the control strategy into at least one interactive visual graphic, obtain device operation data from the execution engine, and overlay the data onto the corresponding nodes and connections of the visual graphic in real time; S4. In response to the user's editing operation on the visual graphics, the control strategy is modified bidirectionally and synchronously through the line-level text modification algorithm; S5. Receive the user's input natural language control requirements, generate declarative candidate control strategies using the large language model, and then deploy the candidate control strategies to the execution engine for execution after verification.
[0006] As a further improvement of the present invention, the variable abstraction layer includes a protocol adaptation layer, a variable definition layer, and a control logic layer; The protocol adaptation layer is used for communication protocols of underlying devices; The variable definition layer is used to declare the binding relationship between variables and physical device locations; The control logic layer is used to reference variable names.
[0007] As a further improvement of the present invention, step S4 specifically includes: S41. In response to the user's editing operation on the visual graphic, perform prefix decoding on the graphic node ID, and determine the YAML source code paragraph and entry name corresponding to the operation target by prefix matching; S42. Based on YAML indentation level matching, locate the start and end line range of the target entry in the source code; S43. Dynamically map the graphics port index to the corresponding source code attribute key name; S44. Perform line-level addition, deletion and modification on the source code within the target line range, while maintaining the original indentation and format; S45. Synchronously update the source code editor content and visual graphics.
[0008] As a further improvement of the present invention, step S5 specifically includes: S511. Encapsulate the control language specification, control mode library, and project equipment topology information into a structured file and preload it into the context of the large language model; S512. Based on the language specifications and control mode library, as well as the device topology information of the current control project, the large language model generates control strategy source code that conforms to the syntax specifications. S513. Call the parser to perform syntax verification on the generated control strategy source code. If an error is detected, the large language model will automatically repair it based on the error information.
[0009] As a further improvement of the present invention, the execution engine in step S5 performs a security check on the candidate control strategy, and the security check includes: S521. The execution engine reads the current running snapshot data, which includes real-time values of variables, control output status, and alarm status. S522. Simulate and run the candidate control strategy in the simulation sandbox to verify whether it will cause variables to go out of bounds or trigger high-priority safety constraints. S523. After the verification is successful, the summary information of the candidate control strategy is presented to the user, and the deployment is executed after receiving the confirmation command input by the user.
[0010] As a further improvement of the present invention, the control strategy source code includes at least a variable definition section, a safety constraint section, a continuous control section, and a sequential control section; the execution priority of the safety constraint section is higher than that of the continuous control section, and the execution priority of the continuous control section is higher than that of the sequential control section. In step S2, the execution engine evaluates and executes each segment of the control strategy source code in priority order in each cycle to form control instructions.
[0011] As a further improvement of the present invention, step S2, in which the execution engine evaluates and executes each segment of the control strategy source code in priority order in each cycle, includes the following steps: S21. At the beginning of each control cycle, the triggering conditions of each safety constraint in the safety constraint segment are evaluated first. S22. When any safety constraint is triggered, its protection action is enforced, and the protection action cannot be overridden by any control output of the continuous control segment and the sequential control segment.
[0012] As a further improvement of the present invention, it also includes: receiving a manual overwrite instruction input by a user, wherein the manual overwrite instruction includes a target variable and its target value; In response to the manual overwrite command, the target value is used as the write command for the target variable, and the following priority is used to determine the priority: the priority of the manual overwrite command is higher than the automatic control output of the continuous control segment and the sequential control segment, but lower than the protection action of the safety constraint segment. When the manual override instruction and the protection action of the safety constraint section point to the same variable, the protection action is executed first and overrides the manual override instruction.
[0013] A declarative control system for building intelligence, used to execute the control method described above, includes: A loading platform module is used to load YAML-based general declarative control logic source code, which includes at least a variable definition section, a security constraint section, a continuous control section, and a sequential control section. The dual-process execution engine module is used to parse the control logic source code and build a syntax tree. Different sections in the control logic source code have different fixed priorities, and the security constraint section has the highest priority. In each control cycle, the control logic source code is evaluated and executed in priority order, and device control instructions are generated based on the evaluation results. The visualization compilation module is used to compile the control logic source code into at least one interactive visualization graphic, and to obtain device operation data from the execution engine and overlay the data on the corresponding nodes and connections of the visualization graphic in real time. The editing synchronization module is used to respond to user editing operations on visual graphics and to perform bidirectional synchronous modifications to the control logic source code. The AI collaboration module is used to receive natural language control requirements input by the user, enabling the large language model to generate declarative candidate control strategies based on pre-loaded control language specifications and project equipment topology information, and then deploying the candidate control strategies to the execution engine module for execution after performing syntax and security constraint verification.
[0014] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described above.
[0015] The beneficial effects of this invention are: The control logic is described using a declarative, structured text format and presented in plain text, allowing for reading and modification without the need for dedicated programming tools. Furthermore, a variable abstraction layer decouples the control logic from the communication protocol. This enables the same control strategy to be migrated between devices using different communication protocols, thus avoiding vendor lock-in.
[0016] Declarative languages facilitate engineers' understanding, maintenance, and review, while also enabling AI systems such as large language models to natively recognize, generate, and edit them. This allows AI to directly translate natural language requirements into executable control strategies, which are then automatically deployed after verification, achieving proactive AI-driven system control.
[0017] By isolating safety constraints from the control logic and assigning them the highest execution priority, the safety constraint segment is evaluated first at the start of all control cycles, and its protective actions cannot be overridden by any automatic control output or manual operation. This ensures safety at the syntactic level and eliminates the possibility of safety failures due to programming oversights.
[0018] The declarative control logic source code is automatically compiled into an interactive visual graph, and device operation data is overlaid on the nodes and connections of the graph in real time. Maintenance personnel can intuitively observe the structure of the control logic and the real-time data flow, greatly facilitating troubleshooting.
[0019] A line-level text modification algorithm achieves precise synchronization between graphical editing and source code. All graphical operations directly modify specific lines of the source code, bypassing the round-trip process of source code parsing, modification, and reserialization. All comments, indentation, and formatting in the source code, except for the modified lines, are fully preserved. Users can drag and drop to edit on the graphical interface or directly modify in the source code editor, with both always remaining synchronized. Attached Figure Description
[0020] Figure 1 This is a schematic diagram of the overall process of the present invention; Figure 2 This is a schematic diagram of the overall process of the declarative control and AI collaboration method of the present invention; Figure 3 This is a flowchart illustrating the execution priority of the engine control cycle in this invention. Figure 4 This is a schematic diagram of the complete AI collaborative control process of the present invention; Figure 5 This is a schematic diagram of the remote policy hot update process of the present invention. Detailed Implementation
[0021] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. Identical components are indicated by the same reference numerals.
[0022] Example 1. Refer to Figure 1-5 As shown, a declarative control and AI collaboration method for building intelligence includes the following steps.
[0023] S1. Loading platform loads control strategies based on YAML format general declarative building control language; the control strategies adopt a structured plain text declarative architecture, and the control strategies set variable abstraction layers.
[0024] Specifically, the variable abstraction layer comprises a protocol adaptation layer, a variable definition layer, and a control logic layer. The protocol adaptation layer is responsible for interacting with specific communication protocols such as BACnet, Modbus, and OPCUA, handling message transmission and reception, data type conversion, and timing control. Each variable declaration in the variable definition layer includes its type, unit, value range, and the bound device identifier, but does not contain any protocol address information. The control logic layer contains all logical definitions within the safety constraints, continuous control, and sequential control sections; these definitions only reference variable names.
[0025] When equipment is replaced or the protocol is changed, engineers only need to modify the binding relationship in the variable definition layer (such as changing the protocol type of a variable from BACnet to Modbus and updating the address), while all references in the control logic layer remain unchanged, thereby achieving complete decoupling between the control logic and the communication protocol.
[0026] S2. The execution engine parses the control strategy and builds a syntax tree. The execution engine executes the control strategy in a loop according to the preset running cycle, generates control commands and sends them to the underlying devices.
[0027] Specifically, this embodiment employs a dual-process heterogeneous execution engine. After receiving the control strategy source code, the execution engine calls the parser to perform lexical and syntactic analysis, constructing an abstract syntax tree. During parsing, it verifies the completeness of each paragraph structure, the validity of variable references, and the legality of control block parameters. If parsing fails, an error message is returned; if successful, it enters the waiting state.
[0028] Furthermore, the control strategy source code includes at least a variable definition section, a security constraint section, a continuous control section, and a sequential control section; the execution priority of the security constraint section is higher than that of the continuous control section, and the execution priority of the continuous control section is higher than that of the sequential control section. In step S2, the execution engine evaluates and executes each segment of the control strategy source code in priority order in each cycle to form control instructions.
[0029] Specifically, the execution engine executes cyclically according to a preset scan cycle. Within each cycle, the engine evaluates each segment in order of priority. Specifically, it first evaluates the safety constraint segment, then executes the continuous control segment, and finally executes the sequential control segment. After evaluation, control instructions for each variable are generated, and the instructions are converted into messages conforming to standard industrial protocols such as BACnet and Modbus through a protocol adaptation layer, and then sent to the underlying PLC or DDC controller.
[0030] Furthermore, in step S2, the execution engine evaluates and executes the control strategy source code segments in priority order within each cycle, including the following steps: S21. At the beginning of each control cycle, the triggering conditions of each safety constraint in the safety constraint section are evaluated first.
[0031] Specifically, at the beginning of each cycle, the engine reads the current values of all variables from the snapshot and evaluates the trigger condition expression of each rule defined in the safety constraint section. For example, if the condition of a certain antifreeze protection rule is "water supply temperature is below 5°C", the engine determines whether the current water supply temperature meets the condition.
[0032] S22. When any safety constraint is triggered, its protection action shall be enforced, and the protection action shall not be overridden by any control output of the continuous control segment or the sequential control segment.
[0033] Specifically, if the trigger condition of a safety constraint is met, the engine immediately generates its protective action instruction (such as setting the unit start / stop command to off) and marks this instruction as the highest priority. This instruction is placed in a separate high-priority queue, and during the subsequent instruction arbitration phase, instructions in this queue take precedence over instructions generated by any consecutive control segment or sequential control segment. Even if a consecutive control segment generates an opposite instruction within the same cycle, the arbitration logic will discard the lower-priority instruction and only issue the protective action for the safety constraint.
[0034] S3. Compile the control strategy into at least one interactive visual graphic, obtain device operation data from the execution engine, and overlay the data onto the corresponding nodes and connections of the visual graphic in real time.
[0035] Specifically, the visual compilation module performs static analysis on the same policy source code, extracts all variables, control blocks, security constraints and sequence steps, and automatically generates function block diagrams, sequence flowcharts or topology overview diagrams.
[0036] Meanwhile, the visual compilation module periodically reads runtime snapshots from the execution engine via API. These snapshots contain real-time values of all variables, output values and operating modes of control blocks, and trigger status of safety constraints. This data is then overlaid onto the corresponding nodes, allowing operations personnel to intuitively see the correspondence between logic and data.
[0037] S4. In response to the user's editing operation on the visual graphics, the control strategy is modified bidirectionally and synchronously through a line-level text modification algorithm.
[0038] Specifically, when a user performs editing operations on the graphics canvas (such as dragging and dropping lines, modifying parameters, etc.), the system triggers a two-way synchronization process, as follows.
[0039] S41. In response to the user's editing operation on the visual graph, perform prefix decoding on the graph node ID, and determine the YAML source code paragraph and entry name corresponding to the operation target through prefix matching.
[0040] Specifically, in this embodiment, all graphical nodes are prefixed: variable nodes are prefixed with var-, control block nodes with ctrl-, security constraint nodes with guard-, and alarm nodes with alarm-. When a user drags and drops a line, the system obtains the IDs of the source and target nodes and determines their respective source code segments and entry names through the prefixes.
[0041] S42. Based on YAML indentation level matching, locate the start and end line range of the target entry in the source code.
[0042] Specifically, the system loads the line array of the source code, finds the line containing the target entry name within the corresponding paragraph, and records it as the starting line; it continues scanning downwards until it encounters the next new entry or paragraph with the same indentation level, which is recorded as the ending line. The complete definition range of the entry is accurately identified by the indentation level (the number of spaces in YAML).
[0043] S43. Dynamically map the graphics port index to the corresponding source code attribute key name.
[0044] Specifically, the system predefined input key set includes setpoint, process_var, enable, sensor, etc., and the output key set includes output, controlled_var, result, etc. For the input port index of a control block node, the system first scans the attribute keys already defined in the source code of the control block, then merges them with the predefined key set, prioritizing the keys already existing in the source code, and finally maps the port index to the corresponding key name, adapting to the key name conventions of different control block types.
[0045] S44. Perform line-level addition, deletion, and modification on the source code within the target line range, while maintaining the original indentation and format.
[0046] Specifically, for adding a connection, the mapped key name is searched within the target line range: if it exists, the value of that line is replaced with a reference to the source variable; if it does not exist, a new line is inserted after the entry's starting line with proper indentation, the indentation level dynamically read from the number of leading spaces in the existing attribute line. For deleting a connection, the key's value is reset to a no-reference state, and it is determined whether the key belongs to an expression type. If so, any remaining isolated logical or arithmetic operators are automatically cleaned up to ensure the expression syntax is correct. All operations are performed at the line level and do not trigger a full YAML serialization round trip.
[0047] S45. Synchronously update the source code editor content and visual graphics.
[0048] The modified source code line array is reassembled into a complete string, updated in the source code editor's display, and triggers the visual compilation module to recompile the graphics. This ensures that the source code and graphics seen by the end user are completely consistent.
[0049] S5 receives natural language control requirements from the user, generates declarative candidate control strategies using a large language model, and then deploys the candidate control strategies to the execution engine after verification.
[0050] Specifically, the system provides a natural language input interface, allowing maintenance personnel to describe their control requirements, such as "controlling the air supply temperature of a certain air conditioning unit, requiring antifreeze protection and CO2 linkage." The AI collaboration module then initiates the processing flow.
[0051] Specifically, step S5 includes two phases: the policy generation phase and the security verification and deployment phase. The policy generation phase includes steps S511 to S513, and the security verification and deployment phase includes steps S521 to S523.
[0052] S511. Encapsulate the control language specification, standard control mode library, and project equipment topology information into structured files and preload them into the context of the large language model.
[0053] Specifically, the system extracts control language specifications (including all paragraph structures, variable type definitions, control mode syntax, etc.), control mode libraries (such as PID, logic rules, schedule templates, etc.), and safety constraint rules from the knowledge base, and encapsulates them into a structured document. Simultaneously, it obtains information such as the device type, spatial location, physical connection relationships, and point list of the current project through the device topology interface, and injects this information as context into the large language model.
[0054] S512: The large language model generates control strategy source code that conforms to the syntax specification based on the language specification, control mode library, and equipment topology information of the current control project.
[0055] Specifically, the large language model parses the user's natural language, identifies control objectives, security requirements, energy-saving strategies, and scheduling rules, and combines pre-loaded knowledge to generate complete YAML strategy source code according to a standard paragraph structure. This YAML strategy source code includes all necessary paragraphs such as variable definitions, security constraints, continuous control, and sequential control.
[0056] S513: Call the parser to perform syntax verification on the generated control strategy source code. When errors are detected, the large language model will automatically repair them based on the error information.
[0057] Specifically, the system calls the execution engine's parser to validate the generated source code, including YAML format, variable reference integrity, and paragraph dependency order. If an error is found (such as an undefined variable or a misspelled key name), the error line number and description are sent back to the large language model. The model corrects the error and resubmits it, repeating this process until the syntax validation passes.
[0058] S521: The execution engine reads the current running snapshot data, which includes real-time values of variables, control output status, and alarm status.
[0059] Specifically, after the syntax check passes, the execution engine retrieves the latest snapshot from the current runtime environment, which includes the real-time values of all variables, the output status of each control block, active alarms, etc.
[0060] S522: Simulate and run candidate control strategies in a simulation sandbox to verify whether they will cause variables to go out of bounds or trigger high-priority safety constraints.
[0061] Specifically, within the simulation sandbox, the execution engine simulates multiple control cycles of candidate strategies based on current snapshot data and observes their output instructions. If, during the simulation, an instruction attempts to set a variable to a value exceeding its preset safety range, or triggers any high-priority safety constraint protection action, the verification fails, deployment is rejected, and the reason is recorded. If all simulation cycles are safe, the verification passes.
[0062] S523: After successful verification, present the summary information of the candidate control strategies to the user, and execute the deployment after receiving the user's confirmation command.
[0063] Specifically, after successful verification, the system automatically generates a natural language summary explaining the policy's objectives, core logic, security boundaries, and expected effects, which is then displayed through the user interface. Once the user reads and confirms the summary, the system deploys the policy to the execution engine for full operation via a remote OTA (Over-The-Air) hot update mechanism.
[0064] In this embodiment, when an operator issues a manual override command via an interface or API, the command specifies the target variable and target value. The manual override command participates in the command arbitration in step S2 as an independent source. Its priority is defined as: higher than the automatic output of the continuous control segment and the sequential control segment, but lower than the protection action of the safety constraint segment. When the manual override command and the protection action of the safety constraint point to the same variable, the arbitration result forces the value of the protection action to be adopted, thereby ensuring that the safety constraint always takes precedence. At the same time, the system records the event log of the manual override being overridden by the safety constraint for audit traceability.
[0065] Meanwhile, during the operation of the control strategy, when the system submits manually modified strategy source code, the execution engine checks for changes at the end of each scan cycle. Upon detecting a change, the engine parses the new source code and performs a complete verification in a background thread. If parsing fails, the old strategy is retained and an error is returned. If parsing succeeds, the scanning loop is paused at the end of the current cycle, a copy-on-write strategy is used to build a new syntax tree and replace the working pointers, while retaining the current values of persistent variables. Normal operation then resumes in the next cycle, without requiring a device restart.
[0066] Example 2: This example provides a declarative control system for building intelligence, used to execute the above-described control method, including: The platform loading module is used to load YAML-based general declarative control logic source code. The control logic source code must include at least a variable definition section, a security constraint section, a continuous control section, and a sequential control section. The dual-process execution engine module is used to parse the control logic source code and build a syntax tree. Different sections in the control logic source code have different fixed priorities, and the safety constraint section has the highest priority. In each control cycle, the control logic source code is evaluated and executed in priority order, and device control instructions are generated based on the evaluation results. The visualization compilation module is used to compile the control logic source code into at least one interactive visualization graphic, and to obtain device operation data from the execution engine and overlay the data on the corresponding nodes and connections of the visualization graphic in real time. The editing synchronization module is used to respond to user editing operations on visual graphics and to perform bidirectional synchronous modifications to the control logic source code. The AI collaboration module is used to receive natural language control requirements input by users, enabling the large language model to generate declarative candidate control strategies based on pre-loaded control language specifications and project equipment topology information, and to perform syntax verification and automatic repair on the generated strategies. It is also used to enable the execution engine module to perform security constraint verification on the candidate control strategies and then deploy them to the execution engine module for execution.
[0067] Furthermore, the dual-process execution engine module includes a control kernel process implemented in Go and a management process implemented in Node.js. The control kernel process is responsible for parsing and executing real-time control logic, ensuring determinism and low latency in control. The management process is responsible for non-real-time tasks such as user interface, API interface, and data persistence. The two processes communicate asynchronously through the MQTT protocol, and the control kernel can run independently of the management process, so that a single point of failure does not affect global control.
[0068] Example 3: This example provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the method described above.
[0069] The above description is merely a preferred embodiment of the present invention. The scope of protection of the present invention is not limited to the above embodiments. All technical solutions falling within the scope of the present invention's concept are within the scope of protection of the present invention. It should be noted that for those skilled in the art, any improvements and modifications made without departing from the principles of the present invention should also be considered within the scope of protection of the present invention.
Claims
1. A declarative control and AI collaboration method for building intelligence, characterized in that, Includes the following steps: S1. The loading platform loads the control strategy of a general declarative building control language based on YAML format; the control strategy adopts a structured plain text declarative architecture, and the control strategy sets a variable abstraction layer; S2. The execution engine parses the control policy and builds a syntax tree. The execution engine executes the control policy in a loop according to a preset running cycle, generates control commands, and sends them to the underlying devices. S3. Compile the control strategy into at least one interactive visual graphic, obtain device operation data from the execution engine, and overlay the data onto the corresponding nodes and connections of the visual graphic in real time; S4. In response to the user's editing operation on the visual graphics, the control strategy is modified bidirectionally and synchronously through the line-level text modification algorithm; S5. Receive the user's input natural language control requirements, generate declarative candidate control strategies using the large language model, and then deploy the candidate control strategies to the execution engine for execution after verification.
2. The declarative control and AI collaboration method for building intelligence according to claim 1, characterized in that, The variable abstraction layer includes a protocol adaptation layer, a variable definition layer, and a control logic layer; The protocol adaptation layer is used for communication protocols of underlying devices; The variable definition layer is used to declare the binding relationship between variables and physical device locations; The control logic layer is used to reference variable names.
3. The declarative control and AI collaboration method for building intelligence according to claim 1, characterized in that, Its features are, Step S4 specifically includes: S41. In response to the user's editing operation on the visual graphic, perform prefix decoding on the graphic node ID, and determine the YAML source code paragraph and entry name corresponding to the operation target by prefix matching; S42. Based on YAML indentation level matching, locate the start and end line range of the target entry in the source code; S43. Dynamically map the graphics port index to the corresponding source code attribute key name; S44. Perform line-level addition, deletion and modification on the source code within the target line range, while maintaining the original indentation and format; S45. Synchronously update the source code editor content and visual graphics.
4. The declarative control and AI collaboration method for building intelligence according to claim 1, characterized in that, Step S5 specifically includes: S511. Encapsulate the control language specification, control mode library, and project equipment topology information into a structured file and preload it into the context of the large language model; S512. Based on the language specifications and control mode library, as well as the device topology information of the current control project, the large language model generates control strategy source code that conforms to the syntax specifications. S513. Call the parser to perform syntax verification on the generated control strategy source code. If an error is detected, the large language model will automatically repair it based on the error information.
5. A declarative control and AI collaborative method for building intelligence according to claim 4, characterized in that, In step S5, the execution engine performs a security check on the candidate control policy, and the security check includes: S521. The execution engine reads the current running snapshot data, which includes real-time values of variables, control output status, and alarm status. S522. Simulate and run the candidate control strategy in the simulation sandbox to verify whether it will cause variables to go out of bounds or trigger high-priority safety constraints. S523. After the verification is successful, the summary information of the candidate control strategy is presented to the user, and the deployment is executed after receiving the confirmation command input by the user.
6. The declarative control and AI collaboration method for building intelligence according to claim 1, characterized in that, The control strategy source code includes at least a variable definition section, a security constraint section, a continuous control section, and a sequential control section; the execution priority of the security constraint section is higher than that of the continuous control section, and the execution priority of the continuous control section is higher than that of the sequential control section. In step S2, the execution engine evaluates and executes each segment of the control strategy source code in priority order in each cycle to form control instructions.
7. A declarative control and AI collaborative method for building intelligence according to claim 6, characterized in that, In step S2, the execution engine evaluates and executes the control strategy source code sections in priority order within each cycle, including the following steps: S21. At the beginning of each control cycle, the triggering conditions of each safety constraint in the safety constraint segment are evaluated first. S22. When any safety constraint is triggered, its protection action is enforced, and the protection action cannot be overridden by any control output of the continuous control segment and the sequential control segment.
8. A declarative control and AI collaborative method for building intelligence according to claim 1, characterized in that, Also includes: Receive a manual overwrite instruction input by the user, the manual overwrite instruction including the target variable and its target value; In response to the manual overwrite command, the target value is used as the write command for the target variable, and the following priority is used to determine the priority: the priority of the manual overwrite command is higher than the automatic control output of the continuous control segment and the sequential control segment, but lower than the protection action of the safety constraint segment. When the manual override instruction and the protection action of the safety constraint section point to the same variable, the protection action is executed first and overrides the manual override instruction.
9. A declarative control system for building intelligence, used to execute the control method of any one of claims 1-8, characterized in that, include: A loading platform module is used to load YAML-based general declarative control logic source code, which includes at least a variable definition section, a security constraint section, a continuous control section, and a sequential control section. The dual-process execution engine module is used to parse the control logic source code and build a syntax tree. Different sections in the control logic source code have different fixed priorities, and the security constraint section has the highest priority. In each control cycle, the control logic source code is evaluated and executed in priority order, and device control instructions are generated based on the evaluation results. The visualization compilation module is used to compile the control logic source code into at least one interactive visualization graphic, and to obtain device operation data from the execution engine and overlay the data on the corresponding nodes and connections of the visualization graphic in real time. The editing synchronization module is used to respond to user editing operations on visual graphics and to perform bidirectional synchronous modifications to the control logic source code. The AI collaboration module is used to receive natural language control requirements input by the user, enabling the large language model to generate declarative candidate control strategies based on pre-loaded control language specifications and project equipment topology information, and then deploying the candidate control strategies to the execution engine module for execution after performing syntax and security constraint verification.
10. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1-8.