LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Event structure which doesn't work + problem of values ​​that are saved multiple times in a table

Good afternoon everyone !

I am creating a medication schedule manager on Labview. The goal is for the user to select a date on the calendar,
then enter a time and a medication. I get a Time/medication table as output as well as a table with only the
scheduled times as output.


The event in my event structure occurs after 30 seconds/1 minute even if I did not press the "add medication" button.
Furthermore, it seems to me that at the end of my VI execution, there is not the right number of hours/medications
in my table (perhaps due to the problem mentioned above), and I don't see how to resolve this problem.

 

I am joining my VI.

Someone would have any idea ? Thank you for any help you can give me.

 

Have a nice day !

0 Kudos
Message 1 of 7
(315 Views)

Hi saar,

 

you need to put more code into (other) event cases!

 

See this:

 

When using an event structure then most of the stuff should be in its own event case.

Otherwise you run into race conditions or "event structure blocks iteration" problems!

 

Edit after Basjong's message:

  • I agree with item 1 and 2.
  • For item 3 I choose the TimeOut event to allow updates of the UI indicators, especially the "Selected Date", so the user has a visual feedback for its selections.
Best regards,
GerdW


using LV2016/2019/2021 on Win10/11+cRIO, TestStand2016/2019
0 Kudos
Message 2 of 7
(296 Views)

The VI does exactly what you have written. That may not necessarily be want you intend it to do however.

 

A few suggestions:

  1. Change the event to "value changed" instead of "Mouse Leave"
  2. Add the stop button to a new event (value changed of stop button)
  3. Add the property note that reads the date inside the Ajoutez event (remove the local variable while you're at it

This will make the program do as you expect. I do suggest to make it a proper state machine in the future.

0 Kudos
Message 3 of 7
(291 Views)

Hi Saar_amaz

 

The Event Structure waits for the event specified to  trigger the execution of what is in that event. Everything else in the code is frozen waiting for the event. 

In your case, change the event to occur with "VALUE CHANGE" , then when you click the boolean Button the value change will trigger the data to be added to the array. You can also keep the array indicator inside the loop so you can see the changes as you click "add" otherwise you need to wait the loop to stop to see the array. 

You should also add another event for the button "Plus de médicaments à ajouter au planning" so then you can stop the loop when this button has a "value change, place the button inside the event structure and wire  it to the stop condition of the loop. 

 

 

LVNinja_0-1710250809149.png

 

LVNinja_1-1710250926681.png

 

 

0 Kudos
Message 4 of 7
(283 Views)

1. "Mouse Leave" is a weird event to be registered for.  I would think you would want a "Value Change" event instead.  You should also move the button's terminal into the event case so that it can reset the latch when it is read.

2. You really should have an event for the Stop button so it gets acted on immediately instead of needing to wait for the button to be pressed again.

3. Without making a callback VI (something I have never done), I think you will also need a Timeout case for your Event Structure and set the timeout to something like 100ms.  Inside of the timeout case is where you check the calendar's date.

 

Attached is a quick cleanup for what I would do.


GCentral
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
"Not that we are sufficient in ourselves to claim anything as coming from us, but our sufficiency is from God" - 2 Corinthians 3:5
0 Kudos
Message 5 of 7
(266 Views)

Thank you very much for your answers !

 

I change my VI according to what I understood but when entering a medication and its hour, I don't have anything in my table when I press Stop.  I think that when I remove the local variable 'Date sélectionnée' I didn't really know if I have to put the way to find the date in the TimeOut or where i press 'ajouter un médicament' event.I was a bit confused.


I am joining the new VI.

 

Edit :

 

Thank you Knight of N, 

I just have a question. When I am using the VI, the medication and the time for the medication are saved very quickly and non stop (like once I press the button, it will save like every second the medication and the time medication). Because it seems that you didn't use the fact to press the button 'appuyer sur un medicament' and it is a problem for my project.

 

Saar

 

 

 

0 Kudos
Message 6 of 7
(257 Views)

Thank you it finally worked !!

 

 

0 Kudos
Message 7 of 7
(210 Views)