Gas detector data transmission method, receiving method and remote data transmission system
By using the BMP bitmap file format to transmit gas detector data, the problem of incompatibility between the gas detector and the client device communication protocol was solved, achieving cross-manufacturer product compatibility and high-definition display, and reducing maintenance work.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- HENAN HANWEI ELECTRONICS
- Filing Date
- 2024-08-27
- Publication Date
- 2026-07-14
AI Technical Summary
The existing communication protocols between gas detectors and client devices are incompatible, which means that different manufacturers or different series of products from the same manufacturer need to develop separate client device programs, and the data format needs to be adjusted synchronously when it changes, which increases the product development and maintenance work.
Data transmission is performed using BMP bitmap file format. After the gas detector generates the data to be transmitted, it imports a preset image template to generate a BMP bitmap file and sends it to the client. The client calculates the scaling ratio based on the image size and screen size for display.
It achieves compatibility with different manufacturers and product series, reduces subsequent product maintenance work, and allows the client to directly display high-definition images without parsing, adapting to any device screen resolution.
Smart Images

Figure CN119147691B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a data transmission method, specifically, to a gas detector data transmission method, a data reception method, and a remote data transmission system. Background Technology
[0002] A gas detector is an instrument for detecting gas concentration. It is suitable for hazardous locations where flammable or toxic gases are present. It can continuously detect the content of the gas being tested in the air for a long period of time and is widely used in various industries such as gas, petrochemical, metallurgy, steel, coking, and power where flammable or toxic gases are present.
[0003] In practical applications, gas detectors typically use LEDs, segment displays, or LCD screens to indicate gas concentration data or alarm status. Data is transmitted via wired or wireless communication using specific communication protocols, and client devices use the same protocols to receive, parse, and display the data. This communication transmission method has the following problems:
[0004] 1. Due to the need to use specific communication protocols for data transmission, different manufacturers or different series of products from the same manufacturer often develop their own communication protocol formats due to differences in video memory content or data format. This results in the incompatibility of communication protocols between products, and often requires the separate development of corresponding client device programs.
[0005] 2. Since the gas detector and the client device need to communicate using the same communication protocol, if the content of the gas detector's memory or the data format changes, the programs of the gas detector and the client device need to be adjusted synchronously, which increases the product development and maintenance work.
[0006] In order to solve the above problems, people have been seeking an ideal technological solution. Summary of the Invention
[0007] The purpose of this invention is to address the shortcomings of existing technologies by providing a method for transmitting and receiving data from a gas detector, as well as a remote data transmission system.
[0008] To achieve the above objectives, the technical solution adopted by the present invention is as follows:
[0009] The first aspect provides a method for transmitting data from a gas detector, which is applied to a gas detector. The gas detector has a video memory space in its CPU RAM. The gas detector generates data to be transmitted based on the detection results. The data to be transmitted includes at least alarm status, gas type, and concentration information.
[0010] The method includes:
[0011] Import the data to be transmitted into the preset image template to generate the image to be transmitted;
[0012] After acquiring the image to be transmitted, the image is output to the video memory space through the display function to generate the video memory content;
[0013] The video memory content is converted into corresponding BMP bitmap file data according to the BMP bitmap file format and sent to the client. The client can then obtain the BMP bitmap file data, generate a BMP file based on the BMP bitmap file data, and display it.
[0014] Preferably, the data to be transmitted is imported into a preset image template to generate the image to be transmitted, including:
[0015] The data to be transmitted is written into the corresponding position in the preset image template with a first color and a specified element type to obtain an initial image; the element type includes at least character elements and numeric elements, wherein the non-specified position of the preset image template is set to the second color, the alarm status and gas type correspond to character elements, and the concentration information corresponds to numeric elements;
[0016] Extract the inner and outer edge pixels of the first color region from the initial image;
[0017] Change the pixel color of the inner and outer edge pixels of the first color region to the specified color to form the image to be transmitted.
[0018] Preferably, the preset image template also includes at least one dynamic chart element, the edge pixels of each dynamic chart element are defined as a second color, different dynamic chart elements have different types and correspond to a unique standard threshold;
[0019] During the process of generating an initial image by writing the data to be transmitted into the corresponding position in the preset image template with the first color and the specified element type, for each dynamic chart element, the chart display ratio is calculated based on the data to be transmitted and the standard threshold corresponding to the dynamic chart element. The dynamic chart element is filled with the third color according to the chart display ratio, and the edge pixels of the dynamic chart element are modified to the third color.
[0020] The steps for obtaining the third color are as follows: the chart display ratio value is encoded using error correction coding, and the encoded data is mapped to a color index. The color index is then converted to RGB color by looking up the color index table, and this RGB color is the third color.
[0021] Preferably, when drawing the outer contour according to the preset pixel width and the specified color, different element types correspond to different specified colors, and the specified colors are different from the first color, the second color and the third color.
[0022] A second aspect provides a gas detector data receiving method, applied to a client connected to a gas detector, wherein the client receives BMP bitmap file data sent by the gas detector based on the aforementioned gas detector data sending method, the method comprising:
[0023] After receiving BMP bitmap file data sent by the gas detector based on the gas detector data transmission method provided in the first aspect, the scaling ratio is calculated according to the image size in the BMP bitmap file data and its own screen size, and a target BMP bitmap of the screen size is generated and displayed according to the received BMP bitmap file data and the scaling ratio.
[0024] The third aspect provides a gas detector, which includes a CPU, a data acquisition unit, a storage unit, and a data transmission device;
[0025] The acquisition unit is used to acquire the gas signal to be measured;
[0026] The CPU generates data to be transmitted based on the acquired raw electrical signals;
[0027] The storage unit is used to store data to be transmitted;
[0028] After acquiring the data to be transmitted, the data transmitting device executes the data transmitting method proposed in the first aspect to generate BMP bitmap file data and send it to the client.
[0029] The fourth aspect provides a client, including a display module and a data receiving device, wherein the data receiving device is used to execute the data receiving method provided in the second aspect to generate a target BMP bitmap; and the display module is used to display the target BMP bitmap sent by the data receiving device.
[0030] In one embodiment, the client is further provided with a command button for obtaining a clear BMP bitmap and an element graphics library, wherein the element graphics library contains character element graphics and number element graphics of different resolutions and sizes.
[0031] When a command to obtain a clear BMP bitmap is received, an intermediate BMP bitmap of the screen size is generated, in which all pixels in the intermediate BMP bitmap are white.
[0032] In the target BMP bitmap that has been obtained, the color matching algorithm is used to search for the region composed of colors whose color difference with the specified color is within a preset threshold range, and the target element graphic is obtained.
[0033] Iterate through each target element image, obtain the position of the target element graphic in the target BMP bitmap, and take the same position in the intermediate BMP bitmap as the paste position;
[0034] Search the specified element graphic library for element graphics that have the same outline and size as the target element graphic as candidate graphics;
[0035] Select the image that matches the screen resolution from the candidate images as the target image, and paste the target image into the pasting position in the middle BMP bitmap;
[0036] After the traversal is complete, delete the original target BMP bitmap and display the intermediate BMP bitmap after pasting the graphic as the target BMP bitmap.
[0037] Furthermore, the element graphic library also includes dynamic chart graphics, each of which is associated with a chart display ratio value.
[0038] In the target BMP bitmap, a color matching algorithm is used to search for regions composed of colors whose color difference with the third color is within a preset threshold range to obtain a dynamic chart graphic. The position of the dynamic chart graphic in the target BMP bitmap is obtained, and the same position in the intermediate BMP bitmap is used as the pasting position. In the specified element graphic library, a graphic with the same outline, size, and percentage value as the dynamic chart graphic is searched as a candidate graphic, and a graphic with the same screen resolution is selected from the candidate graphic as the target graphic. The target graphic is then pasted into the pasting position in the intermediate BMP bitmap.
[0039] The steps for obtaining the chart display ratio are as follows: while calculating the scaling ratio based on the image size in the BMP bitmap file data and the screen size, the BMP bitmap file data is traversed to find a third color that is different from the first color, the second color, and the specified color. The RGB color is converted into a color index by looking up the color index table, and the color index is decoded to obtain the chart display ratio.
[0040] The fifth aspect provides a remote data transmission system for a gas detector, including the aforementioned gas detector and at least one client, wherein the client is the aforementioned client and the gas detector is communicatively connected to the client.
[0041] This invention has outstanding substantive features and significant progress compared to the prior art. Specifically, this invention uses a unified data format for transmission, achieving compatibility between different manufacturers and different product series.
[0042] The client does not perform any parsing; it directly calculates the scaling ratio based on the image size in the BMP bitmap file data and its own screen size, and generates a target BMP bitmap of the screen size for display based on the received BMP bitmap file data and scaling ratio, reducing later product maintenance work; and because the BMP bitmap structure is simple and does not involve image compression, it can be used on any device.
[0043] Specifically, before generating the BMP bitmap file, the gas detector uses different colors as the outlines of the elements. This allows the client to find the element graphic of the corresponding size and resolution in the specified element graphic library based on the element graphic corresponding to the outline when they want to obtain a high-definition image. The client then pastes the element graphic into the corresponding position in the middle BMP bitmap, thereby obtaining a BMP bitmap file adapted to the screen resolution and screen size, and achieving a high-definition display effect. Attached Figure Description
[0044] Figure 1 This is a flowchart illustrating the data transmission method described in Embodiment 1 of the present invention.
[0045] Figure 2 This is a schematic diagram of the image to be transmitted in Embodiment 1 of the present invention.
[0046] Figure 3 This is a schematic diagram of the gas detector described in Embodiment 4 of the present invention.
[0047] Figure 4 This is a schematic diagram of the process for obtaining a clear BMP bitmap as described in Embodiment 6 of the present invention.
[0048] Figure 5 This is a schematic diagram of the structure of the gas detector remote data transmission system described in Embodiment 8 of the present invention.
[0049] Figure 6 This is a schematic flowchart of the remote data transmission system for the gas detector described in Embodiment 8 of the present invention. Detailed Implementation
[0050] Bitmap (BMP) files are a hardware-independent image file format that is widely used. They employ a bitmapped storage format and, apart from selectable image depth, do not use any other compression; therefore, BMP files can be quite large.
[0051] Specifically, a BMP file consists of four parts: a file header, a bitmap information header, color information, and image data. The file header provides information such as the file format and size; specifically, it includes a 2-byte data flag BM, indicating the BMP format supported by Windows; a 4-byte file data length; a bitmap information header that provides information such as the image data size, number of bit planes, compression method, and color index; color information, which is a mapping table of indexes and their corresponding colors; and an image data array byte, which is the image data.
[0052] The technical solution of the present invention will be further described in detail below through specific embodiments.
[0053] Example 1
[0054] This embodiment provides a data transmission method for a gas detector. The gas detector's CPU RAM includes a bitmap display memory space. The gas detector generates data to be transmitted based on the detection results. The data to be transmitted includes at least alarm status, gas type, and concentration information. The CPU's FLASH memory also stores display functions. These display memory functions include the display memory layout of the LCD screen, such as selecting a one-dimensional or two-dimensional display memory layout.
[0055] The method is as follows Figure 1 As shown, it includes:
[0056] After acquiring the data to be transmitted, the data is imported into a preset image template to generate the image to be transmitted; the preset image template includes resolution parameters, image size parameters, content type, and corresponding content placement position; for example... Figure 2 The image shown is a schematic diagram of an image to be transmitted. It can be seen that the image to be transmitted includes concentration information, alarm information, and the type of gas detected. In some embodiments, the image to be transmitted also includes dynamic charts, such as a graphical display of the lower explosive limit percentage and the gas flow rate.
[0057] The video memory content is converted into corresponding BMP bitmap file data according to the BMP bitmap file format and sent to the client. The client can then obtain the BMP bitmap file data, generate a BMP file based on the BMP bitmap file data, and display it.
[0058] Example 2
[0059] This embodiment provides a specific implementation of generating an image to be transmitted.
[0060] In this embodiment, importing the data to be transmitted into a preset image template to generate the image to be transmitted includes:
[0061] The data to be transmitted is written into the corresponding position in the preset image template with a first color and a specified element type to obtain an initial image; the element type includes at least character elements and numeric elements, wherein the non-specified position of the preset image template is set to the second color, the alarm status and gas type correspond to character elements, and the concentration information corresponds to numeric elements.
[0062] Extract the inner and outer edge pixels of the first color region from the initial image;
[0063] Change the pixel color of the inner and outer edge pixels of the first color region to the specified color to form the image to be transmitted.
[0064] It is understandable that the first color and the second color are different colors. For example, if the first color is pure black, then the second color can be pure white.
[0065] The purpose of this technical solution is to enable different clients to regenerate high-definition BMP bitmaps that meet their requirements based on their screen resolution, screen size, and outlines formed by specified colors, and then display them.
[0066] Specifically, in the implementation process, different specified colors can be assigned to the inner and outer edge pixels of the first color area corresponding to different element types. The specified colors are different from the first, second, and third colors, so that the outlines of different elements can be obtained according to different colors and searched separately.
[0067] Furthermore, the preset image template also includes at least one dynamic chart element, with the edge pixels of each dynamic chart element defined as a second color. Different dynamic chart elements have different types and correspond to a unique standard threshold.
[0068] During the process of generating an initial image by writing the data to be transmitted into the corresponding position in the preset image template with the first color and the specified element type, for each dynamic chart element, the chart display ratio is calculated based on the data to be transmitted and the standard threshold corresponding to the dynamic chart element. The dynamic chart element is filled with the third color according to the chart display ratio, and the edge pixels of the dynamic chart element are modified to the third color.
[0069] The steps for obtaining the third color are as follows: the chart display ratio value is encoded using error correction coding, and the encoded data is mapped to a color index. The color index is then converted to RGB color by looking up the color index table, and this RGB color is the third color.
[0070] In practice, to distinguish the third color from the second and first colors, you can first obtain the third color, and then set the first and second colors respectively.
[0071] The purpose of designing the third color is to allow for the derivation of the chart display scale based on the third color when regenerating high-resolution BMP bitmaps to meet the client's requirements on different clients. This allows for the lookup of charts with the corresponding scale for display. Further details will not be elaborated here; please refer to subsequent descriptions.
[0072] Example 3
[0073] This embodiment provides a gas detector data receiving method, applied to a client connected to a gas detector. The client receives BMP bitmap file data sent by the gas detector based on a gas detector data sending method described in any one of embodiments 1-2. Preferably, the client is a cloud platform, controller, PC, handheld device, etc. It can be seen that different types of clients have different screen sizes and resolution requirements, so the size and resolution of the BMP bitmap need to be adjusted according to actual needs.
[0074] Specifically, the data receiving method includes: after acquiring BMP bitmap file data, calculating the scaling ratio based on the image size in the BMP bitmap file data and the screen size itself, and generating a target BMP bitmap of the screen size for display based on the received BMP bitmap file data and the scaling ratio.
[0075] Example 4
[0076] This embodiment provides a gas detector, such as Figure 3 As shown, the gas detector includes a CPU, a data acquisition unit, a storage unit, and a data transmission device;
[0077] The acquisition unit is used to acquire the gas signal to be measured;
[0078] The CPU generates data to be transmitted based on the acquired raw electrical signals;
[0079] The storage unit is used to store data to be transmitted;
[0080] After acquiring the data to be transmitted, the data sending device executes the data sending method described in Embodiment 1 or Embodiment 2 to generate BMP bitmap file data and send it to the client.
[0081] In one embodiment, the data transmitting device may be a device or module that has the data transmitting method described in Embodiment 1 or Embodiment 2 built in.
[0082] In one embodiment, the data transmitting device includes:
[0083] Bitmap video memory space is located in the CPU's RAM and is used to store video memory contents; display functions are located in the CPU's FLASH.
[0084] The generation module is used to import the data to be transmitted into a preset image template and generate the image to be transmitted.
[0085] The mode conversion module is used to call the display function to output the data to be transmitted to the bitmap video memory space to obtain the video memory content;
[0086] The format conversion unit will generate corresponding BMP bitmap file data from the video memory content according to the BMP bitmap file format.
[0087] The communication unit communicates with the client and sends out the BMP bitmap file data.
[0088] Example 5
[0089] This embodiment provides a client, including a display module, an element graphics library, and a data receiving device. The data receiving device is used to execute the data receiving method described in Embodiment 3 to generate a target BMP bitmap. The display module is used to display the target BMP bitmap sent by the data receiving device.
[0090] Specifically, the client can be at least one of a cloud platform, a controller, a PC, or a handheld device, and the handheld device can include a mobile phone or a specially customized monitoring terminal.
[0091] In one embodiment, the data receiving device is a device or module that has the data receiving method described in Embodiment 3 built in.
[0092] In another embodiment, the data receiving device, located on the client, includes:
[0093] The scaling module calculates the scaling ratio based on the bitmap dimensions in the BMP bitmap file data and the screen size itself.
[0094] The restoration module generates a target BMP bitmap of the screen size based on the received BMP bitmap file data and the scaling ratio.
[0095] Example 6
[0096] The difference between this embodiment and embodiment 5 is as follows:
[0097] The client also includes command buttons for obtaining clear BMP bitmaps and an element graphics library, which contains character and number element graphics of different resolutions and sizes.
[0098] like Figure 6 As shown, when a command to obtain a clear BMP bitmap is received, an intermediate BMP bitmap of the screen size is generated, in which all pixels in the intermediate BMP bitmap are white.
[0099] In the target BMP bitmap that has been obtained, the color matching algorithm is used to search for the region composed of colors whose color difference with the specified color is within a preset threshold range, and the target element graphic is obtained.
[0100] Iterate through each target element image, obtain the position of the target element graphic in the target BMP bitmap, and take the same position in the intermediate BMP bitmap as the paste position;
[0101] Search the specified element graphic library for element graphics that have the same outline and size as the target element graphic as candidate graphics;
[0102] Select the image that matches the screen resolution from the candidate images as the target image, and paste the target image into the pasting position in the middle BMP bitmap;
[0103] After the traversal is complete, delete the original target BMP bitmap and display the intermediate BMP bitmap after pasting the graphic as the target BMP bitmap.
[0104] As is well known, bitmaps and resolution are directly related; higher resolution bitmaps have higher clarity, and their magnification also increases accordingly. Therefore, gas detectors use higher resolutions to generate images for transmission. Higher resolution means more pixels per unit length, so the size of each pixel changes less during scaling, thus maintaining image detail and clarity. However, when the magnification of a bitmap exceeds its optimal resolution, detail loss and jagged edges occur. To solve this problem, this embodiment allows users to activate the above technical solution by pressing the command button to obtain a clear BMP bitmap when they want to acquire a high-definition image. Based on the element graphic corresponding to the outline, the system searches for an element graphic of the corresponding size and resolution in a specified element graphic library and pastes this element graphic into the corresponding position in the intermediate BMP bitmap, thereby obtaining a BMP bitmap file adapted to the screen resolution and screen size, achieving a high-definition display effect.
[0105] However, this is on the premise that the gas detector must generate the image to be transmitted in the manner described in Example 2, so that the outline of the element graphic can be found based on the preset color in this example.
[0106] It should be noted that under normal circumstances, it is only necessary to use the data receiving method described in Example 5 to generate a target BMP bitmap for display. Only when the monitoring personnel cannot see the displayed BMP bitmap clearly or find that the data in the BMP is abnormal, is it necessary to further obtain a clear BMP bitmap by pressing the command button to activate the above technical solution to obtain a high-definition image for verification or saving.
[0107] Specifically, when the gas detector changes the pixel color of the inner and outer edge pixels of the first color region to a specified color, it assigns different specified colors to the inner and outer edge pixels of the first color region corresponding to different element types. For example, the inner and outer edge pixels of the first color region corresponding to character elements are assigned the fourth color, and the inner and outer edge pixels of the first color region corresponding to number elements are assigned the fifth color. The fourth color and the fifth color are different and are different from the first color, the second color, and the third color, respectively.
[0108] When the client obtains the target element graphic by searching for regions composed of colors whose color difference with the specified color is within a preset threshold range in the already obtained target BMP bitmap using a color matching algorithm, it executes:
[0109] Traverse the element types. For each element type, obtain its corresponding specified color, such as the fourth or fifth color, according to the element type and color mapping table. In the target BMP bitmap, use a color matching algorithm to search for the region composed of colors whose color difference with the specified color is within a preset threshold range, thereby obtaining several contour regions and the target element graphic.
[0110] The client searches for element graphics in a specified element graphics library that have the same outline and size as the target element graphic as candidate graphics, including:
[0111] Search for element graphics of the same type as the target element graphic in the corresponding element graphic group of the specified element graphic library as candidate graphics;
[0112] The element graphic library is set in the client, and the element graphic library contains character element graphics and number element graphics of different resolutions and sizes. Element graphics of the same type belong to the same element graphic group.
[0113] To make it easier to understand, let's take the data 30.2 as an example to illustrate how to obtain the graph corresponding to 30.2.
[0114] Based on the element type and color mapping table, the fifth color corresponding to data 30.2 is obtained. In the target BMP bitmap, the color matching algorithm is used to search for the region composed of colors whose color difference with the fifth color is within the preset threshold range, thus obtaining 3 contour regions, namely the three target element graphics "3", "0" and "2".
[0115] Find the target element graphic "3". In the specified element graphic library, find element graphics with the same outline and size as the target element graphic "3" as candidate graphics. Select the graphic with the same screen resolution as the target graphic from the candidate graphics and paste the target graphic into the pasting position in the middle BMP bitmap.
[0116] Continue searching for the target element graphic "0". In the specified element graphic library, find the element graphic with the same outline and size as the target element graphic "3" in the group of number element graphic as a candidate graphic. Select the graphic with the same screen resolution as the target graphic from the candidate graphic and paste the target graphic into the pasting position in the middle BMP bitmap.
[0117] Find the target element graphic "2". In the specified element graphic library, find the element graphic with the same outline and size as the target element graphic "3" in the group of digital element graphics as the candidate graphic. Select the graphic with the same screen resolution as the target graphic from the candidate graphic and paste the target graphic into the pasting position in the middle BMP bitmap.
[0118] The method for searching character elements is the same as that for searching numeric elements, and will not be repeated here. It should be noted that character elements include both alphabetic characters and symbolic characters, such as "." and "%".
[0119] Example 7
[0120] The difference between this embodiment and embodiment 6 is that the element graphic library also includes dynamic chart graphics, and each dynamic chart graphic is associated with a chart display ratio value;
[0121] In the target BMP bitmap, a color matching algorithm is used to search for regions composed of colors whose color difference with the third color is within a preset threshold range to obtain a dynamic chart graphic. The position of the dynamic chart graphic in the target BMP bitmap is obtained, and the same position in the intermediate BMP bitmap is used as the pasting position. In the specified element graphic library, a graphic with the same outline, size, and percentage value as the dynamic chart graphic is searched as a candidate graphic, and a graphic with the same screen resolution is selected from the candidate graphic as the target graphic. The target graphic is then pasted into the pasting position in the intermediate BMP bitmap.
[0122] The steps for obtaining the chart display ratio are as follows: while calculating the scaling ratio based on the image size in the BMP bitmap file data and the screen size, the BMP bitmap file data is traversed to find a third color that is different from the first color, the second color, and the specified color. The RGB color is converted into a color index by looking up the color index table, and the color index is decoded to obtain the chart display ratio.
[0123] The purpose of this embodiment is to illustrate that when regenerating high-definition BMP bitmaps that meet the client's requirements on different clients in the future, the chart display ratio can also be deduced from the third color, and the corresponding chart ratio can be queried and displayed based on the chart display ratio, thereby obtaining a dynamic icon with the correct high-definition chart display ratio.
[0124] Example 8
[0125] This embodiment provides a remote data transmission system for a gas detector, such as... Figure 5 and 6 As shown, the gas detector includes the gas detector described in Embodiment 4, and also includes at least one client, which is the client described in Embodiment 5, 6 or 7, and the gas detector is communicatively connected to the client.
[0126] Specifically, the client can be at least one of a cloud platform, a controller or PC, or a handheld device. The cloud platform communicates with the gas detector via 4G / NB, the controller or PC communicates with the gas detector via RS485 / CAN / ETH, and the controller or PC communicates with the gas detector via BLE / WIFI.
[0127] Because BMP bitmap data can be transmitted via different communication protocols, this embodiment leverages this feature. Instead of transmitting the actual data, it converts the data into an image and ultimately generates a BMP bitmap file for transmission. By using the BMP bitmap data format, compatibility with different manufacturers and product series is achieved. The client, without any parsing, directly calculates the scaling ratio based on the image dimensions in the BMP bitmap file data and its own screen size. It then generates a target BMP bitmap of the desired screen size for display based on the received BMP bitmap file data and the scaling ratio, reducing subsequent product maintenance work. Furthermore, due to the simple structure of BMP bitmaps and the absence of image compression, it can be used on any device.
[0128] The gas detector collects the gas signal to be measured, generates data to be transmitted based on the collected raw electrical signal, imports the data to be transmitted into a preset image template to generate an image to be transmitted; after acquiring the image to be transmitted, the image to be transmitted is output to the video memory space through a display function to generate video memory content; the video memory content is generated into corresponding BMP bitmap file data according to the BMP bitmap file format and sent to the client.
[0129] After obtaining the BMP bitmap file data, the client generates a BMP file based on the BMP bitmap file data and displays it.
[0130] Specifically, when the client is the client described in Example 6,
[0131] When the gas detector changes the pixel color of the inner and outer edge pixels of the first color region to a specified color, it can assign different specified colors to the inner and outer edge pixels of the first color region corresponding to different element types, and the specified colors are different from the first color, the second color and the third color.
[0132] When the client obtains the target element graphic from the already acquired target BMP bitmap, it searches for regions composed of colors whose color difference with the specified color is within a preset threshold range using a color matching algorithm. Then, it executes the following:
[0133] Traverse the element types. For each element type, obtain its corresponding specified color according to the element type and color mapping table. In the target BMP bitmap, use a color matching algorithm to search for the region composed of colors whose color difference with the specified color is within a preset threshold range, thereby obtaining several contour regions and the target element graphic.
[0134] The client searches for element graphics in a specified element graphics library that have the same outline and size as the target element graphic as candidate graphics, including:
[0135] Search for element graphics of the same type as the target element graphic in the corresponding element graphic group of the specified element graphic library as candidate graphics;
[0136] The element graphic library is set in the client, and the element graphic library contains character element graphics and number element graphics of different resolutions and sizes. Element graphics of the same type belong to the same element graphic group.
[0137] The above technical solution enables the client to obtain BMP bitmap files adapted to the screen resolution and screen size, achieving a high-definition display effect.
[0138] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention and not to limit them; although the present invention has been described in detail with reference to preferred embodiments, those skilled in the art should understand that modifications can still be made to the specific implementation of the present invention or equivalent substitutions can be made to some technical features without departing from the spirit of the technical solutions of the present invention, and all such modifications and substitutions should be covered within the scope of the technical solutions claimed in the present invention.
Claims
1. A method for transmitting data from a gas detector, applied to a gas detector, characterized in that, The gas detector has a video memory space in its CPU RAM. The gas detector generates data to be transmitted based on the detection results. The data to be transmitted includes at least the alarm status, gas type, and concentration information. The method includes: Import the data to be transmitted into the preset image template to generate the image to be transmitted; the steps are as follows: The data to be transmitted is written into the corresponding position in the preset image template with a first color and a specified element type to obtain an initial image; the element type includes at least character elements and numeric elements, wherein the non-specified position of the preset image template is set to the second color, the alarm status and gas type correspond to character elements, and the concentration information corresponds to numeric elements; Extract the inner and outer edge pixels of the first color region from the initial image; Change the pixel color of the inner and outer edge pixels of the first color region to the specified color to form the image to be transmitted; The preset image template also includes at least one dynamic chart element. The edge pixels of each dynamic chart element are defined as a second color. Different dynamic chart elements have different types and correspond to a unique standard threshold. During the process of generating an initial image by writing the data to be transmitted into the corresponding position in the preset image template with the first color and the specified element type, for each dynamic chart element, the chart display ratio is calculated based on the data to be transmitted and the standard threshold corresponding to the dynamic chart element. The dynamic chart element is filled with the third color according to the chart display ratio, and the edge pixels of the dynamic chart element are modified to the third color. The steps for obtaining the third color are as follows: the chart display ratio value is encoded using error correction coding, and the encoded data is mapped to a color index. The color index is converted to RGB color by looking up the color index table, and this RGB color is the third color. After acquiring the image to be transmitted, the image is output to the video memory space through the display function to generate the video memory content; The video memory content is converted into corresponding BMP bitmap file data according to the BMP bitmap file format and sent to the client. The client can then obtain the BMP bitmap file data, generate a BMP file based on the BMP bitmap file data, and display it.
2. A method for receiving data from a gas detector, applied to a client connected to a gas detector, characterized in that, The method includes: After receiving BMP bitmap file data sent by the gas detector based on the gas detector data transmission method according to claim 1, the scaling ratio is calculated according to the image size in the BMP bitmap file data and its own screen size, and a target BMP bitmap of the screen size is generated and displayed according to the received BMP bitmap file data and the scaling ratio.
3. A gas detector, characterized in that, The gas detector includes a CPU, a data acquisition unit, a storage unit, and a data transmission device; The acquisition unit is used to acquire the gas signal to be measured; The CPU generates data to be transmitted based on the acquired raw electrical signals; The storage unit is used to store data to be transmitted; After acquiring the data to be transmitted, the data sending device executes the data sending method of claim 1 to generate BMP bitmap file data and send it to the client.
4. A client application, characterized in that, It includes a display module, an element graphics library, and a data receiving device, wherein the data receiving device is used to execute the data receiving method according to claim 2 to generate a target BMP bitmap; The display module is used to display the target BMP bitmap sent by the data receiving device; The client also includes command buttons for obtaining clear BMP bitmaps and an element graphics library, which contains character and number element graphics of different resolutions and sizes. When a command to obtain a clear BMP bitmap is received, an intermediate BMP bitmap of the screen size is generated, in which all pixels in the intermediate BMP bitmap are white. In the target BMP bitmap that has been obtained, the color matching algorithm is used to search for the region composed of colors whose color difference with the specified color is within a preset threshold range, and the target element graphic is obtained. Iterate through each target element image, obtain the position of the target element graphic in the target BMP bitmap, and use the same position in the intermediate BMP bitmap as the paste position. Search the specified element graphic library for element graphics that have the same outline and size as the target element graphic as candidate graphics; Select the image that matches the screen resolution from the candidate images as the target image, and paste the target image into the pasting position in the middle BMP bitmap; After the traversal is complete, delete the original target BMP bitmap and display the intermediate BMP bitmap after pasting the graphic as the target BMP bitmap; The element graphics library also includes dynamic chart graphics, each of which is associated with a chart display ratio value. In the target BMP bitmap, a color matching algorithm is used to search for regions composed of colors whose color difference with the third color is within a preset threshold range to obtain a dynamic chart graphic. The position of the dynamic chart graphic in the target BMP bitmap is obtained, and the same position in the intermediate BMP bitmap is used as the pasting position. In the specified element graphic library, a graphic with the same outline, size, and percentage value as the dynamic chart graphic is searched as a candidate graphic, and a graphic with the same screen resolution is selected from the candidate graphic as the target graphic. The target graphic is then pasted into the pasting position in the intermediate BMP bitmap. The steps for obtaining the chart display ratio are as follows: while calculating the scaling ratio based on the image size in the BMP bitmap file data and the screen size, the BMP bitmap file data is traversed to find a third color that is different from the first color, the second color, and the specified color. The RGB color is converted into a color index by looking up the color index table, and the color index is decoded to obtain the chart display ratio.
5. A remote data transmission system for a gas detector, characterized in that: The gas detector includes the gas detector of claim 3, and further includes at least one client, the client being the client of claim 4, and the gas detector is communicatively connected to the client.
6. A remote data transmission system for a gas detector according to claim 5, characterized in that: When the gas detector changes the pixel color of the inner and outer edge pixels of the first color region to a specified color, it can assign different specified colors to the inner and outer edge pixels of the first color region corresponding to different element types, and the specified colors are different from the first color, the second color and the third color. When the client obtains the target element graphic from the already acquired target BMP bitmap, it searches for regions composed of colors whose color difference with the specified color is within a preset threshold range using a color matching algorithm. Then, it executes the following: Traverse the element types. For each element type, obtain its corresponding specified color according to the element type and color mapping table. In the target BMP bitmap, use a color matching algorithm to search for the region composed of colors whose color difference with the specified color is within a preset threshold range, thereby obtaining several contour regions and the target element graphic. The client searches for element graphics in a specified element graphics library that have the same outline and size as the target element graphic as candidate graphics, including: Search for element graphics of the same type as the target element graphic in the corresponding element graphic group of the specified element graphic library as candidate graphics; The element graphic library is set in the client, and the element graphic library contains character element graphics and number element graphics of different resolutions and sizes. Element graphics of the same type belong to the same element graphic group.