A new energy station index calculation method based on JavaScript script language and a multi-format new energy centralized control system

CN122985276APending Publication Date: 2026-10-27XUCHANG XJ SOFTWARE TECHNOLOGIES LTD +2
View PDF 1 Cites 0 Cited by

Patent Information

Application Number
CN202611157800.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-31
Publication Date
2026-10-27

AI Technical Summary

Technical Problem

[0006]本发明的目的是提供一种基于JavaScript脚本语言的新能源场站指标计算方法、多业态新能源集控系统,用以解决新能源场站指标计算存在指标计算逻辑固化,难以适应多样化需求,且指标计算过程缺乏同一的数据访问接口的问题

Benefits of technology

[0025]本发明的有益效果为:通过构建计算引擎,将JavaScript脚本编译为可执行的函数对象,并在引擎中分类调度执行,显著提升了新能源场站指标计算的灵活性和扩展性。用户无需重新编译C++代码,仅需修改JS脚本即可动态更新指标逻辑,大幅降低了运维成本。同时,通过引擎隔离与线程分级机制,实现了计算资源的按需分配,有效避免了高并发场景下的资源竞争,保证了多指标并行计算的高效性与系统稳定性,为新能源场站的实时监控与数据分析提供了可靠的技术支撑。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122985276A_ABST
    Figure CN122985276A_ABST
Patent Text Reader

Abstract

The present application relates to a new energy station index calculation method based on JavaScript script language and a multi-format new energy centralized control system, and belongs to the technical field of new energy centralized control. By constructing a calculation engine, the JavaScript script is compiled into an executable function object, and the execution is scheduled and executed in the engine, which significantly improves the flexibility and expandability of new energy station index calculation. Users do not need to recompile C++ code, but only need to modify the JS script to dynamically update the index logic, which greatly reduces the operation and maintenance cost. At the same time, through the engine isolation and thread grading mechanism, the on-demand allocation of computing resources is realized, effectively avoiding resource competition in high concurrency scenarios, ensuring the efficiency and system stability of multi-index parallel calculation, and providing reliable technical support for real-time monitoring and data analysis of new energy stations.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to a method for calculating indicators of new energy power plants based on the JavaScript scripting language and a multi-business new energy centralized control system, belonging to the field of new energy centralized control technology. Background Technology

[0002] The indicator system of the new energy centralized control system is a crucial component in measuring the power generation capacity, profitability, and management capabilities of new energy power plants. It provides fundamental support for the operation assessment, business decision-making, and operation and maintenance management of new energy power plants. With the rapid development of new energy industries such as wind power and photovoltaics, the number of new energy power plants continues to grow, and the installed capacity continues to expand. As a result, the amount of indicator data that the centralized control center needs to process has increased dramatically, and the complexity and diversity of indicator calculations have also increased significantly.

[0003] Currently, existing centralized control systems for new energy sources typically calculate indicators by retrieving the necessary data from a database and then performing the calculation according to a pre-defined formula. While this fixed calculation method is simple to implement, it often requires modifying the backend program code and recompiling and deploying it when users need to customize new indicator calculation logic based on actual business scenarios. This results in long development cycles, high maintenance costs, and an inability to meet the rapidly changing needs of new energy power plant indicator calculations. Furthermore, new energy power plant indicator calculations involve various data sources, including model data, real-time data, and historical data. The access interfaces for these data types in existing systems are often inconsistent, requiring script developers to write different access codes for different data sources. This increases the complexity of script development, the probability of errors, and limits the versatility and reusability of indicator calculation scripts.

[0004] It is evident that the calculation of indicators for new energy power plants suffers from a rigid calculation logic that makes it difficult to adapt to diverse needs, and the lack of a unified data access interface in the calculation process.

