Abstract:Abstract: Traditional agriculture uses manual way to control temperature and moisture in a greenhouse, but with the rapid development of modern agriculture, this high manpower investment and low accuracy control method cannot meet the needs of the modern agriculture. This paper used the concept of hierarchical finite state machine and lattice-based event to build a 3-layer cyber physical system model, and put forward a hierarchical finite state machine based spatiotemporal cyber physical system modeling method to design a new greenhouse control system. In these modeling methods, the cyber physical system was divided into three layers: physical layer, physical-cyber layer and the cyber layer. There were also two flows in cyber physical system: information gathering flow and decision control flow. The physical layer had sensor nodes, sensor motes and actors, the physical-cyber layer had sink nodes and controller nodes, and the cyber layer had a decision node. The hierarchical finite state machine can easily express the 3-layers system, the state transition between each layer, and the conversion relationship between the two flows in mathematical expressions. In the information gather flow, sensor nodes monitored the physical environment and generated sensor events, sensor motes used physical layer's hierarchical finite state machine to transform sensor events into physical events, and then passed physical events to sink nodes. Sink nodes used physical-cyber layer's hierarchical finite state machine to transform physical events into physical-cyber events. In the decision control flow, decision node used another physical-cyber layer's hierarchical finite state machine to transform the physical-cyber events into cyber events, and passed cyber events to the controller nodes, controller nodes used another physical layer's hierarchical finite state machine to transform cyber events into control events, and passed control events to the actors. At last, actors used the control events to change the physical environment. The lattice-based event modeling method can be used to divide cyber physical system event into three parts: event attributes, the observer information, the occurrence time and location and attribute information of the event. Event attributes referred that which type the event belonged to, the occurrence time referred that when the event happened, the occurrence location referred that where the event happened, and the attribute information of the event referred the physical environment. Because the 3-layer spatiotemporal model method considered the spatiotemporal attribute into the events of each layer's state machine, it improved the event detection and control accuracy in the greenhouse effectively, and ensured the greenhouse environment to meet the plant growth demands for temperature, humidity and light. The experiment proved that 3-layer spatiotemporal modeling method which realized the joint modeling with spatial and temporal attributes, reduced the error detection, improved the detection accuracy and the model performance was good. Compared with the traditional control methods based on "Internet of Things", we found that using 3-layers spatiotemporal cyber physical system modeling in facilities of agriculture, can improve the control accuracy from 80.20% to 87.20%, decrease the false control positive rate from 7.50% to 3.60% and the false negative rate from 12.30% to 9.20%, and it can also be adapted to the modern agriculture requirements of high precision and high automation.