Data refresh methods, devices, equipment and media
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-03-03
- Publication Date
- 2026-08-14
AI Technical Summary
[0004]通过用户自定义数据刷新速度需要用户对数据访问速度和变化频率有一定的了解,而且对于一些不必要读取的数据,PLC会机械重复读取,更严重时,数据队列处理不及时,导致通讯延时变大,严重影响通讯的实时性,降低数据刷新的速度
一种计算机可读存储介质,存储有能够被处理器加载并执行第一方面任一项所述的数据刷新方法的计算机程序。
Smart Images

Figure CN116303164B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of industrial communication, and in particular to a data refresh method, apparatus, device and medium. Background Technology
[0002] Programmable Logic Controllers (PLCs) are highly reliable general-purpose industrial automation devices. They are characterized by strong capabilities, high reliability, flexible configuration, simple programming, ease of use, and easy expansion, and are widely used in industrial control.
[0003] Currently, in PLC applications, communication with the PLC is usually achieved through industrial human-machine interface (HMI) products. Users can observe the data collected by the PLC through the HMI, which is simple and convenient. However, in the communication process between the HMI and the PLC, the data is usually sorted and grouped for communication according to a user-defined data refresh cycle, and then the data is refreshed and returned after communication.
[0004] Customizing the data refresh rate requires the user to have a certain understanding of the data access speed and change frequency. Moreover, for some unnecessary data, the PLC will mechanically and repeatedly read it. In more serious cases, the data queue is not processed in time, resulting in increased communication delay, which seriously affects the real-time performance of communication and reduces the data refresh rate. Summary of the Invention
[0005] To reduce communication latency and improve data refresh speed, this application provides a data refresh method, apparatus, device, and medium.
[0006] Firstly, this application provides a data refresh method, which adopts the following technical solution: A data refresh method, comprising: Retrieve the data attributes of all requested data; Calculate the first priority of all requested data based on the data attributes; All the requested data are sorted according to the first priority to obtain the sorting result; Based on the sorting results, communication is established with the PLC to obtain the requested results.
[0007] By adopting the above technical solution, when the HMI needs to communicate with the PLC to obtain the requested data collected by the PLC, the first priority of each requested data is calculated according to the data attributes of the requested data. Then, the data is sorted according to the first priority. The requested data with the highest first priority is communicated first, and then the data is communicated in sequence according to the first priority. This can reduce the possibility of reading the same requested data multiple times, reduce the impact on the real-time performance of the requested data communication, speed up the communication, improve the refresh speed of the requested data, and improve the real-time performance of the requested data.
[0008] Optionally, before obtaining the data attributes of all requested data, the method further includes: Obtain the address information of the requested data, the address information including address size and address type; The request data is registered based on the address information to obtain registration information, which includes the number of registrations and the age of the registrant. Retrieve the original request queue; Based on the registration information, determine whether the request data exists in the original request queue; If it exists, the registration count is increased, and the registered age is refreshed to obtain the refreshed age.
[0009] Optionally, the data attributes include a second priority and a refresh age, and calculating the first priority of all requested data based on the data attributes includes: The second priority is obtained based on the original request queue; Assign a first weight value to the second priority, a second weight value to the refresh age, and a third weight value to the registration age; Calculate a first priority value for the requested data based on the first weight value, the second weight value, and the third weight value; The first priority of each requested data is determined based on the first priority value.
[0010] Optionally, after determining the first priority of each requested data based on the first priority value, the method further includes: Obtain the first weighting coefficient corresponding to the second priority, the second weighting coefficient of the refresh age, and the third weighting coefficient of the registered age; The first priority value is adjusted based on the first weighting coefficient, the second weighting coefficient, and the third weighting coefficient to obtain the second priority value; The first priority is adjusted based on the second priority value to obtain the second priority.
[0011] Optionally, obtaining the first weighted coefficient corresponding to the second priority, the second weighted coefficient of the refreshed age, and the third weighted coefficient of the registered age includes: Loop time for obtaining scan request data; Determine whether the loop time is greater than the preset scan time; If the loop time is greater than the preset scan time, the first weighting coefficient, the second weighting coefficient, and the third weighting coefficient are obtained based on the preset interval table. If the loop time is less than the preset scan time, the first weighting coefficient, the second weighting coefficient, and the third weighting coefficient are all set to default coefficients.
[0012] Optionally, sorting all the request data according to the first priority to obtain the sorting result includes: Determine whether the first priority value is greater than a preset threshold; If the first priority value is greater than the preset threshold, then a first group of packets is established, and the first group of packets includes all request data whose first priority value is greater than the preset threshold; Obtain the minimum and maximum addresses of the request data in the first group of packets; The address request range of the first group of packets is determined based on the minimum address and the maximum address; Obtain all request data for the specified address request range; Add all request data within the specified address request range to the first packet to form the second packet; The second group of packages is used as the sorting result.
[0013] Optionally, after communicating with the PLC based on the sorting result to obtain the requested result, the method further includes: The number of times the requested data was registered; Determine whether the number of registrations is zero; If the number of registrations is zero, then the request data with zero registration counts in the sorting results will be revoked.
[0014] Secondly, this application provides a data refresh device, which adopts the following technical solution: A data refresh device, comprising: The retrieval module is used to retrieve the data attributes of all requested data; The calculation module is used to calculate the first priority of all requested data based on the data attributes; The sorting module is used to sort all the request data according to the first priority to obtain a sorting result; The communication module is used to communicate with the PLC based on the sorting results to obtain the requested results.
[0015] By adopting the above technical solution, when the HMI needs to communicate with the PLC to obtain the requested data collected by the PLC, the first priority of each requested data is calculated according to the data attributes of the requested data. Then, the data is sorted according to the first priority. The requested data with the highest first priority is communicated first, and then the data is communicated in sequence according to the first priority. This can reduce the possibility of reading the same requested data multiple times, reduce the impact on the real-time performance of the requested data communication, speed up the communication, improve the refresh speed of the requested data, and improve the real-time performance of the requested data.
[0016] Thirdly, this application provides an electronic device that adopts the following technical solution: An electronic device includes a processor coupled to a memory; The memory stores a computer program that can be loaded by a processor and execute the data refresh method described in any of the first aspects.
[0017] Fourthly, this application provides a computer-readable storage medium, which adopts the following technical solution: A computer-readable storage medium storing a computer program capable of being loaded by a processor and executing the data refresh method described in any of the first aspects. Attached Figure Description
[0018] Figure 1 This is a flowchart illustrating a data refresh method provided in an embodiment of this application.
[0019] Figure 2 This is a structural block diagram of a data refresh device provided in an embodiment of this application.
[0020] Figure 3 This is a structural block diagram of the electronic device provided in the embodiments of this application. Detailed Implementation
[0021] The present application will be further described in detail below with reference to the accompanying drawings.
[0022] This application provides a data refresh method, which can be executed by an electronic device. The electronic device can be a server or a terminal device. The server can be a standalone physical server, a server cluster or distributed system composed of multiple physical servers, or a cloud server providing cloud computing services. The terminal device can be a smartphone, tablet computer, desktop computer, etc., but is not limited to these.
[0023] like Figure 1 As shown, a data refresh method is described in the following steps (S101-S104): Step S101: Obtain the data attributes of all requested data.
[0024] In this embodiment, when an operator views data from a programmable logic controller (PLC) through an industrial human-machine interface (HMI), the operator navigates to the interface on which they want to query data. At this point, the data on that interface is the PLC's requested data. The HMI then communicates with the PLC, retrieving the corresponding requested data from the PLC. However, during this communication, to reduce duplicate addresses and shorten the request queue, the data needs to be sorted. For the HMI, improving the refresh rate of the requested data ensures its real-time performance, making the data retrieved by the operator more timely.
[0025] Specifically, before obtaining the data attributes of all requested data, the method also includes: obtaining the address information of the requested data, including address size and address type; registering the requested data based on the address information to obtain registration information, including registration count and registration age; obtaining the original request queue; determining whether the original request queue contains requested data based on the registration information; if it does, increasing the registration count and refreshing the registration age to obtain the refreshed age.
[0026] In this embodiment, when the HMI communicates with the PLC, the variables on each interface of the HMI are associated with the internal address of the PLC. However, the address size and type of each address are different. Therefore, when querying each requested data, it is necessary to register the requested data according to the request address corresponding to each requested data, and then record the registration information. Since the request times of different requested data are different, duplicate requests may occur. When duplicate requests occur, for the same requested data, it is only necessary to increase the registration count, without registering again. However, while increasing the registration count of the requested data, it is also necessary to refresh the registration age. At this time, the refresh age of the requested data is obtained, that is, the refresh age is the current time when the registration age is refreshed.
[0027] On the other hand, since the registration of requested data is done through memory operations, it can be completed quickly, which is faster than registration through external I / O modules. Therefore, the preferred implementation method in this embodiment is memory operation.
[0028] In this embodiment, when the PLC needs to receive requested data, the current time is used as the registered age of the requested data for convenient storage and communication. Storing the registered age also allows staff to easily query the requested data. It is worth noting that the registered age can be stored even when the HMI and PLC are not communicating, ensuring the communication and refresh speeds between the HMI and PLC.
[0029] Step S102: Calculate the first priority of all requested data based on data attributes.
[0030] Specifically, the data attributes include a second priority and a refresh age. Calculating the first priority of all requested data based on the data attributes includes: obtaining the second priority based on the original request queue; assigning a first weight value to the second priority, a second weight value to the refresh age, and a third weight value to the registration age; calculating the first priority value of the requested data based on the first weight value, the second weight value, and the third weight value; and determining the first priority of each requested data based on the first priority value.
[0031] In this embodiment, since the frequency of change of each requested data is different, it is necessary to determine the second priority based on the frequency of change of each requested data. For example, when the requested data is data such as voltage or current that changes rapidly and irregularly, the second priority is high priority; when the requested data is data such as flow rate that changes at a certain rate or is controlled by a control system, the second priority is medium priority; when the requested data is data such as temperature that changes slowly, the second priority is low priority.
[0032] In this embodiment, the first weight value is determined according to the category of the second priority. For example, when the requested data is high-priority change data such as voltage or current, the first weight value is 5; when the requested data is medium-priority change data such as flow rate, the first weight value is 3; and when the requested data is low-priority change data such as temperature, the first weight value is 1.
[0033] When sorting the requested data, since users may repeatedly request the same data, that is, repeatedly refresh the data, the refresh age of the data increases, indicating that the data needs to be refreshed continuously.
[0034] The second weight value varies depending on the refresh age. First, the request data is sorted in descending order of refresh age. Then, different second weight values are assigned to the request data based on the sorting result. For example, the second weight value for request data with the highest refresh age is 3, the second weight value for request data with the second refresh age is 2, the second weight value for request data with the third refresh age is 1, and all request data after the third refresh age uses the second weight value corresponding to the third refresh age.
[0035] Correspondingly, the third weight value for the registered age is assigned in the same way as the refresh age, so it will not be elaborated on here.
[0036] The first priority value of the requested data is determined by the first weight value, the second weight value, and the third weight value. In this embodiment, the first priority value is calculated by simply adding or subtracting the first weight value, the second weight value, and the third weight value, and then the first priority of each requested data is determined based on the first priority value.
[0037] Furthermore, in order to better sort the requested data and enable fast communication between the HMI and PLC, after determining the first priority value, it is necessary to adjust the first priority value according to the corresponding weighting coefficient, so as to make the sorting of the requested data more accurate, maximize the communication speed, and improve the real-time performance of the data.
[0038] Furthermore, after determining the first priority of each requested data based on the first priority value, the method further includes: obtaining the first weighting coefficient corresponding to the second priority, the second weighting coefficient of the refresh age, and the third weighting coefficient of the registered age; adjusting the first priority value based on the first weighting coefficient, the second weighting coefficient, and the third weighting coefficient to obtain the second priority value; and adjusting the first priority based on the second priority value to obtain the second priority.
[0039] In this embodiment, different weight values correspond to different weighting coefficients. By adjusting the first priority value with different weighting coefficients, the second priority value can be obtained, making each requested data more accurate. At the same time, the order of communication between the HMI and PLC based on the second priority value can shorten the length of the request queue, speed up the communication speed, and obtain the requested data one by one according to the importance of the requested data, thereby speeding up the communication speed and improving the real-time performance of the data.
[0040] The method for determining the weighting coefficients in this embodiment is the same as the method for determining the weight values described above, and will not be repeated here.
[0041] It is worth noting that the second priority value is calculated according to the following formula:
[0042] Where M is the second priority value, a is the first weighting coefficient, X1 is the first weight value, b is the second weighting coefficient, X2 is the second weight value, c is the third weighting coefficient, and X3 is the third weight value.
[0043] In another optional embodiment, in order to further optimize the communication speed, the first priority is optimized by dynamically adjusting the weighting coefficients based on the data request loop time, thereby optimizing the second priority value.
[0044] Specifically, obtaining the first weighted coefficient corresponding to the second priority, the second weighted coefficient for refreshing age, and the third weighted coefficient for registering age includes: obtaining the loop time of the scan request data; determining whether the loop time is greater than the preset scan time; if the loop time is greater than the preset scan time, then obtaining the first weighted coefficient, the second weighted coefficient, and the third weighted coefficient based on the preset interval table; if the loop time is less than the preset scan time, then the first weighted coefficient, the second weighted coefficient, and the third weighted coefficient are all set to the default coefficients.
[0045] In this optional implementation, before refreshing the requested data, it is necessary to calculate the scanning time for quickly scanning all the requested data, i.e., the loop time for scanning the requested data. Since the data size and quantity of each requested data are different, the time for scanning a single requested data is different, resulting in different loop times for scanning the requested data. When the calculated loop time is greater than the preset scanning time, it is necessary to obtain the first weighting coefficient, the second weighting coefficient, and the third weighting coefficient according to the preset interval table. The preset interval table is obtained through a large number of experiments.
[0046] When the loop time is less than the preset scan time, there is no need to adjust the weighting coefficients; only the first priority needs to be calculated based on the first, second, and third weight values. In this embodiment, the default first, second, and third weighting coefficients are all 1, meaning they have no effect on the weight values.
[0047] Step S103: Sort all request data according to the first priority to obtain the sorting result.
[0048] Specifically, all request data are sorted according to the first priority, and the sorting result includes: determining whether the first priority value is greater than a preset threshold; if the first priority value is greater than the preset threshold, then a first packet is created, which includes all request data whose first priority value is greater than the preset threshold; obtaining the minimum and maximum addresses of the request data in the first packet; determining the address request range of the first packet based on the minimum and maximum addresses; obtaining all request data within the address request range; adding all request data within the address request range to the first packet to form a second packet; and using the second packet as the sorting result.
[0049] In this embodiment, when the calculated first priority value is greater than a preset threshold, all request data exceeding the preset threshold are acquired. These request data are then combined to form a first packet. Next, the address request range is determined based on the addresses within the request data of the first packet, resulting in a second packet. The second packet includes all request data from the first packet, as well as request data that does not reach the preset threshold and makes the addresses within the first packet consecutive. The second packet is then treated as a whole and sorted with other request data. In this embodiment, the highest first priority value in the packet is defined as the first priority value of the packet. For ease of understanding, the following example will be used for explanation.
[0050] For example, if the requested data is located at addresses 1-20 in the PLC, and the addresses of the requested data with a first priority value greater than the pre-approval threshold are 2, 4, 5, 7, 8, and 10 respectively, then the first group of packets includes the requested data at addresses 2, 4, 5, 7, 8, and 10. To achieve synchronous communication, all the requested data between addresses 2 and 10 are grouped together as a single packet, that is, the second group of packets includes the requested data at addresses 2, 3, 4, 5, 6, 7, 8, 9, and 10. Among them, the first priority value of the requested data at address 7 is the highest among addresses 1-20, so the first priority of the second group of packets is the highest, and the requested data in the second group of packets needs to be communicated first.
[0051] Step S104: Communicate with the PLC based on the sorting result to obtain the requested result.
[0052] After obtaining the first priority of all request data, the HMI and PLC are controlled to communicate. Then, after the HMI obtains the request data from the PLC, it is displayed in the HMI. After the PLC transmits the request data to the HMI, the registration count of the current request data needs to be changed. When the registration count of the request data is adjusted to zero, the request data is canceled, which can improve the communication speed and refresh speed.
[0053] Figure 2 This is a structural block diagram of a data refresh device 200 provided in an embodiment of this application.
[0054] like Figure 2 As shown, the data refresh device 200 mainly includes: Module 201 is used to retrieve the data attributes of all requested data; Calculation module 202 is used to calculate the first priority of all requested data based on data attributes; The sorting module 203 is used to sort all requested data according to the first priority and obtain the sorting result; The communication module 204 is used to communicate with the PLC based on the sorting results to obtain the requested results.
[0055] As an optional implementation of this embodiment, the acquisition module 201 is further configured to, before acquiring the data attributes of all requested data, include: acquiring the address information of the requested data, the address information including address size and address type; registering the requested data based on the address information to obtain registration information, the registration information including registration count and registration age; acquiring the original request queue; determining whether the original request queue contains requested data based on the registration information; if it does, increasing the registration count and refreshing the registration age to obtain the refreshed age.
[0056] As an optional implementation of this embodiment, the calculation module 202 is further specifically used to calculate the first priority of all requested data based on the data attributes, including the second priority and the refresh age, including: obtaining the second priority based on the original request queue; assigning a first weight value to the second priority, assigning a second weight value to the refresh age and assigning a third weight value to the registration age; calculating the first priority value of the requested data based on the first weight value, the second weight value and the third weight value; and determining the first priority of each requested data based on the first priority value.
[0057] As an optional implementation of this embodiment, the calculation module 202 is further configured to, after determining the first priority of each requested data based on the first priority value, further include: obtaining the first weighting coefficient corresponding to the second priority, the second weighting coefficient of the refresh age, and the third weighting coefficient of the registration age; adjusting the first priority value based on the first weighting coefficient, the second weighting coefficient, and the third weighting coefficient to obtain the second priority value; and adjusting the first priority based on the second priority value to obtain the second priority.
[0058] As an optional implementation of this embodiment, the calculation module 202 is further specifically used to obtain the first weighted coefficient corresponding to the second priority, the second weighted coefficient for refreshing age, and the third weighted coefficient for registering age, including: obtaining the loop time of the scan request data; determining whether the loop time is greater than the preset scan time; if the loop time is greater than the preset scan time, obtaining the first weighted coefficient, the second weighted coefficient, and the third weighted coefficient based on the preset interval table; if the loop time is less than the preset scan time, setting the first weighted coefficient, the second weighted coefficient, and the third weighted coefficient to default coefficients.
[0059] As an optional implementation of this embodiment, the sorting module 203 is further specifically used to sort all request data according to a first priority, and the sorting result includes: determining whether the first priority value is greater than a preset threshold; if the first priority value is greater than the preset threshold, then establishing a first group of packets, the first group of packets including all request data whose first priority value is greater than the preset threshold; obtaining the minimum address and maximum address of the request data in the first group of packets; determining the address request range of the first group of packets based on the minimum address and maximum address; obtaining all request data within the address request range; adding all request data within the address request range to the first group of packets to form a second group of packets; and using the second group of packets as the sorting result.
[0060] As an optional implementation of this embodiment, the communication module 204 is further specifically used to communicate with the PLC based on the sorting result and obtain the request result. The method further includes: obtaining the number of registrations of the request data; determining whether the number of registrations is zero; if the number of registrations is zero, then canceling the request data in the sorting result with the registration count cleared to zero.
[0061] In one example, the module in any of the above devices may be one or more integrated circuits configured to implement the above methods, such as one or more application-specific integrated circuits (ASICs), or one or more digital signal processors (DSPs), or one or more field-programmable gate arrays (FPGAs), or a combination of at least two of these integrated circuit forms.
[0062] For example, when modules in a device can be implemented via a processing element scheduler, the processing element can be a general-purpose processor, such as a central processing unit (CPU) or other processor capable of calling programs. Alternatively, these modules can be integrated together as a system-on-a-chip (SOC).
[0063] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working process of the above-described device and module can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0064] Figure 3 This is a structural block diagram of the electronic device 300 provided in an embodiment of this application.
[0065] like Figure 3As shown, the electronic device 300 includes a processor 301 and a memory 302, and may further include one or more of an information input / output (I / O) interface 303, a communication component 304, and a communication bus 305.
[0066] The processor 301 controls the overall operation of the electronic device 300 to complete all or part of the steps of the data refresh method described above. The memory 302 stores various types of data to support the operation of the electronic device 300. This data may include, for example, instructions for any application or method operating on the electronic device 300, as well as application-related data. The memory 302 can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as one or more of Static Random Access Memory (SRAM), Electrically Erasable Programmable Read-Only Memory (EEPROM), Erasable Programmable Read-Only Memory (EPROM), Programmable Read-Only Memory (PROM), Read-Only Memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk.
[0067] I / O interface 303 provides an interface between processor 301 and other interface modules, such as keyboards, mice, and buttons. These buttons can be virtual or physical. Communication component 304 is used for wired or wireless communication between electronic device 300 and other devices. Wireless communication includes Wi-Fi, Bluetooth, Near Field Communication (NFC), 2G, 3G, or 4G, or a combination thereof. Therefore, the corresponding communication component 304 may include a Wi-Fi component, a Bluetooth component, and an NFC component.
[0068] The electronic device 300 may be implemented by one or more application-specific integrated circuits (ASICs), digital signal processors (DSPs), digital signal processing devices (DSPDs), programmable logic devices (PLDs), field-programmable gate arrays (FPGAs), controllers, microcontrollers, microprocessors, or other electronic components to execute the data refresh method given in the above embodiments.
[0069] The communication bus 305 may include a path for transmitting information between the aforementioned components. The communication bus 305 may be a PCI (Peripheral Component Interconnect) bus or an EISA (Extended Industry Standard Architecture) bus, etc. The communication bus 305 may be divided into an address bus, a data bus, a control bus, etc.
[0070] Electronic device 300 may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital radio receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), and in-vehicle terminals (such as in-vehicle navigation terminals), as well as fixed terminals such as digital TVs and desktop computers, and may also be servers.
[0071] This application also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the above-described data refresh method.
[0072] The computer-readable storage medium may include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0073] The terms “comprising,” “including,” or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.
[0074] The above description is merely a preferred embodiment of this application and an explanation of the technical principles employed. Those skilled in the art should understand that the scope of this application is not limited to technical solutions formed by specific combinations of the above-described technical features, but should also cover other technical solutions formed by arbitrary combinations of the above-described technical features or their equivalents without departing from the foregoing application concept. For example, technical solutions formed by substituting the above features with (but not limited to) technical features with similar functions claimed in this application.
Claims
1. A data refresh method, characterized in that, include: Retrieve the data attributes of all requested data; Calculate the first priority of all requested data based on the data attributes; All the requested data are sorted according to the first priority to obtain the sorting result; Based on the sorting results, the system communicates with the PLC to obtain the requested results; The data attributes include a second priority and a refresh age, and the calculation of the first priority of all requested data based on the data attributes includes: The second priority is obtained based on the original request queue, and the second priority is determined according to the frequency of change of each request data. Assign a first weight value to the second priority, a second weight value to the refresh age, and a third weight value to the registration age; Calculate a first priority value for the requested data based on the first weight value, the second weight value, and the third weight value; A first priority is determined for each of the requested data based on the first priority value; After determining the first priority of each requested data based on the first priority value, the method further includes: Obtain the first weighting coefficient corresponding to the second priority, the second weighting coefficient of the refresh age, and the third weighting coefficient of the registered age; The first priority value is adjusted based on the first weighting coefficient, the second weighting coefficient, and the third weighting coefficient to obtain the second priority value; The first priority is adjusted based on the second priority value to obtain the second priority; The step of obtaining the first weighted coefficient corresponding to the second priority, the second weighted coefficient of the refreshed age, and the third weighted coefficient of the registered age includes: Loop time for obtaining scan request data; Determine whether the loop time is greater than the preset scan time; If the loop time is greater than the preset scan time, the first weighting coefficient, the second weighting coefficient, and the third weighting coefficient are obtained based on the preset interval table. If the loop time is less than the preset scan time, the first weighting coefficient, the second weighting coefficient, and the third weighting coefficient are all set to default coefficients.
2. The method according to claim 1, characterized in that, Before retrieving the data attributes of all requested data, the method further includes: Obtain the address information of the requested data, the address information including address size and address type; The request data is registered based on the address information to obtain registration information, which includes the number of registrations and the age of the registrant. Retrieve the original request queue; Based on the registration information, determine whether the request data exists in the original request queue; If it exists, the registration count is increased, and the registered age is refreshed to obtain the refreshed age.
3. The method according to claim 1, characterized in that, The step of sorting all the request data according to the first priority to obtain the sorting result includes: Determine whether the first priority value is greater than a preset threshold; If the first priority value is greater than the preset threshold, then a first group of packets is established, and the first group of packets includes all request data whose first priority value is greater than the preset threshold; Obtain the minimum and maximum addresses of the request data in the first group of packets; The address request range of the first group of packets is determined based on the minimum address and the maximum address; Obtain all request data for the specified address request range; Add all request data within the specified address request range to the first packet to form the second packet; The second group of packages is used as the sorting result.
4. The method according to claim 1, characterized in that, After communicating with the PLC based on the sorting result to obtain the requested result, the method further includes: The number of times the requested data was registered; Determine whether the number of registrations is zero; If the number of registrations is zero, then the request data with zero registration counts in the sorting results will be revoked.
5. A data refresh device, characterized in that, include: The retrieval module is used to retrieve the data attributes of all requested data; The data attributes include second priority and refresh age; The calculation module is used to calculate the first priority of all requested data based on the data attributes; The calculation of the first priority of all requested data based on the data attributes includes: The second priority is obtained based on the original request queue, and the second priority is determined according to the frequency of change of each request data. Assign a first weight value to the second priority, a second weight value to the refresh age, and a third weight value to the registration age; Calculate a first priority value for the requested data based on the first weight value, the second weight value, and the third weight value; A first priority is determined for each of the requested data based on the first priority value; After determining the first priority of each requested data based on the first priority value, the method further includes: Obtain the first weighting coefficient corresponding to the second priority, the second weighting coefficient of the refresh age, and the third weighting coefficient of the registered age; The first priority value is adjusted based on the first weighting coefficient, the second weighting coefficient, and the third weighting coefficient to obtain the second priority value; The first priority is adjusted based on the second priority value to obtain the second priority; The step of obtaining the first weighted coefficient corresponding to the second priority, the second weighted coefficient of the refreshed age, and the third weighted coefficient of the registered age includes: Loop time for obtaining scan request data; Determine whether the loop time is greater than the preset scan time; If the loop time is greater than the preset scan time, the first weighting coefficient, the second weighting coefficient, and the third weighting coefficient are obtained based on the preset interval table. If the loop time is less than the preset scan time, then the first weighting coefficient, the second weighting coefficient, and the third weighting coefficient are all set to the default coefficients; The sorting module is used to sort all the request data according to the first priority to obtain a sorting result; The communication module is used to communicate with the PLC based on the sorting results to obtain the requested results.
6. An electronic device, characterized in that, Includes a processor, which is coupled to a memory; The processor is configured to execute a computer program stored in the memory, causing the electronic device to perform the method as described in any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, It includes a computer program or instructions that, when run on a computer, cause the computer to perform the method as described in any one of claims 1 to 4.
Citation Information
Patent Citations
Refresh task assignment method, electronic device, and computer readable storage medium
CN108595264A
Data ordering method and device, and node server
CN109412972A