LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

simple printing of digits on numeric panel

Solved!
Go to solution

HELLO,

 

I am new to lab windows CVI, all I have to do this,just printing number on numeric panel using start and stop button.

 but I am not getting desired result

 before pressing starting button my timer starts automatically,number displayed  on screen and  after prseeing start button numeric number stops.

So, my start button function is not working properly.

 

Kindley give me suggestion.

 

THANK YOU

 

0 Kudos
Message 1 of 5
(4,674 Views)

Earlier, in a closely related thread, I made some suggestions. It's not clear if you followed them....

 

In addition, if your code is not working, it would be useful to post it here if you want some feedback on it...

 

...and, of course, if the topic is the same as in your previous post, you should stick to that one and not duplicate your issue Smiley Wink

0 Kudos
Message 2 of 5
(4,672 Views)

 Thank's for your suggestion..actually I tried to attach my 'c' file here but due to some problem it was not sucessful.

and yeah, its similar step to previous one..but its a basic step..of that..and I went through examples..but there is something I didnt get.

check my program.

 

Thank you

#include <ansi_c.h>
#include <cvirte.h>		
#include <userint.h>
#include "display.h"

static int panelHandle;




int main (int argc, char *argv[])
{
	if (InitCVIRTE (0, argv, 0) == 0)
		return -1;	/* out of memory */
	if ((panelHandle = LoadPanel (0, "display.uir", PANEL)) < 0)
		return -1;
	DisplayPanel (panelHandle);
	RunUserInterface ();
	DiscardPanel (panelHandle);
	return 0;
}

int CVICALLBACK START01 (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{   int val;
	switch (event)
	{
		case EVENT_COMMIT:
			
			GetCtrlVal(panel, control, &val);
			SetCtrlAttribute(panelHandle,PANEL_TIMER,ATTR_ENABLED,val);
			
			ProcessSystemEvents();

			break;
		case EVENT_DISCARD:

			break;
	}
	return 0;
}

int CVICALLBACK QUIT02 (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_COMMIT:
			QuitUserInterface (0);
			break;
		case EVENT_DISCARD:

			break;
	}
	return 0;
}

int CVICALLBACK DISPLAY03 (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{
	switch (event)
	{
		case EVENT_COMMIT:

			break;
		case EVENT_DISCARD:

			break;
	}
	return 0;
}

int CVICALLBACK TIMER04 (int panel, int control, int event,
		void *callbackData, int eventData1, int eventData2)
{	double value;
	switch (event)
	{
		case EVENT_TIMER_TICK:
             
			
		
			GetCtrlVal(panelHandle,PANEL_DISPLAY,&value);
			SetCtrlVal(panelHandle,PANEL_DISPLAY,value+1);
				

			break;
		case EVENT_DISCARD:

			break;
	}
	return 0;
}

 

0 Kudos
Message 3 of 5
(4,663 Views)
Solution
Accepted by topic author vishalnit93

OK...:

 

1) As I understand your problem description your timer starts automatically and is stopped when you push the START button. You do not want it to be started automatically but only after pushing the START button. If so, then:

 

2a) I assume that you have a UI timer which is enabled by default. Check in the UI editor (Edit Timer / Control Settings / Enabled ) and remove the checkmark. This way you will have a timer but the timer is off until it is started / enabled explicitly by your code.

2b) In your START callback you are setting the enabled status of the timer to val - if you want to use the START button to start the timer the value should be 1 instead, so simply remove the GetCtrlVal line and replace val by 1.

3) add a STOP callback where you stop the timer by setting the enabled attribute to zero.

 

your code:    case EVENT_COMMIT:
			
			GetCtrlVal(panel, control, &val);
			SetCtrlAttribute(panelHandle,PANEL_TIMER,ATTR_ENABLED,val);

changed code: case EVENT_COMMIT:
			
			GetCtrlVal(panel, control, &val);
			SetCtrlAttribute(panelHandle,PANEL_TIMER,ATTR_ENABLED,1);

Message 4 of 5
(4,660 Views)

Thanks Smiley Happy

0 Kudos
Message 5 of 5
(4,657 Views)