📄 carl.c
字号:
{
status =age441x_configureAveraging (EPMid, AGE441X_CHANNEL_B, VI_ON, 4);
Delay(0.5);
status =age441x_linearityCorrection (EPMid, AGE441X_CHANNEL_B, AGE441X_LINCORR_DTYP);
Delay(0.5);
//readout the power meter
status = age441x_configureMeasurement (EPMid,2 , AGE441X_MEAS_SINGLE, AGE441X_CHANNEL_B,
AGE441X_CHANNEL_A, 4, AGE441X_UNIT_DBM);
Delay(1);
}
sprintf(temp," frequency(MHz) PowerMeterB Marker Test Result SPlitter error\n");
SetCtrlVal(panel,control,temp);
WriteFile (datafile, temp, StringLength(temp));
for (a=0;a<1;a++)
{
sprintf(temp,"the chamber temperature %d is ok? ",a+1);
//MessagePopup(" ",temp);
stop=1;
sprintf(temp,"---------the temperature %d test data------------\n",a+1);
SetCtrlVal(panel,control,temp);
WriteFile (datafile, temp, StringLength(temp));
while (stop==1)
{
for(b=0;b<2;b++)
{
status = viPrintf (analyzerid, ":SENSe:POWer:RF:ATTenuation %d dB\n",atten[b]);
Delay(0.2);
status = viPrintf (analyzerid, ":DISPlay:WINDow:TRACe:Y:RLEVel 0 dBm\n"); // reference level
Delay(0.2);
sprintf(temp,"---------the Source %ddBm test data------------\n",ss[b]);
SetCtrlVal(panel,control,temp);
WriteFile (datafile, temp, StringLength(temp));
status = viQueryf (analyzerid, ":DEBug:REMote:TEMPerature?\n","%s",temperature);
Delay(1);
sprintf (temp, "\n****HouYi Temperature: %s\n",temperature);
SetCtrlVal (panel, control, temp);
Delay(0.2);
WriteFile (datafile, temp, StringLength(temp));
for (c=0;c<FreqNum;c++)
{
ViReal64 valueB;
double marker;
//set freq
status = viPrintf(handle_ss,":FREQuency:FIXed %lf MHz\n",frequency[c]);
status = viPrintf(handle_ss,":POWer %d dBm\n",ss[b]);
status = viPrintf(handle_ss,":OUTPut ON\n");
status = viPrintf (analyzerid, ":SENSe:FREQuency:CENTer %lf MHz\n",frequency[c]);
Delay(1);
//test data
status = viPrintf (analyzerid, ":CALCulate:MARKer1:MAXimum\n");
Delay(0.1);
status = viQueryf (analyzerid, ":CALCulate:MARKer1:Y?\n", "%lf", &marker);
Delay(0.2);
status = age441x_read (EPMid, 2, AGE441X_MEAS_SINGLE, &valueB);
Delay(0.5);
sprintf(temp," %6.1f %6.2f %6.2f %6.2f %6.2f\n",frequency[c],valueB,marker,marker-valueB-SplitterError[c],SplitterError[c]);
SetCtrlVal(panel,control,temp);
WriteFile (datafile, temp, StringLength(temp));
}
}
//save stop time
GetCurrentDateTime (&teststoptime);
FormatDateTimeString (teststoptime, "%Y-%m-%d %H:%M:%S", time, sizeof(time));
sprintf (temp, " STOPTIME: %s \n", time);
WriteFile (datafile, temp, StringLength(temp));
}
}
CloseFile (datafile);
return 0;
}
HRESULT ClearObjHandle(CAObjHandle *objHandle)
{
HRESULT error = 0;
if ((objHandle) && (*objHandle))
{
error = CA_DiscardObjHandle (*objHandle);
*objHandle = 0;
}
return error;
}
/*
static void ReportAppAutomationError (HRESULT hr)
{
char errorBuf[256];
if (hr < 0) {
CA_GetAutomationErrorString (hr, errorBuf, sizeof (errorBuf));
MessagePopup (" ", errorBuf);
}
return;
}
*/
//----------------------------------------------------------------------------
// ShutdownExcel
//----------------------------------------------------------------------------
static int ShutdownExcel(void)
{
HRESULT error = 0;
ClearObjHandle (&ExcelWorksheetHandle);
ClearObjHandle (&ExcelSheetsHandle);
ClearObjHandle (&ExcelWorkbookHandle);
if (ExcelWorkbooksHandle)
{
// Close workbook without saving
error = Excel_WorkbookClose (ExcelWorkbooksHandle, NULL, CA_VariantBool (VFALSE),
CA_DEFAULT_VAL, CA_VariantBool (VFALSE));
ClearObjHandle (&ExcelWorkbooksHandle);
}
//ClearObjHandle (&ExcelWorkbooksHandle);
if (ExcelAppHandle)
{
if (excelLaunched)
{
// Quit the Application
error = Excel_AppQuit (ExcelAppHandle, &ErrorInfo);
}
ClearObjHandle (&ExcelAppHandle);
}
return 0;
//Error:
//if (error < 0)
//ReportAppAutomationError (error);
//return error;
}
int excel_npi(char* serial,char* b,char* rfbk,char* ctbk,char* keybk,char* version,int tg,int pa,char* NPItime,char* michecktime,char *excelfilename)
{
char cellrange[300];
//CAObjHandle whandle;
//FILE *filehandle;
int error;
int filesize,exist ;
char position[15][150];
int rownumber;
//char *mcu,*dsp,*fpga;
bsp = strtok (version, ",");
mcuu = strtok (NULL, ",");
dspp = strtok (NULL, ",");
fpgaa = strtok (NULL, ",");
;
//connect excel
SetWaitCursor (1);
error = Excel_NewApp (NULL, 0, LOCALE_NEUTRAL, 0, &ExcelAppHandle);
SetWaitCursor (0);
if (error<0)
{
goto quitexcel;
}
error = Excel_SetProperty (ExcelAppHandle, NULL, Excel_AppVisible, CAVT_BOOL, VFALSE);
if (error<0)
{
goto quitexcel;
}
MakeApplicationActive ();
excelLaunched = 1;
// open file
error = Excel_GetProperty (ExcelAppHandle, NULL, Excel_AppWorkbooks,
CAVT_OBJHANDLE, &ExcelWorkbooksHandle);
if (error<0)
{
goto quitexcel;
}
exist = GetFileInfo (excelfilename, &filesize);
if (exist==0)
{
ExcelRpt_WorkbookNew (ExcelAppHandle, &ExcelWorkbooksHandle);
}
if (exist==1)
{
error = Excel_WorkbooksOpen (ExcelWorkbooksHandle, NULL, excelfilename, CA_DEFAULT_VAL,
CA_DEFAULT_VAL, CA_DEFAULT_VAL,
CA_DEFAULT_VAL, CA_DEFAULT_VAL,
CA_DEFAULT_VAL, CA_DEFAULT_VAL,
CA_DEFAULT_VAL, CA_DEFAULT_VAL,
CA_DEFAULT_VAL, CA_DEFAULT_VAL,
CA_DEFAULT_VAL, &ExcelWorkbookHandle);
}
error = Excel_GetProperty (ExcelAppHandle, NULL, Excel_AppSheets,
CAVT_OBJHANDLE, &ExcelSheetsHandle);
error = Excel_SheetsItem (ExcelSheetsHandle, NULL, CA_VariantInt(1),
&ExcelWorksheetHandle);
error = Excel_WorksheetActivate (ExcelWorksheetHandle, NULL);
if (exist==1)
{
status = ExcelRpt_Find (ExcelWorksheetHandle, ExRConst_dataString, "FINISHED", "A1", ExRConst_Values, ExRConst_Whole,
ExRConst_ByColumns, ExRConst_Next, 1, 1, cellrange);
rownumber = strtol (&cellrange[3], NULL, 10);
}
if (exist==0)
{
rownumber=1;
sprintf(position[0],"A%d",rownumber);
sprintf(position[1],"B%d",rownumber);
sprintf(position[2],"C%d",rownumber);
sprintf(position[3],"D%d",rownumber);
sprintf(position[4],"E%d",rownumber);
sprintf(position[5],"F%d",rownumber);
sprintf(position[6],"G%d",rownumber);
sprintf(position[7],"H%d",rownumber);
sprintf(position[8],"I%d",rownumber);
sprintf(position[9],"J%d",rownumber);
sprintf(position[10],"K%d",rownumber);
//sprintf(position[11],"L%d",rownumber);
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[0], ExRConst_dataString, "MAIN_SERIAL");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[1], ExRConst_dataString, "RF_SERIAL");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[2], ExRConst_dataString, "CT_SERIAL");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[3], ExRConst_dataString, "KEY_SERIAL");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[4], ExRConst_dataString, "TG");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[5], ExRConst_dataString, "PA");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[6], ExRConst_dataString, "BSP-VERSION");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[7], ExRConst_dataString, "MCU-VERSION");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[8], ExRConst_dataString, "DSP-VERSION");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[9], ExRConst_dataString, "FPGA-VERSION");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[10], ExRConst_dataString, "NPI_TIME");
//ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[11], ExRConst_dataString, "MI_TIME");
rownumber=2;
}
sprintf(position[0],"A%d",rownumber);
sprintf(position[1],"B%d",rownumber);
sprintf(position[2],"C%d",rownumber);
sprintf(position[3],"D%d",rownumber);
sprintf(position[4],"E%d",rownumber);
sprintf(position[5],"F%d",rownumber);
sprintf(position[6],"G%d",rownumber);
sprintf(position[7],"H%d",rownumber);
sprintf(position[8],"I%d",rownumber);
sprintf(position[9],"J%d",rownumber);
sprintf(position[10],"K%d",rownumber);
//sprintf(position[11],"L%d",rownumber);
sprintf(position[12],"A%d",rownumber+1);
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[0], ExRConst_dataString, serial);
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[1], ExRConst_dataString, rfbk);
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[2], ExRConst_dataString, ctbk);
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[3], ExRConst_dataString, keybk);
if (tg==1)
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[4], ExRConst_dataString, "ON");
else
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[4], ExRConst_dataString, "OFF");
if (pa==1)
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[5], ExRConst_dataString, "ON");
else
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[5], ExRConst_dataString, "OFF");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[6], ExRConst_dataString, bsp);
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[7], ExRConst_dataString, mcuu);
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[8], ExRConst_dataString, dspp);
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[9], ExRConst_dataString, fpgaa);
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[10], ExRConst_dataString, NPItime);
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[12], ExRConst_dataString, "FINISHED");
//SAVE excell
SetWaitCursor (1);
if (exist==1)
Excel_WorkbookSave (ExcelWorkbookHandle, NULL);
if (exist==0)
ExcelRpt_WorkbookSave (ExcelWorkbooksHandle, excelfilename, ExRConst_DefaultFileFormat);
Delay(1);
SetWaitCursor (0);
SetWaitCursor (1);
ShutdownExcel();
SetWaitCursor (0);
return 1;
//quit file
quitexcel:
ShutdownExcel();
SetWaitCursor (0);
return 0;
}
int excel(char* serial,char* b,char* rfbk,char* ctbk,char* keybk,char* version,int tg,int pa,char* NPItime,char* michecktime,char *excelfilename)
{
char cellrange[300];
int error;
int filesize,exist ;
char position[20][80];
int rownumber;
//connect excel
SetWaitCursor (1);
error = Excel_NewApp (NULL, 0, LOCALE_NEUTRAL, 0, &ExcelAppHandle);
SetWaitCursor (0);
if (error<0)
{
goto quitexcel;
}
error = Excel_SetProperty (ExcelAppHandle, NULL, Excel_AppVisible, CAVT_BOOL, VFALSE);
if (error<0)
{
goto quitexcel;
}
MakeApplicationActive ();
excelLaunched = 1;
error = Excel_GetProperty (ExcelAppHandle, NULL, Excel_AppWorkbooks,
CAVT_OBJHANDLE, &ExcelWorkbooksHandle);
if (error<0)
{
goto quitexcel;
}
exist = GetFileInfo (excelfilename, &filesize);
if (exist==0)
{
ExcelRpt_WorkbookNew (ExcelAppHandle, &ExcelWorkbooksHandle);
}
if (exist==1)
{
error = Excel_WorkbooksOpen (ExcelWorkbooksHandle, NULL, excelfilename, CA_DEFAULT_VAL,
CA_DEFAULT_VAL, CA_DEFAULT_VAL,
CA_DEFAULT_VAL, CA_DEFAULT_VAL,
CA_DEFAULT_VAL, CA_DEFAULT_VAL,
CA_DEFAULT_VAL, CA_DEFAULT_VAL,
CA_DEFAULT_VAL, CA_DEFAULT_VAL,
CA_DEFAULT_VAL, &ExcelWorkbookHandle);
}
error = Excel_GetProperty (ExcelAppHandle, NULL, Excel_AppSheets,
CAVT_OBJHANDLE, &ExcelSheetsHandle);
error = Excel_SheetsItem (ExcelSheetsHandle, NULL, CA_VariantInt(1),
&ExcelWorksheetHandle);
error = Excel_WorksheetActivate (ExcelWorksheetHandle, NULL);
if (exist==0)
{
rownumber=1;
sprintf(position[0],"A%d",rownumber);
sprintf(position[1],"B%d",rownumber);
sprintf(position[2],"C%d",rownumber);
sprintf(position[3],"D%d",rownumber);
sprintf(position[4],"E%d",rownumber);
sprintf(position[5],"F%d",rownumber);
sprintf(position[6],"G%d",rownumber);
sprintf(position[7],"H%d",rownumber);
sprintf(position[8],"I%d",rownumber);
sprintf(position[9],"J%d",rownumber);
sprintf(position[10],"K%d",rownumber);
sprintf(position[11],"L%d",rownumber);
sprintf(position[12],"M%d",rownumber);
sprintf(position[13],"N%d",rownumber);
sprintf(position[14],"O%d",rownumber);
sprintf(position[15],"P%d",rownumber);
sprintf(position[16],"Q%d",rownumber);
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[0], ExRConst_dataString, "MAIN_SERIAL");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[1], ExRConst_dataString, "RF_SERIAL");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[2], ExRConst_dataString, "CT_SERIAL");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[3], ExRConst_dataString, "KEY_SERIAL");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[4], ExRConst_dataString, "TG");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[5], ExRConst_dataString, "PA");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[6], ExRConst_dataString, "BSP-VERSION");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[7], ExRConst_dataString, "MCU-VERSION");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[8], ExRConst_dataString, "DSP-VERSION");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[9], ExRConst_dataString, "FPGA-VERSION");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[10], ExRConst_dataString, "NPI_TIME");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[11], ExRConst_dataString, "MI_TIME");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[12], ExRConst_dataString, "ITEM_NO.");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[13], ExRConst_dataString, "Battery");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[14], ExRConst_dataString, "UK6");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[15], ExRConst_dataString, "AMFM");
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[16], ExRConst_dataString, "ASKFSK");
rownumber=2;
sprintf(position[0],"A%d",rownumber);
sprintf(position[1],"B%d",rownumber);
sprintf(position[2],"C%d",rownumber);
sprintf(position[3],"D%d",rownumber);
sprintf(position[4],"E%d",rownumber);
sprintf(position[5],"F%d",rownumber);
sprintf(position[6],"G%d",rownumber);
sprintf(position[7],"H%d",rownumber);
sprintf(position[8],"I%d",rownumber);
sprintf(position[9],"J%d",rownumber);
sprintf(position[10],"K%d",rownumber);
sprintf(position[11],"L%d",rownumber);
sprintf(position[12],"M%d",rownumber);
sprintf(position[13],"N%d",rownumber);
sprintf(position[14],"O%d",rownumber);
sprintf(position[15],"P%d",rownumber);
sprintf(position[16],"Q%d",rownumber);
sprintf(position[17],"A%d",rownumber+1);
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[0], ExRConst_dataString, serial);
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[1], ExRConst_dataString, rfbk);
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[2], ExRConst_dataString, ctbk);
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[3], ExRConst_dataString, keybk);
if (tg==1)
ExcelRpt_SetCellValue (ExcelWorksheetHandle, position[4], ExRConst_dataString, "ON");
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -