12-20-2017 08:18 AM
I am trying to write a vi to collect data and allow the user to input header information and setup any parameters. Following the example for a state machine, the data will be acquired and written to file in one state. The header information, data analysis parameters, and file name created in another. The user will enter the information and start the data acquire state when ready to take a measurement. I noticed that if the state is running and the user selects another state the user loses ability to click any other state or abort button. It seems that once the loop in state 1 loses the focus I can not get it back unless I stop the vi and start again. I can disable all other buttons or options while in state 1 however I wanted to see if another more appropriate solution exists. I attached a sample of what I am trying to do. I left out the data acquire component that would run inside the loop of state 1.
Solved! Go to Solution.
12-20-2017 08:37 AM
When you are in State 1, you have to press the "Stop Data Acquire" button for the other buttons to do something. This you are in a loop that won't terminate until Stop Data Acquire is true. All other inputs would don't do much. If you press the Stop button while in this state, I think the front panel is locked because the event structure locks the panel (it is a checkbox option you will see if you edit the Stop: Value Change event). Otherwise, you are essentially always in the Wait for Data state where all the buttons should be more or less responsive.
I actually think disabling the other buttons is a decent solution. I often either combine all the references to the control in an array and enable and disable them. Or I put them in a cluster or tab and disable everything in the cluster or tab that will be disabled (then you just need to drag new things into the cluster to get them to disable at the right time). You can also use a tab to have one tab visible when in state 1 and another tab visible when in all the other states.
12-20-2017 08:45 AM - edited 12-20-2017 08:47 AM
eems to me an example where a producer/consumer design would be best. I recommend that you look into that design pattern.
Quick example of how your example would work using channel wires (can be implemented using variables, queues, etc):
12-20-2017 12:56 PM
This must be a new element added to NI. Did this exist in earlier versions of LV or did this start with 2017?
12-20-2017 12:57 PM
I'm referring to the channel wire!?
12-20-2017 01:04 PM
Channel wire was added in 2016
12-20-2017 02:00 PM
Marc,
Thank you for the response. I did consider using producer/consumer however (at the time) my code was not processing much for the HMI screen so I opted for the state machine approach. Plus the approach seems more complicated with the messaging/notifications. I will revisit it as I am considering on adding a step to display the error of the measurement for the operator. This will not be stored in the data file and warrant the producer/consumer pattern. I am not familiar with the channel wires. I am using LabVIEW 2015.
Thank you,
Chris
12-20-2017 02:02 PM
Majoris,
Thank you for the response. I implemented the able/disable option and the code is working now with out hanging.
Thank you,
Chris
12-20-2017 02:39 PM
@ChrisH76 wrote:
Majoris,
Thank you for the response. I implemented the able/disable option and the code is working now with out hanging.
Thank you,
Chris
The best way to say thanks is to mark solutions or give kudos 🙂