WO2017000844A1 - Method, device and system for controlling instrument automatically - Google Patents

Method, device and system for controlling instrument automatically Download PDF

Info

Publication number
WO2017000844A1
WO2017000844A1 PCT/CN2016/087106 CN2016087106W WO2017000844A1 WO 2017000844 A1 WO2017000844 A1 WO 2017000844A1 CN 2016087106 W CN2016087106 W CN 2016087106W WO 2017000844 A1 WO2017000844 A1 WO 2017000844A1
Authority
WO
WIPO (PCT)
Prior art keywords
meter
instrument
underlying
driver
function
Prior art date
Application number
PCT/CN2016/087106
Other languages
French (fr)
Chinese (zh)
Inventor
郭树强
程智刚
Original Assignee
中兴通讯股份有限公司
Priority date (The priority date 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 date listed.)
Filing date
Publication date
Application filed by 中兴通讯股份有限公司 filed Critical 中兴通讯股份有限公司
Publication of WO2017000844A1 publication Critical patent/WO2017000844A1/en

Links

Images

Classifications

    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B19/00Programme-control systems
    • G05B19/02Programme-control systems electric
    • G05B19/04Programme control other than numerical control, i.e. in sequence controllers or logic controllers
    • G05B19/042Programme control other than numerical control, i.e. in sequence controllers or logic controllers using digital processors
    • G05B19/0423Input/output
    • GPHYSICS
    • G05CONTROLLING; REGULATING
    • G05BCONTROL OR REGULATING SYSTEMS IN GENERAL; FUNCTIONAL ELEMENTS OF SUCH SYSTEMS; MONITORING OR TESTING ARRANGEMENTS FOR SUCH SYSTEMS OR ELEMENTS
    • G05B19/00Programme-control systems
    • G05B19/02Programme-control systems electric
    • G05B19/04Programme control other than numerical control, i.e. in sequence controllers or logic controllers
    • HELECTRICITY
    • H04ELECTRIC COMMUNICATION TECHNIQUE
    • H04LTRANSMISSION OF DIGITAL INFORMATION, e.g. TELEGRAPHIC COMMUNICATION
    • H04L43/00Arrangements for monitoring or testing data switching networks

