CN110737439B - Equipment control system and method based on rule file - Google Patents
Equipment control system and method based on rule file Download PDFInfo
- Publication number
- CN110737439B CN110737439B CN201910993146.3A CN201910993146A CN110737439B CN 110737439 B CN110737439 B CN 110737439B CN 201910993146 A CN201910993146 A CN 201910993146A CN 110737439 B CN110737439 B CN 110737439B
- Authority
- CN
- China
- Prior art keywords
- rule
- condition
- file
- instruction
- list
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/44—Encoding
- G06F8/443—Optimisation
Landscapes
- Engineering & Computer Science (AREA)
- General Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Stored Programmes (AREA)
Abstract
The invention relates to the technical field of Internet of things, and discloses a device control system and method based on a rule file, which are used for solving the problems of application iteration and maintenance cost in the conventional device control system and method. The system comprises a rule base, a message acquisition module and a rule engine; wherein, the rule base stores application rule files; the rule engine matches the trigger message rules in the rule base according to the trigger message, and determines a rule file corresponding to the trigger message rules after the trigger message rules are successfully matched; generating a condition list and an execution action list according to the rule file; and according to the combined sequence in the condition list, obtaining the parameter value of the parameter name, carrying out logic operation on the parameter value and the condition value according to an operator, judging whether the decision condition is met, when the decision condition is met, determining the specific equipment for executing the instruction according to the equipment class name contained in the execution action list, and sending the instruction to the corresponding equipment. The method is suitable for controlling the equipment of the Internet of things.
Description
Technical Field
The invention relates to the technical field of Internet of things, in particular to a device control system and method based on a rule file.
Background
Along with the rapid development of the internet of things, more and more intelligent devices are provided, application scenes of the intelligent devices and the intelligent home for the internet of things are more and more abundant and complex, and the demand change is rapid. To meet the rapidly changing requirements, so that the intelligent device can operate normally according to the requirements, application program codes and tests need to be continuously modified, and the iteration and maintenance costs are very high.
At present, for such a situation, it is a common practice to modify an application program to meet a requirement, and this practice modifies a code, and a test program takes much time, so that the cost is very high. Another common way is to use configuration files, and to set parameters of the configuration files to meet the change of the requirements, but the disadvantage is that the number of parameters is fixed, and only the requirement of simple application can be met, and if new parameters are added, the code needs to be modified.
Disclosure of Invention
The technical problem to be solved by the invention is as follows: the utility model provides a device control system and method based on rule files, which is used to solve the problems of application iteration and maintenance cost in the conventional device control system and method.
In order to solve the problems, the invention adopts the technical scheme that:
the equipment control system based on the rule file comprises a rule base, a message acquisition module and a rule engine;
the rule base stores application rule files, the application rule files are composed of parts such as trigger messages (Inputs), condition judgment (Conditions), execution Actions (Actions) and the like, and can be stored in Json format files, and the content of the application rule files includes but is not limited to the following content:
(1) the rule Name: the name of the rule;
(2) trigger messages Inputs: an input message that triggers the rule;
(3) condition judgment Conditions: and describing the condition sequence combination of parameter names, operators and condition values required by the rule for condition judgment, and describing decision conditions. If the judgment result of the condition sequence combination meets the decision condition, executing an Action defined by the Action; otherwise, the operation is not executed;
(4) execute action Actions: when the decision condition is met, the operation instruction needs to be executed, and the operation instruction comprises but is not limited to a device class name, an instruction name and a parameter set.
The message acquisition module is used for acquiring the application trigger message and sending the acquired trigger message to the rule engine for processing;
the rule engine is used for matching the trigger message rules in the rule base according to the trigger message, and determining the corresponding rule file after the matching is successful; judging and executing actions according to the conditions described by the rule language in the determined rule file, and generating a condition list and an execution action list, wherein the condition list comprises a combined sequence formed by combining a parameter name, an operator and a condition value and comprises a decision condition; the execution action list comprises a combination sequence formed by combining an execution instruction and an instruction parameter set; obtaining parameter values of the parameter names according to a combination sequence in a condition list, carrying out logic operation on the parameter values and the condition values according to the operator, judging whether the decision conditions are met or not according to an operation result, and finishing the processing of a rule engine when the decision conditions are not met; and when the decision condition is met, determining the specific equipment for executing the instruction according to the equipment class name contained in the execution action list, and sending the instruction to the corresponding equipment according to the execution action list.
Optionally, in order to meet the user-defined requirement, when generating the condition list, the rule engine may search, from the configuration file or the database, whether a condition value defined by the user for the rule exists, and if the condition value exists, use the user-defined condition value to add or replace the condition value defined in the rule file; if the condition value does not exist, the condition value defined in the rule file is used.
Based on the system, the equipment control method based on the rule file provided by the invention comprises the following steps:
the method comprises the following steps: defining an application rule file, wherein the application rule file comprises a trigger message rule, a condition judgment rule and an execution action rule;
step two: the system analyzes the application rule file in the step one to form a rule base;
step three: the system acquires an application trigger message and sends the application trigger message to a rule engine for processing;
step four: the rule engine matches the trigger message rule in the rule base in the step two according to the trigger message in the step three, and after the matching is successful, the rule engine determines a rule file corresponding to the matching;
step five: the rule engine analyzes the condition judgment and the execution action described by the rule language in the rule file determined in the step four, and generates a condition list and an execution action list; the condition list comprises a combination sequence formed by combining a parameter name, an operator and a condition value and comprises a decision condition; the execution action list comprises a combination sequence formed by combining an execution instruction and an instruction parameter set;
step six: the rule engine acquires the parameter value of the parameter name according to the combined sequence in the condition list in the step five, performs logical operation on the parameter value and the condition value according to the operator, and returns an operation result;
step seven: the rule engine judges whether the decision condition is met or not according to the operation result in the sixth step; when the decision condition is met, performing a step eight; when the decision condition is not satisfied, the processing is finished;
step eight: the rule engine determines the specific equipment for executing the instruction according to the equipment class name contained in the execution action list in the step five; sending an instruction to corresponding equipment according to the execution action list, wherein the parameter of the instruction is determined by the instruction parameter set;
step nine: and the equipment receives the instruction and the parameters sent out in the step eight and executes the instruction.
Further, the application rule file may be saved in a Json format file.
Optionally, in the step five, when the condition list is generated, it is searched from the configuration file or the database whether a condition value customized for the rule by the user exists, and if the condition value exists, the condition value customized by the user is used to add or replace the condition value defined in the rule file; if the condition value does not exist, the condition value defined in the rule file is used.
The invention has the beneficial effects that: the invention provides an intelligent equipment control scheme based on a rule file, which is particularly suitable for application of Internet of things intelligent equipment and intelligent home, can be free from application program code modification and test aiming at complex and changeable requirements, and can quickly meet the requirements by modifying the rule file, so that the intelligent equipment can normally operate according to the requirements, the iteration and maintenance cost is greatly reduced, and the industrial development and application of the Internet of things and the intelligent home are promoted.
Drawings
FIG. 1 is a system architecture principle of the present invention;
FIG. 2 is a schematic diagram of a control flow of a device based on a rule file according to the present invention;
fig. 3 is a schematic diagram of another apparatus control flow based on a rule file.
Detailed Description
Aiming at the application scenes of the Internet of things and the smart home, the method and the system are free from the modification of application program codes in the face of constantly changing requirements, and the requirements are realized by compiling rule files, so that the development cost is reduced. The equipment control system based on the rule file specifically comprises the following components: a rule base, a message acquisition module, a rule engine and a device set, wherein the specific system architecture principle is shown in figure 1;
the rule base stores application rule files, the application rule files are composed of parts such as trigger messages (Inputs), condition judgment (Conditions), execution Actions (Actions) and the like, the application rule files are stored in Json format files, and the application rule file contents include but are not limited to the following contents:
(1) the rule Name is: the name of the rule;
(2) trigger messages Inputs: an input message that triggers the rule;
(3) condition judgment Conditions: and describing the condition sequence combination of parameter names, operators and condition values required by the rule for condition judgment, and describing decision conditions. If the judgment result of the condition sequence combination meets the decision condition, executing the Action defined by the Action; otherwise, the operation is not executed;
(4) execute action Actions: when the decision condition is met, the operation instruction needs to be executed, and the operation instruction comprises but is not limited to a device class name, an instruction name and a parameter set.
The message acquisition module is used for acquiring the application trigger message and sending the acquired trigger message to the rule engine for processing;
the rule engine is used for matching the trigger message rules in the rule base according to the trigger message, and determining the corresponding rule file after the matching is successful; judging and executing actions according to the conditions described by the rule language in the determined rule file, and generating a condition list and an execution action list, wherein the condition list comprises a combined sequence formed by combining a parameter name, an operator and a condition value and comprises a decision condition; the execution action list comprises a combination sequence formed by combining an execution instruction and an instruction parameter set; obtaining parameter values of the parameter names according to a combination sequence in a condition list, carrying out logic operation on the parameter values and the condition values according to the operator, judging whether the decision conditions are met or not according to an operation result, and finishing rule engine processing when the decision conditions are not met; and when the decision condition is met, determining the specific equipment for executing the instruction according to the equipment class name contained in the execution action list, and sending the instruction to the corresponding equipment according to the execution action list.
Based on the above system, the device control flow based on the rule file provided by the present invention is shown in fig. 2, and specifically includes:
the method comprises the following steps: defining application rule files, wherein each application rule file comprises parts such as trigger messages (Inputs), condition judgment (Conditions), execution Actions (Actions) and the like; the application rule file is saved in a Json format file, and the contents of the application rule file include but are not limited to the following contents:
(1) the rule Name: the name of the rule;
(2) trigger messages Inputs: an input message that triggers the rule;
(3) condition judgment Conditions: and describing the condition sequence combination of parameter names, operators and condition values required by the rule for condition judgment, and describing decision conditions. If the judgment result of the condition sequence combination meets the decision condition, executing an Action defined by the Action; otherwise, the operation is not executed.
(4) Execute action Actions: when the decision condition is met, the operation instruction needs to be executed, and the operation instruction comprises but is not limited to a device class name, an instruction name and a parameter set.
Step two: the system analyzes the application rule file in the step one to form a rule base;
step three: the system acquires a trigger message and sends the trigger message to a rule engine for processing;
step four: the rule engine matches the trigger message Inputs in the rule base in the step two according to the trigger message in the step three, and after matching is successful, a rule file corresponding to the matching is determined;
step five: the rule engine analyzes the condition judgment Conditions and the execution action described by the rule language in the rule file determined in the step four, and generates a condition list and an execution action list; the condition list comprises a combination sequence formed by combining a parameter name, an operator and a condition value and comprises a decision condition; the execution action list comprises a combination sequence formed by combining an execution instruction and an instruction parameter set;
step six: the rule engine acquires the parameter value of the parameter name according to the combined sequence in the condition list in the fifth step, performs logical operation on the parameter value and the condition value according to the operator, and returns the operation result;
step seven: the rule engine judges whether the decision condition is met or not according to the operation result in the step six; when the decision condition is met, performing step eight; when the decision condition is not satisfied, the rule engine completes the processing;
step eight: the rule engine determines the specific equipment for executing the instruction according to the equipment class name contained in the execution action list in the fifth step; sending an instruction to corresponding equipment according to the execution action list, wherein the parameter of the instruction is determined by the instruction parameter set;
step nine: the equipment receives the instruction and the parameters sent out in the step eight and executes the instruction;
step ten: the rule trigger message and rule processing are complete.
In addition, as shown in fig. 1, if a user sets a customized condition for a rule file, when generating the condition list, the rule engine searches whether a condition value customized for the rule by the user exists from a configuration file or a database, and if the condition value exists, the condition value defined in the rule file is added or replaced by using the user-customized condition value; if the condition value does not exist, the condition value defined in the rule file is used. Based on this consideration, another control flow of the device based on the rule file provided by the present invention can be shown in fig. 3.
Claims (4)
1. The equipment control system based on the rule file is characterized by comprising a rule base, a message acquisition module and a rule engine;
storing an application rule file in a rule base, wherein the rule file comprises a trigger message rule, a condition judgment rule and an execution action rule;
the message acquisition module is used for acquiring the application trigger message and sending the acquired trigger message to the rule engine for processing;
the rule engine is used for matching the trigger message rules in the rule base according to the trigger messages, and after the trigger message rules are successfully matched, determining the rule files corresponding to the trigger message rules; judging and executing actions according to conditions described by rule languages in a determined rule file, generating a condition list and an execution action list, wherein the condition list comprises a combined sequence formed by combining parameter names, operators and condition values and comprises decision conditions, and when a rule engine generates the condition list, searching whether a condition value customized by a user for the rule exists in a configuration file or a database, and if the condition value exists, using the user-defined condition value to add or replace the condition value defined in the rule file; if the condition value does not exist, using the condition value defined in the rule file; the execution action list comprises a combination sequence formed by combining an execution instruction and an instruction parameter set; obtaining parameter values of the parameter names according to a combination sequence in a condition list, carrying out logic operation on the parameter values and the condition values according to the operator, judging whether the decision conditions are met or not according to an operation result, and finishing the processing of a rule engine when the decision conditions are not met; and when the decision condition is met, determining the specific equipment for executing the instruction according to the equipment class name contained in the execution action list, and sending the instruction to the corresponding equipment according to the execution action list.
2. The rule file based device control system of claim 1 wherein the application rule files in the rule base are stored in a Json format file.
3. The equipment control method based on the rule file is characterized by comprising the following steps of:
the method comprises the following steps: defining an application rule file, wherein the rule file comprises a trigger message rule, a condition judgment rule and an execution action rule;
step two: the system analyzes the rule file in the step one to form a rule base;
step three: the system acquires an application trigger message and sends the application trigger message to a rule engine for processing;
step four: the rule engine matches the trigger message rule in the rule base in the step two according to the trigger message in the step three, and after the matching is successful, the rule engine determines a rule file corresponding to the matching;
step five: the rule engine analyzes the condition judgment and the execution action described by the rule language in the rule file determined in the step four, and generates a condition list and an execution action list; the condition list comprises a combined sequence formed by combining a parameter name, an operator and a condition value and comprises a decision condition, when the condition list is generated, whether a condition value customized by a user for the rule exists or not is searched from a configuration file or a database, and if the condition value exists, the condition value customized by the user is used for adding or replacing the condition value defined in the rule file; if the condition value does not exist, using the condition value defined in the rule file; the execution action list comprises a combination sequence formed by combining an execution instruction and an instruction parameter set;
step six: the rule engine acquires the parameter value of the parameter name according to the combined sequence in the condition list in the step five, performs logical operation on the parameter value and the condition value according to the operator, and returns an operation result;
step seven: the rule engine judges whether the decision condition is met or not according to the operation result in the step six; when the decision condition is met, performing step eight; when the decision condition is not satisfied, the processing is finished;
step eight: the rule engine determines the specific equipment for executing the instruction according to the equipment class name contained in the execution action list in the step five; sending an instruction to corresponding equipment according to the execution action list, wherein the parameter of the instruction is determined by the instruction parameter set;
step nine: and the equipment receives the instruction and the parameters sent out in the step eight and executes the instruction.
4. The method of claim 3, wherein the rule file defined in the first step is stored in a Json format file.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910993146.3A CN110737439B (en) | 2019-10-18 | 2019-10-18 | Equipment control system and method based on rule file |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201910993146.3A CN110737439B (en) | 2019-10-18 | 2019-10-18 | Equipment control system and method based on rule file |
Publications (2)
Publication Number | Publication Date |
---|---|
CN110737439A CN110737439A (en) | 2020-01-31 |
CN110737439B true CN110737439B (en) | 2022-07-22 |
Family
ID=69269222
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201910993146.3A Active CN110737439B (en) | 2019-10-18 | 2019-10-18 | Equipment control system and method based on rule file |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN110737439B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111638652A (en) * | 2020-06-01 | 2020-09-08 | 深圳Tcl数字技术有限公司 | Device control method, system, device and readable storage medium |
CN112612475B (en) * | 2020-12-25 | 2022-03-15 | 四川长虹电器股份有限公司 | Method for realizing simulation of Internet of things equipment |
CN112633784A (en) * | 2021-03-10 | 2021-04-09 | 武汉慧联无限科技有限公司 | Method and device for quickly building business function of Internet of things and electronic equipment |
Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104239017A (en) * | 2013-06-19 | 2014-12-24 | 深圳联友科技有限公司 | Method and system for configuring and calling rules of customized form |
Family Cites Families (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
JP2007241380A (en) * | 2006-03-06 | 2007-09-20 | Matsushita Electric Ind Co Ltd | Remote device control system |
US7912801B2 (en) * | 2007-05-31 | 2011-03-22 | Red Hat, Inc. | Method and apparatus to define a ruleflow |
US8434056B2 (en) * | 2009-06-17 | 2013-04-30 | Phillip J. Windley | Rule engine system controlling devices of disparate types and protocols |
CN105630617A (en) * | 2015-12-28 | 2016-06-01 | 山东中创软件工程股份有限公司 | Business processing method and system based on rule engine |
CN107025102B (en) * | 2016-02-01 | 2020-10-16 | 腾讯科技(深圳)有限公司 | Decision method and system based on rule file |
CN108509478B (en) * | 2017-11-23 | 2021-04-27 | 平安科技(深圳)有限公司 | Splitting and calling method of rule engine file, electronic device and storage medium |
CN108920222B (en) * | 2018-07-12 | 2021-12-03 | 北京京东金融科技控股有限公司 | Business processing method and device based on rule engine |
CN110098953A (en) * | 2019-03-29 | 2019-08-06 | 南京邮电大学 | The things-internet gateway hierarchical control framework of rule-based engine |
-
2019
- 2019-10-18 CN CN201910993146.3A patent/CN110737439B/en active Active
Patent Citations (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104239017A (en) * | 2013-06-19 | 2014-12-24 | 深圳联友科技有限公司 | Method and system for configuring and calling rules of customized form |
Also Published As
Publication number | Publication date |
---|---|
CN110737439A (en) | 2020-01-31 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN110737439B (en) | Equipment control system and method based on rule file | |
CN109241266B (en) | Method and device for creating extended question based on standard question in man-machine interaction | |
CN109710260B (en) | Multi-platform-based applet code conversion method | |
CN105653620B (en) | Log analysis method and device of intelligent question-answering system | |
CN111382347A (en) | Object feature processing and information pushing method, device and equipment | |
CN109189469A (en) | Android application micro services method and system based on reflection | |
CN109189374A (en) | Object formation code generating method and system based on object reference chain | |
CN108345451B (en) | Continuous function diagram programming method | |
CN109285024B (en) | Online feature determination method and device, electronic equipment and storage medium | |
CN116088882B (en) | Function configuration method, system and medium based on intelligent wearable device | |
CN112585547A (en) | Analysis device, analysis method, and analysis program | |
CN116627490A (en) | Intelligent contract byte code similarity detection method | |
CN112199416A (en) | Data rule generation method and device | |
US10341183B2 (en) | Composite navigation method and system for automatic configuration management of application software | |
Li et al. | Toward less hidden cost of code completion with acceptance and ranking models | |
CN106649095A (en) | Static program analysis system for target code | |
CN115857882A (en) | Integrated development environment system | |
CN106250477B (en) | Paging method for data in sub-table | |
CN109814855A (en) | A kind of API recommended method based on object classification and adaptive subgraph match | |
CN107203380A (en) | A kind of SFC interpretation of programs operation method and device | |
CN105930162B (en) | A kind of characteristic positioning method based on subgraph search | |
CN111597202A (en) | Battlefield situation information on-demand extraction method and device based on fractal theory | |
CN111581047A (en) | Supervision method for intelligent contract behavior | |
CN110989995A (en) | Processing method and system for artificial intelligence application based on open source deep learning framework | |
CN110796265A (en) | Interactive operation method and device of decision tree model, terminal equipment and medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |