Automatic data calculation method and system based on configuration driving
By using a configuration-driven automated data calculation method, the problems of long development cycles and high maintenance costs caused by hard coding are solved. It enables data calculation logic debugging and maintenance without hard coding, improves the system's versatility and scalability, and meets the flexible energy data analysis needs in multiple scenarios.
Patent Information
- Application Number
- CN202511636035.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-11-10
- Publication Date
- 2026-01-13
AI Technical Summary
Existing technologies rely on hard-coded patterns in the data computation and modeling of multi-source heterogeneous devices, resulting in lengthy development cycles, repetitive development, high debugging difficulty, high maintenance costs, and an inability to dynamically adapt to computation rules. This leads to poor system versatility and scalability, making it difficult to meet the flexible energy data analysis needs in multiple scenarios.
By adopting a configuration-driven automated data calculation method, a common model measurement point configuration is set, a function registration mechanism is executed, callback function binding is performed, and function execution mechanism is set. This achieves the goal of eliminating the need for hard coding, supporting the reuse of the same/similar calculation functions, dynamically adapting calculation rules, reducing manual intervention, and improving the system's versatility and scalability.
It enables data computation without hard coding, supports rapid debugging and maintenance of computational logic, shortens the development cycle, reduces maintenance costs, and meets the flexible energy data analysis needs in multiple scenarios.
Smart Images

