Real-time regulation method for water-soluble fertilizer proportioning based on edge computing
Patent Information
- Application Number
- CN202610715320.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-05-22
- Publication Date
- 2026-08-18
AI Technical Summary
[0003]集中式云端架构的数据长距离往返传输引入不可控的网络时延,单一边缘节点架构在面对多源传感数据并发输入时存在算力瓶颈导致计算阻塞,二者均导致水溶肥配比调控指令无法及时响应环境变化,存在实时调控滞后的技术问题
[0017]1. This invention decomposes the ratio calculation logic into environmental feature extraction subtasks and ratio solving subtasks based on data type and ratio calculation complexity through an edge gateway. These subtasks are then distributed to edge nodes in the edge cluster with matching computing power for parallel execution using a load-aware protocol. This overcomes the computational blockage caused by the limited computing power of a single edge node and reduces the computation time of the ratio calculation. A lightweight time synchronization protocol is introduced to perform time-series alignment and aggregation caching of intermediate calculation results. The edge gateway reassembles atomic ratio instruction frames based on time constraints and sends them out via a deterministic network interface. This eliminates the time-series misalignment caused by multi-node parallel computation, ensuring the timeliness and execution synchronization of the ratio instruction issuance, and solving the technical problem of lag in real-time control of water-soluble fertilizer ratios.
Smart Images

