Service logic implementation method and device based on configuration file

Through the business logic implementation method based on configuration files, the problem of complex business logic and dynamic condition judgment in the vehicle system is solved, the system is quickly adapted and efficiently maintained, and the update cost and impact are reduced.

CN118760442AInactive Publication Date: 2024-10-11AUTOCORE INTELLIGENT TECH (NANJING) CO LTD

Patent Information

Application Number
CN202411248603.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-06
Publication Date
2024-10-11
Estimated Expiration
Not applicable · inactive patent

AI Technical Summary

Technical Problem

In existing vehicle systems, hard-coded business logic cannot meet the needs of complex business logic changes and dynamic condition judgments. As a result, the system cannot adapt quickly when the market and technology change, and needs to be restarted or reloaded during updates, affecting continuity and stability. sex.

Method used

Adopt a business logic implementation method based on configuration files, define global parameters, states, state transition rules, events and business logic blocks through configuration language, parse configuration files to build configuration data, traverse execution actions and state transitions, and support dynamic updates and exception recovery. Achieve modularity and flexibility of logic blocks.

Benefits of technology

By adjusting the business logic by modifying the configuration file without modifying the program code, the system can quickly respond to changes, shorten the change cycle, reduce maintenance costs, support complex business logic expression and dynamic state transition, and improve system scalability and maintenance efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118760442A_ABST
    Figure CN118760442A_ABST
Patent Text Reader

Abstract

The invention discloses a service logic implementation method and device based on a configuration file, and the method comprises the steps: loading a configuration file described by adopting a configuration language, and enabling configuration contents to comprise global parameters, states, state conversion rules, state conversion triggering events, event triggering conditions, actions corresponding to the triggering events, and service logic blocks, the business logic block defines a logic block triggering condition and an action corresponding to the logic block; analyzing the configuration file to obtain configuration content, and constructing configuration data stored in a preset data format according to the configuration content; traversing the configuration data, capturing a trigger condition, and outputting a trigger result when the trigger condition of the event or the trigger condition of the logic block is met; and executing an action corresponding to the trigger event according to the trigger result and a state conversion rule, and performing state conversion, or executing an action corresponding to the logic block. When the business logic changes, only the configuration file needs to be modified, the whole application does not need to be recompiled and deployed, and the complex business logic can be flexibly expressed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of data processing technology, and in particular to a method and device for implementing business logic based on a configuration file. Background Art

[0002] In existing vehicle systems, business logic is often carried out in a hard-coded form; at the same time, for a small number of configuration or calibration parameters, configuration files in JSON, XML and other formats are used to configure the system. In this way, business rules, event response logic, state change conditions, etc. are mainly defined through coding, and a small amount of system behavior can be changed without modifying the code, such as the specific value and existence of the judgment condition.

[0003] However, this approach usually only supports simple configuration adjustments and cannot meet the needs of complex business logic changes, dynamic condition judgments, and complex event processing. In particular, when it is necessary to quickly adapt to market and technological changes, existing technologies are unable to cope with the situation. When the system is undergoing major business logic updates, it usually needs to be restarted or reloaded, which affects the continuity and stability of the system. Summary of the invention

[0004] The technical purpose of the present application is to provide a method and device for implementing business logic based on a configuration file in order to address the technical problems that existing system configuration methods cannot handle complex business logic and cannot quickly adapt to changes in business requirements.

[0005] In order to achieve the above technical objectives, this application adopts the following technical solutions.

[0006] In a first aspect, an embodiment of the present application provides a service logic configuration method, including: Loading a configuration file, wherein the configuration file is described in a configuration language, and the configuration content defined in the configuration language includes global parameters, states, state transition rules, triggering events of state transitions, triggering conditions of events, actions corresponding to triggering events, and business logic blocks, wherein the business logic blocks define triggering conditions of logic blocks and actions corresponding to logic blocks; Parse the configuration file to obtain configuration content, and construct configuration data stored in a preset data format according to global parameters, states, state transition rules, triggering events of state transitions, triggering conditions of events, actions corresponding to the triggering events, and business logic blocks; Traversing the configuration data, capturing the triggering condition of the event or the triggering condition of the logic block; when the triggering condition of the event is met, outputting a first triggering result, and when the triggering condition of the logic block is met, outputting a second triggering result; According to the first trigger result and the state transition rule, the action corresponding to the trigger event is executed and the state transition is performed; according to the second trigger result, the action corresponding to the logic block is executed.

