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).


Thanks,

Link to comment

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.

Link to comment

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
0 comments

Edited by Walter Gunter
Link to comment

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 comment
  • 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 comment
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:

 

post-107-0-18908600-1384325006.png

  • Like 1
Link to comment

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 comment

Join the conversation

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

Guest
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 Mahbod Morshedi
      Hi All,

      I m trying to build a software, and data management has become too complex. In short, it is acquiring data from three channels and doing some calculations and then showing and reporting that data for the user to make a fitting decision. The user then, can save the file and import the saved worked-up file later to view or manipulate.
      The data consist of three interdependent data set, and so far, I have collected the dat as an array of clusters (size 3) for three sets and kept user input data in the same manner. I am also using a simple "producer/consumer" design. However, I think that may have been a mistake, and I might be able to do a better job using either actor or QMH design, especially since I need to think about adding the acquisition part (which is not yet developed). The thing is that I have not used oop before at all and am not quite sure if this is the correct approach and how should I bundle my data. Considering that the data (not all but some) need to be accessed by other classes if I goo with oop.
      For example, should I keep the data as separate class data and use methods for override or keep it as an array in the parent class and use static methods and only use child classes for graphing. These are the type of questions I am struggling with. Also, can anyone help me decide between DQMH, Actor or just standard Producer/Consumer patterns, please? I am completely lost.
      Thank you in advence.
       
      This is how the front pannel looks like:

      And this is the data set for the system (which I am keeping as an array) there will me more data added to this as the capabiliy grows.

    • By cyro2015
      Hi,
      I tried to create a template based on OOP for QMH. During development I have been confronted with infinite crashes of LabVIEW so I decided to slow down with this project and open it to the community. I finished my working example and stopped for now.
      So if anyone is interested to play around with the code, see attached ZIP file (LV 2020).
      Cu,
      Peter
       
      MHT.zip
    • 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
      www.optofidelity.com
      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
      Hi,
      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!
      Craig
×
×
  • Create New...

Important Information

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