1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
| /*----------------------------------------------------------------------------------------------------*/
/* Set */
/*----------------------------------------------------------------------------------------------------*/
void SetPanelParms(void)
{
SetCtrlVal(panelHandle, PANEL_SHAPE, shape);
SetCtrlVal(panelHandle, PANEL_CHANNEL, channel);
SetCtrlVal(panelHandle, PANEL_GROUP,group );
SetCtrlVal(panelHandle, PANEL_GAIN, gain);
SetCtrlVal(panelHandle, PANEL_MODE , mode);
}
/*----------------------------------------------------------------------------------------------------*/
/*Get the port confuguration parameters */
/*----------------------------------------------------------------------------------------------------*/
void GetPanelParms(void)
{
GetCtrlVal(panelHandle, PANEL_SHAPE, &shape);
GetCtrlVal(panelHandle, PANEL_CHANNEL, &channel);
GetCtrlVal(panelHandle, PANEL_GROUP,&group );
GetCtrlVal(panelHandle, PANEL_GAIN, &gain);
GetCtrlVal(panelHandle, PANEL_MODE , &mode);
}
/*---------------------------------------------------------------------------------------------------------*/
/*---------------------------------------------------------------------------------------------------------*/
int CVICALLBACK ShapeControl (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
int g = GetCtrlVal(panelHandle, PANEL_GROUP,&group);
switch (event)
{
case 1:
if(g==1)
Fmt(buffer_SEND,"%s","SS 1 1");
else
if(g==2)
Fmt(buffer_SEND,"%s","SS 2 1 ");
else
if(g==3)
Fmt(buffer_SEND,"%s","SS 3 1 ");
else
if(g==4)
Fmt(buffer_SEND,"%s","SS 4 1 ");
else
if(g==5)
Fmt(buffer_SEND,"%s","SS 5 1 ");
break;
case 2:
if(g==1)
Fmt(buffer_SEND,"%s","SS 1 2");
else
if(g==2)
Fmt(buffer_SEND,"%s","SS 2 2 ");
else
if(g==3)
Fmt(buffer_SEND,"%s","SS 3 2 ");
else
if(g==4)
Fmt(buffer_SEND,"%s","SS 4 2 ");
else
if(g==5)
Fmt(buffer_SEND,"%s","SS 5 2 ");
break;
case 3:
if(g==1)
Fmt(buffer_SEND,"%s","SS 1 3");
else
if(g==2)
Fmt(buffer_SEND,"%s","SS 2 3 ");
else
if(g==3)
Fmt(buffer_SEND,"%s","SS 3 3 ");
else
if(g==4)
Fmt(buffer_SEND,"%s","SS 4 3");
else
if(g==5)
Fmt(buffer_SEND,"%s","SS 5 3 ");
break;
case 4:
if(g==1)
Fmt(buffer_SEND,"%s","SS 1 4");
else
if(g==2)
Fmt(buffer_SEND,"%s","SS 2 4 ");
else
if(g==3)
Fmt(buffer_SEND,"%s","SS 3 4 ");
else
if(g==4)
Fmt(buffer_SEND,"%s","SS 4 4");
else
if(g==5)
Fmt(buffer_SEND,"%s","SS 5 4 ");
break;
}
return 0;
}
/*---------------------------------------------------------------------------------------------------------*/
/* Send the data to the port */
/*---------------------------------------------------------------------------------------------------------*/
int CVICALLBACK SendCallBack (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
GetPanelParms();
case EVENT_COMMIT:
GetPanelParms();
RS232Error = ReturnRS232Err();
if(RS232Error)
DisplayRS232Error();
strcat( buffer_SEND , "\r");
stringsize= StringLength(buffer_SEND);
bytes_sent= ComWrt(comport,buffer_SEND,stringsize ) ;
printf("%s \n",buffer_SEND);
break;
}
return 0;
}
/*------------------------------------------------------------------------------------------------------------*/
/* Flush the input/output queue : remove all the characters from the input and output queue of the specified */
/* port */
/*------------------------------------------------------------------------------------------------------------*/
int CVICALLBACK FlushCallBack (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
FlushInQ(comport);
MessagePopup("RS232 Message", "Input Queue Flushed");
FlushOutQ(comport);
MessagePopup("RS232 Message","Output Queue Flushed");
break;
}
return 0;
} |
Partager