[0007] In some implementations, the business logic implementation method further includes: A storage space is provided to store the configuration file, and the storage space provides a read and write interface to read or write the configuration file.

[0008] In some implementations, the configuration file is parsed to obtain configuration content, and configuration data stored in a preset data format is constructed according to global parameters, states, state transition rules, triggering events of state transitions, triggering conditions of events, actions corresponding to triggering events, and business logic blocks, including: According to the keywords, the global parameters, states, state transition rules, triggering events of state transitions, triggering conditions of events, actions corresponding to the triggering events, and business logic blocks are identified from the configuration file, and the configuration file is parsed into vocabulary units; The configuration data is obtained by performing grammatical analysis on the vocabulary units and mapping the business logic blocks, events and states in the configuration file to a memory data structure in a preset data format.

[0009] In some implementations, the service logic implementation method further includes: periodically checking whether the configuration file has been updated, or triggering reloading of the latest configuration file through an external command.

[0010] In some implementations, the logic block triggering condition includes an abnormality determination condition, and the action corresponding to the logic block includes an abnormality recovery measure; The business logic implementation method also includes: when the abnormal judgment condition is met, using the abnormal recovery measure to handle it.

[0011] In some embodiments, the abnormal recovery measures include retrying the operation, exiting the function, switching to a safe mode, recording a log for subsequent analysis, or triggering an alarm system.

[0012] In some implementations, the configuration content includes a nested loop control structure; and the business logic implementation method further includes: According to the logic block triggering condition, it is determined whether the loop control structure starts to execute or terminates execution.

[0013] In some implementations, the logic block trigger condition is defined using a conditional operator, which includes a comparison operator, a logical operator, a string comparison operator, and a Boolean operator.

[0014] In a second aspect, the embodiment of the present application further provides a device for implementing business logic based on a configuration file, including: A configuration manager is used to load a configuration file, wherein the configuration file is described in a configuration language, wherein the configuration content defined in the configuration language includes global parameters, states, state transition rules, trigger events of state transitions, trigger conditions of events, actions corresponding to trigger events, and business logic blocks, wherein the business logic blocks define logic block trigger conditions and actions corresponding to logic blocks; parse the configuration file to obtain the configuration content, and construct configuration data stored in a preset data format according to the global parameters, states, state transition rules, trigger events of state transitions, trigger conditions of events, actions corresponding to trigger events, and business logic blocks; A business logic processor is used to traverse the configuration data and capture the trigger conditions of the event or the trigger conditions of the logic block; when the trigger conditions of the event are met, a first trigger result is output, and when the trigger conditions of the logic block are met, a second trigger result is output; according to the first trigger result and the state transition rule, an action corresponding to the trigger event is executed and a state transition is performed; according to the second trigger result, an action corresponding to the logic block is executed.

[0015] In some implementations, the service logic implementation device further includes: The storage module is used to provide a storage space to store the configuration file, and the storage space provides a read and write interface to read or write the configuration file.

[0016] Compared with the prior art, the configuration file-based business logic implementation method provided by the embodiment of the present application has the following beneficial technical effects: it allows the business logic to be adjusted by modifying the configuration file without modifying the program code, making the system more flexible and able to quickly respond to changes in business needs. When the business logic changes, only the configuration file needs to be modified without recompiling and deploying the entire application, which greatly shortens the change cycle and reduces maintenance costs. Since the configuration file can define global parameters, states, trigger events, trigger conditions, and detailed business logic blocks, complex business logic can be expressed very flexibly. By building configuration data and traversing it to perform corresponding actions, state transitions and business processing can be performed precisely according to the configured logic.

