In my last post
I gave a simple method used to simulate the unavailable hardware (be it cRIO, bench-top instruments, PXI or any kind) which can communicate to LabVIEW application. I also mentioned that I simulate using data sockets which I will explain in this article.
DataSocket is an easy-to-use, high-performance programming tool that is designed specifically for sharing and publishing live data in measurement and automation applications between different applications and between machines across the Internet. DataSocket for LabVIEW simplifies live data exchange between different applications on one computer or between computers connected through a network.
In my instrument driver, I will have case structures surrounding the hardware accessing functions. This case structure helps to avoid communicating with hardware when I’m in simulation mode.
In simulation mode, i.e., other side of the case structure, I do not pass out any data. However, the measurement indicators will have the data sockets connected to it.
In my separate simulation VI, I change values of simulated data. The controls in this VI will have data socket connected. Eventually this will change the data to software.
I see that using data-socket based simulation is advantageous when
I need to test the process or work-flow of the automated production line.I need to verify the handshaking between two process (eg. PLC and cRIO) .I don’t have software application built; but need to test the hardware arrangements working correctly.I don’t have hardware but need to verify the software.I need to develop software and hardware simultaneously and independently.
Here is a GIF record of how this simulation works.
How to Establish Data Socket
In order to use data socket, you need to run Data Socket Server. Data Socket server is the heart of this simulation method which transfers your simulated values from simulation VI to the software. You can start the server by searching for in Start Menu of Windows.
Data socket for a controls or indicators can be enabled in Data Binding properties of the respective controls.
Path in the data socket is unique for each control and indicator of the instrument driver VI. For example in the above picture, dstp://localhost/measVoltNum is unique address for the control Measured Voltage. If another control say "Valve" is there in your application, then address for that could be like dstp://localhost/ValveBool . Looks very boredom job? Yes, you need to do this for all controls in simulation VI and use the same data binding address for the controls used in the application.
Once you have done that, you will find the controls in simulation VI have a small boolean box which turns green once it gets connected to the data socket server.