[0005] Chinese invention patent application CN113986404A discloses a JavaScript script execution method, apparatus, electronic device, and storage medium. The method involves loading JavaScript expression scripts from the program configuration during system startup or initialization, converting them into corresponding JavaScript functions, and compiling them into a script engine. Subsequently, during system transaction processing, if the target JavaScript expression script needs to be executed, only the context object needs to be used as a function parameter to call the script engine to execute the corresponding compiled JavaScript function. This avoids parsing and processing every time the script is executed, reducing script processing time and improving transaction processing efficiency. However, this patent (CN113986404A) only discloses a general method for pre-compiling JavaScript expression scripts into functions and caching them in the script engine to avoid repeated parsing; it does not implement the creation and configuration of calculation engines for different calculation types in the field of new energy index calculation. Summary of the Invention

[0006] The purpose of this invention is to provide a method for calculating indicators of new energy power stations based on the JavaScript scripting language and a multi-business new energy centralized control system, in order to solve the problems of fixed indicator calculation logic, difficulty in adapting to diversified needs, and lack of a unified data access interface in the indicator calculation process of new energy power stations.

[0007] To address the aforementioned technical problems, the first aspect of this invention provides a method for calculating the indicators of new energy power stations based on the JavaScript scripting language, comprising the following steps: 1) Compile the JavaScript script containing the calculation logic for new energy power station indicators into an executable function object; 2) During the operation of the new energy power station, in response to the occurrence of a driving event that triggers the calculation of indicators, a function object is called, and the running thread corresponding to the driving event performs the calculation to obtain the new energy power station indicators.

[0008] In one possible implementation, the JavaScript script containing the calculation logic for new energy power station indicators is compiled into an executable function object using the following method: According to the calculation type of the pre-defined new energy power station indicators, determine the target calculation type of the JavaScript script and configure the running thread for the target calculation type; initialize the running thread of the target calculation type, and based on the target calculation type and the running thread of the initialized target calculation type, call the QJSEngine function algorithm to convert the target calculation type and the running thread of the initialized target calculation type into the function object for execution within the C++ process.

[0009] In one possible implementation, the running thread of the target computation type is initialized by configuring a preset C++ fixed logic function interface and a preset public JS computation library in the running thread of the target computation type, so that when the running thread performs computation, it calls computation data through the C++ fixed logic function interface and calls computation functions through the public JS computation library.

[0010] In one possible implementation, when invoking the QJSEngine function algorithm, a set of driving events is set for the running thread of the initialized target calculation type; wherein, in response to the occurrence of a driving event that triggers the index calculation, the function object is invoked, and the calculation is performed by the running thread corresponding to the driving event, including: In response to a driving event that triggers the calculation of an indicator, a function object is invoked to determine the driving event set to which the driving event belongs and its running thread. The calculation is then performed by the running thread of the determined driving event set.

[0011] In one possible implementation, the calculation types for the pre-defined new energy power station indicators include periodic calculation, change data-triggered calculation, supplementary calculation, and recalculation calculation.

[0012] In one possible implementation, when the target computation type is a periodic computation type, the set of driving events includes driving events when the execution time reaches a preset periodic time; When the target calculation type is a calculation class triggered by changing data, the set of driving events includes preset driving events for passing in changing data through the interface used for running data.

[0013] In one possible implementation, the method further includes: creating a computing engine for compiling and executing the function object, so as to execute the function object in the computing engine and calculate the new energy power station indicators.

[0014] One possible implementation also includes: assigning a calculation engine to the JavaScript script based on the JavaScript script's property information.

[0015] In one possible implementation, when a JavaScript script configures the exclusive engine property, the executable function object compiled by the script exclusively uses a computing engine. When a JavaScript script is configured to use the public engine property of its computed indicator object, the executable function object compiled by the script uses the public engine of its computed indicator object.

[0016] To address the aforementioned technical problems, a second aspect of the present invention provides a multi-business new energy centralized control system, including a processor, wherein the processor executes a computer program to implement the steps of the method described below: 1) Compile the JavaScript script containing the calculation logic for new energy power station indicators into an executable function object; 2) During the operation of the new energy power station, in response to the occurrence of a driving event that triggers the calculation of indicators, a function object is called, and the running thread corresponding to the driving event performs the calculation to obtain the new energy power station indicators.