[0017] Compared with the prior art, the business logic implementation device based on the configuration file provided in the embodiment of the present application has the same beneficial technical effects as the business logic implementation method based on the configuration file, and will not be described in detail. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] The drawings described herein are for explanation purposes only and are not intended to limit the scope of the present application in any way. In addition, the shapes and proportional dimensions of the components in the drawings are only for illustration purposes and are used to help understand the present application. They do not specifically limit the shapes and proportional dimensions of the components of the present application. Under the guidance of the present application, those skilled in the art can select various possible shapes and proportional dimensions to implement the present application according to specific circumstances. In the drawings: Figure 1 A flow chart of a method for implementing business logic based on a configuration file provided in an embodiment; Figure 2 A schematic diagram of the structure of a device for implementing business logic based on a configuration file provided in an embodiment; Figure 3 A schematic diagram of the workflow of a device for implementing business logic based on a configuration file provided in an embodiment. DETAILED DESCRIPTION

[0019] In order to enable those skilled in the art to better understand the technical solutions in the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work should fall within the scope of protection of this application.

[0020] Although the existing JSON or XML configuration files are flexible, they can only support simple parameter adjustments and cannot handle complex business logic. Each configuration file usually executes a relatively simple set of business operations and cannot dynamically load or update complex business logic while the system is running. The update of business logic requires the system to be restarted or reloaded; and every major change in business logic requires modifying the code and restarting the system, which increases maintenance costs.

[0021] In order to solve the above problems existing in the prior art, the embodiments of the present application provide a business logic implementation method and device based on a configuration file, which supports a variety of complex in-vehicle business scenarios by defining global parameters, events, states and business logic. This design enables the system to quickly adapt to changes in business needs without the need for frequent modifications to the underlying code, greatly improving the scalability and maintenance efficiency of the system.

[0022] In the description of this application, the terms "first" and "second" are used for descriptive purposes only and should not be understood as indicating or implying relative importance or implicitly indicating the number of technical features indicated. Therefore, the features defined as "first" and "second" may explicitly or implicitly include one or more features.

[0023] The present application is further described below in conjunction with the accompanying drawings and specific embodiments.

[0024] For example, see Figure 1 , a business logic configuration method based on a configuration file, comprising: Step S1: Load the configuration file. The configuration file is described in a configuration language. The configuration content defined in the configuration language includes global parameters, states, state transition rules, trigger events of state transitions, event trigger conditions, actions corresponding to trigger events, and business logic blocks. The business logic blocks define logic block trigger conditions and actions corresponding to logic blocks. Step S2: Parse the configuration file to obtain the configuration content, and construct the configuration data stored in a preset data format according to the global parameters, states, state transition rules, triggering events of state transitions, triggering conditions of events, actions corresponding to the triggering events, and business logic blocks; Step S3: traverse the configuration data to capture the event triggering condition or the logic block triggering condition; when the event triggering condition is met, the first triggering result is output; when the logic block triggering condition is met, the second triggering result is output; Step S4: According to the first trigger result and the state transition rule, execute the action corresponding to the trigger event and perform state transition; according to the second trigger result, execute the action corresponding to the logic block.

[0025] In some embodiments, the language structure and grammar rules of the configuration language are as follows: The language structures include: Configuration file header: defines metadata, such as version, author, creation time, etc.

[0026] Global parameters: define global variables and constants used in the configuration file. These variables will be referenced and used in subsequent event processing modules and state management modules.

[0027] Event: defines the triggering conditions of an event and its corresponding processing logic (i.e. the action corresponding to the triggering event). After the event is triggered, the defined action will be passed to the execution engine of the business logic processor for execution.

[0028] State: defines the system state and the transition rules between states. State changes are triggered by events and maintained by the state management module.

[0029] Business logic block: defines specific business logic and rules, including logic block trigger condition judgment and corresponding execution actions of the logic block. The results generated in the business logic block will be passed to subsequent modules to continue to participate in the maintenance of system status and the execution of business logic.

[0030] The grammar rules include: String: Enclose it in double quotes, such as `"example"`.

[0031] Numeric values: Integers and floating point numbers are represented directly, such as `123` or `45.67`.

[0032] Boolean values: represented by `true` or `false`.

[0033] Trigger condition expression: supports logical operators such as `==`, `!=`, `>`, `<`, etc.

[0034] Action name corresponding to state transition: Use predefined action names, such as "unlockDoors".

[0035] Parameters: The parameters of an action are expressed as key-value pairs, such as `{"intensity": "low"}`.

[0036] The configuration file generated in the embodiment of the present application is written in a configuration language that is easier to understand, reducing the reliance on professional programmers. The business logic blocks in the configuration file can be reused by different applications or services, and only simple configuration is required according to specific needs, which improves the reuse rate of the code.

