A method and device for recording SCPI commands of an instrument
By monitoring user interface operation events and generating SCPI instructions, the technical barriers of vector network analyzer programming operations are solved, user experience and work efficiency are improved, and automatic conversion of interface operation to instructions is realized.
Patent Information
- Application Number
- CN202410572657.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-05-10
- Publication Date
- 2024-12-27
- Estimated Expiration
- 2044-05-10
AI Technical Summary
When professional users and software engineers use vector network analyzers, there are technical barriers to program using SCPI instructions through software programming, making it difficult to convert interface operations into executable SCPI instruction scripts, affecting user experience and efficiency.
Provides SCPI instruction recording methods and devices, and generates and saves corresponding SCPI instructions by monitoring user interface operation events, forming executable script files, supporting Python, C++ and C# script types, realizing automatic conversion of interface operations to instructions.
It significantly improves the experience and convenience of users using vector network analyzers, simplifies operational processes, improves work efficiency, and facilitates users to reuse scripts.
Smart Images

Figure CN118349317B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of software application, and in particular to a method and device for recording SCPI instructions of an instrument. Background Art
[0002] Vector network analyzers are rich in functions, and the operation interfaces of vector network analyzers from different manufacturers are different. Therefore, when operating a vector network analyzer, users generally have two operation methods. One is based on the user directly operating the vector network analyzer interface, and the vector network analyzer software directly responds to the user's operation and performs the corresponding action. The other is for the user to send SCPI instructions corresponding to the function, and the vector network analyzer parses and performs the corresponding action after receiving the instruction. Among them, SCPI (Standard Commands for Programmable Instruments) defines a set of standard syntax, command structure and data format for controlling programmable test and measurement instruments. This command can be used for any instrument, and the same type of commands belong to the same subsystem. SCPI also defines several types of instruments. SCPI commands are composed of a series of keywords, and some also need to include parameters.
[0003] For most professional users, they understand the principle of vector network analyzers and can skillfully control the instrument through the software interface, but there are often great technical barriers to program the instrument using SCPI commands through software programming; and for software engineers, the principle and application of vector network analyzers are also beyond their technical scope. Therefore, for users, being able to quickly help users convert interface operations into executable scripts based on SCPI commands can significantly improve the user experience and convenience of using the instrument. Summary of the invention
[0004] The purpose of the present invention is to provide a SCPI command recording method and device, to provide a command recording function for users, to generate an executable SCPI command script for storing the operations performed by users, and when operating again in the future, the user can directly call the corresponding executable SCPI command script to perform the corresponding operation, thereby facilitating the user's operation of a vector network analyzer and improving the user experience.
[0005] On the one hand, the present application provides a SCPI command recording method, comprising the following steps:
[0006] S1, receiving the SCPI command recording enable switch signal, and starting to record the instrument interface operation commands;
[0007] S2, monitoring the target control of the user's operation event on the instrument interface and the response to the operation event, and determining the position of the target control in the control tree;
[0008] S3, searching the command part of the SCPI instruction corresponding to the target control in the instruction tree according to the position of the control tree, parsing the parameter part of the SCPI instruction according to the response of the operation event, splicing the parameter part and the command part into a complete SCPI instruction, and saving it;
[0009] S4. After all operation events are recorded, all complete SCPI instructions are written into a preset script template according to the selected preset script type to generate an executable script file.
[0010] In some specific implementations, the control tree and the instruction tree correspond one to one, and the target control of the control tree can retrieve a unique SCPI instruction in the instruction tree. The tree structure contains multiple levels and can cover all SCPI instructions.
[0011] In some specific embodiments, the steps of step S2 are:
[0012] S21, obtaining the current response control corresponding to the operation event of the user on the instrument interface;
[0013] S22, determining the control level of the current response control in the control tree, if the control level is a root node control, continue to monitor the user's operation events on the instrument interface, and jump to step S21;
[0014] If the control level is a sub-node control and the sub-node control is the smallest node control, then jump to execute S23;
[0015] S23, determining the current response control as the target control for processing the target operation event in the instrument interface.
[0016] In some specific embodiments, each node of the instruction tree corresponds to the command part of each SCPI instruction, the instruction tree includes several root node instructions, each root node instruction includes several sub-node instructions, each SCPI instruction includes a complete path from the root node to the sub-node, the root node instruction name corresponds to the control name of the root node control, and the sub-node instruction name corresponds to the control name of the sub-node control.
[0017] In some specific implementations, the process of obtaining a complete SCPI instruction is:
[0018] S31, according to the position of the target control in the control tree, recursively search in the instruction tree to obtain the complete path of the current target control in the instruction tree, and then obtain the command part of the SCPI instruction;
[0019] S32, obtaining the response status of all operation events corresponding to the target control, and parsing them into the parameter part of the SCPI instruction;
[0020] S33, combining the command part and the parameter part to generate a corresponding SCPI instruction.
[0021] In some specific implementations, the specific process of recursive search in step S32 is:
[0022] Locate the target control in the instruction tree according to its control level and control name;
[0023] According to the index relationship of the current target control, the next level node is searched downward in the instruction tree to determine the root node instruction corresponding to the current target control and the sub-node instructions under the root node instruction;
[0024] The found root node instruction and all sub-node instructions are arranged in order starting from the root node to form a complete path of SCPI instructions.
[0025] In some specific implementations, the preset script types include Python, C++, and C# script programs.
[0026] In some specific implementations, the script template in step S4 includes an instrument connection and control part, a SCPI command query and setting function part, and a SCPI command execution function part, and all recorded complete SCPI commands are written into the SCPI command execution function part.
[0027] In some specific implementations, the status of the switch for enabling recording SCPI instructions is monitored in real time. Before receiving a signal to turn off the switch for enabling recording SCPI instructions, a SCPI instruction is generated for each target control based on the monitored operation process of the user on all target controls on the instrument interface. The executable script file includes several SCPI instructions.
[0028] In a second aspect, the present application provides a SCPI command recording device for an instrument, comprising:
[0029] A recording command configuration unit, used to configure the connection parameters of the instrument for the user, control the state of the recording SCPI command enable switch, and record or end the recording of the instrument interface operation according to the state of the recording SCPI command enable switch;
[0030] An operation event monitoring unit is used to monitor the target control of the user's operation event on the instrument interface and the response to the operation event, and determine the position of the target control in the control tree;
[0031] The parsing and generating instruction unit is used to retrieve the command part of the SCPI instruction corresponding to the target control in the instruction tree according to the position of the control tree, parse the parameter part of the SCPI instruction according to the response of the operation event, splice the parameter part and the command part into a complete SCPI instruction, and save it;
[0032] The execution script generation unit is used to write all complete SCPI instructions into a preset script template according to the selected preset script type after all operation events are recorded, so as to generate an executable script file.
[0033] The present invention has the beneficial effects:
[0034] For most professional users, they understand the principle of vector network analyzers and can skillfully control the instrument through the software interface, but there are often great technical barriers to program the instrument using SCPI instructions through software programming; and for software engineers, the principle and application of vector network analyzers are also beyond their technical scope. Therefore, for users, being able to quickly help users convert interface operations into executable scripts based on SCPI instructions can significantly improve the user experience and convenience of using the instrument; at the same time, the generated scripts can be reused, which also improves work efficiency. BRIEF DESCRIPTION OF THE DRAWINGS
[0035] Figure 1 A flow chart of the SCPI command recording method provided in this embodiment;
[0036] Figure 2 Another SCPI command recording method flow chart provided in this embodiment;
[0037] Figure 3 A schematic diagram of the structure of the control tree provided in this embodiment;
[0038] Figure 4 A schematic diagram of the layout of the operating interface controls provided in this embodiment;
[0039] Figure 5 A schematic diagram of a secondary node control of the operation interface provided in this embodiment;
[0040] Figure 6 A schematic diagram of an executable SCPI command Python script provided for this embodiment. DETAILED DESCRIPTION
[0041] 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, rather than all the embodiments. The following description of at least one exemplary embodiment is actually only illustrative and is by no means intended to limit the present invention and its application or use. 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.
[0042] The relative arrangement of components and steps, the numerical expressions and numerical values set forth in these embodiments do not limit the scope of the present invention unless specifically stated otherwise.
[0043] At the same time, it should be understood that for the convenience of description, the sizes of the various parts shown in the drawings are not drawn according to the actual proportional relationship.
[0044] Additionally, descriptions of well-known structures, functions, and configurations may be omitted for clarity and conciseness.One of ordinary skill in the art will recognize that various changes and modifications may be made to the examples described herein without departing from the spirit and scope of the present disclosure.
[0045] Technologies, methods, and apparatus known to ordinary technicians in the relevant field may not be discussed in detail, but where appropriate, such technologies, methods, and apparatus should be considered part of the authorization specification.
[0046] In all examples shown and discussed herein, any specific values should be interpreted as merely exemplary and not as limiting. Therefore, other examples of the exemplary embodiments may have different values.
[0047] Example 1
[0048] like Figure 1 As shown, this embodiment provides a SCPI command recording method, comprising the following steps:
[0049] S1. Turn on the switch to enable recording SCPI commands, receive the start enable signal of the switch to enable recording SCPI commands, and start recording the commands of the instrument interface operation;
[0050] S2, monitoring all operation events of the user in the instrument interface, determining the target control for processing the target operation event in the instrument interface, obtaining the control information of the target control, and determining the position of the target control in the control tree;
[0051] For each operation, it is necessary to obtain the response to the operation event; each control in the instrument interface is encapsulated with control information, which includes the control name, the control level in the control tree and the index relationship. The control level can be divided into root node control and sub-node control. The sub-node control is divided into minimum node control and sub-root node control according to whether it contains other sub-node controls. The minimum node control can be understood as no more expanded controls after clicking the sub-node control. The sub-root node control is the control that clicks the sub-node control, and the control can be further divided downward. For the target control, since it is a target operation event, the control level is generally the minimum node control, and the index relationship is the parent control of the current control index, that is, the index relationship of the target control is generally the minimum node control-sub-root node control-root node control.
[0052] Generally, a SCPI instruction corresponds to a complete target operation event, and a complete target operation event may include multiple steps of operation, so multiple operation events are performed on the instrument interface, and each SCPI instruction generally points to the target event that the minimum node control responds to. Therefore, the event corresponding to the minimum node control needs to be used as the target operation event. For example, if you want to execute the target operation event: add a trace, you need to click the trace selection control under the root node control trace control, and then select the minimum node control to add a trace control, and then add the trace control as the target control. Figure 2 As shown, if the SCPI command recording switch is enabled, the software will continue to monitor all operation events of the user on the instrument interface, and these operation events may include multiple target operation events. Therefore, according to all the target operation events of the user on the instrument interface monitored, at least one SCPI command is generated for each target operation event. In this way, each time the recording command is executed, multiple SCPI commands will be generated, and these SCPI commands can be stored in the corresponding positions in the executable SCPI command script in the order of operation.
[0053] Therefore, in order to determine the target control, the following steps need to be performed while monitoring the user's operation on the instrument interface:
[0054] S21, obtaining the current response control corresponding to the operation event of the user on the instrument interface;
[0055] S22, determining the control level of the current response control in the control tree, if the control level is a root node control, continue to monitor the user's operation events on the instrument interface, and jump to step S21;
[0056] If the control level is a sub-node control and the sub-node control is the smallest node control, then jump to execute S23;
[0057] S23, determining the current response control as the target control for processing the target operation event in the instrument interface.
[0058] S3, parsing the control information according to the instruction tree to generate corresponding SCPI instructions;
[0059] In the present application, each node of the instruction tree corresponds to the command part of each SCPI instruction. The instruction tree includes several root node instructions, each root node instruction includes several sub-node instructions, and each sub-node instruction can be used as a root node, so that each sub-node instruction includes several sub-node instructions, which are divided all the way to the smallest sub-node (that is, the sub-node is no longer divided downward). Each SCPI instruction includes the complete path from the root node to the smallest sub-node. The root node instruction name corresponds to the control name of the root node control, the sub-node instruction name corresponds to the control name of the sub-node control, and the name of the smallest sub-node instruction corresponds to the name of the smallest sub-node control. Specifically, Figure 3 As shown, taking the root node control trace control as an example, its corresponding root node instruction is the trace, and there are multiple sub-node instructions. For the sub-node control trace selection control, it can be divided downward into the minimum node control.
[0060] The process of parsing the control information to generate SCPI instructions is:
[0061] S31, recursively search in the instruction tree according to the control information to obtain the complete path of the current target control in the instruction tree, and then obtain the command part of the SCPI instruction;
[0062] The specific process of recursive search is as follows:
[0063] Locate the target control in the instruction tree according to its control level and control name;
[0064] Determine the path of the current target control in the instruction tree according to the index relationship of the current target control, and search downward from the root node instruction corresponding to the current target control according to the index relationship until the minimum secondary node instruction is found;
[0065] The found root node instruction and all sub-node instructions are arranged in order starting from the root node to form a complete path of SCPI instructions.
[0066] S32, obtaining the response status of all operation events corresponding to the target control, and parsing them into the parameter part of the SCPI instruction;
[0067] S33, combining the command part and the parameter part to generate a corresponding SCPI instruction.
[0068] S4. After all operation events are recorded, all complete SCPI instructions are written into a preset script template according to the selected preset script type to generate an executable script file.
[0069] The language type of the script template in this application can be one of Python, C++ or C# scripts. Although the language types of the script templates are different, each script template includes the connection and control part of the instrument, the SCPI command query and setting function part, and the SCPI command execution function part. All complete recorded SCPI commands are written into the SCPI command execution function part. Among them, the SCPI command writing module is used to write the generated SCPI commands, the instrument control definition module is used to define the model and connection method of the currently operated vector network analyzer, and the SCPI command function setting module is used to query and set the recorded SCPI commands. After the user writes the SCPI command into the SCPI command script, the executable SCPI command script obtained can be named, so that the next time the instrument is operated, it is only necessary to find and call the required executable SCPI command script according to the script name and execute the script, which is convenient for user operation, and provides users with more choices, improves user operation efficiency, and enhances user experience.
[0070] For example, Figure 4 , Figure 5As shown, the present application provides an operation interface of an instrument, corresponding to the hierarchical structure of a control tree. It can be seen that the control tree includes root node controls, such as system operation controls (control name: System), trace operation controls (control name: Trace), display operation controls (control name: Display), and channel selection controls (control name: Channel). Under each root node control, several sub-node controls are included. The system operation control includes 6 sub-node controls: save operation control (Save), recall operation control (Recall), system configuration operation control (System Config), print capture operation control (Print Capture) and help operation control (Help). The trace operation control includes 9 sub-node controls: measurement type operation control (Measure), format operation control (Format), scale operation control (Scale), trace selection operation control (Trace Select), limit line operation control (Lines), trace function operation control (Trace Function), marker operation control (Marker), search operation control (Search) and marker function operation control (Marker Function). The display operation control includes two sub-node controls: display configuration operation control (Display Config) and area selection operation control (Area Select), channel operation control includes 9 sub-node operation controls: stimulus operation control (Stimulus), mode selection operation control (Mode), calibration operation control (Cal), sweep operation control (Sweep), intermediate frequency bandwidth operation control (BW), power operation control (Power), average operation control (Average), trigger operation control (Trigger) and channel selection operation control (Channel Select), sub-node operation control can include several sub-node operation controls and the sub-node operation control will not be divided downward at this time, which is the smallest node control, such as trace selection operation control can also include active trace control (Active Trace), add trace operation (AddTrace), add trace + diagram control (Add Trace + Diagram), next trace (Next trace), delete trace operation control (Delete Trace), etc.
[0071] After the recording command is turned on, each user operation will be monitored according to the user's operation on the instrument interface, generating multiple operation events. During these operations, for each root node control, only when the operation is carried out all the way down to the smallest node control, the operation of the target event is completed. At this time, you only need to obtain the information of the target control, and search the corresponding instruction tree according to the control information of the target control to obtain the SCPI instruction generated corresponding to the current target operation event, and write the instruction into the script template. The software monitors the status of the current recording command in real time. When the recording stop command is detected, the currently generated script template is saved according to the required script type to obtain an executable SCPI command script.
[0072] like Figure 6 As shown in the figure, a generated SCPI command script is given. At the beginning, the connection type, connection parameters, control and other definitions of the current operating instrument are defined, and then the setting function of the SCPI command query and the SCPI command execution function are set. Then, multiple complete SCPI commands generated according to user operations are written in the SCPI command execution function part. Finally, the script can be directly called by the instrument to execute the SCPI commands therein, which facilitates the user's operation.
[0073] Example 2
[0074] This embodiment provides a SCPI command recording device based on the method in Embodiment 1 to implement the recording method recorded in Embodiment 1. The device includes:
[0075] A recording command configuration unit, used to configure the connection parameters of the instrument for the user, control the state of the recording SCPI command enable switch, and record or end the recording of the instrument interface operation according to the state of the recording SCPI command enable switch;
[0076] An operation event monitoring unit is used to monitor the target control of the user's operation event on the instrument interface and the response to the operation event, and determine the position of the target control in the control tree;
[0077] The parsing and generating instruction unit is used to retrieve the command part of the SCPI instruction corresponding to the target control in the instruction tree according to the position of the control tree, parse the parameter part of the SCPI instruction according to the response of the operation event, splice the parameter part and the command part into a complete SCPI instruction, and save it;
[0078] The execution script generation unit is used to write all complete SCPI instructions into a preset script template according to the selected preset script type after all operation events are recorded, so as to generate an executable script file.
[0079] The above description is only a preferred embodiment of the present invention and does not limit the present invention in any form. According to the technical essence of the present invention, within the spirit and principles of the present invention, any simple modification, equivalent replacement and improvement made to the above embodiment still falls within the protection scope of the technical solution of the present invention.
Claims
1. A method for recording SCPI commands of an instrument, characterized in that: The following steps are involved: S1, receiving the SCPI command recording enable switch signal, and starting to record the instrument interface operation commands; S2, monitor the target control of the user's operation event on the instrument interface and the response to the operation event, and determine the position of the target control in the control tree; the control tree and the instruction tree correspond one to one, and the target control of the control tree can retrieve a unique SCPI instruction in the instruction tree; S21, obtaining the current response control corresponding to the operation event of the user on the instrument interface; S22, determining the control level of the current response control in the control tree, if the control level is a root node control, continue to monitor the user's operation events on the instrument interface, and jump to step S21; If the control level is a sub-node control and the sub-node control is the smallest node control, then jump to execute S23; S23, determining the current response control as the target control for processing the target operation event in the instrument interface; S3, searching the command part of the SCPI instruction corresponding to the target control in the instruction tree according to the position of the control tree, parsing the parameter part of the SCPI instruction according to the response of the operation event, splicing the parameter part and the command part into a complete SCPI instruction, and saving it; The process of getting a complete SCPI command is: S31, according to the position of the target control in the control tree, recursively search in the instruction tree to obtain the complete path of the current target control in the instruction tree, and then obtain the command part of the SCPI instruction; The specific process of recursive search in step S31 is: Locate the target control in the instruction tree according to its control level and control name; According to the index relationship of the current target control, the next level node is searched downward in the instruction tree to determine the root node instruction corresponding to the current target control and the sub-node instructions under the root node instruction; The root node instruction and all sub-node instructions found are arranged in order starting from the root node to form a complete path of SCPI instructions; S32, obtaining the response status of all operation events corresponding to the target control, and parsing them into the parameter part of the SCPI instruction; S33, merging the command part and the parameter part to generate corresponding SCPI instructions; S4. After all operation events are recorded, all complete SCPI instructions are written into a preset script template according to the selected preset script type to generate an executable script file.
2. The SCPI command recording method of an instrument according to claim 1, characterized in that: Each node of the instruction tree corresponds to the command part of each SCPI instruction. The instruction tree includes several root node instructions. Each root node instruction includes several sub-node instructions. Each SCPI instruction includes a complete path from the root node to the sub-node. The root node instruction name corresponds to the control name of the root node control, and the sub-node instruction name corresponds to the control name of the sub-node control.
3. The SCPI command recording method of an instrument according to claim 1, characterized in that: The preset script types include Python, C++ and C# script programs.
4. The SCPI command recording method of an instrument according to claim 1, characterized in that: The script template in step S4 includes an instrument connection and control part, a SCPI command query and setting function part, and a SCPI command execution function part. All complete recorded SCPI commands are written into the SCPI command execution function part.
5. The SCPI command recording method of an instrument according to claim 1, characterized in that: The state of the switch for enabling recording SCPI commands is monitored in real time. Before receiving the switch for enabling recording SCPI commands to be turned off, a SCPI command is generated for each target control according to the monitored operation process of the user on all target controls of the instrument interface. The executable script file includes several SCPI commands.
6. A SCPI command recording device for an instrument, characterized in that: A SCPI command recording method using an instrument as claimed in claim 1, comprising: A recording command configuration unit, used to configure the connection parameters of the instrument for the user, control the state of the recording SCPI command enable switch, and record or end the recording of the instrument interface operation according to the state of the recording SCPI command enable switch; An operation event monitoring unit is used to monitor the target control of the user's operation event on the instrument interface and the response to the operation event, and determine the position of the target control in the control tree; The parsing and generating instruction unit is used to retrieve the command part of the SCPI instruction corresponding to the target control in the instruction tree according to the position of the control tree, parse the parameter part of the SCPI instruction according to the response of the operation event, splice the parameter part and the command part into a complete SCPI instruction, and save it; The execution script generation unit is used to write all complete SCPI instructions into a preset script template according to the selected preset script type after all operation events are recorded, so as to generate an executable script file.
