element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
NI LabVIEW Community
  • Products
  • Dev Tools
  • NI LabVIEW Community
  • More
  • Cancel
NI LabVIEW Community
NI Forum goal: learn OO LabVIEW
  • Blog
  • LabVIEW Challenge Blogs
  • Forum
  • Documents
  • Quiz
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join NI LabVIEW Community to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Not Answered
  • Replies 6 replies
  • Subscribers 126 subscribers
  • Views 1330 views
  • Users 0 members are here
  • RoadTest
  • mcc172
  • labview
Related

goal: learn OO LabVIEW

Jan Cumps
Jan Cumps over 2 years ago

I made a LabVIEW driver for a DAQ. The sampling mechanism is always the same:

  • one flow starts the DAQ, tells it to sample data, retrieves that data and queues it. In a loop. This is called the Producer Loop in LabVIEW lingo
  • a second flow reads data from that queue and shows / stores / processes it. They call that the consumer loop

image

The top loop - the producer - is always the same. This is the flow that tells the DQ to send samples, then retrieves the sampling data and enqueues it. I know how to turn that into an object (and have done that - will be released later).

I want to make the Consumer Loop OO

I want to focus on the bottom loop: the consumer. That one is application dependent. What do I do with that data?
In my examples, I have implemented several incarnations of that pattern:

  • a simple flow that retrieves one channel and shows its data on a virtual scope screen
  • a flow that samples two channels
  • a flow that collects x samples and does a FFT
  • a flow that collects x samples and calculates acceleration data from it
  • a combination of those.

I'd like to use LabVIEW's OO mechanisms to provide a simple implementation. And allow the user to inherit from that and do what they want. If you are a LabVIEW OO expert, please chime in.

I am able to do Simple object wrapping

I wrapped the upper loop into a block. That's easy because it doesn't need inheritance or polymorphism. This is the original flow:

image

I wrapped that Producer Loop into a block, and added it to the driver lib. Here's what a flow looks like when using that block:

image

The whole Producer Loop functionality above is contained in that block. It makes the flow less busy, and takes care that that same logic can easily be reused - and kept consistent - in every process.
It's reuse, but not yet full OO. Here is the logic behind that block:

image

The keen eye will see that it is the same as the producer loop in the first and second  image, with all inputs and outputs turned into connectors. You can see it in use in the 3rd image.
I need to fix one side effect of wrapping this object: It breaks the Stop button functionality, because its status is now retrieved when entering the block. Not at each iteration.

  • Sign in to reply
  • Cancel

Top Replies

  • Andrew J
    Andrew J over 2 years ago +3
    I did something very similar a couple of years back when I believed NI’s marketing about NXG being the future. A “tester” just needs to create a couple of concrete subclasses to plug in to get it all to…
  • Jan Cumps
    Jan Cumps over 2 years ago in reply to Andrew J +2
    Andrew J said: when I believed NI’s marketing about NXG being the future That was rough for a lot of people. NI really pushed users to migrate their code base. Then canceled all. They must have had very…
Parents
  • Andrew J
    0 Andrew J over 2 years ago

    I did something very similar a couple of years back when I believed NI’s marketing about NXG being the future.  A “tester” just needs to create a couple of concrete subclasses to plug in to get it all to work.  I’ve been meaning to rewrite it to classic LabVIEW but it’s hard to get re motivated to do it!  A lot of it should translate so feel free to use or ignore it and send me any questions.  Hardware Abstraction Framework

    I also created a Unit Testing framework as well - accessible in my Github library.  That has examples of OO as well.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Reply
  • Andrew J
    0 Andrew J over 2 years ago

    I did something very similar a couple of years back when I believed NI’s marketing about NXG being the future.  A “tester” just needs to create a couple of concrete subclasses to plug in to get it all to work.  I’ve been meaning to rewrite it to classic LabVIEW but it’s hard to get re motivated to do it!  A lot of it should translate so feel free to use or ignore it and send me any questions.  Hardware Abstraction Framework

    I also created a Unit Testing framework as well - accessible in my Github library.  That has examples of OO as well.

    • Cancel
    • Vote Up +3 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
Children
  • Jan Cumps
    0 Jan Cumps over 2 years ago in reply to Andrew J
    Andrew J said:
    when I believed NI’s marketing about NXG being the future

    That was rough for a lot of people. NI really pushed users to migrate their code base. Then canceled all. They must have had very good reasons to end this branch of their toolchain.

    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube