Complex event processing system for IoT greenhouse

: Greenhouse is an important part of facility agriculture and a typical application scenario of modern agricultural technology. The greenhouse environment has the characteristics of nonlinearity, strong coupling, large inertia, and multiple disturbances. There are many environmental factors and it is a typical complex system [7] . In smart greenhouses, control commands are mostly triggered by complex events with multi-dimensional information. In this paper, by building the aggregation structure of complex events in the greenhouse, the technology is applied in the greenhouse as a whole. The core innovations of this paper are as follows: through the analysis of the information transmission process in the greenhouse, combined with the characteristics of the scene, a CEP information structure with predictive modules is formed, which is conducive to the popularization and application of CEP technology in the agricultural field. Pointed out the importance of extreme conditions in the prediction of the greenhouse environment for model evaluation. By improving the loss function in the machine learning algorithm, the prediction performance of a variety of algorithms under this condition has been improved. Applying CEP technology to intelligent greenhouse control scenarios, a set of practical complex event processing systems for greenhouse control has been formed.


introduction
With the widespread application of Internet of Things technology in the field of agricultural production, greenhouse data monitoring and signal control technology has been relatively mature [1,2] . However, due to the coupling and hysteresis of greenhouse regulation [3] and the diversity of environmental requirements of crops. Leading to highly reliable and easy-to-use automatic control methods is still the biggest difficulty in current greenhouse research [4,5] Comparison of different routes of greenhouse control technology: Fixed value control is one of the most widely used greenhouse control technologies [5][6] , but its accuracy is low, energy consumption is large, and the oscillation is obvious [3] . In addition to fixed value control, there is direct decoupling control, due to the influence of factors such as the difficulty of obtaining model parameters and the difficulty of observing some variables, the accuracy of decoupling is low [7] ; fuzzy neural network, which requires more accuracy In the original training set of, the application scenario is affected by the limitations of the optimization function, and the traditional algorithm is easy to fall into the local minimum [8] ; the expert system, which integrates expert-level knowledge in special fields for inference control [9,10] , The degree of intelligence in agriculture is greatly improved, and the system functions are diversified. However, it is difficult to adjust manually in different environments, resulting in poor versatility and inaccurate control [7] .
Most of the above control methods are analyzed and adjusted according to one or some characteristics of the greenhouse, and the effect of single-use is not good, and they are often mixed in practice to improve the robustness of the system. However, as the information dimension increases, the utilization rate of the system decreases, neural networks and direct decoupling methods gradually become bottlenecks, and the difficulty of coordination between rules in expert systems is also greatly increased. It is difficult to build some types of traditional control methods as the core Form a unified and coordinated control system. The complexity of control also makes it difficult for workers to effectively participate in greenhouse regulation and control.
The superiority of CEP: It transforms into EPA (Event Processing Agent) for event reception and generation based on human original control experience according to a specific process. Each EPA is relatively independent and has a flexible structure. As a whole, it performs refined control and scheduling by identifying specific greenhouse scenarios, and then integrates knowledge in different fields, reduces operating errors, and has great advantages in achieving effective early warning and human-machine coordination to the goal of unmanned management.
Current status and problems to be solved: In agriculture, Bertha et al. have proposed a complete set of methods for building the peripheral system of a complex event processing engine [20] , Li et al. also made a detailed analysis of the spatiotemporal event model in agriculture [14] , Deng They also made relevant attempts for the use of non-CEP-structured time automata in greenhouses [16] , but the above research did not involve the production of complete event processing rule sets, and only made rules for certain special environmental parameters, and did not form A set of universal and complete event aggregation structure and CEP rule set production method that can give full play to the advantages of complex event processing technology.