Figure CN121326441A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the field of configuration-driven automation, and particularly relates to an automation data calculation method and system based on configuration driving. BACKGROUND
[0002] In the scenarios of industrial automation, intelligent building, power monitoring and the like involving embedded terminal data processing and modeling, the prior art has realized standardized data acquisition of multi-source heterogeneous devices, but still relies on a traditional hard coding mode in subsequent data calculation and modeling links: for example, in an energy management system, a program code needs to be written separately to realize data processing logic for each measuring point (such as three-phase voltage calculation, energy consumption statistics, etc.) or calculation task, and each time a calculation requirement is added or a calculation rule is adjusted, code writing, compiling and system deployment need to be completed again; at the same time, the same or similar calculation functions (such as line voltage conversion in different projects) cannot be reused and need to be developed repeatedly, resulting in a long development cycle; in addition, the calculation logic is deeply embedded in the program, and once there is a calculation deviation or a requirement change, it is difficult to quickly locate the problem and verify the modification, and the system version needs to be released again to complete the update, so the maintenance cost is high; more importantly, the existing system can only realize data acquisition automation, and a large amount of manual intervention is required for configuration and adjustment in the calculation link, and the system cannot dynamically adapt to the calculation rules according to the actual requirements on site, so the system has poor universality and expandability, which seriously restricts the project development efficiency and delivery speed, and it is difficult to meet the flexible energy data analysis and index generation requirements in multiple scenarios.
[0003] Therefore, the present application proposes an automation data calculation method and system based on configuration driving to solve the above problems. SUMMARY
[0004] The present application aims to at least solve one of the technical problems existing in the prior art; for this purpose, the present application proposes an automation data calculation method and system based on configuration driving to solve the technical problem that the prior art has realized standardized data acquisition of multi-source heterogeneous devices, but relies on a hard coding mode in data calculation and modeling, which has many problems: a code needs to be written, compiled and deployed again for adding or adjusting a calculation requirement, the same / similar calculation functions cannot be reused, resulting in repeated development and a long cycle; the calculation logic is embedded in the program, and it is difficult to modify and debug, and a system needs to be released again for a requirement change, so the maintenance cost is high; at the same time, a large amount of manual intervention is required in the calculation link, and the system cannot dynamically adapt to the calculation rules according to the requirements on site, so the system has poor universality and expandability, which seriously restricts the project development efficiency and delivery speed, and it is difficult to meet the flexible energy data analysis and index generation requirements in multiple scenarios.
[0005] To achieve the above-mentioned purpose, a first aspect of the present application provides an automation data calculation method based on configuration driving, comprising: Setting common model measurement point configuration; After reading the common model measurement point configuration information, a function registration mechanism is executed. Callback function binding is performed. A function running mechanism is set.
[0006] Preferably, the setting of the common model measurement point configuration comprises: A registration function name func and its parameter field param are configured in the common model measurement point; wherein the parameter field param comprises an input parameter data and a logic parameter logic.
[0007] It should be noted that in the parameter field param of the common model measurement point configuration, the input parameter data is a parameter set for providing original input for data calculation, and the parameter order thereof strictly corresponds to the variable index in the logic parameter logic in one-to-one correspondence, supports multiple types such as constant data, source measurement points (such as collected phase voltage measurement points), common measurement points, and is used to clearly specify various types of basic data sources required for calculation; the logic parameter logic is a core field for defining data processing rules (common forms such as JSON structures containing formula sub-fields), for example, by using expressions such as "0 1" to specify that the parameters in the data corresponding to the index are used to perform operations (such as multiplying the first parameter and the second parameter), so as to clearly specify the specific logic of data calculation and provide a basis for the system to automatically perform operations.
[0008] Preferably, the function registration mechanism comprises: The registration function name in the func field is extracted. It is determined whether the registration function name exists in the registration function list; if the registration function name exists, the function pointer of the registration function is obtained, and the param field is continued to be parsed; if the registration function name does not exist, the measurement point configuration is skipped; wherein the registration function list is a user-defined registration function key-value table, the key key is the registration function name, and the value value is the function pointer of the registration function.
[0009] It should be noted that the func field is a core field for specifying the registration function name, and the specific value thereof is the registration function name; the registration function name needs to be a name that has been defined in the system registration function list (the list is a key-value table of "registration function name-function pointer", the key corresponds to the registration function name, and the value corresponds to the function pointer of the registration function); if the registration function name exists in the list, the system will obtain the corresponding function pointer and continue to parse the param field; if the registration function name does not exist, the current measurement point configuration is directly skipped.
[0010] Preferably, the param field is parsed, comprising: According to the type of each parameter in data, the corresponding variable address is extracted; wherein, the type of the parameter includes: constant, source measurement point, public measurement point; Constant: the address of directly storing constant value; Source measurement point: the data storage address of the source measurement point in the system is obtained; Store all variable addresses in the pointer array according to the order of data; Convert the logic content into a json object; Pass the extracted pointer data and the json object into the function pointer of the registration function and execute, extract the data processing logic in the json object, and create a lambda function combined with the pointer array.
[0011] Preferably, the lambda function includes: If the creation is successful, the registration function returns the function pointer of the lambda function; If the creation fails, the registration function returns nullptr.
[0012] It should be noted that when the lambda function is parsed by the system after the param field, the pointer array storing the variable addresses extracted according to the order of data is passed into the function pointer of the registration function together with the logic content converted into a json object and executed, and the callable carrier encapsulating the specific data calculation logic created by combining the data processing logic in the json object is used to execute the corresponding calculation logic and obtain the target measurement point result when the source measurement point is updated in the future; and nullptr is used to identify the "null pointer". When the system fails to create a lambda function by combining the pointer data and the processing logic in the json object (such as invalid parameter address, incorrect data processing logic, etc.), the registration function returns nullptr to inform the system that the current lambda function is not successfully created and cannot be used in the subsequent data calculation process.
[0013] Preferably, the callback function binding includes: The generated lambda function pointer is bound to the target measurement point corresponding to the id in the public model measurement point configuration; The source measurement point in the data in the public model measurement point configuration is associated with the target measurement point.
[0014] It should be noted that the generated lambda function pointer is bound to the target measurement point corresponding to the id in the public model measurement point configuration; for example, the "lambda pointer created by auto_calc" is bound to the "line voltage measurement point with id=4", so that the target measurement point is uniquely associated with a set of calculation logic (when the calculation of the measurement point is called later, the bound lambda pointer is directly used). The source measurement point in the data in the public model measurement point configuration is associated with the target measurement point; the association is a "trigger notification" function: for example, when the data of the source measurement point is updated, the system can quickly locate the target measurement point (id=4) that needs to be calculated through the association relationship, avoiding indiscriminate scanning of all measurement points, and improving efficiency.
[0015] Preferably, the function setting mechanism comprises: Retrieving a lambda function pointer; Obtaining the current value of the parameter and executing the calculation logic; After the calculation is completed, the lambda function directly writes the result to the public model measurement point for access by the upper application.
[0016] Preferably, the retrieving of the lambda function pointer comprises: When the source measurement point is updated, the function pointer of the lambda function of the associated target measurement point is retrieved; If the pointer is nullptr: it is determined that the calculation logic is invalid, and the subsequent operation is not performed; If the pointer is not nullptr: the lambda function is called to start the calculation process.
[0017] Preferably, the obtaining of the current value of the parameter and the execution of the calculation logic comprises: Executing the logical expression defined in the logic in the public model measurement point configuration; The variables in the expression obtain the current value from the pointer array according to the numerical index in the logic, and execute the calculation logic.
[0018] The second aspect of the present application provides an automatic data calculation system based on configuration driving, comprising a data setting module, a data processing module and a running module. The data setting module is used for setting the public model measurement point configuration. The data processing module is used for reading the public model measurement point configuration information, executing the function registration mechanism, and performing the callback function binding. The running module is used for setting the function running mechanism and executing.
[0019] Compared with the prior art, the present application has the following advantages: The present application solves the technical problems of the prior art by the core idea of "configuration instead of coding". First, without writing hard code, only need to configure the registration function name (func) and parameter field (param) in the public model measurement point, the input parameter data in param supports types such as constant, source measurement point, and public measurement point, and strictly corresponds to the variable index of the logic parameter logic, the calculation data source is clear, and the logic is defined by the formula field to define the operation expression (such as "0 1") to clearly define the calculation rule, directly replacing the traditional calculation logic definition that needs to be coded separately, avoiding re-coding, compiling and deploying when new or adjustment requirements are needed; secondly, when the system executes the function registration mechanism, it will match the function pointer corresponding to func from the user-defined "function name-function pointer" key-value table, parse data to get the variable address and store it in the pointer array, convert logic to a json object, and then create a lambda function that encapsulates the specific calculation logic, realize the reuse of the same / similar calculation function, and solve the problem of repeated development; then, through the callback function binding, the lambda function pointer is bound to the target measurement point corresponding to the id in the configuration (to ensure that the calculation logic corresponds to the target measurement point uniquely, and to simplify debugging and maintenance), and the association relationship between the source measurement point and the target measurement point is established (to realize accurate triggering when the source measurement point is updated, without indiscriminate scanning, and to improve efficiency); finally, when the source measurement point is updated, the system retrieves the lambda function pointer of the associated target measurement point, and if the pointer is valid, the function is called, the latest parameter value is obtained from the pointer array according to the logic expression, the calculation is performed, and the result is directly written into the target measurement point for the upper application to access, without human intervention in the calculation link throughout the process, realizing dynamic adaptation and automation of data calculation, greatly reducing maintenance cost, improving system generality and expandability, shortening project development cycle, and meeting the flexible energy data analysis and index generation requirements in multiple scenarios. BRIEF DESCRIPTION OF DRAWINGS
[0020] In order to more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the drawings needed to be used in the embodiments or prior art description. Obviously, the drawings in the following description only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained without creative labor on the basis of these drawings.
[0021] Figure 1 The method steps of the embodiments of the present application are shown in the figure; Figure 2 The system module schematic diagram of the embodiments of the present application is shown in the figure. DETAILED DESCRIPTION
[0022] The technical solutions of the present application will be described clearly and completely below in connection with the embodiments. Obviously, the described embodiments are only some of the embodiments of the present application, but not all the embodiments. Based on the embodiments in the present application, all other embodiments obtained by those of ordinary skill in the art without creative efforts belong to the scope of the present application.
[0023] Please refer to Figure 1 The first aspect embodiment of the present application provides an automatic data calculation method based on configuration driving, comprising: Setting a common model measurement point configuration; After reading the common model measurement point configuration information, executing a function registration mechanism; Performing callback function binding; Performing callback function binding; Setting a common model measurement point configuration, comprising: Configuring a registration function name func and a parameter field param in the common model measurement point; wherein the parameter field param includes: an input parameter data and a logic parameter logic.
[0024] The function registration mechanism comprises: Extracting the registration function name in the func field; Looking up the registration function list to check whether the registration function name exists; if it exists, obtaining the function pointer of the registration function, and continuing to parse the param field; if it does not exist, skipping the measurement point configuration; wherein the registration function list is a registration function key-value table defined by the user, the key key is the registration function name, and the value value is the function pointer of the registration function.
[0025] Parsing the param field, comprising: According to the type of each parameter in the data, extracting the corresponding variable address; wherein the type of the parameter includes: constant, source measurement point, common measurement point; Constant: directly storing the address of the constant value; Source measurement point: obtaining the data storage address of the source measurement point in the system; Storing all variable addresses in a pointer array according to the order of data; Converting the logic content into a json object; Passing the extracted pointer data and the json object into the function pointer of the registration function and executing, extracting the data processing logic in the json object, and creating a lambda function in combination with the pointer array.
[0026] Creating a lambda function, comprising: Creating successfully, and the registration function returns the function pointer of the lambda function; Failed to create, the registration function returns nullptr.
[0027] Callback function binding, including: The generated lambda function pointer is bound to the target measurement point corresponding to the id in the public model measurement point configuration. The source measurement point in the data of the public model measurement point configuration is associated with the target measurement point.
[0028] Set the function running mechanism, including: Retrieve the lambda function pointer; Get the current value of the parameter and execute the calculation logic; After the calculation is completed, the lambda function directly writes the result to the public model measurement point for the upper layer application to access.
[0029] Retrieve the lambda function pointer, including: When the source measurement point is updated, retrieve the lambda function pointer of the associated target measurement point; If the pointer is nullptr: Determine that the calculation logic is invalid, and do not perform subsequent operations; If the pointer is not nullptr: Call the lambda function to start the calculation process.
[0030] Get the current value of the parameter and execute the calculation logic, including: Execute the logical expression defined in the logic in the public model measurement point configuration; The variables in the expression are obtained from the pointer array according to the numerical index in the logic, and the calculation logic is executed.
[0031] For example: Step 1: Public model measurement point configuration; The user defines the following configuration information for the line voltage measurement point in the system: { "id": 4, "func": "auto_calc", "param": { "data": ["1.732", "s35"], "logic": { "formula": "0 1" } } } The meanings of each field are as follows:
[0032] The system will automatically obtain the corresponding values according to the above configuration information and substitute them into the formula for calculation, and the final result is written to the target measurement point for calling by the upper application.
[0033] Step 2: Function registration mechanism; When the system starts or receives a new measurement point configuration, the following operations are performed: Extract function name: parse json configuration file, extract func field content (such as auto_calc); Find the registered function list: If the registered function name exists, get its function pointer; If not, skip this measurement point configuration; The registered function list is a key-value table, with the function name as the key and the function pointer as the value; Parse the parameter field: Parse the data and logic fields; Extract the variable address according to the parameter type (constant, source measurement point, etc.) in data; Store the variable address in the pointer array; Convert logic to a structured json object; Create a callback function: Pass the pointer array and json object into the corresponding registered function pointer; Build a lambda expression inside the function and return the function pointer of the expression; Create successfully, return the lambda function pointer; Failed to create, return nullptr; Step 3: Callback function binding; After completing the function registration, the following binding operations are performed: Bind the callback function: bind the lambda function pointer created in step 2 to the target measurement point id=4; Establish an association relationship: associate the source measurement point s35 with the target measurement point id=4, and ensure that the callback function is triggered when s35 is updated.
[0034] Step 4: Function running mechanism; When the source measurement point s35 is updated, the system performs the following process: Trigger the callback function: detect s35 data changes and trigger the callback function of the target measurement point bound to it; Get the latest data: Take the current parameter value from the pointer array: value0=1.732; value1=s35's current value (such as 220V); Perform expression calculation: The calculation result is value0 value1=1.732×220=381.04V; Write to target measuring point: Write the calculation result to the target measuring point with the measuring point id of 4; The upper-layer application can obtain the line voltage value by accessing the measuring point.
[0035] Referring to Figure 2 , the second aspect embodiment of the present application provides a configuration-driven-based automatic data calculation system, comprising a data setting module, a data processing module and a running module. The data setting module is used for setting a common model measuring point configuration. The data processing module is used for reading the common model measuring point configuration information, executing a function registration mechanism, and performing callback function binding. The running module is used for setting a function running mechanism and executing.
[0036] The above embodiments are only used to illustrate the technical method of the present application and are not limited. Although the present application is described in detail with reference to the preferred embodiments, it should be understood by those skilled in the art that the technical method of the present application can be modified or replaced equivalently without departing from the spirit and scope of the technical method of the present application.
Claims
1. A configuration-driven automated data computation method, characterized in that, include: Configure the measurement points for the common model; After reading the public model measurement point configuration information, the function registration mechanism is executed; Bind callback functions; Define the function's execution mechanism.
2. The configuration-driven automated data calculation method according to claim 1, characterized in that, The configuration of common model measurement points includes: Configure the registered function name func and its parameter field param in the public model measurement points; the parameter field param includes: input parameter data and logical parameter logic.
3. The configuration-driven automated data calculation method according to claim 1, characterized in that, The execution function registration mechanism includes: Extract the registered function name from the func field; The system searches the registered function list to see if the registered function name exists. If it exists, it retrieves the function pointer of the registered function and continues to parse the param field. If it does not exist, it skips the configuration of this test point. The registered function list is a user-defined key-value table of registered functions, where the key is the registered function name and the value is the function pointer of the registered function.
4. The configuration-driven automated data calculation method according to claim 3, characterized in that, The parsed param field includes: Based on the type of each parameter in the data, extract the corresponding variable address; the parameter types include: constant, source measurement point, and common measurement point; Constant: The address that directly stores the constant value; Source measurement point: Obtain the data storage address of the source measurement point in the system; Store the addresses of all variables into a pointer array in the order of data; Convert the logic content into a JSON object; The extracted pointer data and JSON object are passed into the function pointer of the registered function and executed. The data processing logic in the JSON object is extracted and combined with the pointer array to create a lambda function.
5. The configuration-driven automated data calculation method according to claim 4, characterized in that, The creation of the lambda function includes: Creation successful; the registration function returns a function pointer to the lambda function. Creation failed; the registration function returned nullptr.
6. The configuration-driven automated data calculation method according to claim 1, characterized in that, The callback function binding includes: Bind the generated lambda function pointer to the target measurement point corresponding to the id in the public model measurement point configuration; Establish a relationship between the source measurement points and the target measurement points in the data of the public model measurement point configuration.
7. The configuration-driven automated data calculation method according to claim 1, characterized in that, The defined function operation mechanism includes: Retrieve lambda function pointers; Get the current value of the parameter and execute the calculation logic; After the calculation is complete, the lambda function writes the result directly to the measurement point of the common model.
8. The configuration-driven automated data calculation method according to claim 7, characterized in that, The retrieval of lambda function pointers includes: When the source measurement point is updated, retrieve the function pointer of the lanbda function associated with the target measurement point; If the pointer is nullptr: the calculation logic is deemed invalid, and no further operations are performed; If the pointer is not nullptr: call the lambda function to start the computation process.
9. The configuration-driven automated data calculation method according to claim 7, characterized in that, The step of obtaining the current value of the parameter and executing the calculation logic includes: Execute the logical expression defined in the logic field of the common model measurement point configuration; The variables in the expression retrieve their current values from the pointer array according to the numeric index in logic, and then perform the calculation logic.
10. A configuration-driven automated data computing system, executing the configuration-driven automated data computing method according to any one of claims 1-9, characterized in that, include: Data setting module, data processing module, and operation module; Data setting module: Used to set the configuration of measurement points for the common model; Data processing module: used to read the configuration information of the measurement points of the public model and then execute the function registration mechanism; And, perform callback function binding; Runtime module: Used to set the function execution mechanism and execute it.
Citation Information
Cited By
An RTOS task hook type adaptation method based on a compile-time static trampoline function table
CN122431993A