“To realize the application of virtual instrument on the network platform, data sharing between different applications must be realized. Although TCP/IP, DDE and other technologies support data sharing between different applications, they cannot be used to transmit dynamic data. The DataSocket provided by NI is specially used to transmit and publish dynamic data. It is an industrial technology based on TCP/IP. The standard online real-time high-speed data exchange programming technology highly encapsulates the bottom layer. When transferring data between different applications, it is not necessary to write specific program codes for different data formats and communication protocols, which simplifies the programming of online measurement and control data. .
Authors: Li Shuifang, Zhu Rongxin, Yao Qicang
In a large and complex test system, data collection, input, output and analysis and processing are often distributed in different geographical locations. Traditional integration testing methods are increasingly unable to meet the needs of complex testing tasks. Therefore, the emergence of networked instruments becomes inevitable. With the continuous development of computer network technology, bus technology and database technology, the Internet has brought data sharing into a new stage and accelerated the development of virtual instruments in network and remote computing technology. With the help of the powerful functions of the Internet, the virtual instrument technology directly publishes the data from the measurement or control equipment to the Web page, and connects different equipment scattered in different locations to form a test system, so that the resources can be shared.
1 Networked virtual instrument
Virtual instrument technology perfectly combines computer technology and instrument technology, and networked virtual instrument is a new technology that combines virtual instrument technology and Internet-oriented Web technology. To put it simply, the virtual instrument transplants the front panel of the traditional instrument to the computer, and uses the resources on the computer for testing, while the networked virtual instrument transplants the front panel to the Internet, and remotely controls the on-site test instruments and equipment through a web browser. Objects, test results and measurement data can be released and shared in real time through the Internet, breaking the traditional mode of collecting, analyzing and displaying in the same place, enhancing the ability of division of labor and cooperation, and greatly improving work efficiency. The structure diagram of the networked virtual instrument is shown in Figure 1.
2 DataSocket technology
To realize the application of virtual instrument on the network platform, data sharing between different applications must be realized. Although TCP/IP, DDE and other technologies support data sharing between different applications, they cannot be used to transmit dynamic data. The DataSocket provided by NI is specially used to transmit and publish dynamic data. It is an industrial technology based on TCP/IP. The standard online real-time high-speed data exchange programming technology highly encapsulates the bottom layer. When transferring data between different applications, it is not necessary to write specific program codes for different data formats and communication protocols, which simplifies the programming of online measurement and control data. . Figure 2 is the architecture diagram of DataSocket.
DataSocket consists of DataSocket API and DataSocket Server. DataSocket API is an application program interface independent of protocol, programming language and operating system, which can convert measurement data into a data stream suitable for transmission on the network. It includes 4 basic actions: open, read, write, close, which can be accessed from The following 5 places to get data:
(1) Data items on HTTP servers
(2) Data items on FTP servers
(3) Local files
(4) Data items on OLE for Process Control
(5) Data items on DSTP servers
DataSocket Server is an independent part that can transmit field data to remote clients at high speed. Publishing data with DataSocket Server requires three parts: publisher (publisher), server (DataSocket Server), and receiver (subscriber). The relationship between the three is shown in Figure 3. The publisher writes data into the DataSocket Server through the DataSocket API, and the receiver reads the data from the DataSocket Server through the DataSocket API. There is timeliness between the publisher and the receiver. The receiver can only read the data sent by the publisher after the information runs, and this data can be read multiple times. DataSocket Server Manager defines the maximum number of connections, the maximum number of data objects, and specifies the data access rights, that is, which computers can be used as publishers and which computers can be used as receivers. These three parts may exist in one device, but most of them are distributed in different devices, which is conducive to improving system performance and improving security.
DataSocket locates data source and target through URL (Uniform Resource Locator). URI. The different prefixes indicate different data types: file is a local file, http is a hypertext transfer protocol, dstp indicates real-time data from the DataSocket server, ftp is a file transfer protocol, and opc indicates that the accessed resource is OPC. Here are a few URLs that qualify:
3 Application examples
Now give an example to use DataSocket technology to realize the detection of networked virtual instruments. A company provides photocopier maintenance services. There are maintenance offices in various places. Each maintenance office sends the photocopier information and model back to the headquarters. After the headquarters analyzes and diagnoses, the diagnosis results are sent to the maintenance office for maintenance personnel to repair. The whole working process is as follows: First, put all the diagnostic programs in the DataSocket Server of the system, and the LabWindows/CVI application program is connected with the photocopier through the serial port and the data acquisition board to obtain the relevant information of the photocopier, and send the information through the DataSocket API. To the DataSocket Server, the system central program reads the DataSocket Server through the DataSocket API to obtain the relevant information and model of the photocopier, judges which diagnostic program to call, and then detects the management program to run the diagnostic program and write the diagnostic results to the DataSocket Server, LabWindows/CVI The application reads the diagnostic result from the DataSocket Server, and the service technician can use the diagnostic result to repair the photocopier. The following is part of the source code of LabWindows/CVI to realize the open, read and close operations of DataSocket:
int CVICALLBACK connect(int panel, int control, int event, void*callbackData, int eventData!, int eventData2)
DSConst_ReadAutoUpdate, datahandle, DS_callback_NULL);
Void DS_callback_read(DSHandle dshandle, int event,
DS_GetDataValue(datahandle, CAVT_FLOAT, data, sizeof(double), &sz, &sz);
int CVICALLBACK disconnect(int panel, int control, int event, void*callbackdata, int eventDatal, int eventData2);
Since the 1990s, the concept of an instrument has developed from a traditional mode instrument to a virtual instrument, that is, “software is an instrument”, and then to a networked virtual instrument, that is, “network is an instrument”. With the continuous development of computer technology, Internet, and database technology, networked virtual instruments will become the mainstream of future instrument development, and will be widely used in all walks of life.