Related technology
CEP (complex event processing technology) is derived from active database technology [12] and is an important method to solve the problem of multiple sequential event stream processing [13] . It can make full use of information from different angles to make decisions on the current situation and has powerful asynchronous decoupling. And situation analysis capabilities. The decision-making method mainly depends on the connection method of EPA (Event Processing Agent) and the realization of EPA aggregation logic. There are very few applications of complex event processing in the field of greenhouse control.

Analysis of Complex Events in the Greenhouse
The focus of research on the use of CEP in greenhouses is to define a common EPA connection method and the type of events to be transmitted, that is, the event aggregation structure. There are four main information objects in the greenhouse information: controller, worker, environment, and processing engine. The relationship is shown in Figure 1: The main information roles and information relationships of greenhouses With the CEP engine as the core, its message generation can be divided into four main processes: the issuance and feedback of control commands, the generation of environmental requirements, the judgment of the control effect of the controller, and the scheduling of control methods. Feedback is analyzed in detail.

Control the basic process of publishing
The greenhouse mainly includes the following stages: ① When the current environment state is inconsistent with the control target, the processing engine will receive the new environmental change demand, which is recorded as End; ② According to the environmental situation, the processing engine sends a series of control commands to the controller. Denoted as Aci; ③ After the controller receives Aci, it returns the state of the controller to the processing engine, denoted as CSI; at the same time, the controller tries to execute instructions from the processing engine, which will have an actual impact on the environment, denoted as Actual Control; ④At the same time, The processing engine informs workers of the current system working status, such as environmental warning information. This process is denoted as Ewi. From the above analysis, the UML sequence diagram of the basic process of feedback control is obtained, as shown in Figure 2: UML sequence diagram of the basic process of feedback control For the final system implementation, UML sequence diagrams need to be converted into UML state diagrams. Record the control method as CS: Method. From this, the UML state diagram of the basic process of feedback control can be obtained, as shown in Figure 3: For a control system with multiple control methods, the scheduling and operation of other control methods need to be considered among the control methods. If the identification of the called control method is recorded as Cmt, for the CEP engine, the causal relationship generated by the event, that is, the aggregation relationship can be represented by the event state transition relationship diagram, as shown in Figure 4. The color of each type of information in the figure represents the source of the information. The specific source is shown in the legend on the left. The arrow represents the factors that need to be considered when generating this type of information. Hereinafter, this event state transition relationship is referred to as the aggregation structure of events, which is processed by the CEP engine The structure of the EPA required for these conversions is called the event processing structure. Considering that the above model judges whether the information transmission is successful, the above model needs to be further improved by introducing the new event process. The generation of the other three environmental requirements, the judgment of the control effect of the controller, and the scheduling of the control method can be deduced according to this idea.

Build information aggregation structure
According to the analysis and derivation of the information sequence structure and relationship of the four major information objects, the issuance and feedback of the control commands in the greenhouse, the generation of environmental demands, the judgment of the control effect and the control method scheduling, the obtained structures can be combined to form a complete The information aggregation structure, that is, the event model in the greenhouse is shown in Figure 5. In the figure, the starting point and endpoint of all kinds of information aggregation are a kind of information received or sent by the system, which is a complete information system structure.

Fig 5.
Greenhouse event model The statistics of all events in the model can be divided into three types: input atomic events provided by the outside world to the engine, complex events finally output by the engine, and complex events representing the required intermediate information, as shown in Tables 1  to 3 Table1. Complex events output by the engine Integrate all the above information processing units to obtain the event processing structure used to implement the CEP engine, as shown in Figure 6. The complex event processing structure of the greenhouse 4 Implementation framework of CEP engine.

Implementation plan of event aggregation execution unit
The execution unit that can realize event aggregation is also called EPA. It uses automata technology to build EPA. It uses jumps between states to identify the content of the event and the relationship that exists. When entering a new state, it will execute an action that needs to be performed in the state and modify it. Local variables. Among them, jumps between states are divided into three categories, which are triggered by specific events, timers, and boundary conditions. When the EPA jumps to the next state, it will perform a set of actions that need to be performed in the state. Among them, actions include three types of modifying local variables using the event information just received, generating new events, and executing specific instructions.

