LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Update various type of status on Main from sub-VIs

Solved!
Go to solution

Hi!

 

I have a project based on the NI QMH (still learning OOP with Labview, hopefully next one will be with DQMH :D) and I'm trying to have a "Status update" on my main interface.

To simplify my problem, I would have 4 VIs:

  • 1 Sub-VI handling the communication with a sensor
  • Another one handling coms with a motor
  • a third one handling the test procedure (Creating tests and sending commands at the right time to the motor)
  • And my main, updating the user with various status, for instance: 1.Boolean Sensor connected ; 2.Bool Motor Connected ; 3.String Test being performed (time remaining as well or whatever.)

 

My idea would be to have a cluster typedef "Status" with 2 booleans and 1 string and to send a message "Update Status" to my main handling loop queue (MHL) from th subVIs with the proper info.

Problem: if I send for instance a "motor connected update" constant to the cluster, then I will overwrite the other information, right?

 

VinnyLaTaupe_0-1620293083518.png

 

 

How would you deal with this?

Maybe first first send a "request status" to the MHL which sends the current status, and then I can just overwrite the info I'm interested in? Or create multiple "update Status"? (Update motor info ; Update Sensor info; Update test....)

 

What would you suggest?
Thanks in advance.

Vincent.

0 Kudos
Message 1 of 10
(1,322 Views)

It overwrites other values because you are providing it with a constant cluster, instead of current information.

 

The way i do it is to use Action Engines (AE), which pass data between subVIs (assuming they run in parallel with the main VI and are not actually run by main VI).

In your case i'd read the current data from AE and pass that cluster as an input to unbundle (by name). That way you keep your other data and only change the value you need.

 

EDIT with example:

AeroSoul_0-1620293993486.png

and how the AE looks from inside:

AeroSoul_1-1620294056330.png

 

 

Message 2 of 10
(1,311 Views)

Ah that's nice. It's a sort of global variable? I didn't know about this.

 

But what do you mean by "assuming they run in parallel with the main VI and are not actually run by main VI"? 

My other VIs are in parrallel to the MHL but inside the main.vi.

Typically like this (Random screenshot from a PC template)

VinnyLaTaupe_1-1620295258003.png

 

 

0 Kudos
Message 3 of 10
(1,301 Views)

What i meant was that AE is probably a bit of an overkill if you have direct access to inputs and outputs of your sensor/motor/test controls.

 

I use them when i don't have direct access to the running VI, in example of opening VI with call and forget:

AeroSoul_0-1620296248234.png

 

0 Kudos
Message 4 of 10
(1,277 Views)

Ah I see.

 

Yeah I would have to do some more research in that way, not very familiar with asynchronous calls... So I'm usually trying to deal everything with queues and send results through them.

0 Kudos
Message 5 of 10
(1,262 Views)
Solution
Accepted by topic author VinnyAstro

Hi Vinny,

 


@VinnyAstro wrote:

Or create multiple "update Status"? (Update motor info ; Update Sensor info; Update test....)


I would go this way!

Keep the cluster in your consumer loop, the producers will send only their own data (motor loop will send motor status, and so on). Why should the motor loop take care of sensor data?

Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
Message 6 of 10
(1,257 Views)

@GerdW wrote:

Why should the motor loop take care of sensor data?


So theoratiaclly it would take care of it, just "get" the status and change its own info and send it back. However just one missmanagement in the cabling and it would mess with our data yes.

 


@GerdW wrote:

Keep the cluster in your consumer loop, the producers will send only their own data (motor loop will send motor status, and so on).


So you suggest one Cluster Status, and within some typedef sub-clusters (one for each system) and one case "update XXX Status" for every sub-sys?

VinnyLaTaupe_0-1620301099950.png


Posting this picture and I'm realizing that for UX purposes, the sub-clusters could also be separeted and don't have to be displayed all together in a bigger one.

0 Kudos
Message 7 of 10
(1,244 Views)