[0017] In one possible implementation, the JavaScript script containing the calculation logic for new energy power station indicators is compiled into an executable function object using the following method: According to the calculation type of the pre-defined new energy power station indicators, determine the target calculation type of the JavaScript script and configure the running thread for the target calculation type; initialize the running thread of the target calculation type, and based on the target calculation type and the running thread of the initialized target calculation type, call the QJSEngine function algorithm to convert the target calculation type and the running thread of the initialized target calculation type into the function object for execution within the C++ process.

[0018] In one possible implementation, the running thread of the target computation type is initialized by configuring a preset C++ fixed logic function interface and a preset public JS computation library in the running thread of the target computation type, so that when the running thread performs computation, it calls computation data through the C++ fixed logic function interface and calls computation functions through the public JS computation library.

[0019] In one possible implementation, when invoking the QJSEngine function algorithm, a set of driving events is set for the running thread of the initialized target calculation type; wherein, in response to the occurrence of a driving event that triggers the index calculation, the function object is invoked, and the calculation is performed by the running thread corresponding to the driving event, including: In response to a driving event that triggers the calculation of an indicator, a function object is invoked to determine the driving event set to which the driving event belongs and its running thread. The calculation is then performed by the running thread of the determined driving event set.

[0020] In one possible implementation, the calculation types for the pre-defined new energy power station indicators include periodic calculation, change data-triggered calculation, supplementary calculation, and recalculation calculation.

[0021] In one possible implementation, when the target computation type is a periodic computation type, the set of driving events includes driving events when the execution time reaches a preset periodic time; When the target calculation type is a calculation class triggered by changing data, the set of driving events includes preset driving events for passing in changing data through the interface used for running data.

[0022] In one possible implementation, the method further includes: creating a computing engine for compiling and executing the function object, so as to execute the function object in the computing engine and calculate the new energy power station indicators.

[0023] One possible implementation also includes: assigning a calculation engine to the JavaScript script based on the JavaScript script's property information.

[0024] In one possible implementation, when a JavaScript script configures the exclusive engine property, the executable function object compiled by the script exclusively uses a computing engine. When a JavaScript script is configured to use the public engine property of its computed indicator object, the executable function object compiled by the script uses the public engine of its computed indicator object.

[0025] The beneficial effects of this invention are as follows: By constructing a computing engine, JavaScript scripts are compiled into executable function objects and executed in a categorized manner within the engine, significantly improving the flexibility and scalability of new energy power plant indicator calculations. Users do not need to recompile C++ code; they only need to modify the JS script to dynamically update the indicator logic, greatly reducing operation and maintenance costs. Simultaneously, through engine isolation and thread hierarchical mechanisms, on-demand allocation of computing resources is achieved, effectively avoiding resource contention in high-concurrency scenarios, ensuring the efficiency and system stability of parallel calculations of multiple indicators, and providing reliable technical support for real-time monitoring and data analysis of new energy power plants. Attached Figure Description

[0026] Figure 1 This is a flowchart of a method for calculating indicators of new energy power stations based on the JavaScript scripting language proposed in this invention; Figure 2 This is a flowchart illustrating the initialization, driving, and termination release of the calculation engine in a practical application scenario of the new energy power station index calculation method based on JavaScript proposed in this invention. Figure 3 This is a schematic diagram illustrating the scheduling and optimization of calculation threads for different script types in a practical application scenario of the new energy power station index calculation method based on JavaScript language proposed in this invention. Figure 4 This invention proposes a multi-business new energy centralized control system. Detailed Implementation

[0027] To make the objectives, technical solutions, and advantages of the present invention clearer, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments.

[0028] The inventive concept of this invention is as follows: define a computing engine module and its interface, initialize the computing engine module, manage and drive the initialized engine module with threads, and optimize the scheduling and operation of different types of computing threads. This enables the loading of JS-based computing function scripts using C++ processes, reducing the system upgrade pressure caused by hard coding, lowering the cost of developing multiple indicators, and maximizing the opening and execution efficiency of custom indicators in the new energy centralized control system.

