A method, apparatus, equipment, and medium for constructing and operating intelligent AI.
By constructing intelligent templates and deploying intelligent AI on the target intelligent gateway, the issues of flexibility and operational efficiency of smart home systems are solved, enabling flexible and efficient smart home control.
Patent Information
- Application Number
- CN202310703483.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-06-13
- Publication Date
- 2026-01-30
- Estimated Expiration
- 2043-06-13
AI Technical Summary
Existing smart home systems lack flexibility, customizability, and scalability, and remote calls can easily block the execution environment, resulting in low operating efficiency.
By constructing intelligent templates, selecting intelligent logic units and connecting them according to the data flow direction, determining the execution order and performing legality verification, generating intelligent AI, and deploying it through the target intelligent gateway, the sending of control commands is optimized by using timed and event-triggered scheduling methods.
It improves the flexibility and operational efficiency of smart home systems, facilitates template modification and upgrades, and reduces maintenance costs.
Smart Images

Figure CN116760654B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of intelligent AI technology, specifically to a method, apparatus, device, and medium for constructing and operating intelligent AI. Background Technology
[0002] In recent years, with the rapid popularization of Internet of Things (IoT) technology, smart home systems built on IoT smart hardware have entered thousands of households and become widespread in ordinary families. However, in the face of ever-changing and complex application scenarios, how to conveniently manage and use smart devices and enable them to better serve people remains a challenge.
[0003] Most existing technologies are based on the IFTTT (IF THIS THEN THAT) mechanism, which is relatively rigid, lacks flexibility, and is not very customizable, programmable, or scalable, thus failing to meet the diverse needs of users. Moreover, remote calls can block the execution environment and reduce system operating efficiency. Summary of the Invention
[0004] In view of this, the present invention provides a method, apparatus, device and medium for building and running intelligent AI, so as to solve the problems of insufficient flexibility and low efficiency in building and running intelligent AI.
[0005] In a first aspect, the present invention provides a method for constructing and operating intelligent AI, the method comprising:
[0006] Intelligent logic units are selected based on preset control commands, intelligent templates are constructed according to the data flow direction of each intelligent logic unit, and the input and output endpoints of the intelligent templates are filled by selecting a target intelligent gateway.
[0007] The data flow connection relationship of the intelligent template is analyzed to determine the execution order of each sub-instruction in the preset control command and to verify its legality. The intelligent template is compiled according to the execution order and then sent to the target intelligent gateway to generate intelligent AI.
[0008] The system acquires and binds pre-stored measurement data from the measurement device corresponding to the intelligent AI input endpoint. It then schedules and executes the intelligent AI to generate corresponding control commands using a preset scheduling method. After optimizing and merging the control commands, the system sends them to the corresponding functional device in a non-blocking manner.
[0009] The intelligent AI construction and operation method provided in this invention constructs an intelligent template corresponding to preset control commands through intelligent logic units and data flow directions. The input and output endpoints of the intelligent template are filled according to the target intelligent gateway. After analyzing the intelligent template to determine the execution order and verify the legality of sub-instructions in the preset control commands, it is compiled and sent to the target intelligent gateway to generate intelligent AI. Measurement data from the measuring device corresponding to the input endpoints of the intelligent AI is acquired and bound. The intelligent AI is scheduled and executed through a preset scheduling method to generate control commands, and the optimized and merged control commands are sent to the corresponding functional devices. This invention generates intelligent AI by constructing intelligent modules and deploying the intelligent AI on the target intelligent gateway, enabling the intelligent gateway to independently run the intelligent AI within the local area network. This facilitates the modification and upgrading of intelligent templates, improves the flexibility of intelligent AI construction and operation, and enhances system operating efficiency.
[0010] In one optional implementation, the process of selecting intelligent logic units based on preset control instructions and constructing intelligent templates according to the data flow direction of each intelligent logic unit includes: analyzing the input and output data of each sub-instruction according to the preset control instructions, determining the function to be implemented according to each sub-instruction, and selecting intelligent logic units corresponding to the function; defining the intelligent logic units, determining the input and output endpoints of each selected intelligent logic unit, and filling in the data; determining the data flow direction between each intelligent logic unit according to the preset control instructions, and connecting the input and output endpoints of the corresponding intelligent logic units with directional connecting lines according to the data flow direction to generate an intelligent template, wherein the intelligent template has input and output endpoints for connecting to the outside world.
[0011] This invention constructs intelligent modules by selecting intelligent logic units with specific logical functions and connecting them according to the data flow direction corresponding to preset control commands. Using intelligent logic modules encapsulates common logic, exposing only input and output endpoints while hiding internal implementation details. During use, only the definitions of inputs and outputs need to be considered; the data types of input and output endpoints are specified during definition, clarifying their behavior and preventing incorrect use. Constructing intelligent AI using intelligent logic units and intelligent templates also facilitates later version management, reducing the significant maintenance costs associated with version upgrades.
[0012] In one alternative implementation, the smart template is built based on a mobile app or desktop web application.
[0013] This invention enables the construction of intelligent modules through APP software or Web application. Intelligent logic units can be selected in the operation interface of the interactive panel view, and templates can be constructed and filled according to the data flow direction. Preset control instructions can be described by instantiated templates, which facilitates operation.
[0014] In one optional implementation, the process of analyzing the data flow connection relationship of the smart template, determining the execution order of each sub-instruction in the preset control command, and performing legality verification includes: analyzing the input endpoints, output endpoints, and connection lines between the input endpoints and output endpoints of all smart logic units of the smart template through the cloud to determine the execution order between each smart logic unit; verifying the legality of the connection lines between each smart logic unit, determining whether there is a circular connection, and breaking the circular connection if it exists.
[0015] After constructing an intelligent template corresponding to preset control commands, this invention requires compiling the template. The core of the compilation is determining the execution order of each sub-instruction. Therefore, it is necessary to analyze the connection relationships between intelligent logic units in the intelligent template, sort the execution order of the intelligent logic units, find the upstream and downstream logic units, and verify their validity to prevent the intelligent AI from getting stuck in a loop without termination. The final execution order of the intelligent logic units is the execution order of each sub-instruction. The execution process involves first filling in the data of these input endpoints, and then executing each sub-instruction in sequence, such as internal logic calculations within the intelligent logic unit and data transmission via connection lines. In this way, data is transmitted from the upstream intelligent logic unit to the downstream intelligent logic unit, and finally acts on the real device bound to the output endpoint of the downstream intelligent logic unit, realizing device control.
[0016] In one optional implementation, the process of sending the compiled smart template to the target smart gateway includes: using the target smart gateway's preset ID as a signature token and encrypting the code of the compiled smart template with the corresponding signature; when the smart template is sent to the target smart gateway, the target smart gateway verifies whether the signature of the smart template is correct based on the preset ID; if the signature is verified to be valid, the smart template is accepted; if the signature is verified to be invalid, the smart template is not accepted and an error indication is returned.
[0017] This invention uses a smart gateway as the runtime host for the instantiated smart AI. Therefore, the smart template is compiled in the cloud and then distributed to the smart gateway. During the distribution process, the target smart gateway's ID is used as the signature token, and the intermediate code, after being encrypted and signed, is verified. If the signature is invalid, the smart AI is not accepted and an error is returned directly, preventing the acceptance of incorrect commands. In this way, the intermediate code can only be distributed to the target smart gateway; other smart gateways will not receive it, preventing the smart AI from being copied arbitrarily and also avoiding distribution to the wrong smart gateway.
[0018] In one optional implementation, the preset scheduling method includes: a timed tick polling scheduling method and an event-triggered scheduling method; the timed tick polling scheduling method triggers the intelligent AI to execute once at a preset time interval; the event-triggered scheduling method monitors preset events of the real devices bound to all input endpoints of the intelligent AI in real time. If a preset event is reached, the intelligent AI is immediately triggered to execute once; if the preset event is not reached, the intelligent AI is triggered to execute once at a preset time interval; if both the preset event and the preset time interval are reached, the intelligent AI is still triggered to execute once.
[0019] This invention employs a parallel scheduling approach, combining timed tick polling and event-triggered scheduling, to schedule the intelligent AI. Even without event triggers, the intelligent AI executes once every preset time interval; if a relevant event arrives, the intelligent AI executes immediately. Furthermore, timed tick polling is not skipped due to event triggers, ensuring the intelligent AI's internal time precision matches the preset time interval, guaranteeing at least one scheduling within that interval. These two scheduling methods ensure a rapid response capability. The reason for such frequent and rapid intelligent AI scheduling lies in the mechanism by which the intelligent gateway operates the intelligent AI.
[0020] In one optional implementation, the process of acquiring and binding pre-stored measurement data from measurement devices corresponding to the input endpoints of intelligent AIs, scheduling and executing intelligent AIs to generate control commands through a preset scheduling method, and then optimizing and merging the control commands before sending them to the corresponding functional devices includes: constructing a global data source based on the memory database of the target intelligent gateway; scanning all intelligent AIs that need to be executed, acquiring measurement data from measurement devices corresponding to their input endpoints, and storing it in the global data source; binding the measurement data with the corresponding input endpoints of the intelligent AIs, scheduling and executing the intelligent AIs sequentially according to a preset scheduling method, and generating control commands corresponding to the measurement data after execution, and caching the control commands in the global data source; optimizing and merging the control commands generated by each intelligent AI in the global data source, sending the most recent control command if duplicate control commands are included, and merging multiple control commands for the same functional device if multiple control commands are included; and sending the optimized and merged control commands to the corresponding functional devices in a non-blocking manner, wherein if scheduling conflicts exist, the control command generated by the most recent scheduling is retained.
[0021] This invention's smart gateway is configured to support the parallel operation of multiple intelligent AIs. Therefore, a global data source is constructed to store the input and output endpoint data of all intelligent AIs. The operation of acquiring measurement data from all input endpoint measurement devices and saving it to the global data source is the smart gateway's MapIn operation. The operation of saving all output endpoint data to the global data source, optimizing and merging it, and then sending it to the corresponding functional device is the smart gateway's FlushOut operation. The MapIn and FlushOut operations are handled uniformly by the smart gateway; the intelligent AIs do not participate in these two operations. The intelligent AIs only need to focus on data calculation and data transmission within their internal intelligent logic units, thus enabling rapid completion of a scheduling round. Furthermore, if the smart gateway's operating mode is based on radio frequency communication, considering bandwidth, the fewer command data packets transmitted, the better. While scheduling and executing intelligent AIs through two scheduling methods ensures rapid response, there is a possibility of multiple control commands from the same device, duplicate control commands, or the accumulation of multiple control commands. Therefore, optimizing and merging control commands and sending them in a non-blocking manner reduces data transmission volume and prevents excessive control commands from causing radio frequency channel congestion.
[0022] Secondly, the present invention provides an apparatus for constructing and operating intelligent AI, comprising:
[0023] The template construction module is used to select intelligent logic units based on preset control instructions, construct intelligent templates according to the data flow direction of each intelligent logic unit, and fill the input and output endpoints of the intelligent templates by selecting a target intelligent gateway;
[0024] The intelligent AI construction module is used to analyze the data flow connection relationship of the intelligent template, determine the execution order of each sub-instruction in the preset control command and perform legality verification, compile the intelligent template according to the execution order, and send the compiled intelligent template to the target intelligent gateway to generate intelligent AI;
[0025] The intelligent AI operation module is used to acquire and bind the pre-stored measurement data of the measurement device corresponding to the intelligent AI input endpoint, schedule and execute the intelligent AI to generate corresponding control commands through a preset scheduling method, and send the optimized and merged control commands to the corresponding functional device in a non-blocking sending mode.
[0026] Thirdly, the present invention provides a computer device, including: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the computer instructions to perform the intelligent AI construction and operation method of the first aspect or any corresponding embodiment described above.
[0027] Fourthly, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to execute the intelligent AI construction and operation method of the first aspect or any corresponding embodiment described above. Attached Figure Description
[0028] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0029] Figure 1 This is a flowchart illustrating the method for constructing and operating intelligent AI according to an embodiment of the present invention;
[0030] Figure 2 This is a schematic diagram of an unbound smart template for a method of building and running intelligent AI according to an embodiment of the present invention;
[0031] Figure 3 This is a schematic diagram of the binding of an intelligent template in the method for constructing and running intelligent AI according to an embodiment of the present invention;
[0032] Figure 4 This is a schematic diagram of the execution sequence of intelligent AI in the intelligent AI construction and operation method according to an embodiment of the present invention;
[0033] Figure 5 This is a flowchart illustrating another method for constructing and operating intelligent AI according to an embodiment of the present invention;
[0034] Figure 6 This is a flowchart illustrating another method for constructing and operating intelligent AI according to an embodiment of the present invention;
[0035] Figure 7 This is a structural block diagram of an intelligent AI construction and operation device according to an embodiment of the present invention;
[0036] Figure 8 This is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. Detailed Implementation
[0037] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0038] This invention is applicable to scenarios requiring flexible control of smart homes, and provides a method for building and running intelligent AI to achieve flexible and efficient control of smart home appliances.
[0039] According to an embodiment of the present invention, an embodiment of a method for constructing and running intelligent AI is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0040] This embodiment provides a method for building and running intelligent AI, which can be used in the aforementioned mobile terminals, such as mobile phones and computers. Figure 1 This is a flowchart of a method for constructing and operating intelligent AI according to an embodiment of the present invention, such as... Figure 1 As shown, the process includes the following steps:
[0041] Step S101: Select intelligent logic units based on preset control instructions, construct intelligent templates according to the data flow direction of each intelligent logic unit, and fill the input and output endpoints of the intelligent templates by selecting a target intelligent gateway.
[0042] Specifically, in this embodiment of the invention, taking the preset control instruction "Automatically turn on the air conditioner when the temperature is higher than 26°C on weekdays" as an application example, it can be deduced that the sub-instructions included in this preset control instruction include time judgment, temperature judgment, and air conditioner control. A smart template is constructed to control the air conditioner when the temperature is {higher or lower than} {a certain number} degrees on a {valid date}. The smart template consists of smart logic units and connecting lines. Here, a smart logic unit (Block) represents logic with a certain function, such as a comparator, negation, conditional AND, HTTP remote call, device control, etc., all of which can be encapsulated as a Block. These are all examples for illustration, but not limitations. By exposing the input and output endpoints of the Block, the internal implementation details can be hidden. When using it, only the definitions of the input and output need to be considered. The data type of the input and output endpoints is specified during definition, clarifying the behavior of the endpoint and preventing incorrect use of the endpoints. A Block can have multiple input and multiple output endpoints. According to the preset control command "automatically turn on the air conditioner when the temperature is higher than 26°C on weekdays", this embodiment of the invention selects the comparator block, calendar block, holiday query block, condition block, and device control block based on mobile APP software or desktop web application. The specific description of each block is as follows:
[0043] 1. A comparator Block is used to compare two values. It outputs 1 if the comparison condition is met, and 0 otherwise. The comparator Block takes three inputs: value 1, value 2, and a comparison operator. It generates one output: 1 if value 1 and value 2 satisfy the comparison operator, and 0 otherwise.
[0044] 2. Calendar Block, used to select a date based on the calendar. It takes one input: a valid date. It generates one output: 1 if the time is within the valid date range, and 0 otherwise.
[0045] 3. Holiday Query Block: This block checks if a given day is a holiday. It requires an HTTP request to a remote server to determine if the local day is a holiday. The Holiday Query Block takes two inputs: country and whether to invert the value. It outputs 1 if the specified country is a holiday, and 0 otherwise. Note: If invert is configured to be 1, the output will be 0 if the day is a holiday, and 1 otherwise. If the HTTP call fails or fails to return valid data, the day is considered not a holiday. During a calculation, if the remote call does not return a value, it will not block and will immediately return a default value. If the remote call returns data, the new data will be used in the next calculation to output a new value.
[0046] 4. Conditional AND Block: Used for logical AND operations, it outputs 1 only when all inputs are 1. Conditional AND Block takes three inputs: condition 1, condition 2, and condition 3, which can be 1 or 0; it generates one output, which is 1 when all inputs are 1, and 0 otherwise.
[0047] 5. Device Control Block: Used to control the actual physical device. The Device Control Block has two inputs: a trigger condition and a control command. It generates one output: the control command is output when the trigger condition is 1 and its most recent trigger condition is 0. The reason for having a most recent trigger condition of 0 is to implement a rising edge trigger, preventing continuous / repeated triggering; a new trigger is only allowed after the previous trigger condition has been reset. The above settings are for illustrative purposes only and are not exhaustive.
[0048] In some optional implementations, after selecting intelligent logic units, the logic units are connected via links according to the data flow direction. These links are directional, connecting from one output endpoint to one input endpoint, and primarily serve as data transfer lines. The data flow direction corresponds to the execution order of preset control instructions. Connecting the intelligent logic units according to the data flow direction completes the initial construction of the intelligent template, such as... Figure 2As shown. The intelligent template implements a complex logic, consisting of a series of Blocks and links connecting them. Therefore, the template can be considered an aggregated high-level Block, as it also has input and output endpoints exposed to the outside world. The intelligent template is not yet a true intelligent AI; it must be populated with the required parameter data and bound to a specific real device to be instantiated as an intelligent AI object. This embodiment of the invention selects a smart gateway as the runtime host for instantiating the intelligent AI, but is not limited to this. Therefore, after the intelligent template is constructed, the input and output endpoints of the intelligent template are populated by selecting a target smart gateway. If the input or output endpoints of the intelligent template need to be bound to real physical devices, the user must select a controllable functional device under the target smart gateway for binding. This embodiment of the invention selects a temperature sensor under the target smart gateway as the input endpoint data and an air conditioner as the output endpoint according to preset control instructions, generating an object as shown below. Figure 3 The smart template shown.
[0049] Step S102: Analyze the data flow connection relationship of the smart template, determine the execution order of each sub-instruction in the preset control command and perform legality verification, compile the smart template according to the execution order, and send the compiled smart template to the target smart gateway to generate smart AI.
[0050] Specifically, in this embodiment of the invention, the intelligent AI is an instance object of the template, which is an executable computing unit. The intelligent AI is composed of compiled intermediate code, and a host environment that supports the intermediate code can run the intelligent AI. This invention generates the intelligent AI by compiling the intelligent template in the cloud, but is not limited to this. The cloud analyzes the input and output endpoints of all blocks in the populated intelligent template and the links between them to determine which are the input endpoints of the most upstream block. Then, it sorts the execution order of the connections between blocks to determine the execution order of each instruction. The execution process involves first filling in the data of these input endpoints, and then executing each instruction in sequence, such as internal logic calculations within the block and data transfer via links. In this way, data is passed from the upstream block to the downstream block, ultimately affecting the real device bound to the output endpoint of the most downstream block. Figure 4As shown, the AI has 11 instructions. The correct execution order is Instruction 1, Instruction 2, Instruction 3, Instruction 4, Instruction 5, Instruction 6, Instruction 7, Instruction 8, Instruction 9, Instruction 10, Instruction 11. If the execution order is: Instruction 1, Instruction 2, Instruction 3, Instruction 8, Instruction 9, Instruction 4, Instruction 5, Instruction 6, Instruction 7, Instruction 10, Instruction 11, the "Calendar Block" input will not be correctly passed to the "Condition and Block" in this round. Instruction 8 will still use the value passed to it by Instruction 5 in the previous round, resulting in the correct calendar value being passed to the "Condition and Block" only in the next round (the next second or when the event is triggered immediately). If the temperature sensor happens to trigger a change in the comparator output, the result may be incorrect behavior. For example, in this round of execution, if the "Comparator Block" output 0 one second and outputs 1 the next, while the "Calendar Block" outputs 1 one second and outputs 0 the next, due to the incorrect instruction order, the "Condition and Block" will output 1 when both inputs are 1, causing the air conditioner to turn on. If the execution order is correct, since instruction 4 is executed first, instruction 5 will pass 0 to "condition and block", thus preventing the air conditioner from turning on.
[0051] In some optional implementations, the smart template is compiled according to the execution order to generate intermediate code. This invention selects a smart gateway as the runtime host, therefore choosing the generated Lua script code, but it is not limited to this; intermediate code in other languages, such as C, can also be compiled using compilers for other languages, allowing the smart AI to run directly on the microcontroller. The preset ID of the target smart gateway is used as the signature token, and the compiled intermediate code is encrypted with the corresponding signature. When the smart template is sent to the target smart gateway, the target smart gateway verifies the signature of the smart template based on the preset ID. If the signature is valid, the smart template is accepted; if the signature is invalid, the smart template is rejected and an error indication is returned.
[0052] Step S103: Obtain and bind the pre-stored measurement data of the measurement device corresponding to the intelligent AI input endpoint, schedule and execute the intelligent AI to generate the corresponding control command through a preset scheduling method, and send the optimized and merged control command to the corresponding functional device in a non-blocking sending method.
[0053] Specifically, in this embodiment of the invention, the smart gateway can support the parallel operation of multiple smart AIs. Therefore, before executing a smart AI, it is necessary to acquire and bind the pre-stored measurement data of the measuring devices corresponding to the input endpoints of the smart AI. For example, this embodiment of the invention requires binding the measured temperature value of the temperature sensor to the constructed smart AI. The smart AI is mainly run through scheduling. Each time it is scheduled, it executes the compiled intermediate code based on the obtained measurement data, thereby completing a logical operation and generating the corresponding control command. The preset scheduling methods in this embodiment of the invention include: timed tick polling scheduling and event-triggered scheduling. The timed tick polling scheduling method triggers the smart AI to execute once at a preset time interval. The event-triggered scheduling method monitors the preset events of the real devices bound to all input endpoints of the smart AI in real time. If the preset event is reached, the smart AI is immediately triggered to execute once. If the preset event is not reached, the smart AI is triggered to execute once at a preset time interval; if both the preset event and the preset time interval are reached, the smart AI is still triggered to execute once.
[0054] In some optional implementations, the smart gateway operates based on radio frequency (RF) communication. Considering bandwidth factors, the fewer command data packets transmitted, the better. While scheduling and executing intelligent AI through two scheduling methods ensures rapid response, there is a possibility of multiple control commands from the same device, duplicate control commands, or the accumulation of multiple control commands. Therefore, it is necessary to optimize and merge control commands and send them in a non-blocking manner to reduce data transmission and prevent too many control commands from causing RF channel congestion. Specifically, in the non-blocking sending method, if scheduling conflicts exist, the control command generated by the most recent scheduling is retained. For example, if the previous call to the sub-device has not yet completed, and a new round of scheduling needs to be completed before sending commands to the sub-device again, the smart gateway will wait for the previous call to finish. If multiple rounds of commands are accumulated and sent to the functional device during this period, only the most recent one will be retained.
[0055] In some optional implementations, the smart gateway's ability to support frequent and rapid scheduling of multiple intelligent AIs is based on the following: the smart gateway possesses attribute data for all sub-devices and stores it in memory; changes in sub-device attributes are synchronized to the smart gateway's memory via events; all internal logic operations within a block are non-blocking, and data computation is memory-based; the smart gateway has its own AI runtime environment, and time-consuming block operations, such as HTTP remote data retrieval, will create a separate coroutine to run, updating the data source data within the block only after the data is returned, thus ensuring that data computation is memory-based; all intelligent AIs run within a virtual machine and are scheduled and executed in a single-threaded, multi-coroutine manner, thus eliminating concurrency, the need for locking mechanisms, and preventing resource contention; control commands output to the real device are issued independently by starting new coroutines within the AI runtime environment. Therefore, the above mechanisms provide a robust, concise, and efficient execution environment, ensuring that the smart gateway can frequently and rapidly schedule the operation of multiple intelligent AIs.
[0056] The intelligent AI construction and operation method provided in this embodiment constructs an intelligent template corresponding to preset control commands through intelligent logic units and data flow directions. The input and output endpoints of the intelligent template are filled according to the target intelligent gateway. After analyzing the intelligent template to determine the execution order and verify the legality of sub-instructions in the preset control commands, it is compiled and sent to the target intelligent gateway to generate intelligent AI. Measurement data from the measuring device corresponding to the input endpoints of the intelligent AI is acquired and bound. The intelligent AI is scheduled and executed through a preset scheduling method to generate control commands, and the optimized and merged control commands are sent to the corresponding functional devices. This invention generates intelligent AI by constructing intelligent modules and deploying the intelligent AI on the target intelligent gateway, enabling the intelligent gateway to independently run the intelligent AI within the local area network. This facilitates the modification and upgrading of intelligent templates, improves the flexibility of intelligent AI construction and operation, and enhances system operating efficiency.
[0057] This embodiment provides a method for building and running intelligent AI, which can be used in the aforementioned mobile terminals, such as mobile phones and computers. Figure 5 This is a flowchart of a method for constructing and operating intelligent AI according to an embodiment of the present invention, such as... Figure 5 As shown, the process includes the following steps:
[0058] Step S501: Select intelligent logic units based on preset control instructions, construct intelligent templates according to the data flow direction of each intelligent logic unit, and fill the input and output endpoints of the intelligent templates by selecting a target intelligent gateway.
[0059] Specifically, step S501 includes:
[0060] Step S5011: Analyze the input and output data of each sub-instruction according to the preset control instructions, determine the function to be implemented according to each sub-instruction, and select the intelligent logic unit corresponding to the function.
[0061] Specifically, in this embodiment of the invention, based on the sub-instructions of the preset control instruction "Automatically turn on the air conditioner when the temperature is higher than 26℃ on weekdays": time judgment, temperature judgment, and air conditioner control, the following input / output parameters are analyzed: 1) Valid date: weekday; 2) Comparison temperature value: 26℃; 3) Comparison operator: higher than; 4) Ambient temperature source device: temperature sensor; 5) Control command: turn on; 6) Control output device: air conditioner. These input / output parameters are abstracted to obtain more general input / output parameters: 1) Valid date: input; 2) Comparison temperature value: input; 3) Comparison operator: input; 4) Ambient temperature source device: input; 5) Control command: input; 6) Control device: output. Therefore, this embodiment of the invention selects the comparator block, calendar block, holiday query block, condition block, and device control block based on mobile APP software or desktop web application.
[0062] Step S5012: Define the intelligent logic unit, determine the input and output endpoints of each selected intelligent logic unit, and fill in the data.
[0063] Specifically, in this embodiment of the invention, the core concept of the Block design is a data source, not logic. Its input endpoint provides data input, and its output endpoint outputs data. Internally, it can create a private data source to store private data, or it can store data in a global data source (DataSource) and process the data through internal logic. Each Block design has input and output endpoints exposed to the outside world. The Block's processing logic is implemented internally and encapsulated within the Block, not exposed to external callers. Therefore, the input and output endpoints need to have clearly defined data types. Current data types include: Boolean, Integer, Float, String, Array, Map, and the general type Variable. For a unified design, each data type is also defined as a Block, exposing an endpoint that serves as both input and output. Data is stored within the Block's internal data source and can be referenced and set externally. Blocks can be interconnected through their exposed endpoints to achieve complex functions. Furthermore, the output endpoint has a 1:n relationship with the input endpoint, meaning that an output endpoint can have multiple connections leading to different input endpoints.
[0064] In some alternative implementations, a Block is defined as follows:
[0065] 1. Document Description Area. The document description area defines the ID, category, name, description, and other information of the Block. Users can determine the function of the Block based on this information, and the UI will also display this content.
[0066] 2. Input / Output Endpoint Definition Area. The endpoint definition area defines the input / output endpoints exposed to the outside world. It is a dictionary type, where the key is the endpoint ID, and the value is also a dictionary containing information such as the endpoint name, input / output category, default value, and data value constraints. The endpoint ID defines a path, using " / " as the separator, which can hierarchically locate a specific endpoint within the block it references. Accessing endpoints in other blocks is done through the endpoint ID.
[0067] 3. Data Source Area. The data source area defines the data sources that this Block needs to use. The data sources are divided into two parts: the collection of other Blocks referenced and the internal private data source. The internal private data source is mainly used to save intermediate states or temporary variables during the calculation of the logic implementation area.
[0068] 4. Logic Implementation Area. The logic implementation area is where data calculations are performed. It is the internal encapsulation of the Block and does not need to be exposed externally. It is divided into two types: 1) Logical operations, which are business logic defined by the scripting language. They are responsible for calculating various data sources, generating new result data, assigning it to the Block's output endpoint, or saving it as an intermediate state. In other words, it is an update operation on the data in the data source area. 2) Connection definitions, which are used to define the source and destination endpoints of connections. During connection operations, data from the source endpoint is passed to the target endpoint according to the connection definition.
[0069] In some optional implementations, data is populated into the defined intelligent logic units according to preset control instructions, such as... Figure 3 As shown, the first input value of the comparator block should be filled with "26", the second input value should be bound to "temperature sensor", and the third input comparison operator should be selected as "greater than"; the input valid date of the calendar block should be filled with "Monday to Friday"; the first input country of the holiday query block should be filled with "China", and the second input whether to invert should be filled with "1"; the input control command of the device control block should be filled with "on", and the output control device should be bound to "air conditioner".
[0070] Step S5013: Determine the data flow direction between each intelligent logic unit according to the preset control command, and connect the input endpoints and output endpoints of the corresponding intelligent logic units with directional connecting lines according to the data flow direction to generate an intelligent template. The intelligent template has input endpoints and output endpoints that can be connected to the outside world.
[0071] Specifically, in this embodiment of the invention, based on mobile APP software or desktop web application, directional connecting lines are used to connect the input and output endpoints of corresponding intelligent logic units according to the data flow direction between them. The connecting line is a directed line that flows from the output endpoint of an upstream block to the input endpoint of a downstream block. The output endpoint of the upstream block is the source endpoint of the connection, and the input endpoint of the downstream block is the destination endpoint. Data transmission is accomplished through these connections. The input endpoint of the upstream block can connect to external inputs and transmit those inputs to the input endpoint; this process is called the MapIn operation. The output endpoint of the downstream block can connect to external outputs; this process is called the FlushOut operation.
[0072] Step S502: Analyze the data flow connection relationship of the intelligent template, determine the execution order of each sub-instruction in the preset control command and perform legality verification, compile the intelligent template according to the execution order, and send the compiled intelligent template to the target intelligent gateway to generate intelligent AI. For details, please refer to [link to relevant documentation]. Figure 1 Step S102 of the illustrated embodiment will not be described again here.
[0073] Step S503: Obtain and bind the pre-stored measurement data from the measurement device corresponding to the intelligent AI input endpoint. Schedule and execute the intelligent AI using a preset scheduling method to generate corresponding control commands. Optimize and merge the control commands and send them to the corresponding functional device in a non-blocking transmission mode. For details, please refer to [link to details]. Figure 1 Step S103 of the illustrated embodiment will not be described again here.
[0074] This invention generates intelligent AI by constructing intelligent modules, compiles the intelligent AI into intermediate scripts, and deploys them to the target intelligent gateway. The intelligent gateway runs the intelligent AI independently of the cloud, allowing it to run independently within the local area network. Therefore, subsequent modifications to the cloud-based intelligent logic unit Block and intelligent template will not affect the existing intelligent AI. This allows for confident and bold version upgrades, eliminating the huge maintenance costs associated with version upgrades, improving the flexibility of intelligent AI construction and operation, and enhancing system operating efficiency.
[0075] This embodiment provides a method for building and running intelligent AI, which can be used in the aforementioned mobile terminals, such as mobile phones and computers. Figure 6 This is a flowchart of a method for constructing and operating intelligent AI according to an embodiment of the present invention, such as... Figure 6 As shown, the process includes the following steps:
[0076] Step S601: Select intelligent logic units based on preset control commands, construct intelligent templates according to the data flow direction of each intelligent logic unit, and fill the input and output endpoints of the intelligent templates by selecting a target intelligent gateway. For details, please refer to [link to relevant documentation]. Figure 1 Step S101 of the illustrated embodiment will not be described again here.
[0077] Step S602: Analyze the data flow connection relationship of the intelligent template, determine the execution order of each sub-instruction in the preset control command and perform legality verification, compile the intelligent template according to the execution order, and send the compiled intelligent template to the target intelligent gateway to generate intelligent AI. For details, please refer to [link to relevant documentation]. Figure 1 Step S102 of the illustrated embodiment will not be described again here.
[0078] Step S603: Obtain and bind the pre-stored measurement data of the measurement device corresponding to the intelligent AI input endpoint, schedule and execute the intelligent AI to generate the corresponding control command through a preset scheduling method, optimize and merge the control command and send it to the corresponding functional device in a non-blocking sending mode.
[0079] Specifically, step S603 includes:
[0080] Step S6031: Construct a global data source based on the target smart gateway's in-memory database.
[0081] Step S6032: Scan all intelligent AIs that need to be executed, obtain the measurement data of the measurement devices corresponding to their input endpoints, and store them in the global data source.
[0082] Step S6033: After binding the measurement data with the corresponding input endpoint of the intelligent AI, the intelligent AI is scheduled and executed sequentially according to the preset scheduling method, and a control command corresponding to the measurement data is generated after execution. The control command is cached in the global data source.
[0083] Step S6034: Optimize and merge the control commands generated by each intelligent AI in the global data source. If there are duplicate control commands, send the control command with the most recent time. If there are multiple control commands for the same functional device, merge them.
[0084] Step S6035: The optimized and merged control commands are sent to the corresponding functional devices in a non-blocking mode. In the non-blocking mode, if there is a scheduling conflict, the control command generated by the most recent scheduling is retained.
[0085] Specifically, in this embodiment of the invention, before executing intelligent AI, the intelligent gateway scans all intelligent AIs, summarizes the measurement data of the measurement devices bound to the input endpoints that need to be used, obtains the values of the relevant devices at once and saves them in the global data source as a data snapshot for this execution. This process is called MapIn operation. Each time an intelligent AI is scheduled for execution, the measurement data of the measurement devices at the input endpoints is directly obtained from this snapshot in the global data source. During the execution of intelligent AI, it will start from the upstream input of the Block according to the execution order of the compiled intermediate script code, and pass the data to the downstream Block in sequence according to the connection link between Blocks, and finally apply the data to the functional device bound to the output endpoint of the downstream Block. After all intelligent AIs have been executed, data that needs to be sent to the functional devices bound to the output endpoints will be generated. This data will not be sent to the sub-devices immediately, but will be stored in the global data source first. After all intelligent AIs have been executed, the intelligent gateway will perform an optimization and merging operation. For example, outputs to the same device can be merged into one, and duplicate commands can be sent only to the most recent one. Then, a new coroutine is created to send the commands to the relevant sub-devices in a non-blocking manner. This process is called FlushOut operation.
[0086] The MapIn and FlushOut operations are handled uniformly by the target smart gateway. The smart AI does not participate in these two operations. The smart AI only needs to focus on the data calculation and data transmission of the internal block, so as to quickly complete a round of scheduling.
[0087] This invention generates intelligent AI by constructing intelligent modules and deploys the intelligent AI on a target intelligent gateway. When scheduling the execution of the intelligent AI, the target intelligent gateway focuses on a global data source, allowing for easy monitoring of data changes. During debugging, only the data source needs to be monitored to observe data changes in real time, greatly facilitating problem diagnosis. This invention also enables the intelligent gateway to run the intelligent AI independently within a local area network, facilitating the modification and upgrading of intelligent templates, improving the flexibility of intelligent AI construction and operation, and enhancing system operating efficiency.
[0088] This embodiment provides a device for building and running intelligent AI, such as... Figure 7 As shown, it includes:
[0089] The template construction module 701 is used to select intelligent logic units based on preset control instructions, construct intelligent templates according to the data flow direction of each intelligent logic unit, and fill the input and output endpoints of the intelligent templates by selecting a target intelligent gateway.
[0090] The intelligent AI construction module 702 is used to analyze the data flow connection relationship of the intelligent template, determine the execution order of each sub-instruction in the preset control command and perform legality verification, compile the intelligent template according to the execution order, and send the compiled intelligent template to the target intelligent gateway to generate intelligent AI;
[0091] The intelligent AI operation module 703 is used to acquire and bind the measurement data of the measurement device corresponding to the intelligent AI input endpoint, schedule and execute the intelligent AI to generate corresponding control commands through a preset scheduling method, and send the control commands to the corresponding functional device in a non-blocking sending mode after optimization and merging.
[0092] Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.
[0093] In this embodiment, the intelligent AI construction and operation device is presented in the form of functional units. Here, a unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.
[0094] This invention also provides a computer device having the above-described features. Figure 7 The device shown is for building and operating intelligent AI.
[0095] Please see Figure 8 , Figure 8 This is a schematic diagram of the structure of a computer device provided in an optional embodiment of the present invention, such as... Figure 8As shown, the computer device includes one or more processors 10, memory 20, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise installed as needed. The processors can process instructions executed within the computer device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple computer devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 8 Take a processor 10 as an example.
[0096] Processor 10 may be a central processing unit, a network processor, or a combination thereof. Processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GDA), or any combination thereof.
[0097] The memory 20 stores instructions executable by at least one processor 10 to cause at least one processor 10 to perform the method shown in the above embodiments.
[0098] The memory 20 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the computer device. Furthermore, the memory 20 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, the memory 20 may optionally include memory remotely located relative to the processor 10, and these remote memories may be connected to the computer device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0099] The memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk or solid-state drive; the memory 20 may also include a combination of the above types of memory.
[0100] The computer device also includes a communication interface 30 for communicating with other devices or communication networks.
[0101] This invention also provides a computer-readable storage medium. The methods described above according to embodiments of the invention can be implemented in hardware or firmware, or implemented as computer code that can be recorded on a storage medium, or implemented as computer code downloaded via a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code, which, when accessed and executed by the computer, processor, or hardware, implements the methods shown in the above embodiments.
[0102] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A method for constructing and running an intelligent AI, characterized by, The method comprises: Based on the preset control instruction, the intelligent logic unit is selected, the intelligent template is constructed according to the data flow direction of each intelligent logic unit, and the input end point and the output end point of the intelligent template are filled by selecting the target intelligent gateway; The data flow connection relationship of the intelligent template is analyzed, the execution order of each sub-instruction in the preset control instruction is determined and the legality is verified, the intelligent template is compiled according to the execution order, and the compiled intelligent template is sent to the target intelligent gateway to generate an intelligent AI, and the legality verification includes: analyzing whether there is a circular connection between the connection lines of each intelligent logic unit, and breaking the circular connection if there is one; The measurement data of the measurement device corresponding to the input end point of the intelligent AI is obtained and bound, the intelligent AI is scheduled and executed by a preset scheduling mode to generate a corresponding control command, and the control command is optimized and combined and then sent to the corresponding functional device in a non-blocking sending mode; The preset scheduling mode includes a timing Tick polling scheduling mode and an event triggering scheduling mode, the timing Tick polling scheduling mode triggers the intelligent AI to execute once according to a preset time interval, the event triggering scheduling mode monitors the preset event of the real device bound to all input end points of the intelligent AI in real time, and if the preset event is reached, the intelligent AI is triggered to execute once, if the preset event is not reached, the intelligent AI is triggered to execute once according to the preset time interval, and if the preset event is reached and the preset time interval is reached, the intelligent AI is still triggered to execute once; The control command is optimized and combined, including: if there are repeated control commands, the control command with the latest time is sent, and if there are multiple control commands for the same functional device, the control commands are combined; The non-blocking sending mode is that if there is a scheduling conflict, the control command generated by the latest scheduling is retained.
2. The method of claim 1, wherein, The process of selecting the intelligent logic unit based on the preset control instruction and constructing the intelligent template according to the data flow direction of each intelligent logic unit comprises: According to the preset control instruction, the input data and the output data of each sub-instruction are analyzed, and the function to be realized is judged according to each sub-instruction, and the intelligent logic unit corresponding to the function is selected; The intelligent logic unit is defined, the input end point and the output end point of each selected intelligent logic unit are determined, and data filling is performed; According to the preset control instruction, the data flow direction between each intelligent logic unit is determined, and the input end point and the output end point of the corresponding intelligent logic unit are connected by using the directional connection line according to the data flow direction, to generate an intelligent template, the intelligent template has an input end point and an output end point connected with the outside world.
3. The method of claim 2, wherein, The intelligent template is constructed based on a mobile APP software or a desktop Web application.
4. The method of claim 2, wherein, The process of analyzing the data flow connection relationship of the intelligent template, determining the execution order of each sub-instruction in the preset control instruction, and verifying the legality comprises: The input endpoints, the output endpoints and the connection lines between the input endpoints and the output endpoints of all the intelligent logic units of the intelligent template are analyzed through the cloud to determine the execution sequence between the intelligent logic units; The legality of the connection lines between the intelligent logic units is verified to determine whether there is a circular connection, and if there is, the circular connection is broken.
5. The method of claim 1, wherein, The process of distributing the compiled intelligent template to the target intelligent gateway includes: The preset ID of the target intelligent gateway is used as a signature token, and the code of the compiled intelligent template is correspondingly signed and encrypted; When the intelligent template is distributed to the target intelligent gateway, the target intelligent gateway verifies whether the signature of the intelligent template is correct according to the preset ID; If the signature is verified to be legal, the intelligent template is accepted, and if the signature is verified to be illegal, the intelligent template is not accepted and an error indication is returned.
6. The method of claim 1, wherein, The process of obtaining the measurement data of the measurement device corresponding to the intelligent AI input endpoint and binding, scheduling and executing the intelligent AI through a preset scheduling mode to generate a control command, and sending the control command to the corresponding functional device after optimization and merging includes: A global data source is constructed based on the memory database of the target intelligent gateway; All intelligent AIs that need to be executed are scanned to obtain the measurement data of the measurement device corresponding to the input endpoint, and the measurement data is stored in the global data source; After the measurement data is bound to the corresponding input endpoint of the intelligent AI, the intelligent AI is executed in turn according to the preset scheduling mode, and a control command corresponding to the measurement data is generated after execution, and the control command is cached in the global data source; The control commands generated by each intelligent AI in the global data source are optimized and merged, if there are repeated control commands, the control command with the latest time is sent, and if there are multiple control commands for the same functional device, the control commands are merged; The optimized and merged control commands are distributed to the corresponding functional device in a non-blocking manner.
7. An intelligent AI construction running device, characterized by, The device includes: A template construction module is configured to select intelligent logic units based on preset control instructions, construct an intelligent template according to the data flow direction of each intelligent logic unit, and fill the input endpoints and output endpoints of the intelligent template by selecting a target intelligent gateway; An intelligent AI construction module is configured to analyze the data flow connection relationship of the intelligent template, determine the execution sequence of each sub-instruction in the preset control instruction and perform legality verification, compile the intelligent template according to the execution sequence, distribute the compiled intelligent template to the target intelligent gateway, and generate an intelligent AI. The legality verification includes analyzing whether there is a circular connection between the intelligent logic units, and if there is, breaking the circular connection; The intelligent AI running module is used for obtaining and binding the measurement data of the measurement device corresponding to the intelligent AI input terminal, scheduling and executing the intelligent AI by a preset scheduling mode to generate a corresponding control command, and sending the control command to the corresponding functional device in a non-blocking sending mode after optimization and merging; the preset scheduling mode includes a timing Tick polling scheduling mode and an event triggering scheduling mode; the timing Tick polling scheduling mode triggers the intelligent AI to execute once according to a preset time interval; the event triggering scheduling mode is to monitor the preset event of the real device bound by all input terminals of the intelligent AI in real time, and if the preset event is reached, the intelligent AI is triggered to execute once immediately; if the preset event is not reached, the intelligent AI is triggered to execute once according to the preset time interval; the optimization and merging of the control command includes that if repeated control commands are included, the control command of the latest time is sent, and if multiple control commands for the same functional device are included, the control commands are merged; the non-blocking sending mode is that if there is a scheduling conflict, the control command generated by the latest scheduling is reserved.
8. A computer device, comprising: Comprise: a memory and a processor, which are connected in communication with each other, the memory stores computer instructions, and the processor executes the computer instructions to perform the method for constructing and running the intelligent AI according to any one of claims 1 to 6.
9. A computer-readable storage medium, characterized in that, The computer readable storage medium stores computer instructions for causing a computer to execute the method for constructing and running the intelligent AI according to any one of claims 1 to 6.
Citation Information
Patent Citations
Internet of things networking system and method based on edge computing
CN109451040A
Scene configuration method, storage medium and terminal equipment
CN114528064A