From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

passing data back from an event

I am struggling with getting data back from an event.  I have a single while loop with an event structure.  I can call a user event and pass data into the event, and execute the event (like "set port c")  but when I pass a "read port A" and want to see the return I can't do it.  I can see that I am "reading port A", but I am stumped in how to see that data back in the calling event.

 

I have a "run test" event that calls a "power on" event, then the "run test" event calls a "write port c" event, that executes, then the "run test" event calls a "read port a"  event, which executes and I can see that the data is correct, but I want the data available back up in the "run test" event.  What am I missing?

0 Kudos
Message 1 of 9
(1,139 Views)

Hi csmith,

 


@csmith3 wrote:

I have a "run test" event that calls … What am I missing?


You have a lot of text, but you missed to attach an (example) VI!

Best regards,
GerdW


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

If you want an answer back from an event you can pass to that event the reference of a queue (or notification) and wait on the same an element. Obviously you cannot use it in another event of the same structure.

0 Kudos
Message 3 of 9
(1,082 Views)

@GerdW wrote:

Hi csmith,

 


@csmith3 wrote:

I have a "run test" event that calls … What am I missing?


You have a lot of text, but you missed to attach an (example) VI!


Yes, please do share some code. Your text is a bit confusing, making me think that you may need an odd structure.

0 Kudos
Message 4 of 9
(1,080 Views)

@ico82 wrote:

If you want an answer back from an event you can pass to that event the reference of a queue (or notification) and wait on the same an element. Obviously you cannot use it in another event of the same structure.


I have found the Queue to be the better route queue to some interesting race conditions I have ran into with the Notifier and if you set the "Ignore Previous Notification" wrong with the Wait For Notification function.

 

So my exact sequence here is create the response queue, send the command with the response queue reference as part of the command data, use Dequeue Element to wait for the response (be use to have a timeout in case something goes wrong on the other side), and then destroy the response queue.


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 9
(1,066 Views)

It's exactly what I usually do, moreover in the code I handle also the possibility of run the same event both with a response and without yet the response can also be the error cluster obtained during the event so that if the translation of the response give an error I can translate the response in the error cluster of the event. If you start you can make it as complex as you want 😅

0 Kudos
Message 6 of 9
(1,062 Views)

@johntrich1971 wrote:

@GerdW wrote:

Hi csmith,

 


@csmith3 wrote:

I have a "run test" event that calls … What am I missing?


You have a lot of text, but you missed to attach an (example) VI!


Yes, please do share some code. Your text is a bit confusing, making me think that you may need an odd structure.


Looks like I didn't proofread - I don't think you need an odd structure, I think that you have an odd structure and may need to restructure.

0 Kudos
Message 7 of 9
(1,029 Views)

All,

I appreciate that this post got looked at, and in a very quick fashion.  I apologize but I cannot post code (rules).  I will try to be more detailed in my description.

 

I have one while loop with one event structure in it. I have value change events for the Run “X” Test, Run “Y” test, Run “Z” test.    I have user events for each piece of test equipment (DMM1, DMM2, Power supply etc), user events for RS-232 communications, user event for my Multifunction IO board (NI PCIe6323).  I am passing a function and data (like Power Supply ON or Set DIO port A) to the user events and they execute.  The Run “X” Test event contains a chain of User Events (set up power supply, set-up digit I/O bits, read RS-232 port).  The problem I encountered was that I could not actually code the completed test in my Run “X” Text value change event since I always need some response back from a user event (read RS-232, Read DMM) and I do not know how to access it (I’ve tried notifiers, Queues, Functional global variables).  I am currently passing the Read RS232, or read DMM user event everything needed to do the read and status the results.  All the calls to setup events (events that perform setup and do not need to return data) work great.  I know I need some more advanced structure, but I am confused as to which one would be best. 

 

Thanks,

csmith3

0 Kudos
Message 8 of 9
(1,023 Views)

First, I wouldn't use the Event structure as the underlying structure for my state machine. I would use a case statement. I would also separate the UI elements from the core state machine logic. If you want to use a single loop than I would suggest looking at the JKI state machine. Use shift registers to pass data between states.

 

BTW, in terms of posting code you could also create a very simplified example illustrating what you are asking about. IT doesn't have to be your exact code since that often times cannot be posted.



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
0 Kudos
Message 9 of 9
(1,011 Views)