DQMH Consortium Toolkits Discussions

cancel
Showing results for 
Search instead for 
Did you mean: 

Automatically create a subvi when creating a new Event

Hi guys, 

 

I am using DQMH for a while now and like if very much. I was wondering if it is possible to automatically create a subvi for each Request. I dont like putting code in the main DQMH Case structure. So I always create a subVI where the "Module Data cluster" is used as input and output. Then I write my logic inside the subVI. 

But I am doing this step so many times that its getting annoying 😄 Did anybody have a similar observation and a clever solution?

 

Thank you!

0 Kudos
Message 1 of 11
(2,641 Views)

Hi @hallo2014,

When I started using DQMH, I tend to do the same, but quickly I found it wasn't beneficial.

First, I found out that name of the wrapper was often really close to the request. So having a meaningful name for it was not easy.

Second, I find it made the code less readable as far as you needed to open the wrappers to see what the code was doing.

 

My current way to do this is to code most of the code in the MHL request case. I can create subVI to implement the request, but they are just using the data they need from the module data cluster.

 

I'm curious to hear from other DQMHers 🙂


Olivier Jourdan

Wovalab founder | DQMH Consortium board member | LinkedIn

Stop writing your LabVIEW code documentation, use Antidoc!
0 Kudos
Message 2 of 11
(2,627 Views)

I did that at first too but quickly realized that the Blockdiagram is getting bigger and bigger... 

wrt Naming: I am simply naming the VI "W_RequestName", because this VI is just a Wrapper, and all important stuff like configs, control references and data is inside the "module data cluster". I know it sounds a bit dirty, but was the most easy and comfortable way for me so far. In my first version I did many very complicated and "cleaner" designs, that annoyed me in the end because I had zero benefits...

0 Kudos
Message 3 of 11
(2,608 Views)

While I think it's a good idea to wrap functionality of MHL cases into subVIs, it's not always exactly one subVI for one request's MHL case. Very often, it is a combination of multiple subVIs that provide shared functionality for several MHL cases.

 

I strongly advise against wiring the whole data cluster into subVIs. Not only will it increase the coupling, it also hides which data the subVI actually works on, and which data it manipulates. And it makes the subVI itself much more complex than it needs to be.

 

I also strongly advise against wrapping the "Variant to Data" + request payload typedef into said subVI. Separating the DQMH framework code (Variant to Data + request payload typedef, data cluster) from the actual functionality makes for a much more maintainable and reusable set of subVIs.




DSH Pragmatic Software Development Workshops (Fab, Steve, Brian and me)
Release Automation Tools for LabVIEW (CI/CD integration with LabVIEW)
HSE Discord Server (Discuss our free and commercial tools and services)
DQMH® (Developer Experience that makes you smile )


0 Kudos
Message 4 of 11
(2,597 Views)

@Olivier-JOURDAN wrote:

Hi @hallo2014,

When I started using DQMH, I tend to do the same, but quickly I found it wasn't beneficial.

First, I found out that name of the wrapper was often really close to the request. So having a meaningful name for it was not easy.

Second, I find it made the code less readable as far as you needed to open the wrappers to see what the code was doing.

 

My current way to do this is to code most of the code in the MHL request case. I can create subVI to implement the request, but they are just using the data they need from the module data cluster.

 

I'm curious to hear from other DQMHers 🙂


The naming conflict thing can be solved fairly easily with namespacing by making a class, putting it in the module private data, and switching out the DQMH module data type def with the class constant, AKA making state data into a class as suggested in Simple DQMH Dos and Don'ts. But then, that means wiring the whole class wire into the methods which is just what joerg recommended against.

 

@OP, it all depends on what your module does really. I've only fully made an instrument driver DQMH module to this point, and for that the process was fairly simple and I did exactly what I just described. I've made a database module template as well, and that as well will use class data as state data.

 

But once I get to actually making a full fledged project, I would say that for my controller or GUI modules, I'm currently leaning towards not using class data and instead just making the MHL cases simple and possibly expanding the case structure just a smidge to give myself a bit more room to work.

 

Spoiler
FireFistRedhawk_0-1643806772006.pngFireFistRedhawk_1-1643806818854.png

 

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 5 of 11
(2,583 Views)