[0029] Detailed implementation method 1: like Figure 1 The diagram shows a flowchart of a method for calculating the indicators of a new energy power station based on the JavaScript scripting language proposed in this invention. The method includes steps S11 and S12, specifically: Step S11: Compile the JavaScript script containing the calculation logic for new energy power station indicators into an executable function object; here, the executable function object refers to a function object executed within a C++ process; the JavaScript script containing the calculation logic for new energy power station indicators is compiled into an executable function object by the following method: according to the pre-defined calculation type for new energy power station indicators, determine the target calculation type of the JavaScript script, and configure a running thread for the target calculation type; here, the calculation type includes, but is not limited to, periodic calculation type, change data triggered calculation type, supplementary calculation type, and recalculation calculation type.

[0030] The target computation type's running thread is initialized, and based on the target computation type and the initialized target computation type's running thread, the QJSEngine function algorithm is called to convert the target computation type and the initialized target computation type's running thread into the function object for execution within the C++ process. Here, during the initialization of the target computation type's running thread, a preset C++ fixed logic function interface and a preset public JS computation library are configured in the target computation type's running thread so that when the running thread performs computation, it can call computation data through the C++ fixed logic function interface and call computation functions through the public JS computation library.

[0031] When calling the QJSEngine function algorithm, a driving event set is set for the running thread of the target calculation type after initialization. Here, during the operation of the new energy power station, multiple JavaScript script compilation function objects may be running simultaneously, and the indicators calculated by each JavaScript script may be indicators for a specific new energy device, or they may be "unified" indicators for multiple new energy devices. Therefore, a separate driving event set is set for each JavaScript script.

[0032] Step S12: During the operation of the new energy power station, in response to the occurrence of a driving event that triggers the calculation of indicators, a function object is called, and the running thread corresponding to the driving event performs the calculation to obtain the new energy power station indicators. It should be noted that, in response to the occurrence of a driving event that triggers the calculation of indicators, a function object is called to determine the driving event set to which the driving event belongs and its running thread, and the running thread of the determined driving event set performs the calculation.

[0033] Through steps S11-S12 above, these JS scripts are injected into the C++ process, realizing the integration of the C++ process with the custom simple JS language, which facilitates the calculation and setting of new energy power station indicators and significantly improves the flexibility and scalability of new energy power station indicator calculation.

[0034] Method Detailed Implementation 2: Below, from a practical application perspective, we will explain the method for calculating indicators of new energy power stations based on the JavaScript scripting language proposed in this invention. The explanation will be presented from three angles: (1) the construction, interface, and function interfaces of the calculation engine during its operation; (2) the initialization and thread-driven configuration of the calculation engine module; and (3) the scheduling and optimization of calculation threads for different script types. Specifically: (1) The computing engine construction, computing engine interface and function interface involved in the operation of the computing engine Create a computation engine object for compiling and executing function objects. Upon creation, this computation engine object is implemented in C++. This object (i.e., the computation engine object) is a singleton object within the C++ process. Internally, it manages the periodic computation thread, the triggering computation thread, the recalculation thread, and the main program log capture function object. In practical applications, the following code is preferred for implementation: CALCENGINE_Export std::shared_ptr <icalengine>CreateCalEngine(); The interfaces, parameters, functions, and return values ​​involved in the created computing engine object are described as follows: virtual int InitEnv(IALignDataAccess dacc, QString&err,EngLogCallbackType debugcallback, int mode = 0) = 0; The computation engine object initialization interface is called after obtaining the computation engine object. Its input and output parameters are: dacc is the data object, provided by the main program; err is the error information during the engine initialization process; debugcallback is the callback function of the main program, used to return error information during the loading and execution process; mode 0 is real-time mode, mode 1 is supplementary recording mode, and mode 3 is debug mode; the return value is 0 to indicate success, and other return values ​​indicate failure.

[0035] The dacc object is an interface for accessing new energy system model data, real-time data, and historical data within a JavaScript script, and will not be described in detail here.

