Jump to content

DQMH - creating modules, singletons or cloneable help


Recommended Posts

Hey Fancy Folk,

 

Back at it with a question regarding DQMH and how to properly set up code.  Long story short, I am creating a "power and IG" module for some motors.  This module will contain a module for a "PS class" that I've already created (class, not module) and I'm trying to figure out if I should make the "PS class" module a singleton or cloneable.

 

The high level view is that the code would have a controller which requests to the "Power and IG" module which would request to the "PS class" module.  The "PS class" module would then broadcast to the "Power and IG" module which would broadcast back to the controller.  This way everything gets passed down/up 1 level at a time.  The "Power and IG" module will be cloneable because there can be multiple copies of this module for one test stand.  However, I only want each "Power and IG" module to have 1 instance of the "PS class" module.  I was originally thinking of making the "Power and IG module" cloneable but the "PS class" module singleton.  The issue I see with this is that I am going to be creating multiple singleton "PS class" modules for when I have multiple "Power and IG" modules and I think that is going to cause the code to fail.  Therefore, I am thinking about making both the "Power and IG" and "PS class" cloneable to be safe.  

 

Thanks,

Matt

Link to comment

Darren,

 

That is what I was thinking too.  I wasn't sure if the DQMH used singleton to mean in the entire project, or specific to a module.  IIRC, singleton in general means 1 copy of this object exists ever.  However, I wasn't sure of "PS Class" being a "sub module" would affect the singleton to mean 1 copy exists for this main module.  I assumed not but wanted to verify.

 

Matt  

Link to comment

For DQMH, the term "singleton" means that the Main VI of the module is non-reentrant. A "cloneable" module has a reentrant Main VI. So if you have a reentrant instance running (of Power and IG), then that instance will also need its own associated reentrant instance of PS class.

  • Like 1
Link to comment

Darren,

 

Thanks for clearing that up!  As I was thinking through everything I got onto the mindset that "singleton" isn't "sub module" specific but project specific.  Meaning that if I had a singleton PS sub module nested in my "Power and IG" module, then only 1 PS class could exist throughout the entire project and not per cloneable Power and IG module (which having 1 copy of the PS submodule per Power and IG module is the desired result).

 

Matt   

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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.

×
×
  • Create New...

Important Information

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