Figure CN122601696A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of edge computing technology, specifically to a method for real-time control of water-soluble fertilizer ratio based on edge computing. Background Technology
[0002] Current water-soluble fertilizer formulation control systems mostly employ centralized cloud servers or single edge computing nodes for data processing and formulation calculations. In a centralized cloud architecture, field sensors collect raw soil and meteorological data, which is then uploaded in full to a remote server via a wide area network (WAN). The server completes the formulation calculation, generates control commands, and then distributes them to the field fertilizer mixing actuators via the WAN. In a single edge node architecture, all sensor data converges to a local edge gateway, which independently handles all environmental feature extraction and formulation calculations, and directly outputs control commands.
[0003] The long-distance round-trip data transmission of centralized cloud architecture introduces uncontrollable network latency, and the single edge node architecture has computing power bottlenecks when facing concurrent input of multi-source sensor data, leading to computing blockage. Both of these result in water-soluble fertilizer ratio control commands failing to respond to environmental changes in a timely manner, resulting in technical problems of real-time control lag. Summary of the Invention
[0004] The purpose of this invention is to provide a method for real-time control of water-soluble fertilizer ratio based on edge computing, which can solve the problems mentioned in the background art.
[0005] To achieve the above objectives, the technical solution adopted by the present invention is as follows:
[0006] A real-time control method for water-soluble fertilizer ratio based on edge computing includes the following steps: an edge gateway receives multi-source soil and meteorological sensor data; based on the data type and ratio calculation complexity of the sensor data, the ratio calculation logic is decomposed into an environmental feature extraction subtask and a ratio solving subtask; the environmental feature extraction subtask and the ratio solving subtask are distributed to edge nodes with matching computing power in the edge cluster for parallel execution through a load-aware protocol; a lightweight time synchronization protocol is introduced, and after completing the corresponding subtask, the edge node sends the intermediate calculation results back to the edge gateway for aggregation; the edge gateway reassembles the aggregated intermediate calculation results according to time constraints to generate an atomic ratio instruction frame, and sends the atomic ratio instruction frame to the water-soluble fertilizer mixing actuator through a deterministic network interface.
[0007] Preferably, based on the data type and computational complexity of the sensor data, the computational calculation logic is decomposed into an environmental feature extraction subtask and a computational calculation subtask, including: parsing the computational calculation logic, constructing a task directed acyclic graph (DAG) representing computational dependencies, where nodes in the DAG represent computational operators and edges represent data flow directions; identifying the feature extraction operator set and the computational calculation operator set in the DAG; and, based on the hardware heterogeneity of each edge node in the edge cluster, segmenting the feature extraction operator set and the computational calculation operator set, clustering operators with strong data dependencies and computationally intensive operations into the computational calculation subtask, and clustering operators with high input / output bandwidth occupancy and low computational density into the environmental feature extraction subtask, and generating a data exchange interface definition between the subtasks.
[0008] Preferably, the environmental feature extraction subtask and the ratio calculation subtask are distributed to edge nodes with matching computing power in the edge cluster for parallel execution via a load-aware protocol. This includes: the edge gateway periodically collecting the CPU utilization, remaining memory capacity, and network transceiver queue depth of each edge node in the edge cluster to construct a node resource state vector; calculating the resource requirement vectors of the environmental feature extraction subtask and the ratio calculation subtask; calculating the Euclidean distance between the resource requirement vector and the resource state vector of each node as the load matching degree; selecting edge nodes with a load matching degree greater than a preset threshold as candidate nodes, and distributing the environmental feature extraction subtask and the ratio calculation subtask to the edge node with the highest load matching degree among the corresponding candidate nodes for execution.
[0009] Preferably, a lightweight time synchronization protocol is introduced. After completing the corresponding subtask, the edge node sends the intermediate calculation results back to the edge gateway for aggregation. This includes: the edge gateway broadcasting a synchronization reference message to the edge cluster; the edge node recording the timestamp of the received synchronization reference message and calculating the clock offset between its local clock and the master clock of the edge gateway; when generating the intermediate calculation results after completing the subtask, the edge node compensating and correcting the timestamp of the intermediate calculation results based on the clock offset; the edge node encapsulating the intermediate calculation results carrying the corrected timestamp into an aggregation message and sending the aggregation message to the edge gateway according to a preset backhaul period; and the edge gateway performing time-series alignment and aggregation caching on the intermediate calculation results sent back by different edge nodes based on the corrected timestamp.
[0010] Preferably, the edge gateway reassembles the aggregated intermediate calculation results according to timing constraints to generate an atomic proportioning instruction frame, and sends the atomic proportioning instruction frame to the water-soluble fertilizer mixing actuator via a deterministic network interface. This includes: the edge gateway verifying the integrity and temporal continuity of the intermediate calculation results in the aggregation cache; deserializing the verified intermediate calculation results to extract the proportion values of each element of the water-soluble fertilizer and their corresponding action timestamps; encoding the proportion values of each element of the water-soluble fertilizer and the action timestamps according to the control protocol format of the water-soluble fertilizer mixing actuator, and encapsulating them into the atomic proportioning instruction frame with an atomic execution identifier; and calling the time-sensitive scheduling queue of the deterministic network interface to send the atomic proportioning instruction frame to the water-soluble fertilizer mixing actuator before the action timestamp.
[0011] Preferably, the edge gateway receiving multi-source soil and meteorological sensor data includes: the edge gateway receiving raw sensor messages from a heterogeneous sensor network through a multi-protocol parsing interface; extracting sensor identifiers, acquisition times, and measurement values from the raw sensor messages; querying a pre-configured spatial topology mapping table based on the sensor identifiers to obtain the spatial location weights of the sensors; weighting and fusing measurement values with the same acquisition time according to the spatial location weights, and using a sliding window filtering mechanism to remove abnormal jump values that deviate from the normal distribution in the measurement values; and combining the filtered and fused measurement values with the corresponding sensor identifiers to form structured sensor data as the multi-source soil and meteorological sensor data output.
[0012] Preferably, after splitting the set of feature extraction operators and the set of ratio solving operators, the method further includes: for cases where there is cross-node data exchange between the split environmental feature extraction subtask and the ratio solving subtask, establishing a shared memory mapping area between the edge nodes executing the environmental feature extraction subtask and the edge nodes executing the ratio solving subtask; configuring a read-write mutex lock for the shared memory mapping area; when the environmental feature extraction subtask generates feature tensor data, acquiring write permission from the read-write mutex lock, writing the feature tensor data into the shared memory mapping area, and releasing the write permission; after the edge node executing the ratio solving subtask detects the release of the write permission, acquiring read permission to read the feature tensor data and continue performing the ratio solving calculation.
[0013] Preferably, after distributing the environmental feature extraction subtask and the ratio calculation subtask to the edge node with the highest load matching degree among the corresponding candidate nodes for execution, the method further includes: real-time monitoring of the chip junction temperature and power consumption fluctuation rate of the edge node to which the subtask has been assigned; triggering a task migration mechanism when the chip junction temperature or the power consumption fluctuation rate exceeds the corresponding safety threshold; recalculating the migration matching degree of the environmental feature extraction subtask or the ratio calculation subtask on other idle edge nodes in the edge cluster; serializing the execution context state data of the subtask being executed on the edge node that exceeds the safety threshold, and migrating the execution context state data to the idle edge node with the highest migration matching degree to resume execution through the direct connection transmission channel between edge nodes.
[0014] Preferably, calculating the clock offset between the local clock and the master clock of the edge gateway further includes: the edge node recording a sequence of received timestamps of multiple consecutive synchronization reference messages, calculating the local clock drift rate between adjacent received timestamps; constructing a clock compensation prediction model based on the local clock drift rate, and using the clock compensation prediction model to estimate the predicted drift value within the next synchronization interval; during the synchronization interval between two adjacent received synchronization reference messages, the edge node dynamically adjusts the phase of the local timer based on the predicted drift value; when the intermediate calculation result is generated, the value of the dynamically phase-adjusted local timer is read as the timestamp of the intermediate calculation result to eliminate the error caused by the continuous accumulation of local clock offset during the synchronization interval.
[0015] Preferably, after verifying the integrity and temporal continuity of intermediate calculation results in the aggregation cache, the method further includes: when it is detected that the intermediate calculation result corresponding to a specific timestamp is missing in the aggregation cache, extracting the historical ratio parameter sequence adjacent to the specific timestamp from the historical ratio database; calculating the change gradient characteristics of the historical ratio parameter sequence; performing differential extrapolation estimation based on the change gradient characteristics and the received intermediate calculation results of adjacent timestamps to generate estimated ratio parameters to replace the missing data; marking the estimated ratio parameters as a downgrade confidence identifier, and participating in the recombination together with the normally received intermediate calculation results to generate an atomic ratio instruction frame with a downgrade execution identifier and sending it out to maintain the continuity of the water-soluble fertilizer mixing actuator control process.
[0016] Compared with the prior art, the beneficial effects of the present invention are as follows:
[0017] 1. This invention decomposes the ratio calculation logic into environmental feature extraction subtasks and ratio solving subtasks based on data type and ratio calculation complexity through an edge gateway. These subtasks are then distributed to edge nodes in the edge cluster with matching computing power for parallel execution using a load-aware protocol. This overcomes the computational blockage caused by the limited computing power of a single edge node and reduces the computation time of the ratio calculation. A lightweight time synchronization protocol is introduced to perform time-series alignment and aggregation caching of intermediate calculation results. The edge gateway reassembles atomic ratio instruction frames based on time constraints and sends them out via a deterministic network interface. This eliminates the time-series misalignment caused by multi-node parallel computation, ensuring the timeliness and execution synchronization of the ratio instruction issuance, and solving the technical problem of lag in real-time control of water-soluble fertilizer ratios.
[0018] 2. Construct a directed acyclic graph of tasks and segment and cluster the operator set based on the heterogeneous characteristics of edge node hardware to match tasks with different computational characteristics to corresponding node resources, thereby improving the utilization rate of cluster resources; select candidate nodes for task distribution based on the Euclidean distance between node resource state vectors and resource demand vectors to achieve matching of computing power and load; correct the time stamp of intermediate calculation results based on clock offset to eliminate the interference of multi-node clock differences on aggregation results; use the time-sensitive scheduling queue of the deterministic network interface to send atomic allocation instruction frames to avoid instruction transmission delays caused by network congestion; monitor the junction temperature and power consumption fluctuation rate of edge node chips and trigger task migration to ensure the stability of edge cluster operation; calculate the clock drift rate to perform dynamic phase fine-tuning of local timers to eliminate accumulated errors during synchronization intervals; when missing intermediate calculation results are detected, perform differential extrapolation estimation based on the gradient characteristics of historical allocation parameter sequences to generate estimated allocation parameters with degraded execution indicators, maintaining the continuity of the fertilizer mixing actuator control process. Attached Figure Description
[0019] Figure 1 This is a flowchart of the multi-source soil and meteorological sensor data reception and preprocessing process of the present invention;
[0020] Figure 2 This is a flowchart of the logic task decomposition and subtask construction for the proportion calculation of the present invention;
[0021] Figure 3 This is a flowchart of the load-aware subtask distribution and abnormal task migration of the present invention;
[0022] Figure 4 This is a flowchart of the lightweight time synchronization and intermediate calculation result aggregation process of the present invention;
[0023] Figure 5 This is a flowchart of the atomic proportioning instruction frame generation and deterministic network distribution process of the present invention;
[0024] Figure 6This is a flowchart of the intermediate calculation result missing compensation and downgrade instruction generation process of the present invention. Detailed Implementation
[0025] In one embodiment, a real-time control system for water-soluble fertilizer ratio based on edge computing includes an edge gateway, an edge cluster, a multi-source heterogeneous sensor network, and a water-soluble fertilizer mixing actuator. The edge gateway, acting as the system's control center, connects to each edge node in the edge cluster via a gigabit LAN, to the multi-source heterogeneous sensor network via a multi-protocol parsing interface, and to the water-soluble fertilizer mixing actuator via a deterministic network interface. The edge gateway employs an embedded architecture, runs a real-time operating system, and possesses multi-protocol parsing, task scheduling, data aggregation, and command issuance capabilities. The edge cluster consists of multiple heterogeneous edge nodes, each with independent computing, storage, and network communication capabilities, used for parallel execution of ratio calculation subtasks. The multi-source heterogeneous sensor network is deployed in various irrigation zones in the field for real-time collection of soil and meteorological parameters. The water-soluble fertilizer mixing actuator is installed at the irrigation head to receive ratio instructions from the edge gateway and execute the mixing operation.
[0026] refer to Figure 1 The edge gateway receives raw sensor messages from the heterogeneous sensor network through a multi-protocol parsing interface. This interface supports multiple industrial-grade communication protocols such as Modbus-RTU, LoRaWAN, NB-IoT, and MQTT, ensuring compatibility with sensor devices from different manufacturers and of different types. For the Modbus-RTU protocol, the edge gateway connects to the sensor via an RS485 bus. The received raw message is in binary format, 9 bytes in length, containing a 1-byte slave address, a 1-byte function code, a 1-byte data length, 4 bytes of measurement data, and a 2-byte CRC checksum. The edge gateway first performs a CRC check on the message, using a check polynomial of 0x8005 and an initial value of 0xFFFF. If the check fails, the message is discarded; if it passes, the slave address is extracted as the sensor identifier, the high 16 bits and low 16 bits of the data field are combined according to the IEEE 754 standard to form a 32-bit floating-point number as the measurement value, and the local timestamp at the time of message reception is extracted as the acquisition time.
[0027] For the LoRaWAN protocol, the edge gateway communicates with the sensor through an external LoRa concentrator. The received raw packets conform to the LoRaWAN 1.0.2 specification and include fields such as preamble, synchronization word, PHDR, PHDR_CRC, MACPayload, and MIC. The edge gateway first performs MIC verification on the packet using the AES-CMAC algorithm and a pre-configured network session key. If the verification fails, the packet is discarded; if the verification passes, the MACPayload field is parsed, the DevAddr field is extracted as the sensor identifier, the FPort field is extracted to determine the encoding format of the application data, the FRMPayload field is extracted and parsed according to the corresponding encoding format to obtain the measurement value, and the local timestamp at the time of packet reception is extracted as the acquisition time.
[0028] For the NB-IoT protocol, the edge gateway connects to the sensor via the operator's cellular network. The received raw messages are in CoAP protocol format, containing version number, message type, token length, code, message ID, token, and options and payload fields. The edge gateway first parses the CoAP message header to extract the message ID and token, then parses the options field to obtain the sensor identifier and data format, and finally parses the payload field to obtain the measurement value. The local timestamp at the time of message reception is extracted as the acquisition time.
[0029] For the MQTT protocol, the edge gateway acts as an MQTT client, connecting to the local MQTT broker and subscribing to topics published by the sensors. When a sensor publishes data, the edge gateway receives the MQTT message, parses the message's topic field to obtain the sensor identifier, parses the message's payload field to obtain the measurement data in JSON format, and extracts the local timestamp of the message reception as the acquisition time.
[0030] The edge gateway queries a pre-configured spatial topology mapping table based on the extracted sensor identifiers to obtain the spatial location weights of the sensors. The spatial topology mapping table is stored in the edge gateway's non-volatile memory. Each record in the table contains five fields: sensor identifier, installation location longitude, installation location latitude, irrigation zone number, and spatial location weight. The spatial location weights are pre-calculated and configured based on the sensor's coverage and representativeness within the irrigation zone. Sensors located in the center of the irrigation zone with a larger coverage area have higher spatial location weights, while sensors located at the edge of the irrigation zone with a smaller coverage area have lower spatial location weights. The spatial location weights range from 0 to 1, and the sum of the spatial location weights of all sensors of the same type within the same irrigation zone is 1. When a sensor is added or removed from an irrigation zone, the edge gateway automatically updates the spatial topology mapping table and recalculates the spatial location weights of the remaining sensors to ensure that the sum of the weights remains 1.
[0031] The edge gateway performs weighted fusion of measurements taken at the same time, in the same irrigation zone, and with the same parameter type, based on spatial location weights. The formula for calculating the weighted fused measurement value is as follows:
[0032]
[0033] in, For collection time Irrigation zones Parameter type The corresponding weighted fused measurement value, Irrigation zones Internal collection time is Parameter type The number of sensors, Irrigation zones intrinsic parameter types The Spatial location weights of each sensor Irrigation zones intrinsic parameter types The Each sensor during data acquisition time The measured value.
[0034] The edge gateway utilizes a sliding window filtering mechanism to remove outlier values that deviate from the normal distribution in the weighted fused measurements. The sliding window filter employs a fixed-size sliding window that slides along the time axis in steps equal to the acquisition period. For each measurement sequence within a window, the edge gateway calculates its mean and standard deviation. Measurements exceeding three times the standard deviation are identified as outlier values and removed. The mean of the remaining valid measurements within the window is then used to replace these outlier values. The formula for calculating the mean in the sliding window filter is:
[0035]
[0036] The formula for calculating the standard deviation of sliding window filtering is:
[0037]
[0038] in, The number of valid measurements within the sliding window. For the first in the sliding window At each data acquisition time point, when the number of abnormal jump values within the sliding window exceeds 1 / 3 of the window size, the edge gateway determines that the measurement value sequence of this parameter type has a serious anomaly, sends a status query command to the corresponding sensor, and checks the sensor's working status. If the sensor returns a fault status, the sensor's measurement value is marked as invalid, and the sensor's measurement value is excluded in the subsequent weighted fusion process. The spatial location weights of other sensors of the same type within the same irrigation zone are then recalculated.
[0039] The edge gateway combines the filtered and fused measurements with the corresponding sensor identifier, acquisition time, irrigation zone number, and parameter type to form structured sensor data, which is then output as multi-source soil and meteorological sensor data. The structured sensor data is stored in JSON format, with each data item containing five fields: sensor_id, timestamp, irrigation_zone, parameter_type, and value, corresponding to the sensor identifier, acquisition timestamp (milliseconds), irrigation zone number, parameter type code, and filtered and fused measurement value, respectively. The edge gateway stores the structured sensor data in a local time-series database and simultaneously transmits it to the task decomposition module for further processing.
[0040] In this embodiment, the data types and preprocessing parameters of the multi-source sensing are shown in Table 1.
[0041] Table 1. Multi-source sensor data types and preprocessing parameters
[0042] Soil temperature Platinum resistance temperature sensor Modbus-RTU 5 0.15-0.25 Soil moisture Capacitive humidity sensor LoRaWAN 7 0.12-0.22 Soil pH Glass electrode pH sensor NB-IoT 9 0.10-0.20 Soil electrical conductivity Four-electrode conductivity sensor MQTT 7 0.10-0.20 Soil nitrogen content Ion selective electrode LoRaWAN 11 0.08-0.18 Soil phosphorus content Ion selective electrode LoRaWAN 11 0.08-0.18 Soil potassium content Ion selective electrode LoRaWAN 11 0.08-0.18 air temperature NTC thermistor sensor MQTT 3 0.20-0.30 air humidity Capacitive humidity sensor MQTT 3 0.20-0.30 Light intensity Silicon photodiode sensor MQTT 3 0.20-0.30 wind speed Three-cup anemometer Modbus-RTU 5 0.20-0.30 Rainfall tipping bucket rain gauge Modbus-RTU 1 0.20-0.30
[0043] Table 1 lists the multi-source sensing data types involved in this embodiment, the corresponding sensor types, the communication protocols used, the window size of the sliding window filter, and the range of spatial location weights. The sliding window size for different parameter types is determined based on the time-varying characteristics of the parameters. Soil nutrient parameters with slower change rates use larger window sizes to improve the filtering effect, while meteorological parameters with faster change rates use smaller window sizes to preserve the dynamic characteristics of the data. The range of spatial location weights is determined based on the deployment density of the sensors within the irrigation zone. Soil nutrient sensors with higher deployment density have lower spatial location weight ranges, while meteorological sensors with lower deployment density have higher spatial location weight ranges.
[0044] refer to Figure 2Based on the data type and computational complexity of the sensor data, the edge gateway breaks down the ratio calculation logic into environmental feature extraction and ratio solving subtasks. The ratio calculation logic is pre-loaded into the edge gateway and includes multiple computational steps such as soil moisture analysis, meteorological condition analysis, crop fertilizer requirement calculation, water-soluble fertilizer element ratio calculation, and constraint verification. The edge gateway first performs a static analysis of the ratio calculation logic to identify the input and output data types, data volume, and computational complexity of each computational step. For computational steps that primarily preprocess, transform, and extract features from the raw sensor data, their input and output bandwidth utilization is high but their computational density is low; these are classified as environmental feature extraction computational steps. For computational steps that primarily perform numerical calculations and model inference based on the extracted environmental features, they exhibit strong data dependencies and are computationally intensive; these are classified as ratio solving computational steps. The edge gateway combines all environmental feature extraction computation steps into an environmental feature extraction subtask, and all ratio calculation computation steps into a ratio calculation subtask. It also generates data exchange interface definitions between subtasks, and clarifies the dimension, data type, storage format of the feature tensors output by the environmental feature extraction subtask, as well as the format requirements of the feature tensors input by the ratio calculation subtask.
[0045] The edge gateway uses a load-aware protocol to distribute environmental feature extraction and resource allocation subtasks to edge nodes in the edge cluster with matching computing power for parallel execution. The load-aware protocol is an application-layer protocol running between the edge gateway and edge nodes, used to achieve real-time acquisition of edge node resource status and intelligent distribution of subtasks. The edge gateway periodically sends resource status query messages to all edge nodes in the edge cluster. Upon receiving the query message, each edge node collects its local CPU utilization, remaining memory capacity, and network transceiver queue depth, encapsulates this information into a resource status response message, and sends it back to the edge gateway. Based on the received resource status response messages, the edge gateway constructs a resource status vector for each edge node and calculates the load matching degree between each subtask and the edge node. The edge gateway then selects edge nodes with the highest load matching degree as candidate nodes and distributes the subtasks to the candidate nodes with the highest load matching degree for execution.
[0046] The edge gateway introduces a lightweight time synchronization protocol to achieve clock synchronization between each edge node and the edge gateway in the edge cluster. The lightweight time synchronization protocol adopts a master-slave synchronization architecture, with the edge gateway acting as the master clock node and the edge nodes acting as slave clock nodes. The edge gateway broadcasts a synchronization reference message to the edge cluster at fixed time intervals. This message contains the current timestamp of the edge gateway's master clock. Upon receiving the synchronization reference message, each edge node records its local clock's reception timestamp and calculates the clock offset between its local clock and the master clock. When generating intermediate calculation results after completing subtasks, the edge nodes compensate and correct the timestamps of the intermediate calculation results based on the clock offset, ensuring that the intermediate calculation results generated by different edge nodes have a unified time reference.
[0047] Edge nodes encapsulate intermediate calculation results carrying corrected timestamps into aggregated messages and send these messages to the edge gateway according to a preset transmission cycle. The aggregated messages are encapsulated using the UDP protocol and include fields such as edge node identifier, subtask identifier, intermediate calculation result data length, intermediate calculation result data, and corrected timestamps. After receiving the aggregated messages from each edge node, the edge gateway extracts the corrected timestamps and intermediate calculation result data from the messages. Based on the corrected timestamps, it performs time-series alignment of the intermediate calculation results transmitted from different edge nodes, aggregates the environmental feature extraction results and matching result calculation results with the same timestamps, and stores them in an aggregation cache.
[0048] The edge gateway reassembles the aggregated intermediate calculation results according to timing constraints to generate atomic proportioning instruction frames. First, the edge gateway verifies the integrity and temporal continuity of the intermediate calculation results in the aggregation cache. It then deserializes the verified intermediate calculation results to extract the proportion values of each element in the water-soluble fertilizer and their corresponding action timestamps. The edge gateway encodes the proportion values and action timestamps according to the control protocol format of the water-soluble fertilizer mixing actuator, encapsulating them into atomic proportioning instruction frames with atomic execution identifiers. The atomic execution identifier indicates that the mixing actuator must completely execute all proportioning operations in this instruction frame and must not partially execute or interrupt execution.
[0049] The edge gateway sends atomic proportioning command frames to the water-soluble fertilizer mixing actuator via a deterministic network interface. The deterministic network interface employs time-sensitive networking (TSN) technology, supporting time-aware shaping and priority scheduling. The edge gateway places the atomic proportioning command frames into a time-sensitive scheduling queue with the highest transmission priority, ensuring that the command frames are transmitted to the mixing actuator within a preset time window. The edge gateway calculates the latest transmission time of the command frames based on the action timestamp and the maximum transmission delay, ensuring that the command frames arrive at the mixing actuator before the action timestamp. Upon receiving the atomic proportioning command frames, the mixing actuator parses the proportion values and action timestamp. When the action timestamp arrives, it starts the mixing device, precisely controlling the feed rate of each element according to the proportion values. After completing the mixing operation, it delivers the mixed water-soluble fertilizer to the corresponding irrigation zone.
[0050] This embodiment fully implements the basic process of real-time control of water-soluble fertilizer ratio based on edge computing. It receives multi-source heterogeneous sensor data through a multi-protocol parsing interface and performs weighted fusion and sliding window filtering preprocessing. The ratio calculation logic is decomposed into two sub-tasks: environmental feature extraction and ratio solution, which are distributed to the edge cluster for parallel execution. A lightweight time synchronization protocol is used to realize the time alignment and aggregation of intermediate calculation results. Finally, an atomic ratio instruction frame is generated and sent to the fertilizer mixing actuator through a deterministic network interface.
[0051] In a preferred embodiment, the edge gateway decomposes the matching calculation logic into environmental feature extraction and matching calculation subtasks based on the data type and computational complexity of the sensor data, as follows: The edge gateway first performs static code analysis on the matching calculation logic, abstracting each basic computational operation into a computational operator node. The attributes of the computational operator node include a unique operator identifier, operator type, input parameter list, output parameter list, computational complexity estimate, input data volume estimate, and output data volume estimate. The operator type includes filtering operators, normalization operators, feature transformation operators, feature selection operators, prediction operators, optimization operators, and verification operators, etc.; the computational complexity estimate is determined based on the number of arithmetic operations included in the operator, in FLOPs; and the input and output data volume estimates are determined based on the number and data type of the input and output parameters, in bytes.
[0052] Edge gateways abstract the data dependencies between computation operators as directed edges, constructing a task-directed acyclic graph (DAG) representing these dependencies. The mathematical representation of the task-directed acyclic graph is:
[0053]
[0054] in, The task is a directed acyclic graph. To compute the set of operator nodes, , To calculate the total number of operators; Let be a set of directed edges. , Indicates from node To the node A directed edge, representing a node. The output data is used as a node. The input data. The attribute of a directed edge is the amount of data transmitted, i.e., the number of nodes. To the node Number of bytes of data transmitted.
[0055] The edge gateway identification task includes a set of feature extraction operators and a set of ratio calculation operators in a directed acyclic graph. Feature extraction operators are computational operators that preprocess, transform, and extract features from raw sensor data. Their input is the raw sensor data or preprocessed intermediate data, and their output is an environmental feature vector or feature tensor. Ratio calculation operators are computational operators that calculate crop nutrient requirements, water-soluble fertilizer element ratios, and optimize control amounts based on environmental features. Their input is an environmental feature vector or feature tensor, and their output is water-soluble fertilizer ratio parameters and control instructions. The edge gateway classifies computational operator nodes according to operator type attributes to generate a set of feature extraction operators. Set of matching solution operators ,satisfy and .
[0056] The edge gateway segments the feature extraction operator set and the allocation calculation operator set based on the heterogeneous hardware characteristics of each edge node in the edge cluster. These heterogeneous hardware characteristics include CPU architecture, number of cores, clock speed, memory capacity, memory bandwidth, network interface bandwidth, and whether it is equipped with a graphics processing unit (GPU) or neural network accelerator. The edge gateway pre-collects and stores the hardware heterogeneous characteristic information of all edge nodes in the edge cluster, establishing an edge node hardware information database. For the feature extraction operator set, due to its high input / output bandwidth utilization but low computational density, it is preferentially allocated to edge nodes with higher network interface bandwidth and a larger number of CPU cores. For the allocation calculation operator set, due to its strong data dependency and computational intensity, it is preferentially allocated to edge nodes with stronger computing power and equipped with GPUs or neural network accelerators.
[0057] During the segmentation process, the edge gateway employs a density-based spatial clustering algorithm to cluster computational operators with strong data dependencies into the same subtask, thereby reducing the amount of data exchange between subtasks. The criteria for strong data dependency are that the amount of data transmitted via the directed edge between two computational operators exceeds a preset data volume threshold, and the sum of the computational complexities of the two operators is less than a preset computational complexity threshold. The clustering algorithm uses computational operator nodes as data points and the strength of data dependency between operators as the distance metric. The formula for calculating the data dependency strength is the ratio of the amount of data transmitted between two operators to the sum of their computational complexities. The clustering algorithm groups operator nodes whose distance is less than a preset distance threshold into the same cluster, with each cluster corresponding to one subtask.
[0058] In this embodiment, the set of feature extraction operators is clustered into an environmental feature extraction subtask, and the set of matching calculation operators is clustered into a matching calculation subtask. The edge gateway defines the data exchange interface between the subtasks, specifying the dimension of the feature tensor output by the environmental feature extraction subtask. ,in The number of samples to be processed in a batch. The environmental features are represented by a dimension; the data type is a 32-bit single-precision floating-point number; the storage format is NCHW format, i.e., batch-channel-height-width format. The feature tensor format input to the matching subtask is completely consistent with the feature tensor format output from the environmental feature extraction subtask.
[0059] In this embodiment, the operator classification and subtask assignment are shown in Table 2.
[0060] Table 2. Classification of computational operators and subtask assignment.
[0061] 1 Soil temperature median filter operator Feature extraction 4.8 4.8 Environmental Feature Extraction 2 Soil moisture Gaussian filter operator Feature extraction 6.4 6.4 Environmental Feature Extraction 3 Soil pH normalization operator Feature extraction 3.2 3.2 Environmental Feature Extraction 4 Logarithmic Transformation Operator of Soil Conductivity Feature extraction 6.4 6.4 Environmental Feature Extraction 5 Soil nutrient characteristic fusion operator Feature extraction 19.2 8.0 Environmental Feature Extraction 6 Meteorological feature standardization operator Feature extraction 12.8 12.8 Environmental Feature Extraction 7 Environmental feature splicing operator Feature extraction 41.6 41.6 Environmental Feature Extraction 8 Crop fertilizer requirement GRU prediction operator Solution of proportions 41.6 16.0 Solution of proportions 9 Linear calculation operator for element ratio Solution of proportions 16.0 8.0 Solution of proportions 10 Nutrient balance constraint check operator Solution of proportions 8.0 8.0 Solution of proportions 11 Quadratic programming operator for regulating quantity Solution of proportions 8.0 4.0 Solution of proportions
[0062] Table 2 lists detailed information on all computational operators included in the matching calculation logic of this embodiment, including operator number, operator name, operator type, computational complexity, input / output data volume, and subtask affiliation. As can be seen from the table, the computational complexity of feature extraction operators is generally... The scale is large, with a significant amount of input and output data, exhibiting characteristics of high input / output bandwidth utilization and low computational density; the computational complexity of the allocation solution operator is generally in the range of... arrive The scale is relatively small, with relatively small input and output data volumes, which aligns with the characteristics of strong data dependencies and computational intensity.
[0063] refer to Figure 3The process by which the edge gateway distributes the environmental feature extraction subtask and the allocation calculation subtask to edge nodes in the edge cluster with matching computing power for parallel execution via a load-aware protocol is as follows: The edge gateway periodically collects the CPU utilization, remaining memory capacity, and network transceiver queue depth of each edge node in the edge cluster, with a collection period of 100 milliseconds. For each edge node... The edge gateway constructs node resource state vectors:
[0064]
[0065] in, For edge nodes The CPU utilization rate, ranging from 0 to 1, is calculated from the average CPU utilization rate collected by the edge node over the most recent 100 milliseconds. For edge nodes The percentage of remaining memory capacity to total memory capacity, with a value ranging from 0 to 1; For edge nodes The network transceiver queue depth is the ratio of the network transceiver queue depth to the maximum queue depth, and its value ranges from 0 to 1. The network transceiver queue depth is the sum of the sending queue depth and the receiving queue depth.
[0066] The edge gateway computing environment feature extraction subtask and the resource requirement vector of each subtask are calculated based on their respective proportions. For each subtask... The resource demand vector is:
[0067]
[0068] in, For subtasks The minimum CPU utilization threshold required for normal execution, with a value ranging from 0 to 1; For subtasks The minimum percentage of remaining memory required for normal execution, ranging from 0 to 1; For subtasks The minimum network transceiver queue depth ratio threshold required for normal execution ranges from 0 to 1. The resource requirement vector is pre-determined through benchmark testing based on the computational complexity, memory usage, and data transmission volume of the subtask. In this embodiment, the resource requirement vector for the environmental feature extraction subtask is... The resource requirement vector for solving the subtask by allocation is: .
[0069] The Euclidean distance between the edge gateway's computational resource demand vector and the resource state vectors of each node is used as the load matching degree. For subtasks... With edge nodes Load matching degree The calculation formula is:
[0070]
[0071] The smaller the load matching score, the better the subtask performance. Resource requirements and edge nodes The more it matches the current resource status, the better.
[0072] The edge gateway selects edge nodes with a load matching degree lower than a preset threshold as candidate nodes. The preset threshold is dynamically adjusted based on the overall load of the edge cluster. The edge gateway calculates the overall load rate of the edge cluster every minute; the overall load rate is the average of the CPU utilization of all edge nodes. When the overall load rate is below 0.3, the preset threshold is set to 0.2; when the overall load rate is between 0.3 and 0.7, the preset threshold is set to 0.3; and when the overall load rate is above 0.7, the preset threshold is set to 0.4. The edge gateway then distributes the environmental feature extraction subtask and the matching subtask to the edge node with the lowest load matching degree among the corresponding candidate nodes for execution.
[0073] In this embodiment, the edge cluster contains 3 edge nodes, and the resource state vector of node 1 is: The resource state vector of node 2 is The resource state vector of node 3 is The current overall load rate of the edge cluster is... The value is between 0.3 and 0.7, therefore the preset threshold is 0.3. The load matching degree between the environmental feature extraction subtask and each node is calculated: , , The load matching degree of all three nodes is greater than the preset threshold of 0.3. The edge gateway adjusts the preset threshold to 0.4. The load matching degree of node 3 is less than the adjusted preset threshold, so it becomes a candidate node for the environmental feature extraction subtask. The edge gateway distributes the environmental feature extraction subtask to node 3 for execution.
[0074] Calculate the load matching degree between subtasks and each node: , , Node 2's load matching degree is less than the preset threshold of 0.3, making it a candidate node for the matching subtask. The edge gateway then distributes the matching subtask to Node 2 for execution.
[0075] After segmenting the feature extraction operator set and the matching calculation operator set, to address the cross-node data exchange between the segmented environmental feature extraction subtask and the matching calculation subtask, the edge gateway establishes a shared memory mapping area between the edge nodes executing the environmental feature extraction subtask and the edge nodes executing the matching calculation subtask. In this embodiment, the environmental feature extraction subtask is executed on node 3, and the matching calculation subtask is executed on node 2. Both nodes' network interface cards support RDMA over Converged Ethernetv2 technology. The edge gateway sends a shared memory establishment command to nodes 3 and 2, which includes the size and access permissions of the shared memory. Nodes 3 and 2 each allocate a contiguous memory region of the same size in their local physical memory, and map the two memory regions into a unified shared memory mapping area using RDMA technology. The size of the shared memory mapping area is determined based on the maximum data size of the feature tensor output by the environmental feature extraction subtask; in this embodiment, it is 1MB. The shared memory mapping area adopts a circular buffer structure, with the buffer header containing write and read pointers indicating the current write and read positions, respectively.
[0076] The edge gateway is configured with a read-write mutex lock for the shared memory mapping area. The read-write mutex lock employs a distributed token bucket mechanism, with the edge gateway acting as the token issuer. When the environmental feature extraction subtask generates feature tensor data, it sends a write token request to the edge gateway. The edge gateway checks the current state of the shared memory mapping area; if there is enough free space between the write pointer and the read pointer to store the feature tensor data, it issues a write token to node 3. After obtaining the write token, node 3 writes the feature tensor data to the position indicated by the write pointer in the shared memory mapping area, updates the write pointer, and sends a write completion notification to the edge gateway. The edge gateway then reclaims the write token.
[0077] Node 2, performing the matching subtask, monitors the read and write pointers of the shared memory mapping area every 1 millisecond. When a discrepancy is detected between the read and write pointers, it sends a read token request to the edge gateway. The edge gateway issues a read token to Node 2. After obtaining the read token, Node 2 reads the feature tensor data from the position indicated by the read pointer in the shared memory mapping area, updates the read pointer, and sends a read completion notification to the edge gateway. The edge gateway then reclaims the read token. Node 2 then uses the read feature tensor data to continue performing the matching calculation.
[0078] After the environmental feature extraction subtask and the allocation calculation subtask are distributed to the edge nodes with the highest load matching degree among the corresponding candidate nodes for execution, the edge gateway monitors the chip junction temperature and power consumption fluctuation rate of the edge nodes assigned subtasks in real time. The central processing unit of the edge node has a built-in digital temperature sensor that can collect the chip junction temperature in real time with an accuracy of 0.1℃. The power module of the edge node has a built-in power consumption monitoring chip that can collect the real-time power consumption of the node with an accuracy of 0.1W. The edge nodes send the collected chip junction temperature and real-time power consumption data to the edge gateway at 100-millisecond intervals. The edge gateway calculates the power consumption fluctuation rate of each edge node, which is the ratio of the standard deviation to the mean of the real-time power consumption over five consecutive collection periods.
[0079]
[0080] in, For edge nodes Power consumption fluctuation rate, For edge nodes The standard deviation of real-time power consumption over five consecutive acquisition cycles. For edge nodes The average real-time power consumption over five consecutive acquisition cycles.
[0081] When the junction temperature of an edge node exceeds a preset junction temperature threshold of 85°C or the power consumption fluctuation rate exceeds a preset fluctuation rate threshold of 0.2, the edge gateway triggers a task migration mechanism. The edge gateway first suspends the distribution of new tasks to that edge node, and then recalculates the migration matching degree of the subtask currently being executed on that edge node across other idle edge nodes in the edge cluster. The calculation method for the migration matching degree is the same as that for the load matching degree, i.e., calculating the Euclidean distance between the resource requirement vector of the subtask and the resource state vector of the idle edge node.
[0082] The edge gateway sends a task migration command to an edge node that exceeds the security threshold. Upon receiving the command, the edge node serializes the execution context state data of the currently executing subtask. This execution context state data includes the subtask's program counter value, general-purpose register status, floating-point register status, memory data segment content, file handle table, and network connection status. Serialization uses the Google Protocol Buffers format, and the serialized data is compressed using the LZ4 algorithm to reduce data transmission volume. The edge node transmits the compressed execution context state data to the idle edge node with the highest migration match through a direct RDMA channel with the target edge node. Upon receiving the data, the target edge node decompresses and deserializes it, restoring the subtask's execution context state and resuming execution from the breakpoint. After the task migration is complete, the edge gateway marks the original edge node as abnormal. Once its chip junction temperature and power consumption fluctuation rate return to below the security threshold, it is remarked as idle.
[0083] This embodiment details the decomposition process of the allocation calculation logic, the subtask distribution mechanism based on the load-aware protocol, the cross-node shared memory data exchange method, and the task migration mechanism when edge nodes are abnormal. By constructing a directed acyclic graph of tasks and segmenting and clustering the operator set according to the heterogeneous characteristics of edge node hardware, matching tasks with different computing characteristics to corresponding node resources is achieved; by selecting candidate nodes for task distribution based on the Euclidean distance between node resource state vectors and resource demand vectors, matching computing power with load is achieved; by establishing an RDMA shared memory mapping area, the latency of data exchange between subtasks is reduced; and by monitoring the junction temperature and power consumption fluctuation rate of edge node chips and triggering task migration, the stability of the edge cluster operation is ensured.
[0084] refer to Figure 4 In another preferred embodiment, the edge gateway introduces a lightweight time synchronization protocol. The process of edge nodes sending intermediate calculation results back to the edge gateway for aggregation after completing their respective subtasks is as follows: The lightweight time synchronization protocol adopts a master-slave unidirectional broadcast synchronization architecture. The edge gateway acts as the master clock node, with its clock source being a local high-precision temperature-compensated crystal oscillator with a frequency stability of ±0.1ppm. Each edge node in the edge cluster acts as a slave clock node, with its clock source being a common temperature-compensated crystal oscillator with a frequency stability of ±20ppm. The time synchronization period is 1 second, meaning the edge gateway broadcasts a synchronization reference message to the edge cluster every second.
[0085] The synchronization reference message is encapsulated using the UDP protocol, with a destination port number of 3190 and a message length of 20 bytes. It includes four fields: message type, master clock identifier, master clock timestamp, and sequence number. The message type field is 1 byte long with a fixed value of 0x01, identifying the message as a synchronization reference message. The master clock identifier field is 4 bytes long, consisting of the last 4 bytes of the edge gateway's MAC address. The master clock timestamp field is 8 bytes long, representing the master clock time at the time the edge gateway sent the message, in nanoseconds. The sequence number field is 7 bytes long, representing the sequence number of the synchronization reference message, incrementing from 0, and used to detect message loss.
[0086] Upon receiving the synchronization reference message, the edge node immediately triggers a hardware interrupt, recording the message's reception timestamp. This timestamp is the edge node's local clock value at the time of the interrupt trigger, measured in nanoseconds. The edge node then calculates the clock offset between its local clock and the edge gateway's master clock. For the... Secondary synchronization, clock skew The calculation formula is:
[0087]
[0088] in, For the first The master clock timestamp in the secondary synchronization reference message For edge nodes to receive the first The local timestamp of the secondary synchronization reference message.
[0089] When edge nodes generate intermediate computation results after completing subtasks, they compensate and correct the time stamps of the intermediate computation results based on the clock offset. The corrected time stamps are shown below. The calculation formula is:
[0090]
[0091] in, The local timestamp, in nanoseconds, used to generate intermediate computation results for edge nodes.
[0092] Edge nodes encapsulate intermediate calculation results carrying corrected timestamps into aggregate messages. These aggregate messages use UDP encapsulation with a destination port of 3191. The message format includes six fields: message type, edge node identifier, subtask identifier, data length, intermediate calculation result data, and corrected timestamp. Specifically, the message type field is 1 byte long with a fixed value of 0x02, identifying the message as an aggregate message; the edge node identifier field is 4 bytes long, representing the last 4 bytes of the edge node's MAC address; the subtask identifier field is 1 byte long, with 0x01 indicating the environmental feature extraction subtask and 0x02 indicating the proportioning solution subtask; the data length field is 2 bytes long, representing the number of bytes in the intermediate calculation result data; the intermediate calculation result data field is the number of bytes specified in the data length field, representing the serialized intermediate calculation result; and the corrected timestamp field is 8 bytes long, representing the corrected timestamp in nanoseconds.
[0093] Edge nodes send aggregated messages to the edge gateway according to a preset backhaul period of 100 milliseconds. If multiple intermediate calculation results are generated within a single backhaul period, the edge node encapsulates these results in the same aggregated message to reduce network transmission frequency. After receiving the aggregated messages from each edge node, the edge gateway extracts the corrected timestamps and intermediate calculation result data from the messages. Based on the corrected timestamps, it performs time-series alignment on the intermediate calculation results returned by different edge nodes. The time-series alignment process involves classifying intermediate calculation results with a corrected timestamp difference of less than 1 millisecond as results from the same time point. Environmental feature extraction results and matching result calculations from the same time point are aggregated into a group and stored in the aggregation cache according to the order of their timestamps. The aggregation cache uses a circular buffer structure with a size of 1024, capable of storing intermediate calculation result data from the most recent 1024 time points.
[0094] The process of calculating the clock offset between the local clock and the edge gateway's master clock also includes: edge node recording continuous... The sequence of timestamps received by the secondary synchronization reference message With the corresponding master clock timestamp sequence , The value is 8. Edge nodes calculate the local clock interval and master clock interval between adjacent received timestamps, and then calculate the local clock drift rate. Local clock drift rate The calculation formula is:
[0095]
[0096] Local clock drift rate represents the relative frequency deviation between the local clock and the master clock, and its value typically ranges from - arrive .
[0097] Edge nodes construct a clock compensation prediction model based on their local clock drift rate, and use this model to estimate the predicted drift value within the next synchronization interval. The clock compensation prediction model employs a linear prediction model to predict the drift value. The calculation formula is:
[0098]
[0099] in, Use the current local time. This is the master clock timestamp from the most recent synchronization reference message.
[0100] During the synchronization interval between two consecutive receptions of synchronization reference messages, the edge node dynamically adjusts the phase of its local timer based on the predicted drift value. The dynamic phase adjustment process is as follows: the edge node calculates the current predicted drift value every 10 milliseconds and adjusts the counting frequency of its local hardware timer accordingly. For example, if the predicted drift value is positive, indicating that the local clock is faster than the master clock, the edge node decreases the timer's counting frequency; if the predicted drift value is negative, indicating that the local clock is slower than the master clock, the edge node increases the timer's counting frequency. When generating intermediate calculation results, the edge node reads the dynamically phase-adjusted local timer value as the timestamp of the intermediate calculation result, eliminating the error caused by the continuous accumulation of local clock offset during the synchronization interval.
[0101] When an edge node fails to receive a synchronization reference message three consecutive times, it determines that the time synchronization connection with the edge gateway has been interrupted. At this point, the edge node continues to dynamically fine-tune the phase of its local timer using the most recently calculated clock drift rate and sends a synchronization recovery request message to the edge gateway. Upon receiving the synchronization recovery request message, the edge gateway immediately unicasts a synchronization reference message to the edge node, restoring the time synchronization connection.
[0102] refer to Figure 5The process by which the edge gateway reassembles the aggregated intermediate calculation results according to timing constraints to generate atomic proportioning instruction frames, and then sends these frames to the water-soluble fertilizer mixing actuator via a deterministic network interface, is as follows: First, the edge gateway verifies the integrity and temporal continuity of the intermediate calculation results in the aggregation cache. The integrity verification process is as follows: For each time point, the intermediate calculation result is checked to see if it simultaneously contains the output data of the environmental feature extraction subtask and the output data of the proportioning solution subtask. If both exist and the data length meets the preset requirements, the intermediate calculation result at that time point is considered complete; otherwise, it is considered incomplete. The temporal continuity verification process is as follows: The difference in time stamps between adjacent time points in the aggregation cache is checked to see if it equals the preset control period of 1 second. If the difference is between 0.9 seconds and 1.1 seconds, the temporal continuity is determined; otherwise, the temporal discontinuity is determined.
[0103] Intermediate calculation results that pass integrity and temporal continuity checks are deserialized. The intermediate calculation results are serialized using Protocol Buffers v3 format. After deserialization, the element ratios of the water-soluble fertilizer and their corresponding action timestamps are extracted. The element ratios of the water-soluble fertilizer include nitrogen, phosphorus, potassium, and micronutrient ratios, in kg / acre; the action timestamps are the execution times corresponding to these ratio values, in milliseconds.
[0104] The edge gateway encodes the ratio values of each element in the water-soluble fertilizer and the timestamp of its action according to the control protocol format of the water-soluble fertilizer mixing actuator, and encapsulates them into an atomic ratioing instruction frame with an atomic execution identifier. The atomic execution identifier is used to indicate that the water-soluble fertilizer mixing actuator must completely execute all ratioing operations in the instruction frame. If any failure occurs during execution, the actuator will stop all operations and revert to the initial state, and partial execution is not allowed.
[0105] In this embodiment, the atomicity ratio instruction frame format is defined as shown in Table 3.
[0106] Table 3. Definition of Atomic Proportioning Command Frame Format
[0107] Frame header 2 Unsigned short integer The fixed value is 0xAA55, used to identify the start of the instruction frame. Instruction type 1 Unsigned character type 0x01 indicates an atomicity ratio instruction, 0x02 indicates a stop instruction, and 0x03 indicates a status query instruction. Actuator Identifier 2 Unsigned short integer The unique logical number of the water-soluble fertilizer mixing actuator Activation timestamp 8 Unsigned long integer Execution time of proportioning instructions Nitrogen ratio 4 Single-precision floating-point type The nitrogen content is expressed in kg / mu (unit: kg / acre). Phosphorus ratio 4 Single-precision floating-point type The phosphorus content is expressed in kg / mu (unit: kg / acre). Potassium element ratio 4 Single-precision floating-point type The potassium content is expressed in kg / mu (unit: kg / acre). Trace element ratio 4 Single-precision floating-point type The ratio of trace elements, in kg / mu. Atomic execution identifier 1 Unsigned character type 0x01 indicates that execution must be atomic, and 0x00 indicates that non-atomic execution is allowed. Degradation execution flag 1 Unsigned character type 0x01 indicates a downgrade instruction generated based on the estimated proportion parameters, while 0x00 indicates an instruction generated based on normal calculation results. Checksum 2 Unsigned short integer The result of performing CRC16-CCITT check on all fields in the instruction frame except the frame header and checksum. Frame end 2 Unsigned short integer The fixed value is 0x55AA, used to mark the end of the instruction frame.
[0108] Table 3 defines the format of the atomic proportioning instruction frame in this embodiment, including the name, length, type, and description of each field. The total length of the instruction frame is 33 bytes, using a fixed-length format to facilitate rapid parsing and processing by the water-soluble fertilizer mixing actuator. The atomic execution identifier and the degraded execution identifier are used to indicate the execution requirements and data source of the instruction, respectively, ensuring the reliability of instruction execution and the traceability of the system.
[0109] The edge gateway invokes the time-sensitive scheduling queue of the deterministic network interface to send atomic proportioning instruction frames to the water-soluble fertilizer mixing actuator before the effective timestamp. The deterministic network interface adopts the IEEE 802.1AS time-sensitive networking standard, supporting time-aware shaping and strict priority scheduling. The time-sensitive scheduling queue has the highest transmission priority, a queue length of 64, and employs a first-in, first-out (FIFO) scheduling strategy. The edge gateway and the water-soluble fertilizer mixing actuator are connected via time-sensitive networking. The switches in the network are configured with time-aware shapers, allocating fixed transmission time windows for atomic proportioning instruction frames. Each time window is 1 millisecond in length and has a period of 1 second. Based on the effective timestamp and the maximum transmission delay of the instruction frame, the edge gateway calculates the latest transmission time of the instruction frame, ensuring that the instruction frame arrives at the water-soluble fertilizer mixing actuator at least 100 milliseconds before the effective timestamp, allowing sufficient preparation time for the actuator.
[0110] Upon receiving the atomic proportioning instruction frame, the water-soluble fertilizer mixing actuator first performs frame header and tail verification, followed by CRC16 verification. If the verification fails, the instruction frame is discarded and a verification failure notification is sent to the edge gateway; if the verification passes, the fields in the instruction frame are parsed. If the atomic execution flag is 0x01, the actuator locks all valves and pumps in the mixing device, sequentially opening the feed valves for nitrogen, phosphorus, potassium, and trace elements according to the proportions in the instruction frame. The feed rate of each element is precisely controlled by the flow meter. After all elements have been fed, the stirring device is started for uniform mixing. After mixing, the outlet valve is opened to deliver the water-soluble fertilizer to the corresponding irrigation zone. If valve failure, abnormal flow, or power interruption occurs during the mixing process, the actuator immediately closes all valves and pumps, sends a fault alarm to the edge gateway, and awaits further instructions.
[0111] refer to Figure 6 After verifying the integrity and temporal continuity of intermediate calculation results in the aggregation cache, when a missing intermediate calculation result corresponding to a specific timestamp is detected in the aggregation cache, the edge gateway extracts the historical matching parameter sequence adjacent to that specific timestamp from the historical matching database. The historical matching database is stored on the edge gateway's local solid-state drive, using the InfluxDB time-series database management system, and stores all matching parameters and their corresponding timestamps for the past 30 days, with a data sampling period of 1 second. The historical matching parameter sequence includes matching parameters for the 5 consecutive timestamps before the specific timestamp and matching parameters for the 3 consecutive timestamps after the specific timestamp, for a total of 8 historical data points.
[0112] The edge gateway calculates the gradient characteristics of the historical allocation parameter sequence. These gradient characteristics include first-order and second-order difference gradients. For the historical allocation parameter sequence... ,in For the missing specific timestamp The corresponding proportioning parameters, first-order difference gradient The calculation formula is:
[0113]
[0114] Second-order difference gradient The calculation formula is:
[0115]
[0116] The edge gateway performs differential extrapolation estimation based on the changing gradient characteristics and intermediate calculation results from adjacent received timestamps to generate estimated matching parameters to replace missing data. The differential extrapolation estimation uses a second-order linear extrapolation method to estimate the matching parameters. The calculation formula is:
[0117]
[0118] The edge gateway calculates a downgrade confidence level indicator for the estimated configuration parameters. The downgrade confidence level indicator ranges from 0 to 1, with higher values indicating higher confidence in the estimated configuration parameters. (Downgrade Confidence Level Indicator) The calculation formula is:
[0119]
[0120] in, The standard deviation of the historical matching parameter series. This represents the mean of the historical matching parameter series. The more stable the changes in the historical matching parameter series, the better. The smaller, The closer the value is to 1, the higher the confidence level of the predicted proportioning parameters; the more drastic the changes in the historical proportioning parameter series, the higher the confidence level. The larger, The closer to 0, the lower the confidence level of the estimated proportion parameters.
[0121] The edge gateway marks the estimated proportioning parameters as a downgrade confidence level identifier, and reassembles them together with the normally received intermediate calculation results to generate an atomic proportioning instruction frame with a downgrade execution identifier, which is then sent out. Upon receiving the instruction frame with the downgrade execution identifier, the water-soluble fertilizer mixing actuator performs the mixing operation according to the estimated proportioning parameters and sends a downgrade execution notification to the edge gateway. This notification includes the downgrade confidence level identifier and the execution time. The edge gateway stores the downgrade execution record in a historical proportioning database for subsequent system performance analysis and optimization.
[0122] This embodiment details the implementation process of the lightweight time synchronization protocol, the calculation of clock drift rate and dynamic phase fine-tuning mechanism, the encoding format of atomic proportioning command frames and the deterministic network delivery method, as well as the differential extrapolation estimation method when intermediate calculation results are missing. By introducing a lightweight time synchronization protocol and performing dynamic phase fine-tuning on the local timer, the interference of multi-node clock differences and accumulated errors during the synchronization interval on the aggregation results is eliminated. The atomic proportioning command frames are sent using the time-sensitive scheduling queue of the deterministic network interface, ensuring the timeliness and reliability of command transmission. When the missing intermediate calculation results are detected, differential extrapolation estimation is performed based on the gradient characteristics of the historical proportioning parameter sequence to generate the estimated proportioning parameters, maintaining the continuity of the fertilizer mixing actuator control process.
Claims
1. A method for real-time control of water-soluble fertilizer ratio based on edge computing, characterized in that, Includes the following steps: The edge gateway receives multi-source soil and weather sensor data; Based on the data type and the complexity of the ratio calculation of the sensor data, the ratio calculation logic is decomposed into an environmental feature extraction subtask and a ratio solving subtask. The environmental feature extraction subtask and the ratio calculation subtask are distributed to edge nodes with matching computing power in the edge cluster for parallel execution via a load-aware protocol. A lightweight time synchronization protocol is introduced, and after completing the corresponding sub-task, the edge node sends the intermediate calculation results back to the edge gateway for aggregation; The edge gateway reassembles the aggregated intermediate calculation results according to timing constraints to generate an atomic ratio instruction frame, and sends the atomic ratio instruction frame to the water-soluble fertilizer mixing actuator via a deterministic network interface.
2. The method for real-time control of water-soluble fertilizer ratio based on edge computing according to claim 1, characterized in that, Based on the data type and computational complexity of the sensor data, the computational logic is decomposed into an environmental feature extraction subtask and a computational solution subtask, including: parsing the computational logic, constructing a task directed acyclic graph representing computational dependencies, where nodes in the task directed acyclic graph represent computational operators and edges represent data flow directions; Identify the set of feature extraction operators and the set of matching solution operators in the directed acyclic graph of the task. Based on the heterogeneous hardware characteristics of each edge node in the edge cluster, the feature extraction operator set and the ratio solving operator set are divided. Operators with strong data dependencies and computationally intensive operations are clustered into the ratio solving subtask, and operators with high input / output bandwidth occupancy and low computational density are clustered into the environmental feature extraction subtask. Data exchange interface definitions between subtasks are generated.
3. The method for real-time control of water-soluble fertilizer ratio based on edge computing according to claim 1, characterized in that, The environmental feature extraction subtask and the ratio calculation subtask are distributed to edge nodes with matching computing power in the edge cluster for parallel execution through a load-aware protocol, including: the edge gateway periodically collects the CPU utilization rate, remaining memory capacity and network transceiver queue depth of each edge node in the edge cluster, and constructs a node resource status vector; Calculate the resource requirement vectors for the environmental feature extraction subtask and the ratio solution subtask, respectively; The Euclidean distance between the resource demand vector and the resource status vector of each node is calculated as the load matching degree. Edge nodes with a load matching degree greater than a preset threshold are selected as candidate nodes, and the environmental feature extraction subtask and the ratio calculation subtask are respectively distributed to the edge node with the highest load matching degree among the corresponding candidate nodes for execution.
4. The method for real-time control of water-soluble fertilizer ratio based on edge computing according to claim 2, characterized in that, A lightweight time synchronization protocol is introduced. After completing the corresponding subtask, the edge node sends the intermediate calculation results back to the edge gateway for aggregation. This includes: the edge gateway broadcasting a synchronization reference message to the edge cluster, the edge node recording the timestamp of the received synchronization reference message, and calculating the clock offset between the local clock and the master clock of the edge gateway. When the edge node generates the intermediate calculation result after completing the subtask, it compensates and corrects the time tag of the intermediate calculation result according to the clock offset. The edge node encapsulates the intermediate calculation results carrying the corrected time stamp into an aggregated message and sends the aggregated message to the edge gateway according to a preset backhaul period. The edge gateway performs time-series alignment and aggregation caching on the intermediate calculation results returned by different edge nodes based on the corrected timestamps.
5. The method for real-time control of water-soluble fertilizer ratio based on edge computing according to claim 4, characterized in that, The edge gateway reassembles the aggregated intermediate calculation results according to timing constraints to generate an atomic ratio instruction frame, and sends the atomic ratio instruction frame to the water-soluble fertilizer mixing actuator via a deterministic network interface, including: the edge gateway verifying the integrity and timing continuity of the intermediate calculation results in the aggregation cache; The intermediate calculation results that have passed the verification are deserialized to extract the element ratio values of the water-soluble fertilizer and the corresponding action timestamps. The ratio values of each element in the water-soluble fertilizer and the timestamp of action are encoded according to the control protocol format of the water-soluble fertilizer mixing actuator and encapsulated into an atomic ratio instruction frame with an atomic execution identifier; The time-sensitive scheduling queue of the deterministic network interface is invoked to send the atomic proportioning instruction frame to the water-soluble fertilizer mixing actuator before the action timestamp.
6. The method for real-time control of water-soluble fertilizer ratio based on edge computing according to claim 1, characterized in that, The edge gateway receives multi-source soil and meteorological sensor data, including: the edge gateway receives raw sensor messages from heterogeneous sensor networks through a multi-protocol parsing interface; Extract the sensor identifier, acquisition time, and measurement value from the original sensing message; Based on the sensor identifier, query the pre-configured spatial topology mapping table to obtain the spatial location weight of the sensor; Measurements collected at the same time are weighted and fused according to the spatial location weights, and abnormal jump values that deviate from the normal distribution are removed using a sliding window filtering mechanism. The filtered and fused measurement values are combined with the corresponding sensor identifiers to form structured sensing data, which is then output as the multi-source soil and meteorological sensing data.
7. The method for real-time control of water-soluble fertilizer ratio based on edge computing according to claim 2, characterized in that, After dividing the set of feature extraction operators and the set of ratio solving operators, the method further includes: for cases where there is cross-node data exchange between the divided environmental feature extraction subtask and the ratio solving subtask, a shared memory mapping area is established between the edge nodes executing the environmental feature extraction subtask and the edge nodes executing the ratio solving subtask. Configure the read-write mutex lock for the shared memory mapping area; When the environmental feature extraction subtask generates feature tensor data, the write permission of the read-write mutex is acquired, the feature tensor data is written to the shared memory mapping area, and the write permission is released. After the edge node executing the ratio calculation subtask detects that the write permission has been released, it obtains read permission to read the feature tensor data and continues to perform the ratio calculation.
8. The method for real-time control of water-soluble fertilizer ratio based on edge computing according to claim 3, characterized in that, After distributing the environmental feature extraction subtask and the ratio calculation subtask to the edge node with the highest load matching degree among the corresponding candidate nodes for execution, the method further includes: real-time monitoring of the chip junction temperature and power consumption fluctuation rate of the edge node to which the subtask has been assigned. When the chip junction temperature or the power consumption fluctuation rate exceeds the corresponding safety threshold, the task migration mechanism is triggered. Recalculate the migration matching degree of the environmental feature extraction subtask or the ratio solving subtask to other idle edge nodes in the edge cluster; The execution context state data of the subtasks being executed on the edge nodes that exceed the safety threshold is serialized, and the execution context state data is migrated to the idle edge node with the highest migration matching degree through the direct transmission channel between edge nodes to resume execution.
9. The method for real-time control of water-soluble fertilizer ratio based on edge computing according to claim 4, characterized in that, Calculating the clock offset between the local clock and the master clock of the edge gateway also includes: the edge node recording the received timestamp sequence of multiple consecutive synchronization reference messages, and calculating the local clock drift rate between adjacent received timestamps; A clock compensation prediction model is constructed based on the local clock drift rate, and the predicted drift value in the next synchronization interval is estimated using the clock compensation prediction model. During the synchronization interval between two consecutive receptions of synchronization reference messages, the edge node dynamically adjusts the phase of its local timer based on the predicted drift value. When the intermediate calculation result is generated, the value of the local timer after dynamic phase fine-tuning is read as the time tag of the intermediate calculation result to eliminate the error caused by the continuous accumulation of local clock offset during the synchronization interval.
10. The method for real-time control of water-soluble fertilizer ratio based on edge computing according to claim 5, characterized in that, After verifying the integrity and temporal continuity of intermediate calculation results in the aggregate cache, the method further includes: when it is detected that the intermediate calculation result corresponding to a specific timestamp is missing in the aggregate cache, extracting the historical matching parameter sequence adjacent to the specific timestamp from the historical matching database; Calculate the gradient characteristics of the historical ratio parameter sequence; Based on the change gradient characteristics and the intermediate calculation results of the received adjacent timestamps, differential extrapolation estimation is performed to generate the estimated matching parameters for replacing the missing data; The estimated ratio parameters are marked as downgraded confidence indicators, and together with the normally received intermediate calculation results, they participate in the recombination to generate an atomic ratio instruction frame with a downgraded execution indicator and send it out, so as to maintain the continuity of the control process of the water-soluble fertilizer mixing actuator.