[0037] In the above configuration language, the business logic block sets the trigger conditions of the logic block and the corresponding actions of the logic block. The business logic block can be regarded as an independent module. Multiple business logic blocks can be set, and each module is responsible for processing specific business logic. This modular design makes the system clearer, easier to understand and maintain. By defining business logic in the configuration file, it is easier to decouple and reconstruct business logic.

[0038] In some embodiments, the service logic implementation method further includes providing a storage space to store the configuration file, and the storage space provides a read and write interface to read or write the configuration file.

[0039] Based on the same inventive concept as the method for implementing business logic based on a configuration file provided in the above embodiment, the embodiment of the present application also provides a device for implementing business logic based on a configuration file, such as Figure 2 and Figure 3 As shown, it includes a configuration manager and a business logic processor.

[0040] The configuration manager is used to load configuration files. The configuration files are described in a configuration language. The configuration content defined by the configuration language includes global variables, states, state transition rules, trigger events for state transitions, trigger conditions for events, actions corresponding to trigger events, and business logic blocks. Business logic blocks define logic block trigger conditions and actions corresponding to logic blocks; parse the configuration files to obtain configuration content, and construct configuration data stored in a preset data format based on global variables, states, state transition rules, trigger events for state transitions, trigger conditions for events, actions corresponding to trigger events, and business logic blocks.

[0041] The business logic processor is used to traverse the configuration data and capture the trigger conditions of the event or the logic block trigger conditions; when the trigger conditions of the event are met, the first trigger result is output, and when the logic block trigger conditions are met, the second trigger result is output; according to the first trigger result and the state transition rule, the action corresponding to the trigger event is executed and the state transition is performed; according to the second trigger result, the action corresponding to the logic block is executed.

[0042] like Figure 2 As shown, in some embodiments, the business logic implementation device also includes a storage module, which is used to provide a storage space to store configuration files, and the storage space provides a read and write interface to read or write the configuration files.

[0043] The configuration file-based business logic implementation device provided in the embodiment of the present application adopts an event-driven architecture, including a storage module, a configuration manager, and a business logic processor. Through the configuration parameterization of the business logic, the decoupling of logic design and logic execution is achieved, thereby improving the flexibility of the system. In addition, the configuration parameters support dynamic updates, and the system can parse the business logic in real time to achieve hot updates.

[0044] Combination Figure 2 and Figure 3 The main functions of each module in some embodiments of the event-driven architecture are described as follows: 1. Configuration Manager: When the system starts, it executes the above steps S1 and S2, loads and parses the configuration file, extracts global variables, event definitions, and state transition rules, etc., and generates configuration data stored in a preset data format. The generated configuration data will be passed to the business logic processor as input data for the event processing module and the state management module.

[0045] 2. Business logic processor: execute the above steps S3 and S4, receive the configuration data defined in the configuration file and load the parameters. The business logic processor executes the corresponding action according to the trigger condition of the event or the trigger condition of the logic block, and passes the first trigger result or the second trigger result parameter to the execution engine for specific operations, such as executing the action corresponding to the trigger event, or the action corresponding to the logic block, or passing the first trigger result or the second trigger result to the state management unit for state conversion, etc.

[0046] 3. Storage module: stores configuration files and provides read and write interfaces for the configuration manager, supports dynamic updates of configuration files and notifies the configuration manager.

[0047] Please continue to see Figure 2 and Figure 3 The workflow of the business logic implementation device based on the configuration file provided in the embodiment includes: Configuration Manager: a) Configuration acquisition: Read the configuration file from the storage module.

[0048] b) Lexical analysis: Parse the configuration file content into vocabulary units, and identify the global variables, event trigger condition definitions, event definitions (including state transition trigger events and actions corresponding to trigger events), and states and state transition rules in the configuration file based on keywords. Generate vocabulary units and pass them to the syntax analysis stage.

[0049] c) Syntax analysis: The configuration manager maps the business logic blocks, events, and states in the configuration file to a memory data structure in a preset data format according to the language rules, and obtains the configuration data in the preset data format (such as a syntax tree data structure). The generated configuration data of the syntax tree data structure will be passed to the business logic processor as the basis for subsequent logic execution.

