Search

CN-121979464-A - Self-adaptive flow control method based on printing content characteristic analysis

CN121979464ACN 121979464 ACN121979464 ACN 121979464ACN-121979464-A

Abstract

The invention provides a self-adaptive flow control method based on printing content feature analysis, which relates to the field of thermal printer data flow control and comprises the steps of segmenting a data flow to be printed and obtaining an energy density value of each data segment based on extraction, calculating a virtual heat value in an iterative mode, calculating physical printing time consumption, calculating transmission time consumption according to the number of bytes of the data segment and the effective transmission rate of a communication interface, obtaining an actual time consumption of the data segment from the completion of sending to the completion of printing, obtaining an error ratio based on the ratio of the estimated time consumption to the actual time consumption, updating an error ratio queue by adopting a sliding window, calculating a standard deviation of the error ratio queue, determining a self-adaptive grading threshold according to the standard deviation, updating a reference coefficient according to the grade to which the error ratio belongs, and dynamically adjusting a heat dissipation attenuation coefficient based on actual time consumption feedback and a virtual heat state. The invention realizes accurate prediction and control of buffer overflow risk.

Inventors

  • WANG PENG
  • LIN ZHE
  • WANG GENG

Assignees

  • 武汉利楚商务服务有限公司

Dates

Publication Date
20260505
Application Date
20260403

