📄 main_back.c
字号:
#include <ansi_c.h>
#include <rs232.h>
#include <cvirte.h> /* Needed if linking in external compiler; harmless otherwise */
#include <userint.h>
#include "interface.h"
#define BUFFERLENGTH 256
#define COM1 1
#define COM2 2
#define COM3 3
#define COM4 4
#define FAIL 1
#define PASS 0
#define VAL_RED 0xFF0000L
#define VAL_DEFAULT 0xCCFFFFL
//?&H00FFFFC0&
#define SPESTRLINES 10
#define SPESTRLINES2 3
struct SpecData
{
int PowerAvgH;
int PowerAvgL;
int PeakPhaseErrorH;
int PeakPhaseErrorL;
int RMSPhaseErrorH;
int RMSPhaseErrorL;
};
static int pnl;
int RS232Error,bytewrite,i,Inqlength,comport;
//int BackColor;
char buffer[BUFFERLENGTH];
float PeakPhaseErrorAvg,RMSPhaseErrorAvg,
FrequencyErrorAvg,BurstLengthAvg,PowerAvg;
//int PowerAvgH,PowerAvgL,PeakPhaseErrorH,PeakPhaseErrorL,
// RMSPhaseErrorH,RMSPhaseErrorL;
struct SpecData GSM900SpecData,PCN1800SpecData;
int InitTest()
{
PeakPhaseErrorAvg=0;
RMSPhaseErrorAvg=0;
FrequencyErrorAvg=0;
BurstLengthAvg=0;
PowerAvg=0;
return 0;
}
int ReadSpec()
{
FILE *stream;
int i,j,ret;
char tempstr[BUFFERLENGTH];
if((stream=fopen("AT.spe","r"))==NULL)
printf("The \"AT.spe\" is not opened!" );
else
{
for (i=0;i<SPESTRLINES;i++)
{
fscanf(stream,"%s",tempstr);
//size_t fread( void *buffer, size_t size, size_t count, FILE *stream );
//sscanf(stream,"%s",tempstr);
}
//GSM900 SpecData
ret=fscanf(stream,"%s\n%d,%d",tempstr,&GSM900SpecData.PowerAvgH,&GSM900SpecData.PowerAvgL);
ret=fscanf(stream,"%s\n%d,%d",tempstr,&GSM900SpecData.PeakPhaseErrorH,&GSM900SpecData.PeakPhaseErrorL);
ret=fscanf(stream,"%s\n%d,%d",tempstr,&GSM900SpecData.RMSPhaseErrorH,&GSM900SpecData.RMSPhaseErrorL);
for (i=0;i<SPESTRLINES2;i++)
{
fscanf(stream,"%s",tempstr);
}
//PCN1800 SpecData
ret=fscanf(stream,"%s\n%d,%d",tempstr,&PCN1800SpecData.PowerAvgH,&PCN1800SpecData.PowerAvgL);
ret=fscanf(stream,"%s\n%d,%d",tempstr,&PCN1800SpecData.PeakPhaseErrorH,&PCN1800SpecData.PeakPhaseErrorL);
ret=fscanf(stream,"%s\n%d,%d",tempstr,&PCN1800SpecData.RMSPhaseErrorH,&PCN1800SpecData.RMSPhaseErrorL);
fclose(stream);
}
return 0;
}
int MeasResultEvaluate(struct SpecData* specdata)
{
int flag;
flag=PASS;
if(PowerAvg>specdata->PowerAvgH||PowerAvg<specdata->PowerAvgL)
flag=FAIL;
if(PeakPhaseErrorAvg>specdata->PeakPhaseErrorH||PeakPhaseErrorAvg<specdata->PeakPhaseErrorL)
flag=FAIL;
if(RMSPhaseErrorAvg>specdata->RMSPhaseErrorH||RMSPhaseErrorAvg<specdata->RMSPhaseErrorL)
flag=FAIL;
return flag;
}
int main (int argc, char *argv[])
{
if (InitCVIRTE (0, argv, 0) == 0) /* Needed if linking in external compiler; harmless otherwise */
return -1; /* out of memory */
if ((pnl = LoadPanel (0, "interface.uir", PNL)) < 0)
return -1;
DisplayPanel (pnl);
RunUserInterface ();
return 0;
}
int TestMain()
{
SetPanelAttribute (pnl, ATTR_BACKCOLOR, VAL_DEFAULT);
ReadSpec();
comport=COM1;
RS232Error=OpenComConfig (comport, "", 38400, 0, 8, 1, 512, 512);
SetCTSMode (comport, LWRS_HWHANDSHAKE_CTS_RTS);
strcpy(buffer,"*cls\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
//GSM900/GSM1800
//strcpy(buffer,"conf:syst gsm900\n");
// strcpy(buffer,"conf:syst gsm900,gsm1800\n");
strcpy(buffer,"conf:syst GSMPCN\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
//Turn on the MS
//Config to BCH+TCH Mode
strcpy(buffer,"CONF:GSM900:BS:CCH:ARFC 30\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
strcpy(buffer,"CONF:GSM900:BS:TCH:ARFC 62\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
//Antenna Parameters check
//CONFigure:<system>:PATTenuation:LEVel <RX>, <TX>
strcpy(buffer,"CONF:GSM900:PATT:LEV 17,17\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
//Average Power(62,5)
strcpy(buffer,"conf:gsm:ms:tch:plev 5\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
/*
strcpy(buffer,"conf:gsm900:BS:CCH:ARFC 63\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
strcpy(buffer,"conf:gsm900:BS:TCH:ARFC 27\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
strcpy(buffer,"CALL:BSOR\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
strcpy(buffer,"CALL:bSR\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
*/
strcpy(buffer,"CALL:MSOR\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
// strcpy(buffer,"CALL:MSIN:NUMB?\n");
// bytewrite=ComWrt (comport, buffer, strlen(buffer));
// Inqlength = GetInQLen (comport);
// ComRd (comport, buffer, Inqlength); //?
/*
//Single Power
strcpy(buffer,"MEAS:RFTR:POW?\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
Inqlength = GetInQLen (comport);
ComRd (comport, buffer, Inqlength); //?
*/
//Average Power
strcpy(buffer,"MEAS:ARR:RFTR:GRO:ALL:MAV? 10\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
Inqlength = GetInQLen (comport);
ComRd (comport, buffer, Inqlength); //?
sscanf(buffer,"%e,%e,%e,%e,%e",&PeakPhaseErrorAvg,
&RMSPhaseErrorAvg,
&FrequencyErrorAvg,
&BurstLengthAvg,
&PowerAvg);
if(MeasResultEvaluate(&GSM900SpecData)==FAIL)
{
//Fail report
GetPanelAttribute (pnl, ATTR_BACKCOLOR, &BackColor);
SetPanelAttribute (pnl, ATTR_BACKCOLOR, VAL_RED);
//SetCtrlVal (pnl, TEXTBOX_2, FAIL);
ResetTextBox (pnl, PNL_TEXTBOX_RESULT, "FAIL");
}
// SetPanelAttribute (pnl, ATTR_BACKCOLOR, VAL_RED);
// GetPanelAttribute (pnl, ATTR_BACKCOLOR, &BackColor);
// ResetTextBox (pnl, PNL_TEXTBOX_RESULT, "FAIL");
strcpy(buffer,"CALL:MSR\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
//Switch to DCS1800/PCN test mode
strcpy(buffer,"conf:syst PCN\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
//End
strcpy(buffer,"SYST:COMM:LOC\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
RS232Error=CloseCom (comport);
return 0;
}
int CVICALLBACK CALLBACK_Start (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_COMMIT:
InitTest();
//ReadSpec();
TestMain();
/*
comport=COM1;
RS232Error=OpenComConfig (comport, "", 38400, 0, 8, 1, 512, 512);
SetCTSMode (comport, LWRS_HWHANDSHAKE_CTS_RTS);
strcpy(buffer,"*cls\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
// strcpy(buffer,"conf:syst gsm900,gsm1800\n");
strcpy(buffer,"conf:syst gsm900\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
strcpy(buffer,"conf:gsm900:BS:CCH:ARFC 63\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
strcpy(buffer,"conf:gsm900:BS:TCH:ARFC 27\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
strcpy(buffer,"CALL:BSOR\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
strcpy(buffer,"CALL:bSR\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
strcpy(buffer,"CALL:MSOR\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
strcpy(buffer,"CALL:MSIN:NUMB?\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
Inqlength = GetInQLen (comport);
strcpy(buffer,"");
ComRd (comport, buffer, 5); //?
strcpy(buffer,"CALL:MSR\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
//End
strcpy(buffer,"SYST:COMM:LOC\n");
bytewrite=ComWrt (comport, buffer, strlen(buffer));
RS232Error=CloseCom (comport);
*/
break;
case EVENT_RIGHT_CLICK:
break;
}
return 0;
}
int CVICALLBACK Time (int panel, int control, int event,
void *callbackData, int eventData1, int eventData2)
{
switch (event)
{
case EVENT_TIMER_TICK:
//MessagePopup ("Timer", "Timer");
break;
}
return 0;
}
void CVICALLBACK FileOpen (int menuBar, int menuItem, void *callbackData,
int panel)
{
}
void CVICALLBACK Exit (int menuBar, int menuItem, void *callbackData,
int panel)
{
QuitUserInterface (0);
}
void CVICALLBACK OpenHistory (int menuBar, int menuItem, void *callbackData,
int panel)
{
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -