Communication method and device based on polling mechanism and relay protection device
By adopting a communication method based on polling mechanism in the RS-485 bus communication system, the master node sends L requests in each round and adjusts the response time through double judgment, which solves the bus conflict problem when multiple nodes send data at the same time. Improved communication efficiency and reliability.
Patent Information
- Application Number
- CN202310912880.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-24
- Publication Date
- 2025-01-24
AI Technical Summary
In the RS-485 bus communication system, multiple nodes may easily cause bus conflicts when sending data at the same time, affecting communication efficiency and reliability.
Using a communication method based on the polling mechanism, the master node sends L requests in each round. Each request corresponds to a request time interval and a response time period. Through double judgment, it is determined whether there may be a conflict in the current communication network, thereby adjusting the response time.
Through the preset request time interval and response time period, reduce the probability of communication conflicts and improve communication efficiency and reliability.
Smart Images

Figure CN119363503A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the field of electric power automation systems, and in particular to a communication method and device based on a polling mechanism, and a relay protection device. Background Art
[0002] The RS-485 bus standard has been around for nearly 40 years and has a wide range of applications. For example, it is used in scenarios where the transmission speed requirements are not high and the changes are relatively slow, such as ambient temperature. Therefore, many small low-cost power distribution devices support RS485 communication.
[0003] The RS-485 bus standard supports a half-duplex communication mode with one master and multiple slaves. Usually, in the RS-485 communication bus, the master node polls the slave nodes on the bus one by one, and the slave nodes respond to the master node according to the polling mechanism to complete the communication.
[0004] However, in many actual application scenarios, multiple nodes may send data to the bus at the same time, causing bus conflicts. Summary of the invention
[0005] In view of this, the present invention proposes a communication method based on a polling mechanism, the communication method based on the polling mechanism, the communication method is used in an electric power automation system, the electric power automation system includes a master node and several slave nodes, the master node and each of the slave nodes communicate based on the polling mechanism, the master node needs to send L requests in each round, where L is a positive integer, and the communication method includes:
[0006] If the i-th request of this round sent by the master node is received, a target response for the i-th request is generated, where i is a positive integer and i≤L;
[0007] Each request corresponds to a request time interval and a response time period, the request time interval represents the minimum time interval between the master node sending the i-th request of this round and sending the i-th request of the previous round, and the response time period represents the maximum time period from the master node sending the i-th request to receiving the response sent by the slave node, and the communication method further includes:
[0008] Determine whether a first time interval is greater than a first preset interval, and determine whether a new request sent by the master node is currently received, wherein the first time interval is determined according to a receiving time of the i-th request and a current first actual time, and the first preset interval is determined according to a response time period corresponding to the i-th request;
[0009] If the above judgment results are all negative, the target response is sent to the master node.
[0010] According to the communication method as described above, optionally, after determining that a new request sent by the master node is not received and before sending the target response to the master node, it also includes:
[0011] Get the current second real time;
[0012] determining a second time interval according to the receiving time and the second actual time;
[0013] Determine whether the second time interval is greater than a second preset interval, where the second preset interval=the response time period corresponding to the i-th request-k / baudrate, where k is a preset calibration coefficient and baudrate is a baud rate;
[0014] If the judgment result is no, an operation of sending the target response to the master node is triggered.
[0015] According to the communication method as described above, optionally, if the result of determining whether the second actual time interval is greater than a second preset interval is yes, the target response is discarded.
[0016] According to the communication method as described above, optionally, after determining whether the first time interval is greater than a first preset interval and the determination result is no, an operation of determining whether a new request sent by the master node is currently received is performed.
[0017] According to the communication method as described above, optionally, if any one of determining whether a first time interval is greater than a first preset interval and determining whether a new request sent by the master node is currently received is yes, the target response is discarded.
[0018] According to the communication method as described above, optionally, when receiving the i-th request sent by the master node, it further includes: attaching a special identifier to the i-th request;
[0019] When starting to generate a target response for the i-th request, the method further includes: clearing the special flag;
[0020] Determining whether a new request sent by the master node is currently received includes: determining whether there is a request with a special identifier currently, and if the determination result is no, determining that a new request sent by the master node is currently not received.
[0021] According to the communication method as described above, optionally, the first time interval is determined to be equal to a response time period corresponding to the i-th request; or
[0022] The first time interval=the response time period corresponding to the ith request-k / baudrate, wherein k is a preset calibration coefficient and baudrate is the baud rate.
[0023] The present invention further provides a communication method based on a polling mechanism, which is used in an electric power automation system. The electric power automation system includes a master node and a plurality of slave nodes. The master node and the slave nodes communicate based on a polling mechanism. The master node needs to send L requests in each round, where L is a positive integer.
[0024] Each request corresponds to a request time interval and a response time period, wherein the request time interval represents the minimum time interval between sending the i-th request in this round and sending the i-th request in the previous round, and the response time period represents the maximum time interval from the master node sending the request to receiving the response sent by the slave node, and the communication method includes:
[0025] If it is identified that an i-th request needs to be sent to a slave node, and the i-th request is one of the L requests in this round, then it is determined whether a third time interval between the i-th request and the i-th request sent in the previous round is greater than or equal to the request time interval corresponding to the i-th request, where i is a positive integer and i≤L;
[0026] If the judgment result is yes, the i-th request is sent to the slave node.
[0027] According to the communication method as described above, optionally, after sending the i-th request to the slave node, the method further includes:
[0028] Determine whether a target response sent by the slave node is received within a response time period corresponding to the i-th request, the target response being generated based on the i-th request;
[0029] If the judgment result is no, it is determined that the i-th request is an abnormal request.
[0030] According to the communication method as described above, optionally, after determining that the i-th request is an abnormal request, the method further includes:
[0031] Determine whether i is less than or equal to L;
[0032] If the judgment result is yes, the value of i+1 is updated to i, and the operation of identifying whether an i-th request needs to be sent to a slave node is returned.
[0033] The present invention also provides a communication device based on a polling mechanism, the communication device is used in an electric power automation system, the electric power automation system includes a master node and a plurality of slave nodes, the master node and each of the slave nodes communicate based on a polling mechanism, the master node needs to send L requests in each round, where L is a positive integer, and the communication device includes:
[0034] a generating unit, configured to generate a target response for the i-th request in this round if the i-th request sent by the master node is received, wherein i is a positive integer and i≤L;
[0035] Each request corresponds to a request time interval and a response time period, the request time interval represents the minimum time interval between the master node sending the i-th request in this round and sending the i-th request in the previous round, and the response time period represents the maximum time period from the master node sending the i-th request to receiving the response sent by the slave node, the communication device also includes:
[0036] a first determination unit, configured to determine whether a first time interval is greater than a first preset interval, and to determine whether a new request sent by the master node is currently received, wherein the first time interval is determined according to a receiving time of the i-th request and a current first actual time, and the first preset interval is determined according to a response time period corresponding to the i-th request;
[0037] A first sending unit is used to send the target response to the master node.
[0038] According to the communication device as described above, optionally, it further includes:
[0039] An acquisition unit, used for acquiring a current second actual time;
[0040] a determining unit, configured to determine a second time interval according to the receiving time and the second actual time;
[0041] A second judgment unit is used to judge whether the second time interval is greater than a second preset interval, where the second preset interval = the response time period corresponding to the i-th request - k / baudrate, where k is a preset calibration coefficient and baudrate is a baud rate. If the judgment result is no, the first sending unit is triggered.
[0042] According to the communication device as described above, optionally, the second judging unit is further configured to: trigger a discarding unit if the judging result of judging whether the second actual time interval is greater than a second preset time interval is yes;
[0043] The communication device further includes the discarding unit, which is configured to discard the target response.
[0044] According to the communication device as described above, optionally, it further includes:
[0045] a marking unit, configured to attach a special identifier to the i-th request when receiving the i-th request sent by the master node;
[0046] A clearing unit is used to clear the special identifier when starting to generate a target response for the i-th request.
[0047] According to the communication device as described above, optionally, the first time interval is determined to be equal to a response time period corresponding to the i-th request; or
[0048] The first time interval=the response time period corresponding to the ith request-k / baudrate, wherein k is a preset calibration coefficient and baudrate is the baud rate.
[0049] The present invention further provides a communication device based on a polling mechanism, the communication device is used in an electric power automation system, the electric power automation system includes a master node and a plurality of slave nodes, the master node and each of the slave nodes communicate based on a polling mechanism, the master node needs to send L requests in each round, where L is a positive integer,
[0050] Each request corresponds to a request time interval and a response time period, wherein the request time interval represents the minimum time interval between sending the i-th request of this round and sending the i-th request of the previous round, and the response time period represents the maximum time period from when the master node sends the request to when it receives the response sent by the slave node, and the communication device includes:
[0051] an identification unit, used to identify whether an i-th request needs to be sent to a slave node, where the i-th request is one of the L requests in this round, and if the identification result is yes, a third judgment unit is triggered, where i is a positive integer and i≤L;
[0052] The third judging unit is used to judge whether a third time interval between the i-th request and the i-th request sent in the previous round is greater than or equal to the request time interval corresponding to the i-th request, and if the judgment result is yes, trigger a second sending unit;
[0053] The second sending unit is used to send the i-th request to the slave node.
[0054] According to the communication device as described above, optionally, it further includes:
[0055] A fourth judgment unit is used to judge whether a target response sent by the slave node is received within a response time period corresponding to the i-th request, the target response is generated based on the i-th request, and if the judgment result is no, it is determined that the i-th request is an abnormal request.
[0056] According to the communication device as described above, optionally, it further includes:
[0057] a fifth judgment unit, used for judging whether i is less than or equal to L, and if the judgment result is yes, triggering an updating unit;
[0058] The updating unit is used to update the value of i+1 to i, thereby triggering the identifying unit.
[0059] The present invention also provides a relay protection device, comprising:
[0060] at least one memory for storing instructions;
[0061] At least one processor is configured to execute any of the aforementioned communication methods based on the polling mechanism according to the instructions stored in the memory.
[0062] According to the present invention, a corresponding request time interval and response time period are preset for each request, and then a double judgment is made to determine whether a communication conflict may exist on the current communication network, thereby reducing the probability of communication conflicts. BRIEF DESCRIPTION OF THE DRAWINGS
[0063] The preferred embodiments of the present invention will be described in detail below with reference to the accompanying drawings so that the above and other features and advantages of the present invention will be more apparent to those skilled in the art. In the accompanying drawings:
[0064] Figure 1 The figure is a flow chart of a communication method based on a polling mechanism according to an embodiment of the present invention.
[0065] Figure 2 The figure is a flow chart of a communication method based on a polling mechanism according to another embodiment of the present invention.
[0066] Figure 3A The figure is a flow chart of a communication method based on a polling mechanism according to another embodiment of the present invention.
[0067] Figure 3B The figure is a flow chart of a communication method based on a polling mechanism according to another embodiment of the present invention.
[0068] Figure 4 FIG. 4 is a schematic diagram of the structure of a communication device based on a polling mechanism according to an embodiment of the present invention.
[0069] Figure 5FIG. 4 is a schematic diagram of the structure of a communication device based on a polling mechanism according to another embodiment of the present invention.
[0070] Fig. 6A FIG. 4 is a schematic diagram of the structure of a communication device based on a polling mechanism according to yet another embodiment of the present invention.
[0071] Figure 6B FIG. 4 is a schematic diagram of the structure of a communication device based on a polling mechanism according to another embodiment of the present invention. DETAILED DESCRIPTION
[0072] In order to make the purpose, technical solution and advantages of the present invention more clear, the present invention is further described in detail with reference to the following embodiments. Nouns and pronouns related to people in this patent application are not limited to specific genders.
[0073] The communication method based on the polling mechanism of the present invention is applicable to an electric power automation system, which includes a master node and multiple slave nodes, and the master node and the slave nodes communicate based on the polling mechanism. Specifically, the communication between the master node and each slave node adopts the RS-485 bus standard. The polling mechanism indicates that the master node needs to send a request to each slave node in turn, and each slave node returns a response to the request in turn. For a request in a round, there are usually multiple requests. For example, in the present invention, there are L requests in each round, where L is a positive integer. The master node sends a request to the slave node, and the slave node generates a corresponding response after receiving the request and sends it to the master node.
[0074] Each node in the present invention can be a small device that can communicate with each other, such as a relay protection device in a switch cabinet, a temperature sensor, a pressure sensor, a humidity sensor, etc. Among them, the relay protection device can be a master node, and other slave nodes can be selected according to actual needs.
[0075] In order to avoid conflicts in communications between multiple nodes, the present invention pre-sets a request time interval and a response time period corresponding to each request sent by the master node.
[0076] The request time interval represents the minimum time interval between sending the i-th request in this round and sending the i-th request in the previous round. For example, the interval between the first request in this round and the first request in the previous round needs to be at least 10 seconds, the interval between the second request in this round and the second request in the previous round needs to be at least 12 seconds, and the interval between the third request in this round and the third request in the previous round needs to be at least 0.5 seconds. In order to avoid communication conflicts, each request needs to wait until the previous request and the corresponding response are transmitted before sending. In the actual communication process, if the time interval between the previous request and the previous request is greater than the preset request time interval response time period corresponding to the previous request, the request can also be sent.
[0077] The response time period indicates the maximum time period from when the master node sends a request to when the slave node receives the response sent by the slave node. For example, after the master node sends the first request, it should receive the response to the first request within 1 second. This 1 second is the response time period corresponding to the first request. After the master node sends the second request, it should receive the response to the second request within 0.5 seconds. This 0.5 second is the response time period corresponding to the second request. Each response time period can be pre-set according to actual conditions. It should be noted that the response time period refers to the maximum time from when the master node sends a request to when it receives a response.
[0078] Embodiment 1
[0079] This example provides a communication method based on a polling mechanism. The execution subject of the communication method is a communication device based on a polling mechanism. The communication device can be integrated into a slave node or be one of the slave nodes.
[0080] like Figure 1 FIG. 1 is a flow chart of a communication method based on a polling mechanism according to this embodiment. The communication method includes:
[0081] Step 101: If the i-th request of this round sent by the master node is received, a target response for the i-th request is generated, where i is a positive integer and i≤L.
[0082] The master node sends the i-th request of this round to the slave node. After receiving the i-th request, the slave node starts to process the i-th request and generates the corresponding target response.
[0083] Step 102, determine whether a first time interval is greater than a first preset interval, and determine whether a new request sent by the master node is currently received, the first time interval is determined based on a receiving time of a received i-th request and a current first actual time, and the first preset interval is determined based on a response time period corresponding to the i-th request.
[0084] Before step 102, the receiving time of the i-th request is obtained. For example, when the communication device receives the i-th request, it records the time as the receiving time corresponding to the i-th request. The first time interval here = the current first actual time - the receiving time, that is, the first actual time minus the receiving time.
[0085] The first preset interval here can be equal to the preset response time period corresponding to the ith request, or can be obtained by modifying the preset response time period corresponding to the ith request. The specific selection can be made according to actual needs and will not be repeated here.
[0086] Whether the communication device has received a new request sent by the master node can be known in a variety of ways. For example, when receiving a request sent by the master node, a special identifier is attached to the request. When the generation of the target response for the i-th request begins, the special identifier is cleared. In this way, the communication device can determine whether a new request sent by the master node is received by checking whether there is a request with a special identifier.
[0087] For step 102, after determining whether a first time interval is greater than a first preset interval, an operation of determining whether a new request sent by the master node is currently received may be performed, or after determining whether a new request sent by the master node is currently received, an operation of determining whether the first time interval is greater than the first preset interval may be performed. For example, if the result of determining whether the first time interval is greater than a first preset interval is yes, the target response may be discarded and not sent to the master node; if the result of determining whether a new request sent by the master node is no, an operation of determining whether a new request sent by the master node is currently received may be further performed; if the result of determining whether a new request sent by the master node is currently received is yes, the target response may be discarded and not sent to the master node; if the result of determining whether a new request sent by the master node is no, subsequent operations may be performed. Of course, the two determination operations may also be performed simultaneously, which will not be described in detail here.
[0088] Step 103: If the above judgment results are all negative, a target response is sent to the master node.
[0089] For example, if the first preset interval = the response time period corresponding to the i-th request, when the first time interval is greater than the first preset interval, it means that the target response cannot be sent to the master node in time, and if it is sent at this time, it is likely to cause a communication conflict on the communication line. Therefore, the target response can be discarded to avoid conflicts.
[0090] When it is determined that a new request is currently received from the master node, it means that the master node has sent a new request without receiving a target response for the i-th request. At this time, sending the target response again is likely to cause a communication conflict. Therefore, the target response can be discarded to avoid a conflict. For the new request, the operations of step 101 to step 103 can be performed.
[0091] According to the communication method based on the polling mechanism of the present invention, a corresponding request time interval and response time period are preset for each request, and then a double judgment is made to determine whether there may be a communication conflict on the current communication network, which can reduce the probability of communication conflicts.
[0092] Embodiment 2
[0093] This embodiment further supplements the communication method based on the polling mechanism of the first embodiment.
[0094] In the communication method, after determining that a new request sent by the master node is not received and before sending a target response to the master node, the method further includes:
[0095] Get the current real time of the second;
[0096] determining a second time interval based on the receiving time and the second actual time;
[0097] Determine whether the second time interval is greater than or equal to a second preset interval, where the second preset interval=preset response time interval corresponding to the i-th request-k / baudrate, where k is a preset calibration coefficient and baudrate is a baud rate;
[0098] If the judgment result is no, the operation of sending the target response to the master node is triggered.
[0099] The second preset interval in this embodiment is obtained based on the correction of the response time period corresponding to the i-th request. In this embodiment, k is a preset calibration coefficient, and its value range is 30-50, and the baud rate is the same communication rate agreed upon by both parties of the serial communication.
[0100] In this embodiment, the second time interval=the current second actual time-the receiving time.
[0101] The present embodiment is described below using different scenarios:
[0102] Scenario 1:
[0103] A0, if the i-th request of this round sent by the master node is received, a target response for the i-th request is generated;
[0104] A1, determine whether the first time interval is greater than a first preset interval, the first preset interval is equal to the response time period corresponding to the i-th request, if the determination result is no, then turn to A2;
[0105] A2, determine whether a new request sent by the master node is currently received. If the result is no, go to A3;
[0106] A3, obtaining a current second actual time, determining a second time interval according to the receiving time and the second actual time, and determining whether the second time interval is greater than a second preset interval, where the second preset interval = a preset response time period corresponding to the i-th request - k / baudrate. If the determination result is no, proceed to A4;
[0107] A4, sends a target response to the master node.
[0108] In this scenario, A1 is first used to roughly determine whether the target response is sent within the preset response time period. If the result is no, A2 is then used to determine whether a new request is received. If the result is no, A3 is further used to accurately determine whether the target response is sent within the preset response time period. Since some time has passed since the determination of A1, it is more accurate to make another determination using the revised response time period. This triple determination can avoid communication conflicts.
[0109] Scenario 2:
[0110] B0, if the master node sends the i-th request in this round, a target response for the i-th request is generated;
[0111] B1, determine whether a new request sent by the master node is currently received. If the result of the determination is no, proceed to B2;
[0112] B2, determine whether the first time interval is greater than a first preset interval, the first preset interval is equal to the response time period corresponding to the i-th request, if the determination result is no, go to B3;
[0113] B3, obtaining a current second actual time, determining a second time interval according to the receiving time and the second actual time, and determining whether the second time interval is greater than a second preset interval. If the determination result is no, proceeding to B4;
[0114] B4, sends the target response to the master node.
[0115] In the second scenario, B1 is first used to determine whether a new request is received. If the determination result is no, B2 is used to roughly determine whether the time to send the target response exceeds the preset response time period. If the determination result is no, B3 is used to further accurately determine whether the time to send the target response has exceeded the preset response time period. Such triple determination can avoid communication conflicts.
[0116] Scenario 3:
[0117] C0, if the master node sends the i-th request in this round, it generates a target response for the i-th request;
[0118] C1, determine whether the first time interval is greater than a first preset interval, the first preset interval is equal to the response time period corresponding to the i-th request - k / baudrate, if the determination result is no, then turn to C2;
[0119] C2, determine whether a new request from the master node is currently received. If the result is no, proceed to C3;
[0120] C3, obtain a current second actual time, determine a second time interval according to the receiving time and the second actual time, and determine whether the second time interval is greater than a second preset interval, where the second preset interval = the response time period corresponding to the i-th request - k / baudrate. If the determination result is no, proceed to C4;
[0121] C4, sends the target response to the master node.
[0122] In the third scenario, C1 is first used to accurately determine whether the target response is sent within the preset response time period. If the determination result is no, C2 is then used to determine whether a new request is received. If the determination result is no, C3 is further used to accurately determine whether the target response is sent within the preset response time period. Since some time has passed since the determination of C1, a second accurate determination can be more accurate. This triple determination can avoid communication conflicts.
[0123] Here, the first actual time and the second actual time are used to represent the time when the target response is attempted to be sent, so the current time is used.
[0124] Optionally, if the determination result of whether the second time interval is greater than a second preset interval is yes, the target response is discarded. If the target response is sent at this time, a communication conflict is likely to occur, so the target response needs to be discarded to avoid the generation of communication conflicts.
[0125] According to this embodiment, by judging whether the second time interval is greater than the response time period corresponding to the i-th request after correction, the generation of communication conflicts can be further avoided.
[0126] Embodiment 3
[0127] This embodiment provides a communication method based on a polling mechanism, which is used in an electric power automation system. The electric power automation system includes a master node and several slave nodes. The master node and the slave nodes communicate based on the polling mechanism. The master node needs to send L requests in each round, where L is a positive integer, and each request corresponds to a request time interval and a response time period. The execution subject of the communication method of this embodiment is a communication device based on a polling mechanism, which can be integrated into the master node or the master node itself.
[0128] like Figure 2 FIG. 1 is a flow chart of a communication method based on a polling mechanism according to this example. The communication method based on a polling mechanism includes:
[0129] Step 201, if it is identified that the i-th request needs to be sent to a slave node, and the i-th request is one of the L requests in this round, then determine whether the third time interval between the i-th request and the i-th request sent in the previous round is greater than or equal to the request time interval corresponding to the i-th request.
[0130] Wherein, i is a positive integer and i≤L.
[0131] For the communication device in the master node, based on the polling mechanism, it is necessary to send requests to each slave node in turn. Before sending the request, it can be determined whether the third time interval between the i-th request and the i-th request in the previous round has met the request time interval requirement.
[0132] Step 202: If the judgment result is yes, send the i-th request to the slave node.
[0133] If the answer is yes, it means that there should be no message being transmitted on the current communication line. At this time, sending the i-th node will not cause communication conflict.
[0134] Optionally, after step 202, the method further includes:
[0135] Determine whether a target response sent by the slave node is received within a response time period corresponding to the i-th request, where the target response is generated based on the i-th request;
[0136] If the judgment result is no, the i-th request is determined to be an abnormal request.
[0137] If the target response is not received within the response time period, it means that a communication conflict is likely to occur, or a failure has occurred in the slave node. As an exemplary illustration, the abnormal request can be marked and the cause can be found later. In addition, the content of the i requests can be resent in the next round of requests.
[0138] Optionally, after determining that the i-th request is an abnormal request, the method further includes:
[0139] Determine whether i is less than or equal to L;
[0140] If the judgment result is yes, the value of i+1 is updated to i, and the operation of identifying whether an i-th request needs to be sent to a slave node is returned.
[0141] After determining that the i-th request is an abnormal request, the next request judgment phase is entered.
[0142] According to this embodiment, before sending a request, it is first determined whether the third time interval between it and the i-th request in the previous round is greater than or equal to the request time interval corresponding to the i-th request. If the judgment result is yes, it is sent, so as to avoid communication conflicts.
[0143] Embodiment 4
[0144] This embodiment specifically illustrates the above-mentioned communication method based on the polling mechanism.
[0145] In this embodiment, the master node and the slave node communicate with each other via the RS-485 bus. In this scenario, the communication data between the master node and the slave node is relatively small. The master node is, for example, a relay protection device, and the slave node is, for example, a temperature sensor, and the multiple temperature sensors are distributed at different locations in the switch cabinet.
[0146] In this embodiment, assuming that the number of slave nodes is 10, and each slave node corresponds to 1 request, then L is 10, that is.
[0147] Master Node:
[0148] like Figure 3A As shown, it is a flow chart of a communication method based on a polling mechanism executed on the master node side.
[0149] Step 301: The master node recognizes that it needs to send the i-th request to a slave node, and then determines whether the third time interval between the i-th request in the previous round is greater than or equal to the corresponding request time interval. If the judgment result is yes, then go to step 302, otherwise go to step 306.
[0150] In step 302 , the master node sends the i th request to the i th slave node, and the process proceeds to step 303 .
[0151] Step 303, determine whether the master node receives a response returned by the i-th slave node within the corresponding response time period of the i-th request. If the determination result is yes, proceed to step 304, otherwise proceed to step 306.
[0152] Step 304 , mark the i-th request in this round as a normal request, and go to step 305 .
[0153] If the i-th request is not a normal request (ie, an abnormal request), the failed request content is used for the i-th request in subsequent polling until the i-th request becomes a normal request.
[0154] Step 305 , using the value of i+1 as the updated value of i, and determining whether the updated value of i is less than or equal to L. If the determination result is yes, returning to step 301 , otherwise executing step 307 .
[0155] Step 306 , mark the i th request as an abnormal request, and return to execute step 305 .
[0156] Step 307, triggering the sending operation of the next round of requests.
[0157] From the node:
[0158] In this embodiment, the slave node is divided into a bottom layer and an upper layer, the bottom layer is used to communicate with the master node, and the upper layer is used to process the received request.
[0159] like Figure 3B As shown, a communication method based on a polling mechanism is executed from the node side.
[0160] Step 310, the bottom layer receives the i-th request sent by the master node and proceeds to step 311.
[0161] In step 311 , the bottom layer attaches a special identifier to the i-th request and records the receiving time t1 of the i-th request, and then goes to step 312 .
[0162] Step 312: The bottom layer sends the i-th request to the upper layer for processing, and then the process goes to step 313.
[0163] Step 313 , the upper layer receives the i-th request and clears the special identifier attached to the i-th request, and then goes to step 314 .
[0164] Step 314, check the i-th request, if the check passes, execute step 315, otherwise execute step 316.
[0165] For example, it is checked whether the destination address in the i-th request is consistent with the address of the current slave node. If they are consistent, the check is passed, and if they are inconsistent, the check is failed. Other items can also be checked according to actual needs, which will not be repeated here.
[0166] Step 315 , generates a target response for the i-th request and sends it to the bottom layer, and then goes to step 317 .
[0167] Step 316: discard the i-th request.
[0168] Step 317 , obtain the current first sending time t2 , and determine the first time interval according to the following formula: first time interval = t2 − t1 , and then go to step 318 .
[0169] Step 318 , determining whether the first time interval is greater than the response time period corresponding to the i-th request, if the determination result is no, executing step 319 , otherwise executing step 325 .
[0170] Step 319, determine whether there is a request with a special identifier at the bottom layer. If the determination result is no, execute step 320, otherwise execute step 325.
[0171] Step 320 , obtain the current second actual time t3 , and determine the second time interval according to the following formula: second time interval=t3−t1 , and then go to step 321 .
[0172] Step 321 , determining whether the second time interval is greater than the second preset interval, if the determination result is no, executing step 322 , otherwise executing step 325 .
[0173] The second preset interval=the response time period corresponding to the ith request-k / baudrate, where k is a preset calibration coefficient and baudrate is the baud rate.
[0174] Step 322, send target response, and go to step 323.
[0175] Step 323, determine whether the destination address of the target response is consistent with the sending address of the received i-th request, if they are consistent, execute step 324, otherwise execute step 326.
[0176] Step 324, clear the buffer area and return True.
[0177] Step 325 , discard the target response, and execute step 326 .
[0178] Step 326, clear the buffer area and return False.
[0179] The return of True and False is used to inform the slave node of the result of this processing.
[0180] Embodiment 5
[0181] This embodiment provides a communication device based on a polling mechanism, which is used in an electric power automation system. The electric power automation system includes a master node and several slave nodes. The master node and the slave nodes communicate based on the polling mechanism. The master node needs to send L requests in each round, where L is a positive integer. The communication device can be one of the slave nodes or integrated in a slave node.
[0182] In this embodiment, each request corresponds to a request time interval and a response time period. The request time interval represents the minimum time period between the master node sending the i-th request in this round and sending the i-th request in the previous round. The response time period represents the maximum time period from the master node sending the i-th request to receiving the response sent by the slave node.
[0183] like Figure 4As shown, the communication device includes a generating unit 401 , a first judging unit 402 and a first sending unit 403 .
[0184] Among them, the generation unit 401 is used to generate a target response for the i-th request if the i-th request of this round sent by the master node is received, wherein i is a positive integer and i≤L; the first judgment unit 402 is used to judge whether a first time interval is greater than a first preset interval, and to judge whether a new request sent by the master node is currently received, the first time interval is determined based on a receiving time of the i-th request and a current first actual time, and the first preset interval is determined based on a response time period corresponding to the i-th request; the first sending unit 403 is used to send a target response to the master node.
[0185] The working methods of each unit in this embodiment are the same as those in the previous embodiment and will not be described again here.
[0186] According to the communication device based on the polling mechanism of this embodiment, a corresponding request time interval and response time period are preset for each request, and then a double judgment is made to determine whether there may be a communication conflict on the current communication network, which can reduce the probability of communication conflicts.
[0187] Embodiment 6
[0188] This embodiment further supplements the communication device based on the polling mechanism of the fourth embodiment.
[0189] like Figure 5 FIG. 5 is a flow chart of a communication device based on a polling mechanism according to this embodiment. The communication device based on a polling mechanism further includes an acquisition unit 501 , a determination unit 502 and a second judgment unit 503 .
[0190] Among them, the acquisition unit 501 is used to obtain a current second actual time; the determination unit 502 is used to determine the second time interval according to the receiving time and the second actual time; the second judgment unit 503 is used to judge whether the second time interval is greater than a second preset interval, the second preset interval = the response time period corresponding to the i-th request - k / baudrate, where k is the preset calibration coefficient, baudrate is the baud rate, if the judgment result is no, the first sending unit 403 is triggered.
[0191] Optionally, the second judgment unit 503 is further used to: if the judgment result of judging whether the second actual time interval is greater than a second preset interval is yes, trigger a discarding unit 504; the communication device also includes a discarding unit 504, and the discarding unit 504 is used to discard the target response.
[0192] Optionally, in this embodiment, the communication device also includes a marking unit 505 and a clearing unit 506, wherein the marking unit 505 is used to attach a special identifier to the i-th request when receiving the i-th request sent by the master node; the clearing unit 506 is used to clear the special identifier when starting to generate a target response for the i-th request.
[0193] Optionally, the first time interval is equal to a response time period corresponding to the i-th request; or
[0194] The first time interval=the response time period corresponding to the ith request-k / baudrate, where k is a preset calibration coefficient and baudrate is the baud rate.
[0195] The working methods of each unit in this embodiment are the same as those in the previous embodiment and will not be described again here.
[0196] According to this embodiment, by judging whether the second time interval is greater than the response time period corresponding to the i-th request after correction, the generation of communication conflicts can be further avoided.
[0197] Embodiment 7
[0198] This embodiment provides a communication device based on a polling mechanism, which is used in an electric power automation system. The electric power automation system includes a master node and several slave nodes. The master node and the slave nodes communicate based on a polling mechanism. The master node needs to send L requests in each round, where L is a positive integer. The communication device based on the polling mechanism of this embodiment can be a master node or integrated in the master node.
[0199] In this embodiment, each request corresponds to a request time interval and a response time period. The request time interval represents the minimum time interval between sending the i-th request in this round and sending the i-th request in the previous round. The response time period represents the maximum time interval from the master node sending the request to receiving the response sent by the slave node.
[0200] like Fig. 6A , which is a schematic diagram of the structure of a communication device based on a polling mechanism according to this embodiment. The communication device based on a polling mechanism includes an identification unit 601 , a third judgment unit 602 and a second sending unit 603 .
[0201] Among them, the identification unit 601 is used to identify whether it is necessary to send the i-th request to a slave node, the i-th request is one of the L requests in this round. If the identification result is yes, a third judgment unit 602 is triggered, wherein i is a positive integer and i≤L; the third judgment unit 602 is used to determine whether the third time interval between the i-th request and the i-th request sent in the previous round is greater than or equal to the request time interval corresponding to the i-th request. If the judgment result is yes, a second sending unit 603 is triggered; the second sending unit 603 is used to send the i-th request to the slave node.
[0202] Alternatively, if Figure 6B As shown, the communication device based on the polling mechanism of this embodiment also includes a fourth judgment unit 604, which is used to determine whether a target response sent from the node is received within the response time period corresponding to the i-th request, and the target response is generated based on the i-th request. If the judgment result is no, it is determined that the i-th request is an abnormal request.
[0203] Alternatively, if Figure 6B As shown, the communication device based on the polling mechanism of this embodiment further includes a fifth judgment unit 605 and an updating unit 606. The fifth judgment unit 605 is used to judge whether i is less than or equal to L, and if the judgment result is yes, the updating unit 606 is triggered; the updating unit 606 is used to update the value of i+1 to i, and then trigger the identification unit 601.
[0204] The working methods of each unit in this embodiment are the same as those in the previous embodiment and will not be described again here.
[0205] According to this embodiment, before sending a request, it is first determined whether the third time interval between it and the i-th request in the previous round is greater than or equal to the request time interval corresponding to the i-th request. If the judgment result is yes, it is sent, so as to avoid communication conflicts.
[0206] The present invention also provides a relay protection device, comprising at least one memory and at least one processor, wherein the memory is used to store instructions, and the processor is used to execute the communication method based on the polling mechanism described in any of the above embodiments according to the instructions stored in the memory.
[0207] An embodiment of the present invention further provides a readable storage medium in which machine-readable instructions are stored, and when the machine-readable instructions are executed by a machine, the machine executes the communication method based on the polling mechanism described in any of the above embodiments.
[0208] The readable medium stores machine-readable instructions, which, when executed by the processor, cause the processor to execute any of the aforementioned methods. Specifically, a system or device equipped with a readable storage medium may be provided, on which a software program code implementing the functions of any of the above-mentioned embodiments is stored, and a computer or processor of the system or device reads and executes the machine-readable instructions stored in the readable storage medium.
[0209] In this case, the program code itself read from the machine-readable medium can realize the function of any one of the above-mentioned embodiments, and thus the machine-readable code and the machine-readable storage medium storing the machine-readable code constitute a part of the present invention.
[0210] Examples of readable storage media include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD+RW), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, the program code may be downloaded from a server computer or a cloud via a communication network.
[0211] Those skilled in the art should understand that the various embodiments disclosed above can be modified and altered in various ways without departing from the essence of the invention. Therefore, the protection scope of the present invention should be defined by the appended claims.
[0212] It should be noted that not all steps and units in the above-mentioned processes and system structure diagrams are necessary, and some steps or units can be ignored according to actual needs. The execution order of each step is not fixed and can be adjusted as needed. The device structure described in the above-mentioned embodiments can be a physical structure or a logical structure, that is, some units may be implemented by the same physical entity, or some units may be implemented by multiple physical entities, or some components in multiple independent devices may be implemented together.
[0213] In the above embodiments, the hardware unit can be realized by mechanical means or electrical means. For example, a hardware unit or a processor can include permanent dedicated circuits or logic (such as special processors, FPGA or ASIC) to complete the corresponding operation. The hardware unit or the processor can also include programmable logic or circuits (such as general-purpose processors or other programmable processors), which can be temporarily set by software to complete the corresponding operation. Concrete implementation (mechanical means or dedicated permanent circuits or temporarily set circuits) can be determined based on cost and time considerations.
[0214] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A communication method based on a polling mechanism, the communication method is used in an electric power automation system, the electric power automation system includes a master node and a plurality of slave nodes, the master node and each of the slave nodes communicate based on a polling mechanism, the master node needs to send L requests in each round, where L is a positive integer, the communication method includes: If the i-th request of this round sent by the master node is received, a target response for the i-th request is generated, where i is a positive integer and i≤L; The method is characterized in that each request corresponds to a request time interval and a response time interval, the request time interval represents the minimum time interval between the master node sending the i-th request of this round and sending the i-th request of the previous round, and the response time interval represents the maximum time interval from the master node sending the i-th request to receiving the response sent by the slave node, and the communication method further includes: Determine whether a first time interval is greater than a first preset interval, and determine whether a new request sent by the master node is currently received, wherein the first time interval is determined according to a receiving time of the i-th request and a current first actual time, and the first preset interval is determined according to a response time period corresponding to the i-th request; If the above judgment results are all negative, the target response is sent to the master node.
2. The communication method according to claim 1, characterized in that: After determining that a new request sent by the master node is not received and before sending the target response to the master node, the method further includes: Get the current real time of the second; determining a second time interval according to the receiving time and the second actual time; Determine whether the second time interval is greater than a second preset interval, where the second preset interval=the response time period corresponding to the i-th request-k / baudrate, where k is a preset calibration coefficient and baudrate is a baud rate; If the judgment result is no, an operation of sending the target response to the master node is triggered.
3. The communication method according to claim 2, characterized in that: If the result of determining whether the second actual time interval is greater than a second preset time interval is yes, the target response is discarded.
4. The communication method according to claim 1, characterized in that: After determining whether the first time interval is greater than a first preset interval and the determination result is no, an operation of determining whether a new request sent by the master node is currently received is performed.
5. The communication method according to claim 1, characterized in that: If any one of the determination results of determining whether a first time interval is greater than a first preset interval and determining whether a new request sent by the master node is currently received is yes, the target response is discarded.
6. The communication method according to claim 1, characterized in that: When receiving the i-th request sent by the master node, the method further includes: attaching a special identifier to the i-th request; When starting to generate a target response for the i-th request, the method further includes: clearing the special flag; Determining whether a new request sent by the master node is currently received includes: determining whether there is a request with a special identifier currently, and if the determination result is no, determining that a new request sent by the master node is currently not received.
7. The communication method according to any one of claims 1 to 6, characterized in that: The first time interval is equal to the response time period corresponding to the i-th request; or The first time interval=the response time period corresponding to the ith request-k / baudrate, wherein k is a preset calibration coefficient and baudrate is the baud rate.
8. A communication method based on a polling mechanism, the communication method is used in an electric power automation system, the electric power automation system includes a master node and a plurality of slave nodes, the master node and each of the slave nodes communicate based on a polling mechanism, the master node needs to send L requests in each round, where L is a positive integer, characterized in that: Each request corresponds to a request time interval and a response time period, wherein the request time interval represents the minimum time interval between sending the i-th request in this round and sending the i-th request in the previous round, and the response time period represents the maximum time interval from the master node sending the request to receiving the response sent by the slave node, and the communication method includes: If it is identified that an i-th request needs to be sent to a slave node, and the i-th request is one of the L requests in this round, then it is determined whether a third time interval between the i-th request and the i-th request sent in the previous round is greater than or equal to the request time interval corresponding to the i-th request, where i is a positive integer and i≤L; If the judgment result is yes, the i-th request is sent to the slave node.
9. The communication method according to claim 8, characterized in that: After sending the i-th request to the slave node, the method further includes: Determine whether a target response sent by the slave node is received within a response time period corresponding to the i-th request, the target response being generated based on the i-th request; If the judgment result is no, it is determined that the i-th request is an abnormal request.
10. The communication method according to claim 9, characterized in that: After determining that the i-th request is an abnormal request, the method further includes: Determine whether i is less than or equal to L; If the judgment result is yes, the value of i+1 is updated to i, and the operation of identifying whether an i-th request needs to be sent to a slave node is returned.
11. A communication device based on a polling mechanism, the communication device is used in an electric power automation system, the electric power automation system includes a master node and a plurality of slave nodes, the master node and each of the slave nodes communicate based on a polling mechanism, the master node needs to send L requests in each round, where L is a positive integer, the communication device includes: a generating unit, configured to generate a target response for the i-th request in this round if the i-th request sent by the master node is received, wherein i is a positive integer and i≤L; The invention is characterized in that each request corresponds to a request time interval and a response time interval, the request time interval represents the minimum time interval between the master node sending the i-th request of this round and sending the i-th request of the previous round, and the response time interval represents the maximum time interval from the master node sending the i-th request to receiving the response sent by the slave node, and the communication device also includes: a first determination unit, configured to determine whether a first time interval is greater than a first preset interval, and to determine whether a new request sent by the master node is currently received, wherein the first time interval is determined according to a receiving time of the i-th request and a current first actual time, and the first preset interval is determined according to a response time period corresponding to the i-th request; A first sending unit is used to send the target response to the master node.
12. The communication device according to claim 11, characterized in that: Also includes: An acquisition unit, used for acquiring a current second actual time; a determining unit, configured to determine a second time interval according to the receiving time and the second actual time; A second judgment unit is used to judge whether the second time interval is greater than a second preset interval, where the second preset interval = the response time period corresponding to the i-th request - k / baudrate, where k is a preset calibration coefficient and baudrate is a baud rate. If the judgment result is no, the first sending unit is triggered.
13. The communication device according to claim 11, characterized in that: The second judging unit is further configured to: trigger a discarding unit if the judging result of judging whether the second actual time interval is greater than a second preset time interval is yes; The communication device further includes the discarding unit, which is configured to discard the target response.
14. The communication device according to claim 11, characterized in that: Also includes: a marking unit, configured to attach a special identifier to the i-th request when receiving the i-th request sent by the master node; A clearing unit is used to clear the special identifier when starting to generate a target response for the i-th request.
15. The communication device according to any one of claims 11 to 14, characterized in that: The first time interval is equal to the response time period corresponding to the i-th request; or The first time interval=the response time period corresponding to the ith request-k / baudrate, wherein k is a preset calibration coefficient and baudrate is the baud rate.
16. A communication device based on a polling mechanism, the communication device is used in an electric power automation system, the electric power automation system includes a master node and several slave nodes, the master node and each of the slave nodes communicate based on a polling mechanism, the master node needs to send L requests in each round, where L is a positive integer, characterized in that: Each request corresponds to a request time interval and a response time period, wherein the request time interval represents the minimum time interval between sending the i-th request of this round and sending the i-th request of the previous round, and the response time period represents the maximum time period from when the master node sends the request to when it receives the response sent by the slave node, and the communication device includes: an identification unit, used to identify whether an i-th request needs to be sent to a slave node, where the i-th request is one of the L requests in this round, and if the identification result is yes, a third judgment unit is triggered, where i is a positive integer and i≤L; The third judging unit is used to judge whether a third time interval between the i-th request and the i-th request sent in the previous round is greater than or equal to the request time interval corresponding to the i-th request, and if the judgment result is yes, trigger a second sending unit; The second sending unit is used to send the i-th request to the slave node.
17. The communication device according to claim 16, characterized in that: Also includes: A fourth judgment unit is used to judge whether a target response sent by the slave node is received within a response time period corresponding to the i-th request, the target response is generated based on the i-th request, and if the judgment result is no, it is determined that the i-th request is an abnormal request.
18. The communication device according to claim 17, characterized in that: Also includes: a fifth judgment unit, used for judging whether i is less than or equal to L, and if the judgment result is yes, triggering an updating unit; The updating unit is used to update the value of i+1 to i, thereby triggering the identifying unit.
19. A relay protection device, characterized in that: include: at least one memory for storing instructions; At least one processor is configured to execute the communication method based on the polling mechanism according to any one of claims 8 to 10 according to the instructions stored in the memory.