Switch control method and device, electronic equipment and storage medium
By building a mapping relationship between customized instructions and official instructions, the problem of switch operation complexity is solved and efficient use by non-professional personnel is achieved.
Patent Information
- Application Number
- CN202510633053.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-05-16
- Publication Date
- 2025-08-08
AI Technical Summary
The operating threshold of existing switches is high, and it is difficult for non-professional personnel to use them proficiently, and it is prone to spelling errors and grammatical errors, which affects efficiency.
Build a mapping relationship between customized instructions and official instructions, and realize automatic matching and execution by inputting customized instructions instead of official instructions.
Improves the efficiency and user experience of switch operations, allowing non-professionals to easily execute complex switch instructions.
Smart Images

Figure CN120447967A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of switches, and in particular to a control method, device, electronic device, and storage medium for a switch. Background Art
[0002] Conventional switches require user configuration via either a web-based management interface or a reserved serial port for accessing the system's command line interface. This often requires extensive knowledge of specialized switch command syntax and parameter formats, making operation difficult for non-technical personnel or those unfamiliar with switch commands. The numerous and complex nature of switch commands makes manual input prone to spelling errors, grammatical errors, and parameter setting errors, impacting efficiency. Summary of the Invention
[0003] The present application aims to solve at least one of the technical problems existing in the prior art. To this end, the present application proposes a switch control method, device, electronic device, and storage medium that can input customized instructions to execute the official instructions of the switch, thereby improving efficiency.
[0004] The control method of a switch in the first embodiment of the present application includes:
[0005] The switch control method according to the embodiment of the present application has at least the following beneficial effects: by establishing a mapping relationship between customized instructions and official instructions, each customized instruction in the customized instruction text is ensured to have a corresponding official instruction. Therefore, when a target instruction input by a user is received, the customized instruction text is first traversed. If a customized instruction identical to the target instruction exists in the customized text, the official instruction mapped to the customized instruction is executed. This allows customized instructions to replace official instructions. Furthermore, because customized instructions are user-configured, users are more comfortable using customized instructions, thereby improving efficiency.
[0006] According to some embodiments of the present application, before obtaining the customized instruction text, the method further includes:
[0007] Acquire the actual storage space of the customized instruction text;
[0008] The actual storage space is compared with the preset storage space, and if the actual storage space is larger than the preset storage space, an error warning is triggered.
[0009] According to some embodiments of the present application, establishing a mapping relationship between the customized instruction and the official instruction includes:
[0010] Presetting characteristic parameters of the customized instruction to obtain a first characteristic parameter;
[0011] Preset the characteristic parameter of the official instruction to obtain the second characteristic parameter;
[0012] Based on the first characteristic parameter and the second characteristic parameter, the mapping relationship between the customized instruction and the official instruction is established, wherein one customized instruction can establish the mapping relationship with one or more official instructions.
[0013] According to some embodiments of the present application, after obtaining the customized instruction text, the method further includes:
[0014] Traversing the customized instruction text;
[0015] If it is detected that the customized instruction text contains multiple identical customized instructions, an error warning is triggered;
[0016] If it is not detected that the customized instruction text contains multiple identical customized instructions, the regular expressions of the customized instructions are processed for compatibility.
[0017] According to some embodiments of the present application, in response to receiving a target instruction input by a user, after traversing the customized instruction text, the method further includes:
[0018] Obtaining the actual instruction length of the target instruction;
[0019] If the actual instruction length is greater than a preset threshold instruction length, an error warning is triggered.
[0020] According to some embodiments of the present application, determining a target official instruction corresponding to the target instruction from the mapping relationship and executing the target official instruction includes:
[0021] If the target instruction corresponds to a target official instruction, executing the target official instruction;
[0022] If the target instruction corresponds to multiple target official instructions, the multiple target official instructions are executed in sequence.
[0023] According to some embodiments of the present application, after traversing the customized instruction text and comparing the customized instruction with the target instruction, the method further includes:
[0024] If no customized instruction identical to the target instruction is detected in the customized instruction text, traversing the official instruction text and comparing the official instruction with the target instruction;
[0025] If there is an official instruction in the official instruction text that is identical to the target instruction, the official instruction is executed.
[0026] The switch device according to the embodiment of the second aspect of the present application is applied to a switch;
[0027] The device comprises:
[0028] The parameter acquisition module is configured to acquire a customized instruction text, wherein the customized instruction text includes at least one customized instruction; acquire an official instruction text, wherein the official instruction text includes at least one official instruction; and construct a mapping relationship between the customized instruction and the official instruction.
[0029] The instruction execution module is configured to traverse the customized instruction text in response to receiving a target instruction input by the user, and compare the customized instruction with the target instruction; if there is a customized instruction identical to the target instruction in the customized instruction text, based on the target instruction, determine the target official instruction corresponding to the target instruction from the mapping relationship, and execute the target official instruction.
[0030] According to an electronic device of an embodiment of the third aspect of the present application, the electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the switch control method described in the embodiment of the first aspect of the present application when executing the computer program.
[0031] According to a computer-readable storage medium of an embodiment of the fourth aspect of the present application, the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the control method of the switch described in the embodiment of the first aspect of the present application is implemented.
[0032] Additional aspects and advantages of the present application will be given in part in the description below, and in part will become obvious from the description below, or will be learned through practice of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0033] The above and / or additional aspects and advantages of the present application will become apparent and easily understood from the description of the embodiments in conjunction with the following drawings, in which:
[0034] Figure 1 This is a flowchart of the steps of the switch control method according to an embodiment of the present application;
[0035] Figure 2 is a specific step flow chart of step S103;
[0036] Figure 3 is a specific step flow chart of step S104;
[0037] Figure 4 This is a flowchart of steps S401 to S502 of an embodiment of the present application;
[0038] Figure 5 This is a flowchart of steps S501 to S503 of an embodiment of the present application;
[0039] Figure 6 This is a flowchart of step S601 to step S602 in an embodiment of the present application;
[0040] Figure 7 This is a flowchart of step S701 to step S702 in an embodiment of the present application;
[0041] Figure 8 This is a schematic structural diagram of an electronic device according to an embodiment of the present application;
[0042] Figure 9 A schematic structural diagram of a sorting device according to an embodiment of the second aspect;
[0043] Figure 10 This is a schematic diagram of the mapping relationship between customized instructions and official instructions in JSON format according to an embodiment of the present application. DETAILED DESCRIPTION
[0044] The following describes in detail embodiments of the present application. Examples of the embodiments are shown in the accompanying drawings, wherein the same or similar reference numerals throughout represent the same or similar elements or elements having the same or similar functions. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present application and are not to be construed as limiting the present application.
[0045] In the description of this application, it should be understood that descriptions involving orientations, such as up, down, front, back, left, right, etc., indicating orientations or positional relationships, are based on the orientations or positional relationships shown in the accompanying drawings. They are only for the convenience of describing this application and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation. Therefore, they cannot be understood as limitations on this application.
[0046] In the description of this application, "several" means one or more, "many" means more than two, "greater than," "less than," and "exceed" are understood to exclude the number itself, while "above," "below," and "within" are understood to include the number itself. The terms "first" and "second" are used solely to distinguish technical features and are not to be construed as indicating or implying relative importance, or as implicitly specifying the number or order of the technical features indicated.
[0047] In the description of this application, unless otherwise clearly defined, terms such as setting, installing, and connecting should be understood in a broad sense, and technicians in the relevant technical field can reasonably determine the specific meanings of the above terms in this application based on the specific content of the technical solution.
[0048] Currently, there are many switch brands, and the command syntax of different switches may also be different. Traditional switches allow users to set up through web interface management, so users need to be familiar with the command syntax and parameter format of the switch, which has a high threshold. For some non-professional technicians, they will inevitably encounter problems with syntax commands during use, which will affect efficiency. Or the technicians are only familiar with the command syntax of a certain brand of switches, and they have to spend time re-learning the command syntax of other brands of switches. In addition, the command syntax of different brands of switches may be confused during use, further affecting efficiency.
[0049] Based on this, the present application proposes a control method, device, electronic device and storage medium for a switch, aiming to match customized instructions with official instructions, and call official instructions by inputting more familiar customized instructions, thereby improving efficiency.
[0050] The first embodiment of the present application proposes a control method for a switch based on a switch. Figure 1 , Figure 1 This is a flow chart of the steps of the switch control method according to an embodiment of the present application. Figure 1 The illustrated process steps include but are not limited to steps S101 to S105.
[0051] Step S101 : Obtain a customized instruction text, wherein the customized instruction text includes at least one customized instruction.
[0052] Step S102: Obtain an official instruction text; wherein the official instruction text includes at least one official instruction.
[0053] Step S103: constructing a mapping relationship between customized instructions and official instructions.
[0054] Step S104 , in response to receiving the target instruction input by the user, traverse the customized instruction text and compare the customized instruction with the target instruction.
[0055] In step S105 , if there is a customized instruction identical to the target instruction in the customized instruction text, a target official instruction corresponding to the target instruction is determined from a mapping relationship based on the target instruction, and the target official instruction is executed.
[0056] The switch control method according to the embodiment of the present application has at least the following beneficial effects: by establishing a mapping relationship between customized instructions and official instructions, each customized instruction in the customized instruction text is ensured to have a corresponding official instruction. Therefore, when a target instruction input by a user is received, the customized instruction text is first traversed. If a customized instruction identical to the target instruction exists in the customized text, the official instruction mapped to the customized instruction is executed. This allows customized instructions to replace official instructions. Furthermore, because customized instructions are user-configured, users are more comfortable using customized instructions, thereby improving efficiency.
[0057] In step S101 of some embodiments, the user uploads a customized instruction text on the text upload interface of the switch. The customized instruction text is edited and generated by the user. The upload interface includes a text box and a submit button. The user uploads the edited customized instruction text to the text box and clicks the submit button to obtain the customized instruction text.
[0058] In step S102 of some embodiments, the user uploads the official instruction text on the text upload interface of the switch, or directly obtains the official instruction text corresponding to the local switch model.
[0059] In some embodiments, reference Figure 2 , step S103 may include but is not limited to steps S201 to S203.
[0060] In step S201 , characteristic parameters of a customized instruction are preset to obtain a first characteristic parameter.
[0061] Step S202: preset characteristic parameters of the official instruction to obtain second characteristic parameters.
[0062] In step S203 , a mapping relationship between the customized instruction and the official instruction is established based on the first characteristic parameter and the second characteristic parameter, wherein a customized instruction can establish a mapping relationship with one or more official instructions.
[0063] In step S201 of some embodiments, the switch includes an instruction conversion module, and the user presets the first characteristic parameter in the instruction conversion module.
[0064] In step S202 of some embodiments, the user presets the second characteristic parameter in the instruction conversion module
[0065] In step S203 of some embodiments, in the json format, the command conversion module constructs a mapping relationship between the customized command and the official command through the first characteristic parameter and the second characteristic parameter. For example, the first characteristic parameter is "pattern" and the second characteristic parameter is "command_templates". By taking the customized command as the value of the first characteristic parameter and the official command as the value of the second characteristic parameter, the mapping relationship between the customized command and the official command is constructed. Figure 10 ,In the first instance, "open http tps" is a customized command, and "https enable" is the official command. In the second example, "r"ht tps timeout setting(\d+)s" is a customized instruction, and "httpstimeout{}" is an official instruction. In the second example, the numeric portion can be dynamically supported, that is, "\d+" can be replaced with one or more consecutive numeric characters during input. In other words, regardless of whether the target instruction entered by the user is "https timeo utsetting 0" or "https timeout setting 100", the customized instruction will match "r"httpstimeout setting(\d+)s" and execute the official instruction "https timeout 0" or "https timeout100". A customized instruction can simultaneously establish a mapping relationship with multiple official instructions. In the third example, "selfdefine action" is a customized instruction, while "https ena ble", "https timeout 60", and "port 3ratelimit 100" are official instructions. Multiple official instructions are separated by a preset delimiter, which can also be set by the user. In the third example, the delimiter is ",". During specific implementation, the user inputs the target instruction, first searches and matches the first characteristic parameter whose value contains the target instruction, then obtains the second characteristic parameter associated with the first characteristic parameter, and then extracts the official instruction contained in the value of the second characteristic parameter, and then executes the official instruction, thereby realizing the process of inputting customized instructions and executing official instructions.
[0066] In steps S201 to S203 of the embodiment of the present application, a mapping relationship between customized instructions and official instructions is constructed by setting the first characteristic parameter and the second characteristic parameter, making the process more standardized. One customized instruction can be mapped to multiple official instructions, making the application of customized instructions more flexible. Only one customized instruction is required, which is equivalent to inputting multiple official instructions, thereby improving the overall efficiency.
[0067] In some embodiments, reference Figure 3 , step S104 may include but is not limited to steps S301 to S302.
[0068] Step S301: If the target instruction corresponds to a target official instruction, the target official instruction is executed.
[0069] Step S302: If the target instruction corresponds to multiple target official instructions, the multiple target official instructions are executed in sequence.
[0070] In step S301 of some embodiments, the switch further includes an execution module. If there is only one target official instruction corresponding to the target instruction, the target official instruction is directly executed in the execution module.
[0071] In step S302 of some embodiments, if there are multiple target official instructions corresponding to the target instruction, such as Figure 10 In the third example, the customized instruction "self define action" is mapped to the three official instructions "https enable", "https timeout 60", and "port 3rate limit 100". Therefore, when the user enters "self define action" as the target instruction, "https enable", "https timeout 60", and "port 3rate limit 100" are its corresponding target official instructions, and these three target official instructions will be executed in sequence in the execution module.
[0072] In steps S301 to S302 of the embodiment of the present application, the target instruction can correspond to multiple target official instructions, and the target official instructions are executed in sequence. Therefore, during the functional test, the user can configure it in advance, so that by inputting one target instruction, multiple corresponding target official instructions can be executed in sequence, thereby completing the test. This greatly improves the efficiency of the test and also makes the control method of the switch of the present application have a wider range of application scenarios.
[0073] In some embodiments, reference Figure 4 , before step S101, it may also include but not limited to steps S401 to S402,
[0074] Step S401: Acquire the actual storage space of the customized instruction text.
[0075] Step S402: compare the actual storage space with the preset storage space. If the actual storage space is larger than the preset storage space, an error warning is triggered.
[0076] In step S401 of some embodiments, the customized instruction text uploaded by the user is detected to obtain the actual storage space of the customized instruction text.
[0077] In step S402 of some embodiments, the switch further includes a display module that compares the actual storage space with the preset storage space. When the actual storage space is larger than the preset storage space, an error warning is triggered, that is, an error prompt is output to the display module.
[0078] In steps S201 to S203 of the present embodiment, the actual storage space of the uploaded customized text is compared with the preset storage space, thereby preventing the customized text from occupying too much space and affecting the operation of the switch. Error warnings are output on the display module, allowing users to more intuitively understand the cause of the error.
[0079] It should be noted that after obtaining the customized text uploaded by the user, the format of the customized instruction text needs to be checked. If the format does not meet the preset requirements, an error warning will be triggered, that is, an error prompt will be output to the display module.
[0080] In some embodiments, reference Figure 5 , step S101 may also include but not limited to steps S501 to S503.
[0081] Step S501, traverse the customized instruction text.
[0082] In step S502 , if it is detected that there are multiple identical customized instructions in the customized instruction text, an error warning is triggered.
[0083] In step S503 , if it is not detected that the customized instruction text contains multiple identical customized instructions, a compatibility process is performed on the regular expressions of the customized instructions.
[0084] In step S501 of some embodiments, the customized instructions in the customized instruction text are traversed and compared in sequence. For example, the first customized instruction is compared with the other customized instructions one by one, then the second customized instruction is compared with the other customized instructions except the first customized instruction one by one, then the third customized instruction is compared with the other customized instructions except the first customized instruction and the second customized instruction one by one, and so on.
[0085] In step S502 of some embodiments, if it is detected during the traversal process that there are multiple identical customized instructions in the customized instruction text, an error warning is triggered, that is, an error prompt is output to the display module.
[0086] In step S503 of some embodiments, if no multiple identical customized instructions are detected in the customized instruction text after the traversal is completed, the regular expression of the customized instruction is processed for compatibility, that is, the customized instruction assigned by the first characteristic parameter and the official instruction assigned by the second characteristic parameter are processed for compatibility accordingly according to the programming language used. For example, when using Python, the re and json modules need to be imported. The value of the first parameter "pattern" is the customized instruction "r"https timeout setting(\d+)s", and the value of the second parameter "command_templates" is the official instruction "https timeout{}". When implementing in C, the POSIX regular expression library and libjson library need to be imported. Since "\d" is not part of the standard definition of the C language, the customized instruction for the first parameter "pattern" should be changed to "r"http s timeoutsetting([0-9]+)s". Correspondingly, the official instruction for the second parameter "command_templates" should also be changed to "https timeout%s". The final result is that regardless of whether the target instruction entered by the user is "https timeout setting 0" or "https timeout setting 100", the customized instruction will match "r"https timeout setting([0-9]+)s", and the official instruction "https timeout 0" or "httpstimeout 100".
[0087] In steps S501 to S503 of the embodiment of the present application, repeated customized instructions may cause instruction conflicts and fail to execute, thereby affecting efficiency. The present application avoids repeated customized instructions in the customized instruction text by traversing the customized instruction text, and performs compatible processing on the regular expressions of the customized instructions, so that the customized instructions can still be correctly executed in different virtual environments or coding languages, promoting the use of customized instructions in more scenarios; and outputting error warnings on the display module allows users to more intuitively understand the cause of the error.
[0088] In some embodiments, reference Figure 6 , step S104 may also include but not limited to step S601 to step S602.
[0089] Step S601: Obtain the actual instruction length of the target instruction.
[0090] Step S602: If the actual instruction length is greater than a preset threshold instruction length, an error warning is triggered.
[0091] In step S601 of some embodiments, multiple target instructions can be input, and each target instruction is separated by a spacing symbol, for example: "open https; r"https timeout setting(\d+)s", "open https" and "r"https timeout setting(\d+)s" are two target instructions input, and are separated by ";", and then the actual instruction length of the input target instruction is obtained.
[0092] In step S602 of some embodiments, the actual instruction length obtained is compared with a threshold instruction length. If the actual instruction length exceeds the threshold instruction length, an error warning is triggered, that is, an error prompt is output to the display module.
[0093] In steps S601 and S602 of the embodiment of the present application, a preset threshold instruction length is used to limit the input target instruction, thereby preventing the user from inputting too many target instructions, which may cause the switch to be unable to execute them in a timely manner and may damage the switch. In addition, an error warning is output on the display module, so that the user can more intuitively understand the cause of the error.
[0094] In some embodiments, reference Figure 7 , step S104 may also include but not limited to step S701 to step S702.
[0095] In step S701 , if no customized instruction identical to the target instruction is detected in the customized instruction text, the official instruction text is traversed and the official instruction is compared with the target instruction.
[0096] Step S702: If there is an official instruction in the official instruction text that is the same as the target instruction, execute the official instruction.
[0097] In step S701 of some embodiments, if no customized instruction identical to the target instruction input by the user is detected in the customized instruction text, the target instruction is directly compared with the official instructions in the official instruction text one by one.
[0098] In step S702 of some embodiments, if an official instruction identical to the target instruction exists in the official instruction text, the official instruction is executed. If no official instruction identical to the target instruction is detected in the official instruction text, the target instruction entered by the user is determined to be misspelled, triggering an error warning.
[0099] In steps S701 to S702 of the embodiment of the present application, by matching the target command that does not match the customized command text with the official command, even if the user forgets the customized command they edited, they can still enter the official command. This makes the control method of the switch of the present application more flexible. That is, both the customized command and the official command can be executed as the target command, thereby improving efficiency.
[0100] Reference Figure 9 , Figure 9 This is a structural diagram of a switch device according to an embodiment of the second aspect of the present application. The switch device according to the embodiment of the present application is applied to a switch, and the switch device includes:
[0101] The parameter acquisition module 901 is configured to acquire a customized instruction text, wherein the customized instruction text includes at least one customized instruction; acquire an official instruction text, wherein the official instruction text includes at least one official instruction; and establish a mapping relationship between the customized instruction and the official instruction.
[0102] The instruction execution module 902 is configured to traverse the customized instruction text in response to receiving the target instruction input by the user, and compare the customized instruction with the target instruction; if there is a customized instruction identical to the target instruction in the customized instruction text, based on the target instruction, determine the target official instruction corresponding to the target instruction from the mapping relationship, and execute the target official instruction.
[0103] The third aspect of the present application also provides an electronic device, comprising a memory 802 and a processor 801. The memory 802 stores a computer program, and the processor 801 executes the computer program to implement the switch control method according to the first aspect. The electronic device can be any smart terminal, including a tablet computer and an in-vehicle computer.
[0104] Reference Figure 8 , Figure 8 FIG. 1 is a schematic diagram of the structure of an electronic device according to an embodiment. The electronic device includes:
[0105] The processor 801 may be implemented as a general-purpose CPU (Central Processing Unit), a microprocessor, an application-specific integrated circuit (ASIC), or one or more integrated circuits, and is used to execute relevant programs to implement the technical solutions provided in the embodiments of the present application.
[0106] The memory 802 can be implemented in the form of a read-only memory, a static storage device, a dynamic storage device, or a random access memory (RAM). The memory 802 can store an operating system and other application programs. When the technical solutions provided in the embodiments of this specification are implemented through software or firmware, the relevant program code is stored in the memory 802 and is called by the processor 801 to execute the television frame laser method of the embodiment of this application;
[0107] Input / output interface 803, used to implement information input and output;
[0108] Communication interface 804, used to implement communication interaction between this device and other devices, which can be achieved through wired communication or wireless communication;
[0109] bus 805, which transmits information between the various components of the device;
[0110] The processor 801 , the memory 802 , the input / output interface 803 and the communication interface 804 are connected to each other in communication within the device via a bus 805 .
[0111] The fourth aspect of the present application further provides a computer-readable storage medium, which stores a computer program. When the computer program is executed by a processor, it implements the control method of the switch of the first aspect.
[0112] The memory, as a non-transient computer-readable storage medium, can be used to store non-transient software programs and non-transient computer executable programs. In addition, the memory may include a high-speed random access memory and may also include a non-transient memory, such as at least one disk storage device, a flash memory device, or other non-transient solid-state storage device. In some embodiments, the memory may optionally include a memory remotely arranged relative to the processor, and these remote memories may be connected to the processor via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0113] The embodiments described in the embodiments of this application are intended to more clearly illustrate the technical solutions of the embodiments of this application and do not constitute a limitation on the technical solutions provided by the embodiments of this application. Those skilled in the art will appreciate that with the evolution of technology and the emergence of new application scenarios, the technical solutions provided in the embodiments of this application are also applicable to similar technical problems.
[0114] Those skilled in the art will understand that the technical solutions shown in the figures do not constitute a limitation on the embodiments of the present application, and may include more or fewer steps than shown in the figures, or a combination of certain steps, or different steps.
[0115] The device embodiments described above are merely illustrative. The units described as separate components may or may not be physically separate, i.e., they may be located in one place or distributed across multiple network units. Some or all of the modules may be selected based on actual needs to achieve the objectives of this embodiment.
[0116] Those skilled in the art will appreciate that all or some of the steps in the methods, systems, and functional modules / units in the devices disclosed above may be implemented as software, firmware, hardware, or appropriate combinations thereof.
[0117] The terms "first", "second", "third", "fourth", etc. (if any) in the specification of the present application and the above-mentioned drawings are used to distinguish similar objects and are not necessarily used to describe a specific order or sequential order. It should be understood that the data used in this way can be interchangeable where appropriate, so that the embodiments of the present application described herein can be implemented in an order other than those illustrated or described herein. In addition, the terms "including" and "having" and any variations thereof are intended to cover non-exclusive inclusions, for example, a process, method, system, product or device that includes a series of steps or units is not necessarily limited to those steps or units clearly listed, but may include other steps or units that are not clearly listed or inherent to these processes, methods, products or devices.
[0118] It should be understood that in this application, "at least one (item)" means one or more, and "plurality" means two or more. "And / or" is used to describe the association relationship of associated objects, indicating that three relationships may exist. For example, "A and / or B" can mean: only A exists, only B exists, and A and B exist at the same time, where A and B can be singular or plural. The character " / " generally indicates that the previous and next associated objects are in an "or" relationship. "At least one of the following items" or similar expressions refers to any combination of these items, including any combination of single items or plural items. For example, at least one of a, b or c can mean: a, b, c, "a and b", "a and c", "b and c", or "a and b and c", where a, b, c can be single or multiple.
[0119] In the several embodiments provided in this application, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely schematic. For example, the division of the above-mentioned units is only a logical function division. In actual implementation, there may be other division methods, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0120] The units described above as separate components may or may not be physically separate, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed across multiple network units. Some or all of these units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0121] In addition, the functional units in the various embodiments of the present application may be integrated into a single processing unit, or each unit may exist physically separately, or two or more units may be integrated into a single unit. The aforementioned integrated units may be implemented in the form of hardware or software functional units.
[0122] If the integrated unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, or all or part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium and includes multiple instructions for enabling a computer device (which can be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of various embodiments of the present application. The aforementioned storage medium includes: various media that can store programs, such as a USB flash drive, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk.
[0123] The preferred embodiments of the present invention are described above with reference to the accompanying drawings, but are not intended to limit the scope of the present invention. Any modifications, equivalent substitutions, and improvements made by those skilled in the art without departing from the scope and essence of the present invention should be within the scope of the present invention.
Claims
1. A method for controlling a switch, characterized in that: Applied to switches; The method comprises: Obtaining a customized instruction text, wherein the customized instruction text includes at least one customized instruction; Obtaining an official instruction text; wherein the official instruction text includes at least one official instruction; Establishing a mapping relationship between the customized instructions and the official instructions; In response to receiving a target instruction input by a user, traversing the customized instruction text and comparing the customized instruction with the target instruction; If there is a customized instruction identical to the target instruction in the customized instruction text, a target official instruction corresponding to the target instruction is determined from the mapping relationship based on the target instruction, and the target official instruction is executed.
2. The switch control method according to claim 1, wherein: Before obtaining the customized instruction text, the method further includes: Acquire the actual storage space of the customized instruction text; The actual storage space is compared with the preset storage space, and if the actual storage space is larger than the preset storage space, an error warning is triggered.
3. The switch control method according to claim 1, wherein: The step of establishing a mapping relationship between the customized instruction and the official instruction includes: Presetting characteristic parameters of the customized instruction to obtain a first characteristic parameter; Preset the characteristic parameter of the official instruction to obtain the second characteristic parameter; Based on the first characteristic parameter and the second characteristic parameter, the mapping relationship between the customized instruction and the official instruction is established, wherein one customized instruction can establish the mapping relationship with one or more official instructions.
4. The switch control method according to claim 1, wherein: After obtaining the customized instruction text, the following steps are also included: Traversing the customized instruction text; If it is detected that the customized instruction text contains multiple identical customized instructions, an error warning is triggered; If it is not detected that the customized instruction text contains multiple identical customized instructions, the regular expressions of the customized instructions are processed for compatibility.
5. The switch control method according to claim 1, wherein: In response to receiving the target instruction input by the user, after traversing the customized instruction text, the method further includes: Obtaining the actual instruction length of the target instruction; If the actual instruction length is greater than a preset threshold instruction length, an error warning is triggered.
6. The switch control method according to claim 3, wherein: The determining a target official instruction corresponding to the target instruction from the mapping relationship and executing the target official instruction includes: If the target instruction corresponds to a target official instruction, executing the target official instruction; If the target instruction corresponds to multiple target official instructions, the multiple target official instructions are executed in sequence.
7. The switch control method according to claim 1, wherein: After traversing the customized instruction text and comparing the customized instruction with the target instruction, the method further includes: If no customized instruction identical to the target instruction is detected in the customized instruction text, traversing the official instruction text and comparing the official instruction with the target instruction; If there is an official instruction in the official instruction text that is identical to the target instruction, the official instruction is executed.
8. A switch device, characterized in that: Applied to switches; The device comprises: The parameter acquisition module is configured to acquire a customized instruction text, wherein the customized instruction text includes at least one customized instruction; acquire an official instruction text, wherein the official instruction text includes at least one official instruction; and construct a mapping relationship between the customized instruction and the official instruction. The instruction execution module is configured to traverse the customized instruction text in response to receiving a target instruction input by the user, and compare the customized instruction with the target instruction; if there is a customized instruction identical to the target instruction in the customized instruction text, based on the target instruction, determine the target official instruction corresponding to the target instruction from the mapping relationship, and execute the target official instruction.
9. An electronic device, characterized in that: The electronic device includes a memory and a processor, the memory stores a computer program, and the processor implements the switch control method according to any one of claims 1 to 7 when executing the computer program.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the switch control method according to any one of claims 1 to 7 is implemented.