Walter Gunter Posted September 23, 2013 Report Posted September 23, 2013 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). Thanks, Quote
QueueYueue Posted September 23, 2013 Report Posted September 23, 2013 It sounds like you haven't setup your inheritance correctly. http://zone.ni.com/reference/en-XX/help/371361H-01/lvconcepts/creating_classes/ 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. Quote
Stagg54 Posted September 23, 2013 Report Posted September 23, 2013 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). Quote
Walter Gunter Posted September 24, 2013 Author Report Posted September 24, 2013 (edited) 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. Album: Gunter Awesomes 1 images 0 comments Edited September 24, 2013 by Walter Gunter Quote
Jon Kokott Posted September 26, 2013 Report Posted September 26, 2013 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. Quote
jon_mcbee Posted November 12, 2013 Report Posted November 12, 2013 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 Quote
todd Posted November 13, 2013 Report Posted November 13, 2013 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: 1 Quote
Walter Gunter Posted November 13, 2013 Author Report Posted November 13, 2013 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.... Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.