[0050] Business Logic Processor: a) Data acquisition (data acquisition module): obtain configuration data from the configuration manager, including global variables, event trigger condition definitions, event definitions, states, and state transition rules.

[0051] b) Event processing (event processing module): According to the state transition rules defined in the configuration file, it is responsible for triggering system events such as condition capture and precondition judgment, and outputs the trigger results to the execution engine so that the execution engine can execute the actions corresponding to the trigger events according to the trigger results and state transition rules.

[0052] c) Execution engine: receives the first trigger result parameter and executes the task corresponding to the specific trigger event, such as unlocking the car door, adjusting the temperature, etc.; or receives the second trigger result parameter and executes the action corresponding to the specific logic block, such as starting the cooling system.

[0053] d) State management (state management module): maintain and manage the system state according to the first trigger result or the second trigger result, and execute state transition logic, such as function opening, closing and exception handling mechanism.

[0054] Optionally, the state changes may be recorded and stored in a storage module for subsequent analysis and use.

[0055] In some embodiments, the business logic processor supports dynamic loading and updating of configuration files. The configuration manager parses and loads new configuration files while the system is running, automatically identifies and applies changes therein. New configuration data is delivered to the business logic processor in real time and takes effect immediately without restarting the system. The configuration manager can use memory mapping technology to load configuration files into memory and manage configuration items through data structures (such as hash tables or tree structures). The system periodically checks whether the configuration file has been updated, or triggers configuration reloading through external commands to ensure that the system always uses the latest configuration.

[0056] In some embodiments, the configuration file is also updated. When the configuration file needs to be updated, the configuration file in the storage module can be replaced, and the configuration manager is notified to read the new configuration file. After reading, the configuration manager will parse and verify, and the new configuration data after verification will be passed to the business logic processor.

[0057] Since the logic and variables have been abstracted as configuration parameters, the business logic processor will apply the new configuration in real time without restarting the system. The business logic under the new configuration will be re-parsed and executed through the above process to ensure that the system responds to the latest business needs.

[0058] In some embodiments, the business logic processor is designed as a general execution framework, which is applicable to a wide range of business scenarios in vehicle systems. The processor can adopt a flexible code structure similar to `if...else...then...while`. Compared with traditional transaction scripts that can only process simple logic, the embodiments of the present application can process more complex and diverse business logic, providing stronger applicability and expansion space. The specific design method is as follows: The business logic processor can implement multi-branch conditional judgment by parsing the business logic blocks in the configuration file. The logic block trigger condition expression in the business logic block is defined using the conditional operators in the configuration language, such as ==, !=, >, <, etc. The logic block trigger condition can be defined using the conditional operators, which include comparison operators, logical operators, string comparison operators, and Boolean operators.

[0059] Such as comparison operators: == (equal to), != (not equal to), > (greater than), < (less than), >= (greater than or equal to), <= (less than or equal to).

[0060] Logical operators: && (and), || (or), ! (not).

[0061] String comparison operators: The processor supports comparison operations on string types.

[0062] Boolean operators: true and false represent Boolean values ​​and can be used directly in conditional judgments.

[0063] The business logic processor can support the above operators to meet various condition judgment requirements.

[0064] As an example, the business logic processor converts the conditional expressions in the configuration file into an internal syntax tree structure by parsing them. When running, the business logic processor traverses the syntax tree according to the current system state and input data, and gradually determines and executes the branch logic that meets the conditions. The conditional expression can include simple variable comparisons or more complex multi-condition combination logic.

[0065] In some embodiments, the business logic processor supports multiple loop control structures, such as while, for, and do...while, to meet the needs of operations that need to be executed repeatedly in the vehicle system. The loop structure determines the start and end of the loop based on the conditional expression, and supports automatic exit from the loop when a specific condition is met.

[0066] The business logic processor allows multiple loop structures to be nested in the configuration file to support complex business logic. For example, when monitoring multiple sensor data, you can nest loops to handle abnormal conditions for each sensor.

[0067] Referring to the configuration language above, the state is defined as a data structure that contains the identifier of the current state, the events that can be triggered, and the transition rules between states. These states are defined in the states section of the configuration file and stored in the state table in memory, which is managed in real time by the business logic processor. State transitions are usually triggered by system events, such as the trigger conditions of events defined in the events section of the configuration file.

