I am having difficulties with EasyTab_SetTabAttribute(panel, tabCtrl, tabPanel, ATTR_EASY_TAB_DIMMED, flag) in my multi-threaded data acquisition application.
The application is designed in two tabs, each coordinating a different measurement (but sharing underlying hardware). I want to use the DIMMED feature of the tabs to enforce resource locks (can't switch tabs while an acquisition is in progress, but before and after is OK).
My code is designed in two threads. The main thread deals with the GUI...the second thread performs a (polled) data acquisition). On "Start" button press (in the main thread), I dim the other tab (the one not currently in use) and start up a data acquisition procedure in the second thread. At the completion of the data acquisition procedure (and in the acquisition thread), I attempt to undim the tab which was dimmed earlier...like this:
/* GLOBALS */
int mainPnl, tabCtrl, acqPnl1, acqPnl2;
int threadPool, threadTID;
/* This call gets scheduled in the acquisition thread by the "Start" button callback (below) */
int CVICALLBACK _threadFunc( void * ) {
/* Perform data acquisiton */
EasyTab_SetTabAttribute(mainPnl, tabCtrl, acqPnl2, ATTR_EASY_TAB_DIMMED, 0);
}
/* This function gets called in the GUI thread by the "Start" button in Acquisition panel 1 to start the ball rolling */
int CVICALLBACK cbHandleStartButtonInAcq1(...) {
EasyTab_SetTabAttribute(mainPnl, tabCtrl, acqPnl2, ATTR_EASY_TAB_DIMMED, 1);
CmtScheduleThreadPoolFunction(threadPool, _threadFunc, NULL, &threadTID);
}
(Yes, I've left out the event switch() statements and the return statements from the snippet, but I think you get my meaning).
The problem is this...The first SetTabAttribute (the one in the button callback) works perfectly (the other tab is dimmed as expected). However, the second SetTabAttribute (called from the acquisition thread) does not undim the other tab (does not return any error code, either).
I'm sure my problem has something to do with the thread interactions. I've tried many variations to help locate the problem:
1) This same structure works perfectly for other (non-easytab) controls on the panels using SetCtrlAttribute(..., 0/1).
2) Placing another SetTabAttribute(..., 0) in the button callback immediately after the existing one which dims the tab functions as expected. Tab is (presumably) dimmed, and then undimmed.
I've added the EasyTab source to my project and traced through the execution and all appears OK (same operations occur for both DIM and UNDIM calls). It's almost as if the EasyTab is undimming, but not recognizing that it's status has been changed. Does anyone have any other recommendations?
Thanks in advance,
- Matt Pfenninger