LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

Error: Invalid Control ID

I get the error code = -13: Invalid Control ID at setctrlval() randomly in the middle of a test.
setctrlval() is updating a Numeric control on my UIR.
When the program stopped, I checked the value of the control ID and it was a valid number.
Could you please identify any possible reasons for this error to occur.
Thanks for your time
0 Kudos
Message 1 of 10
(4,411 Views)
In order for SetCtrlVal to work, the Panel Handle and the Control ID both need to be valid and the Control ID must be for a control on the Panel Handle panel. Your UIR .h file contains constant definitions for the panels and the controls. (Note: don't modify the UIR .h file: the UIR editor overwrites it whenever you edit the UIR).
Panel Handle is the output of LoadPanel, not the PANEL defined in the UIR .h file.
Are you using multiple panels?
Do you load each panel once then display or hide it or do you load and discard any panels repeatedly?
0 Kudos
Message 2 of 10
(4,407 Views)
I do use multiple panels:
if ((frntPanel = LoadPanel (0, "TestSetUp0316.uir", FRNT_PANEL)) < 0)
return -1;
if ((dataDispPanel = LoadPanel (0, "TestSetUp0316.uir", DATAPLOT)) < 0)
return -1;

if ((cvread = LoadPanel (0, "TestSetUp0316.uir", CTREAD)) < 0)
return -1;

I made all Panels top level panels for simplicity.

And I have a command button on the Panel CTREAD that displays the panel DATAPLOT, when clicked.

The Panel DATAPLOT is hidden using HidePanel when you click the button Close.
It is updated with graphs every ten seconds even if not displayed.

the error Invalid control ID occurred after 30 min of testing.
Please advise,
Thanks
0 Kudos
Message 3 of 10
(4,402 Views)
Have you tried to make one of the two panels "son" of the other?
Maybe it's safer.

Do you get the error if you select panels, or just letting go the application all by itself, touching nothing?
0 Kudos
Message 4 of 10
(4,388 Views)
Did the program previously successfully write to the numeric control before you got the error?
Have you verified that SetCtrlVal uses the panel handle (e.g. dataDispPanel) and not the panel constant (e.g. DATAPLOT)?
Are your panel handles defined as globals?
Have you verified that your panel handle hasn't been unintentionally changed?
When you said in your first post that after the crash the value of the control ID was a valid number, did you mean that it matched the number shown in the UIR .h file?
In your call to SetCtrlVal, do you use a constant for the control ID, e.g. DATAPLOT_NUMERIC (format PANEL_CONTROL) or a variable?
0 Kudos
Message 5 of 10
(4,376 Views)
...are you deleting your old plots?
.
0 Kudos
Message 6 of 10
(4,361 Views)
Yes the program run fo 30 min without a problem and then generated the error.
here is the command I am using:
SetCtrlVal (dataDispPanel, DATAPLOT_TIMETOSOAK, soak_secs_to_go);
where dataDisPanel has been defined in:
if ((dataDispPanel = LoadPanel (0, "TestSetUp0316.uir", DATAPLOT)) < 0)
return -1;
>>As you can see, in my call to SetCtrlVal I use a constant control ID DATAPLOT_TIMETOSOAK

>>dataDispPanel is declared as a global in the C file where the Loadpanel() and SetCtrlVal() are used.
>>Loadpanel() is used in the main() function
>>SetCtrlVal() is used in a thread that is added to the pool at a click of a commad button "Run Test"
>>The panel handle "dataDispPanel" is being declared as an extern variable in an other C file, but it is not being discarded by any other thread.
>>The commad DiscardPanel (dataDispPanel); is only used if the "Quit" button is clicked.
>>Actually, when I got the error I just verified that DATAPLOT_TIMETOSOAK was a number but I didn't check if the number was matching the one in the uir.h

>>Also, I run a 13h test last night and the error didn't occur!!!
0 Kudos
Message 7 of 10
(4,356 Views)
In this case the control I am using is a Numeric control it is not a graph.
I use :
SetCtrlAttribute (dataDispPanel, DATAPLOT_TIMETOSOAK, ATTR_VISIBLE, 0);
when I am done displaying its value, but I make it visible again when I need to.
0 Kudos
Message 8 of 10
(4,355 Views)
I only discard the panel at the Quit button click
0 Kudos
Message 9 of 10
(4,354 Views)
I will make this change for my next run..
The funny thing about this error is that it happens randomly.
So I will make the change and see if the error occurs again. If not we'll know it was maybe that...
0 Kudos
Message 10 of 10
(4,353 Views)