Definitions

  • This application relates to, but is not limited to, the field of automated instrumentation technology.
  • FIG. 1 it is a schematic diagram of the working principle of the instrument automatic control in the related art.
  • the specific instrument operation instruction is adopted, and the automatic control of the specific instrument is implemented based on the script, for example, the script is, for example, a control/test script, and the script is only caused by the binding relationship between the script and the instrument.
  • the related art has the following problems: different manufacturers' instruments may use different communication interfaces and protocols to establish a connection between the instrument and the instrument server, so it is necessary to develop corresponding instrument drivers according to different communication interfaces and protocols, and increase the script modification cost. .
  • the present invention provides a method, device and system for automatically controlling a meter to solve the problem in the related art that a corresponding instrument driver needs to be developed according to different communication interfaces and protocols.
  • a method of automatically controlling a meter comprising:
  • the meter agent parses out the meter address of the at least one meter, invokes a corresponding meter connection interface in the meter abstract driver according to each of the meter addresses, and connects with the corresponding meter through the called meter connection interface to maintain the connection status. ;
  • the meter agent obtains the working status information of the corresponding meter or operates the meter according to the instruction received from the client and the meter driving function interface in the meter abstract driving.
  • the meter is connected to the device to be tested by using a switch matrix, and the meter agent controls the switch matrix to switch the meter and the standby by starting a separate thread or a sub-process Measure the line between the devices.
  • the method before the receiving the access request of the client to access the at least one meter, the method further includes:
  • An underlying instrument state scan function is defined in each instrument underlying driver, and the underlying instrument state scan function in each of the instrument underlying drivers has the same name;
  • An instrument state scan function having the same name as the underlying meter state scan function is defined in the meter abstract driver, and the meter state scan function is used to call an underlying meter state scan function in each of the meter underlying drivers.
  • the meter agent invokes a corresponding meter connection interface in the meter abstract driver according to each of the meter addresses, and connects with the corresponding meter through the called meter connection interface to maintain the connection state.
  • the meter agent invokes the meter connection interface in the meter abstract driver, and transmits the meter address to the meter connection interface;
  • the meter connection interface After determining the address type of the instrument address, the meter connection interface invokes a corresponding communication protocol library to cycle through the underlying connection function in each instrument underlying driver;
  • the instrument connection interface returns a failure when the underlying connection function that rotates all of the underlying drivers of the instrument returns a failure.
  • the meter agent obtains the working status information of the corresponding meter or operates the meter according to the instruction received from the client and the instrument driving function interface in the meter abstract driving, including :
  • the meter agent stores the instruction received from the client into the communication queue, and the sub-process of the currently connected corresponding meter parses the instruction to obtain a corresponding underlying function function of the meter, according to the instrument driving function in the instrument abstract driver
  • the interface calls the underlying function of the meter;
  • the meter passes the returned result to the child process, the child process saves the result to a receive queue, and the meter agent returns the result to the client via a Transmission Control Protocol TCP connection.
  • the meter agent obtains the working status information of the corresponding meter or operates the meter according to the instruction received from the client and the instrument driving function interface in the meter abstract driving, and include:
  • the sub-process calls the underlying instrument state scan function to read the working state information of the meter in real time, and obtains the obtained information.
  • the working status information of the meter is stored in the queue or database.
  • An apparatus for automatically controlling a meter comprising:
  • the client request receiving module is configured to: receive an access request of the client to access the at least one meter, and start the meter proxy according to the access request;
  • the meter agent is configured to: parse out the meter address of the at least one meter received by the client request receiving module, and invoke a corresponding meter connection interface in the meter abstract driver according to each of the meter addresses, by using the called meter
  • the connection interface is connected with the corresponding meter and maintains the connection state;
  • the meter agent is further configured to: obtain the working status information of the corresponding meter or operate the meter according to the instruction received from the client and the instrument driving function interface in the meter abstract driving.
  • the device further includes:
  • a switch matrix configured to: connect the meter to a device under test, and the meter agent controls the switch matrix to switch the meter and the device to be tested by starting a separate thread or a sub-process The line between the backups.
  • the device further includes:
  • the underlying driver of the instrument is set to: define an underlying instrument state scanning function in each instrument underlying driver, and the underlying instrument state scanning function in each of the instrument underlying drivers adopts the same name;
  • An instrument abstraction driver is configured to: define, in the meter abstract driver, an instrument state scan function having the same name as the underlying meter state scan function, the gauge state scan function for calling the bottom layer of each of the instrument underlying drivers Instrument status scan function.
  • the instrument agent includes:
  • the meter address forwarding module is configured to: invoke the meter connection interface in the meter abstract driver, and transmit the meter address to the meter connection interface;
  • the instrument abstract driver includes:
  • the instrument address detecting module is configured to: instruct the meter connection interface to call the corresponding communication protocol library after determining the address type, and to cycle through the bottom layer connection function in each instrument underlying driver;
  • the instrument connection interface returns a failure when the underlying connection function that rotates all of the underlying drivers of the instrument returns a failure.
  • a system for automatically controlling instruments including:
  • a client connected to the meter agent, the client is set to: run a script
  • the client request receiving module is configured to: receive an access request of the client to access the at least one meter, and start the meter agent according to the access request;
  • the meter agent is configured to: parse out a meter address of the at least one meter received by the client request receiving module, and invoke a corresponding meter connection interface in the meter abstract driver according to each of the meter addresses, by calling
  • the instrument connection interface is connected with the corresponding instrument and maintains the connection state;
  • the meter agent is further configured to: obtain an operation status information of the corresponding meter or operate the meter according to an instruction received from the client and an instrument driving function interface in the instrument abstract driving;
  • the meter is set to be connected to the instrument agent through a communication interface.
  • the method, device and system for automatically controlling the instrument obtained the working state information or the operation instrument of each instrument by scanning each instrument connected to the instrument server, because the instrument abstract drive and its package
  • the instrument connection interface eliminates the difference of the underlying driving of each instrument. Therefore, the technical solution of the automatic control instrument provided by the embodiment of the invention does not need to know the type of the instrument, and only needs to input the instrument address to realize the pair by calling the instrument abstract driver. Automatic control of the instrument.
  • FIG. 1 is a schematic diagram showing the working principle of instrument automatic control in the related art
  • FIG. 2 is a schematic structural diagram of an apparatus for automatic control of an instrument according to an embodiment of the present invention
  • FIG. 3 is a schematic diagram of a development structure of an instrument underlying driver in an apparatus for automatically controlling an instrument according to an embodiment of the present invention
  • FIG. 4 is a schematic diagram of a working principle of an instrument abstract driving in an apparatus for automatically controlling an instrument according to an embodiment of the present invention
  • FIG. 5 is a schematic flowchart of a method for automatically controlling a meter according to an embodiment of the present invention
  • FIG. 6 is a schematic flowchart diagram of another method for automatically controlling a meter according to an embodiment of the present invention.
  • FIG. 7 is a schematic flowchart diagram of still another method for automatically controlling a meter according to an embodiment of the present invention.
  • FIG. 8 is a schematic flowchart diagram of still another method for automatically controlling a meter according to an embodiment of the present invention.
  • FIG. 9 is a schematic structural diagram of an apparatus for automatically controlling an instrument according to an embodiment of the present invention.
  • FIG. 10 is a schematic structural diagram of an instrument agent in an apparatus for automatically controlling an instrument according to an embodiment of the present invention
  • FIG. 11 is a meter switch matrix in an apparatus for automatic control of an instrument according to an embodiment of the present invention.
  • FIG. 12 is a schematic diagram of a working principle of a meter address forwarding module in an apparatus for automatically controlling an instrument according to an embodiment of the present invention
  • FIG. 13 is a schematic structural diagram of an automatic control system for a meter according to an embodiment of the present invention.
  • FIG. 2 is a schematic structural diagram of an apparatus for automatically controlling an instrument according to an embodiment of the present invention.
  • the method and apparatus for instrument automation control provided by the embodiments of the present invention involve multiple concepts. Before describing the embodiments of the present invention, some basic concepts in the instrument automation control system are first described in detail. The meanings of these concepts are as follows:
  • the instrument underlay driver 201 is invoked by the meter abstraction driver 202 and communicates directly with the meter 206 via the communication interface 205.
  • the instrument underlying driver 201 is a driver developed for each instrument and is the basis of instrument automation control.
  • the underlying driver 201 abstracts the functions and operation steps of the instrument, and uniformly defines a set of instrument underlying function functions, namely the Application Programming Interface (API).
  • the underlying function of the instrument includes the function name, the number of parameters, Parameter type and return value type, etc.
  • the underlying driver 201 includes a connection function to establish a connection with the meter 206, and various functional functions of the meter 206.
  • the connection function also includes the uniqueness of authenticating the identity of the meter, and identity authentication is essential for automatically identifying the type of meter.
  • Each instrument has a certain characteristic or special identifier belonging to the instrument. These characteristics/identities can be found by remote commands provided by the manufacturer.
  • the serial instrument can be authenticated by the serial communication protocol customized by the instrument.
  • the physical interface of the instrument includes, but is not limited to, an Ethernet connection, a serial connection, and a General-Purpose Interface Bus (GPIB) connection.
  • the communication method of the instrument includes a Transmission Control Protocol (TCP).
  • TCP Transmission Control Protocol
  • UDP User Datagram Protocol
  • telnet remote terminal protocol
  • serial communication port Cluster Communication Port, referred to as: COM port
  • GPIB port communication GPIB port communication
  • FIG. 3 is a schematic diagram of a development structure of an instrument underlying driver in an apparatus for automatically controlling an instrument according to an embodiment of the present invention.
  • the underlying driver 201 of the instrument adopts a three-layer structure: a data transmission layer, a command implementation layer, and a command interface layer.
  • the data transmission layer realizes simple transmission and reception functions between the instrument and the meter. Regardless of the communication mode adopted by the instrument, each instrument underlying driver 201 supports a communication protocol, and the transmission and reception functions of the data transmission layer are developed based on the communication protocol. .
  • the command implementation layer based on the data transmission layer, combines the characteristics of the meter itself to realize the functions of the instrument operation and query.
  • the command interface layer implements a specific operation or query function based on the command implementation layer, and the command interface conforms to the uniformly defined underlying function of the instrument, and the underlying function of the instrument implements the actual operation of the instrument.
  • the instrument abstraction driver 202 calls the instrument underlying driver 201 and is called by the meter agent 203 to define a number of meter driver function interfaces.
  • the meter abstraction driver 202 defines the same-named function-instrument-driven function interface of all the underlying function functions of the meter in the underlying driver 201.
  • the same-named function in the instrument abstraction driver 202-meter The driver function interface can directly point to the function of the same name in the instrument underlying driver 201 corresponding to the meter 206 - the underlying function of the meter.
  • FIG. 4 is a schematic diagram showing the working principle of an instrument abstract driving in the device automatic control device provided by the embodiment of the present invention.
  • the meter abstraction driver 202 detects the legality of the meter address passed by the meter agent 203 at the entrance, and determines the type of the meter address by the keyword, that is, the physical connection mode of the meter, thereby determining the connection address of the meter.
  • the meter abstraction driver 202 attempts to establish a connection with the corresponding meter through the connection address, and then in turn calls each meter bottom driver 201 to authenticate the meter 206; if the identity information returned by the meter 206 conforms to the meter defined in the current meter bottom driver 201 The result of the identity authentication can be determined that the current instrument underlying driver 201 is applicable to the currently connected meter. If not, the user continues to try to match the next underlying driver 201 until the correct underlying driver 201 is matched, thereby implementing the underlying driver of the meter. Automatic matching/adaptation between 201 and meter 206.
  • the meter agent 203 calls the instrument driver function interface in the meter abstraction driver 202, it automatically switches to the underlying function function of the same name in the instrument underlying driver 201 that has been adapted, so that Automated control of the meter without knowing the type of meter is achieved. For example, when the meter agent 203 receives the command to turn on the meter laser, it will invoke the function API of the meter abstract driver 202 corresponding to the meter laser. Since the identity of the connected meter 206 has been confirmed at this time, the meter laser in the meter abstract driver 202 is turned on. The function API will accurately find and call the instrument underlying function function of the meter laser in the meter bottom driver 201 corresponding to the connected meter 206.
  • the meter agent 203 is coupled to the client 204 for scripting and to invoke the meter abstraction driver 202.
  • the client 204 is an input of the entire instrument automation control system and is connected to the meter agent 203. It can be an interpreter that runs a script, or it can be a more intuitive command line window or User's Interface (UI) interface.
  • UI User's Interface
  • the communication interface 205 the interface between the meter 206 and the test machine running the instrumentation agent 203, the instrument communication interface supported by the invention includes but is not limited to Ethernet, serial port and GPIB, etc., wherein the communication protocol supported by the Ethernet connection includes: telnet, TCP and UDP, etc.
  • the meter 206 the object of the automatic control, one end of the meter 206 is connected to the testing machine running the meter agent 203 through different communication interfaces, and the other end is connected to the device to be tested 208 through the switch matrix; the meter 206 can also directly and test according to the need Device 208 is connected.
  • the switch matrix 207 has one end connected to all the meters 206 and the other end connected to all the devices 208 to be tested.
  • the remote control is supported, and the line switching between the meter 206 and the device under test 208 is supported by the instruction, and the automatic control of the meter 206 is realized to a greater extent, and the manual line change is eliminated.
  • the device under test 208 is a target object for automatic control, and is connected to the switch matrix, and can also be directly connected to the meter 206 as needed.
  • the timing scan connection status, the busy and idle status of the meter 206, the connection and usage of the meter are presented in real time, and the switch 206 is used to implement the relationship between the meter 206 and the device under test 208. Automatic switching of connected lines.
  • FIG. 5 is a schematic flowchart diagram of a method for automatically controlling a meter according to an embodiment of the present invention.
  • the method for automatically controlling the meter provided in this embodiment may include the following steps, step 510: Step 530:
  • Step 510 Receive an access request of the client to access at least one meter, according to the access request. Start the instrumentation agent;
  • Step 520 The meter agent parses out the meter address of the at least one meter, invokes the corresponding meter connection interface in the meter abstract driver according to each meter address, and connects with the corresponding meter through the called meter connection interface to maintain the connection state;
  • Step 530 The instrument agent obtains the working status information or the operation instrument of the corresponding meter according to the instruction received from the client and the instrument driving function interface in the instrument abstract driving.
  • each instrument that is accessed is scanned on the instrument server to obtain the working state information or the operation instrument of each instrument, and the meter abstraction driver 202 and the packaged instrument connection interface thereof eliminate the respective instruments.
  • the difference between the underlying driver 201 and the method provided by the embodiment of the present invention, in the application, does not need to know the type of the meter, and only needs to input the meter address to enable automatic control of the meter by calling the meter abstract driver 202.
  • the method for automatically controlling the instrument is generally applied to an instrument server, and the instrument server can control a plurality of meters.
  • meter 206 is coupled to device under test 208 via a switch matrix, and meter agent 203 can effect connection, management, and control of the switch matrix by initiating a separate thread or sub-process.
  • the instrument used is changed, or the device to be tested 208 connected to the meter 206 is changed, and the connection between the meter 206 and the device under test 208 needs to be switched, the corresponding instruction is issued to the meter agent 203 or the configuration file is modified. Automatic switching of the connection between the meter 206 and the device under test 208 can be achieved.
  • each of the functional objects has a function that should be implemented by itself, and needs to have a corresponding relationship with other functional objects, and completes the entire Control process.
  • a meter bottom driver 201 corresponds to a meter 206, and each meter bottom driver 201 can implement different functions, such as connection function, query function, operation function, and the like.
  • the instrument underlay driver 201 needs to be separately written for each meter 206, and then an upper meter abstraction driver 202 is formed by encapsulation based on all the instrument underlayer drivers 201.
  • the instrument abstract driver 202 includes a plurality of instrument driving function interfaces for implementing a single function, and each instrument driving function interface realizes a single Features such as connection, query, or setup.
  • FIG. 6 it is a schematic flowchart of another method for automatically controlling a meter according to an embodiment of the present invention.
  • the method provided in this embodiment may further include: before each step 206, each instrument 206 separately writes an underlying driver of the instrument, wherein the implementation manner of writing the underlying driver of the instrument is:
  • Step 500 Define an underlying instrument state scan function in each instrument underlying driver, and the underlying instrument state scan function in all instrument underlying drivers adopt the same name; wherein the underlying instrument state scan function is used to perform instrument state scanning, for example For the API-meter status scan function;
  • Step 501 Define an instrument state scan function having the same name as the underlying instrument state scan function in the instrument abstract driver, and the instrument state scan function with the same name is used to call the underlying instrument state scan function in each instrument underlying driver.
  • the method provided by the embodiment of the present invention not only needs to define an underlying instrument state scanning function for each meter in the instrument underlying driver 201, but also needs to define other underlying single function functions. Therefore, it is necessary to standardize the underlying single function and the instrumentation function interface of the instrument abstraction driver 202 that calls these underlying single function functions; wherein the instrument driver function interface generally refers to the instrument abstraction driver 202, and the instrument underlying driver 201
  • the defined underlying instrument state scan function interfaces with the instrument driver function of the same name.
  • the instrument state scan function in the instrument abstraction driver 202 defined in step 501 is one of the meter drive function interfaces.
  • the meter abstraction driver 202 includes a plurality of single-function API-meter-driven function interfaces, each of which encapsulates the same function of each meter-based driver 201 in each meter-driven function interface - the underlying single
  • the function function, and in the underlying driver 201 of the instrument the names of the respective underlying single function functions corresponding to the instrument driving function interface are the same, and the names of the interfaces of the instrument driving function are the same.
  • FIG. 7 another schematic flowchart of a method for automatically controlling a meter according to an embodiment of the present invention is provided.
  • the instrumentation agent 203 is started, in step 520, the corresponding instrument connection interface in the instrument abstraction driver is invoked according to each instrument address, and the instrument connection interface and the corresponding instrument are invoked.
  • steps 521 to 524 the following steps may be included, that is, steps 521 to 524:
  • Step 521 the instrument agent invokes the instrument connection interface in the instrument abstract driver, and transmits the instrument address to the instrument connection interface;
  • Step 522 After determining the address type of the instrument address, the meter connection interface calls the corresponding communication protocol library to cycle through the underlying connection function in each instrument underlying driver.
  • the instrument connection interface takes the instrument address as a parameter, first determines the legality of the instrument address, and then uses the instrument address as a parameter to sequentially call the underlying connection function in each instrument underlying driver 201; after step 522 ,Also includes:
  • Step 523 when the connection function called to the underlying driver of a certain instrument returns successfully, the round robin is terminated, the instrument abstraction drive records the underlying driver of the current round of the instrument, and the instrument connection interface connection function of the instrument abstraction drive returns successfully;
  • step 524 when the underlying connection function of all the underlying drivers of the instrument returns to fail, the meter connection interface driven by the meter abstraction fails to return, and the user is reminded to check whether the meter address is correctly filled.
  • the method further includes:
  • the underlying driver 201 of the meter sends a special instruction that can be recognized only by the corresponding meter to the meter 206 by calling the corresponding underlying function of the meter to see whether the connected meter can correctly respond. If the response is correct, the connected meter 206 is The underlying driver 201 of the meter matches and returns successfully; if the response fails, it indicates that the connected meter 206 does not match the underlying driver 201 of the meter, releases the connection and resources with the meter, and returns to failure. Write all meter addresses to be connected to the configuration file or database. After the connection is successful, when the other instrument driver function interface is called, the instrument driver function interface automatically calls the underlying function function of the same name in the instrument underlying driver 201 object recorded previously.
  • step 530 of the embodiment the meter agent obtains the working status information of the corresponding meter according to the instruction received from the client and the instrument driving function interface in the instrument abstract driving.
  • the operation of the meter may include the following steps, that is, steps 531 to 532:
  • Step 531 the instrument agent stores the instruction received from the client into the communication queue, and the sub-process of the currently connected corresponding instrument parses the instruction to obtain the corresponding underlying function function of the instrument, and invokes the bottom layer of the instrument according to the instrument driving function interface in the instrument abstract driver.
  • step 532 the meter passes the returned result to the child process, and the child process saves the result to the receiving. Queue, the instrument agent returns the result to the client over a TCP connection.
  • the child process will call the underlying instrument state scan function to read the real-time status of the meter at a time interval of a custom time, and will obtain The status of the meter status is stored in the queue or database.
  • An API for meter status scanning is defined in each meter bottom driver 201, and the underlying meter status scan function in all meter bottom drivers 201 has the same name, and an API of the same name is defined in the meter abstract driver 202 accordingly. Used to call the underlying instrument state scan function in the instrument underlying driver 201.
  • the instrumentation agent 203 and the meter abstraction driver 202 are in a calling relationship between the upper and lower levels.
  • Meter agent 203 is responsible for generating and managing threads that are connected to client 204, as well as child processes that are connected to meter 206; each child process invokes meter abstraction driver 202 to send instructions to meter 206.
  • the instrumentation agent 203 parses out all the instrument addresses in the configuration file or the database, and invokes the instrument connection interface of the instrument abstraction driver 202 by using multiple processes, wherein each sub-process corresponds to one instrument address, and the instrument address is used as the instrument address.
  • the sub-process calls the parameter of the meter connection interface of the meter abstract driver 202; after the meter connection is successful, the child process does not end and maintains the connection state with the meter.
  • the meaning of each instrument process corresponding to a meter address is: a sub-process is generated in units of each group of ports of the meter, thus forming ⁇ process-1: (meter ip1, port 1), process-2: (meter ip2, Correspondence between ports 2)... ⁇ .
  • the method of automatically controlling the meter may include:
  • the meter agent 203 receives an access request from the client 204 to access the at least one meter 206, according to the access request, the meter agent 203 creates a first thread that generates a service to the client 204;
  • the meter agent 203 parses out the meter address of the at least one meter, generates at least one child process, and invokes the corresponding meter connection interface in the meter abstraction driver 202 according to each of the meter addresses in each of the child processes. Connecting to the corresponding meter through the instrument connection interface invoked and maintaining the connection state;
  • the meter connection interface sends an instruction to the meter to obtain the working status information or the operation meter of the meter.
  • the instrument automation control system can access multiple instruments, and supports multiple clients to separately control multiple instruments, as shown in FIG. 13, multiple client connections.
  • the method of automatically controlling the instrument may include:
  • step 601 the client 204 transmits the meter connection request and the meter address of the meter to be connected to the meter agent 203. After the connection is successful, the command is sent to the meter agent 203.
  • Step 602 after receiving the meter connection request and the meter address from the client, the meter agent 203 calls the meter connection interface in the meter abstraction driver 202 as a parameter. When the meter connection interface returns successfully, it indicates that the meter has been established with the meter.
  • the instrument agent 203 receives the instruction from the client, parses the corresponding instrument underlying function and its parameters, and then invokes the instrument driver function interface of the same name in the instrument abstraction driver 202, and passes the parsed parameters.
  • step 603 the meter abstraction driver 202 firstly calls the underlying connection function in each instrument underlying driver 201 to perform matching.
  • Step 604 after matching the correct instrument underlay driver 201, the meter abstraction driver 202 only needs to respond to the meter agent 203 to invoke the meter driver function interface, and then invokes the underlying connection function of the same name in the instrument underlying driver 201, and passes the instrumentation agent from the instrument. 203 parameters.
  • step 605 the underlying driver 201 executes the corresponding underlying function, and the underlying function calls the corresponding communication interface (drive) to send the corresponding instrument instruction to the meter, and the instrument returns the query result or performs the corresponding action after receiving the instruction.
  • FIG. 9 is a schematic structural diagram of an apparatus for automatically controlling a meter according to an embodiment of the present invention.
  • the device provided in this embodiment includes:
  • the client request receiving module 209 is configured to: receive an access request from the client 204 to access the at least one meter, and start the meter proxy 203 according to the access request;
  • the meter agent 203 is configured to: parse out the meter address of the at least one meter received by the client request receiving module 209, invoke the corresponding meter connection interface in the meter abstraction driver 202 according to each of the meter addresses, and connect through the called meter.
  • the interface is connected to the corresponding meter and maintains the connection status;
  • the meter agent 203 is further configured to: obtain the operating status information of the corresponding meter or operate the meter according to the instruction received from the client 204 and the meter driving function interface in the meter abstraction driver 202.
  • the instrument agent 203 also supports the call, as shown in FIG. 2, which is a schematic structural diagram of another device for automatically controlling the instrument provided by the embodiment of the present invention.
  • the apparatus provided in this embodiment may further include:
  • the switch matrix 207 is configured to connect the meter to the device under test, wherein the meter agent 203 implements line switching between the meter 206 and the device under test 208 by activating a separate thread or sub-process open control switch matrix 207.
  • the apparatus for automatically controlling the meter provided by the embodiment may further include:
  • the underlying driver 201 of the meter is configured to: define an underlying instrument state scan function in each instrument underlayer driver 201, and use the same name for the underlying instrument state scan function in each instrument underlayer driver 201;
  • the meter abstraction driver 202 is configured to: define, in the meter abstraction driver 202, an instrument state scan function having the same name as the underlying instrument state scan function, the instrument state scan function for invoking the underlying instrument state scan in each instrument underlying driver 201 function.
  • the meter abstraction driver 202 can include:
  • the instrument address detecting module is configured to: instruct the meter connection interface to call the corresponding communication protocol library after determining the address type, and to cycle through the underlying connection function in each instrument underlying driver 201;
  • FIG. 10 is a schematic structural diagram of an instrument agent in an apparatus for automatically controlling an instrument according to an embodiment of the present invention.
  • the instrumentation agent 203 includes: an instrument switch matrix selection module 2031, an instrument sweep The module 2032 and the meter address forwarding module 2034 are depicted.
  • FIG. 11 is a schematic diagram showing the working principle of an instrument switch matrix selection module in an apparatus for automatically controlling an instrument according to an embodiment of the present invention.
  • the meter switch matrix selection module 2031 is configured to control the switch matrix 207 to automatically switch the line between the meter 206 and the device under test 208 according to an internal algorithm and a switch matrix line mapping table indicating input and output connection address mapping relationships.
  • the meter switch matrix selection module 2031 determines that the connection switch between the set meter 206 and the switch matrix 207 is enabled - that is, allows the switch to be switched, the current state of the switch matrix 207 is read, and the switch matrix line map is queried.
  • the instruction to control the switch matrix 207 to perform line switching (the selected switching line) is sent to the switch matrix 207 to implement automatic switching of the connection between the meter 206 and the device under test 208 to avoid manual line change.
  • the meter scanning module 2032 is configured to: when the current state of the meter 206 is determined to be "idle", the connection between the setting meter 206 and the switch matrix 207 is switched to enable - that is, permission to be switched.
  • the meter address forwarding module 2033 is configured to: wait for receiving a new meter connection request from the client, invoke the meter connection interface in the meter abstraction driver 202, and input the meter address to the meter connection interface, and all the meter addresses in the configuration file. The corresponding meter remains connected.
  • FIG. 12 is a schematic diagram showing the working principle of an instrument address forwarding module in an apparatus for automatically controlling an instrument according to an embodiment of the present invention.
  • the instrument address forwarding module 2033 is responsible for the allocation and management of system resources by a main thread, and establishes a socket connection with each client in a multi-threaded manner, and adopts multi-threading in consideration of the client and the instrument agent 203.
  • the connection pressure between the device and the processing efficiency of the instruction by the meter agent 203 is responsible for the allocation and management of system resources by a main thread, and establishes a socket connection with each client in a multi-threaded manner, and adopts multi-threading in consideration of the client and the instrument agent 203.
  • the connection pressure between the device and the processing efficiency of the instruction by the meter agent 203 is responsible for the allocation and management of system resources by a main thread, and establishes a socket connection with each client in a multi-threaded manner, and adopts multi-threading in consideration of the client and the instrument
  • the meter address forwarding module 2033 automatically releases the connection thread and the socket connection resource with the client; and, maintains the meter 206
  • the connection between the two does not actively release the resources, that is, the multi-process is taken into consideration that the instrument agent 203 and the meter 206 will maintain a constant connection state. If multi-threading is used, the information blocking may not be solved, and the multi-process can achieve the maximum efficiency, and the instrument Connections between 206 include, but are not limited to, Ethernet, serial, and GPIB.
  • the meter address forwarding module 2033 in the meter agent 203 establishes a mapping relationship between the connection sub-process corresponding to the meter address and the child thread connected to the client.
  • the client transmits an instruction to the meter address forwarding module 2033 via TCP, and the meter address forwarding module 2033 deposits the instruction into the communication team.
  • the column is obtained by the sub-process connected to the corresponding instrument, parsing the underlying function function of the instrument in the instruction, and calling the instrument driving function interface of the same name in the instrument abstraction driver 202; the result returned by the meter 206 is first passed to the instrument address forwarding module 2033.
  • the child process saves the result to the receiving queue, is obtained by the child thread connecting the corresponding client, and returns the result to the client 204 through the TCP connection.
  • each child process periodically sends a keep-alive command to the meter 206 to confirm that the connection between the meter address forwarding module and the meter 206 is normal, and the keep-alive command can be a value 206.
  • the meter scanning module 2032 shares a set of connection sub-processes with the meter 206 with the meter address forwarding module 2033.
  • the child process In addition to calling the meter abstraction driver 202, the child process also periodically scans the meter 206 to determine if the meter 206 is currently being used. The judgment basis may be different according to different meters 206, and the scan function of each meter 206 needs to be packaged into the respective instrument bottom layer driver 201, and uniformly named for the meter scanning module to call periodically. With the scan result, statistics can be made on the current and temporary usage rate of each meter 206, and the control of the switch matrix 207 can be combined to realize automatic switching between the idle meter and the device under test 208, which greatly improves Resource utilization of meter 206.
  • FIG. 13 is a schematic structural diagram of an automatic control system for a meter according to an embodiment of the present invention.
  • the system for automatically controlling the instrument provided in this embodiment includes:
  • the client 204 is connected to the meter agent 203, and the client 204 is configured to: run a script;
  • the client request receiving module 209 is configured to: receive an access request from the client 204 to access the at least one meter 206, and start the meter agent 203 according to the access request;
  • the metering agent 203 is configured to: parse out the meter address of the at least one meter received by the client request receiving module 209, and invoke the corresponding meter connection interface in the meter abstraction driver 202 according to each meter address, through the called meter connection interface and The corresponding meter 206 is connected and maintains the connection state;
  • the meter agent 203 is further configured to: according to instructions and meter abstractions received from the client 204 Driving the instrument driver function interface in 202, obtaining the working status information of the corresponding meter 206 or operating the meter 206;
  • the meter 206 is configured to be connected to the meter agent 203 through a communication interface.
  • the instrument automation system known in the related art cannot realize the automatic identification of the instrument type and the automatic matching between the instrument and the instrument driver.
  • the advantage of using the technical solution adopted by the embodiment of the present invention is that the instrument underlying driving and the connected instrument can be realized. Automatic matching between the two; in the process of connecting with the meter, the system can periodically scan the working state of the meter and return the result to the system; the switch matrix is connected between the meter and the device under test, and the user can modify the configuration file or issue the corresponding command. It is possible to automatically switch the connection line between the meter and the device under test.
  • all or part of the steps of the above embodiments may also be implemented by using an integrated circuit. These steps may be separately fabricated into individual integrated circuit modules, or multiple modules or steps may be fabricated into a single integrated circuit module. achieve.
  • the devices/function modules/functional units in the above embodiments may be implemented by a general-purpose computing device, which may be centralized on a single computing device or distributed over a network of multiple computing devices.
  • the device/function module/functional unit in the above embodiment When the device/function module/functional unit in the above embodiment is implemented in the form of a software function module and sold or used as a stand-alone product, it can be stored in a computer readable storage medium.
  • the above mentioned computer readable storage medium may be a read only memory, a magnetic disk or an optical disk or the like.
  • the working status information or the operation instrument of each instrument is obtained by scanning each instrument connected to the instrument server, and the instrument abstraction driver and the packaged instrument connection interface thereof eliminate the difference of the underlying driving of each instrument. Therefore, the technical solution of the automatic control instrument provided by the embodiment of the invention does not need to know the type of the instrument in the application, and only needs to input the instrument address to realize automatic control of the instrument by calling the instrument abstract drive.