Claims (10)

  1. 1. An adaptive flow control method based on print content feature analysis, comprising: S1, segmenting a data stream to be printed to obtain a plurality of data segments, and extracting energy density characteristics in different modes according to the types of the data segments to obtain energy density values of the data segments; S2, calculating a virtual heat value in an iterative mode, determining a temperature correction factor based on the relation between the virtual heat value and a safety threshold, and calculating physical printing time by combining the byte number of the data segment, the energy density value, the reference coefficient and the temperature correction factor, wherein the virtual heat value is obtained by superposing the energy density value of the current data segment after carrying out heat dissipation and attenuation treatment on the historical virtual heat value; S3, calculating transmission time according to the byte number of the data segment and the effective transmission rate of the communication interface, determining estimated time based on the physical printing time and the transmission time, and inserting waiting time before the data segment is transmitted when the physical printing time exceeds the transmission time, wherein the waiting time is the difference between the physical printing time and the transmission time; S4, obtaining the actual time consumption of the data segment from the completion of sending to the completion of printing, obtaining an error ratio based on the ratio of the estimated time consumption to the actual time consumption, updating an error ratio queue by adopting a sliding window, calculating the standard deviation of the error ratio queue, determining a self-adaptive grading threshold according to the standard deviation, updating a reference coefficient according to the grade to which the error ratio belongs, and adjusting a heat dissipation attenuation coefficient based on the error ratio when the virtual heat value exceeds a safety threshold and the error ratio meets a preset condition.
  2. 2. The adaptive streaming control method according to claim 1, wherein the data segment type includes a bitmap data segment and an instruction data segment, and step S1 specifically includes: When the data segment is a bitmap data segment, dividing the image into a plurality of slices in the vertical direction, traversing all pixel points in the slices, counting the number of black pixel points, and obtaining an energy density value of the slices based on the ratio of the number of black pixel points to the total number of pixel points of the slices; When the data segment is an instruction data segment, analyzing a printing control instruction sequence in the data stream, extracting character width amplification factor, character height amplification factor and thickening mode coefficient, and obtaining a time multiplying factor based on the multiplication relation of the three; and carrying out normalization processing on the time multiplying factor to obtain the energy density value of the instruction data segment.
  3. 3. The method for adaptively controlling flow based on print content feature analysis according to claim 1, wherein the calculating of the virtual heat value comprises the following specific steps: initializing virtual heat variables upon start-up of a printing device 0, Wherein the virtual heat variable For modeling printhead heat build-up conditions; When processing the first When the data segments are obtained, heat dissipation and attenuation treatment are carried out on the historical virtual heat value to obtain residual heat, and the residual heat and the normalized energy density value of the current data segment are accumulated to obtain an updated virtual heat value: ; Wherein, the Represent the first The virtual heat value of the individual data segments, To finish processing the first The virtual heat value after the data segment, For the heat dissipation and attenuation coefficient, Is the first Normalized energy density values for the individual data segments.
  4. 4. The adaptive flow control method based on print content feature analysis according to claim 3, wherein the temperature correction factor has a calculation formula: ; Wherein, the Represent the first The temperature correction factors for the individual data segments, As a function of the temperature-sensitive coefficient, Is a safe heat threshold.
  5. 5. The adaptive streaming method according to claim 2, wherein when the data segment is a bitmap data segment, the step of calculating the time consumed for physical printing is: Acquisition of the first The number of total pixel points, normalized energy density, temperature correction factors and bitmap reference coefficients of the corresponding slices of the bitmap data segments; Calculating physical printing time consumption of the bitmap data segment based on the product relation of total pixel number of the slice, normalized energy density, temperature correction factor and bitmap reference coefficient: ; Wherein, the Represent the first The physical printing of the bit map data segment is time consuming, Representing the reference coefficients of the bitmap, The number of total pixels is indicated, The height of the slice is indicated, The width of the slice is indicated, In order to normalize the energy density, Is the first Temperature correction factors for the individual bitmap data segments.
  6. 6. The adaptive streaming method according to claim 2, wherein when the data segment is an instruction data segment, the step of calculating the time consumed by the physical printing is: Acquisition of the first A time multiplying factor, a temperature correction factor and an instruction reference coefficient of each instruction data segment; calculating the physical printing time consumption of the instruction data segment based on the multiplication relation of the time multiplying factor, the temperature correcting factor and the instruction reference coefficient: ; Wherein, the Represent the first The physical printing of the individual pieces of instruction data is time consuming, As a reference coefficient of the instruction, Is the first The time magnification factor of each instruction data segment, Is the first A temperature correction factor for each of the command data segments.
  7. 7. The adaptive streaming control method based on print content feature analysis according to claim 1, wherein the step S3 specifically comprises: calculating the transmission time based on the ratio relation between the byte number of the data segment and the effective transmission rate of the communication interface; comparing the size relationship of physical printing time consumption and transmission time consumption: judging that buffer overflow risks exist when the physical printing time exceeds the transmission time, and calculating waiting time based on the difference between the buffer overflow risks and the transmission time; When the physical printing time does not exceed the transmission time, judging that the buffer overflow risk does not exist, and directly transmitting the data segment without inserting the waiting time; determining estimated time consumption according to the transmission time consumption and the physical printing time consumption: ; Wherein, the Representing the estimated time consumption of the ith data segment, Indicating that the transmission is time-consuming, Indicating that physical printing is time consuming.
  8. 8. The adaptive streaming control method based on print content feature analysis according to claim 1, wherein updating the error rate queue with the sliding window comprises: Initializing an error rate history queue, wherein the error rate history queue is used for storing latest errors Error ratio values for the individual data segments; When the first is After the printing of each data segment is completed, the actual time consumption of the data segment from the completion of transmission to the completion of printing is acquired, and the error ratio is calculated based on the ratio of the estimated time consumption to the actual time consumption ; Judging the current length of the error ratio history queue: if the queue length has reached Removing the oldest error rate value from the queue to keep the queue length constant Then inserting the newly calculated error ratio into the tail of the queue for updating the sliding window; if the queue length is not reached The error rate is directly inserted into the end of the queue for sliding window updating.
  9. 9. The adaptive streaming control method according to claim 8, wherein the determining the adaptive rating threshold according to the standard deviation comprises: calculating an average value and a standard deviation of the error ratio based on the error ratio history queue; setting an adaptive dead zone radius based on the product relation of standard deviation and noise margin coefficient, and restraining the dead zone radius not to be lower than a preset lower limit: ; Wherein, the The radius of the dead zone is indicated, Is the lower limit of the radius of the dead zone, For the noise margin coefficient to be a factor of the noise margin, Representing standard deviation; and forming a multi-stage correction area based on the dead zone radius, wherein the multi-stage correction area comprises a dead zone, a fine tuning area, a fast tuning area and an abnormal area, the upper bound of the fine tuning area is 2 times of the dead zone radius, and the upper bound of the fast tuning area is 3 times of the dead zone radius.
  10. 10. The adaptive flow control method based on print content feature analysis according to claim 9, wherein the adjusting the heat dissipation attenuation coefficient based on the error ratio specifically comprises: calculating the deviation degree of error ; Determining an error level according to the relation between the error deviation degree and the adaptive grading threshold value: When (when) Judging the dead zone, and not correcting the reference coefficient; When (when) When the learning rate is 0.1, the reference coefficient is corrected; When (when) When the learning rate is 0.5, the reference coefficient is corrected; When (when) Or (b) If the abnormal area is judged, the correction is not carried out; the calculation formula of reference coefficient correction is as follows: ; ; Wherein, the An updated bitmap reference coefficient representing a bitmap data segment, Representing pre-update bitmap reference coefficients for a bitmap data segment, An updated instruction reference coefficient representing the instruction data segment, Indicating the pre-update instruction reference coefficients of the instruction data segment, Representing a learning rate; Judging whether the virtual heat value exceeds a safety threshold value and whether the error deviation degree meets the requirement : If yes, entering a heat dissipation attenuation coefficient updating flow: ; Wherein, the Indicating the updated heat dissipation decay factor, In order to update the pre-update heat dissipation factor, For the learning rate of the heat dissipation decay factor, Representing the error ratio.

