Jump to content

Recommended Posts

I am working on some labview code that I really want to use OOP.  I have some classes, ie, motor, relay, potentiometer, etc that I am using and wanted to incorporate in a state machine. I wonder if there are some good examples of this?  I found a thread on here discussing it http://lavag.org/topic/13064-object-based-state-machine-pattern/ , but I am not clear if it answers my question. 

1. When I try to wire a class into a state machine (while loop with a case structure), I always get a broken wire in the while loop. It says the wire type is different?  Am I thinking of this incorrectly. I have a class object I put on the block diagram, i wire it to 'Initialize.Vi' and it breaks (there and on any vi from that class).


Link to post
Share on other sites

It sounds like you haven't setup your inheritance correctly.



You're asking fairly vague questions that are pretty hard to answer without writing a lot. Maybe posting some code would help (it would definitly give us the answer to your first question), but really, you need to ask some more specific questions.

Link to post
Share on other sites

Dynamic Dispatch is your friend.


It sounds like you are on the right track, but you just haven't had that epiphany moment yet.  It will come.  Try and find some example code to look at.  I'm sure there's plenty out there (just don't know where off the top of my head).

Link to post
Share on other sites

Sorry about the vague description above. I wrote it while in the middle of the task with me understanding all that I was working on at the time.  I sort of figured out where I was having issues, but still not sure why. So, the first time I tried what is shown below, the wire between the class object on the left and the Init.vi in the State Machine was broken.  I couldn't figure out why. Then, I just tried it with the init.vi on the outside of the state machine and the wire was no longer broken. While trying to figure out how to explain to you guys my challenge, I again tried to put the Init.vi inside the State Machine, and now i don't have a broken wire.  I am losing it...any thoughts.

Object Oriented and State Machine
Album: Gunter Awesomes
1 images

Edited by Walter Gunter
Link to post
Share on other sites

It would be easier if you simply posted the code, however, I suspect that the class going into your init function is not the same as the one coming out.  


Other LVOOP comment, take a look at the Actor Framework.  It comes with labVIEW, and I think will take you to a better place, however, it is probably a difficult place to start off with LVOOP as some of the conceptual aspects of it are more difficult than the code you've presented.

Link to post
Share on other sites
  • 1 month later...

I dont know if this will help you or not, but would love to get feedback from you on its usefulness.  I have attached an example project that compares a very simple piece of code written with a QMH, written with an LVOOP approach, and written with the Actor Framework.  I used this as a demo at a recent CLA/CLD summit.  It is intended to be an apples to apples to apples comparison for someone who is looking to learn LVOOP/Actor Framework.  It was originally posted on the NI Community Forums, but I apparently cant link to the page from LAVA(?) (Thanks Todd).



EDIT: Replaced attached files with link to files on the NI Community Forums so that I only have to maintain one set of files: https://decibel.ni.com/content/docs/DOC-32600



Link to post
Share on other sites
It was originally posted on the NI Community Forums, but I apparently cant link to the page from LAVA(?).

Live links are down due to spam. If you place the cursor within the link text and click the "Unlink" button (just below the smiley face, for me), the link text shows up:



  • Like 1
Link to post
Share on other sites

awesome timing..I have had to put my program on the back burner as other fires have popped up and had higher priority. I just learned about the Actor Framework at NI Days in DC and determined since I was going down the QMH/State Machine path, that it might be a good idea to use it in my program. So, today, I am starting again and you have posted the LVOOP 2012 examples for my benefit and learning.  I will post an update once I make some progress. I might need help determining what my Actors are....

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Similar Content

    • By Marko Hakkarainen
      I had some time to learn about new interfaces and finally I could implement my collection class as I had envisioned. I didn’t want to use iterable and iterator names, because I thought that would have been too bold a claim.
      The original version of the collection class was (and is) used as a collection of sequence steps. Each element can be either a sequence command (send message, wait timer, wait complete etc.) or another collection of commands (sub-sequence). That’s the reasons for the labels and search method. Otherwise it is just a fancy (Rube Goldberg) array.
      Next method is recursive and it steps through all elements in the collection. Execute is only method, which requires override.
      For now, it’s at least an exercise in new interfaces. I don’t know if it’s useful enough to be in the code repository, but I can polish it up if needed.
      Marko H
      Certified LabVIEW Architect
      Iterable Collection LV2020.zip
    • By Zyl
      Hi everybody,
      I'm running into something I don't really understand. Maybe you can help me here !
      I've got a LVLIB that is used as an 'Interface': it exposes public VIs which wrap around public functions of a private class (see code attached) . The class is private because I want to force the users to use the 'interface' functions.
      In one of my interface VI, I create a DVR on the private class (Interface_init). The DVR is stored into a typedef (FClass_DVR.ctl) and this typedef is the 'reference' that link all the interface public functions.
      In TestCode.vi (which is not part of the lvlib and illustrates the standard code that a user can create to use my driver), I can call my public interface functions and link them without any problem.

      But as soon as I create an indicator on that reference (to create a state-machine-context-cluster for example), my TestCode VI breaks !

      The error returned is : This VI cannot use the LabVIEW class control because of library access scope. The LabVIEW class is a private library item and can only be accessed from inside the same library or libraries contained in that library.
      I understand that the class is private. But the DVR is contained into a public control. Using an In Place structure on that DVR into TestCode would not work, since the class is private. So why is the DVR control problematic at that point ? Creating it do not breaks any access protection...
      Am I missing something ?
      DVR Private POC.zip
    • By Brains
      Does anybody know the best way to make a copy of a byref object (open gds v4) at runtime and pass all the attributes values (including inherited attributes) to the new object?
      Thank you!
    • By GregFreeman
      I currently have a project that I am refactoring. There is a lot of coupling that is not sitting well with me due to typedefs belonging to a class, then getting bundled into another class which is then fired off as event data.
      Effectively, I have class A with a public typedef, then class B contains ClassA.typedef and then class B gets fired off in an event to class C to be handled. Class C now has a dependency on class A which is causing a lot of coupling I don't want.
      For my real world example I query a bunch of data from our MES, which results in a bunch of typedef controls on the connector panes of those VIs. Those typedefs belong to the MES class. I then want to bundle all that data into a TestConfig class and send that via an event to our Tester class. But, now our tester has a dependency on the MES.
      I see a few ways to handle this. First is move the typedefs currently in the MES class, to the TestConfig class. The MES VIs will now have the typedefs from the TestConfig class on their connector panes, but at least the dependency is the correct "direction." Or, I can move the typedefs out of classes all together, but then I am not sure the best way to organize them. Looking for how others have handled these sorts of dependencies.
    • By bharathp
      Hi everyone.
      I need help regarding LVOOP implementation. I have gone through several examples and documents on LVOOP for quite some time, and finally decided to use it in this simple application. In my project LabVIEW application communicates between a PLC(local) and a server(TCP).I have used command pattern.For the server part i have created class and methods and it runs in a separate loop(i pass messages from main process loop). my problem is how can i make my main process using the same method? In QMH and state machine i can do it easily by checking condition and queuing next action how can i implement the same using OOP?
      I have tried passing the next command in the current method. Is it the right way to do?
      I am also thinking using a while loop inside methods for checking for validating conditions is it okay to do so?
      Or should i use QMH for the main process to send commands to the server loop?
      Or am i doing it all wrong?
      LVOOP attempt.zip
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.