Abstract

A method, device and system for controlling an instrument automatically. The method includes that: an access request accessing to at least one instrument (206) by a client (204) is received, and an instrument agent (203) is started according to the access request (step 510); an instrument address of at least one instrument (206) is analyzed by the instrument agent (203), a corresponding instrument connection interface in an instrument abstract driver (202) is called according to each instrument address, according to the instrument connection interface called, the corresponding instrument (206) is connected, and the connection state is maintained (step 520); according to an instruction received from a client (204) and an instrument driver function interface in the instrument abstract driver (202), the working state information of the corresponding instrument (206) or an operating instrument (206) is obtained by the instrument agent (203) (step 530).

Description

一种自动化控制仪表的方法、装置和系统Method, device and system for automatically controlling instrument 技术领域Technical field
本申请涉及但不限于自动化仪表技术领域。This application relates to, but is not limited to, the field of automated instrumentation technology.
背景技术Background technique
相关的仪表自动化控制技术中,如图1所示,为相关技术中的仪表自动化控制的工作原理示意图。图1所示工作原理中,采用特定的仪表操作指令,基于脚本实现对特定仪表的自动化控制,其中,脚本例如为例如控制/测试脚本,由于脚本与仪表之间的绑定关系,导致脚本只能适用于一款仪表,脚本适用性和可移植性差;需要直接使用仪表厂家提供的远程操作指令,使得开发人员必须了解仪表的远程操作特性和远程指令规则,增加了学习成本和开发难度;随着新仪表的引入,必须不断开发针对新仪表的脚本,导致后续大量重复的开发脚本;而脚本数量的增加也大大提高了脚本维护成本。In the related instrument automation control technology, as shown in FIG. 1 , it is a schematic diagram of the working principle of the instrument automatic control in the related art. In the working principle shown in FIG. 1, the specific instrument operation instruction is adopted, and the automatic control of the specific instrument is implemented based on the script, for example, the script is, for example, a control/test script, and the script is only caused by the binding relationship between the script and the instrument. Can be applied to a meter, script applicability and portability is poor; need to directly use the remote operation instructions provided by the instrument manufacturer, so that developers must understand the remote operation characteristics of the instrument and remote command rules, increasing the learning cost and development difficulty; With the introduction of new instruments, scripts for new instruments must be continuously developed, resulting in a large number of repeated development scripts; and the increase in the number of scripts greatly increases the cost of script maintenance.
相关技术中的仪表自动化连接技术中,由于脚本与具体的仪表绑定在一起,导致脚本灵活性差;各种类型仪表的仪表操作指令都有所不同,增加了开发脚本的难度;用户需要人为的匹配仪表与驱动。In the instrument automation connection technology in the related art, since the script is bound to the specific instrument, the script flexibility is poor; the instrument operation instructions of various types of instruments are different, and the difficulty of developing the script is increased; the user needs artificial Match instruments and drivers.
因此,相关技术存在如下问题:不同厂家的仪表可能采用不同的通讯接口和协议建立仪表与仪表服务器之间的连接,因此需要根据不同的通讯接口、协议开发相应的仪表驱动,增加了脚本修改成本。Therefore, the related art has the following problems: different manufacturers' instruments may use different communication interfaces and protocols to establish a connection between the instrument and the instrument server, so it is necessary to develop corresponding instrument drivers according to different communication interfaces and protocols, and increase the script modification cost. .
发明内容Summary of the invention
以下是对本文详细描述的主题的概述。本概述并非是为了限制权利要求的保护范围。The following is an overview of the topics detailed in this document. This Summary is not intended to limit the scope of the claims.
本文提供一种自动化控制仪表的方法、装置和系统,以解决相关技术中,需要根据不同的通讯接口、协议开发相应的仪表驱动的问题。The present invention provides a method, device and system for automatically controlling a meter to solve the problem in the related art that a corresponding instrument driver needs to be developed according to different communication interfaces and protocols.
一种自动化控制仪表的方法,包括:A method of automatically controlling a meter, comprising:
接收到客户端访问至少一个仪表的访问请求,根据所述访问请求启动仪 表代理;Receiving an access request of the client to access at least one meter, and starting the instrument according to the access request Table agent
所述仪表代理解析出所述至少一个仪表的仪表地址,根据每个所述仪表地址调用仪表抽象驱动中对应的仪表连接接口,通过所调用的仪表连接接口与对应的仪表进行连接并维持连接状态;The meter agent parses out the meter address of the at least one meter, invokes a corresponding meter connection interface in the meter abstract driver according to each of the meter addresses, and connects with the corresponding meter through the called meter connection interface to maintain the connection status. ;
所述仪表代理根据从客户端接收到的指令和所述仪表抽象驱动中的仪表驱动功能接口,得到对应的仪表的工作状态信息或操作所述仪表。The meter agent obtains the working status information of the corresponding meter or operates the meter according to the instruction received from the client and the meter driving function interface in the meter abstract driving.
可选地,所述的方法中,采用开关矩阵将所述仪表连接到待测设备,所述仪表代理通过启动一个单独的线程或子进程来控制所述开关矩阵切换所述仪表与所述待测设备之间的线路。Optionally, in the method, the meter is connected to the device to be tested by using a switch matrix, and the meter agent controls the switch matrix to switch the meter and the standby by starting a separate thread or a sub-process Measure the line between the devices.
可选地,所述的方法中,所述接收到客户端访问至少一个仪表的访问请求之前,所述方法还包括:Optionally, in the method, before the receiving the access request of the client to access the at least one meter, the method further includes:
在每个仪表底层驱动中定义一个底层仪表状态扫描函数,且每个所述仪表底层驱动中的底层仪表状态扫描函数采用相同的名称;An underlying instrument state scan function is defined in each instrument underlying driver, and the underlying instrument state scan function in each of the instrument underlying drivers has the same name;
在所述仪表抽象驱动中定义与所述底层仪表状态扫描函数名称相同的仪表状态扫描函数,所述仪表状态扫描函数用于调用每个所述仪表底层驱动中的底层仪表状态扫描函数。An instrument state scan function having the same name as the underlying meter state scan function is defined in the meter abstract driver, and the meter state scan function is used to call an underlying meter state scan function in each of the meter underlying drivers.
可选地,所述的方法中,所述仪表代理根据每个所述仪表地址调用仪表抽象驱动中对应的仪表连接接口,通过所调用的仪表连接接口与对应的仪表进行连接并维持连接状态,包括:Optionally, in the method, the meter agent invokes a corresponding meter connection interface in the meter abstract driver according to each of the meter addresses, and connects with the corresponding meter through the called meter connection interface to maintain the connection state. include:
所述仪表代理调用所述仪表抽象驱动中的所述仪表连接接口,并向所述仪表连接接口传入所述仪表地址;The meter agent invokes the meter connection interface in the meter abstract driver, and transmits the meter address to the meter connection interface;
所述仪表连接接口在判定所述仪表地址的地址类型之后,调用相应的通讯协议库,轮循每个仪表底层驱动中的底层连接函数;After determining the address type of the instrument address, the meter connection interface invokes a corresponding communication protocol library to cycle through the underlying connection function in each instrument underlying driver;
当轮循到一个所述仪表底层驱动的底层连接函数返回成功时,轮循终止,所述仪表抽象驱动记录当前轮循到的仪表底层驱动,所述仪表连接接口返回成功;When the round-robin to the underlying connection function of the underlying driver of the meter returns successfully, the round-robin is terminated, and the meter abstraction drive records the underlying driver of the current round-robin, and the meter connection interface returns successfully;
当轮循所有仪表底层驱动的底层连接函数都返回失败时,所述仪表连接接口返回失败。 The instrument connection interface returns a failure when the underlying connection function that rotates all of the underlying drivers of the instrument returns a failure.
可选地,所述的方法中,所述仪表代理根据从客户端接收到的指令和所述仪表抽象驱动中的仪表驱动功能接口,得到对应的仪表的工作状态信息或操作所述仪表,包括:Optionally, in the method, the meter agent obtains the working status information of the corresponding meter or operates the meter according to the instruction received from the client and the instrument driving function interface in the meter abstract driving, including :
所述仪表代理将从所述客户端接收到的指令存入通信队列,当前连接的对应仪表的子进程解析所述指令得到对应的仪表底层功能函数,根据所述仪表抽象驱动中的仪表驱动功能接口调用所述仪表底层功能函数;The meter agent stores the instruction received from the client into the communication queue, and the sub-process of the currently connected corresponding meter parses the instruction to obtain a corresponding underlying function function of the meter, according to the instrument driving function in the instrument abstract driver The interface calls the underlying function of the meter;
所述仪表将返回的结果传递给所述子进程,所述子进程将所述结果保存至接收队列,所述仪表代理通过传输控制协议TCP连接将所述结果返回给所述客户端。The meter passes the returned result to the child process, the child process saves the result to a receive queue, and the meter agent returns the result to the client via a Transmission Control Protocol TCP connection.
可选地,所述的方法中,所述仪表代理根据从客户端接收到的指令和所述仪表抽象驱动中的仪表驱动功能接口,得到对应的仪表的工作状态信息或操作所述仪表,还包括:Optionally, in the method, the meter agent obtains the working status information of the corresponding meter or operates the meter according to the instruction received from the client and the instrument driving function interface in the meter abstract driving, and include:
在所述仪表代理的子进程与所述仪表维持连接状态的过程中,每隔一段时长,所述子进程调用底层仪表状态扫描函数实时读取所述仪表的工作状态信息,并将得到的所述仪表的工作状态信息存入队列或数据库中。During the process of maintaining the connection state between the child process of the meter agent and the meter, the sub-process calls the underlying instrument state scan function to read the working state information of the meter in real time, and obtains the obtained information. The working status information of the meter is stored in the queue or database.
一种自动化控制仪表的装置,包括:An apparatus for automatically controlling a meter, comprising:
客户端请求接收模块,设置为:接收到客户端访问至少一个仪表的访问请求,根据所述访问请求启动仪表代理;The client request receiving module is configured to: receive an access request of the client to access the at least one meter, and start the meter proxy according to the access request;
仪表代理,设置为:解析出所述客户端请求接收模块接收到的所述至少一个仪表的仪表地址,根据每个所述仪表地址调用仪表抽象驱动中对应的仪表连接接口,通过所调用的仪表连接接口与对应的仪表进行连接并维持连接状态;The meter agent is configured to: parse out the meter address of the at least one meter received by the client request receiving module, and invoke a corresponding meter connection interface in the meter abstract driver according to each of the meter addresses, by using the called meter The connection interface is connected with the corresponding meter and maintains the connection state;
所述仪表代理,还设置为:根据从客户端接收到的指令和所述仪表抽象驱动中的仪表驱动功能接口,得到对应的仪表的工作状态信息或操作所述仪表。The meter agent is further configured to: obtain the working status information of the corresponding meter or operate the meter according to the instruction received from the client and the instrument driving function interface in the meter abstract driving.
可选地,所述的装置中,还包括:Optionally, the device further includes:
开关矩阵,设置为:将所述仪表连接到待测设备,所述仪表代理通过启动一个单独的线程或子进程来控制所述开关矩阵切换所述仪表与所述待测设 备之间的线路。a switch matrix, configured to: connect the meter to a device under test, and the meter agent controls the switch matrix to switch the meter and the device to be tested by starting a separate thread or a sub-process The line between the backups.
可选地,所述的装置中,还包括:Optionally, the device further includes:
仪表底层驱动,设置为:在每个仪表底层驱动中定义一个底层仪表状态扫描函数,且每个所述仪表底层驱动中的底层仪表状态扫描函数采用相同的名称;The underlying driver of the instrument is set to: define an underlying instrument state scanning function in each instrument underlying driver, and the underlying instrument state scanning function in each of the instrument underlying drivers adopts the same name;
仪表抽象驱动,设置为:在所述仪表抽象驱动中定义与所述底层仪表状态扫描函数名称相同的仪表状态扫描函数,所述仪表状态扫描函数用于调用每个所述仪表底层驱动中的底层仪表状态扫描函数。An instrument abstraction driver is configured to: define, in the meter abstract driver, an instrument state scan function having the same name as the underlying meter state scan function, the gauge state scan function for calling the bottom layer of each of the instrument underlying drivers Instrument status scan function.
可选地,所述的装置中,所述仪表代理包括:Optionally, in the device, the instrument agent includes:
仪表地址转发模块,设置为:调用所述仪表抽象驱动中的所述仪表连接接口,并向所述仪表连接接口传入所述仪表地址;The meter address forwarding module is configured to: invoke the meter connection interface in the meter abstract driver, and transmit the meter address to the meter connection interface;
所述仪表抽象驱动包括:The instrument abstract driver includes:
仪表地址检测模块,设置为:指示所述仪表连接接口在判定了地址类型之后,调用相应的通讯协议库,轮循每个仪表底层驱动中的底层连接函数;The instrument address detecting module is configured to: instruct the meter connection interface to call the corresponding communication protocol library after determining the address type, and to cycle through the bottom layer connection function in each instrument underlying driver;
当轮循到一个所述仪表底层驱动的底层连接函数返回成功时,轮循终止,所述仪表抽象驱动记录当前轮循到的仪表底层驱动,所述仪表连接接口返回成功;When the round-robin to the underlying connection function of the underlying driver of the meter returns successfully, the round-robin is terminated, and the meter abstraction drive records the underlying driver of the current round-robin, and the meter connection interface returns successfully;
当轮循所有仪表底层驱动的底层连接函数都返回失败时,所述仪表连接接口返回失败。The instrument connection interface returns a failure when the underlying connection function that rotates all of the underlying drivers of the instrument returns a failure.
一种自动化控制仪表的系统,包括:A system for automatically controlling instruments, including:
客户端,与仪表代理连接,所述客户端设置为:运行脚本;a client, connected to the meter agent, the client is set to: run a script;
客户端请求接收模块,设置为:接收到客户端访问至少一个仪表的访问请求,根据所述访问请求启动所述仪表代理;The client request receiving module is configured to: receive an access request of the client to access the at least one meter, and start the meter agent according to the access request;
所述仪表代理,设置为:解析出所述客户端请求接收模块接收到的所述至少一个仪表的仪表地址,根据每个所述仪表地址调用仪表抽象驱动中对应的仪表连接接口,通过所调用的仪表连接接口与对应的仪表进行连接并维持连接状态; The meter agent is configured to: parse out a meter address of the at least one meter received by the client request receiving module, and invoke a corresponding meter connection interface in the meter abstract driver according to each of the meter addresses, by calling The instrument connection interface is connected with the corresponding instrument and maintains the connection state;
所述仪表代理,还设置为:根据从客户端接收到的指令和所述仪表抽象驱动中的仪表驱动功能接口,得到对应的仪表的工作状态信息或操作所述仪表;The meter agent is further configured to: obtain an operation status information of the corresponding meter or operate the meter according to an instruction received from the client and an instrument driving function interface in the instrument abstract driving;
仪表,设置为:通过通讯接口与所述仪表代理相连接。The meter is set to be connected to the instrument agent through a communication interface.
本发明实施例提供的自动化控制仪表的方法、装置和系统,通过在仪表服务器上对接入的每台仪表进行扫描得到每台仪表的工作状态信息或者操作仪表,由于仪表抽象驱动及其封装的仪表连接接口消除了各个仪表底层驱动的差异,因此,本发明实施例提供的自动化控制仪表的技术方案在应用中,无需知道仪表的类型,只需要输入仪表地址就能够通过调用仪表抽象驱动实现对仪表的自动化控制。The method, device and system for automatically controlling the instrument provided by the embodiment of the invention obtain the working state information or the operation instrument of each instrument by scanning each instrument connected to the instrument server, because the instrument abstract drive and its package The instrument connection interface eliminates the difference of the underlying driving of each instrument. Therefore, the technical solution of the automatic control instrument provided by the embodiment of the invention does not need to know the type of the instrument, and only needs to input the instrument address to realize the pair by calling the instrument abstract driver. Automatic control of the instrument.
在阅读并理解了附图和详细描述后,可以明白其他方面。Other aspects will be apparent upon reading and understanding the drawings and detailed description.
附图概述BRIEF abstract
图1为相关技术中的仪表自动化控制的工作原理示意图;1 is a schematic diagram showing the working principle of instrument automatic control in the related art;
图2为本发明实施例提供的一种仪表自动化控制的装置的结构示意图;2 is a schematic structural diagram of an apparatus for automatic control of an instrument according to an embodiment of the present invention;
图3为本发明实施例提供的仪表自动化控制的装置中一种仪表底层驱动的开发结构示意图;3 is a schematic diagram of a development structure of an instrument underlying driver in an apparatus for automatically controlling an instrument according to an embodiment of the present invention;
图4为本发明实施例提供的仪表自动化控制的装置中一种仪表抽象驱动的工作原理示意图;4 is a schematic diagram of a working principle of an instrument abstract driving in an apparatus for automatically controlling an instrument according to an embodiment of the present invention;
图5为本发明实施例提供的一种自动化控制仪表的方法的流程示意图;FIG. 5 is a schematic flowchart of a method for automatically controlling a meter according to an embodiment of the present invention;
图6为本发明实施例提供的另一种自动化控制仪表的方法的流程示意图;FIG. 6 is a schematic flowchart diagram of another method for automatically controlling a meter according to an embodiment of the present invention;
图7为本发明实施例提供的又一种自动化控制仪表的方法的流程示意图;FIG. 7 is a schematic flowchart diagram of still another method for automatically controlling a meter according to an embodiment of the present invention;
图8为本发明实施例提供的再一种自动化控制仪表的方法的流程示意图;FIG. 8 is a schematic flowchart diagram of still another method for automatically controlling a meter according to an embodiment of the present invention; FIG.
图9为本发明实施例提供的一种仪表自动化控制的装置的结构示意图;FIG. 9 is a schematic structural diagram of an apparatus for automatically controlling an instrument according to an embodiment of the present invention; FIG.
图10为本发明实施例提供的仪表自动化控制的装置中一种仪表代理的结构示意图;10 is a schematic structural diagram of an instrument agent in an apparatus for automatically controlling an instrument according to an embodiment of the present invention;
图11为本发明实施例提供的仪表自动化控制的装置中一种仪表开关矩阵 选择模块的工作原理示意图;11 is a meter switch matrix in an apparatus for automatic control of an instrument according to an embodiment of the present invention; A schematic diagram of the working principle of the selection module;
图12为本发明实施例提供的仪表自动化控制的装置中一种仪表地址转发模块的工作原理示意图;12 is a schematic diagram of a working principle of a meter address forwarding module in an apparatus for automatically controlling an instrument according to an embodiment of the present invention;
图13为本发明实施例提供的一种仪表的自动化控制系统的结构示意图。FIG. 13 is a schematic structural diagram of an automatic control system for a meter according to an embodiment of the present invention.
本发明的实施方式Embodiments of the invention
下文中将结合附图对本发明的实施方式进行详细说明。需要说明的是,在不冲突的情况下,本文中的实施例及实施例中的特征可以相互任意组合。Embodiments of the present invention will be described in detail below with reference to the accompanying drawings. It should be noted that, in the case of no conflict, the features in the embodiments and the embodiments herein may be arbitrarily combined with each other.
在附图的流程图示出的步骤可以在诸根据一组计算机可执行指令的计算机系统中执行。并且,虽然在流程图中示出了逻辑顺序,但是在某些情况下,可以以不同于此处的顺序执行所示出或描述的步骤。The steps illustrated in the flowchart of the figures may be executed in a computer system in accordance with a set of computer executable instructions. Also, although logical sequences are shown in the flowcharts, in some cases the steps shown or described may be performed in a different order than the ones described herein.
如图2所示,为本发明实施例提供的一种仪表自动化控制的装置的结构示意图。本发明实施例提供的仪表自动化控制的方法和装置涉及多个概念,在描述本发明实施例之前,首先对仪表自动化控制系统中的一些基本概念进行详细描述,这些概念的含义如下:FIG. 2 is a schematic structural diagram of an apparatus for automatically controlling an instrument according to an embodiment of the present invention. The method and apparatus for instrument automation control provided by the embodiments of the present invention involve multiple concepts. Before describing the embodiments of the present invention, some basic concepts in the instrument automation control system are first described in detail. The meanings of these concepts are as follows:
仪表底层驱动201,供仪表抽象驱动202调用,并通过通讯接口205直接与仪表206进行通信。仪表底层驱动201是针对每款仪表各自开发的驱动程序,是仪表自动化控制的基础。仪表底层驱动201中抽象出仪表的功能、操作步骤,统一定义一套仪表底层功能函数,即应用程序接口(Application Programming Interface,简称为:API),仪表底层功能函数包括函数名称、参数个数、参数类型和返回值类型等。仪表底层驱动201包括与仪表206之间建立连接的连接函数,仪表206的各个功能函数;连接函数还包括了认证仪表身份的唯一性这一功能,身份认证对于自动识别仪表类型至关重要。每一款仪表都有只属于该款仪表的某项特性或特殊标识,可以通过厂家提供的远程指令查到这些特性/标识,例如,串口仪表可以通过仪表自定义的串口通信协议进行身份认证。仪表的物理接口包括但不仅限于以太网连接、串口连接和通用接口总线(General-Purpose Interface Bus,简称为:GPIB)连接,仪表的通信方式包括传输控制协议(Transmission Control Protocol,简称为:TCP)、用户数据报 协议(User Datagram Protocol,简称为:UDP)、远程终端协议(telnet)、串行通讯端口(Cluster Communication Port,简称为:COM口)通讯和GPIB口通讯等。仪表底层功能函数实现了对仪表的实际操作,应当适用于后续开发的所有种类仪表,因此需严格按照接口的定义编写。The instrument underlay driver 201 is invoked by the meter abstraction driver 202 and communicates directly with the meter 206 via the communication interface 205. The instrument underlying driver 201 is a driver developed for each instrument and is the basis of instrument automation control. The underlying driver 201 abstracts the functions and operation steps of the instrument, and uniformly defines a set of instrument underlying function functions, namely the Application Programming Interface (API). The underlying function of the instrument includes the function name, the number of parameters, Parameter type and return value type, etc. The underlying driver 201 includes a connection function to establish a connection with the meter 206, and various functional functions of the meter 206. The connection function also includes the uniqueness of authenticating the identity of the meter, and identity authentication is essential for automatically identifying the type of meter. Each instrument has a certain characteristic or special identifier belonging to the instrument. These characteristics/identities can be found by remote commands provided by the manufacturer. For example, the serial instrument can be authenticated by the serial communication protocol customized by the instrument. The physical interface of the instrument includes, but is not limited to, an Ethernet connection, a serial connection, and a General-Purpose Interface Bus (GPIB) connection. The communication method of the instrument includes a Transmission Control Protocol (TCP). User datagram Protocol (User Datagram Protocol, referred to as: UDP), remote terminal protocol (telnet), serial communication port (Cluster Communication Port, referred to as: COM port) communication and GPIB port communication. The underlying function of the instrument implements the actual operation of the instrument and should be applied to all types of instruments developed in the future. Therefore, it must be written in strict accordance with the definition of the interface.
如图3所示,为本发明实施例提供的仪表自动化控制的装置中一种仪表底层驱动的开发结构示意图。仪表底层驱动201采用三层结构:数据传输层、命令实现层和命令接口层。数据传输层实现与仪表之间简单的发送、接收功能,不论仪表采用何种通信方式,每一个仪表底层驱动201都支持一种通讯协议,数据传输层的发送、接收功能基于这种通讯协议开发。命令实现层,基于数据传输层,结合仪表自身的特性实现了对仪表的操作、查询两种功能。命令接口层基于命令实现层实现特定的操作或查询功能,其命令接口符合统一定义的仪表底层功能函数,仪表底层功能函数实现了对仪表的实际操作。FIG. 3 is a schematic diagram of a development structure of an instrument underlying driver in an apparatus for automatically controlling an instrument according to an embodiment of the present invention. The underlying driver 201 of the instrument adopts a three-layer structure: a data transmission layer, a command implementation layer, and a command interface layer. The data transmission layer realizes simple transmission and reception functions between the instrument and the meter. Regardless of the communication mode adopted by the instrument, each instrument underlying driver 201 supports a communication protocol, and the transmission and reception functions of the data transmission layer are developed based on the communication protocol. . The command implementation layer, based on the data transmission layer, combines the characteristics of the meter itself to realize the functions of the instrument operation and query. The command interface layer implements a specific operation or query function based on the command implementation layer, and the command interface conforms to the uniformly defined underlying function of the instrument, and the underlying function of the instrument implements the actual operation of the instrument.
仪表抽象驱动202,调用仪表底层驱动201,并被仪表代理203调用,定义有若干个仪表驱动功能接口。仪表抽象驱动202中定义了所有仪表底层驱动201中已经规划好的仪表底层功能函数的同名函数-仪表驱动功能接口,当仪表206的身份被确认后,这些仪表抽象驱动202中的同名函数-仪表驱动功能接口,可以直接指向与仪表206相对应的仪表底层驱动201中的同名函数-仪表底层功能函数。The instrument abstraction driver 202 calls the instrument underlying driver 201 and is called by the meter agent 203 to define a number of meter driver function interfaces. The meter abstraction driver 202 defines the same-named function-instrument-driven function interface of all the underlying function functions of the meter in the underlying driver 201. When the identity of the meter 206 is confirmed, the same-named function in the instrument abstraction driver 202-meter The driver function interface can directly point to the function of the same name in the instrument underlying driver 201 corresponding to the meter 206 - the underlying function of the meter.
如图4所示,为本发明实施例提供的仪表自动化控制的装置中一种仪表抽象驱动的工作原理示意图。仪表抽象驱动202在入口处会检测仪表代理203传入的仪表地址的合法性,通过关键字判断仪表地址的类型,即仪表的物理连接方式,进而确定仪表的连接地址。仪表抽象驱动202尝试通过连接地址与对应的仪表建立连接,然后依次调用每个仪表底层驱动201对仪表206进行身份认证;若仪表206返回的身份认证信息符合当前仪表底层驱动201中所定义的仪表身份认证结果,则可确定当前仪表底层驱动201为当前连接仪表所适用,若不符合,则继续尝试匹配下一个仪表底层驱动201,直到匹配到正确的仪表底层驱动201为止,实现了仪表底层驱动201与仪表206之间的自动匹配/适配。FIG. 4 is a schematic diagram showing the working principle of an instrument abstract driving in the device automatic control device provided by the embodiment of the present invention. The meter abstraction driver 202 detects the legality of the meter address passed by the meter agent 203 at the entrance, and determines the type of the meter address by the keyword, that is, the physical connection mode of the meter, thereby determining the connection address of the meter. The meter abstraction driver 202 attempts to establish a connection with the corresponding meter through the connection address, and then in turn calls each meter bottom driver 201 to authenticate the meter 206; if the identity information returned by the meter 206 conforms to the meter defined in the current meter bottom driver 201 The result of the identity authentication can be determined that the current instrument underlying driver 201 is applicable to the currently connected meter. If not, the user continues to try to match the next underlying driver 201 until the correct underlying driver 201 is matched, thereby implementing the underlying driver of the meter. Automatic matching/adaptation between 201 and meter 206.
仪表代理203在调用仪表抽象驱动202中的仪表驱动功能接口时,会自动转去调用已经适配的仪表底层驱动201中的同名的仪表底层功能函数,这样就 实现了在不知道仪表类型的情况下对仪表的自动化控制。例如,仪表代理203收到打开仪表激光器的命令,会调用仪表抽象驱动202中对应打开仪表激光器的功能API,由于此时已经确认了连接的仪表206的身份,仪表抽象驱动202中的打开仪表激光器的功能API会准确找到并调用对应所连接仪表206的仪表底层驱动201中的打开仪表激光器的仪表底层功能函数。When the meter agent 203 calls the instrument driver function interface in the meter abstraction driver 202, it automatically switches to the underlying function function of the same name in the instrument underlying driver 201 that has been adapted, so that Automated control of the meter without knowing the type of meter is achieved. For example, when the meter agent 203 receives the command to turn on the meter laser, it will invoke the function API of the meter abstract driver 202 corresponding to the meter laser. Since the identity of the connected meter 206 has been confirmed at this time, the meter laser in the meter abstract driver 202 is turned on. The function API will accurately find and call the instrument underlying function function of the meter laser in the meter bottom driver 201 corresponding to the connected meter 206.
仪表代理203,与客户端204连接,供脚本调用,以及调用仪表抽象驱动202。The meter agent 203 is coupled to the client 204 for scripting and to invoke the meter abstraction driver 202.
客户端204,是整套仪表自动化控制系统的输入端,与仪表代理203连接。可以是运行脚本的解释器,也可以是更直观的命令行窗口或用户界面(User's Interface,简称为:UI)界面。The client 204 is an input of the entire instrument automation control system and is connected to the meter agent 203. It can be an interpreter that runs a script, or it can be a more intuitive command line window or User's Interface (UI) interface.
通讯接口205,仪表206与运行仪表代理203的测试机之间的接口,本发明支持的仪表通讯接口包括但不限于以太网、串口和GPIB等,其中以太网连接支持的通信协议包括:telnet、TCP和UDP等。The communication interface 205, the interface between the meter 206 and the test machine running the instrumentation agent 203, the instrument communication interface supported by the invention includes but is not limited to Ethernet, serial port and GPIB, etc., wherein the communication protocol supported by the Ethernet connection includes: telnet, TCP and UDP, etc.
仪表206,自动化控制的对象,仪表206的一端通过不同的通讯接口与运行仪表代理203的测试机相连,另一端通过开关矩阵与待测设备208相连;根据需要,仪表206也可直接与待测设备208相连。The meter 206, the object of the automatic control, one end of the meter 206 is connected to the testing machine running the meter agent 203 through different communication interfaces, and the other end is connected to the device to be tested 208 through the switch matrix; the meter 206 can also directly and test according to the need Device 208 is connected.
开关矩阵207,一端连接所有仪表206,另一端连接所有待测设备208。支持远程控制,支持通过指令实现仪表206与待测设备208之间的线路切换,更大限度的实现对仪表206的自动化控制,免去了人工换线。The switch matrix 207 has one end connected to all the meters 206 and the other end connected to all the devices 208 to be tested. The remote control is supported, and the line switching between the meter 206 and the device under test 208 is supported by the instruction, and the automatic control of the meter 206 is realized to a greater extent, and the manual line change is eliminated.
待测设备208,是进行自动化控制的目标对象,连接开关矩阵,根据需要也可直接与仪表206连接。The device under test 208 is a target object for automatic control, and is connected to the switch matrix, and can also be directly connected to the meter 206 as needed.
在仪表服务器与仪表206保持连接的过程中,实现定时扫描连接状况、仪表206的忙、闲状态,实时呈现仪表的连接、使用情况;以及借助开关矩阵207实现仪表206与待测设备208之间连接线路的自动切换。During the process of maintaining the connection between the meter server and the meter 206, the timing scan connection status, the busy and idle status of the meter 206, the connection and usage of the meter are presented in real time, and the switch 206 is used to implement the relationship between the meter 206 and the device under test 208. Automatic switching of connected lines.
如图5所示,为本发明实施例提供的一种自动化控制仪表的方法的流程示意图。本实施例提供的自动化控制仪表的方法可以包括如下步骤,即步骤510步骤530:FIG. 5 is a schematic flowchart diagram of a method for automatically controlling a meter according to an embodiment of the present invention. The method for automatically controlling the meter provided in this embodiment may include the following steps, step 510: Step 530:
步骤510,接收到客户端访问至少一个仪表的访问请求,根据该访问请求 启动仪表代理;Step 510: Receive an access request of the client to access at least one meter, according to the access request. Start the instrumentation agent;
步骤520,仪表代理解析出至少一个仪表的仪表地址,根据每个仪表地址调用仪表抽象驱动中对应的仪表连接接口,通过所调用的仪表连接接口与对应的仪表进行连接并维持连接状态;Step 520: The meter agent parses out the meter address of the at least one meter, invokes the corresponding meter connection interface in the meter abstract driver according to each meter address, and connects with the corresponding meter through the called meter connection interface to maintain the connection state;
步骤530,仪表代理根据从客户端接收到的指令和仪表抽象驱动中的仪表驱动功能接口,得到对应的仪表的工作状态信息或操作仪表。Step 530: The instrument agent obtains the working status information or the operation instrument of the corresponding meter according to the instruction received from the client and the instrument driving function interface in the instrument abstract driving.
本发明实施例提供的技术方案,在仪表服务器上对接入的每台仪表进行扫描得到每台仪表的工作状态信息或者操作仪表,由于仪表抽象驱动202及其封装的仪表连接接口消除了各个仪表底层驱动201的差异,因此,本发明实施例提供的方法在应用中,无需知道仪表的类型,只需要输入仪表地址就能够通过调用仪表抽象驱动202实现对仪表的自动化控制。According to the technical solution provided by the embodiment of the present invention, each instrument that is accessed is scanned on the instrument server to obtain the working state information or the operation instrument of each instrument, and the meter abstraction driver 202 and the packaged instrument connection interface thereof eliminate the respective instruments. The difference between the underlying driver 201 and the method provided by the embodiment of the present invention, in the application, does not need to know the type of the meter, and only needs to input the meter address to enable automatic control of the meter by calling the meter abstract driver 202.
本发明实施例提供的自动化控制仪表的方法通常应用于仪表服务器,仪表服务器能够控制多个仪表。在本发明的一个可选地实施例中,仪表206与待测设备208通过开关矩阵相连,仪表代理203可以通过启动一个单独的线程或子进程实现对开关矩阵的连接、管理和控制。当使用的仪表发生改变,或该仪表206连接的待测设备208发生改变,需要切换仪表206与待测设备208之间的连线时,通过给仪表代理203下发相应指令或修改配置文件,就能实现仪表206与待测设备208之间连线的自动切换。The method for automatically controlling the instrument provided by the embodiment of the present invention is generally applied to an instrument server, and the instrument server can control a plurality of meters. In an alternative embodiment of the invention, meter 206 is coupled to device under test 208 via a switch matrix, and meter agent 203 can effect connection, management, and control of the switch matrix by initiating a separate thread or sub-process. When the instrument used is changed, or the device to be tested 208 connected to the meter 206 is changed, and the connection between the meter 206 and the device under test 208 needs to be switched, the corresponding instruction is issued to the meter agent 203 or the configuration file is modified. Automatic switching of the connection between the meter 206 and the device under test 208 can be achieved.
在本发明实施例提供的自动化控制仪表的方法的过程中涉及到了多个不同的功能对象,这些功能对象各自具有自己应当实现的功能,且需要与其他功能对象具有对应关系,并配合完成整个的控制过程。In the process of the method for automatically controlling the instrument provided by the embodiment of the present invention, a plurality of different functional objects are involved, and each of the functional objects has a function that should be implemented by itself, and needs to have a corresponding relationship with other functional objects, and completes the entire Control process.
在实际应用中,一个仪表底层驱动201对应着一种仪表206,每一个仪表底层驱动201,都可以实现不同的功能,例如可以实现连接功能、查询功能、操作功能等。In practical applications, a meter bottom driver 201 corresponds to a meter 206, and each meter bottom driver 201 can implement different functions, such as connection function, query function, operation function, and the like.
本发明实施例提供的方法,在执行上述实施例的步骤510之前,需要为每台仪表206分别编写仪表底层驱动201,然后基于所有仪表底层驱动201,通过封装形成一个上层的仪表抽象驱动202,该仪表抽象驱动202中包括了若干个实现单一功能的仪表驱动功能接口,每一个仪表驱动功能接口实现一个单一 功能,例如连接功能、查询功能或者设置功能等。In the method provided by the embodiment of the present invention, before performing the step 510 of the foregoing embodiment, the instrument underlay driver 201 needs to be separately written for each meter 206, and then an upper meter abstraction driver 202 is formed by encapsulation based on all the instrument underlayer drivers 201. The instrument abstract driver 202 includes a plurality of instrument driving function interfaces for implementing a single function, and each instrument driving function interface realizes a single Features such as connection, query, or setup.
可选地,如图6所示,为本发明实施例提供的另一种自动化控制仪表的方法的流程示意图。在上述图5所示实施例的基础上,本实施例提供的方法在步骤510之前,还可以包括:每台仪表206分别编写仪表底层驱动,其中,编写仪表底层驱动的实现方式为:Optionally, as shown in FIG. 6 , it is a schematic flowchart of another method for automatically controlling a meter according to an embodiment of the present invention. On the basis of the foregoing embodiment shown in FIG. 5, the method provided in this embodiment may further include: before each step 206, each instrument 206 separately writes an underlying driver of the instrument, wherein the implementation manner of writing the underlying driver of the instrument is:
步骤500,在每个仪表底层驱动中定义一个底层仪表状态扫描函数,所有仪表底层驱动中的底层仪表状态扫描函数采用相同的名称;其中,该底层仪表状态扫描函数用于执行仪表状态扫描,例如为API-仪表状态扫描函数;Step 500: Define an underlying instrument state scan function in each instrument underlying driver, and the underlying instrument state scan function in all instrument underlying drivers adopt the same name; wherein the underlying instrument state scan function is used to perform instrument state scanning, for example For the API-meter status scan function;
步骤501,在仪表抽象驱动中定义与底层仪表状态扫描函数名称相同的仪表状态扫描函数,该名称相同的仪表状态扫描函数用于调用每个仪表底层驱动中的底层仪表状态扫描函数。Step 501: Define an instrument state scan function having the same name as the underlying instrument state scan function in the instrument abstract driver, and the instrument state scan function with the same name is used to call the underlying instrument state scan function in each instrument underlying driver.
本发明实施例提供的方法,不仅需要为每台仪表在仪表底层驱动201中定义一个底层仪表状态扫描函数,而且还需要定义其他的底层单功能函数。因此,则需要对这些底层单功能函数与仪表抽象驱动202中调用这些底层单功能函数的仪表驱动功能接口进行规范;其中,仪表驱动功能接口泛指仪表抽象驱动202中,与仪表底层驱动201中定义的底层仪表状态扫描函数同名的仪表驱动功能接口,步骤501中定义的仪表抽象驱动202中的仪表状态扫描函数就是其中一个仪表驱动功能接口。在本发明的一个可选地实施例中,仪表抽象驱动202包括多个单功能API-仪表驱动功能接口,在每一个仪表驱动功能接口中封装了每个仪表底层驱动201的同一功能-底层单功能函数,而在仪表底层驱动201中,对应这一仪表驱动功能接口的各个底层单功能函数名字相同,且与仪表驱动功能接口的名字相同。The method provided by the embodiment of the present invention not only needs to define an underlying instrument state scanning function for each meter in the instrument underlying driver 201, but also needs to define other underlying single function functions. Therefore, it is necessary to standardize the underlying single function and the instrumentation function interface of the instrument abstraction driver 202 that calls these underlying single function functions; wherein the instrument driver function interface generally refers to the instrument abstraction driver 202, and the instrument underlying driver 201 The defined underlying instrument state scan function interfaces with the instrument driver function of the same name. The instrument state scan function in the instrument abstraction driver 202 defined in step 501 is one of the meter drive function interfaces. In an alternative embodiment of the present invention, the meter abstraction driver 202 includes a plurality of single-function API-meter-driven function interfaces, each of which encapsulates the same function of each meter-based driver 201 in each meter-driven function interface - the underlying single The function function, and in the underlying driver 201 of the instrument, the names of the respective underlying single function functions corresponding to the instrument driving function interface are the same, and the names of the interfaces of the instrument driving function are the same.
可选地,如图7所示,为本发明实施例提供的又一种自动化控制仪表的方法的流程示意图。在上述图5所示实施例的基础上,启动仪表代理203之后,即步骤520中,根据每个仪表地址调用仪表抽象驱动中对应的仪表连接接口,通过所调用的仪表连接接口与对应的仪表进行连接并维持连接状态,可以包括如下步骤,即步骤521~步骤524:Optionally, as shown in FIG. 7, another schematic flowchart of a method for automatically controlling a meter according to an embodiment of the present invention is provided. On the basis of the embodiment shown in FIG. 5, after the instrumentation agent 203 is started, in step 520, the corresponding instrument connection interface in the instrument abstraction driver is invoked according to each instrument address, and the instrument connection interface and the corresponding instrument are invoked. To perform the connection and maintain the connection state, the following steps may be included, that is, steps 521 to 524:
步骤521,仪表代理调用仪表抽象驱动中的仪表连接接口,并向该仪表连接接口传入仪表地址; Step 521, the instrument agent invokes the instrument connection interface in the instrument abstract driver, and transmits the instrument address to the instrument connection interface;
步骤522,仪表连接接口在判定该仪表地址的地址类型之后,调用相应的通讯协议库,轮循每个仪表底层驱动中的底层连接函数。Step 522: After determining the address type of the instrument address, the meter connection interface calls the corresponding communication protocol library to cycle through the underlying connection function in each instrument underlying driver.
本实施例中,仪表连接接口以该仪表地址为参数,先判断仪表地址的合法性,再以仪表地址为参数,依次轮循调用每个仪表底层驱动201中的底层连接函数;在步骤522之后,还包括:In this embodiment, the instrument connection interface takes the instrument address as a parameter, first determines the legality of the instrument address, and then uses the instrument address as a parameter to sequentially call the underlying connection function in each instrument underlying driver 201; after step 522 ,Also includes:
步骤523,当调用到某个仪表底层驱动的连接函数返回成功时,轮循终止,仪表抽象驱动记录当前轮循到的仪表底层驱动,仪表抽象驱动的仪表连接接口连接函数返回成功;Step 523, when the connection function called to the underlying driver of a certain instrument returns successfully, the round robin is terminated, the instrument abstraction drive records the underlying driver of the current round of the instrument, and the instrument connection interface connection function of the instrument abstraction drive returns successfully;
步骤524,当轮循所有仪表底层驱动的底层连接函数都返回失败时,则仪表抽象驱动的仪表连接接口返回失败,并提醒用户检查仪表地址是否填写正确。In step 524, when the underlying connection function of all the underlying drivers of the instrument returns to fail, the meter connection interface driven by the meter abstraction fails to return, and the user is reminded to check whether the meter address is correctly filled.
在本发明的一个可选地实施例中,还包括:In an optional embodiment of the present invention, the method further includes:
连接建立后,仪表底层驱动201通过调用对应的仪表底层功能函数向仪表206发送只有该对应仪表才能够识别的特殊指令,看所连接仪表能否正确应答,若应答正确,说明所连接仪表206与仪表底层驱动201匹配,返回成功;若应答失败,则说明所连接仪表206与仪表底层驱动201不匹配,释放与该仪表的连接和资源,返回失败。将要连接的所有仪表地址写入配置文件或数据库中。连接成功后,当调用其他仪表驱动功能接口时,仪表驱动功能接口会自动调用之前记录的仪表底层驱动201对象中的同名仪表底层功能函数。After the connection is established, the underlying driver 201 of the meter sends a special instruction that can be recognized only by the corresponding meter to the meter 206 by calling the corresponding underlying function of the meter to see whether the connected meter can correctly respond. If the response is correct, the connected meter 206 is The underlying driver 201 of the meter matches and returns successfully; if the response fails, it indicates that the connected meter 206 does not match the underlying driver 201 of the meter, releases the connection and resources with the meter, and returns to failure. Write all meter addresses to be connected to the configuration file or database. After the connection is successful, when the other instrument driver function interface is called, the instrument driver function interface automatically calls the underlying function function of the same name in the instrument underlying driver 201 object recorded previously.
可选地,如图8所示,为本发明实施例提供的再一种自动化控制仪表的方法的流程示意图。在上述图5所示实施例的基础上,本实施例的步骤530中,仪表代理根据从客户端接收到的指令和仪表抽象驱动中的仪表驱动功能接口,得到对应的仪表的工作状态信息或操作所述仪表,可以包括如下步骤,即步骤531~步骤532:Optionally, as shown in FIG. 8 , a schematic flowchart of a method for automatically controlling a meter according to an embodiment of the present invention is provided. On the basis of the foregoing embodiment shown in FIG. 5, in step 530 of the embodiment, the meter agent obtains the working status information of the corresponding meter according to the instruction received from the client and the instrument driving function interface in the instrument abstract driving. The operation of the meter may include the following steps, that is, steps 531 to 532:
步骤531,仪表代理将从客户端接收到的指令存入通信队列,当前连接的对应仪表的子进程解析该指令得到对应的仪表底层功能函数,根据仪表抽象驱动中的仪表驱动功能接口调用仪表底层功能函数;Step 531, the instrument agent stores the instruction received from the client into the communication queue, and the sub-process of the currently connected corresponding instrument parses the instruction to obtain the corresponding underlying function function of the instrument, and invokes the bottom layer of the instrument according to the instrument driving function interface in the instrument abstract driver. Function function
步骤532,仪表将返回的结果传递给子进程,该子进程将结果保存至接收 队列,仪表代理通过TCP连接将结果返回给客户端。In step 532, the meter passes the returned result to the child process, and the child process saves the result to the receiving. Queue, the instrument agent returns the result to the client over a TCP connection.
本实施例中,在仪表代理203的子进程与仪表保持连接的过程中,每隔一段自定义的时长,子进程会调用底层仪表状态扫描函数对仪表此时的实时状态进行读取,将得到的仪表状态结果存入队列或数据库中。其中,在每个仪表底层驱动201中定义有一个用于仪表状态扫描的API,所有仪表底层驱动201中的底层仪表状态扫描函数采用相同名称,相应的在仪表抽象驱动202中定义一个同名的API,用于调用仪表底层驱动201中的底层仪表状态扫描函数。In this embodiment, during the process in which the child process of the meter agent 203 is connected to the meter, the child process will call the underlying instrument state scan function to read the real-time status of the meter at a time interval of a custom time, and will obtain The status of the meter status is stored in the queue or database. An API for meter status scanning is defined in each meter bottom driver 201, and the underlying meter status scan function in all meter bottom drivers 201 has the same name, and an API of the same name is defined in the meter abstract driver 202 accordingly. Used to call the underlying instrument state scan function in the instrument underlying driver 201.
仪表代理203与仪表抽象驱动202之间是上下级的调用关系。仪表代理203负责生成和管理与客户端204连接的线程,以及与仪表206连接的子进程;每个子进程会调用仪表抽象驱动202给仪表206发送指令。The instrumentation agent 203 and the meter abstraction driver 202 are in a calling relationship between the upper and lower levels. Meter agent 203 is responsible for generating and managing threads that are connected to client 204, as well as child processes that are connected to meter 206; each child process invokes meter abstraction driver 202 to send instructions to meter 206.
启动仪表代理203之后,仪表代理203解析出配置文件或数据库中的所有仪表地址,采用多进程分别调用仪表抽象驱动202的仪表连接接口,其中每个子进程对应一个仪表地址,同时将该仪表地址作为本子进程调用仪表抽象驱动202的仪表连接接口的参数;仪表连接成功后,子进程不结束,保持与仪表的连接状态。每一个子进程对应一个仪表地址的含义是:以仪表的每组端口为单位生成一个子进程,这样就形成了{process-1:(仪表ip1,端口1),process-2:(仪表ip2,端口2)…}的对应关系。After the instrumentation agent 203 is started, the instrumentation agent 203 parses out all the instrument addresses in the configuration file or the database, and invokes the instrument connection interface of the instrument abstraction driver 202 by using multiple processes, wherein each sub-process corresponds to one instrument address, and the instrument address is used as the instrument address. The sub-process calls the parameter of the meter connection interface of the meter abstract driver 202; after the meter connection is successful, the child process does not end and maintains the connection state with the meter. The meaning of each instrument process corresponding to a meter address is: a sub-process is generated in units of each group of ports of the meter, thus forming {process-1: (meter ip1, port 1), process-2: (meter ip2, Correspondence between ports 2)...}.
在本发明的一个可选地实施例中,自动化控制仪表的方法过程可以包括:In an alternative embodiment of the present invention, the method of automatically controlling the meter may include:
接收到客户端204访问至少一个仪表206的访问请求,根据该访问请求启动,仪表代理203创建生成服务于客户端204的第一线程;Receiving an access request from the client 204 to access the at least one meter 206, according to the access request, the meter agent 203 creates a first thread that generates a service to the client 204;
启动仪表代理203,由该仪表代理203解析出至少一个仪表的仪表地址,生成至少一个子进程,在每一个子进程中根据每个所述仪表地址调用仪表抽象驱动202中对应的仪表连接接口,通过所调用的仪表连接接口与对应的仪表进行连接并维持连接状态;Starting the meter agent 203, the meter agent 203 parses out the meter address of the at least one meter, generates at least one child process, and invokes the corresponding meter connection interface in the meter abstraction driver 202 according to each of the meter addresses in each of the child processes. Connecting to the corresponding meter through the instrument connection interface invoked and maintaining the connection state;
通过该仪表连接接口向仪表发送指令,得到该仪表的工作状态信息或操作仪表。The meter connection interface sends an instruction to the meter to obtain the working status information or the operation meter of the meter.
在本实施例的一个应用场景中,仪表自动化控制系统可以接入多台仪表,并支持多个客户端对多台仪表分别进行控制,如图13所示,多个客户端连接 多台仪表的自动化控制系统中,该自动化控制仪表的方法过程可以包括:In an application scenario of the embodiment, the instrument automation control system can access multiple instruments, and supports multiple clients to separately control multiple instruments, as shown in FIG. 13, multiple client connections. In an automated control system of multiple meters, the method of automatically controlling the instrument may include:
步骤601,客户端204将仪表连接请求、需要连接的仪表的仪表地址传给仪表代理203,连接成功后,将指令发送给仪表代理203。In step 601, the client 204 transmits the meter connection request and the meter address of the meter to be connected to the meter agent 203. After the connection is successful, the command is sent to the meter agent 203.
步骤602,仪表代理203收到来自客户端的仪表连接请求和仪表地址后,将仪表地址作为参数调用仪表抽象驱动202中的仪表连接接口,当仪表连接接口返回成功后,说明已经与仪表之间建立连接;仪表代理203这时接收来自客户端的指令,解析出相应的仪表底层功能函数及其参数,然后调用仪表抽象驱动202中的同名仪表驱动功能接口,并传入解析出的参数。Step 602, after receiving the meter connection request and the meter address from the client, the meter agent 203 calls the meter connection interface in the meter abstraction driver 202 as a parameter. When the meter connection interface returns successfully, it indicates that the meter has been established with the meter. The instrument agent 203 receives the instruction from the client, parses the corresponding instrument underlying function and its parameters, and then invokes the instrument driver function interface of the same name in the instrument abstraction driver 202, and passes the parsed parameters.
步骤603,仪表抽象驱动202先轮循调用每个仪表底层驱动201中的底层连接函数,进行匹配。In step 603, the meter abstraction driver 202 firstly calls the underlying connection function in each instrument underlying driver 201 to perform matching.
步骤604,当匹配到正确的仪表底层驱动201之后,仪表抽象驱动202只需响应仪表代理203而调用仪表驱动功能接口,然后调用仪表底层驱动201中的同名底层连接函数,并传入来自仪表代理203的参数。Step 604, after matching the correct instrument underlay driver 201, the meter abstraction driver 202 only needs to respond to the meter agent 203 to invoke the meter driver function interface, and then invokes the underlying connection function of the same name in the instrument underlying driver 201, and passes the instrumentation agent from the instrument. 203 parameters.
步骤605,仪表底层驱动201执行相应的底层功能函数,底层功能函数调用相应的通讯接口(驱动)将相应的仪表指令发送给仪表,仪表收到指令后再返回查询结果或做出相应的动作。In step 605, the underlying driver 201 executes the corresponding underlying function, and the underlying function calls the corresponding communication interface (drive) to send the corresponding instrument instruction to the meter, and the instrument returns the query result or performs the corresponding action after receiving the instruction.
通过日志记录可以看到仪表自动化控制系统与仪表之间的指令交互,以及对仪表当前业务类型的扫描统计,实际运行超过24小时后将记录结果输出,输出结果例如为以下内容:Through the log record, you can see the instruction interaction between the instrument automation control system and the instrument, as well as the scan statistics of the current service type of the instrument. After the actual operation exceeds 24 hours, the result will be recorded. The output result is as follows:
Figure PCTCN2016087106-appb-000001
Figure PCTCN2016087106-appb-000001
Figure PCTCN2016087106-appb-000002
Figure PCTCN2016087106-appb-000002
如图9所示,为本发明实施例提供的一种自动化控制仪表的装置的结构示意图。本实施例提供的装置包括:FIG. 9 is a schematic structural diagram of an apparatus for automatically controlling a meter according to an embodiment of the present invention. The device provided in this embodiment includes:
客户端请求接收模块209,设置为:接收到客户端204访问至少一个仪表的访问请求,根据该访问请求启动仪表代理203;The client request receiving module 209 is configured to: receive an access request from the client 204 to access the at least one meter, and start the meter proxy 203 according to the access request;
仪表代理203,设置为:解析出客户端请求接收模块209接收到的至少一个仪表的仪表地址,根据每个所述仪表地址调用仪表抽象驱动202中对应的仪表连接接口,通过所调用的仪表连接接口与对应的仪表进行连接并维持连接 状态;The meter agent 203 is configured to: parse out the meter address of the at least one meter received by the client request receiving module 209, invoke the corresponding meter connection interface in the meter abstraction driver 202 according to each of the meter addresses, and connect through the called meter. The interface is connected to the corresponding meter and maintains the connection status;
该仪表代理203,还设置为:根据从客户端204接收的指令和所述仪表抽象驱动202中的仪表驱动功能接口,得到对应的仪表的工作状态信息或操作所述仪表。The meter agent 203 is further configured to: obtain the operating status information of the corresponding meter or operate the meter according to the instruction received from the client 204 and the meter driving function interface in the meter abstraction driver 202.
在本发明的一个可选地实施例中,仪表代理203中还支持调用,如图2所示,为本发明实施例提供的另一种自动化控制仪表的装置的结构示意图。本实施例提供的装置还可以包括:In an optional embodiment of the present invention, the instrument agent 203 also supports the call, as shown in FIG. 2, which is a schematic structural diagram of another device for automatically controlling the instrument provided by the embodiment of the present invention. The apparatus provided in this embodiment may further include:
开关矩阵207,设置为:将仪表连接到待测设备,其中,仪表代理203通过启动一个单独的线程或子进程开控制开关矩阵207实现仪表206与待测设备208之间的线路切换。The switch matrix 207 is configured to connect the meter to the device under test, wherein the meter agent 203 implements line switching between the meter 206 and the device under test 208 by activating a separate thread or sub-process open control switch matrix 207.
在本发明的一个可选地实施例中,如图2所示,本实施例提供的自动化控制仪表的装置还可以包括:In an optional embodiment of the present invention, as shown in FIG. 2, the apparatus for automatically controlling the meter provided by the embodiment may further include:
仪表底层驱动201,设置为:在每个仪表底层驱动201中定义一个底层仪表状态扫描函数,且每个仪表底层驱动201中的底层仪表状态扫描函数采用相同的名称;The underlying driver 201 of the meter is configured to: define an underlying instrument state scan function in each instrument underlayer driver 201, and use the same name for the underlying instrument state scan function in each instrument underlayer driver 201;
仪表抽象驱动202,设置为:在该仪表抽象驱动202中定义与底层仪表状态扫描函数名称相同的仪表状态扫描函数,该仪表状态扫描函数用于调用每个仪表底层驱动201中的底层仪表状态扫描函数。The meter abstraction driver 202 is configured to: define, in the meter abstraction driver 202, an instrument state scan function having the same name as the underlying instrument state scan function, the instrument state scan function for invoking the underlying instrument state scan in each instrument underlying driver 201 function.
在本发明的一个可选地实施例中,仪表抽象驱动202可以包括:In an alternative embodiment of the invention, the meter abstraction driver 202 can include:
仪表地址检测模块,设置为:指示仪表连接接口在判定了地址类型之后,调用相应的通讯协议库,轮循每个仪表底层驱动201中的底层连接函数;The instrument address detecting module is configured to: instruct the meter connection interface to call the corresponding communication protocol library after determining the address type, and to cycle through the underlying connection function in each instrument underlying driver 201;
当轮循到一个仪表底层驱动的底层连接函数返回成功时,轮循终止,仪表抽象驱动202记录下当前轮循到的仪表底层驱动201,此时,仪表连接接口返回成功;When the round-robin connection function of the underlying driver of the instrument is successfully returned, the round-robin is terminated, and the instrument abstraction driver 202 records the underlying driver 201 of the current round-robin. At this time, the instrument connection interface returns successfully;
当轮循所有仪表底层驱动201的底层连接函数都返回失败时,仪表连接接口返回失败。When the underlying connection function of all the underlying drivers 201 of the instrument returns to failure, the instrument connection interface returns a failure.
如图10所示,为本发明实施例提供的仪表自动化控制的装置中一种仪表代理的结构示意图。仪表代理203包括:仪表开关矩阵选择模块2031、仪表扫 描模块2032和仪表地址转发模块2034。FIG. 10 is a schematic structural diagram of an instrument agent in an apparatus for automatically controlling an instrument according to an embodiment of the present invention. The instrumentation agent 203 includes: an instrument switch matrix selection module 2031, an instrument sweep The module 2032 and the meter address forwarding module 2034 are depicted.
如图11所示,为本发明实施例提供的仪表自动化控制的装置中一种仪表开关矩阵选择模块的工作原理示意图。仪表开关矩阵选择模块2031,设置为:根据内部算法及表示输入、输出连接地址映射关系的开关矩阵线路映射表,控制开关矩阵207实现仪表206与待测设备208之间线路的自动切换。换言之,仪表开关矩阵选择模块2031在确定了设置仪表206与开关矩阵207之间的连接切换置为使能-即允许被切换之后,读取开关矩阵207的当前状态,查询开关矩阵线路映射表,将控制开关矩阵207进行线路切换的指令(选择的切换线路)发送给开关矩阵207,实现仪表206与待测设备208连接的自动切换,避免人工换线。FIG. 11 is a schematic diagram showing the working principle of an instrument switch matrix selection module in an apparatus for automatically controlling an instrument according to an embodiment of the present invention. The meter switch matrix selection module 2031 is configured to control the switch matrix 207 to automatically switch the line between the meter 206 and the device under test 208 according to an internal algorithm and a switch matrix line mapping table indicating input and output connection address mapping relationships. In other words, after the meter switch matrix selection module 2031 determines that the connection switch between the set meter 206 and the switch matrix 207 is enabled - that is, allows the switch to be switched, the current state of the switch matrix 207 is read, and the switch matrix line map is queried. The instruction to control the switch matrix 207 to perform line switching (the selected switching line) is sent to the switch matrix 207 to implement automatic switching of the connection between the meter 206 and the device under test 208 to avoid manual line change.
仪表扫描模块2032,设置为:判断仪表206的当前状态为“空闲”时,设置仪表206与开关矩阵207之间的连接切换为使能-即允许被切换。The meter scanning module 2032 is configured to: when the current state of the meter 206 is determined to be "idle", the connection between the setting meter 206 and the switch matrix 207 is switched to enable - that is, permission to be switched.
所有仪表地址写入在配置文件中,仪表代理203支持读取配置文件中的仪表地址。仪表地址转发模块2033,设置为:时刻等待接收来自客户端的新的仪表连接请求,调用仪表抽象驱动202中的仪表连接接口,并向该仪表连接接口传入仪表地址,与配置文件中所有仪表地址对应的仪表保持连接状态。All meter addresses are written in the configuration file, and the meter agent 203 supports reading the meter address in the configuration file. The meter address forwarding module 2033 is configured to: wait for receiving a new meter connection request from the client, invoke the meter connection interface in the meter abstraction driver 202, and input the meter address to the meter connection interface, and all the meter addresses in the configuration file. The corresponding meter remains connected.
如图12所示,为本发明实施例提供的仪表自动化控制的装置中一种仪表地址转发模块的工作原理示意图。仪表地址转发模块2033,由一个主线程负责系统资源的调配和管理,采用多线程方式与每个客户端建立一个套接字(socket)连接,采用多线程是结合考虑到客户端与仪表代理203之间的连接压力以及仪表代理203对指令的处理效率,客户端工作结束后,仪表地址转发模块2033会自动释放与该客户端之间的连接线程及socket连接资源;以及,保持与仪表206之间的连接不主动释放资源,即采用多进程是考虑到仪表代理203与仪表206之间会保持常连状态,如果采用多线程可能无法解决信息阻塞,而多进程能够实现效率最大化,与仪表206之间的连接包括但不限于以太网、串口和GPIB等。FIG. 12 is a schematic diagram showing the working principle of an instrument address forwarding module in an apparatus for automatically controlling an instrument according to an embodiment of the present invention. The instrument address forwarding module 2033 is responsible for the allocation and management of system resources by a main thread, and establishes a socket connection with each client in a multi-threaded manner, and adopts multi-threading in consideration of the client and the instrument agent 203. The connection pressure between the device and the processing efficiency of the instruction by the meter agent 203. After the client works, the meter address forwarding module 2033 automatically releases the connection thread and the socket connection resource with the client; and, maintains the meter 206 The connection between the two does not actively release the resources, that is, the multi-process is taken into consideration that the instrument agent 203 and the meter 206 will maintain a constant connection state. If multi-threading is used, the information blocking may not be solved, and the multi-process can achieve the maximum efficiency, and the instrument Connections between 206 include, but are not limited to, Ethernet, serial, and GPIB.
工作状态下,由仪表代理203中的仪表地址转发模块2033在仪表地址对应的连接子进程与客户端连接的子线程之间建立映射关系。客户端通过TCP给仪表地址转发模块2033传递指令,仪表地址转发模块2033将指令存入通信队 列,由连接着对应仪表的子进程获取指令,解析出指令中的仪表底层功能函数,并调用仪表抽象驱动202中的同名仪表驱动功能接口;仪表206返回的结果首先传递给仪表地址转发模块2033与该仪表之间的子进程,子进程将结果保存至接收队列,由连接对应客户端的子线程获取到,并通过TCP连接将结果返回给客户端204。In the working state, the meter address forwarding module 2033 in the meter agent 203 establishes a mapping relationship between the connection sub-process corresponding to the meter address and the child thread connected to the client. The client transmits an instruction to the meter address forwarding module 2033 via TCP, and the meter address forwarding module 2033 deposits the instruction into the communication team. The column is obtained by the sub-process connected to the corresponding instrument, parsing the underlying function function of the instrument in the instruction, and calling the instrument driving function interface of the same name in the instrument abstraction driver 202; the result returned by the meter 206 is first passed to the instrument address forwarding module 2033. With the child process between the meter, the child process saves the result to the receiving queue, is obtained by the child thread connecting the corresponding client, and returns the result to the client 204 through the TCP connection.
为了确保仪表地址转发模块2033与仪表206之间的连接正常,每个子进程都会定时向仪表206发送保活命令以确认仪表地址转发模块与仪表206之间的连接正常,保活命令可以值仪表206本身支持的最简单的指令。由于不同仪表206可以使用的保活命令不尽相同,将保活功能也封装进仪表底层驱动201中。In order to ensure that the connection between the meter address forwarding module 2033 and the meter 206 is normal, each child process periodically sends a keep-alive command to the meter 206 to confirm that the connection between the meter address forwarding module and the meter 206 is normal, and the keep-alive command can be a value 206. The simplest instruction supported by itself. Since the keep-alive commands that can be used by different meters 206 are not the same, the keep-alive function is also packaged into the instrument under-floor driver 201.
仪表扫描模块2032与仪表地址转发模块2033共用一套与仪表206之间的连接子进程。子进程除了调用仪表抽象驱动202,还会定时对仪表206进行扫描,判断仪表206当前是否正在被使用。判断依据依不同仪表206可能有所不同,需要将对应每款仪表206的扫描功能函数封装进各自的仪表底层驱动201中,并统一命名,供仪表扫描模块定时调用。有了扫描结果,可以对每台仪表206当前及一段时间内的使用率做出统计,也可以结合对开关矩阵207的控制,实现对空闲仪表与待测设备208之间的自动切换,大大提高仪表206的资源利用率。The meter scanning module 2032 shares a set of connection sub-processes with the meter 206 with the meter address forwarding module 2033. In addition to calling the meter abstraction driver 202, the child process also periodically scans the meter 206 to determine if the meter 206 is currently being used. The judgment basis may be different according to different meters 206, and the scan function of each meter 206 needs to be packaged into the respective instrument bottom layer driver 201, and uniformly named for the meter scanning module to call periodically. With the scan result, statistics can be made on the current and temporary usage rate of each meter 206, and the control of the switch matrix 207 can be combined to realize automatic switching between the idle meter and the device under test 208, which greatly improves Resource utilization of meter 206.
如图13所示,为本发明实施例提供的一种仪表的自动化控制系统的结构示意图。本实施例提供的自动化控制仪表的系统包括:FIG. 13 is a schematic structural diagram of an automatic control system for a meter according to an embodiment of the present invention. The system for automatically controlling the instrument provided in this embodiment includes:
客户端204,与仪表代理203连接,该客户端204设置为:运行脚本;The client 204 is connected to the meter agent 203, and the client 204 is configured to: run a script;
客户端请求接收模块209,设置为:接收到客户端204访问至少一个仪表206的访问请求,根据该访问请求启动仪表代理203;The client request receiving module 209 is configured to: receive an access request from the client 204 to access the at least one meter 206, and start the meter agent 203 according to the access request;
仪表代理203,设置为:解析出客户端请求接收模块209接收到的至少一个仪表的仪表地址,根据每个仪表地址调用仪表抽象驱动202中对应的仪表连接接口,通过所调用的仪表连接接口与对应的仪表206进行连接并维持连接状态;The metering agent 203 is configured to: parse out the meter address of the at least one meter received by the client request receiving module 209, and invoke the corresponding meter connection interface in the meter abstraction driver 202 according to each meter address, through the called meter connection interface and The corresponding meter 206 is connected and maintains the connection state;
该仪表代理203,还设置为:根据从客户端204接收到的指令和仪表抽象 驱动202中的仪表驱动功能接口,得到对应的仪表206的工作状态信息或操作所述仪表206;The meter agent 203 is further configured to: according to instructions and meter abstractions received from the client 204 Driving the instrument driver function interface in 202, obtaining the working status information of the corresponding meter 206 or operating the meter 206;
仪表206,设置为:通过通讯接口与仪表代理203的相连接。The meter 206 is configured to be connected to the meter agent 203 through a communication interface.
相关技术中已知的仪表自动化系统无法实现对仪表类型的自动识别以及仪表与仪表驱动之间的自动匹配,使用本发明实施例采用的技术方案的优势是:能够实现仪表底层驱动与所连接仪表之间的自动匹配;在与仪表连接过程中,系统能够定时扫描仪表的工作状态,并将结果返回给系统;仪表和待测设备之间接入开关矩阵,用户通过修改配置文件或下发相应指令就可以实现仪表与待测设备之间连接线路的自动切换。The instrument automation system known in the related art cannot realize the automatic identification of the instrument type and the automatic matching between the instrument and the instrument driver. The advantage of using the technical solution adopted by the embodiment of the present invention is that the instrument underlying driving and the connected instrument can be realized. Automatic matching between the two; in the process of connecting with the meter, the system can periodically scan the working state of the meter and return the result to the system; the switch matrix is connected between the meter and the device under test, and the user can modify the configuration file or issue the corresponding command. It is possible to automatically switch the connection line between the meter and the device under test.
本领域普通技术人员可以理解上述实施例的全部或部分步骤可以使用计算机程序流程来实现,所述计算机程序可以存储于一计算机可读存储介质中,所述计算机程序在相应的硬件平台上(根据系统、设备、装置、器件等)执行,在执行时,包括方法实施例的步骤之一或其组合。One of ordinary skill in the art will appreciate that all or a portion of the steps of the above-described embodiments can be implemented using a computer program flow, which can be stored in a computer readable storage medium on a corresponding hardware platform (according to The system, device, device, device, etc. are executed, and when executed, include one or a combination of the steps of the method embodiments.
可选地,上述实施例的全部或部分步骤也可以使用集成电路来实现,这些步骤可以被分别制作成一个个集成电路模块,或者将它们中的多个模块或步骤制作成单个集成电路模块来实现。Alternatively, all or part of the steps of the above embodiments may also be implemented by using an integrated circuit. These steps may be separately fabricated into individual integrated circuit modules, or multiple modules or steps may be fabricated into a single integrated circuit module. achieve.
上述实施例中的装置/功能模块/功能单元可以采用通用的计算装置来实现,它们可以集中在单个的计算装置上,也可以分布在多个计算装置所组成的网络上。The devices/function modules/functional units in the above embodiments may be implemented by a general-purpose computing device, which may be centralized on a single computing device or distributed over a network of multiple computing devices.
上述实施例中的装置/功能模块/功能单元以软件功能模块的形式实现并作为独立的产品销售或使用时,可以存储在一个计算机可读取存储介质中。上述提到的计算机可读取存储介质可以是只读存储器,磁盘或光盘等。When the device/function module/functional unit in the above embodiment is implemented in the form of a software function module and sold or used as a stand-alone product, it can be stored in a computer readable storage medium. The above mentioned computer readable storage medium may be a read only memory, a magnetic disk or an optical disk or the like.
工业实用性Industrial applicability
本发明实施例通过在仪表服务器上对接入的每台仪表进行扫描得到每台仪表的工作状态信息或者操作仪表,由于仪表抽象驱动及其封装的仪表连接接口消除了各个仪表底层驱动的差异,因此,本发明实施例提供的自动化控制仪表的技术方案在应用中,无需知道仪表的类型,只需要输入仪表地址就能够通过调用仪表抽象驱动实现对仪表的自动化控制。 In the embodiment of the present invention, the working status information or the operation instrument of each instrument is obtained by scanning each instrument connected to the instrument server, and the instrument abstraction driver and the packaged instrument connection interface thereof eliminate the difference of the underlying driving of each instrument. Therefore, the technical solution of the automatic control instrument provided by the embodiment of the invention does not need to know the type of the instrument in the application, and only needs to input the instrument address to realize automatic control of the instrument by calling the instrument abstract drive.

Claims (11)

  1. 一种自动化控制仪表的方法,包括:A method of automatically controlling a meter, comprising:
    接收到客户端访问至少一个仪表的访问请求,根据所述访问请求启动仪表代理;Receiving an access request of the client to access at least one meter, and starting the instrumentation agent according to the access request;
    所述仪表代理解析出所述至少一个仪表的仪表地址,根据每个所述仪表地址调用仪表抽象驱动中对应的仪表连接接口,通过所调用的仪表连接接口与对应的仪表进行连接并维持连接状态;The meter agent parses out the meter address of the at least one meter, invokes a corresponding meter connection interface in the meter abstract driver according to each of the meter addresses, and connects with the corresponding meter through the called meter connection interface to maintain the connection status. ;
    所述仪表代理根据从客户端接收到的指令和所述仪表抽象驱动中的仪表驱动功能接口,得到对应的仪表的工作状态信息或操作所述仪表。The meter agent obtains the working status information of the corresponding meter or operates the meter according to the instruction received from the client and the meter driving function interface in the meter abstract driving.
  2. 根据权利要求1所述的方法,其中,The method of claim 1 wherein
    采用开关矩阵将所述仪表连接到待测设备,所述仪表代理通过启动一个单独的线程或子进程来控制所述开关矩阵切换所述仪表与所述待测设备之间的线路。The meter is connected to the device under test using a switch matrix that controls the switch matrix to switch the line between the meter and the device under test by initiating a separate thread or sub-process.
  3. 根据权利要求1所述的方法,其中,所述接收到客户端访问至少一个仪表的访问请求之前,所述方法还包括:The method of claim 1, wherein the method further comprises: before receiving the access request of the client to access the at least one meter, the method further comprising:
    在每个仪表底层驱动中定义一个底层仪表状态扫描函数,且每个所述仪表底层驱动中的底层仪表状态扫描函数采用相同的名称;An underlying instrument state scan function is defined in each instrument underlying driver, and the underlying instrument state scan function in each of the instrument underlying drivers has the same name;
    在所述仪表抽象驱动中定义与所述底层仪表状态扫描函数名称相同的仪表状态扫描函数,所述仪表状态扫描函数用于调用每个所述仪表底层驱动中的底层仪表状态扫描函数。An instrument state scan function having the same name as the underlying meter state scan function is defined in the meter abstract driver, and the meter state scan function is used to call an underlying meter state scan function in each of the meter underlying drivers.
  4. 根据权利要求1所述的方法,其中,所述仪表代理根据每个所述仪表地址调用仪表抽象驱动中对应的仪表连接接口,通过所调用的仪表连接接口与对应的仪表进行连接并维持连接状态,包括:The method according to claim 1, wherein the meter agent invokes a corresponding meter connection interface in the meter abstract driver according to each of the meter addresses, and connects with the corresponding meter through the called meter connection interface to maintain the connection status. ,include:
    所述仪表代理调用所述仪表抽象驱动中的所述仪表连接接口,并向所述仪表连接接口传入所述仪表地址;The meter agent invokes the meter connection interface in the meter abstract driver, and transmits the meter address to the meter connection interface;
    所述仪表连接接口在判定所述仪表地址的地址类型之后,调用相应的通讯协议库,轮循每个仪表底层驱动中的底层连接函数; After determining the address type of the instrument address, the meter connection interface invokes a corresponding communication protocol library to cycle through the underlying connection function in each instrument underlying driver;
    当轮循到一个所述仪表底层驱动的底层连接函数返回成功时,轮循终止,所述仪表抽象驱动记录当前轮循到的仪表底层驱动,所述仪表连接接口返回成功;When the round-robin to the underlying connection function of the underlying driver of the meter returns successfully, the round-robin is terminated, and the meter abstraction drive records the underlying driver of the current round-robin, and the meter connection interface returns successfully;
    当轮循所有仪表底层驱动的底层连接函数都返回失败时,所述仪表连接接口返回失败。The instrument connection interface returns a failure when the underlying connection function that rotates all of the underlying drivers of the instrument returns a failure.
  5. 根据权利要求1所述的方法,其中,所述仪表代理根据从客户端接收到的指令和所述仪表抽象驱动中的仪表驱动功能接口,得到对应的仪表的工作状态信息或操作所述仪表,包括:The method according to claim 1, wherein the meter agent obtains the working status information of the corresponding meter or operates the meter according to the instruction received from the client and the meter driving function interface in the meter abstract driving. include:
    所述仪表代理将从所述客户端接收到的指令存入通信队列,当前连接的对应仪表的子进程解析所述指令得到对应的仪表底层功能函数,根据所述仪表抽象驱动中的仪表驱动功能接口调用所述仪表底层功能函数;The meter agent stores the instruction received from the client into the communication queue, and the sub-process of the currently connected corresponding meter parses the instruction to obtain a corresponding underlying function function of the meter, according to the instrument driving function in the instrument abstract driver The interface calls the underlying function of the meter;
    所述仪表将返回的结果传递给所述子进程,所述子进程将所述结果保存至接收队列,所述仪表代理通过传输控制协议TCP连接将所述结果返回给所述客户端。The meter passes the returned result to the child process, the child process saves the result to a receive queue, and the meter agent returns the result to the client via a Transmission Control Protocol TCP connection.
  6. 根据权利要求1所述的方法,其中,所述仪表代理根据从客户端接收到的指令和所述仪表抽象驱动中的仪表驱动功能接口,得到对应的仪表的工作状态信息或操作所述仪表,还包括:The method according to claim 1, wherein the meter agent obtains the working status information of the corresponding meter or operates the meter according to the instruction received from the client and the meter driving function interface in the meter abstract driving. Also includes:
    在所述仪表代理的子进程与所述仪表维持连接状态的过程中,每隔一段时长,所述子进程调用底层仪表状态扫描函数实时读取所述仪表的工作状态信息,并将得到的所述仪表的工作状态信息存入队列或数据库中。During the process of maintaining the connection state between the child process of the meter agent and the meter, the sub-process calls the underlying instrument state scan function to read the working state information of the meter in real time, and obtains the obtained information. The working status information of the meter is stored in the queue or database.
  7. 一种自动化控制仪表的装置,包括:An apparatus for automatically controlling a meter, comprising:
    客户端请求接收模块,设置为:接收到客户端访问至少一个仪表的访问请求,根据所述访问请求启动仪表代理;The client request receiving module is configured to: receive an access request of the client to access the at least one meter, and start the meter proxy according to the access request;
    仪表代理,设置为:解析出所述客户端请求接收模块接收到的所述至少一个仪表的仪表地址,根据每个所述仪表地址调用仪表抽象驱动中对应的仪表连接接口,通过所调用的仪表连接接口与对应的仪表进行连接并维持连接状态;The meter agent is configured to: parse out the meter address of the at least one meter received by the client request receiving module, and invoke a corresponding meter connection interface in the meter abstract driver according to each of the meter addresses, by using the called meter The connection interface is connected with the corresponding meter and maintains the connection state;
    所述仪表代理,还设置为:根据从客户端接收到的指令和所述仪表抽象 驱动中的仪表驱动功能接口,得到对应的仪表的工作状态信息或操作所述仪表。The meter agent is further configured to: according to the instruction received from the client and the instrument abstraction The instrument drive function interface in the drive obtains the working status information of the corresponding meter or operates the meter.
  8. 根据权利要求7所述的装置,还包括:The apparatus of claim 7 further comprising:
    开关矩阵,设置为:将所述仪表连接到待测设备,所述仪表代理通过启动一个单独的线程或子进程来控制所述开关矩阵切换所述仪表与所述待测设备之间的线路。A switch matrix is configured to: connect the meter to a device under test, and the meter agent controls the switch matrix to switch a line between the meter and the device under test by initiating a separate thread or sub-process.
  9. 根据权利要求7所述的装置,还包括:The apparatus of claim 7 further comprising:
    仪表底层驱动,设置为:在每个仪表底层驱动中定义一个底层仪表状态扫描函数,且每个所述仪表底层驱动中的底层仪表状态扫描函数采用相同的名称;The underlying driver of the instrument is set to: define an underlying instrument state scanning function in each instrument underlying driver, and the underlying instrument state scanning function in each of the instrument underlying drivers adopts the same name;
    仪表抽象驱动,设置为:在所述仪表抽象驱动中定义与所述底层仪表状态扫描函数名称相同的仪表状态扫描函数,所述仪表状态扫描函数用于调用每个所述仪表底层驱动中的底层仪表状态扫描函数。An instrument abstraction driver is configured to: define, in the meter abstract driver, an instrument state scan function having the same name as the underlying meter state scan function, the gauge state scan function for calling the bottom layer of each of the instrument underlying drivers Instrument status scan function.
  10. 根据权利要求9所述的装置,其中,所述仪表代理包括:The apparatus of claim 9 wherein said meter agent comprises:
    仪表地址转发模块,设置为:调用所述仪表抽象驱动中的所述仪表连接接口,并向所述仪表连接接口传入所述仪表地址;The meter address forwarding module is configured to: invoke the meter connection interface in the meter abstract driver, and transmit the meter address to the meter connection interface;
    所述仪表抽象驱动包括:The instrument abstract driver includes:
    仪表地址检测模块,设置为:指示所述仪表连接接口在判定了地址类型之后,调用相应的通讯协议库,轮循每个仪表底层驱动中的底层连接函数;The instrument address detecting module is configured to: instruct the meter connection interface to call the corresponding communication protocol library after determining the address type, and to cycle through the bottom layer connection function in each instrument underlying driver;
    当轮循到一个所述仪表底层驱动的底层连接函数返回成功时,轮循终止,所述仪表抽象驱动记录当前轮循到的仪表底层驱动,所述仪表连接接口返回成功;When the round-robin to the underlying connection function of the underlying driver of the meter returns successfully, the round-robin is terminated, and the meter abstraction drive records the underlying driver of the current round-robin, and the meter connection interface returns successfully;
    当轮循所有仪表底层驱动的底层连接函数都返回失败时,所述仪表连接接口返回失败。The instrument connection interface returns a failure when the underlying connection function that rotates all of the underlying drivers of the instrument returns a failure.
  11. 一种自动化控制仪表的系统,包括:A system for automatically controlling instruments, including:
    客户端,与仪表代理连接,所述客户端设置为:运行脚本;a client, connected to the meter agent, the client is set to: run a script;
    客户端请求接收模块,设置为:接收到客户端访问至少一个仪表的访问 请求,根据所述访问请求启动所述仪表代理;The client requests the receiving module, and is set to: receive the access of the client to access at least one meter Requesting, starting the meter agent according to the access request;
    所述仪表代理,设置为:解析出所述客户端请求接收模块接收到的所述至少一个仪表的仪表地址,根据每个所述仪表地址调用仪表抽象驱动中对应的仪表连接接口,通过所调用的仪表连接接口与对应的仪表进行连接并维持连接状态;The meter agent is configured to: parse out a meter address of the at least one meter received by the client request receiving module, and invoke a corresponding meter connection interface in the meter abstract driver according to each of the meter addresses, by calling The instrument connection interface is connected with the corresponding instrument and maintains the connection state;
    所述仪表代理,还设置为:根据从客户端接收到的指令和所述仪表抽象驱动中的仪表驱动功能接口,得到对应的仪表的工作状态信息或操作所述仪表;The meter agent is further configured to: obtain an operation status information of the corresponding meter or operate the meter according to an instruction received from the client and an instrument driving function interface in the instrument abstract driving;
    仪表,设置为:通过通讯接口与所述仪表代理相连接。 The meter is set to be connected to the instrument agent through a communication interface.
PCT/CN2016/087106 2015-06-30 2016-06-24 Method, device and system for controlling instrument automatically WO2017000844A1 (en)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201510372245.1 2015-06-30
CN201510372245.1A CN106325117B (en) 2015-06-30 2015-06-30 Method, device and system for automatically controlling instrument

Publications (1)

Publication Number Publication Date
WO2017000844A1 true WO2017000844A1 (en) 2017-01-05

Family

ID=57607804

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2016/087106 WO2017000844A1 (en) 2015-06-30 2016-06-24 Method, device and system for controlling instrument automatically

Country Status (2)

Country Link
CN (1) CN106325117B (en)
WO (1) WO2017000844A1 (en)

Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH07253899A (en) * 1994-03-16 1995-10-03 Pfu Ltd Test processing system
US20020116507A1 (en) * 2001-02-20 2002-08-22 Manjure Samir B. Distributed testing of an implementation of a remote access protocol
CN1722663A (en) * 2004-07-13 2006-01-18 联想(北京)有限公司 A proxy server system and method for realizing proxy communication thereof
CN102158370A (en) * 2011-04-12 2011-08-17 瑞斯康达科技发展股份有限公司 Automated testing method and system
CN102769665A (en) * 2012-06-28 2012-11-07 大唐移动通信设备有限公司 Radio frequency test instrument sharing system and application method thereof
US20130036156A1 (en) * 2011-08-03 2013-02-07 Mariela Todorova Automated framework for testing enterprise services consumer technologies
CN203117722U (en) * 2013-03-22 2013-08-07 北京经纬恒润科技有限公司 Line switching device and system
US20140032638A1 (en) * 2012-07-25 2014-01-30 Lg Cns Co., Ltd. Automated testing environment

Family Cites Families (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN101247292B (en) * 2008-02-22 2011-08-10 中兴通讯股份有限公司 Test equipment and method based on universal test meter API
CN203574669U (en) * 2013-10-18 2014-04-30 工业和信息化部电信传输研究所 Terminal consistency test system and API interface universal adapter for system
CN104270289A (en) * 2014-10-17 2015-01-07 上海斐讯数据通信技术有限公司 ONU automatic testing method based on TCL script

Patent Citations (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
JPH07253899A (en) * 1994-03-16 1995-10-03 Pfu Ltd Test processing system
US20020116507A1 (en) * 2001-02-20 2002-08-22 Manjure Samir B. Distributed testing of an implementation of a remote access protocol
CN1722663A (en) * 2004-07-13 2006-01-18 联想(北京)有限公司 A proxy server system and method for realizing proxy communication thereof
CN102158370A (en) * 2011-04-12 2011-08-17 瑞斯康达科技发展股份有限公司 Automated testing method and system
US20130036156A1 (en) * 2011-08-03 2013-02-07 Mariela Todorova Automated framework for testing enterprise services consumer technologies
CN102769665A (en) * 2012-06-28 2012-11-07 大唐移动通信设备有限公司 Radio frequency test instrument sharing system and application method thereof
US20140032638A1 (en) * 2012-07-25 2014-01-30 Lg Cns Co., Ltd. Automated testing environment
CN203117722U (en) * 2013-03-22 2013-08-07 北京经纬恒润科技有限公司 Line switching device and system

Also Published As

Publication number Publication date
CN106325117A (en) 2017-01-11
CN106325117B (en) 2020-04-10

Similar Documents

Publication Publication Date Title
CN110430100B (en) Network connectivity detection method and device
CN111542064B (en) Container arrangement management system and arrangement method for wireless access network
US6993683B2 (en) Analysis of pipelined networks
US7657789B1 (en) Multi-machine testing system and method for testing software
CN1747472A (en) Universal embedded marker and marking method based on CCP
CN107241315B (en) Access method and device of bank gateway interface and computer readable storage medium
US20140196029A1 (en) Scripting language executor service for applications
CN110677383B (en) Firewall wall opening method and device, storage medium and computer equipment
CN104639385B (en) Detect the method and apparatus of L2VPN network user's side interface connectivity
CN112243032B (en) Service calling method and system based on access gateway
US20080028034A1 (en) Method for mapping an iscsi target name to a storage resource based on an initiator hardware class identifier
CN108881111A (en) A kind of method and device for realizing multi-tenant system
CN113672441B (en) Method and device for testing intelligent equipment
US20130160006A1 (en) Apparatus and method for controlling sensor data in cloud system
CN108804313A (en) A kind of method, apparatus and server of remote debugging program
CN102291274A (en) System and method for realizing automatic adaptation of network testing instrument
US20240036909A1 (en) Method, system, and device for modifying internal configuration of virtual machine
US9386010B2 (en) Abstracted authenticated client connectivity application programming interface (API)
US7996524B2 (en) Controlling external communication of embedded device using proxy server
CN106559236B (en) Equipment resource management method and device of service board, main control board and frame type equipment
KR20070052641A (en) Robot server, content providing system and method comprising the same
US7865880B2 (en) System and/or method for implementing efficient techniques for testing common information model providers
WO2017000844A1 (en) Method, device and system for controlling instrument automatically
CN117041111A (en) Vehicle cloud function test method and device, electronic equipment and storage medium
CN110022332B (en) Hypertext transfer security protocol proxy method, device, equipment and medium

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 16817208

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

122 Ep: pct application non-entry in european phase

Ref document number: 16817208

Country of ref document: EP

Kind code of ref document: A1