META_Factory.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:269k
- // if( is_calibration_start == false )
- // {
- // return;
- // }
- is_calibration_start = false;
- //////////////////////// RF calibration //////////////////////////////////////
- if( cbIP2->Checked ||
- cbAFC->Checked ||
- cbRxPathLoss->Checked ||
- cbTxIq->Checked ||
- cbTxPcl->Checked ||
- m_cbTrxOffset->Checked
- )
- {
- RCT_Dcl_Reset_Close();
- }
- //////////////////////// BT CAP ID calibration /////////////////////////////////////////
- if (m_cbBTCapID->Checked)
- {
- if (!m_btt_ctrl.BTT_Close(&m_sBtt))
- {
- PostMessage(
- this->Handle,
- WM_MF_BTT_CLOSE_FAIL,
- 0,
- 0
- );
- }
- }
- ///////////////////////////// ADC calibration /////////////////////////////////
- if(cbADC->Checked)
- {
- if( m_Dcs.vi )
- {
- SetNormalVoltage_CloseAgilentPowerSupply();
- }
- else
- {
- InitAgilentPowerSupply_SetNormalVoltage_CloseAgilentPowerSupply();
- }
- }
- PostMessage(
- this->Handle,
- WM_MF_CA_FAIL,
- 0,
- 0
- );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFatcory::after_Calibration_Fail(TObject *Sender)
- {
- after_Calibration_Fail_function();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFatcory::after_Calibration_Fail_function(void)
- {
- write_log();
- clear_log();
- write_result();
- clear_result();
- // bb_Start->Kind = bkOK;
- bb_Start->Tag = BUTTON_TAG_START;
- bb_Start->Enabled = true;
- bb_Start->Caption = "Start (F6)";
- if( cbIP2->Checked )
- {
- WriteIP2RxAmCalModeToNormal();
- }
- if( cbSaveBarcodeToFileFail->Checked )
- {
- SaveBarcodeToFile();
- }
- if( cbSaveBarcodeToNVRAMFail->Checked )
- {
- WriteBarcodeToNVRAM();
- }
- DisplayBarcodeAfterIncreasement( cbBarcodeIncreasementFail->ItemIndex );
- if( cbTurnOffPowerSupplyFail->Checked )
- {
- if( IS_AgilentPowerSupply_INITIALISE == true )
- {
- SetOffVoltage_CloseAgilentPowerSupply();
- }
- else
- {
- OpenOffCloseAgilentPowerSupply();
- }
- }
- if( cbTerminateMETAFail->Checked )
- {
- SaveFactoryUISetting();
- FormDestroy_function();
- }
- if (cbIP2->Checked ||
- cbAFC->Checked ||
- cbRxPathLoss->Checked ||
- cbTxIq->Checked ||
- cbTxPcl->Checked
- )
- {
- CRFSTOP RF_STOP_Obj;
- RF_STOP_Obj.REQ_Start();
- }
- MF_state = eInit;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFatcory::on_Calibration_TerminateSuccess(TObject *Sender)
- {
- is_calibration_start = false;
- DisableAllCalTimer();
- if (cbIP2->Checked ||
- cbAFC->Checked ||
- cbRxPathLoss->Checked ||
- cbTxIq->Checked ||
- cbTxPcl->Checked ||
- m_cbTrxOffset->Checked
- )
- {
- RCT_Dcl_Reset_Close();
- }
- //////////////////////// BT CAP ID calibration /////////////////////////////////////////
- if (m_cbBTCapID->Checked)
- {
- if (!m_btt_ctrl.BTT_Close(&m_sBtt))
- {
- PostMessage(
- this->Handle,
- WM_MF_BTT_CLOSE_FAIL,
- 0,
- 0
- );
- }
- }
- ///////////////////////////// ADC calibration /////////////////////////////////
- if( cbADC->Checked )
- {
- if( m_Dcs.vi )
- {
- SetNormalVoltage_CloseAgilentPowerSupply();
- }
- else
- {
- InitAgilentPowerSupply_SetNormalVoltage_CloseAgilentPowerSupply();
- }
- }
- PostMessage(
- this->Handle,
- WM_MF_CA_SUCCESS,
- 0,
- 0
- );
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFatcory::after_Calibration_TerminateSuccess(TObject *Sender)
- {
- CRFSTOP RF_STOP_Obj;
- RF_STOP_Obj.REQ_Start();
- if( ! cbIP2->Visible )
- {
- if( cbAFC->Checked &&
- cbRxPathLoss->Checked &&
- cbTxIq->Checked &&
- cbTxPcl->Checked &&
- cbADC->Checked
- )
- {
- lb_META_factory_status->Caption = " Calibration done!";
- }
- }
- else
- {
- if( cbIP2->Checked &&
- cbAFC->Checked &&
- cbRxPathLoss->Checked &&
- cbTxIq->Checked &&
- cbTxPcl->Checked &&
- cbADC->Checked
- )
- {
- lb_META_factory_status->Caption = " Calibration done!";
- }
- }
- write_log();
- clear_log();
- write_result(); // added by Andy Ueng
- clear_result(); // added by Andy Ueng
- //i_ID++; // marked by Andy Ueng
- // bb_Start->Kind = bkOK;
- bb_Start->Tag = BUTTON_TAG_START;
- bb_Start->Enabled = true;
- bb_Start->Caption = "Start (F6)";
- MF_state = eInit;
- if( cbIP2->Checked )
- {
- WriteIP2RxAmCalModeToNormal();
- }
-
- if( cbSaveBarcodeToFileSuccess->Checked )
- {
- SaveBarcodeToFile();
- }
- if( cbSaveBarcodeToNVRAMSuccess->Checked )
- {
- WriteBarcodeToNVRAM();
- }
- DisplayBarcodeAfterIncreasement( cbBarcodeIncreasementSuccess->ItemIndex );
-
- if( cbTurnOffPowerSupplySuccess->Checked )
- {
- if( IS_AgilentPowerSupply_INITIALISE == true )
- {
- SetOffVoltage_CloseAgilentPowerSupply();
- }
- else
- {
- OpenOffCloseAgilentPowerSupply();
- }
- }
- if( cbTerminateMETASuccess->Checked )
- {
- SaveFactoryUISetting();
- FormDestroy_function();
- }
- }
- //---------------------------------------------------------------------------
- void TfrmFatcory::wrap_log_file()
- {
- FILE *fp = fopen( as_LogFileName.c_str(), "at+");
- if ( fp == NULL )
- return;
- if ( filesize(fp) > (1024*1024*20) )
- {
- change_file_name( as_LogFileName);
- stLogFile->Caption = as_LogFileName;
- fclose(fp);
- if ((fp = fopen( as_LogFileName.c_str() ,"wt+"))
- == NULL)
- {
- //ShowMessage( "Cannot open output file: " + as_LogFileName );
- AnsiString as_warning_msg;
- as_warning_msg = "Cannot open output file: " + as_LogFileName;
- Application->MessageBox( as_warning_msg.c_str(), "Warning", MB_OK );
- return;
- }
- } // if
- fclose(fp);
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFatcory::bb_StartClick(TObject *Sender)
- {
- Calibration_Button_Click();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFatcory::Calibration_Button_Click(void)
- {
- DisableAllCalTimer();
- if( ! cbIP2->Checked &&
- ! cbAFC->Checked &&
- ! cbRxPathLoss->Checked &&
- ! cbTxIq->Checked &&
- ! cbTxPcl->Checked &&
- ! m_cbTrxOffset->Checked &&
- ! cbADC->Checked &&
- ! m_cbCV->Checked &&
- ! cbWiFiTxDcOffset->Checked &&
- ! cbWiFiTxPower->Checked &&
- ! m_cbBTCapID->Checked
- )
- {
- Application->MessageBox(" Please choose at least one calibration item", "Warning", MB_OK);
- return;
- }
- if (cbWiFiTxPower->Checked && rbAgilentN4010A->Checked)
- {
- if (!(DllMan->LoadN4010ADllFunctions(this->Handle)))
- {
- Application->MessageBox(" Load Agilent N4010A AgN4010WSODrv.dll fail", "Warning", MB_OK);
- return;
- }
- }
- MF_state = eInit;
- if (BUTTON_TAG_START == bb_Start->Tag)
- {
- bb_Start->Tag = BUTTON_TAG_STOP;
- bb_Start->Enabled = false;
- as_ID = edtBarcode->Text;
- //if (!read_ini_file(stIniFile->Caption))
- //{
- // Application->MessageBox("Read INI file fail", "FAILURE", MB_OK);
- // return;
- //}
- st_Log->Clear();
- wrap_log_file();
- st_Log->Add( "nn********************************************************************************************"
- );
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- ed_Label->Text + " " + "ID = " + as_ID
- );
- m_Cal.as_ResultBuf = m_Cal.as_ResultBuf + as_ID + ", ";
- lb_META_factory_ID->Caption = "ID: " + as_ID;
- int time_out;
- TNotifyEvent ne;
- TNotifyEvent neTBU;
- ne = on_Calibration_TerminateSuccess;
- neTBU = on_Calibration_TerminateByUser;
- SetRctParameter();
- SetBttParameter();
- SetWftParameter();
- SetDcsParameter();
- SetCalibrationParameter();
- pt_calibration = new T_META_factory_calibration(
- true,
- MF_ctrl,
- MF_ADC_ctrl,
- META_factory_cfg,
- st_Log,
- ne,
- neTBU,
- as_ID,
- as_AgeTaModel,
- &m_Rct,
- &m_sBtt,
- &m_Wft,
- &m_Dcs,
- &m_Cal
- );
- if (pt_calibration != NULL)
- {
- pt_calibration->FreeOnTerminate = true;
- pt_calibration->OnTerminate = on_Calibration_Fail;
- pt_calibration->Priority = tpHighest;
- is_suspend_cal = true;
- }
- else
- {
- PostMessage(this->Handle,
- WM_MF_PT_CALIBRATION_NEW_FAIL,
- 0,
- 0
- );
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: new calibration 2"
- );
- return;
- }
- if (is_suspend_cal && pt_calibration != NULL)
- {
- is_suspend_cal = false;
- pt_calibration->Resume();
- }
- }
- }
- //---------------------------------------------------------------------------
- bool TfrmFatcory::read_META_factory_setup( AnsiString asSetupFile, AnsiString asExeName )
- {
- AnsiString asPath;
- if ( getPathFromStr(asExeName, asPath) &&
- withPath( asPath) &&
- !withPath( asSetupFile)
- )
- {
- asSetupFile = asPath + asSetupFile;
- }
- TIniFile *ini;
- try
- {
- ini = new TIniFile( asSetupFile );
- if( ini == NULL ) return false;
- if( ! b_OpenNVRAMdatabase )
- {
- stNVRAMDBFile->Caption = ini->ReadString("META factory","NVRAM database file", "");
- if ( stNVRAMDBFile->Caption.Length() >0)
- {
- if( ! read_db_file( stNVRAMDBFile->Caption ) )
- {
- Application->MessageBox("Open NVRAM database file fail", "FAILURE", MB_OK);
- delete ini;
- return false;
- }
- }
- }
- if( ! b_OpenCfgFile )
- {
- stCFGFile->Caption = ini->ReadString("META factory","Configuration file", "");
- if ( stCFGFile->Caption.Length() >0)
- {
- if( ! read_cfg_file( stCFGFile->Caption ) )
- {
- Application->MessageBox( "Read configuration file fail", "FAILURE", MB_OK );
- delete ini;
- return false;
- }
- }
- }
- if( ! b_SetupLogFile )
- {
- stLogFile->Caption = ini->ReadString("META factory","Logging file", "");
- if ( stLogFile->Caption.Length() >0)
- {
- if( ! setup_log_file( stLogFile->Caption ) )
- {
- Application->MessageBox( "Setup log file fail", "FAILURE", MB_OK );
- delete ini;
- return false;
- }
- }
- }
- if( ! b_SetupResultFile )
- {
- stResultFile->Caption = ini->ReadString("META factory","Result file", "");
- if ( stResultFile->Caption.Length() >0)
- {
- if( ! setup_result_file( stResultFile->Caption ) )
- {
- Application->MessageBox( "Setup result file fail", "FAILURE", MB_OK );
- delete ini;
- return false;
- }
- }
- }
- if( ! b_OpenIniFile )
- {
- stIniFile->Caption = ini->ReadString("META factory","Calibration data initial file", "");
- if ( stIniFile->Caption.Length() >0)
- {
- if( ! read_ini_file(stIniFile->Caption) )
- {
- Application->MessageBox( "Read ini file fail", "FAILURE", MB_OK );
- delete ini;
- return false;
- }
- }
- }
- if( ! m_Cal.b_CalResultPath )
- {
- stCalPath->Caption = ini->ReadString("META factory","Calibration data result path", "");
- if ( stIniFile->Caption.Length()<0 )
- {
- Application->MessageBox( "Read calibration data result path fail", "FAILURE", MB_OK );
- delete ini;
- return false;
- }
- else
- {
- m_Cal.b_CalResultPath = true;
- }
- }
- delete ini;
- return true;
- }
- catch (...)
- {
- AnsiString as_warning_msg;
- as_warning_msg = " META factory : read setup file : " + asSetupFile + " error ";
- Application->MessageBox( as_warning_msg.c_str(), "Warning", MB_OK );
- return false;
- }
- }
- //---------------------------------------------------------------------------
- bool TfrmFatcory::write_META_factory_setup(
- AnsiString asSetupFile,
- AnsiString asExeName
- )
- {
- AnsiString asPath;
- if ( getPathFromStr(asExeName, asPath) &&
- withPath( asPath) &&
- !withPath( asSetupFile)
- )
- {
- asSetupFile = asPath + asSetupFile;
- }
- TIniFile *ini;
- try
- {
- ini = new TIniFile( asSetupFile );
- if(ini == NULL) return false;
- ini->WriteString("META factory","NVRAM database file", stNVRAMDBFile->Caption );
- ini->WriteString("META factory","Configuration file", stCFGFile->Caption );
- ini->WriteString("META factory","Logging file", stLogFile->Caption );
- ini->WriteString("META factory","Result file", stResultFile->Caption );
- ini->WriteString("META factory","Calibration data initial file", stIniFile->Caption );
- ini->WriteString("META factory","Calibration data result path", stCalPath->Caption );
- ini->WriteString("Main menu", "COM PORT", "COM"+IntToStr(frmMainSel->cbxCOM->ItemIndex+1) );
- delete ini;
- ini = NULL;
- }
- catch (...)
- {
- AnsiString as_warning_msg;
- as_warning_msg = " META factory : write setup file : " + asSetupFile + " error ";
- Application->MessageBox( as_warning_msg.c_str(), "Warning", MB_OK );
- }
- return true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFatcory::FormClose(TObject *Sender,
- TCloseAction &Action)
- {
- DisableAllCalTimer();
- if( ! write_META_factory_setup( "MF_setup.txt", Application->ExeName ) )
- {
- Application->MessageBox( "Execution Failure : Save META factory setup", "FAILURE", MB_OK );
- }
- TIniFile *ini_file;
- ini_file = new TIniFile( stCFGFile->Caption );
- if(ini_file != NULL) // added by Andy Ueng
- {
- // ini_file->WriteString( "META factory",
- // "FACTORY_ID",
- // EditStartID->Text );
- delete ini_file;
- }
- SaveFactoryUISetting();
- if ( cbTerminateMETAExit->Checked )
- {
- FormDestroy_function();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFatcory::FormShow(TObject *Sender)
- {
- static bool b_FirstFormShow = true;
- if (b_FirstFormShow)
- {
- b_FirstFormShow = false;
- m_Cal.e_bb_chip = frmMainSel->Get_FinalBBChip();
- m_Cal.ui_rf_id = frmMainSel->Get_FinalRFID();
- m_Cal.s_wifi_cap = frmMainSel->Get_FinalWiFiCap();
-
- if( read_META_factory_setup( "MF_setup.txt", Application->ExeName ) == false )
- {
- // Application->MessageBox("Read META factory setup fail", "FAILURE", MB_OK );
- }
- frmFatcory->AutoScroll = true;
- lb_META_factory_ID->Caption = "";
- lb_META_factory_status->Caption = "";
- bb_Start->Tag = BUTTON_TAG_START;
- bb_Start->Enabled = true;
- bb_Start->Caption = "Start (F6)";
- update_Start_button();
- DisableAllCalTimer();
- //DisplayInitialValueFrom();
- DisplayPowerSupplyType();
- DisplayAFCCal();
- DisplayCrystalCapId();
- //DisplayCapIdCal();
- DisplayTxAfcOffsetCal();
- DisplayResetRfTester();
- DisplayAFCType();
- DisplayRxPathLossCal();
- DisplayIP2Cal();
- DisplayTxIqCal();
- DisplayTxPclCal();
- DisplayADCCal();
- DisplayCVCal();
- DisplayWiFiTxDcOffsetCal();
- DisplayWiFiTxPowerCal();
- DisplayBTCrystalCAPIDCal();
- DisplayPAType();
- //DisplayPABiasType();
- DisplayTXPCLType();
- DisplayApcModulation();
- DisplayRFCalibrationEquipment();
- DisplayWiFiCalibrationEquipment();
- DisplayBTCalibrationEquipment();
- DisplayBarcodeIncreasementEnter();
- DisplayReadBarcodeFromEnter();
- DisplayAutoStartCalibrationEnter();
- DisplaySaveBarcodeToNVRAMExit();
- DisplaySaveBarcodeToFileExit();
- DisplayBarcodeIncreasementExit();
- DisplaySaveBarcodeToNVRAMSuccess();
- DisplaySaveBarcodeToFileSuccess();
- DisplayBarcodeIncreasementSuccess();
- DisplaySaveBarcodeToNVRAMFail();
- DisplaySaveBarcodeToFileFail();
- DisplayBarcodeIncreasementFail();
- //DisplayBarcodeSaveTo();
- DisplayTerminateMETAExit();
- DisplayTerminateMETAFail();
- DisplayTurnOffPowerSupplyFail();
- DisplayTerminateMETASuccess();
- DisplayTurnOffPowerSupplySuccess();
- ApplyHideProperty();
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFatcory::About2Click(TObject *Sender)
- {
- Form_About->lblAboutTitle->Caption ="META factory";
- if ( Form_About->ShowModal() == mrOk)
- {
- Form_About->lblAboutTitle->Caption ="META LAB 2"; // recovery
- } else
- {
- Form_About->lblAboutTitle->Caption ="META LAB 2"; // recovery
- }
- }
- //---------------------------------------------------------------------------
- bool TfrmFatcory::read_cfg_file(AnsiString asFileName)
- {
- if (NULL == META_factory_cfg )
- {
- META_factory_cfg = new TMETA_factory_cfg();
- }
- if( META_factory_cfg == NULL )
- {
- return false;
- }
- if( ! b_OpenCfgFile )
- {
- if(! META_factory_cfg->ReadFromIniFile(asFileName))
- {
- b_OpenCfgFile = false;
- return false;
- }
- else
- {
- b_OpenCfgFile = true;
- stCFGFile->Caption = asFileName;
- char cM_PM;
- META_factory_cfg->getM_PM( cM_PM );
- if( (cM_PM >=5) && (0 == m_Cal.RfCapability.capability.Calibration_8PM) )
- {
- Application->MessageBox( "MS support at most 4 PM per frame, please modify M_PM in CFG file" , "Warning", MB_OK );
- return false;
- }
- else if( cM_PM >8 )
- {
- Application->MessageBox( "MS support at most 8 PM per frame, please modify M_PM in CFG file" , "Warning", MB_OK );
- return false;
- }
- }
- }
- update_Start_button();
- return true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFatcory::miOpenConfigFileClick(TObject *Sender)
- {
- if (dlg_OpenConfigFile->Execute())
- {
- b_OpenCfgFile = false;
- if (!read_cfg_file(dlg_OpenConfigFile->FileName))
- {
- Application->MessageBox("Read configuration fail", "FAILURE", MB_OK);
- return;
- }
- write_ConfigurationFile("MF_setup.txt", Application->ExeName, stCFGFile->Caption);
- }
- }
- //---------------------------------------------------------------------------
- bool TfrmFatcory::setup_log_file( AnsiString asFileName)
- {
- as_LogFileName = asFileName;
- b_SetupLogFile = true;
- stLogFile->Caption = asFileName;
- return true;
- }
- //---------------------------------------------------------------------------
- bool TfrmFatcory::setup_result_file( AnsiString asFileName)
- {
- as_ResultFileName = asFileName;
- b_SetupResultFile = true;
- stResultFile->Caption = asFileName;
- return true;
- }
- //---------------------------------------------------------------------------
- bool TfrmFatcory::setup_cal_result_path( AnsiString asFileName)
- {
- as_CalResultPath = asFileName;
- m_Cal.b_CalResultPath = true;
- stCalPath->Caption = asFileName;
- return true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFatcory::miSetupLoggingFileClick(
- TObject *Sender)
- {
- if ( dlg_SetupLogFile->Execute() )
- {
- b_SetupLogFile = false;
- if( ! setup_log_file( dlg_SetupLogFile->FileName ) )
- {
- Application->MessageBox( "Setup log file fail", "FAILURE", MB_OK );
- return;
- }
- write_LoggingFile( "MF_setup.txt", Application->ExeName, stLogFile->Caption );
- }
- }
- //---------------------------------------------------------------------------
- bool TfrmFatcory::read_ini_file(AnsiString asFileName)
- {
- AnsiString as;
- // AFC
- if (!MF_rf_afc_ptr->REQ_Read_From_File(asFileName.c_str()))
- {
- return false;
- }
- if (!MF_crystal_afc_ptr->REQ_Read_CAPID_From_File(asFileName.c_str()))
- {
- return false;
- }
- // RX path loss
- if (!MF_rf_agc_ptr->REQ_Read_From_File(asFileName.c_str()))
- {
- return false;
- }
- // IP2
- if (!MF_rf_pm_ptr->REQ_Read_IP2Reg_From_File(asFileName.c_str(), m_Cal.ui_rf_id))
- {
- return false;
- }
- // APC
- if (!MF_rf_apc_ptr->REQ_Read_APC_From_File(asFileName.c_str(), m_Cal.ui_rf_id, m_Cal.b_TADOSupport))
- {
- return false;
- }
- if (!MF_rf_apc_8psk_ptr->REQ_Read_APC_From_File(asFileName.c_str(), m_Cal.ui_rf_id))
- {
- return false;
- }
- // BT CAP ID
- if (!m_Cal.s_cal_obj.pc_BT_INFO6611_Obj->REQ_Read_From_File(asFileName.c_str()))
- {
- return false;
- }
- // ADC
- if (!MF_BB_ADC_ptr->REQ_Read_From_File(asFileName.c_str()))
- {
- return false;
- }
- if (!m_Cal.s_cal_obj.pc_WIFI_APC_Obj->REQ_Read_TxPower2400M_From_File(asFileName.c_str()))
- {
- return false;
- }
- // ALC
- if (!m_Cal.s_cal_obj.pc_WIFI_ALC_Obj->REQ_Read_From_File(asFileName.c_str()))
- {
- return false;
- }
- b_OpenIniFile = true;
- stIniFile->Caption = asFileName;
- update_Start_button();
- return true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFatcory::miOpenInitialFileClick(TObject *Sender)
- {
- if ( dlg_OpenIniFile->Execute() )
- {
- b_OpenIniFile = false;
- if( read_ini_file( dlg_OpenIniFile->FileName ) == false )
- {
- Application->MessageBox( "Read ini file fail", "FAILURE", MB_OK );
- return;
- }
- write_InitialFile( "MF_setup.txt", Application->ExeName, stIniFile->Caption );
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFatcory::Exit1Click(TObject *Sender)
- {
- Close();
- }
- //---------------------------------------------------------------------------
- void TfrmFatcory::update_Start_button()
- {
- if ( b_OpenCfgFile && b_OpenIniFile && bb_Start->Tag == BUTTON_TAG_START )
- {
- bb_Start->Enabled = true;
- } else
- {
- bb_Start->Enabled = false;
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFatcory::ed_LabelKeyUp(TObject *Sender,
- WORD &Key, TShiftState Shift)
- {
- if ( AnsiCompareText(as_Label , ed_Label->Text) != 0)
- {
- //i_ID = 0;
- as_ID = "0";
- }
- // lb_META_factory_ID->Caption = "ID:" + IntToStr( i_ID );
- lb_META_factory_ID->Caption = "ID:" + as_ID;
- }
- //---------------------------------------------------------------------------
- bool TfrmFatcory::read_db_file( AnsiString asFileName )
- {
- unsigned long nvram_idb;
- META_RESULT meta_result;
- meta_result = META_NVRAM_Init_r( m_META_HANDLE_Obj.Get_MainHandle(), asFileName.c_str(), &nvram_idb);
- if( ! b_OpenNVRAMdatabase )
- {
- if ((META_SUCCESS != meta_result) &&
- (META_MAUI_DB_INCONSISTENT != meta_result)
- )
- {
- Application->MessageBox("Open NVRAM database file fail", "FAILURE", MB_OK);
- return false;
- }
- else
- {
- if (META_MAUI_DB_INCONSISTENT == meta_result)
- {
- Application->MessageBox("NVRAM database file and target load is inconsistent", "WARNING", MB_OK);
- }
- b_OpenNVRAMdatabase = true;
- //asFileName = frmMainSel->Get_NVRAMDBFileName();
- stNVRAMDBFile->Caption = asFileName;
- update_Start_button();
- NVRAMMan->GetSupportInfoFromNVRAMDB();
- return true;
- }
- }
- NVRAMMan->GetSupportInfoFromNVRAMDB();
- return true;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFatcory::miOpenfdmfileClick(TObject *Sender)
- {
- if (dlg_OpenFDM_DB->Execute())
- {
- b_OpenNVRAMdatabase = false;
- if (!read_db_file( dlg_OpenFDM_DB->FileName ))
- {
- Application->MessageBox("Open NVRAM database file fail", "FAILURE", MB_OK);
- return;
- }
- write_NVRAM_DATABASE_FILE( "MF_setup.txt", Application->ExeName, stNVRAMDBFile->Caption );
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFatcory::miSetupresultfileClick(
- TObject *Sender)
- {
- if ( dlg_SetupResultFile->Execute() )
- {
- b_SetupResultFile = false;
- if( ! setup_result_file( dlg_SetupResultFile->FileName ) )
- {
- Application->MessageBox( "Setup result file fail", "FAILURE", MB_OK );
- return;
- }
- write_ResultFile( "MF_setup.txt", Application->ExeName, stResultFile->Caption );
- }
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFatcory::TimerCalTimer(TObject *Sender)
- {
- DisableAllCalTimer();
- if(pt_calibration != NULL && is_calibration_start)
- {
- pt_calibration->OnTerminate = on_Calibration_Fail;
- pt_calibration->Terminate();
- is_calibration_start = false;
- pt_calibration = NULL;
- }
- switch(TimerCalTimeoutID)
- {
- //////////////////////////// baseband //////////////////////////////
- case WM_MF_BB_REG_READ_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: read baseband register (cal timer)"
- );
- }
- break;
- case WM_MF_BB_REG_WRITE_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: write baseband register (cal timer)"
- );
- }
- break;
- case WM_MF_BB_REG_SET_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: set baseband register (cal timer)"
- );
- }
- break;
- //////////////////////////// RF general //////////////////////////////
- case WM_MF_RF_STOP_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: stop RF (cal timer)"
- );
- }
- break;
- //////////////////////////// RX path loss //////////////////////////////
- case WM_MF_NVRAM_PATH_LOSS_WRITE_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: write path loss to flash (cal timer)"
- );
- }
- break;
- case WM_MF_RF_PM_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: PM (cal timer)"
- );
- }
- break;
- //////////////////// AFC ////////////////////////////////////////
- case WM_MF_NVRAM_AFC_WRITE_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: write AFC slope and offset to flash (cal timer)"
- );
- }
- break;
- case WM_MF_RF_AFC_CONTROL_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: AFC control (cal timer)"
- );
- }
- break;
- case WM_MF_RF_AFC_GET_AFCDAC_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: get target AFC DAC (cal timer)"
- );
- }
- break;
- case WM_MF_RF_SET_AFC_DAC_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: set AFC DAC (cal timer)"
- );
- }
- break;
- ////////////////////// crystal AFC ///////////////////////////////////
- case WM_MF_RF_CRYSTAL_AFC_SELECT_BAND_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: crystal AFC select band (cal timer)"
- );
- }
- break;
- case WM_MF_RF_CRYSTAL_AFC_CONTROL_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: crystal AFC cotnrol (cal timer)"
- );
- }
- break;
- case WM_MF_NVRAM_CRYSTAL_AFC_CAPID_WRITE_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: write crystal AFC CAP ID to NVRAM (cal timer)"
- );
- }
- break;
- case WM_MF_RF_CRYSTAL_AFC_TX_LEVEL_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: crystal AFC TX level (cal timer)"
- );
- }
- break;
- case WM_MF_RF_CRYSTAL_AFC_CHECK_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: crystal AFC check (cal timer)"
- );
- }
- break;
- case WM_MF_RF_SET_CRYSTAL_AFC_DAC_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: set crystal AFC DAC (cal timer)"
- );
- }
- break;
- case WM_MF_RF_SET_CRYSTAL_AFC_DAC_CNF_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: set crystal AFC DAC cnf(cal timer)"
- );
- }
- break;
- case WM_MF_AGE8960_SET_MESA_FUNC_PFER_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: set measurement function PFER(cal timer)"
- );
- }
- break;
- case WM_MF_AGE8960_READ_PFER_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: read PFER(cal timer)"
- );
- }
- break;
- ////////////////////// IP2 ///////////////////////////////////
- case WM_MF_RF_IP2_SET_MAG_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Set IP2 mag to register (cal timer)"
- );
- }
- break;
- case WM_MF_RF_IP2_SET_POL_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Set IP2 pol to register (cal timer)"
- );
- }
- break;
- case WM_MF_RF_IP2_SET_AMCALMODE_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: IP2 set rxamcalmode to register (cal timer)"
- );
- }
- break;
- case WM_MF_RF_IP2_SET_CW7_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: IP2 set CW7 to register (cal timer)"
- );
- }
- break;
- case WM_MF_RF_IP2_SET_BCCODE_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: IP2 set B,C code to register (cal timer)"
- );
- }
- break;
- case WM_MF_RF_IP2_SET_MT6139_COEF_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: IP2 set MT6139 coefficient (cal timer)"
- );
- }
- break;
- case WM_MF_RF_IP2_GET_BCCODE_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: IP2 Get B,C code from register (cal timer)"
- );
- }
- break;
- case WM_MF_RF_IP2_CHECK_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: IP2 check (cal timer)"
- );
- }
- break;
- case WM_MF_RF_IP2_SET_CW2_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: IP2 set CW2 to register (cal timer)"
- );
- }
- break;
- case WM_MF_RF_IP2_GET_ACODE_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: IP2 get acode from register (cal timer)"
- );
- }
- break;
- case WM_MF_RF_IP2_GET_CW7_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: IP2 get CW7 from register (cal timer)"
- );
- }
- break;
- case WM_MF_RF_IP2_PM_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: IP2 PM (cal timer)"
- );
- }
- break;
- case WM_MF_NVRAM_IP2_READ_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: read IP2 from flash (cal timer)"
- );
- }
- break;
- case WM_MF_NVRAM_IP2_WRITE_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: write IP2 to flash (cal timer)"
- );
- }
- break;
- ////////////////////// APC ////////////////////////////////////
- case WM_MF_NVRAM_LEVEL_RAMP_WRITE_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: write level ramp to flash (cal timer)"
- );
- }
- break;
- case WM_MF_SET_RAMPAPCLEVEL_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: set ramp APC level (cal timer)"
- );
- }
- break;
- case WM_MF_RF_A60111A_ENTER_FACTORY_MODE_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: A60111A enter factory mode (cal timer)"
- );
- }
- break;
- case WM_MF_RF_A60111A_READ_REF_TEMP_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: A60111A read temp_ref (cal timer)"
- );
- }
- break;
- case WM_MF_RF_TX_LEVEL_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: TX level (cal timer)"
- );
- }
- break;
- case WM_MF_RF_TX_LEVEL_EVALDAC_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: TX level evaluate DAC value(cal timer)"
- );
- }
- break;
- case WM_MF_SET_APC_DAC_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: set APC DAC (cal timer)"
- );
- }
- break;
- case WM_MF_SET_APC_DC_OFFSET_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: set APC DC offset (cal timer)"
- );
- }
- break;
- case WM_MF_AGE8960_READ_TX_POWER_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: read TX power (cal timer)"
- );
- }
- break;
- case WM_MF_AGE8960_CONFIG_TX_POWER_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: config TX power (cal timer)"
- );
- }
- break;
- case WM_MF_AGE8960_CONFIG_PFER_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: config PFER (cal timer)"
- );
- }
- break;
- case WM_MF_AGE8960_CONFIG_IQ_TUNNING_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: config IQ_TUNNING (cal timer)"
- );
- }
- break;
- case WM_MF_AGE8960_CONFIG_EPSK_MOD_ACCURACY_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: config EPSK modulation accuracy (cal timer)"
- );
- }
- break;
- case WM_MF_AGE8960_FETCH_EPSK_OOS_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: fetch EPSK original offset (cal timer)"
- );
- }
- break;
- case WM_MF_AGE8960_FETCH_EPSK_SBS_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: fetch EPSK IQ imbalance (cal timer)"
- );
- }
- break;
- case WM_MF_WIFI_CPT_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: WiFi continuous packet TX (cal timer)"
- );
- }
- break;
- case WM_MF_WIFI_CPT_STOP_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: WiFi stop continuous packet TX (cal timer)"
- );
- }
- break;
- case WM_MF_WIFI_INIT_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: WiFi tester init (cal timer)"
- );
- }
- break;
- case WM_MF_WIFI_TERMINATE_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: WiFi tester terminate (cal timer)"
- );
- }
- break;
- case WM_MF_WIFI_CONN_OPEN_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: WiFi tester connection open (cal timer)"
- );
- }
- break;
- case WM_MF_WIFI_CONN_UPDATE_CALDATA_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: WiFi tester updates calibration data (cal timer)"
- );
- }
- break;
- case WM_MF_WIFI_CONN_CLOSE_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: WiFi tester connection close (cal timer)"
- );
- }
- break;
- case WM_MF_WIFI_SET_DEFAULT_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: WiFi tester sets default value (cal timer)"
- );
- }
- break;
- case WM_MF_WIFI_SET_PACKET_LEN_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: WiFi tester sets packet length (cal timer)"
- );
- }
- break;
- case WM_MF_WIFI_SET_TRIGGER_STYLE_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: WiFi tester sets trigger style (cal timer)"
- );
- }
- break;
- case WM_MF_WIFI_APPLY_CHANGE_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: WiFi tester apply change value (cal timer)"
- );
- }
- break;
- case WM_MF_WIFI_SET_CENTRAL_FREQ_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: WiFi tester sets cental frequency (cal timer)"
- );
- }
- break;
- case WM_MF_WIFI_SET_POWER_RANGE_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: WiFi tester sets power range (cal timer)"
- );
- }
- break;
- case WM_MF_WIFI_DATA_CAPTURE_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: WiFi tester captures data (cal timer)"
- );
- }
- break;
- case WM_MF_WIFI_ANALYZE_POWER_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: WiFi tester analyzes TX power (cal timer)"
- );
- }
- break;
- case WM_MF_WIFI_READ_POWER_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: WiFi tester reads TX power (cal timer)"
- );
- }
- break;
- case WM_MF_NVRAM_WIFI_APC_READ_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: reads WiFi TX power from NVRAM (cal timer)"
- );
- }
- break;
- case WM_MF_NVRAM_WIFI_APC_WRITE_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: writes WiFi TX power to NVRAM (cal timer)"
- );
- }
- break;
- case WM_MF_NVRAM_WIFI_ALC_READ_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: reads WiFi ALC from NVRAM (cal timer)"
- );
- }
- break;
- case WM_MF_NVRAM_WIFI_ALC_WRITE_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: writes WiFi ALC to NVRAM (cal timer)"
- );
- }
- break;
- case WM_MF_NVRAM_WIFI_TX_DC_OFFSET_READ_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: reads WiFi TX DC offset from NVRAM (cal timer)"
- );
- }
- break;
- case WM_MF_NVRAM_WIFI_TX_DC_OFFSET_WRITE_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: writes WiFi TX DC offset to NVRAM (cal timer)"
- );
- }
- break;
- case WM_MF_WIFI_TX_DC_OFFSET_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: writes WiFi TX DC offset calibration (cal timer)"
- );
- }
- break;
- // BT tester
- case WM_MF_BTT_INIT_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: BT tester < initialization (cal timer)"
- );
- }
- break;
- case WM_MF_BTT_CONFIG_SLAVE_PARAMETER_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: BT tester < config slave parameter (cal timer)"
- );
- }
- break;
- case WM_MF_BTT_CONFIG_DOWNLINK_POWER_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: BT tester < config downlink power (cal timer)"
- );
- }
- break;
- case WM_MF_BTT_CONFIG_BD_ADDRESS_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: BT tester < config BD address (cal timer)"
- );
- }
- break;
- case WM_MF_BTT_CONFIG_INQUIRY_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: BT tester < config inquiry parameter (cal timer)"
- );
- }
- break;
- case WM_MF_BTT_CONFIG_SCAN_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: BT tester < config scan parameter (cal timer)"
- );
- }
- break;
- case WM_MF_BTT_INQUIRY_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: BT tester < inquiry (cal timer)"
- );
- }
- break;
- case WM_MF_BTT_QUERY_STATE_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: BT tester < query state (cal timer)"
- );
- }
- break;
- case WM_MF_BTT_CONNECT_TEST_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: BT tester < connect testmode (cal timer)"
- );
- }
- break;
- case WM_MF_BTT_RELEASE_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: BT tester < release connection (cal timer)"
- );
- }
- break;
- case WM_MF_BTT_CONFIG_MOD_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: BT tester < config modulation (cal timer)"
- );
- }
- break;
- case WM_MF_BTT_READ_FREQ_ACCURACY:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: BT tester > read frequency accuracy (cal timer)"
- );
- }
- break;
- // BT
- case WM_MF_BT_ENABLE_PCM_CLOCK_SYNC_SIGNAL_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: target < enable PCM clock sync. signal (cal timer)"
- );
- }
- break;
- case WM_MF_BT_START_CALIBRATE_CRYSTAL_CLOCK_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: target < start calibrate BT crystal clock (cal timer)"
- );
- }
- break;
- case WM_MF_BT_READ_CRYSTAL_CLOCK_RESULT_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: target > read BT crystal clock result (cal timer)"
- );
- }
- break;
- case WM_MF_BT_SET_CRYSTAL_CAPID_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: target < set BT crystal CAP ID (cal timer)"
- );
- }
- break;
- case WM_MF_BT_ENTER_TEST_MODE_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: target < enter BT test mode (cal timer)"
- );
- }
- break;
- case WM_MF_BT_INQUIRY_ENABLE_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: target < BT inquiry enable (cal timer)"
- );
- }
- break;
- case WM_MF_NVRAM_CV_READ_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: reads CV from NVRAM (cal timer)"
- );
- }
- break;
- case WM_MF_NVRAM_CV_WRITE_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: writes CV to NVRAM (cal timer)"
- );
- }
- break;
- case WM_MF_NVRAM_REF_TEMP_READ_FAIL:
- {
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: reads ref_temp from NVRAM (cal timer)"
- );
- }
- break;
- default:
- {
- }
- break;
- } // switch
- PostMessage(
- this->Handle,
- TimerCalTimeoutID,
- 0,
- 0
- );
- on_Calibration_Fail_function();
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFatcory::TimerADCCalTimer(TObject *Sender)
- {
- DisableAllCalTimer();
- if( pt_calibration != NULL && is_calibration_start )
- {
- pt_calibration->OnTerminate = on_Calibration_Fail;
- pt_calibration->Terminate();
- is_calibration_start = false;
- pt_calibration = NULL;
- }
- switch(TimerADCCalTimeoutID)
- {
- case WM_MF_ADC_MEASURE_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: ADC measure (ADC cal timer)"
- );
- }
- break;
- case WM_MF_NVRAM_ADC_WRITE_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: write ADC to flash (ADC cal timer)"
- );
- }
- break;
- case WM_MF_NVRAM_ADC_READ_FAIL:
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: read ADC from flash (ADC cal timer)"
- );
- }
- break;
- default:
- break;
- }
- PostMessage(
- this->Handle,
- TimerADCCalTimeoutID,
- 0,
- 0
- );
- on_Calibration_Fail_function();
- }
- //---------------------------------------------------------------------------
- ////////////////////////////////// ADC calibration end ////////////////////////////////////
- void __fastcall TfrmFatcory::edtStartIDCheck(TObject *Sender)
- {
- int i;
- int data;
- AnsiString text;
- TEdit *edit = (TEdit*)Sender;
- char hint[256] =
- { " value shall be 0~10000000000 "
- };
- text = edit->Text;
- if( !IsValidFactoryID( text, data ) )
- { ShowHintLabel( edit, hint );
- edit->SetFocus();
- return;
- }
-
- }
- //---------------------------------------------------------------------------
- void TfrmFatcory::ShowHintLabel( TControl *sender, char* hint )
- {
- TPoint pt0 = this->ClientOrigin;
- TPoint pt1 = sender->ClientOrigin;
- lblHint->Left = (pt1.x-pt0.x);
- lblHint->Top = (pt1.y-pt0.y)+sender->Height+3;
- lblHint->Caption = hint;
- lblHint->Visible = true;
- HintTimer->Enabled = true;
- }
- //------------------------------------------------------------------------------------------------
- void __fastcall TfrmFatcory::HintTimerTimer(TObject *Sender)
- {
- HintTimer->Enabled = false;
- lblHint->Visible = false;
- }
- //------------------------------------------------------------------------------------------------
- AnsiString TfrmFatcory::read_Barcode(AnsiString asSetupFile, AnsiString asExeName)
- {
- AnsiString asPath;
- if ( getPathFromStr(asExeName, asPath) &&
- withPath( asPath) &&
- !withPath( asSetupFile)
- )
- {
- asSetupFile = asPath + asSetupFile;
- }
- TIniFile *ini;
- AnsiString as_temp_BARCODE;
- try
- {
- ini = new TIniFile( asSetupFile );
- if(ini != NULL) // added by Andy Ueng
- {
- as_temp_BARCODE = ini->ReadString("META factory","BARCODE", "0");
- delete ini;
- return as_temp_BARCODE;
- }
- // end of added
- return("0");
- }
- catch (...)
- {
- //ShowMessage( " META factory : read setup file : " + asSetupFile + " error : barcode ");
- AnsiString as_warning_msg;
- as_warning_msg = " META factory : read setup file : " + asSetupFile + " error : barcode ";
- Application->MessageBox( as_warning_msg.c_str(), "Warning", MB_OK );
- }
- return("0");
- }
- //------------------------------------------------------------------------------
- void __fastcall TfrmFatcory::OpenOffCloseAgilentPowerSupply(void)
- {
- if( ! m_dcs_ctrl.DCS_Init( &m_Dcs ) )
- {
- PostMessage(
- this->Handle,
- WM_MF_ADC_DCS_INIT_FAIL,
- 0,
- 0
- );
- return;
- }
- if( ! m_dcs_ctrl.DCS_outputVoltCurr( &m_Dcs, 1.0*i_OFF_VOLTAGE/1000.0, i_CURRENT_LIMIT/1000.0) )
- {
- PostMessage(
- this->Handle,
- WM_MF_ADC_DCS_SET_VOLTAGE_CURRENT_FAIL,
- 0,
- 0
- );
- return;
- }
- if( ! m_dcs_ctrl.DCS_close( &m_Dcs ) )
- {
- PostMessage(
- this->Handle,
- WM_MF_ADC_DCS_CLOSE_FAIL,
- 0,
- 0
- );
- return;
- }
- #if 0
- if ( rbAgilent661x->Checked )
- {
- if(( hp661x_init(as_Agilent_Power_Supply_GPIB_addr.c_str(), 0, 0, &MF_ADC_ctrl.vi)) != VI_SUCCESS)
- {
- PostMessage(
- this->Handle,
- WM_MF_AGE661x_INIT_FAIL,
- 0,
- 0
- );
- return;
- }
- if((hp661x_outputVoltCurr(MF_ADC_ctrl.vi, 1.0*i_OFF_VOLTAGE/1000.0, i_CURRENT_LIMIT/1000.0)) != VI_SUCCESS)
- {
- PostMessage(
- this->Handle,
- WM_MF_ADC_SET_VOLTAGE_CURRENT_FAIL,
- 0,
- 0
- );
- return;
- }
- if(hp661x_close(MF_ADC_ctrl.vi) != VI_SUCCESS)
- {
- PostMessage(
- this->Handle,
- WM_MF_AGE661x_CLOSE_FAIL,
- 0,
- 0
- );
- return;
- }
- }
- else if ( rbAgilent663x2->Checked )
- {
- if(( hp663x2_init(m_Dcs.ADD, 0, 0, &MF_ADC_ctrl.vi)) != VI_SUCCESS)
- {
- PostMessage(
- this->Handle,
- WM_MF_AGE663x2_INIT_FAIL,
- 0,
- 0
- );
- return;
- }
- if((hp663x2_outputVoltCurr(MF_ADC_ctrl.vi, 1.0*i_OFF_VOLTAGE/1000.0, i_CURRENT_LIMIT/1000.0)) != VI_SUCCESS)
- {
- PostMessage(
- this->Handle,
- WM_MF_ADC_SET_VOLTAGE_CURRENT_FAIL,
- 0,
- 0
- );
- return;
- }
- if(hp663x2_close(MF_ADC_ctrl.vi) != VI_SUCCESS)
- {
- PostMessage(
- this->Handle,
- WM_MF_AGE663x2_CLOSE_FAIL,
- 0,
- 0
- );
- return;
- }
- }
- #endif
- }
- //-------------------------------------------------------------------------
- void __fastcall TfrmFatcory::FormDestroy(TObject *Sender)
- {
- FormDestroy_function();
- }
- //--------------------------------------------------------------------------
- void __fastcall TfrmFatcory::FormDestroy_function( void )
- {
- if( cbWiFiTxPower->Checked )
- {
- if( ! m_wft_ctrl.WFT_ConClose( &m_Wft ) )
- {
- PostMessage(
- this->Handle,
- WM_MF_WIFI_CONN_CLOSE_FAIL,
- 0,
- 0
- );
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " WiFi tester closes connection fail "
- );
- }
- if( ! m_wft_ctrl.WFT_Terminate( &m_Wft ) )
- {
- PostMessage(
- this->Handle,
- WM_MF_WIFI_TERMINATE_FAIL,
- 0,
- 0
- );
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " WiFi tester terminates fail "
- );
- }
- }
-
- TerminateFactoryThread();
- DeallocateDynamicMemory();
- if ( cbTerminateMETAExit->Checked || cbTerminateMETASuccess->Checked || cbTerminateMETAFail->Checked)
- {
- Application->Terminate();
- }
- }
- //---------------------------------------------------------------------------
- void TfrmFatcory::DisableAllCalTimer(void)
- {
- TimerCal->Enabled = false;
- TimerADCCal->Enabled = false;
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFatcory::InitAgilentPowerSupply_SetNormalVoltage_CloseAgilentPowerSupply( void )
- {
- if( ! m_dcs_ctrl.DCS_Init( &m_Dcs ) )
- {
- PostMessage(
- this->Handle,
- WM_MF_ADC_DCS_INIT_FAIL,
- 0,
- 0
- );
- return;
- }
- if( ! m_dcs_ctrl.DCS_outputVoltCurr( &m_Dcs, i_NORMAL_VOLTAGE/1000.0, i_CURRENT_LIMIT/1000.0) )
- {
- PostMessage(
- this->Handle,
- WM_MF_ADC_DCS_SET_VOLTAGE_CURRENT_FAIL,
- 0,
- 0
- );
- return;
- }
- if( ! m_dcs_ctrl.DCS_close( &m_Dcs ) )
- {
- PostMessage(
- this->Handle,
- WM_MF_ADC_DCS_CLOSE_FAIL,
- 0,
- 0
- );
- return;
- }
- #if 0
- //===========================================================================
- if (! META_factory_cfg->get_NORMAL_VOLTAGE(i_NORMAL_VOLTAGE) )
- {
- PostMessage(
- this->Handle,
- WM_MF_CFG_READ_FAIL,
- 0,
- 0
- );
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail (NORMAL_VOLTAGE)."
- );
- return;
- }
- if (! META_factory_cfg->get_CURRENT_LIMIT(i_CURRENT_LIMIT) )
- {
- PostMessage(
- this->Handle,
- WM_MF_CFG_READ_FAIL,
- 0,
- 0
- );
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail (CURRENT_LIMIT)."
- );
- return;
- }
- // Agilent 661x
- if ( rbAgilent661x->Checked )
- {
- /////////////////////////////////// set power supply output voltage = 3.8V ///////////////////////
- // Initialize hp661x
- if(( hp661x_init(m_Dcs.ADD.c_str(), 0, 0, &MF_ADC_ctrl.vi)) != VI_SUCCESS)
- {
- Application->MessageBox( "Initial Agilent 661x fail" , "Fail", MB_OK );
- return;
- }
- // set power supply to normal voltage
- /* Set output voltage and current levels, turn output on*/
- if((hp661x_outputVoltCurr(MF_ADC_ctrl.vi, 1.0*i_NORMAL_VOLTAGE/1000.0, i_CURRENT_LIMIT/1000.0)) != VI_SUCCESS)
- {
- PostMessage(
- this->Handle,
- WM_MF_ADC_SET_VOLTAGE_CURRENT_FAIL,
- 0,
- 0
- );
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 661x set vlotage = " +
- Double_To_AnsiString(1.0*i_NORMAL_VOLTAGE/1000.0)
- );
- return;
- }
- else
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " set Agilent 663x2 set vlotage = " +
- Double_To_AnsiString(1.0*i_NORMAL_VOLTAGE/1000.0)
- );
- }
- // close hp661x
- if(hp661x_close(MF_ADC_ctrl.vi) != VI_SUCCESS)
- {
- PostMessage(
- this->Handle,
- WM_MF_AGE661x_CLOSE_FAIL,
- 0,
- 0
- );
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 661x close fail"
- );
- return;
- }
- }
- else if ( rbAgilent663x2->Checked )
- {
- //====================================================================================================
- // Agilent 663x2
- /////////////////////////////////// set power supply output voltage = 3.8V ///////////////////////
- // Initialize hp663x2
- if(( hp663x2_init(m_Dcs.ADD.c_str(), 0, 0, &MF_ADC_ctrl.vi)) != VI_SUCCESS)
- {
- Application->MessageBox( "Initial Agilent 663x2 fail" , "Fail", MB_OK );
- return;
- }
- // set power supply to normal voltage
- /* Set output voltage and current levels, turn output on*/
- if((hp663x2_outputVoltCurr(MF_ADC_ctrl.vi, 1.0*i_NORMAL_VOLTAGE/1000.0, i_CURRENT_LIMIT/1000.0)) != VI_SUCCESS)
- {
- PostMessage(
- this->Handle,
- WM_MF_ADC_SET_VOLTAGE_CURRENT_FAIL,
- 0,
- 0
- );
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 663x2 set vlotage = " +
- Double_To_AnsiString(1.0*i_NORMAL_VOLTAGE/1000.0)
- );
- return;
- }
- else
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " set Agilent 663x2 set vlotage = " +
- Double_To_AnsiString(1.0*i_NORMAL_VOLTAGE/1000.0)
- );
- }
- // close hp663x2
- if(hp663x2_close(MF_ADC_ctrl.vi) != VI_SUCCESS)
- {
- PostMessage(
- this->Handle,
- WM_MF_AGE663x2_CLOSE_FAIL,
- 0,
- 0
- );
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 663x2 close fail"
- );
- return;
- }
- }
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFatcory::SetNormalVoltage_CloseAgilentPowerSupply( void )
- {
- if( ! m_dcs_ctrl.DCS_outputVoltCurr( &m_Dcs, i_NORMAL_VOLTAGE/1000.0, i_CURRENT_LIMIT/1000.0) )
- {
- PostMessage(
- this->Handle,
- WM_MF_ADC_DCS_SET_VOLTAGE_CURRENT_FAIL,
- 0,
- 0
- );
- return;
- }
- if( ! m_dcs_ctrl.DCS_close( &m_Dcs ) )
- {
- PostMessage(
- this->Handle,
- WM_MF_ADC_DCS_CLOSE_FAIL,
- 0,
- 0
- );
- return;
- }
- #if 0
- if (! META_factory_cfg->get_NORMAL_VOLTAGE( i_NORMAL_VOLTAGE))
- {
- PostMessage(
- this->Handle,
- WM_MF_CFG_READ_FAIL,
- 0,
- 0
- );
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail (NORMAL_VOLTAGE)."
- );
- return;
- }
- if (! META_factory_cfg->get_CURRENT_LIMIT( i_CURRENT_LIMIT))
- {
- PostMessage(
- this->Handle,
- WM_MF_CFG_READ_FAIL,
- 0,
- 0
- );
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Read config file fail (CURRENT_LIMIT)."
- );
- return;
- }
- if ( rbAgilent661x->Checked )
- {
- if(IS_AgilentPowerSupply_INITIALISE == true)
- {
- // set power supply to normal voltage
- /* Set output voltage and current levels, turn output on*/
- if((hp661x_outputVoltCurr(MF_ADC_ctrl.vi, 1.0*i_NORMAL_VOLTAGE/1000.0, 1.0*i_CURRENT_LIMIT/1000.0)) != VI_SUCCESS)
- {
- PostMessage(
- this->Handle,
- WM_MF_ADC_SET_VOLTAGE_CURRENT_FAIL,
- 0,
- 0
- );
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 661x set vlotage = " +
- Double_To_AnsiString(1.0*i_NORMAL_VOLTAGE/1000.0)
- );
- return;
- }
- else
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " set Agilent 661x set vlotage = " +
- Double_To_AnsiString(1.0*i_NORMAL_VOLTAGE/1000.0)
- );
- }
- // close hp661x
- if(hp661x_close(MF_ADC_ctrl.vi) != VI_SUCCESS)
- {
- PostMessage(
- this->Handle,
- WM_MF_AGE661x_CLOSE_FAIL,
- 0,
- 0
- );
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Agilent 661x close fail"
- );
- return;
- }
- IS_AgilentPowerSupply_INITIALISE = false;
- }
- }
- //================================================================================================
- // Agilent 663x2
- else if ( rbAgilent663x2->Checked )
- {
- if(IS_AgilentPowerSupply_INITIALISE == true)
- {
- // set power supply to normal voltage
- /* Set output voltage and current levels, turn output on*/
- if((hp663x2_outputVoltCurr(MF_ADC_ctrl.vi, 1.0*i_NORMAL_VOLTAGE/1000.0, 1.0*i_CURRENT_LIMIT/1000.0)) != VI_SUCCESS)
- {
- PostMessage(
- this->Handle,
- WM_MF_ADC_SET_VOLTAGE_CURRENT_FAIL,
- 0,
- 0
- );
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 663x2 set vlotage = " +
- Double_To_AnsiString(1.0*i_NORMAL_VOLTAGE/1000.0)
- );
- return;
- }
- else
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " set Agilent 663x2 set vlotage = " +
- Double_To_AnsiString(1.0*i_NORMAL_VOLTAGE/1000.0)
- );
- }
- if(hp663x2_close(MF_ADC_ctrl.vi) != VI_SUCCESS)
- {
- PostMessage(
- this->Handle,
- WM_MF_AGE663x2_CLOSE_FAIL,
- 0,
- 0
- );
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Agilent 663x2 close fail"
- );
- return;
- }
- IS_AgilentPowerSupply_INITIALISE = false;
- }
- }
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFatcory::CloseAgilentPowerSupply( void )
- {
- if( ! m_dcs_ctrl.DCS_close( &m_Dcs ) )
- {
- PostMessage(
- this->Handle,
- WM_MF_ADC_DCS_CLOSE_FAIL,
- 0,
- 0
- );
- return;
- }
- #if 0
- //======================================================================
- // Agilent 661x
- if( rbAgilent661x->Checked )
- {
- if(IS_AgilentPowerSupply_INITIALISE == true)
- {
- if(hp661x_close(MF_ADC_ctrl.vi) != VI_SUCCESS)
- {
- PostMessage(
- this->Handle,
- WM_MF_AGE661x_CLOSE_FAIL,
- 0,
- 0
- );
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Agilent 661x close"
- );
- return;
- }
- IS_AgilentPowerSupply_INITIALISE = false;
- }
- }
- //=======================================================================
- // Agilent 663x2
- else if( rbAgilent663x2->Checked )
- {
- if(IS_AgilentPowerSupply_INITIALISE == true)
- {
- if(hp663x2_close(MF_ADC_ctrl.vi) != VI_SUCCESS)
- {
- PostMessage(
- this->Handle,
- WM_MF_AGE663x2_CLOSE_FAIL,
- 0,
- 0
- );
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Agilent 663x2 close"
- );
- return;
- }
- IS_AgilentPowerSupply_INITIALISE = false;
- }
- }
- #endif
- }
- //------------------------------------------------------------------------------
- void __fastcall TfrmFatcory::SetOffVoltage_CloseAgilentPowerSupply(void)
- {
- if( ! m_dcs_ctrl.DCS_outputVoltCurr( &m_Dcs, i_OFF_VOLTAGE/1000.0, i_CURRENT_LIMIT/1000.0) )
- {
- PostMessage(
- this->Handle,
- WM_MF_ADC_DCS_SET_VOLTAGE_CURRENT_FAIL,
- 0,
- 0
- );
- return;
- }
- if( ! m_dcs_ctrl.DCS_close( &m_Dcs ) )
- {
- PostMessage(
- this->Handle,
- WM_MF_ADC_DCS_CLOSE_FAIL,
- 0,
- 0
- );
- return;
- }
- #if 0
- if( IS_AgilentPowerSupply_INITIALISE == true )
- {
- if ( rbAgilent661x->Checked )
- {
- /* Set output voltage and current levels, turn output off */
- if((hp661x_outputVoltCurr(MF_ADC_ctrl.vi, 1.0*i_OFF_VOLTAGE/1000.0, i_CURRENT_LIMIT/1000.0)) != VI_SUCCESS)
- {
- PostMessage(
- this->Handle,
- WM_MF_ADC_SET_VOLTAGE_CURRENT_FAIL,
- 0,
- 0
- );
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 661x set vlotage = " +
- Double_To_AnsiString(1.0*i_OFF_VOLTAGE/1000.0)
- );
- return;
- }
- else
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " set Agilent 661x set vlotage = " +
- Double_To_AnsiString(1.0*i_OFF_VOLTAGE/1000.0) + "n"
- );
- }
- // Close hp663x2
- if(hp661x_close(MF_ADC_ctrl.vi) != VI_SUCCESS)
- {
- PostMessage(
- this->Handle,
- WM_MF_AGE661x_CLOSE_FAIL,
- 0,
- 0
- );
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 661x close fail"
- );
- return;
- }
- IS_AgilentPowerSupply_INITIALISE = false;
- }
- else if ( rbAgilent663x2->Checked )
- {
- /* Set output voltage and current levels, turn output off */
- if((hp663x2_outputVoltCurr(MF_ADC_ctrl.vi, 1.0*i_OFF_VOLTAGE/1000.0, i_CURRENT_LIMIT/1000.0)) != VI_SUCCESS)
- {
- PostMessage(
- this->Handle,
- WM_MF_ADC_SET_VOLTAGE_CURRENT_FAIL,
- 0,
- 0
- );
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 663x2 set vlotage = " +
- Double_To_AnsiString(1.0*i_OFF_VOLTAGE/1000.0)
- );
- return;
- }
- else
- {
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " set Agilent 663x2 set vlotage = " +
- Double_To_AnsiString(1.0*i_OFF_VOLTAGE/1000.0)
- );
- }
- // Close hp663x2
- if(hp663x2_close(MF_ADC_ctrl.vi) != VI_SUCCESS)
- {
- PostMessage(
- this->Handle,
- WM_MF_AGE663x2_CLOSE_FAIL,
- 0,
- 0
- );
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() + " FAIL: Agilent 663x2 close fail"
- );
- return;
- }
- IS_AgilentPowerSupply_INITIALISE = false;
- }
- }
- #endif
- }
- //---------------------------------------------------------------------------
- void __fastcall TfrmFatcory::RCT_Dcl_Reset_Close( void )
- {
- if( ( m_Rct.age.vi != NULL && rbAgilent8960->Checked ) ||
- ( m_Rct.cmu.base != NULL && rbCMU200->Checked )
- )
- {
- if( ! m_rct_ctrl.RCT_dcl( &m_Rct ) )
- {
- PostMessage(
- this->Handle,
- WM_MF_AGE8960_DCL_FAIL,
- 0,
- 0
- );
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Agilent 8960 DCL"
- );
- return;
- }
- Sleep(50);
- if( ! m_rct_ctrl.RCT_reset( &m_Rct ) )
- {
- PostMessage(
- this->Handle,
- WM_MF_AGE8960_RESET_FAIL,
- 0,
- 0
- );
- st_Log->Add( DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: Agilent 8960 reset");
- return;
- }
- Sleep(50);
- AnsiString asFreqBand;
- META_factory_cfg->getFreqBank(asFreqBand);
- if (rbCrystal->Checked && m_Cal.s_CalItem.b_trx_offset_cal)
- {
- if (!m_rct_ctrl.RCT_sig_close(&m_Rct, asFreqBand))
- {
- PostMessage(
- this->Handle,
- WM_MF_AGE8960_CLOSE_FAIL,
- 0,
- 0
- );
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_Rct.as_RCT + " signalling close"
- );
- return;
- }
- }
- if (cbIP2->Checked ||
- cbAFC->Checked ||
- cbRxPathLoss->Checked ||
- cbTxIq->Checked ||
- cbTxPcl->Checked
- )
- {
- if (!m_rct_ctrl.RCT_close(&m_Rct, asFreqBand))
- {
- PostMessage(
- this->Handle,
- WM_MF_AGE8960_CLOSE_FAIL,
- 0,
- 0
- );
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_Rct.as_RCT + " close");
- return;
- }
- }
- if (!m_rct_ctrl.RCT_close_RM(&m_Rct))
- {
- PostMessage(this->Handle,
- WM_MF_AGE8960_CLOSE_FAIL,
- 0,
- 0
- );
- st_Log->Add(DateToStr(Date()) + " " + CurrentTimeStr() +
- " FAIL: " + m_Rct.as_RCT + " close handle manager");
- return;
- }
- }
- }
- //====================================================================================
- void TfrmFatcory::DisplayAFCType(void)
- {
- AnsiString as_AFC_Type = read_AFC_Type("MF_setup.txt", Application->ExeName);
- if(as_AFC_Type.AnsiCompareIC("crystal") == 0)
- {
- rbCrystal->Checked = true;
- }
- else
- {
- rbTCVCXO->Checked = true;
- }
- if ((RF_ID_A60111A == m_Cal.ui_rf_id) ||
- (RF_ID_AD6548 == m_Cal.ui_rf_id) ||
- (RF_ID_AERO2 == m_Cal.ui_rf_id) ||
- (RF_ID_AERO2E == m_Cal.ui_rf_id) ||
- (RF_ID_AG2550 == m_Cal.ui_rf_id) ||
- (RF_ID_MT6139B == m_Cal.ui_rf_id) ||
- (RF_ID_MT6139C == m_Cal.ui_rf_id) ||
- (RF_ID_MT6139E == m_Cal.ui_rf_id) ||
- (RF_ID_MT6140A == m_Cal.ui_rf_id) ||
- (RF_ID_MT6140B == m_Cal.ui_rf_id) ||
- (RF_ID_MT6140C == m_Cal.ui_rf_id) ||
- (RF_ID_MT6140D == m_Cal.ui_rf_id)
- )
- {
- rbCrystal->Checked = true;
- }
- else if ((RF_ID_MT6119 == m_Cal.ui_rf_id) ||
- (RF_ID_MT6119C == m_Cal.ui_rf_id) ||
- (RF_ID_MT6129A == m_Cal.ui_rf_id) ||
- (RF_ID_MT6129B == m_Cal.ui_rf_id) ||
- (RF_ID_MT6129C == m_Cal.ui_rf_id) ||
- (RF_ID_MT6129D == m_Cal.ui_rf_id)
- )
- {
- rbTCVCXO->Checked = true;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmFatcory::SaveAFCType(void)
- {
- if (rbCrystal->Checked)
- {
- write_AFC_Type( "MF_setup.txt", Application->ExeName, "Crystal" );
- }
- else
- {
- write_AFC_Type( "MF_setup.txt", Application->ExeName, "TCVCXO" );
- }
- }
- //====================================================================================
- void TfrmFatcory::DisplayCrystalCapId(void)
- {
- as_Crystal_Cap_Id = read_Crystal_CAP_ID("MF_setup.txt", Application->ExeName);
- if (as_Crystal_Cap_Id.AnsiCompareIC("run time update") == 0)
- {
- rbRunTimeUpdate->Checked = true;
- }
- else
- {
- rbWriteNVRAM->Checked = true;
- as_Crystal_Cap_Id = (AnsiString) "write NVRAM";
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmFatcory::SaveCrystalCapId(void)
- {
- if (rbRunTimeUpdate->Checked)
- {
- write_Crystal_CAP_ID("MF_setup.txt", Application->ExeName, "run time update");
- }
- else
- {
- write_Crystal_CAP_ID("MF_setup.txt", Application->ExeName, "write NVRAM");
- }
- }
- //====================================================================================
- void TfrmFatcory::DisplayTxAfcOffsetCal(void)
- {
- AnsiString as_TxAfcOffsetCal = read_TxAfcOffsetCal("MF_setup.txt", Application->ExeName);
- if (as_TxAfcOffsetCal.AnsiCompareIC("yes") == 0)
- {
- m_cbTrxOffset->Checked = true;
- }
- else
- {
- m_cbTrxOffset->Checked = false;
- }
- if ((RF_ID_A60111A == m_Cal.ui_rf_id) ||
- (RF_ID_AG2550 == m_Cal.ui_rf_id) ||
- (RF_ID_MT6139B == m_Cal.ui_rf_id) ||
- (RF_ID_MT6139C == m_Cal.ui_rf_id) ||
- (RF_ID_MT6139E == m_Cal.ui_rf_id) ||
- (RF_ID_MT6140A == m_Cal.ui_rf_id) ||
- (RF_ID_MT6140B == m_Cal.ui_rf_id) ||
- (RF_ID_MT6140C == m_Cal.ui_rf_id) ||
- (RF_ID_MT6140D == m_Cal.ui_rf_id)
- )
- {
- m_cbTrxOffset->Checked = true;
- }
- else if (RF_ID_AERO2 == m_Cal.ui_rf_id)
- {
- m_cbTrxOffset->Checked = false;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmFatcory::SaveTxAfcOffsetCal( void )
- {
- if ( m_cbTrxOffset->Checked )
- {
- write_TxAfcOffsetCal( "MF_setup.txt", Application->ExeName, "yes" );
- }
- else
- {
- write_TxAfcOffsetCal( "MF_setup.txt", Application->ExeName, "no" );
- }
- }
- //=============================================================================
- void TfrmFatcory::DisplayResetRfTester( void )
- {
- AnsiString as_ResetRfTester = read_ResetRfTester("MF_setup.txt", Application->ExeName);
- if(as_ResetRfTester.AnsiCompareIC("yes") == 0)
- {
- cbResetRfTester->Checked = true;
- }
- else
- {
- cbResetRfTester->Checked = false;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmFatcory::SaveResetRfTester( void )
- {
- if ( cbResetRfTester->Checked )
- {
- write_ResetRfTester( "MF_setup.txt", Application->ExeName, "yes" );
- }
- else
- {
- write_ResetRfTester( "MF_setup.txt", Application->ExeName, "no" );
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmFatcory::DisplayAFCCal( void )
- {
- AnsiString as_AFC = read_AFC("MF_setup.txt", Application->ExeName);
- if(as_AFC.AnsiCompareIC("yes") == 0)
- {
- cbAFC->Checked = true;
- }
- else
- {
- cbAFC->Checked = false;
- }
- }
- //---------------------------------------------------------------------------
- void TfrmFatcory::SaveAFCCal(void)
- {
- if ( cbAFC->Checked )
- {
- write_AFC("MF_setup.txt", Application->ExeName, "yes");
- }
- else
- {
- write_AFC("MF_setup.txt", Application->ExeName, "no");
- }
- }
- //====================================================================================
- void TfrmFatcory::DisplayRxPathLossCal(void)
- {
- AnsiString as_RxPathLoss = read_RxPathLoss("MF_setup.txt", Application->ExeName);
- if(as_RxPathLoss.AnsiCompareIC("yes") == 0)
- {
- cbRxPathLoss->Checked = true;
- }
- else
- {
- cbRxPathLoss->Checked = false;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmFatcory::SaveRxPathLossCal(void)
- {
- if (cbRxPathLoss->Checked)
- {
- write_RxPathLoss("MF_setup.txt", Application->ExeName, "yes");
- }
- else
- {
- write_RxPathLoss("MF_setup.txt", Application->ExeName, "no");
- }
- }
- //============================================================================
- void TfrmFatcory::DisplayTxIqCal( void )
- {
- AnsiString as_TxIqCal = read_TxIqCal("MF_setup.txt", Application->ExeName);
- if(as_TxIqCal.AnsiCompareIC("yes") == 0)
- {
- cbTxIq->Checked = true;
- }
- else
- {
- cbTxIq->Checked = false;
- }
- if ((RF_ID_A60111A == m_Cal.ui_rf_id) ||
- (RF_ID_AERO2E == m_Cal.ui_rf_id) ||
- (RF_ID_MT6139B == m_Cal.ui_rf_id) ||
- (RF_ID_MT6139C == m_Cal.ui_rf_id) ||
- (RF_ID_MT6139E == m_Cal.ui_rf_id) ||
- (RF_ID_MT6140A == m_Cal.ui_rf_id) ||
- (RF_ID_MT6140B == m_Cal.ui_rf_id) ||
- (RF_ID_MT6140C == m_Cal.ui_rf_id) ||
- (RF_ID_MT6140D == m_Cal.ui_rf_id)
- )
- {
- cbTxIq->Checked = true;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmFatcory::SaveTxIqCal( void )
- {
- if ( cbTxIq->Checked )
- {
- write_TxIqCal( "MF_setup.txt", Application->ExeName, "yes" );
- }
- else
- {
- write_TxIqCal( "MF_setup.txt", Application->ExeName, "no" );
- }
- }
- //====================================================================================
- void TfrmFatcory::DisplayIP2Cal( void )
- {
- AnsiString as_IP2 = read_IP2("MF_setup.txt", Application->ExeName);
- if( as_IP2.AnsiCompareIC("yes") == 0 && cbIP2->Visible )
- {
- cbIP2->Checked = true;
- }
- else
- {
- cbIP2->Checked = false;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmFatcory::DisplayIP2Visible(unsigned int ui_rf_id)
- {
- switch (ui_rf_id)
- {
- case RF_ID_SKY74045:
- case RF_ID_SKY74117:
- case RF_ID_SKY74400:
- // case RF_ID_MT6139B:
- // case RF_ID_MT6139C:
- // case RF_ID_MT6139E:
- // case RF_ID_MT6140A:
- // case RF_ID_MT6140B:
- {
- cbIP2->Visible = true;
- }
- break;
- default:
- {
- cbIP2->Visible = false;
- cbIP2->Enabled = false;
- cbIP2->Checked = false;
- }
- break;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmFatcory::SaveIP2Cal(void)
- {
- if (cbIP2->Checked)
- {
- write_IP2("MF_setup.txt", Application->ExeName, "yes");
- }
- else
- {
- write_IP2("MF_setup.txt", Application->ExeName, "no");
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmFatcory::DisplayTxPclCal(void)
- {
- AnsiString as_TxPcl = read_TxPcl("MF_setup.txt", Application->ExeName);
- if(as_TxPcl.AnsiCompareIC("yes") == 0)
- {
- cbTxPcl->Checked = true;
- }
- else
- {
- cbTxPcl->Checked = false;
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmFatcory::SaveTxPclCal(void)
- {
- if (cbTxPcl->Checked)
- {
- write_TxPcl("MF_setup.txt", Application->ExeName, "yes");
- }
- else
- {
- write_TxPcl("MF_setup.txt", Application->ExeName, "no");
- }
- }
- //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
- void TfrmFatcory::DisplayADCCal( void )
- {
- AnsiString as_ADC_calibration = read_ADC_calibration("MF_setup.txt", Application->ExeName);
- if(as_ADC_calibration.AnsiCompareIC("yes") == 0)
- {
- cbADC->Checked = true;
- }
- else
- {
- cbADC->Checked = false;
- }