Implementation scheme of event delivery transceiver unit
The transceiver unit for event transmission between EPAs can form a network of multiple EPAs to communicate with each other. Each EPA will respond to input events and pass the output events to other EPAs. This kind of structure constitutes a kind of EPA communication network called Event Processing Network (EPN), which is the key to the realization of complex event aggregation.
To enable accurate communication between EPAs, the transceiver unit is required to complete the accurate delivery of events. In this paper, the system uses Kafka middleware with message subscription function to implement event delivery and reception. For the CEP engine, the realization of delivery needs to ensure that all kinds of messages collected and generated by the event processing agent in the system can be packaged into events.

Planting plan selection
In this paper, lettuce is selected as the object of planting plan selection, structure construction, and simulation experiment. The typical sensor group and controller group existing in the glass solar greenhouse of Zhuozhou Intelligent Agriculture Laboratory of China Agricultural University are used as the collection and control of the simulation experiment. equipment. Organize the planting plan of lettuce by collecting crop planting books, literature, and web materials in [17][18][19] in the references. The planting plan is shown in Table 4 Table4. Lettuce

Greenhouse complex event model
Each event flow from the beginning to the end in the figure corresponds to a specific agricultural issue. The system needs to use existing response strategies to construct an event processing unit, analyze the current situation based on the sequence of events that have occurred, and transmit the analysis results to other units. Regarding the environment, it is necessary to observe the changing trend of the greenhouse (EPA2), according to the crop planting plan, find the most favorable greenhouse environment for crop growth (EPA5, EPA6, EPA3), and consider the mutual influence relationship existing in the greenhouse to refine the regulation. Target (EPA7). In terms of control, the system needs to monitor whether the connection and operation of the controller are normal (EPA8), consider the impact of the environment on the controller effect (EPA1, EPA4), how to schedule the controller and generate early warnings (EPA9, EPA10, EPA11, EPA12) And whether the instruction is executed smoothly (EPA13). The following is only a detailed explanation of the construction ideas of the greenhouse change trend EPA.

Greenhouse change trend judgment model
EPA2 is used to obtain the changing trend of environmental factors from environmental information. Specifically, EPA2 will record the current environmental event and the last environmental event processed to obtain the change value of the environmental factor and the time difference between the two events, and obtain the historical or future environmental factor change speed, that is, the changing trend. EPA2 information structure Take temperature as an example. In the actual scene, its changing trend has three types of states: rising, falling, and stable, which represents the rising, falling, and stable trend of temperature in a certain period. To judge this kind of trend, it is necessary to obtain the values of environmental factors throughout a period of time, and the state transition is mainly determined by the difference between the two. Therefore, three states can be defined in EPA2, which are steady (E), rising (R), and falling (F). Three types of boundary conditions are defined. The difference between the predicted value and the true value is greater than the threshold (tr), and the true The difference between the predicted value and the predicted value is greater than the threshold (tf) and the absolute value of the difference between the predicted value and the true value is less than the threshold (te). For example, when the EPA state is at F and the boundary condition te is established, the EPA state will jump to E and generate an Etd (tem, EQUAL) event. The specific process is shown in Figure 8:

To sum up
This paper solves the key problem of the greenhouse control engine construction in the CEP system, provides a complete greenhouse event aggregation scheme, realizes the greenhouse complex event processing system based on the automata algorithm and the expert system rules, and well integrates the current greenhouse Predicting, formulating planting plans, decoupling, human-machine coordination control plans and their scheduling strategies, early warning and Internet of Things monitoring and other common areas of knowledge and methods, fully combining the advantages of various control methods to control the characteristics of greenhouses, and coordinating with each other. As a whole, it has good interpretability and an easier optimization strategy, which realizes the efficient control of man-machine coordination