[0036] The main program's callback function, debugcallback, is defined using the following algorithm: using EngLogCallbackType = std::function<void(int level, QString&errinfo)> ; MyClass myObject; EngLogCallbackType callback = std::bind(&MyClass::myMemberFunction,&myObject,std::placeholders::_1,std::placeholders::_2); In the algorithm of the callback function of the main program mentioned above, the log information generated during the engine calculation process can be captured by the external main program through the MyClass::myMemberFunction function, and used for error message prompts and output during the calculation process.

[0037] Additionally, the following interfaces are used to release, start, and stop computing engine objects: virtual int UninitEnv() = 0; / / Release the engine and clean up caches generated during engine operation; virtual int Start() = 0; / / Start the engine, begin the periodic timer driving thread, and start the data change thread to listen for data changes; virtual int Stop() = 0; / / Stop the engine, stop the timed driver thread, stop the data change driver, and wait for the current calculation to finish before the driver thread stops.

[0038] In addition, the corresponding functions are implemented through the following interfaces: virtual int DataSuppComplete(TSTSuppEndData&stdata) = 0; (1) After offline data for all time frames of a network outage is completed, the interface represented by the above statement (1) is called to drive the recalculation function. TTSSuppEndData defines the unique identifier (id) of the site containing the offline data for this offline data supplementation, as well as the start and end times of the offline data.

[0039] virtual int OnDataChange(TTypeChgData&chgdata) = 0; (2) The data change callback function of the calculation engine module is called by the main program. When a certain type of data change occurs, the function contained in the above statement (2) is called to pass the changed data into the engine. The calculation engine uses the changed data to calculate the JS script driven by the data change. The information contained in the TTypeChgData structure is: the type of the new energy centralized control system equipment table, the field name of the changed data and its corresponding unique identifier (id) list of change records.

[0040] virtual int SetFrameDataToCalc(QDateTime&datafrmtime) =0; (3) After supplementing a single time point data frame, the interface represented by the above statement (3) is called to drive the execution of the JS script function for periodic calculation during the supplementation calculation, where datafrmtime is the data frame time.

[0041] virtual int ReloadFunction(QList <tfunctiondefforq>&funcs, QString&err, bool restart = true) = 0; (4) Reload all script functions. In statement (4), ReloadFunction will stop all function calculation threads, clear the existing function cache, reload the function cache, and update all functions in the engine cache to the funcs function list; err, the error message returned when reloading functions; restart, whether to restart all calculation threads. This interface can be used for debugging with editing tools.

[0042] virtual int ExecFunc(TFunctionDefForQ&func, QList <QObject >params,QString&err) = 0; (5) Executing a function is called by the editing tool. In statement (5), params is the parameter list when the function is executed, err is the error message when the function is executed, and debugcallback is the error message callback function of the main program, used to return the error message during the loading and execution process. The TFunctionDefForQ structure is the description model of the calculation function.

[0043] (2) Initialization and thread-driven configuration of the computing engine module Here, in conjunction with the attached diagram Figure 2 The creation, initialization, startup, and thread driving of the computing engine module are described in detail. This includes steps one through five, specifically: Step one: The C++ main process calls the interface for creating a calculation engine object at an appropriate time to obtain the calculation engine object used to execute user-defined JS scripts. In practical applications, the module implementing the JavaScript language method for calculating new energy power station indicators described in this invention is a dynamic library, loaded and initialized by another process. Before the module is initialized, the process itself may need to initialize other data. Therefore, the appropriate time refers to when this module needs IAlignDataAccess... After initializing the dacc data, create the computation engine object interface.

[0044] Step Two: Call the computing engine initialization interface to initialize the computing engine's runtime environment and computing environment. The processing performed in this step is as follows: First, the JS function objects contained in the user-defined JS script are loaded. Based on the calculation type and thread configuration of the JS function objects, periodic calculation execution threads, change-data-triggered calculation execution threads, periodic supplementary calculation execution threads, and recalculation execution threads are assigned to the JS function. During the initialization of the aforementioned execution threads, the built-in C++ fixed logic function (i.e., built-in C++ fixed logic object) interface is also loaded, and additional common JS calculation libraries are initialized in the aforementioned execution threads.

