LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

Error handling in QMH projects with multiple error sources

Solved!
Go to solution

Hi guys,

 

I have a head scratcher:

In a QMH architecture I have a state machine that describes a certain measurement task involving different instruments.

Each of these instruments has its own message handling loop vi and each of these loops could cause errors.

 

I want to pass on these errors to the state machine (main VI if you will) in order to take appropriate action or - at least - let the user know what instrument the error came from. Currently I use a global variable for each error source and merge the errors in the main VI.

Problem: When multiple errors occur, only the one wired to the first input of the merge errors VI is displayed.

 

What is the best way to get errors from multiple sources to higher level VIs and retain all error information for debugging purposes?

Thanks!

0 Kudos
Message 1 of 15
(4,541 Views)

NI provides a QMH Template that has a Method and a Discussion of ways to handle errors that might be a good solution for you.  Start LabVIEW, click on Create Project, and choose Queued Message Handler (at least that's what I see on LabVIEW 2015).  Look at how Errors are handled -- each sub-VI can classify its errors into various levels of severity, with Error Handling code in the QMH to dispatch things appropriately.

 

Bob Schor

0 Kudos
Message 2 of 15
(4,527 Views)

One method I quite like is to have a 'report error' SubVI which I put on the error out of each state machine (between the case structure and the while loop border). This VI sends the error (along with any additional debug information you want such as the 'state', a timestamp etc.) to the main state machine (or to a specific error handler state machine) which can then log/report the error (I sometimes put them into a lossy queue so I can see how frequently the error occurs etc.) and decide what action to take.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 3 of 15
(4,525 Views)

My architecture is a bit different. I started with the QMH template and quickly replaced the event handling loop with the state machine. I will attach my main VI and one of my sub VIs to illustrate.

I have taken a look at the example but I still don't know how exactly I should implement that into my program.

 

"LL parken v2" is my main state machine. It uses a queue (IAI) to send commands to one instrument.

"IAI_message handling loop_v3" is one of my sub VIs that should report its errors back to the state machine.

 

Do I need one queue for the commands (main VI -> sub VI) and another queue for errors (sub VI -> main VI)?

 

Download All
0 Kudos
Message 4 of 15
(4,514 Views)

@Sam_Sharp wrote:

One method I quite like is to have a 'report error' SubVI which I put on the error out of each state machine (between the case structure and the while loop border). This VI sends the error (along with any additional debug information you want such as the 'state', a timestamp etc.) to the main state machine (or to a specific error handler state machine) which can then log/report the error (I sometimes put them into a lossy queue so I can see how frequently the error occurs etc.) and decide what action to take.


How does it send the error one level higher, by what means? Global variable, queue, something else? Could you please post an example?

0 Kudos
Message 5 of 15
(4,504 Views)

My QMH-based acquisition program "inverts" your model.  Note that the QMH, itself, can be considered a State Machine, but one that is (in my mind) better suited to an "executive" role, managing the total Program flow, including Front Panel, Initialization, Setup/TearDown, and Error Handling.  When it determines that it is time for Data Acquisition to take place, it tells the State Machine to start running (in my case, the State Machine runs in an Asynchronous Loop, getting started with a set of References that can serve as an immediate Communication Channel).  When the State Machine needs to tell the QMH something ("Hey, there's an Error Here!"), it "sends a Message" back to the QMH.  Similarly, if it needs to send data back, it Sends a Message.  Works pretty well here ...

 

Bob Schor

0 Kudos
Message 6 of 15
(4,503 Views)

@Bob_Schor wrote:

My QMH-based acquisition program "inverts" your model.  Note that the QMH, itself, can be considered a State Machine, but one that is (in my mind) better suited to an "executive" role, managing the total Program flow, including Front Panel, Initialization, Setup/TearDown, and Error Handling.  When it determines that it is time for Data Acquisition to take place, it tells the State Machine to start running (in my case, the State Machine runs in an Asynchronous Loop, getting started with a set of References that can serve as an immediate Communication Channel).  When the State Machine needs to tell the QMH something ("Hey, there's an Error Here!"), it "sends a Message" back to the QMH.  Similarly, if it needs to send data back, it Sends a Message.  Works pretty well here ...

 

Bob Schor


I cannot change my whole architecture again 😄
But I still need a solution to adjust my code as best as possible.

0 Kudos
Message 7 of 15
(4,489 Views)

I would either pass the 'main' state machine (a QMH) queue reference into the SubVIs, make it a named queue and obtain the reference within the 'report error' VI, or perhaps even hold the reference in an FGV.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 8 of 15
(4,485 Views)

@Sam_Sharp wrote:

I would either pass the 'main' state machine (a QMH) queue reference into the SubVIs, make it a named queue and obtain the reference within the 'report error' VI, or perhaps even hold the reference in an FGV.


So essentially I would have one queue "down" from the "main state machine" that defines how my program runs to the instrument. And another queue "up" to report back. That would work I guess, thanks!

 

But I have several instruments (4 I think) that - at least that is the current plan - would have their own subVIs and queues. Can I use your solution then as well?

0 Kudos
Message 9 of 15
(4,440 Views)

Yes, you would end up having 5 queues. One for each instrument and one for your 'main' state machine. Your main state machine enqueues to the instruments for controlling them, and the instruments can enqueue to the main state machine for reporting errors, passing data etc.


LabVIEW Champion, CLA, CLED, CTD
(blog)
0 Kudos
Message 10 of 15
(4,431 Views)