CN103559296A - XML-based parsing method for SCPI (The Standard Commands for Programmable Instruments) - Google Patents
XML-based parsing method for SCPI (The Standard Commands for Programmable Instruments) Download PDFInfo
- Publication number
- CN103559296A CN103559296A CN201310561418.5A CN201310561418A CN103559296A CN 103559296 A CN103559296 A CN 103559296A CN 201310561418 A CN201310561418 A CN 201310561418A CN 103559296 A CN103559296 A CN 103559296A
- Authority
- CN
- China
- Prior art keywords
- scpi
- order
- command
- xml
- node
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/80—Information retrieval; Database structures therefor; File system structures therefor of semi-structured data, e.g. markup language structured data such as SGML, XML or HTML
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/42—Syntactic analysis
- G06F8/427—Parsing
Abstract
The invention provides an XML-based parsing method for SCPI, which comprises the following steps: 1, describing the SCPI by adopting XML documents; 2, judging whether the SCPI are received or not; 3, performing XML document enquiry, and judging whether matches exist or not; 4, acquiring command numbers and parameter information; 5, processing the SCPI. Through the adoption of the scheme, the SCPI parser has high expandability and universality, so that the problem that the conventional SCPI parser is complex in structure and difficult to reuse is solved.
Description
Technical field
The invention belongs to technical field of measurement and test, in particular a kind of SCPI command analysis method based on XML.
Background technology
SCPI (The Standard Commands for Programmable Instruments) is the major criterion of the program control order of surveying instrument, in various program control test surveying instruments, be widely used, using SCPI standard is also the development trend of program-controlled instrument.At instrument, receive after SCPI order, according to SCPI command syntax format standard resolve command statement in SCPI command set, obtain the information such as command code, parameter type, parameter value, parameter unit, complete the operation of order request.
Carry out control instrument with SCPI order, be first that the SCPI order of user's input is translated and become the language that instrument can be identified, i.e. SCPI command analysis.Because SCPI adopts tree hierarchy, every one-level consists of a series of dependence test instructions, when the design of SCPI resolver, need to build the command tree of certain storage organization and write relevant traversal program.Create SCPI command tree, first command keyword to be preserved into formatted text file or be kept in database, scanning document or operating database when creating command tree, the information of reading order key word, command keyword is converted to SCPI standard format and represents, then according to the grade structure command tree of order; And in the processing of parameter and suffix, the processing mode difference of different instruments is very big, realize the unified Transformation Program that also needs various data types of processing.Visible SCPI resolving complexity is easily made mistakes, multiplexing difficulty, resolver complex structure.
The function of SCPI interpreter is mainly that input instruction is resolved, and the program control message translation of using SCPI order to write is become to the discernible code of instrument, and its key step comprises two parts: the establishment of the one, SCPI command set and storage; The 2nd, program control message is analyzed and inquired about.
Create the process of command tree, be exactly the SCPI command set of digital oscilloscope according to certain structure, create for the command tree of inquiring about.This requires to realize in stage: input be 1 formatted text file that comprises all SCPI command keywords of digital oscilloscope, output be 1 by the command tree of rule creation.Because SCPI order adopts tree structure, there are a lot of subsystems, each subsystem has again a lot of subcommands, therefore need to build the command tree of certain storage organization and write relevant traversal program.Conventional SCPI interpreter method for designing has Automatic, string comparing etc.Automatic is to utilize two instrument LEX and YACC under unix system to generate, mainly for unix system.Compare with Automatic, string comparing is applied widely, takies storage resources few, and the performance of acquisition is also better than Automatic.
The process of command lookup is exactly according to the SCPI order of user's input, travels through command tree, obtains ISN and the parameter information of order, by carrying out character string comparison, in same level, from front to back, command tree node has been traveled through.SCPI command string to user's input, judgement command string initial character is to determine public order or the specific control command of SCPI instrument; Then initiation command inquiry, if can find the order of coupling completely, takes out its command number and returns; Finally according to command number, carry out related objective code result data.
Because SCPI adopts tree hierarchy, every one-level consists of a series of dependence test instructions, when the design of SCPI resolver, need to build the command tree of certain storage organization and write relevant traversal program.Create SCPI command tree, first command keyword to be preserved into formatted text file or be kept in database, scanning document or operating database when creating command tree, the information of reading order key word, command keyword is converted to SCPI standard format and represents, then according to the grade structure command tree of order; And in the processing of parameter and suffix, the processing mode difference of different instruments is very big, realize the unified Transformation Program that also needs various data types of processing.Visible SCPI resolving complexity is easily made mistakes, multiplexing difficulty, resolver complex structure.
Therefore, there is defect in prior art, needs to improve.
Summary of the invention
Technical matters to be solved by this invention is for the deficiencies in the prior art, and a kind of SCPI command analysis method based on XML is provided.
Technical scheme of the present invention is as follows:
A SCPI command analysis method of XML, wherein, comprises the following steps:
Step 1: adopt XML document to describe SCPI order; Arrange and adopt XML document to describe SCPI command tree;
Step 2: judging whether to receive SCPI order, is to enter step 3, otherwise continue to judge whether to receive SCPI order;
Step 3: Query XML document, has judged whether occurrence; According to the SCPI order receiving, separated SCPI command keyword, the node that inquiry matches in the same level of XML document; The node matching if inquire, takes off one-level key word, in the child node of this node, inquires about, and to the last after a SCPI command keyword, enters step 4; If inquiry, less than the node matching, is judged to be and does not find occurrence, enter step 2;
Step 4: obtain command number and parameter information; Identification fill order coding and parameter type, number of parameters information in corresponding XML child node, and send isolate corresponding parameter and unit in SCPI order after;
Step 5: order is processed to SCPI; Programmable instrument, according to command code and parameter, is carried out order accordingly.
The described SCPI command analysis method based on XML, wherein, in described step 1, when creating the XML document of SCPI order, comes tab command key word and abbreviation of keyword with the attribute of XML node; The command code, the parameter type that by XML child node, represent the SCPI of subordinate order or SCPI order at the corresponding levels.
The described SCPI command analysis method based on XML, wherein, in described step 2, arranges according to SCPI order, at grammer and form, whether to meet the rule of SCPI command standard grammer and form, judges whether the SCPI order receiving is effective SCPI order.
Adopt such scheme, SCPI order is written as to XML document form, by obtaining the command code of SCPI order to the operations such as inquiry of XML document, the information such as parameter type, for different SCPI orders, only need to revise XML document content and just can realize the renewal to SCPI order; Use the SCPI command analysis utensil of the inventive method design to have extensibility and versatility highly, effectively solved SCPI command analysis device complex structure, the problem of multiplexing difficulty.
Accompanying drawing explanation
Fig. 1 is method flow diagram of the present invention.
Embodiment
Below in conjunction with the drawings and specific embodiments, the present invention is described in detail.
Embodiment 1
As shown in Figure 1, the present invention proposes a kind of SCPI command analysis method based on XML.XML is a kind of generalized markup language that W3C tissue proposes.XML allows document developer to create the semantic marker of data of description and the constraint condition that document is followed.The XML syntax analyzer of any standard can read, resolve, check this text based self-described document, and the data access interface by standard is to be independent of the mode access data elements of platform.
The principal character of XML is semi-structured, it is the class data between structural data and complete non-structure data, by self-defined descriptive markup data, XML document is regarded as tree construction, wherein element and attribute are mapped to the node into tree, and the nest relation between element is mapped to the limit into tree.XML document is tree construction, similar with SCPI command tree form, therefore can adopt XML document to describe SCPI command tree.And adopt the standardization document form of this XML parameter type and the suffix of order all can be described out, can directly by differentiating type, realize the processing of parameter and suffix.In command tree, not only comprised that command keyword and abbreviation thereof have also comprised the information such as command code, parameter type.
When instrument is received SCPI order, by key word or its abbreviation of order, search corresponding node, as find matched node, obtain the information such as command code, parameter type, thereby realize parsing and the parameter processing of various command.
Embodiment 2
On the basis of above-described embodiment, further, provide a kind of SCPI command analysis method based on XML, wherein, comprise the following steps:
Step 1: adopt XML document to describe SCPI order; Arrange and adopt XML document to describe SCPI command tree;
Step 2: judging whether to receive SCPI order, is to enter step 3, otherwise continue to judge whether to receive SCPI order;
Step 3: Query XML document, has judged whether occurrence; According to the SCPI order receiving, separated SCPI command keyword, the node that inquiry matches in the same level of XML document; The node matching if inquire, takes off one-level key word, in the child node of this node, inquires about, and to the last after a SCPI command keyword, enters step 4; If inquiry, less than the node matching, is judged to be and does not find occurrence, enter step 2;
Step 4: obtain command number and parameter information; Identification fill order coding and parameter type, number of parameters information in corresponding XML child node, and send isolate corresponding parameter and unit in SCPI order after;
Step 5: order is processed to SCPI; Programmable instrument, according to command code and parameter, is carried out order accordingly.
The described SCPI command analysis method based on XML, wherein, in described step 1, when creating the XML document of SCPI order, comes tab command key word and abbreviation of keyword with the attribute of XML node; The command code, the parameter type that by XML child node, represent the SCPI of subordinate order or SCPI order at the corresponding levels.
The described SCPI command analysis method based on XML, wherein, in described step 2, arranges according to SCPI order, at grammer and form, whether to meet the rule of SCPI command standard grammer and form, judges whether the SCPI order receiving is effective SCPI order.
Adopt such scheme, SCPI order is written as to XML document form, by obtaining the command code of SCPI order to the operations such as inquiry of XML document, the information such as parameter type, for different SCPI orders, only need to revise XML document content and just can realize the renewal to SCPI order; Use the SCPI command analysis utensil of the inventive method design to have extensibility and versatility highly, effectively solved SCPI command analysis device complex structure, the problem of multiplexing difficulty.
Should be understood that, for those of ordinary skills, can be improved according to the above description or convert, and all these improvement and conversion all should belong to the protection domain of claims of the present invention.
Claims (3)
1. the SCPI command analysis method based on XML, is characterized in that, comprises the following steps:
Step 1: adopt XML document to describe SCPI order; Arrange and adopt XML document to describe SCPI command tree;
Step 2: judging whether to receive SCPI order, is to enter step 3, otherwise continue to judge whether to receive SCPI order;
Step 3: Query XML document, has judged whether occurrence; According to the SCPI order receiving, separated SCPI command keyword, the node that inquiry matches in the same level of XML document; The node matching if inquire, takes off one-level key word, in the child node of this node, inquires about, and to the last after a SCPI command keyword, enters step 4; If inquiry, less than the node matching, is judged to be and does not find occurrence, enter step 2;
Step 4: obtain command number and parameter information; Identification fill order coding and parameter type, number of parameters information in corresponding XML child node, and send isolate corresponding parameter and unit in SCPI order after;
Step 5: order is processed to SCPI; Programmable instrument, according to command code and parameter, is carried out order accordingly.
2. the SCPI command analysis method based on XML as claimed in claim 1, is characterized in that, in described step 1, when creating the XML document of SCPI order, with the attribute of XML node, comes tab command key word and abbreviation of keyword; The command code, the parameter type that by XML child node, represent the SCPI of subordinate order or SCPI order at the corresponding levels.
3. the SCPI command analysis method based on XML as claimed in claim 1, it is characterized in that, in described step 2, arrange according to SCPI order, at grammer and form, whether to meet the rule of SCPI command standard grammer and form, judge whether the SCPI order receiving is effective SCPI order.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310561418.5A CN103559296A (en) | 2013-11-04 | 2013-11-04 | XML-based parsing method for SCPI (The Standard Commands for Programmable Instruments) |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201310561418.5A CN103559296A (en) | 2013-11-04 | 2013-11-04 | XML-based parsing method for SCPI (The Standard Commands for Programmable Instruments) |
Publications (1)
Publication Number | Publication Date |
---|---|
CN103559296A true CN103559296A (en) | 2014-02-05 |
Family
ID=50013542
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201310561418.5A Pending CN103559296A (en) | 2013-11-04 | 2013-11-04 | XML-based parsing method for SCPI (The Standard Commands for Programmable Instruments) |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN103559296A (en) |
Cited By (5)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104461574A (en) * | 2014-12-23 | 2015-03-25 | 上海斐讯数据通信技术有限公司 | XML-based command line and command line program processing method thereof |
CN107729388A (en) * | 2017-09-19 | 2018-02-23 | 杭州安恒信息技术有限公司 | A kind of app server implementation methods based on XML protocol |
CN109299223A (en) * | 2018-10-15 | 2019-02-01 | 百度在线网络技术(北京)有限公司 | Method and device for inquiry instruction |
CN110110149A (en) * | 2018-01-11 | 2019-08-09 | 天维讯达(北京)科技有限公司 | A kind of analysis method and device of SCPI order |
CN113703836A (en) * | 2021-08-20 | 2021-11-26 | 北京空间飞行器总体设计部 | SCPI instruction management method for spacecraft power system evaluation |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20090240351A1 (en) * | 2008-10-30 | 2009-09-24 | Agilent Technologies, Inc. | Programming Electronic Instruments by Logging Commands Into a File Format |
CN102521250A (en) * | 2011-11-16 | 2012-06-27 | 中国电子科技集团公司第四十一研究所 | Method for implementing universal syntactic analysis of intelligent measuring instrument |
-
2013
- 2013-11-04 CN CN201310561418.5A patent/CN103559296A/en active Pending
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20090240351A1 (en) * | 2008-10-30 | 2009-09-24 | Agilent Technologies, Inc. | Programming Electronic Instruments by Logging Commands Into a File Format |
CN102521250A (en) * | 2011-11-16 | 2012-06-27 | 中国电子科技集团公司第四十一研究所 | Method for implementing universal syntactic analysis of intelligent measuring instrument |
Non-Patent Citations (1)
Title |
---|
孟德伟等: "基于XML的通用SCPI命令解析器设计", 《仪器仪表用户》 * |
Cited By (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN104461574A (en) * | 2014-12-23 | 2015-03-25 | 上海斐讯数据通信技术有限公司 | XML-based command line and command line program processing method thereof |
CN104461574B (en) * | 2014-12-23 | 2018-06-19 | 上海斐讯数据通信技术有限公司 | A kind of order line processing unit and method based on XML |
CN107729388A (en) * | 2017-09-19 | 2018-02-23 | 杭州安恒信息技术有限公司 | A kind of app server implementation methods based on XML protocol |
CN107729388B (en) * | 2017-09-19 | 2020-04-28 | 杭州安恒信息技术股份有限公司 | XML protocol-based app server implementation method |
CN110110149A (en) * | 2018-01-11 | 2019-08-09 | 天维讯达(北京)科技有限公司 | A kind of analysis method and device of SCPI order |
CN110110149B (en) * | 2018-01-11 | 2023-09-12 | 天维讯达(北京)科技有限公司 | Method and device for analyzing SCPI command |
CN109299223A (en) * | 2018-10-15 | 2019-02-01 | 百度在线网络技术(北京)有限公司 | Method and device for inquiry instruction |
CN113703836A (en) * | 2021-08-20 | 2021-11-26 | 北京空间飞行器总体设计部 | SCPI instruction management method for spacecraft power system evaluation |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN106919434B (en) | Code generation method and device | |
US10162738B2 (en) | System, method, and computer readable medium for universal software testing | |
CN106528165B (en) | Code generating method and code generating system | |
CN103164249B (en) | Extension mechanism for script compiler | |
CN109343857B (en) | Method, apparatus and storage medium for deploying machine learning model on line | |
CN106412086B (en) | Method and system for automatically generating communication code by using protocol description file | |
US20070033520A1 (en) | System and method for web page localization | |
US7784036B2 (en) | Methods and systems for transforming a parse graph into an and/or command tree | |
US8086618B2 (en) | Configuration rule translation mapper | |
CN104156313A (en) | Method for automatically generating Web service testing case | |
CN1526104B (en) | Parsing structured data | |
CN107168762B (en) | Body-based RUCM (robust object model) consistency checking method | |
CN103559296A (en) | XML-based parsing method for SCPI (The Standard Commands for Programmable Instruments) | |
Zhang et al. | Development of IFC-based construction industry ontology for information retrieval from IFC models | |
CN104657402A (en) | Language Tag Management On International Data Storage | |
CN112395843B (en) | PHP code-based service processing method, device and medium | |
CN101739258A (en) | Automatic code generation method of architecture analysis and design language (AADL) model | |
CN103593277A (en) | Log processing method and system | |
CN109325217B (en) | File conversion method, system, device and computer readable storage medium | |
CN102520963B (en) | Method and system for realizing service logic processing based on strongly-typed relation mapping | |
CN103761095A (en) | Method for generating universal header data information of upgraded file | |
US20200183670A1 (en) | System and method for transforming cold fusion technology environment to open source environment | |
CN102073662A (en) | Method and system for analyzing and creating XML (Extensible Markup Language) data | |
CN103235757B (en) | Several apparatus and method that input domain tested object is tested are made based on robotization | |
CN110110150B (en) | XML data reading method, reading device, computer equipment and storage medium |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
C06 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
RJ01 | Rejection of invention patent application after publication | ||
RJ01 | Rejection of invention patent application after publication |
Application publication date: 20140205 |