Description

Self-adaptive flow control method based on printing content characteristic analysis Technical Field The invention relates to the technical field of data flow control of thermal printers, in particular to a self-adaptive flow control method based on characteristic analysis of printing content. Background The thermal printer develops color of thermal paper by heating the print head, and its printing speed is significantly affected by the temperature of the print head. When continuously printing high-density images, the time consumption of actual printing is increased due to the fact that the temperature of a printing head is increased, and if an upper computer transmits data at a fixed speed, buffer area of the printer is easy to overflow, and the problems of data loss, messy codes or paper jam are caused. The existing flow control technology performs data transmission control through fixed delay or simple rate limitation, but cannot adapt to differences of different printing content densities, different equipment thermal characteristics and different communication environments. In practical application, the fixed delay strategy has the dilemma that the printing efficiency is obviously reduced when the conservative delay is set and the buffer can be prevented from overflowing, and the overflow risk still exists in a high-density printing scene when the more aggressive delay is set and the efficiency is improved. The control mode of the one-knife cutting is difficult to find a balance point between guaranteeing reliability and improving efficiency. Chinese patent CN112039835B discloses an adaptive polling time estimation method, apparatus, device and storage medium, which establishes a connection with a printer via TCP/IP protocol, polls the current remaining buffer of the querying printer before sending data, and sends data only when the remaining buffer is sufficient to accommodate one complete print frame. But it cannot perform fine flow control according to the print content, and a problem of improper buffer management may occur in a long-time continuous print scene. Disclosure of Invention In view of the above, the invention provides a self-adaptive flow control method based on printing content feature analysis, so as to solve the technical problem that the flow control strategy in the prior art cannot adapt to improper buffer management during long-time continuous printing caused by printing content density difference, and realize accurate prediction and control of buffer overflow risk. The technical scheme of the invention is realized in such a way that the invention provides a self-adaptive flow control method based on printing content characteristic analysis, which comprises the following steps: S1, segmenting a data stream to be printed to obtain a plurality of data segments, and extracting energy density characteristics in different modes according to the types of the data segments to obtain energy density values of the data segments; S2, calculating a virtual heat value in an iterative mode, determining a temperature correction factor based on the relation between the virtual heat value and a safety threshold, and calculating physical printing time by combining the byte number of the data segment, the energy density value, the reference coefficient and the temperature correction factor, wherein the virtual heat value is obtained by superposing the energy density value of the current data segment after carrying out heat dissipation and attenuation treatment on the historical virtual heat value; S3, calculating transmission time according to the byte number of the data segment and the effective transmission rate of the communication interface, determining estimated time based on the physical printing time and the transmission time, and inserting waiting time before the data segment is transmitted when the physical printing time exceeds the transmission time, wherein the waiting time is the difference between the physical printing time and the transmission time; S4, obtaining the actual time consumption of the data segment from the completion of sending to the completion of printing, obtaining an error ratio based on the ratio of the estimated time consumption to the actual time consumption, updating an error ratio queue by adopting a sliding window, calculating the standard deviation of the error ratio queue, determining a self-adaptive grading threshold according to the standard deviation, updating a reference coefficient according to the grade to which the error ratio belongs, and adjusting a heat dissipation attenuation coefficient based on the error ratio when the virtual heat value exceeds a safety threshold and the error ratio meets a preset condition. On the basis of the above technical solution, preferably, the data segment type includes a bitmap data segment and an instruction data segment, and step S1 specifically includes: When the data segment is a bitmap data segment, dividing the image