A method and system for collecting gate passage data with double half-digit coding
Through the double-half-bit encoding method, the gate sensor status is encoded as visible characters in the ASCII code, which solves the problem of low transmission and storage efficiency, realizes more efficient data transmission and storage, and is suitable for data applications in different systems.
Patent Information
- Application Number
- CN202211509320.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-11-29
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2042-11-29
AI Technical Summary
In the prior art, the transmission and storage efficiency of gate pass data is low, especially when the number of sensors is greater than 24, as BASE64 encoding increases data redundancy and reduces transmission and storage efficiency.
The double-half-bit encoding method is used to encode the gate sensor status into visible characters in the ASCII code. The sensor status data is processed by division and padding, and the encoding process is optimized using a comparison table to ensure that the encoding result is displayable characters and reduce data redundancy.
It improves the transmission efficiency of gate machine pass data, avoids data loss, and is suitable for data applications between different systems. The transmission efficiency is better than BASE64 encoding.
Smart Images

Figure CN115859912B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of sensor data processing, and in particular relates to a method and system for collecting gate passage data. Background Art
[0002] Gates are key components of railway and rail transit automatic ticketing systems. They utilize external sensors and internal intelligent recognition systems to identify passenger traffic. Current technology uses multiple infrared sensors, each consisting of an infrared transmitter and receiver, installed on either side of the gate passage. When a passenger or luggage blocks the corresponding sensor, the receiver in the sensor loses the ability to receive the infrared signal. The status of these sensors reflects the communication status. The core components of a gate are the gate control system and the traffic logic algorithm. The communication logic algorithm uses the sensor status to identify the current traffic event and control the opening and closing of the gate. Whether a blocked infrared sensor is blocked can be represented by a "0" or "1" value. Passage data, namely the status of the multiple infrared sensors on the gate, is represented by a binary code. Transmitting or storing this data requires converting the binary code into characters. If the number of sensors is 24 or fewer, 3-byte binary data can be used to represent the sensor status. Base64 encoding is then used to convert the 3-byte binary data into 4-byte displayable characters for transmission and storage. If the number of sensors is greater than 24, using Base64 encoding requires expanding the binary data into multiple 3-byte data, and then using Base64 encoding for each 3-byte binary data segment into a 4-byte displayable character. This operation increases data redundancy and reduces transmission and storage efficiency. Summary of the Invention
[0003] Purpose of the invention: In view of the problems existing in the prior art, the present invention provides a method for collecting gate pass data with double half-digit coding, which can transmit and save gate pass data in the form of displayable characters.
[0004] Technical solution: On one hand, the present invention discloses a method for collecting gate pass data with double half-digit coding, comprising:
[0005] Step 1: Get the status of all sensors on the gate, where the sensor is a beam infrared sensor, and the status is whether it is blocked, and the status is represented by 0 or 1;
[0006] Step 2: Encode the sensor status data into visible characters in ASCII code;
[0007] When the number of sensors N is 24<N≤32, the encoding steps are:
[0008] Step 21: Use 4 bytes of data to represent the status of all sensors, forming raw data;
[0009] Step 22: Divide the first 30 bits of the 32-bit original data into 5 groups in order, with 6 bits in each group. The upper 2 bits of each group are padded with 0 to form 5 bytes of data. Add 20H to each byte of data to obtain 5 bytes of initial coded data.
[0010] If N≤30, the 5-byte initial encoded data is the encoding result; if 30<N, it also includes:
[0011] Step 23: Searching a comparison table based on the values S31 and S32 of the 31st and 32nd bits in the original data to obtain an operation instruction for the 5-byte initial encoded data; performing an operation on the 5-byte initial encoded data according to the obtained operation instruction in ascending order of priority, and determining whether the operation is valid according to a first judgment criterion; if valid, performing the operation to obtain 5 bytes of encoded data as an encoding result;
[0012] The first judgment criterion is: after operating the 5-byte initial coded data, if the 5-byte data values obtained are all within the range of 20H-7EH, that is, if the 5-byte data obtained are all displayable characters in the ASCII code, then it is valid; otherwise, it is invalid;
[0013] Step 24: If a valid code cannot be obtained in step 23, determine whether the 5-byte coded data after the operation is valid according to the second judgment criterion;
[0014] The second judgment criterion is: after operating the 5-byte initial coded data, if the 5-byte data values obtained are all within the range of 20H-7FH, then it is valid; otherwise, it is invalid;
[0015] If valid, convert 7FH in the 5-byte encoded data obtained by the above operation to 09H to obtain the final encoding result;
[0016] The comparison table is:
[0017]
[0018]
[0019] The operation code "1+" in the comparison table indicates that 40H is added to the corresponding byte, "1-" indicates that 20H is added to the corresponding byte, and "0" indicates that the corresponding byte remains unchanged.
[0020] Furthermore, in step 2, when the number N of sensors satisfies N≤24, the states of all sensors are represented by 3-byte binary numbers, and the sensor states represented by 3 bytes are converted into 4-byte data using BASE64 encoding.
[0021] Furthermore, the collection method further includes:
[0022] Step 3: Save the encoded sensor status data as a text file.
[0023] Furthermore, the collection method further includes:
[0024] Step 4: Decode the encoded sensor status data; when the value of the number of sensors N is 24<N≤32, the decoding is to decode 5-byte data into 4-byte data, and the steps are:
[0025] Step 41: Obtain a predicted operation code based on the size of each byte value of the 5-byte encoded data, specifically:
[0026] Replace the byte with value 09H in the 5-byte encoded data with 7FH;
[0027] If the value of the byte is less than 60H, the predicted operation code of the corresponding byte is "0", otherwise the predicted operation code of the corresponding byte is "1*", where "*" is "+" or "-";
[0028] Step 42: Compare the 5-byte predicted operation code with the comparison table to determine the values of S31 and S32, as well as the operation instruction during encoding;
[0029] Step 43: Perform an inverse operation on the 5-byte encoded data: if the operation code in the operation instruction is "1-", the value of the corresponding byte remains unchanged; if the operation code in the operation instruction is "1+" or "0", the value of the corresponding byte is subtracted by 20H;
[0030] Step 44: For the 5-byte data obtained after the inverse operation, retain the lower 6 bits of each byte, add the values of S31 and S32, and obtain 32-bit decoded data.
[0031] Furthermore, the step 4 further includes: when the number N of sensors satisfies N≤24, the decoding is to use BASE64 code decoding to decode the 4-byte data into 3-byte data.
[0032] Furthermore, the number of the sensors is 32, and the 32 sensors are symmetrically distributed in area A and area B of the gate area, and the area A and area B are two areas of the gate area symmetrically distributed with the gate as the symmetry axis;
[0033] Of the 32 sensors, 26 are installed at fixed locations in Areas A and B, and the remaining 6 are backup sensors. The specific process for their location setting is as follows:
[0034] (1) Install 26 fixed position sensors; determine multiple preset position points in the gate area according to the structure of the gate; the multiple preset position points are symmetrically distributed in area A and area B;
[0035] (2) Among the preset positions in area A, the optimal position of the first backup sensor in area A is determined by a traversal method and installed. The optimal position is the preset position where the first backup sensor is located when the recognition rate of traffic status is the highest when the traffic data obtained by the installed sensor is used to identify the traffic state;
[0036] According to the optimal position of the first backup sensor, obtain the symmetrical preset position point of the position in area B as the optimal position of the second backup sensor and install it;
[0037] (3) Among the remaining preset positions in area A, the traversal method is used to determine the optimal position of the third backup sensor in area A and install it; based on the optimal position of the third backup sensor, the symmetrical preset position point of the position in area B is obtained as the optimal position of the fourth backup sensor and installed;
[0038] (4) Among the remaining preset position points in area A, the traversal method is used to determine the optimal position of the fifth backup sensor in area A and install it; based on the optimal position of the fifth backup sensor, the symmetrical preset position point of this position in area B is obtained as the optimal position of the sixth backup sensor and installed.
[0039] On the other hand, the present invention also discloses a system for implementing the above-mentioned method for collecting gate passage data using double-half-digit coding, comprising:
[0040] Gate sensor status acquisition module 1, used to obtain the status of all sensors on the gate, the sensors are through-beam infrared sensors, and the status is whether they are blocked, and the status is represented by 0 or 1;
[0041] Encoding module 2, used for encoding sensor status data into visible characters in ASCII code;
[0042] When the number of sensors N is 24<N≤32, the encoding steps of the encoding module are:
[0043] Step 21: Use 4 bytes of data to represent the status of all sensors, forming raw data;
[0044] Step 22: Divide the first 30 bits of the 32-bit original data into 5 groups in order, with 6 bits in each group. The upper 2 bits of each group are padded with 0 to form 5 bytes of data. Add 20H to each byte of data to obtain 5 bytes of initial coded data.
[0045] If N≤30, the 5-byte initial coded data is the coding result of the coding module; if 30<N, it also includes:
[0046] Step 23: Searching a comparison table based on the values S31 and S32 of the 31st and 32nd bits in the original data to obtain an operation instruction for the 5-byte initial coded data; performing an operation on the 5-byte initial coded data based on the obtained operation instruction in ascending order of priority, and determining whether the operation is valid based on a first judgment criterion; if valid, performing the operation to obtain 5-byte coded data as the encoding result of the encoding module;
[0047] The first judgment criterion is: after operating the 5-byte initial coded data, if the 5-byte data values obtained are all within the range of 20H-7EH, that is, if the 5-byte data obtained are all displayable characters in the ASCII code, then it is valid; otherwise, it is invalid;
[0048] Step 24: If a valid code cannot be obtained in step 23, determine whether the 5-byte coded data after the operation is valid according to the second judgment criterion;
[0049] The second judgment criterion is: after operating the 5-byte initial coded data, if the 5-byte data values obtained are all within the range of 20H-7FH, then it is valid; otherwise, it is invalid;
[0050] If valid, convert 7FH in the 5-byte encoded data obtained by the above operation to 09H to obtain the final encoding result;
[0051] The comparison table is:
[0052]
[0053]
[0054] The operation code "1+" in the comparison table indicates that 40H is added to the corresponding byte, "1-" indicates that 20H is added to the corresponding byte, and "0" indicates that the corresponding byte remains unchanged.
[0055] Furthermore, the encoding module 2 is further configured to: when the number N of sensors satisfies N≤24, use 3-byte binary numbers to represent the states of all sensors, and use BASE64 encoding to convert the sensor states represented by 3 bytes into 4-byte data.
[0056] Furthermore, it also includes a data storage module 3 for saving the encoded sensor state data as a text file.
[0057] Furthermore, a decoding module 4 is included for decoding the encoded sensor status data; when the value of the number of sensors N is 24<N≤32, the decoding is to decode 5-byte data into 4-byte data, and the steps are:
[0058] Step 4: Decode the encoded sensor status data; when the value of the number of sensors N is 24<N≤32, the decoding is to decode 5-byte data into 4-byte data, and the steps are:
[0059] Step 41: Obtain a predicted operation code based on the size of each byte value of the 5-byte encoded data, specifically:
[0060] Replace the byte with value 09H in the 5-byte encoded data with 7FH;
[0061] If the value of the byte is less than 60H, the predicted operation code of the corresponding byte is "0", otherwise the predicted operation code of the corresponding byte is "1*", where "*" is "+" or "-";
[0062] Step 42: Compare the 5-byte predicted operation code with the comparison table to determine the values of S31 and S32, as well as the operation instruction during encoding;
[0063] Step 43: Perform an inverse operation on the 5-byte encoded data: if the operation code in the operation instruction is "1-", the value of the corresponding byte remains unchanged; if the operation code in the operation instruction is "1+" or "0", the value of the corresponding byte is subtracted by 20H;
[0064] Step 44: For the 5-byte data obtained after the inverse operation, retain the lower 6 bits of each byte, add the values of S31 and S32, and obtain 32-bit decoded data.
[0065] Beneficial Effects: The disclosed method and system for collecting gate access data using dual-half-digit encoding can transmit and store gate access data in displayable characters, making it suitable for use in transferring access data between different systems without causing data loss. Compared to BASE64 encoding, this method offers higher data transmission efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0066] Figure 1 This is a flow chart of the method for collecting gate passage data using double-half-digit coding disclosed in the present invention;
[0067] Figure 2 Flowchart for double half-bit coding;
[0068] Figure 3This is a schematic diagram of the composition of the gate passage data acquisition system with double half-digit coding disclosed in the present invention;
[0069] Figure 4 This is a distribution diagram of the infrared sensors;
[0070] Figure 5 This is a schematic diagram of the preset location points. DETAILED DESCRIPTION
[0071] The present invention will be further explained below with reference to the accompanying drawings and specific embodiments.
[0072] Example 1:
[0073] The present invention discloses a method for collecting gate pass data with double half-digit coding, such as Figure 1 Shown, including:
[0074] Step 1: Get the status of all sensors on the gate, where the sensor is a beam infrared sensor, and the status is whether it is blocked, and the status is represented by 0 or 1;
[0075] Step 2: Encode the sensor status data into visible characters in ASCII code; specifically, different encoding methods are used according to the number of sensors.
[0076] (1) When the number of sensors N satisfies N≤24, the states of all sensors are represented by 3-byte binary numbers, and BASE64 encoding is used to convert the 3-byte sensor states into 4-byte data.
[0077] (2) When the number of sensors N is 24<N≤32, the encoding steps are as follows Figure 2 Shown, including:
[0078] Step 21: Use 4 bytes of data to represent the status of all sensors, forming raw data;
[0079] 4-byte binary data can represent the status of up to 32 sensors. If the number of sensors is less than 32, 0 is used to represent the status of non-existent sensors.
[0080] Step 22: Divide the first 30 bits of the 32-bit original data into 5 groups in order, with 6 bits in each group. The upper 2 bits of each group are padded with 0 to form 5 bytes of data. Add 20H to each byte of data to obtain 5 bytes of initial coded data.
[0081] If N≤30, the 5-byte initial encoded data is the encoding result;
[0082] When N≤30, the 31st and 32nd bits in the original data are supplementary data bits, and their values do not correspond to the actual sensor. The 5-byte data formed by dividing the 1-30 bits of data has a value range of 00H-3FH for each byte. After adding 20H to each byte of data, the value range is 20H-5FH. In ASCII code, all characters within this range are displayable characters. At this point, the purpose of converting non-displayable characters into displayable characters is achieved, and the encoding is completed.
[0083] If 30 < N, bits 31 and 32 of the original data also need to be reflected in the encoded result, including:
[0084] Step 23: Look up the comparison table based on the values S31 and S32 of the 31st and 32nd bits in the original data to obtain an operation instruction for the 5-byte initial encoded data; perform an operation on the 5-byte initial encoded data based on the obtained operation instruction in ascending order of priority, and determine whether the operation is valid based on the first judgment criterion;
[0085] The first judgment criterion is: after operating the 5-byte initial encoded data, the obtained 5-byte data values are all within the range of 20H-7EH, that is, the obtained 5-byte data are all displayable characters in the ASCII code, then they are valid; otherwise, they are invalid.
[0086] If valid, the 5-byte encoded data is obtained as the encoding result according to the above operation;
[0087] For example, when S31 and S32 are 01, there are 7 operations with priority values 0-6 according to the comparison table. First, the 5-byte initial encoded data is operated according to the operation code with priority 0. If the 5-byte data values obtained are all within the range of 20H-7EH, it is valid and the obtained 5-byte data can be used as the encoding result. Otherwise, the 5-byte initial encoded data is operated again according to the operation code with priority 1 to determine whether it is valid.
[0088] If none of the 7 operation modes with priority levels 0-6 can obtain the coded data within the range of 20H-7EH, that is, step 23 cannot obtain a valid code, then perform the correction code according to step 24:
[0089] Step 24: Determine whether the 5-byte encoded data after the operation is valid according to the second judgment criterion;
[0090] The second judgment criterion is: after operating the 5-byte initial coded data, if the 5-byte data values obtained are all within the range of 20H-7FH, then it is valid; otherwise, it is invalid;
[0091] If valid, convert 7FH in the 5-byte coded data obtained by the above operation into 09H to obtain the final coding result; the comparison table is:
[0092]
[0093]
[0094] The operation code "1+" in the comparison table indicates that 40H is added to the corresponding byte, "1-" indicates that 20H is added to the corresponding byte, and "0" indicates that the corresponding byte remains unchanged.
[0095] In step 23, whether the operation is valid is determined based on the first judgment criterion. In some invalid cases, the 5-byte data obtained contains 7FH, which exceeds the judgment range of the first judgment criterion. In this regard, step 24 expands the judgment range and adopts the second judgment criterion, but converts 7FH in the byte after the operation into 09F, that is, replaces the "DEL (delete)" in the ASCII code with "HT (horizontal tab)".
[0096] BASE64 code encodes 3 bytes of original data into 4 bytes of data for transmission, which means that the data volume increases by 33.33%. The encoding method in this embodiment encodes 4 bytes of original data into 5 bytes of data for transmission, which increases the data volume by 25%. Therefore, the transmission efficiency is better than BASE64 encoding.
[0097] After the above encoding, the collected sensor data can be transmitted or saved via text. That is, the sensor status data is transmitted by transmitting the encoded data. If the collected data needs to be saved, it also includes:
[0098] Step 3: Save the encoded sensor status data as a text file.
[0099] The device or system that receives the coded data decodes the received data to obtain the sensor status data. The saved text file also needs to be decoded to obtain the sensor status data. At this time, the following decoding is required, specifically:
[0100] When the number N of sensors satisfies N≤24, the decoding is to use BASE64 code decoding to decode 4-byte data into 3-byte data.
[0101] When the value of the number of sensors N is 24<N≤32, the decoding is to decode 5-byte data into 4-byte data, and the steps are:
[0102] Step 41: Obtain a predicted operation code based on the size of each byte value of the 5-byte encoded data, specifically:
[0103] Replace the byte with value 09H in the 5-byte encoded data with 7FH;
[0104] If the byte value is less than 60H (i.e. 01100000B), the predicted operation code of the corresponding byte is "0", otherwise the predicted operation code of the corresponding byte is "1*", where "*" is "+" or "-";
[0105] Step 42: Compare the 5-byte predicted operation code with the comparison table to determine the values of S31 and S32, as well as the operation instruction during encoding;
[0106] Step 43: Perform an inverse operation on the 5-byte encoded data: if the operation code in the operation instruction is "1-", the value of the corresponding byte remains unchanged; if the operation code in the operation instruction is "1+" or "0", the value of the corresponding byte is subtracted by 20H;
[0107] Step 44: For the 5-byte data obtained after the inverse operation, retain the lower 6 bits of each byte, add the values of S31 and S32, and obtain 32-bit decoded data.
[0108] This embodiment uses the following examples to illustrate the above encoding and decoding steps:
[0109] Example 1: The original data from bit 1 to bit 32 is 00000000:
[0110] Coding: First divide S1-S30 into 5 groups, and fill the highest 2 bits with 0 to obtain the 5-byte data: 00B, 00B, 00B, 00B, 00B; add 20H to the data of each byte, and the 5-byte data becomes: 20H, 20H, 20H, 20H, 20H;
[0111] Since S31 and S32 are both 0, according to the row of data with priority 1 in the comparison table, the operation code of each byte is 0, that is, it remains unchanged, so the encoded 5 bytes are: 20H, 20H, 20H, 20H, 20H.
[0112] Decoding: The encoded data is 2020202020H, that is, each byte is less than 60H, and the predicted operation code is 0; compared with the comparison table, the row with the priority value of 0, S31 and S32 both being 0 is consistent with the predicted operation code, and it is determined that the values of S31 and S32 are both 0, and the operation instructions of the 5 bytes during encoding are all 0; subtract 20H from each byte in 20H, 20H, 20H, 20H, and the result is 00H, 00H, 00H, 00H, 00H, retaining the lower 6 bits of each byte, and obtaining 30 bits of all-0 binary data, and adding the values of S31 and S32 to obtain 32-bit decoded data: 00H, 00H, 00H, 00H, 00H;
[0113] Example 2: The original data from bit 1 to bit 32 is FF 002000:
[0114] Coding: Original data S1-S32:FF 002000, that is: 11111111, 00000000, 00100000, 00000000
[0115] First, divide S1-S30 into 5 groups: 111111, 110000, 000000, 100000, 000000, 00 (S31, S32), and fill the highest 0 bit of each group with 0, so the 5-byte data is: 3F, 30, 00, 20, 00H; add 20H to the data of each byte, and the 5-byte data becomes: 5FH, 50H, 20H, 40H, 20H;
[0116] Since S31 and S32 are both 0, according to the first row of the comparison table, each byte keeps the original code, so the encoded 5 bytes are: 5FH, 50H, 20H, 40H, 20H.
[0117] Decoding: The encoded data is 5FH, 50H, 20H, 40H, 20H. Comparing the size of each byte with 60H, the predicted operation code of the 5 bytes is all 0. Comparing with the comparison table, the row with priority value 0, S31 and S32 as 00 is consistent with the predicted operation code, and the operation instructions of the 5 bytes during encoding are all 0; subtract 20H from each byte in 5FH, 50H, 20H, 40H, 20H, and the result is 3FH, 30H, 00H, 20H, 00H. Retain the lower 6 bits of each byte and get 30-bit binary data: 111111000000 00100000000000B. Add the values of S31 and S32 to get 32-bit decoded data: FF002000H.
[0118] Example 3: Following the above steps, encode the following example:
[0119] The code corresponding to the data 00FF 0000 is 202F 5C 2020;
[0120] The code corresponding to the data 0000FF 00 is 2020235F 20;
[0121] The code corresponding to the data 000000FF is 602020605F;
[0122] The code corresponding to the data AA AA AA FF is 6A 6A 6A 6A 5F;
[0123] A system for realizing the above-mentioned method for collecting gate pass data with double half-digit coding, such as Figure 3 Shown, including:
[0124] Gate sensor status acquisition module 1, used to obtain the status of all sensors on the gate, the sensors are through-beam infrared sensors, and the status is whether they are blocked, and the status is represented by 0 or 1;
[0125] Encoding module 2 is used to encode the sensor status data into visible characters in ASCII code; specifically:
[0126] When the number of sensors N satisfies N≤24, the states of all sensors are represented by 3-byte binary numbers, and BASE64 encoding is used to convert the 3-byte sensor states into 4-byte data.
[0127] When the number of sensors N is 24<N≤32, the encoding steps of the encoding module are:
[0128] Step 21: Use 4 bytes of data to represent the status of all sensors, forming raw data;
[0129] Step 22: Divide the first 30 bits of the 32-bit original data into 5 groups in order, with 6 bits in each group. The upper 2 bits of each group are padded with 0 to form 5 bytes of data. Add 20H to each byte of data to obtain 5 bytes of initial coded data.
[0130] If N≤30, the 5-byte initial coded data is the encoding result of the encoding module; if 30<N, it also includes:
[0131] Step 23: Searching a comparison table based on the values S31 and S32 of the 31st and 32nd bits in the original data to obtain an operation instruction for the 5-byte initial coded data; performing an operation on the 5-byte initial coded data based on the obtained operation instruction in ascending order of priority, and determining whether the operation is valid based on a first judgment criterion; if valid, performing the operation to obtain 5-byte coded data as the encoding result of the encoding module;
[0132] The first judgment criterion is: after operating the 5-byte initial coded data, if the 5-byte data values obtained are all within the range of 20H-7EH, that is, if the 5-byte data obtained are all displayable characters in the ASCII code, then it is valid; otherwise, it is invalid;
[0133] Step 24: If a valid code cannot be obtained in step 23, determine whether the 5-byte coded data after the operation is valid according to the second judgment criterion;
[0134] The second judgment criterion is: after operating the 5-byte initial coded data, if the 5-byte data values obtained are all within the range of 20H-7FH, then it is valid; otherwise, it is invalid;
[0135] If valid, convert 7FH in the 5-byte encoded data obtained by the above operation to 09H to obtain the final encoding result;
[0136] The comparison table is:
[0137]
[0138]
[0139] The operation code "1+" in the comparison table indicates that 40H is added to the corresponding byte, "1-" indicates that 20H is added to the corresponding byte, and "0" indicates that the corresponding byte remains unchanged.
[0140] The data storage module 3 is used to save the encoded sensor status data as a text file.
[0141] The decoding module 4 is used to decode the encoded sensor status data; specifically:
[0142] When the value of the number of sensors N is 24<N≤32, the decoding is to decode 5-byte data into 4-byte data, and the steps are:
[0143] Step 4: Decode the encoded sensor status data; specifically:
[0144] When the number N of sensors satisfies N≤24, the decoding is to use BASE64 code decoding to decode 4-byte data into 3-byte data.
[0145] When the value of the number of sensors N is 24<N≤32, the decoding is to decode 5-byte data into 4-byte data, and the steps are:
[0146] Step 41: Obtain a predicted operation code based on the size of each byte value of the 5-byte encoded data, specifically:
[0147] Replace the byte with value 09H in the 5-byte encoded data with 7FH;
[0148] If the value of the byte is less than 60H, the predicted operation code of the corresponding byte is "0", otherwise the predicted operation code of the corresponding byte is "1*", where "*" is "+" or "-";
[0149] Step 42: Compare the 5-byte predicted operation code with the comparison table to determine the values of S31 and S32, as well as the operation instruction during encoding;
[0150] Step 43: Perform an inverse operation on the 5-byte encoded data: if the operation code in the operation instruction is "1-", the value of the corresponding byte remains unchanged; if the operation code in the operation instruction is "1+" or "0", the value of the corresponding byte is subtracted by 20H;
[0151] Step 44: For the 5-byte data obtained after the inverse operation, retain the lower 6 bits of each byte, add the values of S31 and S32, and obtain 32-bit decoded data.
[0152] Example 2:
[0153] The more infrared sensors are installed on the gate, the better the traffic data can reflect the characteristics of the traffic event. Sensors at different locations also have different effects on the recognition of communication events. In this embodiment, the positions of the 32 sensors installed on the gate are optimized. A beam infrared sensor consists of a transmitter and a receiver, which are installed on both sides of the gate channel, such as Figure 4 As shown in the figure, S1 and S1' form a through-beam infrared sensor, which is symmetrically distributed with the channel as the symmetry axis. The channel arrow indicates the direction of passage. Passengers enter from the passage area A, pass through the monitoring area A, the safety area, the monitoring area B and the passage area B. Multiple through-beam infrared sensors are symmetrically distributed in the area A and area B of the gate area. Area A and area B are two areas of the gate area that are symmetrically distributed with the gate as the symmetry axis. Figure 4 The dotted lines are symmetrically distributed, such as S1 and S26 are symmetrically distributed, and S2 and S25 are symmetrically distributed; among the 32 sensors, 26 sensors are installed in fixed positions in areas A and B, such as Figure 4 S1-S26 in the diagram, the remaining 6 sensors (S27-32) are spare sensors, and the specific process of their position setting is as follows:
[0154] (1) Install 26 fixed position sensors; determine multiple preset position points in the gate area according to the structure of the gate; the multiple preset position points are symmetrically distributed in area A and area B; Figure 5 As shown, this embodiment has 4 preset points in the A passage area, 12 preset points in the A monitoring area, and one preset point in the portion of the safety area located in area A. There are a total of 17 preset points in area A. Based on the symmetrical relationship, there are also 17 preset points in area B.
[0155] (2) Among the preset positions in area A, the optimal position of the first backup sensor in area A is determined by a traversal method and installed. The optimal position is the preset position where the first backup sensor is located when the recognition rate of traffic status is the highest when the traffic data obtained by the installed sensor is used to identify the traffic state;
[0156] According to the optimal position of the first backup sensor, obtain the symmetrical preset position point of the position in area B as the optimal position of the second backup sensor and install it;
[0157] (3) Among the remaining preset positions in area A, the traversal method is used to determine the optimal position of the third backup sensor in area A and install it; based on the optimal position of the third backup sensor, the symmetrical preset position point of the position in area B is obtained as the optimal position of the fourth backup sensor and installed;
[0158] (4) Among the remaining preset position points in area A, the traversal method is used to determine the optimal position of the fifth backup sensor in area A and install it; based on the optimal position of the fifth backup sensor, the symmetrical preset position point of this position in area B is obtained as the optimal position of the sixth backup sensor and installed.
[0159] After the above steps, the optimal locations of the six backup sensors were determined.
Claims
1. A method for collecting gate pass data with double half-digit coding, characterized in that: include: Step 1: Get the status of all sensors on the gate, where the sensor is a beam infrared sensor, and the status is whether it is blocked, and the status is represented by 0 or 1; Step 2: Encode the sensor status data into visible characters in ASCII code; When the number of sensors N is 24<N≤32, the encoding steps are: Step 21: Use 4 bytes of data to represent the status of all sensors, forming raw data; Step 22: Divide the first 30 bits of the 32-bit original data into 5 groups in order, each with 6 bits. Padded the upper 2 bits of each group with 0 to form 5 bytes of data. Add 20H to each byte of data to obtain 5 bytes of initial coded data. If N≤30, the 5-byte initial encoded data is the encoding result; If 30 < N, also include: Step 23: Searching a comparison table based on the values S31 and S32 of the 31st and 32nd bits in the original data to obtain an operation instruction for the 5-byte initial encoded data; performing an operation on the 5-byte initial encoded data according to the obtained operation instruction in ascending order of priority, and determining whether the operation is valid according to a first judgment criterion; if valid, performing the operation to obtain 5 bytes of encoded data as an encoding result; The first judgment criterion is: after operating the 5-byte initial coded data, if the 5-byte data values obtained are all within the range of 20H-7EH, that is, if the 5-byte data obtained are all displayable characters in the ASCII code, then it is valid; otherwise, it is invalid; Step 24: If a valid code cannot be obtained in step 23, determine whether the 5-byte coded data after the operation is valid according to the second judgment criterion; The second judgment criterion is: after operating the 5-byte initial coded data, if the 5-byte data values obtained are all within the range of 20H-7FH, then it is valid; otherwise, it is invalid; If valid, convert 7FH in the 5-byte encoded data obtained by the above operation to 09H to obtain the final encoding result; The comparison table is: The operation code "1+" in the comparison table indicates that 40H is added to the corresponding byte, "1-" indicates that 20H is added to the corresponding byte, and "0" indicates that the corresponding byte remains unchanged.
2. The method for collecting gate pass data with double half-digit coding according to claim 1 is characterized in that: In step 2, when the number N of sensors satisfies N≤24, the states of all sensors are represented by 3-byte binary numbers, and the sensor states represented by 3 bytes are converted into 4-byte data using BASE64 encoding.
3. The method for collecting gate pass data with double half-digit coding according to claim 1 is characterized in that: The collection method further comprises: Step 3: Save the encoded sensor status data as a text file.
4. The method for collecting gate passage data with double half-digit coding according to claim 1 is characterized in that: The collection method further comprises: Step 4: Decode the encoded sensor status data; when the value of the number of sensors N is 24<N≤32, the decoding is to decode 5-byte data into 4-byte data, and the steps are: Step 41: Obtain a predicted operation code based on the size of each byte value of the 5-byte encoded data, specifically: Replace the byte with value 09H in the 5-byte encoded data with 7FH; If the byte value is less than 60H, the predicted operation code of the corresponding byte is "0", otherwise the predicted operation code of the corresponding byte is "1*", where "*" is "+" or "-"; Step 42: Compare the 5-byte predicted operation code with the comparison table to determine the values of S31 and S32, as well as the operation instruction during encoding; Step 43: Perform an inverse operation on the 5-byte encoded data: if the operation code in the operation instruction is "1-", the value of the corresponding byte remains unchanged; if the operation code in the operation instruction is "1+" or "0", the value of the corresponding byte is subtracted by 20H; Step 44: For the 5-byte data obtained after the inverse operation, retain the lower 6 bits of each byte, add the values of S31 and S32, and obtain 32-bit decoded data.
5. The method for collecting gate passage data with double half-digit coding according to claim 4 is characterized in that: The step 4 further includes: when the number N of sensors satisfies N≤24, the decoding is to use BASE64 code decoding to decode the 4-byte data into 3-byte data.
6. The method for collecting gate passage data with double half-digit coding according to claim 1 is characterized in that: The number of sensors is 32, and the 32 sensors are symmetrically distributed in area A and area B of the gate area. Area A and area B are two areas of the gate area symmetrically distributed with the gate as the symmetry axis; Of the 32 sensors, 26 are installed at fixed locations in Areas A and B, and the remaining 6 are backup sensors. The specific process for their location setting is as follows: (1) Install 26 fixed position sensors; determine multiple preset position points in the gate area according to the structure of the gate; the multiple preset position points are symmetrically distributed in area A and area B; (2) Among the preset positions in area A, the optimal position of the first backup sensor in area A is determined by a traversal method and installed. The optimal position is the preset position where the first backup sensor is located when the recognition rate of traffic status is the highest when the traffic data obtained by the installed sensor is used to identify the traffic state; According to the optimal position of the first backup sensor, obtain the symmetrical preset position point of the position in area B as the optimal position of the second backup sensor and install it; (3) Among the remaining preset positions in area A, the traversal method is used to determine the optimal position of the third backup sensor in area A and install it; based on the optimal position of the third backup sensor, the symmetrical preset position point of the position in area B is obtained as the optimal position of the fourth backup sensor and installed; (4) Among the remaining preset position points in area A, the traversal method is used to determine the optimal position of the fifth backup sensor in area A and install it; based on the optimal position of the fifth backup sensor, the symmetrical preset position point of this position in area B is obtained as the optimal position of the sixth backup sensor and installed.
7. A double half-digit coded gate pass data acquisition system, characterized in that: include: A gate sensor status acquisition module (1) is used to acquire the status of all sensors on the gate, wherein the sensors are infrared sensors, and the status is whether they are blocked, and the status is represented by 0 or 1; An encoding module (2), for encoding the sensor status data into visible characters in ASCII code; When the number of sensors N is 24<N≤32, the encoding steps of the encoding module are: Step 21: Use 4 bytes of data to represent the status of all sensors, forming raw data; Step 22: Divide the first 30 bits of the 32-bit original data into 5 groups in order, with 6 bits in each group. The upper 2 bits of each group are padded with 0 to form 5 bytes of data. Add 20H to each byte of data to obtain 5 bytes of initial coded data. If N≤30, the 5-byte initial encoding data is the encoding result of the encoding module; If 30 < N, also include: Step 23: Searching a comparison table based on the values S31 and S32 of the 31st and 32nd bits in the original data to obtain an operation instruction for the 5-byte initial coded data; performing an operation on the 5-byte initial coded data based on the obtained operation instruction in ascending order of priority, and determining whether the operation is valid based on a first judgment criterion; if valid, performing the operation to obtain 5-byte coded data as the encoding result of the encoding module; The first judgment criterion is: after operating the 5-byte initial coded data, if the 5-byte data values obtained are all within the range of 20H-7EH, that is, if the 5-byte data obtained are all displayable characters in the ASCII code, then it is valid; otherwise, it is invalid; Step 24: If a valid code cannot be obtained in step 23, determine whether the 5-byte coded data after the operation is valid according to the second judgment criterion; The second judgment criterion is: after operating the 5-byte initial coded data, if the 5-byte data values obtained are all within the range of 20H-7FH, then it is valid; otherwise, it is invalid; If valid, convert 7FH in the 5-byte encoded data obtained by the above operation to 09H to obtain the final encoding result; The comparison table is: The operation code "1+" in the comparison table indicates that 40H is added to the corresponding byte, "1-" indicates that 20H is added to the corresponding byte, and "0" indicates that the corresponding byte remains unchanged.
8. The gate machine passage data acquisition system according to claim 7, characterized in that: The encoding module (2) is further used for: when the number N of sensors satisfies N≤24, using 3-byte binary numbers to represent the states of all sensors, and using BASE64 encoding to convert the sensor states represented by 3 bytes into 4-byte data.
9. The gate machine passage data acquisition system according to claim 7, characterized in that: It also includes a data storage module (3) for storing the encoded sensor state data as a text file.
10. The gate machine passage data acquisition system according to claim 7, characterized in that: It also includes a decoding module (4) for decoding the encoded sensor state data; when the value of the number of sensors N is 24<N≤32, the decoding is to decode 5-byte data into 4-byte data, and the steps are: Step 41: Obtain a predicted operation code based on the size of each byte value of the 5-byte encoded data, specifically: Replace the byte with value 09H in the 5-byte encoded data with 7FH; If the byte value is less than 60H, the predicted operation code of the corresponding byte is "0", otherwise the predicted operation code of the corresponding byte is "1*", where "*" is "+" or "-"; Step 42: Compare the 5-byte predicted operation code with the comparison table to determine the values of S31 and S32, as well as the operation instruction during encoding; Step 43: Perform an inverse operation on the 5-byte encoded data: if the operation code in the operation instruction is "1-", the value of the corresponding byte remains unchanged; if the operation code in the operation instruction is "1+" or "0", the value of the corresponding byte is subtracted by 20H; Step 44: For the 5-byte data obtained after the inverse operation, retain the lower 6 bits of each byte, add the values of S31 and S32, and obtain 32-bit decoded data.
Citation Information
Patent Citations
Data lossless compression method for data transmission of remote monitoring system
CN101197071A
Data coding / decoding method suitable for Bei Dou short message civil agreement
CN103279462A