Scanning gun code scanning setting method based on logic table driving method
Through the scanner setting method of the logical table driver method, the problem of code redundancy and maintenance difficulty in traditional settings is solved, code simplification and efficiency improvement are achieved, and a flexible expansion architecture is provided.
Patent Information
- Application Number
- CN202411270697.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-09-11
- Publication Date
- 2024-12-06
AI Technical Summary
The traditional scanner setting method based on if-else or switch-case logic judgment results in large coding workload, high development difficulty, redundant code, and difficult to maintain and expand, increasing the risk of errors.
The scanning gun code setting method based on the logical table driving method is adopted. By creating a setting code lookup table, analyzing the scanning code and matching the setting items, calling the corresponding setting function, separating the setting code from the logic processing, simplifying the code structure and improving maintainability.
It effectively reduces the volume of program code, improves system operation efficiency and response speed, simplifies function expansion and maintenance, reduces code redundancy and error risks, and provides a flexible infrastructure to facilitate the addition and integration of new functions.
Smart Images

Figure CN119089921A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of scanner terminal equipment, and specifically is a scanner code scanning setting method based on a logic table driving method. Background Art
[0002] A barcode scanner, also known as a barcode scanner, is a device used to read barcode or QR code information and is widely used in the retail, logistics, medical and manufacturing industries.
[0003] However, as the functions of scanners continue to increase, their settings have become more and more complicated, involving multiple dimensions such as scanning modes, code recognition, result feedback methods, and result processing rules. The corresponding setting instructions can reach hundreds of items. The traditional implementation method based on if-else or switch-case logical judgment not only has a large coding workload and high development difficulty, but also easily leads to code redundancy, which brings difficulties to subsequent function expansion and maintenance, and increases the risk of errors. Therefore, it needs to be improved. Summary of the invention
[0004] The purpose of the present invention is to provide a scanner code scanning setting method based on a logic table driven method to solve the problems raised in the above background technology.
[0005] In order to achieve the above object, the present invention provides the following technical solution: a method for setting a barcode scanning gun based on a logic table driven method, comprising the following process:
[0006] Process 1: According to the scanner setting code control process diagram, indicate how the setting code is processed. The specific steps are as follows:
[0007] Step 1: Create a setting code query table, and store various setting code strings in the setting table, such as enabling setting codes, disabling setting codes, turning on scanning prompt sounds, etc.
[0008] Step 2: After parsing the data, first determine whether the scan code setting function is enabled. If so, search the query table and match the setting code. If not, determine whether it is an enable setting instruction. If so, enter the scanner setting code setting mode. Otherwise, it prompts an invalid setting code.
[0009] Step 3: After determining that the scanner has entered the setup code setting mode, each subsequent scan will be used as a setup code to look up the table for matching. After matching the corresponding setting item, the relevant setting function will be directly called to further perform the corresponding setting. After the setting is completed, the entire setting procedure is completed and ended by scanning the save setting code and exiting the setting code. If not, the data scanned this time will be sent to the next processing link as general data;
[0010] Process 2: Code optimization, the specific steps are as follows:
[0011] Step 1: Set the code string macro definition, the code is as follows Figure 2 As shown;
[0012] Step 2: Integrate the scanner setting code, specific setting functions, and setting parameters into a whole as the element type of the scanner setting query table, as shown in the attached figure. Figure 3 As shown;
[0013] Step 3: Set up the function, as shown in the attached Figure 4 As shown;
[0014] Step 4: Scanner settings item set structure, all settings items as a property of the structure, global initialize a variable of this type, the code is as follows Figure 5 As shown;
[0015] Step 5: Set the code query table. The actual received scanner setting code needs to be compared with the elements in the table. The code is as shown in the attached Figure 6 As shown;
[0016] Step 6: Match the setting code. After enabling the scanner setting code setting mode, you need to use this function to match the setting code and trigger the setting action. The code is as follows: Figure 7 As shown;
[0017] Preferably, the setting code string described in step 1 of process 1 consists of letters, numbers and special characters, and the setting code string cannot be changed at will.
[0018] Preferably, the scanning prompt tone described in step 1 of process 1 is provided with a long prompt and a short prompt, and the default time of the long prompt is 120 seconds.
[0019] Preferably, the scan code described in step 2 of process 1 is a barcode and a QR code by default, and the scan code is provided with a key.
[0020] Preferably, the setting instruction in step 2 of process 1 is controlled by a character string plus several parameters, and the parameters in the setting instruction cannot be changed at will.
[0021] Preferably, the invalid setting code described in step 2 of process 1 has an automatic deletion function, and the time for automatic deletion of the invalid setting code is set to 1 second.
[0022] Preferably, the scanning guns described in step 3 of process 1 are wired scanning guns and wireless scanning guns by default, and the wireless scanning gun can be used for 30 days when fully charged.
[0023] Preferably, the setting value described in step 2 of process 2 can be changed as needed.
[0024] Preferably, the control scanning light described in step 3 of process 2 adopts LED lighting technology and laser lighting technology, and the scanning light lighting technology can be independently selected by the relevant person.
[0025] Compared with the prior art, the present invention has the following beneficial effects:
[0026] In resource-constrained systems, the table-driven approach effectively reduces the size of program code and improves system efficiency and response speed by reducing the use of logical judgment statements; by separating the setup code from the logical processing, the code structure is clearer and easier for developers to understand and maintain; the application of the table-driven approach provides a flexible infrastructure for the subsequent expansion of the scanner's functions, making the addition and integration of new functions easier and faster. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 This is the overall diagram of the scanner setting code processing flow;
[0028] Figure 2 It is the setting code string macro definition, the optimized C language code;
[0029] Figure 3 It is a code that integrates the scanner setting code, specific setting function and setting parameters into a whole as the element type of the scanner setting item query table;
[0030] Figure 4 It is the code for setting the function specifically;
[0031] Figure 5 It is the code to globally initialize a variable of this type;
[0032] Figure 6 It is the code that is actually received and scanned by the scanner setting code and matched with the elements in the table;
[0033] Figure 7 After enabling the scanner code setting mode, this function is needed to match the setting code and trigger the setting action. DETAILED DESCRIPTION
[0034] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0035] like Figure 1 As shown, an embodiment of the present invention provides a method for setting a barcode scanning gun based on a logic table driven method, including the following process:
[0036] Process 1: According to the scanner setting code control process diagram, indicate how the setting code is processed. The specific steps are as follows:
[0037] Step 1: Create a setting code query table, and store various setting code strings in the setting table, such as enabling setting codes, disabling setting codes, turning on scanning prompt sounds, etc.
[0038] Step 2: After parsing the data, first determine whether the scan code setting function is enabled. If so, search the query table and match the setting code. If not, determine whether it is an enable setting instruction. If so, enter the scanner setting code setting mode. Otherwise, it prompts an invalid setting code.
[0039] Step 3: After determining that the scanner has entered the setup code setting mode, each subsequent scan will be used as a setup code to look up the table for matching. After matching the corresponding setting item, the relevant setting function will be directly called to further perform the corresponding setting. After the setting is completed, the entire setting procedure is completed and ended by scanning the save setting code and exiting the setting code. If not, the data scanned this time will be sent to the next processing link as general data;
[0040] Process 2: Code optimization:
[0041] C language logical judgment in general:
[0042] if(0==strcmp(data,setStr))
[0043] {
[0044] / / Execute the corresponding scanner setting action 1
[0045] }
[0046] else if(0==strcmp(data,setStr1))
[0047] {
[0048] / / Execute the corresponding scanner setting action 2
[0049] }
[0050] else if(0==strcmp(data,setStr2))
[0051] {
[0052] / / Execute the corresponding scanner setting action 3
[0053] }
[0054] else if(0==strcmp(data,setStr2))
[0055] {
[0056] / / Execute the corresponding scanner setting action 4
[0057] }
[0058] else
[0059] {
[0060] / / Execute the corresponding scanner setting action 5
[0061] }
[0062] The specific steps are as follows:
[0063] Step 1: Set the code string macro definition. The optimized C language code is as follows: Figure 2 As shown;
[0064] The setting code string macro definition is used to facilitate developers to count and use the scanner setting code in the program.
[0065] Step 2: Integrate the scanner setting code, specific setting functions, and setting parameters into a whole as the element type of the scanner setting query table, as shown in the attached figure. Figure 3 As shown;
[0066] Step 3: Set up the function, as shown in the attached Figure 4 As shown;
[0067] Step 3: Scanner settings item set structure, all settings items as a property of the structure, global initialize a variable of this type, the code is as follows Figure 5 As shown;
[0068] Step 4: Set the code query table. The actual received scanner setting code needs to be compared and matched with the elements in the table. The code is as shown in the attached Figure 6 As shown:
[0069] Step 5: Match the setting code. After enabling the scanner setting code setting mode, you need to use this function to match the setting code and trigger the setting action. The code is as follows: Figure 7 As shown:
[0070] Attached Figure 7 The array contains some setting items. It is inconvenient to write and maintain logical judgment statements (if...else or switch...case), which will also make the system very complicated. At this time, the advantages of table-driven method begin to emerge.
[0071] This method decouples program logic from data and transfers the setting item information originally hard-coded in the program to a predefined data table, thereby achieving flexible configuration and dynamic adjustment of program behavior. Under the framework of the table-driven method, the program code is designed as a highly general instruction set that does not directly depend on specific data details. Data changes and additions and deletions of setting items are achieved by modifying the data table, which greatly simplifies the code structure and improves the readability and maintainability of the code.
[0072] The setting code string in step 1 of process 1 consists of letters, numbers and special characters, and the setting code string cannot be changed at will.
[0073] This design makes it easier for developers to count and use scanners to set codes in programs.
[0074] Among them, the scanning prompt tone of step 1 in process 1 is set to long prompt and short prompt, and the default time of the long prompt is 120 seconds.
[0075] This design will remind the operator for a long time when the scanner recognizes an error.
[0076] Among them, the scan code of step 2 in process 1 defaults to barcode and QR code, and the scan code is set with a key.
[0077] Such a design can effectively prevent the scan code from being forged, thereby improving the security of the use of the scan code.
[0078] Among them, the setting instruction of step 2 in process 1 is controlled by a string plus several parameters, and the parameters in the setting instruction cannot be changed at will.
[0079] This design ensures the uniqueness of the setting instructions.
[0080] Among them, the invalid setting code in step 2 of process 1 has an automatic deletion function, and the time for automatic deletion of the invalid setting code is set to 1 second.
[0081] This design avoids the situation where the scanner records a large number of invalid setting codes and causes insufficient memory.
[0082] Among them, the scanners in step three of process one are wired scanners and wireless scanners by default. The wireless scanner can be used for 30 days when fully charged.
[0083] With this design, the scanner gun has two options when in use.
[0084] Among them, the setting value of step 2 in process 2 can be changed as needed.
[0085] This design makes the setting value more flexible during use.
[0086] Among them, the control scanning light in step three of process two adopts LED lighting technology and laser lighting technology, and the scanning light lighting technology can be selected by the relevant person independently.
[0087] This design allows lighting technology to be selected by relevant people according to the needs of the items, thus bringing convenience to the relevant people's operation.
[0088] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0089] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. A method for setting a barcode scanning gun based on a logic table driven method, characterized in that: The following processes are included: Process 1: According to the scanner setting code control process diagram, indicate how the setting code is processed. The specific steps are as follows: Step 1: Create a setting code query table, and store various setting code strings in the setting code query table, including enabling setting codes, disabling setting codes, and turning on scanning prompt sounds; Step 2: After parsing the data, first determine whether the scan code setting function is enabled. If so, search the query table and match the setting code. If not, determine whether it is an enable setting instruction. If so, enter the scanner setting code setting mode. Otherwise, it prompts an invalid setting code. Step 3: After determining that the scanner has entered the setup code setting mode, each subsequent scan will be used as a setup code to look up the table for matching. After matching the corresponding setting item, the relevant setting function will be directly called to further perform the corresponding setting. After the setting is completed, the entire setting procedure is completed and ended by scanning the save setting code and exiting the setting code. If not, the data scanned this time will be sent to the next processing link as general data; Process 2: Code optimization, the specific steps are as follows: Step 1: Set the code string macro definition; Step 2: Integrate the scanner setting code, specific setting function and setting parameters into a whole as the element type of the scanner setting item query table; Step 3: Set up the function Step 4: Scanner settings item set structure, all settings items as a property of the structure, global initialization of a variable of this type; Step 5: Set the code query table. The actual received scanner setting code must be compared and matched with the elements in the table. Step 6: Match the setting code. After enabling the scanner setting code setting mode, this function is needed to match the setting code and trigger the setting action.
2. According to claim 1, a method for setting a barcode scanning gun based on a logic table driven method is characterized in that: The setting code string described in step 1 of process 1 consists of letters, numbers and special characters, and the setting code string cannot be changed at will.
3. According to claim 1, a method for setting a barcode scanning gun based on a logic table driven method is characterized in that: The scanning prompt tone described in step 1 of process 1 is set to have a long prompt and a short prompt, and the default time of the long prompt is 120 seconds.
4. According to claim 1, a method for setting a barcode scanning gun based on a logic table driven method is characterized in that: The scan codes described in step 2 of process 1 are barcodes and QR codes by default, and the scan codes are provided with a key.
5. According to claim 1, a method for setting a barcode scanning gun based on a logic table driven method is characterized in that: The setting instruction described in step 2 of process 1 is controlled by a string plus several parameters, and the parameters in the setting instruction cannot be changed at will.
6. The method for setting a barcode scanning gun based on a logic table driven method according to claim 1, characterized in that: The invalid setting code described in step 2 of process 1 has an automatic deletion function, and the time for automatic deletion of the invalid setting code is set to 1 second.
7. The method for setting a barcode scanning gun based on a logic table driven method according to claim 1, characterized in that: The scanners described in step 3 of process 1 are wired scanners and wireless scanners by default. The wireless scanner can be used for 30 days when fully charged.
8. The method for setting a barcode scanning gun based on a logic table driven method according to claim 1, characterized in that: The setting values described in step 2 of process 2 can be changed as needed.
9. The method for setting a barcode scanning gun based on a logic table driven method according to claim 1, characterized in that: The control scanning light described in step 3 of process 2 adopts LED lighting technology and laser lighting technology, and the scanning light lighting technology can be selected by the relevant person independently.
