08-19-2009 09:55 AM
last thing , I added a reset button. I wanted to know is there option where in i can reset the all the switches back to the blank space. instead of all 00000000.
you see what im talking about in the attachment.
08-19-2009 10:28 AM
Darnell:
Your switch output controls are string controls. To clear them, in the callback for your Reset button, just SetCtrlVal to "" like the following.
SetCtrlVal (panelHandle, PANEL_BINARY_READ_6, "");
P.S. In your posting, you don't need to include the .CDB file, .NIOBJ file, or .RES file. To debug your project, we'll just rebuild it anyway. Your posting will be much smaller without those large and unnecessary file. We really just need the .prj, .c, .h, and .uir files.
P.P.S. Here's a previous posting offering suggestions on learning to use LabWindows/CVI. There are a bunch of good links there for you.
08-19-2009 10:50 AM - edited 08-19-2009 10:55 AM
You may also want to reset your numeric controls by setting them to 0. For example:
SetCtrlVal (panelHandle, PANEL_NUMERIC_2, 0);
I suggested earlier that you make your control names more meaningful. You should at least change the names to make the relationships between controls clearer. For example, now Switch 1 uses NUMERIC_2 and BINARY_READ_6. This will make the relationships harder to keep track of, which will make editing and debugging much harder. Often a little more work up front (like carefully choosing control names) will save you a lot of work later on.
Here's the link I mentioned earlier on tips for learning CVI.
http://forums.ni.com/ni/board/message?message.uid=365757#U365757
08-19-2009 05:55 PM
08-19-2009 06:08 PM
The name change was just a suggestion. Take it or leave it.
But...
The more code you write with the old names, the harder it will be to change them later.
New names will also help you understand the logic. It is easier to understand (because it's more logical) that Switch 1 is related to NUMERIC_1 and BINARY_READ_1 than to understand that Switch 1 is related to NUMERIC_2 and BINARY_READ_6.
It is good practise to follow some good guidelines from the beginning rather than making "corrections" later. Once you get something working, it's harder to justify going back to change them. But if you do things smarter (in my opinion) from the beginning, you save time now and later, and help the programmer who follows you understand what you have done.
08-19-2009 06:29 PM
08-19-2009 08:00 PM
// 472, 1 syntax error; found 'int' expecting ';'.
// 485, 37 Array assignments are illegal.
// 485, 37 Lvalue required.
okay this function , i did good all the way until i got to this point, Im trying to set the temp from my gui and then im trying to send it to the instrument,
im coming up with this three errors .
im still trying as we speak, so i need a lil help with this part
08-20-2009 08:24 AM
When you post an error message, it would help us to know in which file the error occurred.
When you get a message similar to syntax error; found 'int' expecting ';' it means that you didn't correctly terminate a previous statement with a ';'. Start at line 472 (in whatever file you got the error) and work back up till you find the line that didn't end in a ';'
08-20-2009 11:44 AM
//lines 467 to 468 i fix the errors but is that the correct way.
Im trying to have the option to set the temp from my gui to the instrument. is that the correct way.
//dont pay attn to the stuff thats commented out
int CVICALLBACK temp_setting (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int b ;
int temp_setting=25;
//char send_data[64];
//char msg1[80]={"hello"};
switch (event)
{
case EVENT_COMMIT:
GetCtrlVal (chiller, CHILLER_TEMP_SET, &temp_setting);
// SetCtrlVal (chiller,CHILLER_TEMP_SET,temp_setting);
send_data[temp_setting];
ComWrt (1, send_data, 6);//RS232 CMD
break;
case EVENT_RIGHT_CLICK:
/* Code that responds to a right */
//SetCtrlVal (chiller, CHILLER_MSG_BOARD, msg1);
break;
}
return 0;
}