[0068] The state management module in the business logic processor can update the system status in real time according to the state transition rules in the configuration file based on the results of the event processing module monitoring external and internal events. Whenever a state transition occurs, the business logic processor performs related operations according to the transition logic defined in the configuration file and records the state change log when necessary.

[0069] In some embodiments, the logic block triggering condition includes an exception judgment condition, and the action corresponding to the logic block includes an exception recovery measure. The business logic processor has a built-in exception capture module that can identify and handle various abnormal situations that may occur during runtime, such as invalid input, hardware failure, or logic error. The exception module identifies potential faults by listening to specific events or detecting abnormal conditions. When an exception is captured, the processor will process it according to the exception recovery measures predefined in the business logic block logicBlocks part of the configuration file. Common exception recovery measures include: retrying the operation, exiting the function, switching to safe mode, recording logs for subsequent analysis, or triggering an alarm system.

[0070] In some embodiments, the business logic processor handles exceptions through a try...catch...finally structure. When an exception occurs, the business logic processor first attempts to execute the exception recovery logic in the configuration file; if the exception cannot be handled, a higher-level exception handling mechanism is triggered, the exception is thrown upward to the system level, and further protection measures are taken. Through the above design, the business logic processor not only provides extensive support for conventional vehicle-mounted business scenarios, but also has high flexibility, easy scalability and exception handling capabilities, and is suitable for the execution framework of various vehicle-mounted business scenarios.

[0071] Compared with the existing methods, this application adopts a modular architecture, modularizes functions such as configuration management, business logic processing, state management and exception handling, and achieves a high degree of functional decoupling. This design not only simplifies the system development process, but also reduces the risk of failure caused by functional coupling and facilitates maintenance.

[0072] In some embodiments, the configuration file uses a human-readable text format, such as JSON or XML, and defines the system's global variables, events, states, business logic blocks, and state transition rules.

[0073] As an example, the configuration file structure includes sections such as metadata, globals, events, states, and logicBlocks.

[0074] The application example uses geofence as an example to illustrate the workflow of the configuration file and the business logic implementation method based on the configuration file.

