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.
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.
11-15-2021 03:11 PM
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?
11-15-2021 03:29 PM
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!
11-16-2021 01:23 AM
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.
11-16-2021 08:38 AM
11-16-2021 12:09 PM
@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.
11-16-2021 12:40 PM
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 😅
11-17-2021 07:14 AM
@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.
11-17-2021 08:16 AM
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
11-17-2021 10:31 AM - edited 11-17-2021 10:32 AM
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.