Method for laser wind finding radar to control radar through user-defined instruction
Through multi-threaded interaction and lock-free ring queue decoupling communication and business logic, the problem of instant command control when laser wind measurement radar is abnormal is solved, and fast and safe radar internal state changes and information acquisition are achieved, improving operation and maintenance and development efficiency.
Patent Information
- Application Number
- CN202510481058.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-04-17
- Publication Date
- 2025-07-11
AI Technical Summary
When the existing laser wind measurement radar is abnormal in its operating state, it is difficult to achieve immediate and visual internal information interaction and command control, and the existing instructions are complex and difficult to understand, resulting in inconvenient operation, maintenance, development and maintenance.
Multi-threaded interaction means are used to receive instructions through Socket, Http and MQTT, and decouple communication and business logic through lock-free ring queues and instruction proxy forwarding threads (proxy threads) to achieve orderly execution of instructions.
It realizes that special instructions are issued quickly without interrupting the operation of the radar, changes the internal state of the radar, improves operation and maintenance efficiency and development maintenance, and enhances the privacy and security of operations.
Smart Images

Figure CN120295671A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of lidar wind measurement, and particularly relates to a command control method for a lidar wind measurement radar. Background Art
[0002] A pulsed lidar wind measurement radar is a device that uses laser technology to measure wind speed and direction. Its core principle is based on the Doppler effect. When a laser light source emits light waves towards a moving target (such as aerosol particles in the atmosphere), the frequency of the returned light waves will change due to the movement of the target. By measuring this frequency change, the magnitude and direction of the wind speed can be accurately calculated, and it has the characteristics of high temporal and spatial resolution. Therefore, lidar wind measurement radars are widely used in weather forecast research and wind energy assessment.
[0003] The operating status of lidar wind measurement radars is mostly stored and viewed in the form of system logs and application program logs. The data and logs of the wind measurement radar are generally stored in storage media such as hard disks or EMMCs, and the storage priority of wind speed data is the highest, resulting in that system logs and application program logs can only store important information and cannot save all operating information. When the radar operating status is abnormal and it is necessary to check the specific working status of a certain module, or the real-time data of a certain interface or certain variables in the program during operation, usually it is necessary to enter the IDE to enable the debug mode or rewrite the code and rewrite the radar program again to achieve the purpose. However, due to the high sampling rate, lidar wind measurement radars can usually only be developed in C language on the hardware platform of a single-chip microcomputer, and it is usually very difficult to debug online. Moreover, these methods usually require interrupting the radar operation and restarting to take effect, so that the operating status of the radar has changed and it is very difficult to troubleshoot problems.
[0004] On-site wind power operation and maintenance personnel often trigger the internal execution of specified actions of the radar through some operations during operation and maintenance to confirm the radar operating status or troubleshoot. The conventional method is to trigger through client page interaction. There are many internal hidden function switches that are not convenient to directly display on the interface and usually need to be triggered through DIP switches or special instructions. DIP switches have problems such as accidental touch and affecting airtightness. The special instructions on the market are usually more complex and difficult to understand, and they are usually not a complete module at the software level and are seriously coupled with the business level, which is not conducive to development and maintenance.
[0005] In summary, there is an urgent need for a visual means that can interact with the inside of the radar immediately to obtain specified information inside the radar in real time, as well as a set of radar internal instructions that are convenient for developers and operation and maintenance personnel to maintain and execute. Summary of the Invention
[0006] The present invention provides a command control method for a lidar wind measurement radar to solve the problems existing in the above-mentioned prior art. The method is characterized by comprising the following steps: S1. An internal thread of the lidar wind measurement radar receives an external control command; S2. After each thread receives the control command, it performs format verification and disassembling on the control command; S3. Each thread encapsulates the control command that has passed the verification into a structure; S4. The lidar wind measurement radar polls the queue formed by each structure through an instruction proxy forwarding thread, and sequentially executes the commands of the control commands in each structure.
[0007] Further, the threads for the lidar wind measurement radar to receive external control commands include a Socket thread, an mqtt thread, and an http thread.
[0008] Further, the method for performing format verification on the control command is as follows: The control command is disassembled into a main command and sub-commands by searching for space characters in the control command, and the main command and each sub-command are sequentially subjected to validity verification. Those that pass the verification enter the subsequent instruction execution process, and those that do not pass the verification return an instruction error message according to the current communication link, informing the operator that the instruction format is incorrect.
[0009] Further, the method for performing validity verification on the main command and each sub-command is as follows: Judge whether the value ranges of the main command and each sub-command fall within a preset range. If so, the instruction is valid; otherwise, the instruction is invalid.
[0010] Further, the structure includes an instruction source, an instruction type, an instruction timestamp, and an instruction content.
[0011] Further, the queue formed by the structures is a lock-free circular queue.
[0012] Further, the instruction proxy forwarding thread is a proxy thread.
[0013] The present invention has the following beneficial effects: The present invention provides a command control method for a lidar wind measurement radar. Through various interaction means, special commands are quickly issued to change the internal operation state of the radar, and the radar is allowed to execute internal commands or record the operation state of a specified module on the premise of not powering off and keeping the radar running; The present invention uses multi-thread means to decouple each communication thread and the thread that finally executes the instruction at the program and business levels, ensuring the orderly execution of the instruction. Description of the Drawings
[0014] Figure 1It is the flow chart of the internal interaction thread of the program; Figure 2 It is the flow chart of instruction execution. Specific implementation mode
[0015] The following combines the appendix Figure 1-2 To further illustrate the present invention. Embodiment 1:
[0016] This embodiment provides a set of instruction systems for controlling a radar, which is used for real-time control of a lidar through instructions. The system is integrated in the internal application program of the radar, belongs to the same process as the radar application program, and runs independently as a thread.
[0017] In this embodiment, the lidar receives instructions through Tcp, Http or MQTT. Different threads receive instructions independently and can receive them simultaneously. The process of each thread receiving instructions is as follows: Tcp, the Socket thread is responsible for tcp message interaction. The radar acts as a tcp server and listens on a specified port number (flexible configuration is supported). This port number is only responsible for instruction interaction. When this thread is initialized, the official socket interface provided by C language is used to create a tcpsocket on the operating system where the radar runs. After successful creation, the official setopt interface for setting socket parameters is used to modify the parameters of the current socket (such as port reuse, tcp keep-alive function enabled, tcp keep-alive time, etc.) to ensure normal operation in scenarios such as abnormal disconnection of tcp connections, disconnection of network cables, and manual disconnection and reconnection. After the parameter setting is successful, the port number is listened on. All events occurring on this port number, such as client connection, client disconnection, received instruction content, and tcp error, are informed to this thread in the form of events. After receiving the events, the thread normally processes the behaviors of client connection, disconnection, and sending instructions.
[0018] Http, the http thread is used as the thread to interact with the near-end web client. The radar is the http server and interacts with the web client using the http protocol. The interactive content is a private communication protocol. Different access interfaces are distinguished by uri. For example, uri ending with "funcParaSet" represents the function parameters to be sent, and ending with "diyCmdSet" represents the command to be sent. The http payload is a string in the negotiated json format, and the content is the content of the sent command or the parameters to be sent. The callback functions corresponding to different uri interfaces are registered inside the radar. The user can send the specified command to the radar through the negotiated uri interface in the browser. After receiving the data, the radar matches the uri through the string matching algorithm and then calls the corresponding interface. Then, the content of the sent command is obtained by parsing the json content in the payload, and then the sent command is processed normally.
[0019] MQTT, radar uses mqtt protocol to communicate with cloud platform, which can realize remote cluster operation and maintenance. mqtt thread is the thread for interacting with cloud platform. Radar uses the parameters configured in production stage to create client. After successfully connecting with broker, it listens for commands sent by other clients forwarded by broker. The content of mqtt protocol for interaction between cloud platform and radar is the manufacturer's private communication protocol. The protocol stipulates that mqtt topic is "command", and the key in the json string content of the load is "diyCmd" which represents the issued command. Radar identifies the topic through string matching algorithms such as KMP and parses the json format string. If it is identified that the interactive content contains issued instructions, it will process the issued instructions normally.
[0020] After receiving the command message, the above thread checks whether it conforms to the command format according to the specified content format. The command format is main command (space) subcommand (space) command content 1 (space) command content 2... command content n. The commands are pure numbers without spaces or other special characters. For example, main command 1 is to switch the command mode, command 2 is to obtain the version number, command 3 is to read and write the log level, command 4 is to set the log switch of each module, and command 5 is to set parameters to the laser. Each type of command specifies subcommands and command content.
[0021] After each of the above receiving threads receives the message string, it calls a unified message verification interface. The verification method is to violently match the entire string to search for all space characters, and then separate the message string according to the searched space characters. The separated string list is regarded as the command content list. If no space is found, it is regarded as a matching failure. Then, it is identified whether the main command and subsequent sub-commands disassembled conform to the expectation. The method of determining whether it conforms to the expectation is the exhaustive method. According to the instruction template, the value range of the first-level main command is 0-10. If it is not within this range, it is regarded as not conforming to the expectation. Then, the second-level sub-command is verified according to the first-level main command. For example, if the main command is 4, it represents setting the internal log switch of the module. According to the instruction template, the value range of the second-level sub-command is 1-15. If it is not within this range, it is regarded as not conforming to the expectation. Each level of command is verified in turn to see if it conforms to the command template.
[0022] After the instruction verification is completed, the traditional way for the radar to execute the instruction is to directly execute the command at the thread that receives the message. However, there are several disadvantages to doing this: 1. There is a strong coupling between the message receiving module and several modules that execute the business, which is not conducive to the later expansion and maintenance of software functions. 2. It brings an uncontrollable state where two threads execute the same instruction simultaneously. 3. If the command execution takes a certain amount of time and it is a blocking interface, then it will cause the communication thread that receives the command to be blocked or even disconnected.
[0023] Therefore, in this embodiment, an independent instruction proxy forwarding thread, that is, the proxy thread in this embodiment, is used to poll and execute all commands, ensuring that all instructions are received and executed through this thread, and ensuring that each communication thread and each business thread are completely decoupled. The proxy thread and each business thread inside the wind measurement radar interact through a data structure of a lock-free circular queue.
[0024] The lock-free circular queue provided in this embodiment is a multi-producer multi-consumer data structure. The nodes of the queue are as follows: It is divided into four parts: the source of the instruction edatasrc + the type of the instruction (main command) ecmdtype + the timestamp ultimestamp of the instruction execution + the encapsulated instruction content (sub-command and specific command content, value) pcmdinfo.
[0025] After communication threads such as http, tcp, and mqtt receive the command, they encapsulate the command content into the structure corresponding to the node of the lock-free circular queue. The proxy thread periodically polls whether there are new nodes in the lock-free circular queue. If there are, it takes out the nodes and executes them according to the instruction type and instruction content.
[0026] After the proxy thread retrieves the instruction structure from the queue, it obtains the main command and sub-command contents according to the instruction structure content, calls the corresponding interface, executes the content of the instruction, and returns the result to the proxy thread after execution. The proxy thread retrieves the next instruction structure from the instruction structure queue. If the instruction structure queue is empty, it waits until a new instruction structure is added to the queue and then retrieves it. Embodiment 2:
[0027] As a supplement to the above embodiment, this embodiment provides a radar control process for the mqtt thread to receive control instructions.
[0028] The mqtt thread receives a command to change the log output of the wind measurement calculation module / thread (providing a string example "4 1 1"). After parsing this command inside the thread, the command of "changing the log output enable of the wind measurement calculation module" is encapsulated into a node and written into the lock-free circular queue shared with the proxy thread. The proxy thread periodically polls that there is a new node in the queue, retrieves it, and recognizes through the service type that it is the command of "changing the log output enable of the wind measurement calculation module". The proxy thread calls the interface of the variable for changing the log output level inside the wind measurement calculation module / thread. This interface rewrites the local variable value log_enable inside the wind measurement calculation module / thread. Key nodes of the module will use if statements to judge the value of log_enable to determine whether to output the corresponding key information to the log file, so as to realize that when a fault occurs in the wind measurement service and troubleshooting is required, the fault can be located through detailed full-scale information, and when the wind measurement is normal, there is no relevant log output to affect the readability of the log. In the embodiment, except for the normal loss of writing and reading lock-free circular queue nodes, neither the mqtt thread nor the wind measurement calculation thread will be blocked. Issuing commands will not cause any impact on the normal operation of the radar. The final executor is handed over to the proxy thread, and the mqtt thread and the wind measurement calculation thread are decoupled. Embodiment 3:
[0029] As a supplement to the above embodiment, this embodiment provides a radar control process in which the http thread and the mqtt thread receive control instructions simultaneously.
[0030] The http thread and the mqtt thread both received a command to change the laser parameters. Inside the radar, communication with the laser is carried out through a half-duplex 485 bus. If the command to change the laser parameters is directly executed inside the thread receiving the instruction, two problems will occur: a. The http thread and the mqtt thread send messages to the laser through the 485 bus. Since there is no order of precedence, the timing of interaction with the laser through the 485 bus is affected. b. Due to the half-duplex characteristic of the 485 transceiver interface, it is a blocking interface and both need to wait. If the transmitted data is long, it may cause the http thread and the mqtt thread to block, affecting normal communication.
[0031] In this embodiment, the http thread and the mqtt thread both encapsulate two commands and write them into a lock-free circular queue. When the proxy thread retrieves a node from the lock-free circular queue, it will only retrieve one node and will only retrieve the next node and execute the task after the previous task is completed. In this way, it is ensured that there will be no simultaneous 485 communication with the laser. Moreover, when a certain thread uses the 485 transceiver, a mutex lock is used to ensure that only one thread can use the 485 bus at the same time. At the same time, it can also ensure that the http thread and the mqtt thread for communication will not block, and the http thread, the mqtt thread and the laser communication thread are also decoupled.
[0032] The present invention interacts quickly with the inside of the wind measurement lidar through a set of instruction systems, realizes the rapid issuance of various instructions for the radar to execute, quickly realizes the change of the internal module actions or operating states of the radar, and can also quickly obtain the detailed states of the internal modules of the radar. For maintenance personnel, detailed information inside the radar can be obtained through various channels, enriching the troubleshooting means and improving the troubleshooting efficiency. For developers, the robustness of the program and the expandability of subsequent interaction instructions are improved. For operations that are not convenient to interact directly through the interface buttons, the privacy and security of the operations are enhanced by using instructions.
[0033] The above text generally describes the present invention in detail. However, based on the present invention, some modifications or improvements can be made, which are obvious to those of ordinary skill in the technical field. Therefore, modifications or improvements made without departing from the spirit of the present invention are within the protection scope of the present invention.
Claims
1. A method for controlling commands of a laser Doppler wind lidar, characterized in that, It includes the following steps: S1. The internal thread of the lidar wind profiler receives an external control instruction; S2. After each thread receives the control instruction, it disassembles the control instruction and performs format verification; S3. Each thread encapsulates the control instruction that has passed the verification into a structure; S4. The lidar wind profiler polls the queue formed by each structure through the instruction proxy forwarding thread and sequentially executes the commands of the control instructions in each structure.
2. The method for controlling instructions of a lidar wind profiler according to claim 1, wherein: The threads for the lidar wind profiler to receive external control instructions include a Socket thread, an mqtt thread, and an http thread.
3. A method for controlling commands of a laser Doppler wind lidar according to claim 1, characterized in that, The method for disassembling and performing format verification on the control instruction is: The control instruction is disassembled into a main command and sub-commands by searching for space characters in the control instruction, and the main command and each sub-command are sequentially subjected to validity verification. Those that pass the verification enter the subsequent instruction execution process, and those that do not pass the verification return an instruction error message according to the current communication link, informing the operator that the instruction format is incorrect.
4. A method for controlling a laser Doppler wind lidar instruction according to claim 3, characterized in that, The method for performing validity verification on the main command and each sub-command is: Judge whether the value ranges of the main command and each sub-command fall within a preset range. If so, the instruction is valid; otherwise, the instruction is invalid.
5. The method for controlling instructions of a lidar wind profiler according to claim 1, wherein: The structure includes the instruction source, instruction type, instruction timestamp, and instruction content.
6. A method for controlling instructions of a laser Doppler wind lidar according to claim 5, characterized in that: The queue formed by the structures is a lock-free circular queue.
7. A method for controlling commands of a lidar wind radar according to claim 1, characterized in that: The instruction proxy forwarding line is a proxy thread.