[0075] The following is an example of a configuration file: { "metadata": { / / metadata part "version": "1.0", / / version number "author": "Developer", / / author "created": "2024-06-24" / / creation date }, "globals": { / / Global variable definition "maxSpeed": 120, / / Maximum speed threshold "temperatureThreshold": 25 / / temperature threshold }, "events": [ / / Event definition part { "trigger": "geoFence", / / Trigger event: geofence "condition": "location == 'homeProximity'", / / Event trigger condition: location close to home "actions": [ / / Action list corresponding to the trigger event {"action": "unlockDoors"}, / / Action: unlock the doors {"action": "turnOnLights", "parameters": {"intensity": "low"}}, / / Action corresponding to the trigger event: turn on the lights, the parameter is low intensity {"action": "adjustTemperature", "parameters": {"temperature":22}} / / Action corresponding to the trigger event: adjust the temperature to 22 degrees ] } ], "states": [ / / state definition part { "name": "idle", / / Status name: idle "transitions": [ / / State transition rules {"event": "startEngine", "targetState": "running"} / / Event: start engine, target state: running ] }, { "name": "running", / / Status name: running "transitions": [ / / State transition rules {"event": "stopEngine", "targetState": "idle"} / / Event: Stop engine, Target state: idle } , "logicBlocks": [ / / Business logic block definition { "name": "checkTemperature", / / Logic block name: Check temperature "conditions": [ / / List of logic block trigger conditions {"condition": "currentTemperature>globals.temperatureThreshold"}, / / Logic block trigger condition: Current temperature is greater than the temperature threshold {"condition": "currentSpeed<globals.maxSpeed"} / / Logic block trigger condition: Current speed is less than the maximum speed , "actions": [ / / List of actions corresponding to the logic block {"action": "activateCoolingSystem"} / / Action corresponding to the logic block: Activate the cooling system } 。

[0076] As can be seen from the above example, the state transition rules define the current source state, the state transition trigger conditions corresponding to the source state, and the target state.

[0077] Combined with the configuration file example in the above embodiments, taking the geofence - geofence as an example, the business logic implementation process based on the configuration file includes: I. System initialization: When the system starts, the configuration manager first parses the metadata part in the configuration file to obtain the basic information of the system such as version number, author, creation date, etc. These information are used for record - keeping and log management.

[0078] ​​2. Global variable loading: The business logic processor then parses the global variable globals part, extracts the global variables maxSpeed ​​and temperatureThreshold, and sets them to 120 and 25 respectively. These global variables will be referenced in subsequent event processing and logical judgment.

[0079] 3. Event processing: During system operation, the business logic processor continuously listens for events defined in the events section of the configuration file. In this example, the geoFence event is defined as being triggered when the vehicle's location approaches the home area (location == 'homeProximity').

[0080] When the triggering conditions of an event are met, the business logic processor performs the following actions: Unlock the doors (call the unlockDoors action).

[0081] Turn on the car's lights at low intensity (call the turnOnLights action with the parameter {"intensity": "low"}).

[0082] Adjust the temperature in the car to 22 degrees (call the adjustTemperature action and pass the parameter {"temperature": 22}).

[0083] 4. State management: The business logic processor also manages the state of the vehicle and performs state transitions according to the states section in the configuration file. In this example, the initial state of the system is idle.

[0084] When the engine is started (startEngine event), the state changes from idle to running. The processor executes the logic for entering the running state accordingly. When the engine is stopped (stopEngine event), the state returns from running to idle, and the processor executes the logic for stopping the running state.

[0085] 5. Business logic execution: The business logic processor executes the business logic blocks defined in the logicBlocks section periodically or when specific events occur. In this example, the checkTemperature logic block is triggered to check whether the current temperature and speed meet specific conditions: If the current temperature is higher than 25 degrees (currentTemperature > globals.temperatureThreshold) and the speed is lower than 120 km / h (currentSpeed < globals.maxSpeed), the processor will activate the cooling system (invoke the activateCoolingSystem action).

[0086] In some instances, throughout the process, the business logic processor dynamically responds to events and logic rules defined in the configuration file based on the current system state and real-time inputs. After each state transition, event handling, or business logic execution, relevant operation logs can be recorded for subsequent analysis and maintenance.

[0087] Compared with traditional test script and transaction script methods, this application defines global variables, events, states, and business logic through an advanced configuration language, supporting a variety of complex in-vehicle business scenarios. This design enables the system to quickly adapt to changes in business requirements without frequent modification of underlying code, greatly improving the scalability and maintenance efficiency of the system.

[0088] Traditional transaction scripts are usually static, and once the logic is set, it is difficult to adjust dynamically. In contrast, this application supports the dynamic loading and real-time update of configuration files. The business logic processor can adjust the system behavior in real time according to the latest configuration file without restarting the system. This dynamic nature significantly improves the response speed and flexibility of the system, especially suitable for rapidly changing in-vehicle environments.

[0089] It should be noted that in this application, the emphasis of the solutions described in each embodiment is different, but there is a certain interrelated relationship among the embodiments. When understanding the solutions of this application, the embodiments can be referred to each other.

[0090] The above has introduced in detail the method and device for implementing business logic based on a configuration file provided by this application. Specific examples are used in this article to elaborate on the principle and implementation manner of this application. The description of the above embodiments is only used to help understand the concept of this application and should not be construed as a limitation on the protection scope of this application.

Claims

1. A business logic implementation method based on configuration files, It is characterized in that include: Loading a configuration file, wherein the configuration file is described in a configuration language, and the configuration content defined in the configuration language includes global parameters, states, state transition rules, triggering events of state transitions, triggering conditions of events, actions corresponding to triggering events, and business logic blocks, wherein the business logic blocks define triggering conditions of logic blocks and actions corresponding to logic blocks; Parse the configuration file to obtain configuration content, and construct configuration data stored in a preset data format according to global parameters, states, state transition rules, triggering events of state transitions, triggering conditions of events, actions corresponding to the triggering events, and business logic blocks; Traversing the configuration data, capturing the triggering condition of the event or the triggering condition of the logic block; When the trigger condition of the event is met, a first trigger result is output, and when the trigger condition of the logic block is met, a second trigger result is output; According to the first trigger result and the state transition rule, the action corresponding to the trigger event is executed and the state transition is performed; according to the second trigger result, the action corresponding to the logic block is executed.

2. The method for implementing business logic based on a configuration file according to claim 1, It is characterized in that The business logic implementation method also includes: A storage space is provided to store the configuration file, and the storage space provides a read and write interface to read or write the configuration file.

3. The method for implementing business logic based on configuration files according to claim 1, It is characterized in that Parse the configuration file to obtain configuration content, and construct configuration data stored in a preset data format according to global parameters, states, state transition rules, triggering events of state transitions, triggering conditions of events, actions corresponding to triggering events, and business logic blocks, including: According to the keywords, the global parameters, states, state transition rules, triggering events of state transitions, triggering conditions of events, actions corresponding to the triggering events, and business logic blocks are identified from the configuration file, and the configuration file is parsed into vocabulary units; The configuration data is obtained by performing grammatical analysis on the vocabulary units and mapping the business logic blocks, events and states in the configuration file to a memory data structure in a preset data format.

4. The method for implementing business logic based on a configuration file according to claim 1, It is characterized in that The service logic implementation method also includes: periodically checking whether the configuration file has been updated, or reloading the latest configuration file by triggering an external command.

5. The method for implementing business logic based on configuration files according to claim 1, It is characterized in that The logic block triggering condition includes an abnormality judgment condition, and the action corresponding to the logic block includes an abnormality recovery measure; The business logic implementation method also includes: when the abnormal judgment condition is met, using the abnormal recovery measure to handle it.

6. The method for implementing business logic based on configuration files according to claim 5, It is characterized in that The abnormal recovery measures include retrying the operation, exiting the function, switching to a safe mode, recording a log for subsequent analysis, or triggering an alarm system.

7. The method for implementing business logic based on configuration files according to claim 1, It is characterized in that The configuration content includes a nested loop control structure; the business logic implementation method also includes: According to the logic block triggering condition, it is determined whether the loop control structure starts to execute or terminates execution.

8. The method for implementing business logic based on configuration files according to claim 1, It is characterized in that The logic block triggering condition is defined using a conditional operator, which includes a comparison operator, a logical operator, a string comparison operator, and a Boolean operator.

9. A business logic implementation device based on a configuration file, It is characterized in that include: A configuration manager is used to load a configuration file, wherein the configuration file is described in a configuration language, and the configuration content defined in the configuration language includes global parameters, states, state transition rules, triggering events of state transitions, triggering conditions of events, actions corresponding to triggering events, and business logic blocks, wherein the business logic blocks define triggering conditions of logic blocks and actions corresponding to logic blocks; Parse the configuration file to obtain configuration content, and construct configuration data stored in a preset data format according to global parameters, states, state transition rules, triggering events of state transitions, triggering conditions of events, actions corresponding to the triggering events, and business logic blocks; A business logic processor, used for traversing the configuration data and capturing the triggering condition of the event or the triggering condition of the logic block; When the trigger condition of the event is met, a first trigger result is output, and when the trigger condition of the logic block is met, a second trigger result is output; According to the first trigger result and the state transition rule, the action corresponding to the trigger event is executed and the state transition is performed; according to the second trigger result, the action corresponding to the logic block is executed.

10. The device for implementing business logic based on configuration files according to claim 9, It is characterized in that The service logic implementation device also includes: The storage module is used to provide a storage space to store the configuration file, and the storage space provides a read and write interface to read or write the configuration file.

Citation Information

Patent Citations

  • Dynamic event-driven model

    CN111813406A

  • Low-code rapid research and development configuration platform

    CN115756430A

  • Event architecture and method for configuring same

    US7231339B1

  • Method for dynamically configuring business logic, cloud platform, vehicle, and storage medium

    WO2024060965A1

Cited By

  • Business process processing algorithm and system based on multi-condition rule driving

    CN119417208A

  • Service updating method, device and equipment and storage medium thereof

    CN119473347A

  • Data processing method and device for configuration file custom logical operation, equipment and storage medium

    CN120523504A

  • A data processing method and device for configuring file custom logic operation, equipment and storage medium

    CN120523504B

  • Low-code service configuration engine and configuration method thereof

    CN121613787A