Matt_AM Posted September 23, 2021 Report Share Posted September 23, 2021 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 Quote Link to comment
Darren Posted September 23, 2021 Report Share Posted September 23, 2021 From your description it sounds like the PS Class module has to be cloneable. Otherwise all Power and IG instances would be sharing the same singleton instance of PS Class, which I'm guessing is not what you're going for. Quote Link to comment
Matt_AM Posted September 23, 2021 Author Report Share Posted September 23, 2021 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 Quote Link to comment
Darren Posted September 23, 2021 Report Share Posted September 23, 2021 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. 1 Quote Link to comment
Matt_AM Posted September 28, 2021 Author Report Share Posted September 28, 2021 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 Quote Link to comment
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.