META_Factory.cpp
上传用户:gelin96
上传日期:2017-01-08
资源大小:20993k
文件大小:269k
源码类别:

MTK

开发平台:

C++ Builder

  1. }
  2. //---------------------------------------------------------------------------
  3. void TfrmFatcory::SaveADCCal( void )
  4. {
  5.     if ( cbADC->Checked )
  6.     {
  7.         write_ADC_calibration( "MF_setup.txt", Application->ExeName, "yes" );
  8.     }
  9.     else
  10.     {
  11.         write_ADC_calibration( "MF_setup.txt", Application->ExeName, "no" );
  12.     }
  13. }
  14. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  15. void TfrmFatcory::DisplayCVCal(void)
  16. {
  17.     AnsiString  as_CV_calibration = read_CV_calibration("MF_setup.txt", Application->ExeName);
  18.     if (as_CV_calibration.AnsiCompareIC("yes") == 0)
  19.     {
  20.         m_cbCV->Checked = true;
  21.     }
  22.     else
  23.     {
  24.         m_cbCV->Checked = false;
  25.     }
  26.     if ((m_Cal.e_bb_chip != MT6205)  &&
  27. (m_Cal.e_bb_chip != MT6205B) &&
  28.         (m_Cal.e_bb_chip != MT6217)  &&
  29. (m_Cal.e_bb_chip != MT6218)  &&
  30. (m_Cal.e_bb_chip != MT6218B) &&
  31. (m_Cal.e_bb_chip != MT6219)  &&
  32.         (m_Cal.e_bb_chip != MT6225)  &&
  33.         (m_Cal.e_bb_chip != MT6226)  &&
  34. (m_Cal.e_bb_chip != MT6226D) &&
  35. (m_Cal.e_bb_chip != MT6226M) &&
  36.         (m_Cal.e_bb_chip != MT6227)  &&
  37.         (m_Cal.e_bb_chip != MT6227D) &&
  38. (m_Cal.e_bb_chip != MT6228)  &&
  39. (m_Cal.e_bb_chip != MT6229)  &&
  40. (m_Cal.e_bb_chip != MT6230)  &&
  41.         (m_Cal.e_bb_chip != MT6268T) &&
  42. (m_Cal.e_bb_chip != TK6516_MD)
  43.        )
  44.     {
  45.         m_cbCV->Visible = true;
  46.     }
  47.     else
  48.     {
  49.         m_cbCV->Visible = false;
  50.         m_cbCV->Checked = false;
  51.     }
  52. }
  53. //---------------------------------------------------------------------------
  54. void TfrmFatcory::SaveCVCal(void)
  55. {
  56.     if (m_cbCV->Checked)
  57.     {
  58.         write_CV_calibration("MF_setup.txt", Application->ExeName, "yes");
  59.     }
  60.     else
  61.     {
  62.         write_CV_calibration("MF_setup.txt", Application->ExeName, "no");
  63.     }
  64. }
  65. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  66. void TfrmFatcory::DisplayWiFiTxDcOffsetCal( void )
  67. {
  68.     AnsiString  as_WiFiTxDcOffset_calibration = read_WiFiTxDcOffset_calibration("MF_setup.txt", Application->ExeName);
  69.     if(as_WiFiTxDcOffset_calibration.AnsiCompareIC("yes") == 0)
  70.     {
  71.         cbWiFiTxDcOffset->Checked = true;
  72.     }
  73.     else
  74.     {
  75.         cbWiFiTxDcOffset->Checked = false;
  76.     }
  77.     WiFi_ChipCapability_S sWiFiCap = frmMainSel->Get_FinalWiFiCap();
  78.     if (sWiFiCap.support_802_11b ||
  79.         sWiFiCap.support_802_11a ||
  80.         sWiFiCap.support_802_11g
  81.        )
  82.     {
  83.         cbWiFiTxDcOffset->Visible = true;
  84.     }
  85.     else
  86.     {
  87.         cbWiFiTxDcOffset->Visible = false;
  88.         cbWiFiTxDcOffset->Checked = false;
  89.     }
  90. }
  91. //---------------------------------------------------------------------------
  92. void TfrmFatcory::SaveWiFiTxDcOffsetCal(void)
  93. {
  94.     if ( cbWiFiTxDcOffset->Checked )
  95.     {
  96.         write_WiFiTxDcOffset_calibration( "MF_setup.txt", Application->ExeName, "yes" );
  97.     }
  98.     else
  99.     {
  100.         write_WiFiTxDcOffset_calibration( "MF_setup.txt", Application->ExeName, "no" );
  101.     }
  102. }
  103. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  104. void TfrmFatcory::DisplayWiFiTxPowerCal(void)
  105. {
  106.     AnsiString  as_WiFiTxPower_calibration = read_WiFiTxPower_calibration("MF_setup.txt", Application->ExeName);
  107.     if(as_WiFiTxPower_calibration.AnsiCompareIC("yes") == 0)
  108.     {
  109.         cbWiFiTxPower->Checked = true;
  110.     }
  111.     else
  112.     {
  113.         cbWiFiTxPower->Checked = false;
  114.     }
  115.     WiFi_ChipCapability_S sWiFiCap = frmMainSel->Get_FinalWiFiCap();
  116.     if (sWiFiCap.support_802_11b ||
  117.         sWiFiCap.support_802_11a ||
  118.         sWiFiCap.support_802_11g
  119.        )
  120.     {
  121.         cbWiFiTxPower->Visible = true;
  122.     }
  123.     else
  124.     {
  125.         cbWiFiTxPower->Visible = false;
  126.         cbWiFiTxPower->Checked = false;
  127.     }
  128. }
  129. //---------------------------------------------------------------------------
  130. void TfrmFatcory::SaveWiFiTxPowerCal(void)
  131. {
  132.     if ( cbWiFiTxPower->Checked )
  133.     {
  134.         write_WiFiTxPower_calibration( "MF_setup.txt", Application->ExeName, "yes" );
  135.     }
  136.     else
  137.     {
  138.         write_WiFiTxPower_calibration( "MF_setup.txt", Application->ExeName, "no" );
  139.     }
  140. }
  141. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  142. void TfrmFatcory::DisplayBTCrystalCAPIDCal(void)
  143. {
  144.     AnsiString as_BTCrystalCAPIDCal = read_BTCrystalCAPID_calibration("MF_setup.txt", Application->ExeName);
  145.     if (as_BTCrystalCAPIDCal.AnsiCompareIC("yes") == 0)
  146.     {
  147.         m_cbBTCapID->Checked = true;
  148.     }
  149.     else
  150.     {
  151.         m_cbBTCapID->Checked = false;
  152.     }
  153. }
  154. //---------------------------------------------------------------------------
  155. void TfrmFatcory::SaveBTCrystalCAPIDCal(void)
  156. {
  157.     if (m_cbBTCapID->Checked)
  158.     {
  159.         write_BTCrystalCAPID_calibration("MF_setup.txt", Application->ExeName, "yes");
  160.     }
  161.     else
  162.     {
  163.         write_BTCrystalCAPID_calibration("MF_setup.txt", Application->ExeName, "no");
  164.     }
  165. }
  166. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  167. void TfrmFatcory::DisplayPAType(void)
  168. {
  169.      AnsiString as_PAType = read_PAType("MF_setup.txt", Application->ExeName);
  170.      if(as_PAType.AnsiCompareIC("RFMD3140") == 0)
  171.      {
  172.          cbPAType->ItemIndex = RFMD_3140;
  173.      }
  174.      else if(as_PAType.AnsiCompareIC("RFMD3159") == 0)
  175.      {
  176.          cbPAType->ItemIndex = RFMD_3159;
  177.      }
  178.      else if(as_PAType.AnsiCompareIC("RenesasPF08155B") == 0)
  179.      {
  180.          cbPAType->ItemIndex = RENESAS_PF08155B;
  181.      }
  182.      //else if(as_PAType.AnsiCompareIC("RenesasPF09016B") == 0)
  183.      //{
  184.      //   cbPAType->ItemIndex = RENESAS_PF09016B;
  185.      //}
  186.      else if(as_PAType.AnsiCompareIC("Skyworks77328") == 0)
  187.      {
  188.          cbPAType->ItemIndex = SKY_77328;
  189.      }
  190.      else if(as_PAType.AnsiCompareIC("Skyworks77506") == 0)
  191.      {
  192.          cbPAType->ItemIndex = SKY_77506;
  193.      }
  194.      else if(as_PAType.AnsiCompareIC("Skyworks77316") == 0)
  195.      {
  196.          cbPAType->ItemIndex = SKY_77316;
  197.      }
  198.      else if (as_PAType.AnsiCompareIC("Skyworks77340") == 0)
  199.      {
  200.          cbPAType->ItemIndex = SKY_77340;
  201.      }
  202.      else if (as_PAType.AnsiCompareIC("Axiom502") == 0)
  203.      {
  204.          cbPAType->ItemIndex = AXIOM_AX502;
  205.      }
  206.      else if (as_PAType.AnsiCompareIC("Triquint TQM6M5001") == 0)
  207.      {
  208.          cbPAType->ItemIndex = TRIQUINT_TQM6M5001;
  209.      }
  210.      else
  211.      {
  212.          cbPAType->ItemIndex = RFMD_3140;
  213.      }
  214. }
  215. //---------------------------------------------------------------------------
  216. void TfrmFatcory::SavePAType(void)
  217. {
  218.     switch (cbPAType->ItemIndex)
  219.     {
  220.         case RFMD_3140:
  221.         {
  222.              write_PAType("MF_setup.txt", Application->ExeName, "RFMD3140");
  223.         }
  224.         break;
  225.         case RFMD_3159:
  226.         {
  227.              write_PAType("MF_setup.txt", Application->ExeName, "RFMD3159");
  228.         }
  229.         break;
  230.         case SKY_77328:
  231.         {
  232.              write_PAType("MF_setup.txt", Application->ExeName, "Skyworks77328");
  233.         }
  234.         break;
  235.         case SKY_77506:
  236.         {
  237.              write_PAType("MF_setup.txt", Application->ExeName, "Skyworks77506");
  238.         }
  239.         break;
  240.         case SKY_77316:
  241.         {
  242.              write_PAType("MF_setup.txt", Application->ExeName, "Skyworks77316");
  243.         }
  244.         break;
  245.         case SKY_77340:
  246.         {
  247.             write_PAType("MF_setup.txt", Application->ExeName, "Skyworks77340");
  248.         }
  249.         break;
  250.         
  251.         case RENESAS_PF08155B:
  252.         {
  253.              write_PAType("MF_setup.txt", Application->ExeName, "RenesasPF08155B");
  254.         }
  255.         break;
  256.        //case RENESAS_PF09016B:
  257.        //      write_PAType( "MF_setup.txt", Application->ExeName, "RenesasPF09016B" );
  258.        // break;
  259.         case AXIOM_AX502:
  260.         {
  261.             write_PAType("MF_setup.txt", Application->ExeName, "Axiom502");
  262.         }
  263.         break;
  264.         case TRIQUINT_TQM6M5001:
  265.         {
  266.             write_PAType("MF_setup.txt", Application->ExeName, "Triquint TQM6M5001");
  267.         }    
  268.         default:
  269.         {
  270.         }
  271.         break;
  272.     }
  273. }
  274. #if 0
  275. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  276. void TfrmFatcory::DisplayPABiasType(void)
  277. {
  278.      AnsiString as_PABiasType = read_PABiasType("MF_setup.txt", Application->ExeName);
  279.     // if(as_PABiasType.AnsiCompareIC("Fixed") == 0)
  280.      {
  281.      //    m_rbFixedPaBias->Checked = true;
  282.      }
  283.     // else
  284.     // {
  285.     //     m_rbDynPaBias->Checked = true;
  286.     // }
  287.     // if (RFMD_3159 == cbPAType->ItemIndex)
  288.     // {
  289.     //     m_gbPaBias->Visible = true;
  290.     // }
  291.     // else
  292.      {
  293.         // m_gbPaBias->Visible = false;
  294.      }
  295. }
  296. #endif
  297. #if 0
  298. //---------------------------------------------------------------------------
  299. void TfrmFatcory::SavePABiasType(void)
  300. {
  301.     if (m_rbFixedPaBias->Checked)
  302.     {
  303.         write_PABiasType("MF_setup.txt", Application->ExeName, "Fixed");
  304.     }
  305.     else
  306.     {
  307.         write_PABiasType("MF_setup.txt", Application->ExeName, "Dynamic");
  308.     }
  309. }
  310. #endif
  311. //====================================================================================
  312. void TfrmFatcory::DisplayTXPCLType(void)
  313. {
  314.      // GMSK
  315.      AnsiString as_GMSK_TX_PCL_type = read_GMSK_TX_PCL_type("MF_setup.txt", Application->ExeName);
  316.      if (as_GMSK_TX_PCL_type.AnsiCompareIC("full pcl") == 0)
  317.      {
  318.          m_rbGMSKFullPCL->Checked = true;
  319.          if (SKY_77316 == cbPAType->ItemIndex ||
  320.              SKY_77328 == cbPAType->ItemIndex ||
  321.              SKY_77506 == cbPAType->ItemIndex
  322.             )
  323.          {
  324.              m_rbGMSK2PCL->Enabled = true;
  325.              m_rbGMSK3PCL->Enabled = false;
  326.              m_rb6DAC->Enabled = false;
  327.          }
  328.          else
  329.          {
  330.              m_rbGMSK2PCL->Enabled = false;
  331.              m_rbGMSK3PCL->Enabled = true;
  332.              m_rb6DAC->Enabled = false;
  333.          }
  334.      }
  335.      else // not GMSK TX PCL
  336.      {
  337.          if (SKY_77316 == cbPAType->ItemIndex ||
  338.              SKY_77328 == cbPAType->ItemIndex ||
  339.              SKY_77506 == cbPAType->ItemIndex
  340.             )
  341.          {
  342.              m_rbGMSK2PCL->Enabled = true;
  343.              m_rbGMSK2PCL->Checked = true;
  344.              m_rbGMSK3PCL->Enabled = false;
  345.              m_rb6DAC->Enabled = false;
  346.          }
  347.          else
  348.          {
  349.              m_rbGMSK3PCL->Checked = true;
  350.              m_rbGMSK2PCL->Enabled = false;
  351.              m_rbGMSK3PCL->Enabled = true;
  352.              m_rb6DAC->Enabled = false;
  353.          }
  354.      }
  355.      if (SKY_77340 == cbPAType->ItemIndex)
  356.      {
  357.         m_rbGMSK3PCL->Enabled = false;
  358.      }
  359.      // EPSK
  360.      AnsiString as_EPSK_TX_PCL_type = read_EPSK_TX_PCL_type("MF_setup.txt", Application->ExeName);
  361.      if (as_EPSK_TX_PCL_type.AnsiCompareIC("full pcl") == 0)
  362.      {
  363.          m_rbEPSKFullPCL->Checked = true;
  364.          if (SKY_77316 == cbPAType->ItemIndex)
  365.          {
  366.              m_gbEPSKTxPcl->Visible = true;
  367.              m_rbEPSK1PCL->Enabled = false;
  368.              m_rbEPSK2PCL->Enabled = true;
  369.              m_rbEPSK3PCL->Enabled = false;
  370.              m_rbEPSK4PCL->Enabled = false;
  371.          }
  372.          else if ((RFMD_3159 == cbPAType->ItemIndex) ||
  373.                   (SKY_77340 == cbPAType->ItemIndex)
  374.                  ) 
  375.          {
  376.             m_gbEPSKTxPcl->Visible = true;
  377.             if (m_Cal.ui_rf_id != RF_ID_A60111A)
  378.             {
  379.                 m_rbEPSK1PCL->Enabled = false;
  380.                 m_rbEPSK4PCL->Enabled = true;
  381.             }
  382.             else
  383.             {
  384.                 m_rbEPSK1PCL->Enabled = true;
  385.                 m_rbEPSK4PCL->Enabled = false;
  386.             }
  387.             m_rbEPSK2PCL->Enabled = false;
  388.             m_rbEPSK3PCL->Enabled = false;
  389.          }
  390.          else
  391.          {
  392.              m_gbEPSKTxPcl->Visible = false;
  393.          }
  394.      }
  395.      else // not full EPSK TX PCL
  396.      {
  397.          if (SKY_77316 == cbPAType->ItemIndex)
  398.          {
  399.              m_gbEPSKTxPcl->Visible = true;
  400.              m_rbEPSK1PCL->Enabled = false;
  401.              m_rbEPSK2PCL->Enabled = true;
  402.              m_rbEPSK2PCL->Checked = true;
  403.              m_rbEPSK3PCL->Enabled = false;
  404.              m_rbEPSK4PCL->Enabled = false;
  405.          }
  406.          else if ((RFMD_3159 == cbPAType->ItemIndex) ||
  407.                   (SKY_77340 == cbPAType->ItemIndex)
  408.                  ) 
  409.          {
  410.             m_gbEPSKTxPcl->Visible = true;
  411.             if (m_Cal.ui_rf_id != RF_ID_A60111A)
  412.             {
  413.                 m_rbEPSK1PCL->Enabled = false;
  414.                 m_rbEPSK4PCL->Enabled = true;
  415.                 m_rbEPSK4PCL->Checked = true;
  416.             }
  417.             else
  418.             {
  419.                 m_rbEPSK1PCL->Enabled = true;
  420.                 m_rbEPSK1PCL->Checked = true;
  421.                 m_rbEPSK4PCL->Enabled = false;
  422.             }
  423.             m_rbEPSK2PCL->Enabled = false;
  424.             m_rbEPSK3PCL->Enabled = false;
  425.          }
  426.          else
  427.          {
  428.             m_gbEPSKTxPcl->Visible = false;
  429.          }
  430.     }
  431. }
  432. //--------------------------------------------------------------------------
  433. void TfrmFatcory::SaveTXPCLType(void)
  434. {
  435.     // GMSK
  436.     if (m_rbGMSK2PCL->Checked)
  437.     {
  438.         write_GMSK_TX_PCL_type("MF_setup.txt", Application->ExeName, "2 pcl");
  439.     }
  440.     else if (m_rbGMSK3PCL->Checked)
  441.     {
  442.         write_GMSK_TX_PCL_type("MF_setup.txt", Application->ExeName, "3 pcl");
  443.     }
  444.     else
  445.     {
  446.         write_GMSK_TX_PCL_type("MF_setup.txt", Application->ExeName, "full pcl");
  447.     }
  448.     // EPSK
  449.     if (m_rbEPSK1PCL->Checked)
  450.     {
  451.         write_EPSK_TX_PCL_type("MF_setup.txt", Application->ExeName, "1 pcl");
  452.     }
  453.     else if (m_rbEPSK2PCL->Checked)
  454.     {
  455.         write_EPSK_TX_PCL_type("MF_setup.txt", Application->ExeName, "2 pcl");
  456.     }
  457.     else if (m_rbEPSK3PCL->Checked)
  458.     {
  459.         write_EPSK_TX_PCL_type("MF_setup.txt", Application->ExeName, "3 pcl");
  460.     }
  461.     else if (m_rbEPSK4PCL->Checked)
  462.     {
  463.         write_EPSK_TX_PCL_type("MF_setup.txt", Application->ExeName, "4 pcl");
  464.     }
  465.     else
  466.     {
  467.         write_EPSK_TX_PCL_type("MF_setup.txt", Application->ExeName, "full pcl");
  468.     }
  469. }
  470. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  471. void TfrmFatcory::DisplayApcModulation(void)
  472. {
  473.     // GMSK
  474.     AnsiString as_APC_GMSK_Mod = read_APC_GMSK_Modulation("MF_setup.txt", Application->ExeName);
  475.     if (as_APC_GMSK_Mod.AnsiCompareIC("yes") == 0)
  476.     {
  477.         m_cbGMSK->Checked = true;
  478.     }
  479.     else
  480.     {
  481.         m_cbGMSK->Checked = false;
  482.     }
  483.     // EPSK
  484.     AnsiString as_APC_EPSK_Mod = read_APC_EPSK_Modulation("MF_setup.txt", Application->ExeName);
  485.     if (as_APC_EPSK_Mod.AnsiCompareIC("yes") == 0)
  486.     {
  487.         m_cbEPSK->Checked = true;
  488.     }
  489.     else
  490.     {
  491.         m_cbEPSK->Checked = false;
  492.     }
  493.     if ((RFMD_3159 == cbPAType->ItemIndex) ||
  494.         (SKY_77316 == cbPAType->ItemIndex) ||
  495.         (SKY_77340 == cbPAType->ItemIndex)
  496.        ) 
  497.     {
  498.          m_cbEPSK->Visible = true;
  499.          m_gbEPSKTxPcl->Visible = true;
  500.     }
  501.     else
  502.     {
  503.          m_cbEPSK->Visible = false;
  504.          m_gbEPSKTxPcl->Visible = false;
  505.     }
  506. }
  507. //---------------------------------------------------------------------------
  508. void TfrmFatcory::SaveApcModulation(void)
  509. {
  510.     if (m_cbGMSK->Checked)
  511.     {
  512.         write_APC_GMSK_Modulation("MF_setup.txt", Application->ExeName, "yes");
  513.     }
  514.     else
  515.     {
  516.         write_APC_EPSK_Modulation("MF_setup.txt", Application->ExeName, "no");
  517.     }
  518.     if (m_cbEPSK->Checked)
  519.     {
  520.         write_APC_EPSK_Modulation("MF_setup.txt", Application->ExeName, "yes");
  521.     }
  522.     else
  523.     {
  524.         write_APC_EPSK_Modulation("MF_setup.txt", Application->ExeName, "no");
  525.     }
  526. }
  527. //====================================================================================
  528. void TfrmFatcory::DisplayRFCalibrationEquipment(void)
  529. {
  530.     AnsiString as_RF_calibration_equipment = read_RF_calibration_equipment("MF_setup.txt", Application->ExeName);
  531.     m_Rct.device_type = m_rct_ctrl.RCT_StringToDeviceType( as_RF_calibration_equipment );
  532.     switch( m_Rct.device_type )
  533.     {
  534.         case AGILENT_8960:
  535.         {
  536.              rbAgilent8960->Checked = true;
  537.         }
  538.         break;
  539.         case CMU_200:
  540.         default:
  541.         {
  542.              rbCMU200->Checked = true;
  543.         }     
  544.         break;
  545.     }
  546. }
  547. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  548. void TfrmFatcory::SaveRFCalibrationEquipment( void )
  549. {
  550.     if ( rbAgilent8960->Checked )
  551.     {
  552.         write_RF_calibration_equipment( "MF_setup.txt", Application->ExeName, "agilent 8960" );
  553.     }
  554.     else
  555.     {
  556.         write_RF_calibration_equipment( "MF_setup.txt", Application->ExeName, "cmu 200" );
  557.     }
  558. }
  559. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  560. void TfrmFatcory::DisplayWiFiCalibrationEquipment(void)
  561. {
  562.     AnsiString as_WiFi_calibration_equipment = read_WiFi_calibration_equipment("MF_setup.txt", Application->ExeName);
  563.     if (as_WiFi_calibration_equipment.AnsiCompareIC("N4010A") == 0)
  564.     {
  565.         rbAgilentN4010A->Checked = true;
  566.     }
  567.     else
  568.     {
  569.         rbLitePointIQV->Checked = true;
  570.     }
  571. }
  572. //---------------------------------------------------------------------------
  573. void TfrmFatcory::SaveWiFiCalibrationEquipment(void)
  574. {
  575.     if (rbAgilentN4010A->Checked)
  576.     {
  577.         write_WiFi_calibration_equipment("MF_setup.txt", Application->ExeName, "N4010A");
  578.     }
  579.     else
  580.     {
  581.         write_WiFi_calibration_equipment("MF_setup.txt", Application->ExeName, "IQView" );
  582.     }
  583. }
  584. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  585. void TfrmFatcory::DisplayBTCalibrationEquipment(void)
  586. {
  587.     AnsiString as_WiFi_calibration_equipment = read_BT_calibration_equipment("MF_setup.txt", Application->ExeName);
  588.     if (as_WiFi_calibration_equipment.AnsiCompareIC("CMU 200") == 0)
  589.     {
  590.         m_cbBTTester->ItemIndex = BT_DEVICE_CMU_200;
  591.     }
  592.     else
  593.     {
  594.         m_cbBTTester->ItemIndex = BT_DEVICE_CBT;
  595.     }
  596. }
  597. //---------------------------------------------------------------------------
  598. void TfrmFatcory::SaveBTCalibrationEquipment(void)
  599. {
  600.     switch (m_cbBTTester->ItemIndex)
  601.     {
  602.         case BT_DEVICE_CMU_200:
  603.         {
  604.             write_BT_calibration_equipment("MF_setup.txt", Application->ExeName, "CMU 200");
  605.         }
  606.         break;
  607.         case BT_DEVICE_CBT:
  608.         {
  609.             write_BT_calibration_equipment("MF_setup.txt", Application->ExeName, "CBT");
  610.         }
  611.         break;
  612.         default:
  613.         {
  614.         }
  615.         break;
  616.     }
  617. }
  618. //====================================================================================
  619. void TfrmFatcory::DisplayPowerSupplyType(void)
  620. {
  621.      AnsiString as_Power_Supply_Type = read_Power_Supply_Type("MF_setup.txt", Application->ExeName);
  622.      m_Dcs.device_type = m_dcs_ctrl.DCS_StringToDeviceType( as_Power_Supply_Type );
  623.      m_cbPowerSupply->ItemIndex = m_Dcs.device_type;
  624. }
  625. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  626. void TfrmFatcory::SavePowerSupplyType(void)
  627. {
  628.     switch (m_cbPowerSupply->ItemIndex)
  629.     {
  630.         case AGILENT_661x:
  631.         {
  632.             write_Power_Supply_Type("MF_setup.txt", Application->ExeName, AGILENT_661x_STR);
  633.         }
  634.         break;
  635.         case AGILENT_663x2:
  636.         {
  637.             write_Power_Supply_Type("MF_setup.txt", Application->ExeName, AGILENT_663x2_STR);
  638.         }
  639.         break;
  640.         case AGILENT_E3631A:
  641.         {
  642.             write_Power_Supply_Type("MF_setup.txt", Application->ExeName, AGILENT_E3631A_STR);
  643.         }
  644.         break;
  645.         case KEITHLEY_2306:
  646.         {
  647.             write_Power_Supply_Type("MF_setup.txt", Application->ExeName, KEITHLEY_2306_STR);
  648.         }
  649.         break;
  650.         default:
  651.         {
  652.         }
  653.         break;
  654.     }
  655. }
  656. //====================================================================================
  657. void TfrmFatcory::DisplayReadBarcodeFromEnter( void )
  658. {
  659.      as_Read_barcode_from_enter = read_Read_barcode_from_enter("MF_setup.txt", Application->ExeName);
  660.      if(as_Read_barcode_from_enter.AnsiCompareIC("file") == 0)
  661.      {
  662.          cbReadBarcodeFromEnter->ItemIndex = BARCODE_READ_FROM_FILE_INDEX;
  663.          as_Barcode = read_Barcode("MF_setup.txt", Application->ExeName);
  664.          edtBarcode->Text = as_Barcode;
  665.          DisplayBarcodeAfterIncreasement( cbBarcodeIncreasementEnter->ItemIndex );
  666.      }
  667.      else if(as_Read_barcode_from_enter.AnsiCompareIC("flash") == 0)
  668.      {
  669.          cbReadBarcodeFromEnter->ItemIndex = BARCODE_READ_FROM_FLASH_INDEX;
  670.          ReadBarcodeFromNVRAM();
  671.      }
  672.      else
  673.      {
  674.          cbReadBarcodeFromEnter->ItemIndex = BARCODE_READ_FROM_NONE_INDEX;
  675.      }
  676. }
  677. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  678. void TfrmFatcory::SaveReadBarcodeFromEnter( void )
  679. {
  680.      if ( cbReadBarcodeFromEnter->ItemIndex == BARCODE_READ_FROM_FILE_INDEX )
  681.      {
  682.           write_Read_barcode_from_enter( "MF_setup.txt", Application->ExeName, "file" );
  683.      }
  684.      else if ( cbReadBarcodeFromEnter->ItemIndex == BARCODE_READ_FROM_FLASH_INDEX )
  685.      {
  686.           write_Read_barcode_from_enter( "MF_setup.txt", Application->ExeName, "flash" );
  687.      }
  688.      else
  689.      {
  690.           write_Read_barcode_from_enter( "MF_setup.txt", Application->ExeName, "none" );
  691.      }
  692. }
  693. //====================================================================================
  694. void TfrmFatcory::DisplayAutoStartCalibrationEnter( void )
  695. {
  696.      as_Auto_start_calibration_enter = read_Auto_start_calibration_enter("MF_setup.txt", Application->ExeName);
  697.      if(as_Auto_start_calibration_enter.AnsiCompareIC("yes") == 0)
  698.      {
  699.           cbAutoStartCalibrationEnter->Checked = true;
  700.      }
  701.      else
  702.      {
  703.          cbAutoStartCalibrationEnter->Checked = false;
  704.      }
  705. }
  706. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  707. void TfrmFatcory::SaveAutoStartCalibrationEnter( void )
  708. {
  709.      if ( cbAutoStartCalibrationEnter->Checked == true )
  710.      {
  711.           write_Auto_start_calibration_enter("MF_setup.txt", Application->ExeName, "yes" );
  712.      }
  713.      else
  714.      {
  715.           write_Auto_start_calibration_enter("MF_setup.txt", Application->ExeName, "no" );
  716.      }
  717. }
  718. //====================================================================================
  719. void TfrmFatcory::DisplayBarcodeIncreasementEnter( void )
  720. {
  721.      int temp_Barcode;
  722.      as_Barcode_increasement_enter = read_Barcode_increasement_enter("MF_setup.txt", Application->ExeName);
  723.      if (as_Barcode_increasement_enter.ToInt() <= 9)
  724.      {
  725.          cbBarcodeIncreasementEnter->ItemIndex = as_Barcode_increasement_enter.ToInt();
  726.          //if( cbReadBarcodeFromEnter->ItemIndex != BARCODE_READ_FROM_FLASH_INDEX )
  727.          //{
  728.          //   DisplayBarcodeAfterIncreasement( cbBarcodeIncreasementEnter->ItemIndex );
  729.          //}   
  730.      }
  731.      else
  732.      {
  733.          cbBarcodeIncreasementEnter->ItemIndex = 1; // set to increasement 1
  734.      }
  735. }
  736. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  737. void TfrmFatcory::SaveBarcodeIncreasementEnter( void )
  738. {
  739.      write_Barcode_increasement_enter( "MF_setup.txt", Application->ExeName, IntToStr((cbBarcodeIncreasementEnter->ItemIndex)) );
  740. }
  741. //====================================================================================
  742. void TfrmFatcory::DisplayBarcodeIncreasementExit( void )
  743. {
  744.      as_Barcode_increasement_exit = read_Barcode_increasement_exit("MF_setup.txt", Application->ExeName);
  745.      if (as_Barcode_increasement_exit.ToInt() <= 9)
  746.      {
  747.          cbBarcodeIncreasementExit->ItemIndex = as_Barcode_increasement_exit.ToInt();
  748.      }
  749.      else
  750.      {
  751.          cbBarcodeIncreasementExit->ItemIndex = 1; // set to increasement 1
  752.      }
  753. }
  754. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  755. void TfrmFatcory::SaveBarcodeIncreasementExit( void )
  756. {
  757.      write_Barcode_increasement_exit( "MF_setup.txt", Application->ExeName, IntToStr((cbBarcodeIncreasementExit->ItemIndex)) );
  758. }
  759. //====================================================================================
  760. void TfrmFatcory::DisplaySaveBarcodeToNVRAMSuccess( void )
  761. {
  762.      as_Save_barcode_to_NVRAM_success = read_Save_barcode_to_NVRAM_success("MF_setup.txt", Application->ExeName);
  763.      if (as_Save_barcode_to_NVRAM_success.AnsiCompareIC("yes") == 0)
  764.      {
  765.          cbSaveBarcodeToNVRAMSuccess->Checked = true;
  766.      }
  767.      else
  768.      {
  769.          cbSaveBarcodeToNVRAMSuccess->Checked = false;
  770.      }
  771. }
  772. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  773. void TfrmFatcory::SaveSaveBarcodeToNVRAMSuccess( void )
  774. {
  775.      if( cbSaveBarcodeToNVRAMSuccess->Checked == true )
  776.      {
  777.          write_Save_barcode_to_NVRAM_success( "MF_setup.txt", Application->ExeName, (AnsiString) "yes" );
  778.      }
  779.      else
  780.      {
  781.          write_Save_barcode_to_NVRAM_success( "MF_setup.txt", Application->ExeName, (AnsiString) "no" );
  782.      }
  783. }
  784. //====================================================================================
  785. void TfrmFatcory::DisplaySaveBarcodeToFileSuccess( void )
  786. {
  787.      as_Save_barcode_to_file_success = read_Save_barcode_to_file_success("MF_setup.txt", Application->ExeName);
  788.      if (as_Save_barcode_to_file_success.AnsiCompareIC("yes") == 0)
  789.      {
  790.          cbSaveBarcodeToFileSuccess->Checked = true;
  791.      }
  792.      else
  793.      {
  794.          cbSaveBarcodeToFileSuccess->Checked = false;
  795.      }
  796. }
  797. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  798. void TfrmFatcory::SaveSaveBarcodeToFileSuccess( void )
  799. {
  800.      if( cbSaveBarcodeToFileSuccess->Checked == true )
  801.      {
  802.          write_Save_barcode_to_file_success( "MF_setup.txt", Application->ExeName, (AnsiString) "yes" );
  803.      }
  804.      else
  805.      {
  806.          write_Save_barcode_to_file_success( "MF_setup.txt", Application->ExeName, (AnsiString) "no" );
  807.      }
  808. }
  809. //====================================================================================
  810. void TfrmFatcory::DisplayBarcodeIncreasementSuccess( void )
  811. {
  812.      as_Barcode_increasement_success = read_Barcode_increasement_success("MF_setup.txt", Application->ExeName);
  813.      if (as_Barcode_increasement_success.ToInt() <= 9)
  814.      {
  815.          cbBarcodeIncreasementSuccess->ItemIndex = as_Barcode_increasement_success.ToInt();
  816.      }
  817.      else
  818.      {
  819.          cbBarcodeIncreasementSuccess->ItemIndex = 1; // set to increasement 1
  820.      }
  821. }
  822. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  823. void TfrmFatcory::SaveBarcodeIncreasementSuccess( void )
  824. {
  825.      write_Barcode_increasement_success( "MF_setup.txt", Application->ExeName, IntToStr((cbBarcodeIncreasementSuccess->ItemIndex)) );
  826. }
  827. //====================================================================================
  828. void TfrmFatcory::DisplaySaveBarcodeToNVRAMFail( void )
  829. {
  830.      as_Save_barcode_to_NVRAM_fail = read_Save_barcode_to_NVRAM_fail("MF_setup.txt", Application->ExeName);
  831.      if (as_Save_barcode_to_NVRAM_fail.AnsiCompareIC("yes") == 0)
  832.      {
  833.          cbSaveBarcodeToNVRAMFail->Checked = true;
  834.      }
  835.      else
  836.      {
  837.          cbSaveBarcodeToNVRAMFail->Checked = false;
  838.      }
  839. }
  840. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  841. void TfrmFatcory::SaveSaveBarcodeToNVRAMFail( void )
  842. {
  843.      if( cbSaveBarcodeToNVRAMFail->Checked == true )
  844.      {
  845.          write_Save_barcode_to_NVRAM_fail( "MF_setup.txt", Application->ExeName, (AnsiString) "yes" );
  846.      }
  847.      else
  848.      {
  849.          write_Save_barcode_to_NVRAM_fail( "MF_setup.txt", Application->ExeName, (AnsiString) "no" );
  850.      }
  851. }
  852. //====================================================================================
  853. void TfrmFatcory::DisplaySaveBarcodeToFileFail( void )
  854. {
  855.      as_Save_barcode_to_file_fail = read_Save_barcode_to_file_fail("MF_setup.txt", Application->ExeName);
  856.      if (as_Save_barcode_to_file_fail.AnsiCompareIC("yes") == 0)
  857.      {
  858.          cbSaveBarcodeToFileFail->Checked = true;
  859.      }
  860.      else
  861.      {
  862.          cbSaveBarcodeToFileFail->Checked = false;
  863.      }
  864. }
  865. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  866. void TfrmFatcory::SaveSaveBarcodeToFileFail( void )
  867. {
  868.      if( cbSaveBarcodeToFileFail->Checked == true )
  869.      {
  870.          write_Save_barcode_to_file_fail( "MF_setup.txt", Application->ExeName, (AnsiString) "yes" );
  871.      }
  872.      else
  873.      {
  874.          write_Save_barcode_to_file_fail( "MF_setup.txt", Application->ExeName, (AnsiString) "no" );
  875.      }
  876. }
  877. //---------------------------------------------------------------------------------------
  878. void TfrmFatcory::SaveBarcodeToFile( void )
  879. {
  880.      write_Barcode( "MF_setup.txt", Application->ExeName, edtBarcode->Text );
  881. }
  882. //====================================================================================
  883. void TfrmFatcory::DisplayBarcodeIncreasementFail( void )
  884. {
  885.      as_Barcode_increasement_fail = read_Barcode_increasement_fail("MF_setup.txt", Application->ExeName);
  886.      if (as_Barcode_increasement_fail.ToInt() <= 9)
  887.      {
  888.          cbBarcodeIncreasementFail->ItemIndex = as_Barcode_increasement_fail.ToInt();
  889.      }
  890.      else
  891.      {
  892.          cbBarcodeIncreasementFail->ItemIndex = 1; // set to increasement 1
  893.      }
  894. }
  895. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  896. void TfrmFatcory::SaveBarcodeIncreasementFail( void )
  897. {
  898.      write_Barcode_increasement_fail( "MF_setup.txt", Application->ExeName, IntToStr((cbBarcodeIncreasementFail->ItemIndex)) );
  899. }
  900. //====================================================================================
  901. void TfrmFatcory::DisplaySaveBarcodeToNVRAMExit( void )
  902. {
  903.      as_Save_barcode_to_NVRAM_exit = read_Save_barcode_to_NVRAM_exit("MF_setup.txt", Application->ExeName);
  904.      if(as_Save_barcode_to_NVRAM_exit.AnsiCompare("yes") == 0)
  905.      {
  906.          cbSaveBarcodeToNVRAMExit->Checked = true;
  907.      }
  908.      else
  909.      {
  910.          cbSaveBarcodeToNVRAMExit->Checked = false;
  911.      }
  912. }
  913. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  914. void TfrmFatcory::SaveSaveBarcodeToNVRAMExit( void )
  915. {
  916.      if ( cbSaveBarcodeToNVRAMExit->Checked == true )
  917.      {
  918.           write_Save_barcode_to_NVRAM_exit( "MF_setup.txt", Application->ExeName, "yes" );
  919.           WriteBarcodeToNVRAMAfterIncreasement( cbBarcodeIncreasementExit->ItemIndex );
  920.      }
  921.      else
  922.      {
  923.           write_Save_barcode_to_NVRAM_exit( "MF_setup.txt", Application->ExeName, "no" );
  924.      }
  925. }
  926. //====================================================================================
  927. void TfrmFatcory::DisplaySaveBarcodeToFileExit( void )
  928. {
  929.      as_Save_barcode_to_file_exit = read_Save_barcode_to_file_exit("MF_setup.txt", Application->ExeName);
  930.      if(as_Save_barcode_to_file_exit.AnsiCompare("yes") == 0)
  931.      {
  932.          cbSaveBarcodeToFileExit->Checked = true;
  933.      }
  934.      else
  935.      {
  936.          cbSaveBarcodeToFileExit->Checked = false;
  937.      }
  938. }
  939. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  940. void TfrmFatcory::SaveSaveBarcodeToFileExit( void )
  941. {
  942.      if ( cbSaveBarcodeToFileExit->Checked == true )
  943.      {
  944.           write_Save_barcode_to_file_exit( "MF_setup.txt", Application->ExeName, "yes" );
  945.           SaveBarcodeAfterIncreasement( cbBarcodeIncreasementExit->ItemIndex );
  946.      }
  947.      else
  948.      {
  949.           write_Save_barcode_to_file_exit( "MF_setup.txt", Application->ExeName, "no" );
  950.      }
  951. }
  952. //====================================================================================
  953. void TfrmFatcory::DisplayTerminateMETAExit ( void )
  954. {
  955.      as_Terminate_META_exit = read_Terminate_META_exit("MF_setup.txt", Application->ExeName);
  956.      if(as_Terminate_META_exit.AnsiCompareIC("yes") == 0)
  957.      {
  958.           cbTerminateMETAExit->Checked = true;
  959.      }
  960.      else
  961.      {
  962.           cbTerminateMETAExit->Checked = false;
  963.      }
  964. }
  965. //------------------------------------------------------------------------------
  966. void TfrmFatcory::SaveTerminateMETAExit( void )
  967. {
  968.     write_Terminate_META_exit( "MF_setup.txt", Application->ExeName, as_Terminate_META_exit );
  969. }
  970. //====================================================================================
  971. void TfrmFatcory::DisplayTurnOffPowerSupplyFail ( void )
  972. {
  973.      as_Turn_off_power_supply_fail = read_TurnOffPowerSupplyFail("MF_setup.txt", Application->ExeName);
  974.      if(as_Turn_off_power_supply_fail.AnsiCompareIC("yes") == 0)
  975.      {
  976.           cbTurnOffPowerSupplyFail->Checked = true;
  977.      }
  978.      else if(as_Terminate_META_fail.AnsiCompareIC("no") == 0)
  979.      {
  980.           cbTurnOffPowerSupplyFail->Checked = false;
  981.      }
  982.      else
  983.      {
  984.           cbTurnOffPowerSupplyFail->Checked = false;
  985.            as_Turn_off_power_supply_fail = (AnsiString) "no";
  986.      }
  987. }
  988. //------------------------------------------------------------------------------
  989. void TfrmFatcory::SaveTurnOffPowerSupplyFail ( void )
  990. {
  991.      write_TurnOffPowerSupplyFail( "MF_setup.txt", Application->ExeName,  as_Turn_off_power_supply_fail );
  992. }
  993. //====================================================================================
  994. void TfrmFatcory::DisplayTerminateMETAFail ( void )
  995. {
  996.      as_Terminate_META_fail = read_TerminateMETAFail("MF_setup.txt", Application->ExeName);
  997.      if(as_Terminate_META_fail.AnsiCompareIC("yes") == 0)
  998.      {
  999.           cbTerminateMETAFail->Checked = true;
  1000.      }
  1001.      else if(as_Terminate_META_fail.AnsiCompareIC("no") == 0)
  1002.      {
  1003.           cbTerminateMETAFail->Checked = false;
  1004.      }
  1005.      else
  1006.      {
  1007.           cbTerminateMETAFail->Checked = false;
  1008.           as_Terminate_META_fail = (AnsiString) "no";
  1009.      }
  1010. }
  1011. //------------------------------------------------------------------------------
  1012. void TfrmFatcory::SaveTerminateMETAFail ( void )
  1013. {
  1014.      write_TerminateMETAFail( "MF_setup.txt", Application->ExeName, as_Terminate_META_fail );
  1015. }
  1016. //====================================================================================
  1017. void TfrmFatcory::DisplayTurnOffPowerSupplySuccess( void )
  1018. {
  1019.      as_Turn_off_power_supply_success = read_TurnOffPowerSupplySuccess("MF_setup.txt", Application->ExeName);
  1020.      if(as_Turn_off_power_supply_success.AnsiCompareIC("yes") == 0)
  1021.      {
  1022.           cbTurnOffPowerSupplySuccess->Checked = true;
  1023.      }
  1024.      else if(as_Terminate_META_success.AnsiCompareIC("no") == 0)
  1025.      {
  1026.           cbTurnOffPowerSupplySuccess->Checked = false;
  1027.      }
  1028.      else
  1029.      {
  1030.           cbTurnOffPowerSupplySuccess->Checked = false;
  1031.            as_Turn_off_power_supply_success = (AnsiString) "no";
  1032.      }
  1033. }
  1034. //------------------------------------------------------------------------------
  1035. void TfrmFatcory::SaveTurnOffPowerSupplySuccess ( void )
  1036. {
  1037.      write_TurnOffPowerSupplySuccess( "MF_setup.txt", Application->ExeName,  as_Turn_off_power_supply_success );
  1038. }
  1039. //====================================================================================
  1040. void TfrmFatcory::DisplayTerminateMETASuccess ( void )
  1041. {
  1042.      as_Terminate_META_success = read_TerminateMETASuccess("MF_setup.txt", Application->ExeName);
  1043.      if(as_Terminate_META_success.AnsiCompareIC("yes") == 0)
  1044.      {
  1045.           cbTerminateMETASuccess->Checked = true;
  1046.      }
  1047.      else if(as_Terminate_META_success.AnsiCompareIC("no") == 0)
  1048.      {
  1049.           cbTerminateMETASuccess->Checked = false;
  1050.      }
  1051.      else
  1052.      {
  1053.           cbTerminateMETAFail->Checked = false;
  1054.           as_Terminate_META_success = (AnsiString) "no";
  1055.      }
  1056. }
  1057. //------------------------------------------------------------------------------
  1058. void TfrmFatcory::SaveTerminateMETASuccess ( void )
  1059. {
  1060.      write_TerminateMETASuccess( "MF_setup.txt", Application->ExeName, as_Terminate_META_success );
  1061. }
  1062. //===============================================================================
  1063. AnsiString TfrmFatcory::readPowerSupplyGPIBAddr(void)
  1064. {
  1065.      AnsiString GPIBAddr;
  1066.      GPIBAddr = m_dcs_ctrl.DCS_ReadGPIBAddress(&m_Dcs);
  1067.      return GPIBAddr;
  1068. }
  1069. //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1070. void TfrmFatcory::savePowerSupplyGPIBAddr(void)
  1071. {
  1072.     switch (m_cbPowerSupply->ItemIndex)
  1073.     {
  1074.         case AGILENT_661x:
  1075.         {
  1076.             write_661x_GPIB_Address("MF_setup.txt", Application->ExeName, m_Dcs.ADD);
  1077.         }
  1078.         break;
  1079.         case AGILENT_663x2:
  1080.         {
  1081.              write_663x2_GPIB_Address("MF_setup.txt", Application->ExeName, m_Dcs.ADD);
  1082.         }
  1083.         break;
  1084.         case AGILENT_E3631A:
  1085.         {
  1086.             write_E3631A_GPIB_Address("MF_setup.txt", Application->ExeName, m_Dcs.ADD);
  1087.         }
  1088.         break;
  1089.         case KEITHLEY_2306:
  1090.         {
  1091.             write_Keithley2306_GPIB_Address("MF_setup.txt", Application->ExeName, m_Dcs.ADD);
  1092.         }
  1093.         break;
  1094.         default:
  1095.         {
  1096.         }
  1097.         break;
  1098.     }
  1099. }
  1100. //==============================================================================
  1101. void TfrmFatcory::AllocateDynamicMemory(void)
  1102. {
  1103.     if (NULL == st_Log)
  1104.     {
  1105.         st_Log = new TStringList();
  1106.     }
  1107.     // PM
  1108.     if (NULL == MF_rf_agc_ptr)
  1109.     {
  1110.         MF_rf_agc_ptr = new CRFAGC();
  1111.     }
  1112.     if (NULL == MF_rf_pm_cnf)
  1113.     {
  1114.         MF_rf_pm_cnf = new RfPm_Cnf;
  1115.     }
  1116.     if (NULL == MF_rf_pm_req)
  1117.     {
  1118.         MF_rf_pm_req = new RfPm_Req;
  1119.     }
  1120.     // IP2
  1121.     if (NULL == MF_rf_pm_ptr)
  1122.     {
  1123.         MF_rf_pm_ptr = new CRFPM();
  1124.     }
  1125.     // AFC
  1126.     if (NULL == MF_rf_afc_ptr)
  1127.     {
  1128.         MF_rf_afc_ptr = new CRFAFC();
  1129.     }
  1130.     if (NULL == MF_rf_afc_req)
  1131.     {
  1132.         MF_rf_afc_req = new RfAfc_Req;
  1133.     }
  1134.     // crystal AFC
  1135.     if (NULL == MF_crystal_afc_ptr)
  1136.     {
  1137.         MF_crystal_afc_ptr = new CCRYSTALAFC();
  1138.     }
  1139.     if (NULL == MF_bb_reg_ptr)
  1140.     {
  1141.         MF_bb_reg_ptr = new CBBREG();
  1142.     }
  1143.     // APC
  1144.     if (NULL == MF_rf_apc_ptr)
  1145.     {
  1146.         MF_rf_apc_ptr = new CRFAPC();
  1147.     }
  1148.     if (NULL == MF_rf_apc_8psk_ptr)
  1149.     {
  1150.         MF_rf_apc_8psk_ptr = new CRFAPC8PSK();
  1151.     }
  1152.     if (NULL == MF_rf_tx_level_req)
  1153.     {
  1154.         MF_rf_tx_level_req = new RfNbtx_Req;
  1155.     }
  1156.     // TX IQ
  1157.     if (NULL == MF_rf_txiq_ptr)
  1158.     {
  1159.         MF_rf_txiq_ptr = new CRFTXIQ();
  1160.     }
  1161.     // BT cap id
  1162.     if (NULL == m_Cal.s_cal_obj.pc_BT_INFO6601_Obj)
  1163.     {
  1164.         m_Cal.s_cal_obj.pc_BT_INFO6601_Obj = new CBTINFO6601();
  1165.     }
  1166.     if (NULL == m_Cal.s_cal_obj.pc_BT_INFO6611_Obj)
  1167.     {
  1168.         m_Cal.s_cal_obj.pc_BT_INFO6611_Obj = new CBTINFO6611();
  1169.     }
  1170.     // ADC
  1171.     if (NULL == MF_BB_ADC_Req)
  1172.     {
  1173.         MF_BB_ADC_Req = new ADCMeaData_Req;
  1174.     }
  1175.     if (NULL == BBCnf_ADC)
  1176.     {
  1177.         BBCnf_ADC = new ADCMeaData_Cnf;
  1178.     }
  1179.     if (NULL == MF_BB_ADC_ptr)
  1180.     {
  1181.         MF_BB_ADC_ptr = new CBBADC();
  1182.     }
  1183.     if (NULL == m_Cal.s_cal_obj.pc_WIFI_APC_Obj)
  1184.     {
  1185.         m_Cal.s_cal_obj.pc_WIFI_APC_Obj = new CWIFIAPC();
  1186.     }
  1187.     if (NULL == m_Cal.s_cal_obj.pc_WIFI_ALC_Obj)
  1188.     {
  1189.         m_Cal.s_cal_obj.pc_WIFI_ALC_Obj = new CWIFIALC();
  1190.     }
  1191.     if (NULL == m_Cal.s_cal_obj.pc_WIFI_TXDC_Obj)
  1192.     {
  1193.         m_Cal.s_cal_obj.pc_WIFI_TXDC_Obj = new CWIFITXDC();
  1194.     }
  1195. }
  1196. //------------------------------------------------------------------------------
  1197. void TfrmFatcory::DeallocateDynamicMemory(void)
  1198. {
  1199.     if (META_factory_cfg)
  1200.     {
  1201.         delete META_factory_cfg;
  1202.         META_factory_cfg = NULL;
  1203.     }
  1204.     if (st_Log)
  1205.     {
  1206.         delete st_Log;
  1207.         st_Log = NULL;
  1208.     }
  1209.     // AFC
  1210.     if (MF_rf_afc_ptr)
  1211.     {
  1212.         delete MF_rf_afc_ptr;
  1213.         MF_rf_afc_ptr = NULL;
  1214.     }
  1215.     if (MF_rf_afc_req)
  1216.     {
  1217.         delete MF_rf_afc_req;
  1218.         MF_rf_afc_req = NULL;
  1219.     }
  1220.     if (MF_rf_afc_cnf)
  1221.     {
  1222.         delete MF_rf_afc_cnf;
  1223.         MF_rf_afc_cnf = NULL;
  1224.     }
  1225.     // crystal AFC
  1226.     if (MF_crystal_afc_ptr)
  1227.     {
  1228.         delete MF_crystal_afc_ptr;
  1229.         MF_crystal_afc_ptr = NULL;
  1230.     }
  1231.     if (MF_bb_reg_ptr)
  1232.     {
  1233.         delete MF_bb_reg_ptr;
  1234.         MF_bb_reg_ptr = NULL;
  1235.     }
  1236.     // AGC
  1237.     if (MF_rf_agc_ptr)
  1238.     {
  1239.         delete MF_rf_agc_ptr;
  1240.         MF_rf_agc_ptr = NULL;
  1241.     }
  1242.     if (MF_rf_pm_req)
  1243.     {
  1244.         delete MF_rf_pm_req;
  1245.         MF_rf_pm_req = NULL;
  1246.     }
  1247.     if (MF_rf_pm_cnf)
  1248.     {
  1249.         delete MF_rf_pm_cnf;
  1250.         MF_rf_pm_cnf = NULL;
  1251.     }
  1252.     // IP2
  1253.     if (MF_rf_pm_ptr)
  1254.     {
  1255.         delete MF_rf_pm_ptr;
  1256.         MF_rf_pm_ptr = NULL;
  1257.     }
  1258.     // TX IQ
  1259.     if (MF_rf_txiq_ptr)
  1260.     {
  1261.         delete MF_rf_txiq_ptr;
  1262.         MF_rf_txiq_ptr = NULL;
  1263.     }
  1264.     // APC
  1265.     if (MF_rf_apc_ptr)
  1266.     {
  1267.         delete MF_rf_apc_ptr;
  1268.         MF_rf_apc_ptr = NULL;
  1269.     }
  1270.     if (MF_rf_apc_8psk_ptr)
  1271.     {
  1272.         delete MF_rf_apc_8psk_ptr;
  1273.         MF_rf_apc_8psk_ptr = NULL;
  1274.     }
  1275.     if (MF_rf_tx_level_req)
  1276.     {
  1277.         delete MF_rf_tx_level_req;
  1278.         MF_rf_tx_level_req = NULL;
  1279.     }
  1280.     // BT CAP ID
  1281.     if (m_Cal.s_cal_obj.pc_BT_INFO6601_Obj)
  1282.     {
  1283.         delete m_Cal.s_cal_obj.pc_BT_INFO6601_Obj;
  1284.         m_Cal.s_cal_obj.pc_BT_INFO6601_Obj = NULL;
  1285.     }
  1286.     if (m_Cal.s_cal_obj.pc_BT_INFO6611_Obj)
  1287.     {
  1288.         delete m_Cal.s_cal_obj.pc_BT_INFO6611_Obj;
  1289.         m_Cal.s_cal_obj.pc_BT_INFO6611_Obj = NULL;
  1290.     }
  1291.     // ADC
  1292.     if (MF_BB_ADC_Req)
  1293.     {
  1294.         delete MF_BB_ADC_Req;
  1295.         MF_BB_ADC_Req = NULL;
  1296.     }
  1297.     if (BBCnf_ADC)
  1298.     {
  1299.         delete BBCnf_ADC;
  1300.         BBCnf_ADC = NULL;
  1301.     }
  1302.     if (MF_BB_ADC_ptr)
  1303.     {
  1304.         delete MF_BB_ADC_ptr;
  1305.         MF_BB_ADC_ptr = NULL;
  1306.     }
  1307.     if (MF_BB_ADC_Req)
  1308.     {
  1309.         delete MF_BB_ADC_Req;
  1310.         MF_BB_ADC_Req = NULL;
  1311.     }
  1312.     if (BBCnf_ADC)
  1313.     {
  1314.         delete BBCnf_ADC;
  1315.         BBCnf_ADC = NULL;
  1316.     }
  1317.     // WiFi
  1318.     if (m_Cal.s_cal_obj.pc_WIFI_APC_Obj)
  1319.     {
  1320.         delete m_Cal.s_cal_obj.pc_WIFI_APC_Obj;
  1321.         m_Cal.s_cal_obj.pc_WIFI_APC_Obj = NULL;
  1322.     }
  1323.     if (m_Cal.s_cal_obj.pc_WIFI_ALC_Obj)
  1324.     {
  1325.         delete m_Cal.s_cal_obj.pc_WIFI_ALC_Obj;
  1326.         m_Cal.s_cal_obj.pc_WIFI_ALC_Obj = NULL;
  1327.     }
  1328.     if (m_Cal.s_cal_obj.pc_WIFI_TXDC_Obj)
  1329.     {
  1330.         delete m_Cal.s_cal_obj.pc_WIFI_TXDC_Obj;
  1331.         m_Cal.s_cal_obj.pc_WIFI_TXDC_Obj = NULL;
  1332.     }
  1333. }
  1334. //------------------------------------------------------------------------------
  1335. void TfrmFatcory::TerminateFactoryThread( void )
  1336. {
  1337.     if( pt_calibration != NULL && is_calibration_start )
  1338.     {
  1339.        pt_calibration->Terminate();
  1340.        is_calibration_start = false;
  1341.        pt_calibration = NULL;
  1342.     }
  1343.     if(pt_boot != NULL)
  1344.     {
  1345.        pt_boot->Terminate();
  1346.        pt_boot = NULL;
  1347.     }
  1348. }
  1349. //==============================================================================
  1350. void __fastcall TfrmFatcory::IMEICheck(TObject *Sender)
  1351. {
  1352.    int  i;
  1353.    int  data;
  1354.    AnsiString  text;
  1355.    TEdit *edit = (TEdit*)Sender;
  1356.    char  hint[] = " IMEI digit length shall be less or equal 14 ";
  1357.    text = edit->Text;
  1358.    if( !IsValidIMEI( text) )
  1359.    {
  1360.       ShowHintLabel( edit, hint );
  1361.       edit->SetFocus();
  1362.       return;
  1363.    }
  1364. }
  1365. //---------------------------------------------------------------------------
  1366. void __fastcall TfrmFatcory::IMEILengthCheck(TObject *Sender,
  1367.       WORD &Key, TShiftState Shift)
  1368. {
  1369.    // if((edtIMEI->Text).Length() == MAX_IMEI_DIGIT_LEN)
  1370.    // {
  1371.    //      check_sum = IMEI_DOWNLOAD_Object.REQ_NVRAM_Calcualte_IMEI_Spare((edtIMEI->Text).c_str());
  1372.    //      lblCheckSum->Caption = IntToStr(check_sum);
  1373.    // }
  1374. }
  1375. //---------------------------------------------------------------------------
  1376. void __fastcall TfrmFatcory::cbTerminateMETAExitClick(
  1377.       TObject *Sender)
  1378. {
  1379.       if ( cbTerminateMETAExit->Checked )
  1380.       {
  1381.           as_Terminate_META_exit = (AnsiString) "yes";
  1382.       }
  1383.       else
  1384.       {
  1385.           as_Terminate_META_exit = (AnsiString) "no";
  1386.       }
  1387. }
  1388. //---------------------------------------------------------------------------
  1389. void __fastcall TfrmFatcory::cbTerminateMETAFailClick(
  1390.       TObject *Sender)
  1391. {
  1392.       if ( cbTerminateMETAFail->Checked )
  1393.       {
  1394.           as_Terminate_META_fail = (AnsiString) "yes";
  1395.       }
  1396.       else
  1397.       {
  1398.           as_Terminate_META_fail = (AnsiString) "no";
  1399.       }
  1400. }
  1401. //---------------------------------------------------------------------------
  1402. void __fastcall TfrmFatcory::cbTurnOffPowerSupplyFailClick(
  1403.       TObject *Sender)
  1404. {
  1405.       if ( cbTurnOffPowerSupplyFail->Checked )
  1406.       {
  1407.           as_Turn_off_power_supply_fail = (AnsiString) "yes";
  1408.       }
  1409.       else
  1410.       {
  1411.           as_Turn_off_power_supply_fail = (AnsiString) "no";
  1412.       }
  1413. }
  1414. //---------------------------------------------------------------------------
  1415. void __fastcall TfrmFatcory::cbTurnOffPowerSupplySuccessClick(
  1416.       TObject *Sender)
  1417. {
  1418.       if ( cbTurnOffPowerSupplySuccess->Checked )
  1419.       {
  1420.           as_Turn_off_power_supply_success = (AnsiString) "yes";
  1421.       }
  1422.       else
  1423.       {
  1424.           as_Turn_off_power_supply_success = (AnsiString) "no";
  1425.       }
  1426. }
  1427. //---------------------------------------------------------------------------
  1428. void __fastcall TfrmFatcory::cbTerminateMETASuccessClick(
  1429.       TObject *Sender)
  1430. {
  1431.       if ( cbTerminateMETASuccess->Checked )
  1432.       {
  1433.           as_Terminate_META_success = (AnsiString) "yes";
  1434.       }
  1435.       else
  1436.       {
  1437.           as_Terminate_META_success = (AnsiString) "no";
  1438.       }
  1439. }
  1440. //==============================================================================
  1441. void TfrmFatcory::DisplayBarcodeAfterIncreasement( int Increasement )
  1442. {
  1443.     AnsiString temp_as_Barcode;
  1444.     temp_as_Barcode = AnsiStringAdd( edtBarcode->Text , Increasement );
  1445.     edtBarcode->Text = temp_as_Barcode;
  1446. }
  1447. //---------------------------------------------------------------------------
  1448. void TfrmFatcory::SaveBarcodeAfterIncreasement( int Increasement )
  1449. {
  1450.     AnsiString as_temp_Barcode;
  1451.     as_temp_Barcode = AnsiStringAdd( edtBarcode->Text , Increasement );
  1452.     edtBarcode->Text = as_temp_Barcode;
  1453.     write_Barcode( "MF_setup.txt", Application->ExeName, as_temp_Barcode );
  1454. }
  1455. //==============================================================================
  1456. void __fastcall TfrmFatcory::cbSaveBarcodeToFileSuccessClick(
  1457.       TObject *Sender)
  1458. {
  1459.     if( cbSaveBarcodeToFileSuccess->Checked )
  1460.     {
  1461.          as_Save_barcode_to_file_success = (AnsiString) "yes";
  1462.     }
  1463.     else
  1464.     {
  1465.          as_Save_barcode_to_file_success = (AnsiString) "no";
  1466.     }
  1467. }
  1468. //---------------------------------------------------------------------------
  1469. void __fastcall TfrmFatcory::cbSaveBarcodeToNVRAMSuccessClick(
  1470.       TObject *Sender)
  1471. {
  1472.     if( cbSaveBarcodeToFileSuccess->Checked )
  1473.     {
  1474.          as_Save_barcode_to_NVRAM_success = (AnsiString) "yes";
  1475.     }
  1476.     else
  1477.     {
  1478.          as_Save_barcode_to_NVRAM_success = (AnsiString) "no";
  1479.     }
  1480. }
  1481. //==============================================================================
  1482. void TfrmFatcory::ReadBarcodeFromNVRAM( void )
  1483. {
  1484.      BARCODE_Object.ConfirmCallback = ::CNF_ReadFromNVRAM;
  1485.      BARCODE_Object.REQ_Read_From_NVRAM();
  1486. }
  1487. //---------------------------------------------------------------------------
  1488. void  TfrmFatcory::UploadFromFlashDone(void)
  1489. {
  1490.     E_METAAPP_RESULT_T state = BARCODE_Object.Get_ConfirmState();
  1491.     switch (state)
  1492.     {
  1493.         case METAAPP_SUCCESS:
  1494.         {
  1495.             m_sBarcode = BARCODE_Object.Get_Barcode();
  1496.             Barcode_ptr = m_sBarcode.c_Barcode;
  1497.             as_Barcode = (AnsiString)  Barcode_ptr;
  1498.             edtBarcode->Text = as_Barcode;
  1499.             DisplayBarcodeAfterIncreasement( cbBarcodeIncreasementEnter->ItemIndex );
  1500.         }
  1501.         break;
  1502.         case METAAPP_FAIL:
  1503.         {  Application->MessageBox( "Execution Failure : Upload barcode form flash", "FAILURE", MB_OK );
  1504.         }
  1505.         break;
  1506.         case METAAPP_TIMEOUT:
  1507.         {  Application->MessageBox( "Execution Timeout : Upload barcode form flash", "TIMEOUT", MB_OK );
  1508.         }
  1509.         break;
  1510.         case METAAPP_STOP:
  1511.        {
  1512.        }
  1513.        break;
  1514.    }
  1515. }
  1516. //---------------------------------------------------------------------------
  1517. void TfrmFatcory::WriteBarcodeToNVRAMAfterIncreasement( int increasement )
  1518. {
  1519.     //strcpy( BARCODE_Object.Barcode, (AnsiStringAdd( edtBarcode->Text, increasement)).c_str() );
  1520.     S_BARCODE barcode;
  1521.     strcpy( barcode.c_Barcode, (AnsiStringAdd( edtBarcode->Text, increasement)).c_str() );
  1522.     BARCODE_Object.Set_Barcode( barcode );
  1523.     BARCODE_Object.ConfirmCallback = ::CNF_WriteToNVRAM;
  1524.     BARCODE_Object.REQ_Write_To_NVRAM();
  1525. }
  1526. //---------------------------------------------------------------------------
  1527. void TfrmFatcory::WriteBarcodeToNVRAM( void )
  1528. {
  1529.     //strcpy( BARCODE_Object.Barcode, (edtBarcode->Text).c_str() );
  1530.     S_BARCODE barcode;
  1531.     strcpy( barcode.c_Barcode, (edtBarcode->Text).c_str() );
  1532.     BARCODE_Object.Set_Barcode( barcode );
  1533.     BARCODE_Object.ConfirmCallback = ::CNF_WriteToNVRAM;
  1534.     BARCODE_Object.REQ_Write_To_NVRAM();
  1535. }
  1536. //---------------------------------------------------------------------------
  1537. void TfrmFatcory::DownloadToFlashDone( void )
  1538. {
  1539.     E_METAAPP_RESULT_T state = BARCODE_Object.Get_ConfirmState();
  1540.     switch (state)
  1541.     {
  1542.         case METAAPP_SUCCESS:
  1543.         {
  1544.         }
  1545.         break;
  1546.         case METAAPP_FAIL:
  1547.         {
  1548.             Application->MessageBox( "Execution Failure : Download barcode to flash", "FAILURE", MB_OK );
  1549.         }
  1550.         break;
  1551.         case METAAPP_TIMEOUT:
  1552.         {
  1553.             Application->MessageBox( "Execution Timeout : Download barcode to flash", "TIMEOUT", MB_OK );
  1554.         }
  1555.         break;
  1556.         case METAAPP_STOP:
  1557.         {
  1558.         }
  1559.         break;
  1560.         case METAAPP_NVRAM_LID_VER_NOT_SUPPORT:
  1561.         {
  1562.             Application->MessageBox("Execution Warning : NVRAM_EF_BARCODE_NUM_LID version is not support, please update META to latest version", "WARNING", MB_OK);
  1563.         }
  1564.         break;
  1565.         default:
  1566.         {
  1567.         }
  1568.         break;
  1569.     }
  1570. }
  1571. //==============================================================================
  1572. void TfrmFatcory::SaveFactoryUISetting( void )
  1573. {
  1574.     SaveAFCType();
  1575.     SaveCrystalCapId();
  1576. //    SaveCapIdCal();
  1577.     SaveTxAfcOffsetCal();
  1578.     SaveResetRfTester();
  1579.     SaveIP2Cal();
  1580.     SaveAFCCal();
  1581.     SaveRxPathLossCal();
  1582.     SaveTxIqCal();
  1583.     SaveTxPclCal();
  1584.     SaveADCCal();
  1585.     SaveCVCal();
  1586.     SaveWiFiTxDcOffsetCal();
  1587.     SaveWiFiTxPowerCal();
  1588.     SaveBTCrystalCAPIDCal();
  1589.     SaveTXPCLType();
  1590.     SavePAType();
  1591.     //SavePABiasType();
  1592.     SaveApcModulation();
  1593.     SaveRFCalibrationEquipment();
  1594.     SaveWiFiCalibrationEquipment();
  1595.     SaveBTCalibrationEquipment();
  1596.     SavePowerSupplyType();
  1597.     SaveReadBarcodeFromEnter();
  1598.     SaveBarcodeIncreasementEnter();
  1599.     SaveAutoStartCalibrationEnter();
  1600.     SaveSaveBarcodeToNVRAMExit();
  1601.     SaveSaveBarcodeToFileExit();
  1602.     SaveBarcodeIncreasementExit();
  1603.     SaveSaveBarcodeToNVRAMSuccess();
  1604.     SaveSaveBarcodeToFileSuccess();
  1605.     SaveBarcodeIncreasementSuccess();
  1606.     SaveSaveBarcodeToNVRAMFail();
  1607.     SaveSaveBarcodeToFileFail();
  1608.     SaveBarcodeIncreasementFail();
  1609.     //SaveBarcodeSaveTo();
  1610.     SaveTerminateMETAExit();
  1611.     SaveTerminateMETAFail();
  1612.     SaveTurnOffPowerSupplyFail();
  1613.     SaveTerminateMETASuccess();
  1614.     SaveTurnOffPowerSupplySuccess();
  1615. }
  1616. //=============================================================================
  1617. void  TfrmFatcory::Reconnect_Button_Click( void )
  1618. {
  1619.     IsReconnectByFactory = true;
  1620.     frmMainSel->ReconnectButtonClick();
  1621. }
  1622. //---------------------------------------------------------------------------
  1623. void __fastcall TfrmFatcory::btnReconnectClick(TObject *Sender)
  1624. {
  1625.     Reconnect_Button_Click();
  1626. }
  1627. //==============================================================================
  1628. //---------------------------------------------------------------------------
  1629. void __fastcall TfrmFatcory::cbSaveBarcodeToNVRAMFailClick(
  1630.       TObject *Sender)
  1631. {
  1632.     if( cbSaveBarcodeToFileFail->Checked )
  1633.     {
  1634.          as_Save_barcode_to_NVRAM_fail = (AnsiString) "yes";
  1635.     }
  1636.     else
  1637.     {
  1638.          as_Save_barcode_to_NVRAM_fail = (AnsiString) "no";
  1639.     }
  1640. }
  1641. //---------------------------------------------------------------------------
  1642. void __fastcall TfrmFatcory::cbSaveBarcodeToFileFailClick(
  1643.       TObject *Sender)
  1644. {
  1645.     if( cbSaveBarcodeToFileFail->Checked )
  1646.     {
  1647.          as_Save_barcode_to_file_fail = (AnsiString) "yes";
  1648.     }
  1649.     else
  1650.     {
  1651.          as_Save_barcode_to_file_fail = (AnsiString) "no";
  1652.     }
  1653. }
  1654. //---------------------------------------------------------------------------
  1655. void __fastcall TfrmFatcory::cbAutoStartCalibrationEnterClick(
  1656.       TObject *Sender)
  1657. {
  1658.      if( cbAutoStartCalibrationEnter->Checked )
  1659.      {
  1660.          as_Auto_start_calibration_enter = (AnsiString) "yes";
  1661.      }
  1662.      else
  1663.      {
  1664.          as_Auto_start_calibration_enter = (AnsiString) "no";
  1665.      }
  1666. }
  1667. //---------------------------------------------------------------------------
  1668. void __fastcall TfrmFatcory::cbSaveBarcodeToNVRAMExitClick(
  1669.       TObject *Sender)
  1670. {
  1671.     if( cbSaveBarcodeToFileExit->Checked )
  1672.     {
  1673.          as_Save_barcode_to_NVRAM_exit = (AnsiString) "yes";
  1674.     }
  1675.     else
  1676.     {
  1677.          as_Save_barcode_to_NVRAM_exit = (AnsiString) "no";
  1678.     }
  1679. }
  1680. //---------------------------------------------------------------------------
  1681. void __fastcall TfrmFatcory::cbSaveBarcodeToFileExitClick(
  1682.       TObject *Sender)
  1683. {
  1684.     if( cbSaveBarcodeToFileExit->Checked )
  1685.     {
  1686.          as_Save_barcode_to_file_exit = (AnsiString) "yes";
  1687.     }
  1688.     else
  1689.     {
  1690.          as_Save_barcode_to_file_exit = (AnsiString) "no";
  1691.     }
  1692. }
  1693. //---------------------------------------------------------------------------
  1694. void TfrmFatcory::ReconnectWithTargetSuccess( void )
  1695. {
  1696.     if( cbAutoStartCalibrationEnter->Checked )
  1697.     {
  1698.          Calibration_Button_Click();
  1699.     }
  1700. }
  1701. //------------------------------------------------------------------------------
  1702. void __fastcall TfrmFatcory::FormCreate(TObject *Sender)
  1703. {
  1704.     hForm_MF = this->Handle;
  1705.     MF_ctrl.hPostMsgDestHandle = this->Handle;
  1706.     hForm_PostMsgTarget = this->Handle;
  1707.     WindowProc = SubClassWndProc;
  1708.     b_OpenNVRAMdatabase = false;
  1709.     b_OpenCfgFile = false;
  1710.     b_SetupLogFile = false;
  1711.     b_OpenIniFile = false;
  1712.     m_Cal.b_CalResultPath = false;
  1713.     st_Log = NULL;
  1714.     MF_rf_agc_ptr = NULL;
  1715.     MF_rf_pm_cnf = NULL;
  1716.     MF_rf_pm_req = NULL;
  1717.     MF_rf_pm_ptr = NULL;
  1718.     MF_rf_afc_ptr = NULL;
  1719.    // MF_rf_SetAfcDacValue = NULL;
  1720.     MF_rf_afc_req = NULL;
  1721.     MF_crystal_afc_ptr = NULL;
  1722.     MF_bb_reg_ptr = NULL;
  1723.     MF_rf_apc_ptr = NULL;
  1724.     MF_rf_tx_level_req = NULL;
  1725.     MF_rf_txiq_ptr = NULL;
  1726.     MF_BB_ADC_Req = NULL;
  1727.     BBCnf_ADC = NULL;
  1728.     MF_BB_ADC_ptr = NULL;
  1729.     
  1730.     AllocateDynamicMemory();
  1731.     MF_state = eInit;
  1732.     MF_ctrl.hCOM = hCOM;
  1733.     MF_state = eInit;
  1734.        // read_BARCODE("MF_setup.txt", Application->ExeName);
  1735.        // EditStartID->Text = as_BARCODE;
  1736.    //    DisableAllCalTimer();
  1737.         // equipment control
  1738.         i_NORMAL_VOLTAGE = read_NORMAL_VOLTAGE( "MF_setup.txt", Application->ExeName);
  1739.         i_CURRENT_LIMIT = read_CURRENT_LIMIT( "MF_setup.txt", Application->ExeName);
  1740.         i_OFF_VOLTAGE = read_OFF_VOLTAGE("MF_setup.txt", Application->ExeName);
  1741.         //LoadAge1960DllFunctions();
  1742.         //LoadVisa32DllFunctions();
  1743.        // as_Power_Supply_GPIB_addr = readAgilentPowerSupplyGPIBAddr();
  1744.         //InitAgilentPowerSupply_SetNormalVoltage_CloseAgilentPowerSupply();
  1745.         
  1746.     Init();
  1747. }
  1748. //---------------------------------------------------------------------------
  1749. void __fastcall TfrmFatcory::StartButtonClickExecute(TObject *Sender)
  1750. {
  1751.     Calibration_Button_Click();
  1752. }
  1753. //---------------------------------------------------------------------------
  1754. void __fastcall TfrmFatcory::actReconnectButtonExecute(
  1755.       TObject *Sender)
  1756. {
  1757.      Reconnect_Button_Click();
  1758. }
  1759. //---------------------------------------------------------------------------
  1760. void __fastcall TfrmFatcory::miSetupcalibrationdataresultfilepathClick(
  1761.       TObject *Sender)
  1762. {
  1763.     frmCalPath->Top  = 232;
  1764.     frmCalPath->Left = 48;
  1765.     frmCalPath->Show();
  1766. }
  1767. //---------------------------------------------------------------------------
  1768. void __fastcall TfrmFatcory::miEditRXpathlossCFGParameterClick(
  1769.       TObject *Sender)
  1770. {
  1771.     frmCFGRxPathLoss->Top  = 4;
  1772.     frmCFGRxPathLoss->Left = 80;
  1773.     frmCFGRxPathLoss->Show();
  1774. }
  1775. //---------------------------------------------------------------------------
  1776. void __fastcall TfrmFatcory::miTCVCXOAFCCFGParameterClick(
  1777.       TObject *Sender)
  1778. {
  1779.     frmCFGAfc->Top  = 168;
  1780.     frmCFGAfc->Left = 213;
  1781.     frmCFGAfc->Show();
  1782. }
  1783. //---------------------------------------------------------------------------
  1784. void __fastcall TfrmFatcory::miCrystalAFCCFGParameterClick(
  1785.       TObject *Sender)
  1786. {
  1787.     frmCFGCrystalAfc->Top  = 168;
  1788.     frmCFGCrystalAfc->Left = 213;
  1789.     frmCFGCrystalAfc->Show();
  1790. }
  1791. //---------------------------------------------------------------------------
  1792. void __fastcall TfrmFatcory::miTXPCLCFGParameterClick(
  1793.       TObject *Sender)
  1794. {
  1795.     frmCFGTxPcl->Top  = 27;
  1796.     frmCFGTxPcl->Left = 128;
  1797.     frmCFGTxPcl->Show();
  1798. }
  1799. //---------------------------------------------------------------------------
  1800. void __fastcall TfrmFatcory::miADCCFGParameterClick(TObject *Sender)
  1801. {
  1802.     frmCFGAdc->Top  = 168;
  1803.     frmCFGAdc->Left = 45;
  1804.     frmCFGAdc->Show();
  1805. }
  1806. //---------------------------------------------------------------------------
  1807. void __fastcall TfrmFatcory::miCommonCFGParameterClick(
  1808.       TObject *Sender)
  1809. {
  1810.     frmCFGCommon->Top  = 4;
  1811.     frmCFGCommon->Left = 133;
  1812.     frmCFGCommon->Show();
  1813. }
  1814. //---------------------------------------------------------------------------
  1815. void __fastcall TfrmFatcory::bb_StopClick(TObject *Sender)
  1816. {
  1817.     if ( BUTTON_TAG_STOP == bb_Start->Tag )
  1818.     {
  1819.         DisableAllCalTimer();
  1820.         if ( pt_calibration != NULL && is_calibration_start)
  1821.         {
  1822.             pt_calibration->Terminate();
  1823.             is_calibration_start = false;
  1824.             pt_calibration = NULL;
  1825.         }
  1826.         write_log();
  1827.         clear_log();
  1828.         bb_Start->Tag = BUTTON_TAG_START;
  1829.         bb_Start->Enabled = true;
  1830.         bb_Start->Caption = "Start (F6)";
  1831.         CRFSTOP RF_STOP_Obj;
  1832.         RF_STOP_Obj.REQ_Start();
  1833.     }    
  1834. }
  1835. //---------------------------------------------------------------------------
  1836. void __fastcall TfrmFatcory::ToggleHideExecute(TObject *Sender)
  1837. {
  1838.     if( g_bHideEnable )
  1839.     {
  1840.         g_bHideEnable = false;
  1841.     }
  1842.     else
  1843.     {
  1844.         g_bHideEnable = true;
  1845.     }
  1846.     ApplyHideProperty();
  1847. }
  1848. //---------------------------------------------------------------------------
  1849. void TfrmFatcory::ApplyHideProperty(void)
  1850. {
  1851.     gbTxGslot->Visible = !g_bHideEnable;
  1852.     
  1853. #if 0
  1854.     if( g_bHideEnable )
  1855.     {
  1856.        // gbCrystalOption->Visible = false;
  1857.        // m_cbTrxOffset->Visible = false;
  1858.        // m_cbTrxOffset->Checked = false;
  1859.         //cbTxPhaseError->Visible = false;
  1860.         //cbTxPhaseError->Checked = false;
  1861.         //cbADC->Top = 100;
  1862.         //rbRenesasPF08155B->Visible = false;
  1863.        // rbRenesasPF09016B->Visible = false;
  1864.         //rbSkyworks77316->Visible = false;
  1865.         //miPhaseErrorCFGParameter->Visible = false;
  1866.     }
  1867.     else
  1868.     {
  1869.         //cbADC->Top = 123;
  1870.       // gbCrystalOption->Visible = true;
  1871.       //  m_cbTrxOffset->Visible = true;
  1872.         //rbRenesasPF08155B->Visible = true;
  1873.        // rbRenesasPF09016B->Visible = true;
  1874.         //rbSkyworks77316->Visible = true;
  1875.         //cbTxPhaseError->Visible = true;
  1876.         //miPhaseErrorCFGParameter->Visible = true;
  1877.     }
  1878. #endif
  1879. }
  1880. //==============================================================================
  1881. TYPE_META_FACTORY_STATE TfrmFatcory::Get_MFState(void)
  1882. {
  1883.     TYPE_META_FACTORY_STATE   state;
  1884.     if( cbIP2->Checked )
  1885.     {
  1886.         state = eIP2;
  1887.     }
  1888.     else if( cbAFC->Checked )
  1889.     {
  1890.         state = eAFC;
  1891.     }
  1892.     else if( cbRxPathLoss->Checked )
  1893.     {
  1894.         state = eRF_PathLoss;
  1895.     }
  1896.     else if( cbTxIq->Checked )
  1897.     {
  1898.         state = eTX_DcOffset;
  1899.     }
  1900.     else if( cbTxPcl->Checked )
  1901.     {
  1902.         state = eTX_PCL;
  1903.     }
  1904.   
  1905.     return state; 
  1906. }
  1907. //---------------------------------------------------------------------------
  1908. void __fastcall TfrmFatcory::rbRFMD3140Click(TObject *Sender)
  1909. {
  1910.     if( m_rbGMSK2PCL->Checked )
  1911.         m_rbGMSK3PCL->Checked = true;
  1912.     m_rbGMSK2PCL->Enabled = false;
  1913.     m_rbGMSK3PCL->Enabled = true;
  1914. }
  1915. //---------------------------------------------------------------------------
  1916. void __fastcall TfrmFatcory::rbRenesasPF08155BClick(TObject *Sender)
  1917. {
  1918.     if( m_rbGMSK2PCL->Checked )
  1919.         m_rbGMSK3PCL->Checked = true;
  1920.     m_rbGMSK2PCL->Enabled = false;
  1921.     m_rbGMSK3PCL->Enabled = true;
  1922. }
  1923. //---------------------------------------------------------------------------
  1924. void __fastcall TfrmFatcory::rbSkyworks77316Click(TObject *Sender)
  1925. {
  1926.     if( m_rbGMSK3PCL->Checked )
  1927.         m_rbGMSK2PCL->Checked = true;
  1928.     m_rbGMSK2PCL->Enabled = true;
  1929.     m_rbGMSK3PCL->Enabled = false;
  1930. }
  1931. //---------------------------------------------------------------------------
  1932. void __fastcall TfrmFatcory::rbSkyworks77328Click(TObject *Sender)
  1933. {
  1934.     if( m_rbGMSK3PCL->Checked )
  1935.         m_rbGMSK2PCL->Checked = true;
  1936.     m_rbGMSK2PCL->Enabled = true;
  1937.     m_rbGMSK3PCL->Enabled = false;    
  1938. }
  1939. //---------------------------------------------------------------------------
  1940. void __fastcall TfrmFatcory::rbRenesasPF09016BClick(TObject *Sender)
  1941. {
  1942.     if( m_rbGMSK2PCL->Checked )
  1943.         m_rbGMSK3PCL->Checked = true;
  1944.     m_rbGMSK2PCL->Enabled = false;
  1945.     m_rbGMSK3PCL->Enabled = true;    
  1946. }
  1947. //---------------------------------------------------------------------------
  1948. void __fastcall TfrmFatcory::rbAgilent663x2Click(TObject *Sender)
  1949. {
  1950.     m_Dcs.device_type = AGILENT_663x2;
  1951. }
  1952. //---------------------------------------------------------------------------
  1953. void __fastcall TfrmFatcory::rbAgilent661xClick(TObject *Sender)
  1954. {
  1955.     m_Dcs.device_type = AGILENT_661x;
  1956. }
  1957. //---------------------------------------------------------------------------
  1958. void __fastcall TfrmFatcory::rbAgilentE3631AClick(TObject *Sender)
  1959. {
  1960.     m_Dcs.device_type = AGILENT_E3631A;
  1961. }
  1962. //---------------------------------------------------------------------------
  1963. void __fastcall TfrmFatcory::rbAgilent8960Click(TObject *Sender)
  1964. {
  1965.     m_Rct.device_type = AGILENT_8960;
  1966. }
  1967. //---------------------------------------------------------------------------
  1968. void __fastcall TfrmFatcory::rbCMU200Click(TObject *Sender)
  1969. {
  1970.     m_Rct.device_type = CMU_200;
  1971. }
  1972. //---------------------------------------------------------------------------
  1973. void TfrmFatcory::WriteIP2RxAmCalModeToNormal(void)
  1974. {
  1975.     MF_rf_pm_ptr->ConfirmCallback = ::CNF_ReadIP2FromNVRAM;
  1976.     MF_rf_pm_ptr->REQ_Read_IP2Reg_From_NVRAM_Start(m_Cal.ui_rf_id);
  1977. }
  1978. //---------------------------------------------------------------------------
  1979. void TfrmFatcory::CNF_ReadIP2FromNVRAM(void)
  1980. {
  1981.     if (MF_rf_pm_ptr->Get_ConfirmState() == METAAPP_SUCCESS)
  1982.     {
  1983.         MF_rf_pm_ptr->Get_uc_mt6139_coef();
  1984.         MF_rf_pm_ptr->Set_uc_mt6139_coef_rxamcalmode( RXAMCALMODE_MT6139C_NORMAL );
  1985.         MF_rf_pm_ptr->ConfirmCallback = ::CNF_WriteIP2ToNVRAM;
  1986.         MF_rf_pm_ptr->REQ_Write_IP2Reg_To_NVRAM_Start(m_Cal.ui_rf_id);
  1987.     }
  1988.     else
  1989.     {
  1990.         Application->MessageBox( "Execution Failure : Upload IP2 setting form flash, please check the version of load and NVRAM database are same.", "FAILURE", MB_OK );
  1991.     }
  1992. }
  1993. //---------------------------------------------------------------------------
  1994. void TfrmFatcory::CNF_WriteIP2ToNVRAM( void )
  1995. {
  1996.     if( MF_rf_pm_ptr->Get_ConfirmState() != METAAPP_SUCCESS )
  1997.     {
  1998.         Application->MessageBox( "Execution Failure : Download IP2 setting to flash, please check the version of load and NVRAM database are same.", "FAILURE", MB_OK );
  1999.     }
  2000. }
  2001. //===========================================================================
  2002. /////////////////////////////        Query       ////////////////////////////
  2003. //===========================================================================
  2004. //---------------------------------------------------------------------------
  2005. void __fastcall TfrmFatcory::on_QueryRFID_Fail(TObject *Sender)
  2006. {
  2007. }
  2008. //---------------------------------------------------------------------------
  2009. void __fastcall TfrmFatcory::on_QueryRFID_TerminateSuccess(TObject *Sender)
  2010. {
  2011. }
  2012. //-----------------------------------------------------------------------------
  2013. void TfrmFatcory::QueryRfId( void )
  2014. {
  2015.     t_rf_id.hPostMsgDestHandle = this->Handle;
  2016.     t_rf_id.ne_onTermSuccess   = on_QueryRFID_TerminateSuccess;
  2017.     pt_rfid = new T_RFID( true, &t_rf_id);
  2018.     if(pt_rfid != NULL)
  2019.     {
  2020.         pt_rfid->FreeOnTerminate = true;
  2021.         pt_rfid->OnTerminate = on_QueryRFID_Fail;
  2022.         pt_rfid->Priority = tpHighest;
  2023.         pt_rfid->Resume();
  2024.     }
  2025. }
  2026. //-----------------------------------------------------------------------------
  2027. void __fastcall TfrmFatcory::on_QueryTwoApcDcOffset_Fail(TObject *Sender)
  2028. {
  2029.     QueryRfId();
  2030. }
  2031. //---------------------------------------------------------------------------
  2032. void __fastcall TfrmFatcory::on_QueryTwoApcDcOffset_TerminateSuccess(TObject *Sender)
  2033. {
  2034.     QueryRfId();
  2035. }
  2036. //---------------------------------------------------------------------------
  2037. void  TfrmFatcory::Query_TwoApcDcOffset_Support( void )
  2038. {
  2039.     t_RfTado.hPostMsgDestHandle = this->Handle;
  2040.     t_RfTado.ne_onTermSuccess   = on_QueryTwoApcDcOffset_TerminateSuccess;
  2041.     pt_rftado = new T_RFTADO(
  2042.                                        true,
  2043.                                        &t_RfTado);
  2044.     if(pt_rftado != NULL)
  2045.     {
  2046.         pt_rftado->FreeOnTerminate = true;
  2047.         pt_rftado->OnTerminate = on_QueryTwoApcDcOffset_Fail;
  2048.         pt_rftado->Priority = tpHighest;
  2049.         pt_rftado->Resume();
  2050.     }
  2051. }
  2052. //===========================================================================
  2053. /////////////////////////   Global information   ////////////////////////////
  2054. //===========================================================================
  2055. void TfrmFatcory::Init(void)
  2056. {
  2057.      m_bInit = true;
  2058.     // b_TADOSupport = false;
  2059. }
  2060. //---------------------------------------------------------------------------
  2061. void __fastcall TfrmFatcory::btnNVRAMDBClick(TObject *Sender)
  2062. {
  2063.     miOpenfdmfileClick( this );    
  2064. }
  2065. //---------------------------------------------------------------------------
  2066. void __fastcall TfrmFatcory::btnConfigurationClick(TObject *Sender)
  2067. {
  2068.     miOpenConfigFileClick( Sender );
  2069. }
  2070. //---------------------------------------------------------------------------
  2071. void __fastcall TfrmFatcory::btnLoggingClick(TObject *Sender)
  2072. {
  2073.     miSetupLoggingFileClick( Sender );
  2074. }
  2075. //---------------------------------------------------------------------------
  2076. void __fastcall TfrmFatcory::btnResultClick(TObject *Sender)
  2077. {
  2078.     miSetupresultfileClick( Sender );
  2079. }
  2080. //---------------------------------------------------------------------------
  2081. void __fastcall TfrmFatcory::btnCalInitClick(TObject *Sender)
  2082. {
  2083.     miOpenInitialFileClick( Sender );
  2084. }
  2085. //---------------------------------------------------------------------------
  2086. void __fastcall TfrmFatcory::btnCalResultPathClick(TObject *Sender)
  2087. {
  2088.     miSetupcalibrationdataresultfilepathClick( Sender );    
  2089. }
  2090. //---------------------------------------------------------------------------
  2091. void __fastcall TfrmFatcory::rbKeithley2306Click(TObject *Sender)
  2092. {
  2093.     m_Dcs.device_type = KEITHLEY_2306;
  2094. }
  2095. //===========================================================================
  2096. ///////////////////////  Calibration  Parameter   ///////////////////////////
  2097. //===========================================================================
  2098. void  TfrmFatcory::SetRctParameter(void)
  2099. {
  2100.     // device type
  2101.     if( rbAgilent8960->Checked )
  2102.     {
  2103.         m_Rct.device_type = AGILENT_8960;
  2104.         m_Rct.as_RCT      = "Agilent 8960";
  2105.     }
  2106.     else
  2107.     {
  2108.         m_Rct.device_type =  CMU_200;
  2109.         m_Rct.as_RCT      = "CMU 200";
  2110.     }
  2111.     //m_Rct.cmu = cmu;
  2112.     // CMU
  2113.     if( rbCrystal->Checked && cbAFC->Checked )
  2114.     {
  2115.         m_Rct.cmu.bSigEnable = true;
  2116.     }
  2117.     else
  2118.     {
  2119.         m_Rct.cmu.bSigEnable = false;
  2120.     }
  2121.     // reset RCT
  2122.     m_Rct.bReset = cbResetRfTester->Checked;
  2123. }
  2124. //-------------------------------------------------------------------------
  2125. void TfrmFatcory::SetBttParameter(void)
  2126. {
  2127.     // device type
  2128.     m_sBtt.e_device_type = (E_BT_DEVICE_TYPE)m_cbBTTester->ItemIndex;
  2129.     switch (m_sBtt.e_device_type)
  2130.     {
  2131.         case BT_DEVICE_CMU_200:
  2132.         {
  2133.             m_sBtt.as_BTT = "CMU 200";
  2134.         }
  2135.         break;
  2136.         case BT_DEVICE_CBT:
  2137.         {
  2138.             m_sBtt.as_BTT = "CBT";
  2139.         }
  2140.         break;
  2141.         default:
  2142.         {
  2143.         }
  2144.         break;
  2145.     }
  2146. }
  2147. //-------------------------------------------------------------------------
  2148. void  TfrmFatcory::SetWftParameter( void )
  2149. {
  2150.     // device type
  2151.     if( rbLitePointIQV->Checked )
  2152.     {
  2153.         m_Wft.device_type = IQVIEW;
  2154.     }
  2155.     else
  2156.     {
  2157.         m_Wft.device_type =  N4010A;
  2158.     }
  2159. }
  2160. //---------------------------------------------------------------------------
  2161. void  TfrmFatcory::SetDcsParameter(void)
  2162. {
  2163.     AnsiString as_Power_Supply_GPIB_addr;
  2164.     m_Dcs.device_type = m_cbPowerSupply->ItemIndex;
  2165.     // GPIB address
  2166.     if (as_Power_Supply_GPIB_addr.AnsiCompare("") == 0)
  2167.     {
  2168.         switch (m_cbPowerSupply->ItemIndex)
  2169.         {
  2170.             case AGILENT_661x:
  2171.             {
  2172.                 as_Power_Supply_GPIB_addr = read_661x_GPIB_Address("MF_setup.txt", Application->ExeName);
  2173.             }
  2174.             break;
  2175.             case AGILENT_663x2:
  2176.             {
  2177.                 as_Power_Supply_GPIB_addr = read_663x2_GPIB_Address("MF_setup.txt", Application->ExeName);
  2178.             }
  2179.             break;
  2180.             case AGILENT_E3631A:
  2181.             {
  2182.                 as_Power_Supply_GPIB_addr = read_E3631A_GPIB_Address("MF_setup.txt", Application->ExeName);
  2183.             }
  2184.             break;
  2185.             case KEITHLEY_2306:
  2186.             {
  2187.                 as_Power_Supply_GPIB_addr = read_Keithley2306_GPIB_Address("MF_setup.txt", Application->ExeName);
  2188.             }
  2189.             break;
  2190.             default:
  2191.             {
  2192.             }
  2193.             break;
  2194.         }
  2195.     }
  2196.     m_Dcs.ADD = as_Power_Supply_GPIB_addr;
  2197. }
  2198. //---------------------------------------------------------------------------
  2199. void  TfrmFatcory::SetCalibrationParameter( void )
  2200. {
  2201.     // flag
  2202.     m_Cal.b_ResetRfTester = cbResetRfTester->Checked;
  2203.     // initial file
  2204.     m_Cal.as_IniFile = stIniFile->Caption;
  2205.     // cal path
  2206.     m_Cal.as_CalPath = stCalPath->Caption;
  2207.     // calibration item
  2208.     m_Cal.s_CalItem.b_ip2_cal = cbIP2->Checked && cbIP2->Visible;
  2209.     m_Cal.s_CalItem.b_afc_cal = cbAFC->Checked && cbAFC->Visible;
  2210.     m_Cal.s_CalItem.b_rx_path_loss_cal = cbRxPathLoss->Checked && cbRxPathLoss->Visible;
  2211.     m_Cal.s_CalItem.b_tx_iq_cal = cbTxIq->Checked && cbTxIq->Visible;
  2212.     m_Cal.s_CalItem.b_tx_pcl_cal = cbTxPcl->Checked && cbTxPcl->Visible;
  2213.     m_Cal.s_CalItem.b_trx_offset_cal = m_cbTrxOffset->Checked && m_cbTrxOffset->Visible;
  2214.     m_Cal.s_CalItem.b_adc_cal = cbADC->Checked && cbADC->Visible;
  2215.     m_Cal.s_CalItem.b_cv_cal = m_cbCV->Checked && m_cbCV->Visible;
  2216.     m_Cal.s_CalItem.b_wifi_tx_dc_offset_cal = cbWiFiTxDcOffset->Checked && cbWiFiTxDcOffset->Visible;
  2217.     m_Cal.s_CalItem.b_wifi_tx_power_cal = cbWiFiTxPower->Checked && cbWiFiTxPower->Visible;
  2218.     m_Cal.s_CalItem.b_bt_cap_id_cal = m_cbBTCapID->Checked && m_cbBTCapID->Visible;
  2219.     // AFC type
  2220.     if (rbTCVCXO->Checked)
  2221.     {
  2222.         m_Cal.e_AFC_type = TCVCXO;
  2223.     }
  2224.     else
  2225.     {
  2226.         m_Cal.e_AFC_type = CRYSTAL;
  2227.     }
  2228.     // Crystal AFC option
  2229.     if (rbTCVCXO->Checked)
  2230.     {
  2231.         m_Cal.s_crystal_afc_option.crystal_cap_id_update = RUN_TIME;
  2232.     }
  2233.     else
  2234.     {
  2235.         m_Cal.s_crystal_afc_option.crystal_cap_id_update = WRITE_NVARM;
  2236.     }
  2237.    // m_Cal.s_crystal_afc_option.b_tx_afc_offset_cal = m_cbTrxOffset->Checked;
  2238.     // TX IQ
  2239.     if ((RF_ID_A60111A == m_Cal.ui_rf_id) ||
  2240.         (RF_ID_MT6140A == m_Cal.ui_rf_id) ||
  2241.         (RF_ID_MT6140B == m_Cal.ui_rf_id) ||
  2242.         (RF_ID_MT6140C == m_Cal.ui_rf_id) ||
  2243.         (RF_ID_MT6140D == m_Cal.ui_rf_id) ||
  2244.         (RF_ID_AERO2E  == m_Cal.ui_rf_id) 
  2245.        )
  2246.     {
  2247.         if ((MT6205  == m_Cal.e_bb_chip) ||
  2248.     (MT6205B == m_Cal.e_bb_chip) ||
  2249.     (MT6217  == m_Cal.e_bb_chip) ||
  2250.     (MT6218  == m_Cal.e_bb_chip) ||
  2251.             (MT6218B == m_Cal.e_bb_chip) ||
  2252.             (MT6219  == m_Cal.e_bb_chip) ||
  2253.             (MT6223  == m_Cal.e_bb_chip) ||
  2254.             (MT6223P == m_Cal.e_bb_chip) ||
  2255.             (MT6225  == m_Cal.e_bb_chip) ||
  2256.             (MT6226  == m_Cal.e_bb_chip) ||
  2257.             (MT6226D == m_Cal.e_bb_chip) ||
  2258.     (MT6226M == m_Cal.e_bb_chip) ||
  2259.             (MT6227  == m_Cal.e_bb_chip) ||
  2260.             (MT6227D == m_Cal.e_bb_chip) ||
  2261.     (MT6228  == m_Cal.e_bb_chip) 
  2262.            )
  2263.         {
  2264.             m_Cal.e_TX_IQ_type = TX_IQ_GMSK;
  2265.         }
  2266.         else
  2267.         {
  2268.             m_Cal.e_TX_IQ_type = TX_IQ_EPSK;
  2269.         }
  2270.     }
  2271.     else
  2272.     {
  2273.         m_Cal.e_TX_IQ_type = TX_IQ_GMSK;
  2274.     }
  2275.     // PA type
  2276.     m_Cal.e_PA_type = (E_PA_TYPE_T) cbPAType->ItemIndex;
  2277.     // APC type
  2278.     if (m_rbGMSK2PCL->Checked)
  2279.     {
  2280.          m_Cal.e_GMSK_APC_type = TWO_PCL;
  2281.     }
  2282.     else if(m_rbGMSK3PCL->Checked)
  2283.     {
  2284.         m_Cal.e_GMSK_APC_type = THREE_PCL;
  2285.     }
  2286.     else if (m_rb6DAC->Checked)
  2287.     {
  2288.         m_Cal.e_GMSK_APC_type = SIX_DAC;
  2289.     }
  2290.     else
  2291.     {
  2292.         m_Cal.e_GMSK_APC_type = FULL_PCL;
  2293.     }
  2294.     if (m_rbEPSK1PCL->Checked)
  2295.     {
  2296.         m_Cal.e_EPSK_APC_type = ONE_PCL;
  2297.     }
  2298.     else if (m_rbEPSK2PCL->Checked)
  2299.     {
  2300.          m_Cal.e_EPSK_APC_type = TWO_PCL;
  2301.     }
  2302.     else if(m_rbEPSK3PCL->Checked)
  2303.     {
  2304.         m_Cal.e_EPSK_APC_type = THREE_PCL;
  2305.     }
  2306.     else if(m_rbEPSK4PCL->Checked)
  2307.     {
  2308.         m_Cal.e_EPSK_APC_type = FOUR_PCL;
  2309.     }
  2310.     else
  2311.     {
  2312.         m_Cal.e_EPSK_APC_type = FULL_PCL;
  2313.     }
  2314.     // APC modulation
  2315.     m_Cal.i_APC_mod = 0;
  2316.     if (m_cbGMSK->Checked)
  2317.     {
  2318.         m_Cal.i_APC_mod |= APC_MOD_GMSK;
  2319.     }
  2320.     if (m_cbEPSK->Checked)
  2321.     {
  2322.         m_Cal.i_APC_mod |= APC_MOD_EPSK;
  2323.     }
  2324.    // if (m_rbFixedPaBias->Checked)
  2325.     {
  2326.         m_Cal.e_PA_bias = PA_BIAS_FIXED;
  2327.     }
  2328.    // else
  2329.   //  {
  2330.   //      m_Cal.e_PA_bias = PA_BIAS_DYN;
  2331.   //  }
  2332.     // TX slot
  2333.     if (rbSingleSlot->Checked )
  2334.     {   m_Cal.e_tx_slot = TX_SLOT_SINGLE;
  2335.     }
  2336.     else
  2337.     {  m_Cal.e_tx_slot = TX_SLOT_MULTI;
  2338.     }
  2339.     // BT tester
  2340. }
  2341. //--------------------------------------------------------------------------
  2342. void __fastcall TfrmFatcory::cbPATypeChange(TObject *Sender)
  2343. {
  2344.     switch (cbPAType->ItemIndex)
  2345.     {
  2346.         case RFMD_3140:
  2347.         {
  2348.             if (!m_rbGMSKFullPCL->Checked)
  2349.             {
  2350.                 m_rbGMSK3PCL->Checked = true;
  2351.             }
  2352.             m_rbGMSK2PCL->Enabled = false;
  2353.             m_rbGMSK3PCL->Enabled = true;
  2354.             m_rb6DAC->Enabled = false;
  2355.             m_cbEPSK->Visible = false;
  2356.             m_gbEPSKTxPcl->Visible = false;
  2357.         }
  2358.         break;
  2359.         case RFMD_3159:
  2360.         //case SKY_77340:
  2361.         {
  2362.             if (!m_rbGMSKFullPCL->Checked)
  2363.             {
  2364.                 m_rbGMSK3PCL->Checked = true;
  2365.             }
  2366.             m_rbGMSK2PCL->Enabled = false;
  2367.             m_rbGMSK3PCL->Enabled = true;
  2368.             m_rb6DAC->Enabled = false;
  2369.             m_cbEPSK->Visible = true;
  2370.             m_gbEPSKTxPcl->Visible = true;
  2371.             m_rbEPSK2PCL->Enabled = false;
  2372.             if (RF_ID_A60111A != m_Cal.ui_rf_id)
  2373.             {
  2374.                 m_rbEPSK1PCL->Enabled = false;
  2375.                 m_rbEPSK2PCL->Enabled = false;
  2376.                 m_rbEPSK3PCL->Enabled = false;
  2377.                 m_rbEPSK4PCL->Enabled = true;
  2378.                 if (!m_rbEPSKFullPCL->Checked)
  2379.                 {
  2380.                     m_rbEPSK4PCL->Checked = true;
  2381.                 }
  2382.             }
  2383.             else
  2384.             {
  2385.                 m_rbEPSK1PCL->Enabled = true;
  2386.                 m_rbEPSK2PCL->Enabled = false;
  2387.                 m_rbEPSK3PCL->Enabled = false;
  2388.                 m_rbEPSK4PCL->Enabled = false;
  2389.                 if (!m_rbEPSKFullPCL->Checked)
  2390.                 {
  2391.                     m_rbEPSK1PCL->Checked = true;
  2392.                 }
  2393.             }
  2394.         }
  2395.         break;
  2396.         case SKY_77340:
  2397.         {
  2398.             if (!m_rbGMSKFullPCL->Checked)
  2399.             {
  2400.                 m_rbGMSK3PCL->Checked = false;
  2401.             }
  2402.             m_rbGMSKFullPCL->Checked = true;
  2403.             m_rbGMSKFullPCL->Enabled = true;
  2404.             m_rbGMSK2PCL->Enabled = false;
  2405.             m_rbGMSK3PCL->Enabled = false;
  2406.             m_rb6DAC->Enabled = false;
  2407.             m_cbEPSK->Visible = true;
  2408.             m_gbEPSKTxPcl->Visible = true;
  2409.             m_rbEPSK2PCL->Enabled = false;
  2410.             if (RF_ID_A60111A != m_Cal.ui_rf_id)
  2411.             {
  2412.                 m_rbEPSK1PCL->Enabled = false;
  2413.                 m_rbEPSK2PCL->Enabled = false;
  2414.                 m_rbEPSK3PCL->Enabled = false;
  2415.                 m_rbEPSK4PCL->Enabled = true;
  2416.                 if (!m_rbEPSKFullPCL->Checked)
  2417.                 {
  2418.                     m_rbEPSK4PCL->Checked = true;
  2419.                 }
  2420.             }
  2421.             else
  2422.             {
  2423.                 m_rbEPSK1PCL->Enabled = true;
  2424.                 m_rbEPSK2PCL->Enabled = false;
  2425.                 m_rbEPSK3PCL->Enabled = false;
  2426.                 m_rbEPSK4PCL->Enabled = false;
  2427.                 if (!m_rbEPSKFullPCL->Checked)
  2428.                 {
  2429.                     m_rbEPSK1PCL->Checked = true;
  2430.                 }
  2431.             }
  2432.         }
  2433.         break;
  2434.         case SKY_77328:
  2435.         case SKY_77506:
  2436.         {
  2437.             if (!m_rbGMSKFullPCL->Checked)
  2438.             {
  2439.                 m_rbGMSK2PCL->Checked = true;
  2440.             }
  2441.             m_rbGMSK2PCL->Enabled = true;
  2442.             m_rbGMSK3PCL->Enabled = false;
  2443.             m_rb6DAC->Enabled = false;
  2444.             m_cbEPSK->Visible = false;
  2445.             m_gbEPSKTxPcl->Visible = false;
  2446.             //m_gbPaBias->Visible = false;
  2447.         }
  2448.         break;
  2449.         case SKY_77316:
  2450.         {
  2451.             if (!m_rbGMSKFullPCL->Checked)
  2452.             {
  2453.                 m_rbGMSK2PCL->Checked = true;
  2454.             }
  2455.             m_rbGMSK2PCL->Enabled = true;
  2456.             m_rbGMSK3PCL->Enabled = false;
  2457.             m_rb6DAC->Enabled = false;
  2458.             m_cbEPSK->Visible = true;
  2459.             m_gbEPSKTxPcl->Visible = true;
  2460.             //m_gbPaBias->Visible = false;
  2461.             if (m_rbEPSK3PCL->Checked ||
  2462.                 m_rbEPSK4PCL->Checked
  2463.                )
  2464.             {
  2465.                 m_rbEPSK2PCL->Checked = true;
  2466.             }
  2467.             m_rbEPSK2PCL->Enabled = true;
  2468.             m_rbEPSK3PCL->Enabled = false;
  2469.             m_rbEPSK4PCL->Enabled = false;
  2470.         }
  2471.         break;
  2472.         case RENESAS_PF08155B:
  2473.         {
  2474.             if (!m_rbGMSKFullPCL->Checked)
  2475.             {
  2476.                 m_rbGMSK3PCL->Checked = true;
  2477.             }
  2478.             m_rbGMSK2PCL->Enabled = false;
  2479.             m_rbGMSK3PCL->Enabled = true;
  2480.             m_rb6DAC->Enabled = false;
  2481.             m_cbEPSK->Visible = false;
  2482.             m_gbEPSKTxPcl->Visible = false;
  2483.            // m_gbPaBias->Visible = false;
  2484.         }
  2485.         break;
  2486.         case AXIOM_AX502:
  2487.         {
  2488.             if (!m_rbGMSKFullPCL->Checked)
  2489.             {
  2490.                 m_rb6DAC->Checked = true;
  2491.             }
  2492.             m_rbGMSK2PCL->Enabled = false;
  2493.             m_rbGMSK3PCL->Enabled = false;
  2494.             m_rb6DAC->Enabled = true;
  2495.             m_cbEPSK->Visible = false;
  2496.             m_gbEPSKTxPcl->Visible = false;
  2497.            // m_gbPaBias->Visible = false;
  2498.         }
  2499.         break;
  2500.         case TRIQUINT_TQM6M5001:
  2501.         {
  2502.             if (!m_rbGMSKFullPCL->Checked)
  2503.             {
  2504.                 m_rbGMSK3PCL->Checked = true;
  2505.             }
  2506.             m_rbGMSK2PCL->Enabled = false;
  2507.             m_rbGMSK3PCL->Enabled = true;
  2508.             m_cbEPSK->Visible = true;
  2509.             m_gbEPSKTxPcl->Visible = true;
  2510.             if (m_rbEPSK3PCL->Checked ||
  2511.                 m_rbEPSK4PCL->Checked
  2512.                )
  2513.             {
  2514.                 m_rbEPSK2PCL->Checked = true;
  2515.             }
  2516.             m_rbEPSK2PCL->Enabled = true;
  2517.             m_rbEPSK3PCL->Enabled = false;
  2518.             m_rbEPSK4PCL->Enabled = false;
  2519.         }
  2520.         break;
  2521.        // case RENESAS_PF09016B:
  2522.        // {
  2523.        //     if( m_rbGMSK2PCL->Checked )
  2524.        //         m_rbGMSK3PCL->Checked = true;
  2525.        //
  2526.        //     m_rbGMSK2PCL->Enabled = false;
  2527.        //     m_rbGMSK3PCL->Enabled = true;
  2528.        // }
  2529.        // break;
  2530.         default:
  2531.         {
  2532.         }
  2533.         break;
  2534.     }
  2535. }
  2536. //---------------------------------------------------------------------------
  2537. void __fastcall TfrmFatcory::FormActivate(TObject *Sender)
  2538. {
  2539.     if ( m_bInit )
  2540.     {
  2541.         m_bInit = false;
  2542.         CMETAHANDLE META_HANDLE_Obj;
  2543.         m_Cal.i_MainMETAHandle = META_HANDLE_Obj.Get_MainHandle();
  2544.         // update UI
  2545.         
  2546.       // hForm_MF = this->Handle;
  2547.       // MF_ctrl.hPostMsgDestHandle = this->Handle;
  2548.      //  hForm_PostMsgTarget = this->Handle;
  2549.         //WindowProc = SubClassWndProc;
  2550.        // Query_TwoApcDcOffset_Support();
  2551.         
  2552.         m_Cal.ui_rf_id = frmMainSel->Get_FinalRFID();
  2553.         m_Cal.e_bb_chip = frmMainSel->Get_FinalBBChip();
  2554.         m_Cal.s_wifi_cap = frmMainSel->Get_FinalWiFiCap();
  2555.         BT_ModuleID_S* p_bt_moduleid = frmMainSel->Get_BTMoudleID();
  2556.         m_Cal.s_bt_bb_id = *p_bt_moduleid;
  2557.         //IP2
  2558.         if( //RF_ID_MT6139B  == m_Cal.ui_rf_id ||
  2559.          //   RF_ID_MT6139C  == m_Cal.ui_rf_id ||
  2560. //            RF_ID_MT6139E  == m_Cal.ui_rf_id ||
  2561.            // RF_ID_MT6140A  == m_Cal.ui_rf_id ||
  2562.            // RF_ID_MT6140B  == m_Cal.ui_rf_id ||
  2563.             RF_ID_SKY74045 == m_Cal.ui_rf_id ||
  2564.             RF_ID_SKY74117 == m_Cal.ui_rf_id ||
  2565.             RF_ID_SKY74400 == m_Cal.ui_rf_id
  2566.           )
  2567.         {
  2568.             cbIP2->Visible = true;
  2569.         }
  2570.         else
  2571.         {
  2572.             cbIP2->Checked = false;
  2573.             cbIP2->Visible = false;
  2574.         }
  2575.         // TADO
  2576.         m_Cal.b_TADOSupport = frmMainSel->Get_TADO_Support();
  2577.         // RF capability
  2578.         m_Cal.RfCapability = frmMainSel->Get_FinalMSCap();
  2579.         // TX IQ version
  2580.         CRFTXIQRUN RF_TXIQRUN_Obj;
  2581.         BBCHIP_TYPE bb_chip = frmMainSel->Get_FinalBBChip();
  2582.         m_Cal.e_bbtxcfg_ver = RF_TXIQRUN_Obj.Query_BBTxCfgVer_Start(bb_chip);
  2583.         if( b_OpenCfgFile )
  2584.         {
  2585.             char cM_PM;
  2586.             META_factory_cfg->getM_PM( cM_PM );
  2587.             if( (cM_PM >= 5) &&  (0 == m_Cal.RfCapability.capability.Calibration_8PM) )
  2588.             {
  2589.                 Application->MessageBox( "MS support at most 4 PM per frame, please modify M_PM value in CFG file" , "Warning", MB_OK );
  2590.             }
  2591.             else if( cM_PM > 8 )
  2592.             {
  2593.                 Application->MessageBox( "MS support at most 8 PM per frame, please modify M_PM value in CFG file" , "Warning", MB_OK );
  2594.             }
  2595.         }
  2596.         // multislot TX
  2597.         CRFMULTISLOTTX RF_MULTI_SLOT_TX_Obj;
  2598.         m_Cal.b_MultiSlotTxExSupport = RF_MULTI_SLOT_TX_Obj.Query_MultiSlotTxEx_Start();
  2599.         // WiFi ALC
  2600.         CWIFIALC   WIFI_ALC_Obj;
  2601.         m_Cal.b_WiFiAlcSupport = WIFI_ALC_Obj.REQ_Query_ALC_Suppport_Start();
  2602.         // BT
  2603.         if ((BTMODULE_MT6601 == m_Cal.s_bt_bb_id.id) ||
  2604.             (BTMODULE_MT6611 == m_Cal.s_bt_bb_id.id) 
  2605.            )
  2606.         {
  2607.             m_cbBTCapID->Visible = true;
  2608.         }
  2609.         else
  2610.         {
  2611.             m_cbBTCapID->Visible = false;
  2612.             m_cbBTCapID->Checked = false;
  2613.         }
  2614.     }
  2615. }
  2616. //---------------------------------------------------------------------------
  2617. void __fastcall TfrmFatcory::rbTCVCXOClick(TObject *Sender)
  2618. {
  2619.     m_cbTrxOffset->Visible = false;
  2620. }
  2621. //---------------------------------------------------------------------------
  2622. void __fastcall TfrmFatcory::rbCrystalClick(TObject *Sender)
  2623. {
  2624.     m_cbTrxOffset->Visible = true;
  2625. }
  2626. //---------------------------------------------------------------------------