[0045] Here, the built-in C++ fixed logic function interface is used to place the C++ function library in a fixed directory. The computing engine loads the C++ function library, and these function interfaces are "hung" into the process's runtime memory and "connected" to the JS environment of the aforementioned running thread, allowing JS to call its loaded C++ code using simple names. The initialization of additional public JS computing library is used to dynamically inject a set of pre-defined, reusable, non-business-oriented standardized JS algorithms into the JS execution context of each thread during the startup phase of the aforementioned running thread.

[0046] Then, the JS script function object is initialized as an executable and callable object in QJSEngine, and the execution mode of the calling object is set (periodic drive, change data trigger drive, recalculation interface call drive). That is, the calculation engine calls the compilation interface of QJSEngine to compile / convert the JS script function object into a runnable / executable function object in memory, and sets the corresponding execution mode of calling the function object.

[0047] Step 3: Start the computing engine after initialization.

[0048] After the initialization of the JavaScript function execution threads is completed, the computation engine is started, and the execution threads of each JavaScript function start automatically. Among them, the thread triggered by changing data is started, and the main process calls the computation engine's OnDataChange interface to pass in the changed data to trigger the driving computation.

[0049] The periodic calculation thread is started and the calculation is driven by the periodic time configured in the JS script model.

[0050] The periodic calculation thread is started, and the calculation is driven by the main process calling the calculation engine's SetFrameDataToCalc.

[0051] The recalculation thread is started by the main process calling the computation engine's DataSuppComplete to drive the computation.

[0052] Step 4: When the main process needs to stop the computing engine, it calls the Stop interface of the computing engine to stop the thread calculation of all JS script functions.

[0053] Step 5: When the main process needs to terminate the use of the computing engine, it calls the UninitEnv interface of the computing engine, and all types of JS script running threads managed within the computing engine will be released.

[0054] (3) Thread scheduling and optimization for different script types Based on the thread configuration method of the JavaScript function model, optimize the thread scheduling method of the executable objects of the script functions. For details, refer to [link / reference needed]. Figure 3 As shown, the details are as follows: If the JavaScript function model is configured as an exclusive engine (that is, when a JavaScript script has the exclusive engine property configured, the executable function object compiled by the script has exclusive use of a computing engine): then this script function has exclusive use of a computing engine and uses an independent running thread. The QJSEngine managed in this thread is only used to execute this one script function, ensuring the independence and efficiency of function execution.

[0055] If the JavaScript function model is configured not to use an exclusive engine, but instead to use the object's common engine (that is, when a JavaScript script is configured to use the common engine property of its computed metric object, the executable function object compiled by the script uses the common engine of its computed metric object): the running thread of this JavaScript function is the object's shared thread, and all JavaScript functions of this object run in the QJSEngine managed by this thread. This configuration method is suitable when the computational load is not very time-consuming, but the JavaScript functions need to share the global computation results of this object. For example, if two JavaScript functions are set up for the same new energy equipment (wind turbine / photovoltaic / energy storage), and these two JavaScript functions involve the same running parameters, then these two JavaScript functions can be set in the same computed engine (i.e., the common engine).

[0056] If the JavaScript function model is configured not to use a dedicated engine or the object's common engine, then the execution thread for this JavaScript function is a globally shared thread. The QJSEngine managed by this thread runs all JavaScript functions configured as globally shared threads. This configuration method is suitable for situations where the computational load is not very time-consuming and there is no need to share data with this object.