No, he is suggested distinct status messages for each part of your system. Each status update would only have the data for itself. By doing so, you do not have to request the status from other parts of the system. The motor loop will always know the status of the motor and all it needs to do is send the updates to the UI/controller loop. When you send them is up to you. You could only send updates when some has changed or you could send periodic updates at regular intervals. While AE can be useful, I would avoid using them. You are already using the QMH so use that. Use messages to send your data. Do not overload messages with extra content or try to overload them., such as using one status message for all of your various components while each has some distinct data.

 

Another option you have would be to use user events. This works well for UI updates since the UI loop will/should be using the event structure. This is still a messaging architecture. The only thing that differs is how the message is delivered.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 8 of 10
(1,210 Views)

@Mark_Yedinak wrote:

No, he is suggested distinct status messages for each part of your system. Each status update would only have the data for itself. By doing so, you do not have to request the status from other parts of the system. The motor loop will always know the status of the motor and all it needs to do is send the updates to the UI/controller loop. When you send them is up to you. You could only send updates when some has changed or you could send periodic updates at regular intervals.


I think this is what I meant but I wasn't clear. I'm trying something like this at the moment. (obviously the multiple case structures are here to show the different cases)

VinnyLaTaupe_0-1620375966271.png

 


@Mark_Yedinak wrote:

While AE can be useful, I would avoid using them. You are already using the QMH so use that. Use messages to send your data. Do not overload messages with extra content or try to overload them., such as using one status message for all of your various components while each has some distinct data.


Yep ok I will use messages. But out of curiosity, what are the pros and cons with AEs?

 


@Mark_Yedinak wrote:

Another option you have would be to use user events. This works well for UI updates since the UI loop will/should be using the event structure. This is still a messaging architecture. The only thing that differs is how the message is delivered.


Ah yeah that's interesting too. That would be one user event per system when I want to update their status and the main event case would request an update status in a UI loop? I believe that's actually what they suggest in the QMH template, but I haven't really understood it until now.

0 Kudos
Message 9 of 10
(1,190 Views)

Personally, I have never been a hige fan of action engines. They do server their purpose and I do occassionally use them. When I do use them it is generally to pass some basic config data to other parts of the system without the need to wire data into some subsystem. In general, my code uses OOP techniques heavily and I will use composition in my classes to pass the necessary data and information around the system. My systems are also very heavily reliant on messaging techniques. Way before DQMH or Actor Framework I developed a network based messaging system which has been the basis of most of my systems. It has many things in common with the actor framework with the major exception that the messaging system is a publish/subscribe model and our messages can be broadcast. Unlike the AF, the messages are not objects. The primary reason is tha the messaging format is language agnostic so we can pass messages between systems built using different languages. This could be done with AF but you would need to include some type of translation layer to convert message data from a LV object to pure data.

 

What I don't like about AE is that when used, it is very difficult to know all parts of your system which could be affected is the AE changes. It also makes it harder to re-use code since the AE must travel with all components that use it. I prefer explicitly defining and describing what coomponents are used by any piece of code. This makes tracking dependenies a little easier. This is were classes really help.

 

AE can be helpful if you are dealling with really large data since it will keep the data to a single copy. However, I would still prefer to use a class with a Data Value Reference for the data set.

 

What I have seen often is that AE can promote lazy programming/design. Yes, they can be used effectively but too oftem people simply drop an AE in their code to get data from point A to point B without thinking the design through. Ultimately this can lead to heavily coupled code.

 

Your case is a perfect example of where the AE would be a lazy way to pass status information around. You are alreay using a messaging architecture so use messages to pass the data. Throwing in AE just muddies the code and hides the true interactions of the system. Yes, a messaging system can be difficult to debug at times since it is asynchronus and there is no direct data flow. But at least you have explicit messages defined which describe what is happening. It defines an API between your subsystems. AEs are basically falling back on the concept of global data. You open up your data to be modified or manipulated by any part of your system. That makes debugging even more of a nightmare than a mesaging system since you may have no clue where or what is changing your data.



Mark Yedinak
Certified LabVIEW Architect
LabVIEW Champion

"Does anyone know where the love of God goes when the waves turn the minutes to hours?"
Wreck of the Edmund Fitzgerald - Gordon Lightfoot
Message 10 of 10
(1,177 Views)