Summary of the invention
The technical problem to be solved in the present invention is: a kind of automated terminal test emulation mode and analogue system are provided, support telnet, sshv2, serial ports, GPIB working method, and support multiple terminals to work simultaneously.
The present invention solves the problems of the technologies described above taked technical scheme to be: a kind of automated terminal test emulation mode, is characterized in that: it comprises the following steps:
Step 1, initialization:
In man-machine interface software for display correlation behavior, man-machine interface comprises tree control and tab control; Start tcp service and safeguard thread: use any terminal emulation instrument to utilize telnet agreement to be connected to designated port, and utility command line mode monitoring software running status; Start version information exchange threads: software self Release parameter is passed to this thread, in local area network (LAN), broadcast own software version, and monitor designated port, judge whether software version exists renewal, and prompting is upgraded;
Step 2, receive user and operate and start counterpart terminal thread:
2.1, open file: according to user's operation, open a test profile, according to its content, generate configuration tree, and show in the tree control of man-machine interface;
2.2, bring into operation: recurrence traversal configuration tree, skip and complete node, for moving node, start to dialog box thread and terminal thread that should node, when the node moving has moved, recurrence traversal configuration tree, has moved until finally configure whole nodes of tree again;
Step 3, out of service: when there is operating node, to dialog box thread corresponding to the node moving with and tag wire journey send halt instruction, out of service;
Step 4, exit: when do not moving node time, to each thread and each control, send exit instruction, and wait for that terminal procedure completes, and closes man-machine interface;
In described step 2, the terminal thread of each node is parallel thread, and the operating procedure of each terminal thread is:
First complete the initialization of the communication layers corresponding with it, the communication layers that each terminal thread is corresponding is a kind of in tcp communication layers, gpib communication layers or com communication layers; Tcp communication layers is for setting up and closing tcp and is connected, and sending and receiving tcp link information, support telnet and sshv2 mode; Gpib communication layers is for setting up and closing gpib and be connected, and sending and receiving gpib link information; Com communication layers is used for opening and closing serial ports and connects, and read and write serial port information; Next open the corresponding terminal leg presents of this node, and the message of transmitting terminal operation;
Then enter message circulation, circulation is read message and is processed: when type of message is terminal operating message, a line of reading terminals script file, judge that this row type is that terminal issues or up embedded command, if carrying out respective handling, up embedded command judges or hold function to complete, and shown by the tab control of man-machine interface, if issuing, terminal is issued to target device by corresponding communication layers; In the behavior of terminal leg presents inspection message queue, have while there is no needed message, suspend this terminal to being issued to the processing of target device, and at set intervals cyclic query once, until other terminal is proceeded to issue when main frame has sent this message and be stored in terminal message queue; When the type of message of message circulation is exit instruction, out of service and exit.
An automated terminal test analogue system, is characterized in that: it comprises that main thread module, tcp service safeguard thread module, version information exchange threads module and terminal thread module;
Described main thread module is used for receiving user's operation, and starts other module of control; It comprises initialization module, opens module, moves module, stopping modular and exit module; Initialization module is used in man-machine interface software for display correlation behavior, and man-machine interface comprises tree control and tab control, starts respectively tcp service and safeguards thread module and version information exchange threads module; Open module for opening a test profile according to user's operation, according to its content, generate configuration tree, and show in the tree control of man-machine interface; Operation module is for recurrence traversal configuration tree, skip and complete node, for moving node, start to dialog box thread and terminal thread that should node, when the node moving has moved, recurrence traversal configuration tree, has moved until finally configure whole nodes of tree again; For when there is operating node in stopping modular, to dialog box thread corresponding to the node moving with and tag wire journey send halt instruction, out of service; While exiting module for node when not moving, to each thread and each control, send exit instruction, and wait for that terminal procedure completes, and closes man-machine interface;
Tcp service safeguards that thread module is for using any terminal emulation instrument to utilize telnet agreement to be connected to designated port, and supports utility command line mode monitoring software running status;
Version information exchange threads module, for software self Release parameter is passed to this thread, is broadcasted own software version, and is monitored designated port in local area network (LAN), judges whether software version exists renewal, and prompting is upgraded;
Terminal thread module is a plurality of parallel modules, and each terminal thread module comprises respectively communication layers initialization module and message loop module; Communication layers initialization module has been used for the initialization of the communication layers corresponding with it, and the communication layers that each terminal thread is corresponding is a kind of in tcp communication layers, gpib communication layers or com communication layers; Tcp communication layers is for setting up and closing tcp and is connected, and sending and receiving tcp link information, support telnet and sshv2 mode; Gpib communication layers is for setting up and closing gpib and be connected, and sending and receiving gpib link information; Com communication layers is used for opening and closing serial ports and connects, and read and write serial port information, and opens the corresponding terminal leg presents of this node, the message of transmitting terminal operation; Message loop module reads message and processes for circulation: when type of message is terminal operating message, a line of reading terminals script file, judge that this row type is that terminal issues or up embedded command, if carrying out respective handling, up embedded command judges or hold function to complete, and transfer to the tab control of man-machine interface to show, if issuing, terminal is issued to target device by corresponding communication layers; In the behavior of terminal leg presents inspection message queue, have while there is no needed message, suspend this terminal to being issued to the processing of target device, and at set intervals cyclic query once, until other terminal is proceeded to issue when main frame has sent this message and be stored in terminal message queue; When the type of message of message circulation is exit instruction, out of service and exit.
Beneficial effect of the present invention is: the inventive method and system are supported telnet, sshv2, serial ports and GPIB working method, support multiple terminals to work simultaneously, and each terminal thread moves a separate threads, they adopt message circulation pattern separately, when terminal leg presents type does not have needed message for terminal issues in main frame, suspend and be issued to target device, cyclic query once at set intervals, until other terminal proceeds to issue when main frame has sent this message, can collaborative work between the thread of multiple terminals thereby make.
Embodiment
Below in conjunction with instantiation, the present invention will be further described.
Fig. 1 is the FB(flow block) of one embodiment of the invention, and it comprises the following steps:
Step 1, initialization:
In man-machine interface (UI) software for display correlation behavior, man-machine interface comprises tree control and tab control; Start tcp service and safeguard thread: use any terminal emulation instrument to utilize telnet agreement to be connected to designated port, and utility command line mode monitoring software running status; Start version information exchange threads: software self Release parameter is passed to this thread, in local area network (LAN), broadcast own software version, and monitor designated port, judge whether software version exists renewal, and prompting is upgraded;
Step 2, receive user and operate and start counterpart terminal thread:
2.1, open file: according to user's operation, open a test profile, according to its content, generate configuration tree, and show in the tree control of man-machine interface;
2.2, bring into operation: recurrence traversal configuration tree, skip and complete node, for moving node, start to dialog box thread and terminal thread that should node, when the node moving has moved, recurrence traversal configuration tree, has moved until finally configure whole nodes of tree again;
Step 3, out of service: when there is operating node, to dialog box thread corresponding to the node moving with and tag wire journey send halt instruction, out of service;
Step 4, exit: when do not moving node time, to each thread and each control, send exit instruction, and wait for that terminal procedure completes, and closes man-machine interface;
In described step 2, the terminal thread of each node is parallel thread, the operating procedure of each terminal thread as shown in Figure 6, for:
First complete the initialization of the communication layers corresponding with it, the communication layers that each terminal thread is corresponding is a kind of in tcp communication layers, gpib communication layers or com communication layers; Tcp communication layers is for setting up and closing tcp and is connected, and sending and receiving tcp link information, support telnet and sshv2 mode; Gpib communication layers is for setting up and closing gpib and be connected, and sending and receiving gpib link information; Com communication layers is used for opening and closing serial ports and connects, and read and write serial port information; Next open the corresponding terminal leg presents of this node, and the message of transmitting terminal operation;
Then enter message circulation, circulation is read message and is processed: when type of message is terminal operating message, a line of reading terminals script file, judge that this row type is that terminal issues or up embedded command, if carrying out respective handling, up embedded command judges or hold function to complete, and transfer to the tab control of man-machine interface to show, if issuing, terminal is issued to target device by corresponding communication layers; In the behavior of terminal leg presents inspection message queue, have while there is no needed message, suspend this terminal to being issued to the processing of target device, and at set intervals cyclic query once, until other terminal is proceeded to issue when main frame has sent this message and be stored in terminal message queue; When the type of message of message circulation is exit instruction, out of service and exit.
As shown in Figure 2, man-machine interface is software for display correlation behavior first, and interface description is as follows: 1) menu bar: menu operation is provided; 2) toolbar: conventional menu operation is provided, comprises and open configuration file, start/suspend/finish to move help menu; 3) status bar: version of display state; 4) Tree control: the test configurations tree generating according to test profile, shows each test module; 5) tab control: according to current test run situation, the one or more tab pages of Dynamic Establishing and corresponding dialog control, and show its terminal interaction content; 6) list control: show running log.After interface display module completes, start to start tcp service and safeguard thread, this thread by and UI main thread between message transmit, complete the supervision to software operation state, its flow process details is safeguarded in thread flow process and is illustrated in tcp service.After tcp service safeguards that thread has started, start to start version information exchange threads, and software self Release parameter is passed to this thread, this thread is mainly the prompt facility of realizing redaction.
After version information exchange threads completes, initialization all completes, software starts to enter the circulation of UI main thread message, by user, operate and send corresponding message, enter corresponding operational process, its main operating instruction is as follows: 1) open file: open a test profile, generate configuration tree structure, and show in the tree control at interface according to its content.2) bring into operation: recurrence traversal configuration tree, skip and complete node, for moving node, start dialog box thread and tab control new page that should node.When the node moving has moved, recurrence traversal configuration tree, has moved until finally configure whole nodes of tree again.Detailed process is shown in Fig. 3.3) out of service: to the corresponding dialog box thread of all nodes that moving, to send WM_QUIT message.Detailed process is shown in Fig. 3.4) help: show help document.5) exit: to each thread and each control, send WM_QUIT message, wait for that terminal procedure completes, close interface, quit a program.
Fig. 4 is the FB(flow block) that thread is safeguarded in tcp service, main process description: initialization tcp socket completes 60013 port initialization listening states, then Xiang Ben thread message queue sends WM_tcpserveraccept message, and this message represents that 60013 ports do not receive connection request; Next enter message circulation, because message queue takes out WM_tcpserveraccept message, so continue to monitor 60013 ports, whether receive connection request, if, again do not send WM_tcpserveraccept message, if receive connection request, the tcp that sets up 60013 ports connects, send WM_tcpserverconnect message, this message represents that 60013 ports receive and connect; When message queue takes out WM_tcpserverconnect message, process the order that this connection is imported into, if being this, this order connects the finish command, close this connection, send WM_tcpserveraccept Messages-Waiting connects next time, if not connecting the finish command, after this order of finishing dealing with, send WM_tcpserverconnect message, wait for the order that next this connection is imported into; If WM_QUIT message is taken out in message circulation, represent that UI interface thread has started to exit operation, close and connect and socket, finish this thread.
Fig. 5 is the FB(flow block) of version information exchange threads, process description:
Initialization udp socket completes 60014 port initialization states, then to this port, sends the udp broadcasting packet that comprises self software version information, and sends WM_udprx message, and this message represents to prepare to receive data from udp; Next enter message circulation, if WM_udprx message is taken out in message circulation, the version information in resolution data, just be greater than self version in the prompting of UI status bar, if just data are invalid or be not more than self version and again send WM_udprx message; If WM_QUIT message is taken out in message circulation, represent that UI interface thread has started to exit operation, close and connect and socket, finish this thread.
Fig. 6 is the FB(flow block) of terminal thread, process description: initialize communications mode completes the initialization of different communication layer, sends WM_trmthreadrun message, and this message represents that tag wire journey is in service; Next enter message circulation, if WM_trmthreadrun message is taken out in message circulation, resolve and processing scripts content, some script command primitive that wherein step " processing of script command primitive " comprises formulation are processed, and comprise that the message queue of controlling multiple terminals cross-thread collaborative work is processed and (referring to script command primitive, process main flow process, as shown in Figure 7 and Figure 8); If WM_QUIT message is taken out in message circulation, represent that UI interface thread has started to exit operation, close and connect and socket, to UI thread, send WM_appdlgtrmdlgclose message, finish this thread.
As shown in Figure 7 and Figure 8, script command primitive is processed main flow process and is described as follows: because distribution under terminal was processed before this flow process, so enter this flow process, be all that the script that comprises script command primitive is capable; Then in this flow process, process, and judgement yes or no, for calling below.Here specify that information order processing needs cross-thread, its mechanism is to safeguard a terminal message queue at UI thread, each terminal thread is when processing messages order, be all finally access terminal message queue, therefore realize the cross-thread of each terminal and control, for example: terminal thread a and terminal thread b are parallel, when terminal thread a runs to 10 seconds, to check message " msg1 ", and now terminal message queue does not comprise this message, so thread a circular test message " msg1 ".When terminal thread b runs to 30 seconds, by interpolation message " msg1 ", now terminal message queue will comprise this message.In the circulation of terminal thread a after 30 seconds, check message " msg1 " success, then continue next line script and process.Therefore the effect of institute's describing message " msg1 " is above: terminal thread b controls for the execution of terminal thread a, makes it to have postponed after carrying out 10 seconds within 20 seconds, to continue to carry out again.
The present invention also provides a kind of automated terminal test analogue system, and it comprises that main thread module, tcp service safeguard thread module, version information exchange threads module and terminal thread module;
Described main thread module is used for receiving user's operation, and starts other module of control; It comprises initialization module, opens module, moves module, stopping modular and exit module; Initialization module is used in man-machine interface software for display correlation behavior, and man-machine interface comprises tree control and tab control, starts respectively tcp service and safeguards thread module and version information exchange threads module; Open module for opening a test profile according to user's operation, according to its content, generate configuration tree, and show in the tree control of man-machine interface; Operation module is for recurrence traversal configuration tree, skip and complete node, for moving node, start to dialog box thread and terminal thread that should node, when the node moving has moved, recurrence traversal configuration tree, has moved until finally configure whole nodes of tree again; For when there is operating node in stopping modular, to dialog box thread corresponding to the node moving with and tag wire journey send halt instruction, out of service; While exiting module for node when not moving, to each thread and each control, send exit instruction, and wait for that terminal procedure completes, and closes man-machine interface;
Tcp service safeguards that thread module is for using any terminal emulation instrument to utilize telnet agreement to be connected to designated port, and supports utility command line mode monitoring software running status;
Version information exchange threads module, for software self Release parameter is passed to this thread, is broadcasted own software version, and is monitored designated port in local area network (LAN), judges whether software version exists renewal, and prompting is upgraded;
Terminal thread module is a plurality of parallel modules, and each terminal thread module comprises respectively communication layers initialization module and message loop module; Communication layers initialization module has been used for the initialization of the communication layers corresponding with it, and the communication layers that each terminal thread is corresponding is a kind of in tcp communication layers, gpib communication layers or com communication layers; Tcp communication layers is for setting up and closing tcp and is connected, and sending and receiving tcp link information, support telnet and sshv2 mode; Gpib communication layers is for setting up and closing gpib and be connected, and sending and receiving gpib link information; Com communication layers is used for opening and closing serial ports and connects, and read and write serial port information, and opens the corresponding terminal leg presents of this node, the message of transmitting terminal operation; Message loop module reads message and processes for circulation: when type of message is terminal operating message, a line of reading terminals script file, judge that this row type is that terminal issues or up embedded command, if carrying out respective handling, up embedded command judges or hold function to complete, and transfer to the tab control of man-machine interface to show, if issuing, terminal is issued to target device by corresponding communication layers; In the behavior of terminal leg presents inspection message queue, have while there is no needed message, suspend this terminal to being issued to the processing of target device, and at set intervals cyclic query once, until other terminal is proceeded to issue when main frame has sent this message and be stored in terminal message queue; When the type of message of message circulation is exit instruction, out of service and exit.