Thank you for the advice. The issues about the coupling is valid. I guess that would be a trade off. 

But my main point was that I am trying to avoid implementing inside the main Case structure of dqmh. That forces me the increase the size of the case structure any time I am adding or changing code. This gets especially messy when I am using "Request with wait for reply and broadcast". In this mode, there is already a lot of code in the case structure just for the DQMH framework.


By using just one "wrapper" Subvi for my actual business logic, it does not require the touch the main DQMH case structure and just use the subvi instead (which of cause has many other decoupled sub-vis).

But it seems not many have the same idea 🙂 

0 Kudos
Message 6 of 11
(2,581 Views)

@hallo2014 wrote:

By using just one "wrapper" Subvi for my actual business logic, it does not require the touch the main DQMH case structure and just use the subvi instead (which of cause has many other decoupled sub-vis).


You can still do that, without wiring the entire "Module Data Cluster" as input and output of the SubVI. Just unbundle from the cluster what the subVI needs to do its thing, and wire them as individual controls to it. Then if the subVI changed the state of anything, put it as an indicator and wire it to a bundle. A couple extra minutes for each subVI to save you hours or possibly days of debugging. That's how I'm gonna approach it anyway.

 

Edit: but to answer your question about making a subVI automatically be created whenever you make a request, there might be some scripting you could finesse to do it, but if it is automatically created the VI name would need to be created automatically but can't be the same as the request. I have the most basic knowledge of scripting, enough to fix small things on a folder of VIs, so can't help you there. It's a business decision, weighing the time taken to make all that scripting code vs the collective extra time taken to manually make each subVI.

Redhawk
Test Engineer at Moog Inc.

Saying "Thanks that fixed it" or "Thanks that answers my question" and not giving a Kudo or Marked Solution, is like telling your waiter they did a great job and not leaving a tip. Please, tip your waiters.

0 Kudos
Message 7 of 11
(2,574 Views)

@FireFist-Redhawk  a écrit :

 

The naming conflict thing can be solved fairly easily with namespacing by making a class, putting it in the module private data, and switching out the DQMH module data type def with the class constant, AKA making state data into a class as suggested in Simple DQMH Dos and Don'ts. But then, that means wiring the whole class wire into the methods which is just what joerg recommended against.

I prefer to maintain the existing cluster and add any object needed to the cluster. That way you can follow Joerg's recommendation and maintain maximum compatibility with the future version of DQMH.


Olivier Jourdan

Wovalab founder | DQMH Consortium board member | LinkedIn

Stop writing your LabVIEW code documentation, use Antidoc!
0 Kudos
Message 8 of 11
(2,555 Views)

@hallo2014  a écrit :

But my main point was that I am trying to avoid implementing inside the main Case structure of dqmh. That forces me the increase the size of the case structure any time I am adding or changing code. This gets especially messy when I am using "Request with wait for reply and broadcast". In this mode, there is already a lot of code in the case structure just for the DQMH framework.


Increasing the size of the MHL is not bad. Size should remain reasonable, but I would say that I increase 95% of my MHLs. Not sure that creating a subvi would make the code less messy 😅


Olivier Jourdan

Wovalab founder | DQMH Consortium board member | LinkedIn

Stop writing your LabVIEW code documentation, use Antidoc!
0 Kudos
Message 9 of 11
(2,553 Views)

@FireFist-Redhawk wrote:


The naming conflict thing can be solved fairly easily with namespacing by making a class, putting it in the module private data, and switching out the DQMH module data type def with the class constant, AKA making state data into a class as suggested in Simple DQMH Dos and Don'ts. But then, that means wiring the whole class wire into the methods which is just what joerg recommended against.

We had a great discussion about this very topic with our DQMH Trusted Advisors some time ago, after which Sam updated his very helpful Dos and Don'ts article accordingly (thanks Sam!):

 

Bildschirmfoto 2022-02-02 um 16.38.32.png




DSH Pragmatic Software Development Workshops (Fab, Steve, Brian and me)
Release Automation Tools for LabVIEW (CI/CD integration with LabVIEW)
HSE Discord Server (Discuss our free and commercial tools and services)
DQMH® (Developer Experience that makes you smile )


Message 10 of 11
(2,546 Views)