[0057] Method Detailed Implementation 3: The following explanation focuses on the calculation of new energy power plant indicators in a multi-format new energy centralized control system. Taking the calculation of the theoretical power of a photovoltaic power plant as an example, the following is the JavaScript code that implements the calculation of the theoretical power of a photovoltaic power plant (it should be noted that the code is only a simplified illustration of the JavaScript-based method for calculating new energy power plant indicators proposed in this invention when actually calculating the theoretical power of a photovoltaic power plant; the specific calculation of the theoretical power of the photovoltaic power plant is only a simplified illustration, and in actual engineering, the specific calculation method can be set by the photovoltaic manufacturer): function pvstathdpower() { var stlst = alignDataAccess.GetObjectByType("align_pv_st"); / / Get the list of photovoltaic power station objects through the data object if (stlst.length === 0) { logout.WarnLog("No photovoltaic found"); return; } / / Calculate the theoretical power of the photovoltaic power station in a loop for(var i=0;i <stlst.length;++i) { var st=stlst[i]; var sttype= st.GetValByName("stationtypeid"); var stid = st.GetValByName("id"); var stname = st.GetValByName("name"); / / Skip if the site type is configured incorrectly. if (sttype != 7) { continue? } / / Retrieve configuration and real-time parameters through data objects var installedcapacity = st.GetValByName("installedcapacity"); / / Installed capacity var irradiancevalue = st.GetValByName("irradiancevalue"); / / Irradiance var thdpower = pvthdpowercalcobj.calcthdpower(installedcapacity, irradiancevalue); / / Theoretical power is calculated using the internal C++ function interface. st.SetValByName("stationthdpower",thdpower,1); / / The calculation result is written to the real-time cache and synchronized to the real-time library. logout.DebugLog("station id: " + stid+",stname:"+stname+",sttype:"+sttype+ ",installedcapacity:"+installedcapacity+",irradiancevalue:"+ irradiancevalue+",stationcalculateqvalue="+thdpower); } }; By running the above code, the theoretical power of the photovoltaic power station can be calculated.

[0058] Based on the above, the process of creating the engine object is explained from aspects such as initializing the engine, loading JavaScript functions, loading C++ function libraries, initializing execution functions for various types of scripts, and periodically calculating the arrival of JavaScript function cycles. 1. Initialize the engine By passing in IAlignDataAccess The parameter dacc will be used to inject the object into the JavaScript runtime environment with the name alignDataAccess.

[0059] 2. Load JavaScript functions: Define the function `pvstathdpower`, which calculates the real-time theoretical power of a photovoltaic power station. This function is a periodic calculation function. The function flow in the script is as follows: Retrieve the list of photovoltaic power plants using the data object alignDataAccess; Iterate through the list of photovoltaic power plants, and for each photovoltaic power plant, read the installed capacity and the current irradiance value.

[0060] The function `calcthdpower` from the C++ interface library for calculating theoretical photovoltaic power is called, and the installed capacity of the photovoltaic power station and the current irradiance parameter `irradiancevalue` are passed in. The return value is the corresponding theoretical power. The calculation result is written to the data cache and synchronized to the real-time library.

[0061] 3. Load the C++ function library, specifically the C++ module for calculating the theoretical power of photovoltaic power, and specify its JavaScript object name as: pvthdpowercalcobj. The calculation logic for the theoretical power is encapsulated within this C++ module. The calcthdpower function is called when needed.

[0062] 4. Initialize the runtime environment for various types of script functions, and mount C++ function libraries to the JavaScript runtime environment. Also, start various JavaScript function execution threads (including the periodic calculation JavaScript function execution thread).

[0063] 5. Periodic calculation: When the js function reaches its periodicity, calculate the theoretical power of each photovoltaic power station according to the pvstathdpower function flow.

[0064] System Specific Implementation Method 1: A multi-business new energy centralized control system according to the present invention is shown in the schematic diagram below. Figure 4 As shown, the system includes a memory, a processor, a system bus, and a computer program stored in the memory. The processor and memory communicate and interact with each other via the system bus. The processor executes the computer program to implement the steps of the new energy power station indicator calculation method based on the JavaScript scripting language of this invention. The processor can be a microprocessor (MCU) or other processing device; the memory can be any type of memory that stores information using electrical energy, such as non-volatile storage media (including computer programs, databases), or other types of memory.

[0065] In summary, by utilizing the computing engine module and its interface; initializing, managing, and driving the computing engine module; and scheduling and optimizing different types of computing threads, the system enables the loading of JS-based computing function scripts using C++ processes. This reduces the system upgrade pressure caused by hard coding, lowers the cost of developing multiple indicators, and maximizes the efficiency of custom indicator development and execution in the new energy centralized control system.

