Example Code

Model View Controller for Distributed Systems

Code and Documents

Attachment

Download All

Overview
The concept shows how you can send messages to and from an RT system using LVOOP for an extensible scalable system.

 


Description
It uses network streams to effectively spread the queue between systems. The original hardware that was used was a cRIO 9076 with a 9474 digital output in slot 1. The Original VI shows the basic code. Pressing a color button sets the LED on the front panel to that color and then uses the timeout on the view to switch it off 2 seconds later. The color box on the fourth color button allows the user to set the color to an arbitrary one. The 2 OOP Single System VI does exactly the same but uses LVOOP to pass messages between the View and the Controller. The 3 OOP Single System has an extra loop to forward the messages back to the View from the Controller. This cannot be done directly and simply when firing events to a remote system. 4 OOP Same system controller is the controller with its queues replaced with network streams. The incoming commands loop could be removed and the network stream fed directly into the controller. This way leaves the controller unaltered from the previous examples. 4 OOP Same System View is the View/Front Panel for the Same system controller. 5 OOP RT system View is exactly the same as 4 OOP Same System View but with a different IP address on both the incoming and outgoing network streams. Change these values if your cRIO has a different IP Address. Run this the 6 OOP RT System Controller on the cRIO and see that the code now runs across both systems. 7 OOP RT System Controller TCL is meant to be run with 5 OOP RT System View to show the extra time taken to load in the class from disk on the RT system. A jump of approximately 30 -40 microseconds was seen on the cRIO 9076. 8 OOP RT System View shows a volume of data coming back from the cRIO. The 8 OOP RT System Controller TCL creates 4 sine waves slightly out of sync to pass back to the View. N.B. to get this to work on a remote system you will need to put the relevant class files onto the cRIO. Drag the Classes for RT virtual folder across to the RT system. Edit the Source Distribution build specification to include the source files of each of the .lvclass files in the subfolders you just moved and also the methods contained within the classes. Build the source distribution and ftp this to the cRIO and put into the c/classes folder. 


Requirements

  • LabVIEW 2012 (or compatible)


Steps to Implement or Execute Code

  1. Unzip the attached folder to your computer
  2. Open the project "MVC For RT.lvproj"
  3. Open and run the VI with diffrerernt function

 

Additional Information or References
VI Snippet of "1 Original.vi" (Check more VIs in the project)

 Block Diagram.png


 **This document has been updated to meet the current required format for the NI Code Exchange.**

 

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.