[0066] This invention, based on the indicator analysis of a new energy centralized control system, defines indicator calculation as JavaScript script functions. These JavaScript script functions are injected into a C++ process, achieving integration between the C++ process and a custom, simple JavaScript language. QJSEngine is used to calculate the JavaScript script functions. A calculation engine module is implemented, along with the necessary interfaces, providing custom indicator calculation and thread management scheduling based on the JavaScript language. This satisfies the calculation requirements of the JavaScript script functions while also considering calculation efficiency and management. The developed JavaScript scripts are clearly categorized and easy to manage.< / tfunctiondefforq> < / icalengine>

Claims

1. A method for calculating indicators of new energy power stations based on JavaScript scripting language, characterized in that, Includes the following steps: 1) Compile the JavaScript script containing the calculation logic for new energy power station indicators into an executable function object; 2) During the operation of the new energy power station, in response to the occurrence of a driving event that triggers the calculation of indicators, a function object is called, and the running thread corresponding to the driving event performs the calculation to obtain the new energy power station indicators.

2. The method for calculating the indicators of new energy power stations based on JavaScript scripting language according to claim 1, characterized in that, The JavaScript script containing the calculation logic for new energy power station indicators can be compiled into an executable function object using the following method: Based on the calculation type calculated according to the pre-defined new energy power station indicators, determine the target calculation type of the JavaScript script and configure the running thread for the target calculation type; The target computation type's running thread is initialized, and based on the target computation type and the initialized target computation type's running thread, the QJSEngine function algorithm is invoked to convert the target computation type and the initialized target computation type's running thread into the function object for execution within the C++ process.

3. The method for calculating the indicators of new energy power stations based on JavaScript scripting language according to claim 2, characterized in that, The target computation type's running thread is initialized using the following method: a preset C++ fixed logic function interface and a preset common JS computation library are configured in the target computation type's running thread, so that when the running thread performs computation, the computation data is called through the C++ fixed logic function interface, and the computation function is called through the common JS computation library.

4. The method for calculating the indicators of new energy power stations based on JavaScript scripting language according to claim 2, characterized in that, When invoking the QJSEngine function algorithm, a set of driving events is set for the running thread of the target calculation type after initialization; wherein, in response to the occurrence of a driving event that triggers the index calculation, the function object is called, and the running thread corresponding to the driving event performs the calculation, including: In response to a driving event that triggers metric calculation, a function object is invoked to determine the driving event set to which the driving event belongs and its running thread. The calculation is then performed by the running thread of the determined driving event set.

5. The method for calculating the indicators of new energy power stations based on JavaScript scripting language according to claim 4, characterized in that, The calculation types for the pre-defined new energy power station indicators include periodic calculation, change data-triggered calculation, supplementary calculation, and recalculation calculation.

6. The method for calculating the indicators of new energy power stations based on JavaScript scripting language as described in claim 5, characterized in that, When the target calculation type is a periodic calculation type, the set of driving events includes driving events whose execution time reaches the preset period time; When the target calculation type is a calculation class triggered by changing data, the set of driving events includes preset driving events for passing in changing data through the interface used for running data.

7. The method for calculating the indicators of new energy power stations based on JavaScript scripting language according to claim 1, characterized in that, Also includes: Create a computing engine for compiling and executing the function object, and execute the function object in the computing engine to calculate the new energy power station indicators.

8. The method for calculating the indicators of new energy power stations based on JavaScript scripting language according to claim 7, characterized in that, Also includes: Assign a calculation engine to the JavaScript script based on its property information.

9. The method for calculating the indicators of new energy power stations based on JavaScript scripting language according to claim 8, characterized in that, When a JavaScript script is configured with the exclusive engine property, the executable function object compiled by that script exclusively uses a computing engine; When a JavaScript script is configured to use the public engine property of its computed indicator object, the executable function object compiled by the script uses the public engine of its computed indicator object.

10. A multi-business new energy centralized control system, comprising a processor, characterized in that, The processor executes a computer program to implement the steps of the method according to any one of claims 1 to 9.

Citation Information

Patent Citations

  • JavaScript execution method and device, electronic equipment and storage medium

    CN113986404A