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

MTK

开发平台:

C++ Builder

  1. /*****************************************************************************
  2. *  Copyright Statement:
  3. *  --------------------
  4. *  This software is protected by Copyright and the information contained
  5. *  herein is confidential. The software may not be copied and the information
  6. *  contained herein may not be used or disclosed except with the written
  7. *  permission of MediaTek Inc. (C) 2005
  8. *
  9. *  BY OPENING THIS FILE, BUYER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
  10. *  THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
  11. *  RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO BUYER ON
  12. *  AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES,
  13. *  EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF
  14. *  MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR NONINFRINGEMENT.
  15. *  NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH RESPECT TO THE
  16. *  SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY, INCORPORATED IN, OR
  17. *  SUPPLIED WITH THE MEDIATEK SOFTWARE, AND BUYER AGREES TO LOOK ONLY TO SUCH
  18. *  THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO. MEDIATEK SHALL ALSO
  19. *  NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE RELEASES MADE TO BUYER'S
  20. *  SPECIFICATION OR TO CONFORM TO A PARTICULAR STANDARD OR OPEN FORUM.
  21. *
  22. *  BUYER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S ENTIRE AND CUMULATIVE
  23. *  LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE RELEASED HEREUNDER WILL BE,
  24. *  AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE MEDIATEK SOFTWARE AT ISSUE,
  25. *  OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE CHARGE PAID BY BUYER TO
  26. *  MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
  27. *
  28. *  THE TRANSACTION CONTEMPLATED HEREUNDER SHALL BE CONSTRUED IN ACCORDANCE
  29. *  WITH THE LAWS OF THE STATE OF CALIFORNIA, USA, EXCLUDING ITS CONFLICT OF
  30. *  LAWS PRINCIPLES.  ANY DISPUTES, CONTROVERSIES OR CLAIMS ARISING THEREOF AND
  31. *  RELATED THERETO SHALL BE SETTLED BY ARBITRATION IN SAN FRANCISCO, CA, UNDER
  32. *  THE RULES OF THE INTERNATIONAL CHAMBER OF COMMERCE (ICC).
  33. *
  34. *****************************************************************************/
  35. /*****************************************************************************
  36.  *
  37.  * Filename:
  38.  * ---------
  39.  *   form_CFGRxPahtLoss.cpp
  40.  *
  41.  * Project:
  42.  * --------
  43.  *   Maui META APP
  44.  *
  45.  * Description:
  46.  * ------------
  47.  *  RX path loss CFG form source
  48.  *
  49.  * Author:
  50.  * -------
  51.  *  Andy Ueng (mtk00490)
  52.  *
  53.  *============================================================================
  54.  *             HISTORY
  55.  * Below this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  56.  *------------------------------------------------------------------------------
  57.  * $Revision$
  58.  * $Modtime$
  59.  * $Log$
  60.  * 
  61.  *------------------------------------------------------------------------------
  62.  * Upper this line, this part is controlled by PVCS VM. DO NOT MODIFY!!
  63.  *============================================================================
  64.  ****************************************************************************/
  65. //---------------------------------------------------------------------------
  66. #include <vcl.h>
  67. #include <assert.h>
  68. #pragma hdrstop
  69. // form
  70. #include "form_CFGRxPathLoss.h"
  71. #include "META_Factory.h"
  72. #include "meta_const.h"
  73. // misc
  74. #include "misc.h"
  75. #ifndef  _FT_UTILS_H_
  76. #include "ft_utils.h"
  77. #endif
  78. //---------------------------------------------------------------------------
  79. #pragma package(smart_init)
  80. #pragma resource "*.dfm"
  81. TfrmCFGRxPathLoss *frmCFGRxPathLoss;
  82. //---------------------------------------------------------------------------
  83. __fastcall TfrmCFGRxPathLoss::TfrmCFGRxPathLoss(TComponent* Owner)
  84.         : TForm(Owner)
  85. {
  86.     // RX path loss
  87.     InitRxPathLoss();
  88. }
  89. //---------------------------------------------------------------------------
  90. void TfrmCFGRxPathLoss::InitRxPathLoss( void )
  91. {
  92.     edtMAX_RX_LOSS[FrequencyBand850][ 0] = edtGSM850_MAX_RX_LOSS_0;
  93.     edtMAX_RX_LOSS[FrequencyBand850][ 1] = edtGSM850_MAX_RX_LOSS_1;
  94.     edtMAX_RX_LOSS[FrequencyBand850][ 2] = edtGSM850_MAX_RX_LOSS_2;
  95.     edtMAX_RX_LOSS[FrequencyBand850][ 3] = edtGSM850_MAX_RX_LOSS_3;
  96.     edtMAX_RX_LOSS[FrequencyBand850][ 4] = edtGSM850_MAX_RX_LOSS_4;
  97.     edtMAX_RX_LOSS[FrequencyBand850][ 5] = edtGSM850_MAX_RX_LOSS_5;
  98.     edtMAX_RX_LOSS[FrequencyBand850][ 6] = edtGSM850_MAX_RX_LOSS_6;
  99.     edtMAX_RX_LOSS[FrequencyBand850][ 7] = edtGSM850_MAX_RX_LOSS_7;
  100.     edtMAX_RX_LOSS[FrequencyBand850][ 8] = edtGSM850_MAX_RX_LOSS_8;
  101.     edtMAX_RX_LOSS[FrequencyBand850][ 9] = edtGSM850_MAX_RX_LOSS_9;
  102.     edtMAX_RX_LOSS[FrequencyBand850][10] = edtGSM850_MAX_RX_LOSS_10;
  103.     edtMAX_RX_LOSS[FrequencyBand850][11] = edtGSM850_MAX_RX_LOSS_11;
  104.     edtMIN_RX_LOSS[FrequencyBand850][ 0] = edtGSM850_MIN_RX_LOSS_0;
  105.     edtMIN_RX_LOSS[FrequencyBand850][ 1] = edtGSM850_MIN_RX_LOSS_1;
  106.     edtMIN_RX_LOSS[FrequencyBand850][ 2] = edtGSM850_MIN_RX_LOSS_2;
  107.     edtMIN_RX_LOSS[FrequencyBand850][ 3] = edtGSM850_MIN_RX_LOSS_3;
  108.     edtMIN_RX_LOSS[FrequencyBand850][ 4] = edtGSM850_MIN_RX_LOSS_4;
  109.     edtMIN_RX_LOSS[FrequencyBand850][ 5] = edtGSM850_MIN_RX_LOSS_5;
  110.     edtMIN_RX_LOSS[FrequencyBand850][ 6] = edtGSM850_MIN_RX_LOSS_6;
  111.     edtMIN_RX_LOSS[FrequencyBand850][ 7] = edtGSM850_MIN_RX_LOSS_7;
  112.     edtMIN_RX_LOSS[FrequencyBand850][ 8] = edtGSM850_MIN_RX_LOSS_8;
  113.     edtMIN_RX_LOSS[FrequencyBand850][ 9] = edtGSM850_MIN_RX_LOSS_9;
  114.     edtMIN_RX_LOSS[FrequencyBand850][10] = edtGSM850_MIN_RX_LOSS_10;
  115.     edtMIN_RX_LOSS[FrequencyBand850][11] = edtGSM850_MIN_RX_LOSS_11;
  116.     edtMAX_RX_LOSS[FrequencyBand900][ 0] = edtGSM900_MAX_RX_LOSS_0;
  117.     edtMAX_RX_LOSS[FrequencyBand900][ 1] = edtGSM900_MAX_RX_LOSS_1;
  118.     edtMAX_RX_LOSS[FrequencyBand900][ 2] = edtGSM900_MAX_RX_LOSS_2;
  119.     edtMAX_RX_LOSS[FrequencyBand900][ 3] = edtGSM900_MAX_RX_LOSS_3;
  120.     edtMAX_RX_LOSS[FrequencyBand900][ 4] = edtGSM900_MAX_RX_LOSS_4;
  121.     edtMAX_RX_LOSS[FrequencyBand900][ 5] = edtGSM900_MAX_RX_LOSS_5;
  122.     edtMAX_RX_LOSS[FrequencyBand900][ 6] = edtGSM900_MAX_RX_LOSS_6;
  123.     edtMAX_RX_LOSS[FrequencyBand900][ 7] = edtGSM900_MAX_RX_LOSS_7;
  124.     edtMAX_RX_LOSS[FrequencyBand900][ 8] = edtGSM900_MAX_RX_LOSS_8;
  125.     edtMAX_RX_LOSS[FrequencyBand900][ 9] = edtGSM900_MAX_RX_LOSS_9;
  126.     edtMAX_RX_LOSS[FrequencyBand900][10] = edtGSM900_MAX_RX_LOSS_10;
  127.     edtMAX_RX_LOSS[FrequencyBand900][11] = edtGSM900_MAX_RX_LOSS_11;
  128.     edtMIN_RX_LOSS[FrequencyBand900][ 0] = edtGSM900_MIN_RX_LOSS_0;
  129.     edtMIN_RX_LOSS[FrequencyBand900][ 1] = edtGSM900_MIN_RX_LOSS_1;
  130.     edtMIN_RX_LOSS[FrequencyBand900][ 2] = edtGSM900_MIN_RX_LOSS_2;
  131.     edtMIN_RX_LOSS[FrequencyBand900][ 3] = edtGSM900_MIN_RX_LOSS_3;
  132.     edtMIN_RX_LOSS[FrequencyBand900][ 4] = edtGSM900_MIN_RX_LOSS_4;
  133.     edtMIN_RX_LOSS[FrequencyBand900][ 5] = edtGSM900_MIN_RX_LOSS_5;
  134.     edtMIN_RX_LOSS[FrequencyBand900][ 6] = edtGSM900_MIN_RX_LOSS_6;
  135.     edtMIN_RX_LOSS[FrequencyBand900][ 7] = edtGSM900_MIN_RX_LOSS_7;
  136.     edtMIN_RX_LOSS[FrequencyBand900][ 8] = edtGSM900_MIN_RX_LOSS_8;
  137.     edtMIN_RX_LOSS[FrequencyBand900][ 9] = edtGSM900_MIN_RX_LOSS_9;
  138.     edtMIN_RX_LOSS[FrequencyBand900][10] = edtGSM900_MIN_RX_LOSS_10;
  139.     edtMIN_RX_LOSS[FrequencyBand900][11] = edtGSM900_MIN_RX_LOSS_11;
  140.     edtMAX_RX_LOSS[FrequencyBand1800][ 0] = edtDCS1800_MAX_RX_LOSS_0;
  141.     edtMAX_RX_LOSS[FrequencyBand1800][ 1] = edtDCS1800_MAX_RX_LOSS_1;
  142.     edtMAX_RX_LOSS[FrequencyBand1800][ 2] = edtDCS1800_MAX_RX_LOSS_2;
  143.     edtMAX_RX_LOSS[FrequencyBand1800][ 3] = edtDCS1800_MAX_RX_LOSS_3;
  144.     edtMAX_RX_LOSS[FrequencyBand1800][ 4] = edtDCS1800_MAX_RX_LOSS_4;
  145.     edtMAX_RX_LOSS[FrequencyBand1800][ 5] = edtDCS1800_MAX_RX_LOSS_5;
  146.     edtMAX_RX_LOSS[FrequencyBand1800][ 6] = edtDCS1800_MAX_RX_LOSS_6;
  147.     edtMAX_RX_LOSS[FrequencyBand1800][ 7] = edtDCS1800_MAX_RX_LOSS_7;
  148.     edtMAX_RX_LOSS[FrequencyBand1800][ 8] = edtDCS1800_MAX_RX_LOSS_8;
  149.     edtMAX_RX_LOSS[FrequencyBand1800][ 9] = edtDCS1800_MAX_RX_LOSS_9;
  150.     edtMAX_RX_LOSS[FrequencyBand1800][10] = edtDCS1800_MAX_RX_LOSS_10;
  151.     edtMAX_RX_LOSS[FrequencyBand1800][11] = edtDCS1800_MAX_RX_LOSS_11;
  152.     edtMIN_RX_LOSS[FrequencyBand1800][ 0] = edtDCS1800_MIN_RX_LOSS_0;
  153.     edtMIN_RX_LOSS[FrequencyBand1800][ 1] = edtDCS1800_MIN_RX_LOSS_1;
  154.     edtMIN_RX_LOSS[FrequencyBand1800][ 2] = edtDCS1800_MIN_RX_LOSS_2;
  155.     edtMIN_RX_LOSS[FrequencyBand1800][ 3] = edtDCS1800_MIN_RX_LOSS_3;
  156.     edtMIN_RX_LOSS[FrequencyBand1800][ 4] = edtDCS1800_MIN_RX_LOSS_4;
  157.     edtMIN_RX_LOSS[FrequencyBand1800][ 5] = edtDCS1800_MIN_RX_LOSS_5;
  158.     edtMIN_RX_LOSS[FrequencyBand1800][ 6] = edtDCS1800_MIN_RX_LOSS_6;
  159.     edtMIN_RX_LOSS[FrequencyBand1800][ 7] = edtDCS1800_MIN_RX_LOSS_7;
  160.     edtMIN_RX_LOSS[FrequencyBand1800][ 8] = edtDCS1800_MIN_RX_LOSS_8;
  161.     edtMIN_RX_LOSS[FrequencyBand1800][ 9] = edtDCS1800_MIN_RX_LOSS_9;
  162.     edtMIN_RX_LOSS[FrequencyBand1800][10] = edtDCS1800_MIN_RX_LOSS_10;
  163.     edtMIN_RX_LOSS[FrequencyBand1800][11] = edtDCS1800_MIN_RX_LOSS_11;
  164.     edtMAX_RX_LOSS[FrequencyBand1900][ 0] = edtPCS1900_MAX_RX_LOSS_0;
  165.     edtMAX_RX_LOSS[FrequencyBand1900][ 1] = edtPCS1900_MAX_RX_LOSS_1;
  166.     edtMAX_RX_LOSS[FrequencyBand1900][ 2] = edtPCS1900_MAX_RX_LOSS_2;
  167.     edtMAX_RX_LOSS[FrequencyBand1900][ 3] = edtPCS1900_MAX_RX_LOSS_3;
  168.     edtMAX_RX_LOSS[FrequencyBand1900][ 4] = edtPCS1900_MAX_RX_LOSS_4;
  169.     edtMAX_RX_LOSS[FrequencyBand1900][ 5] = edtPCS1900_MAX_RX_LOSS_5;
  170.     edtMAX_RX_LOSS[FrequencyBand1900][ 6] = edtPCS1900_MAX_RX_LOSS_6;
  171.     edtMAX_RX_LOSS[FrequencyBand1900][ 7] = edtPCS1900_MAX_RX_LOSS_7;
  172.     edtMAX_RX_LOSS[FrequencyBand1900][ 8] = edtPCS1900_MAX_RX_LOSS_8;
  173.     edtMAX_RX_LOSS[FrequencyBand1900][ 9] = edtPCS1900_MAX_RX_LOSS_9;
  174.     edtMAX_RX_LOSS[FrequencyBand1900][10] = edtPCS1900_MAX_RX_LOSS_10;
  175.     edtMAX_RX_LOSS[FrequencyBand1900][11] = edtPCS1900_MAX_RX_LOSS_11;
  176.     edtMIN_RX_LOSS[FrequencyBand1900][ 0] = edtPCS1900_MIN_RX_LOSS_0;
  177.     edtMIN_RX_LOSS[FrequencyBand1900][ 1] = edtPCS1900_MIN_RX_LOSS_1;
  178.     edtMIN_RX_LOSS[FrequencyBand1900][ 2] = edtPCS1900_MIN_RX_LOSS_2;
  179.     edtMIN_RX_LOSS[FrequencyBand1900][ 3] = edtPCS1900_MIN_RX_LOSS_3;
  180.     edtMIN_RX_LOSS[FrequencyBand1900][ 4] = edtPCS1900_MIN_RX_LOSS_4;
  181.     edtMIN_RX_LOSS[FrequencyBand1900][ 5] = edtPCS1900_MIN_RX_LOSS_5;
  182.     edtMIN_RX_LOSS[FrequencyBand1900][ 6] = edtPCS1900_MIN_RX_LOSS_6;
  183.     edtMIN_RX_LOSS[FrequencyBand1900][ 7] = edtPCS1900_MIN_RX_LOSS_7;
  184.     edtMIN_RX_LOSS[FrequencyBand1900][ 8] = edtPCS1900_MIN_RX_LOSS_8;
  185.     edtMIN_RX_LOSS[FrequencyBand1900][ 9] = edtPCS1900_MIN_RX_LOSS_9;
  186.     edtMIN_RX_LOSS[FrequencyBand1900][10] = edtPCS1900_MIN_RX_LOSS_10;
  187.     edtMIN_RX_LOSS[FrequencyBand1900][11] = edtPCS1900_MIN_RX_LOSS_11;
  188. }
  189. //---------------------------------------------------------------------------
  190. void __fastcall TfrmCFGRxPathLoss::btnLoadFromCFGFileClick(TObject *Sender)
  191. {
  192.     bool ok;
  193.     AnsiString asPath, asFileName;
  194.     AnsiString as_sub_max_rx_loss, as_sub_min_rx_loss;
  195.     int i;
  196.     static bool isFirstOpen = true;
  197.     if( isFirstOpen )
  198.     {
  199.         isFirstOpen = false;
  200.         if( getPathFromStr( frmFatcory->stCFGFile->Caption, asPath ) )
  201.         {
  202.             OpenDlg->InitialDir = asPath;
  203.             if( getFilenameFromStr( frmFatcory->stCFGFile->Caption, asFileName ) )
  204.             {
  205.                 OpenDlg->FileName = asFileName;
  206.             }
  207.         }
  208.         else
  209.         {
  210.             if( getPathFromStr(Application->ExeName, asPath) )
  211.             {
  212.                 OpenDlg->InitialDir = asPath;
  213.             }
  214.             else
  215.             {
  216.                 OpenDlg->InitialDir = "C:\";
  217.             }
  218.         }
  219.     }
  220.     ok = OpenDlg->Execute();
  221.     if( !ok )
  222.     {
  223.         sbCFGRxPathLoss->Panels->Items[0]->Text = (AnsiString) "  Load RX path loss setting from file fail";
  224.         Application->MessageBox( "Execution Failure : Load RX path loss setting from file fail", "FAILURE", MB_OK );
  225.         return;
  226.     }
  227.     if (!cfg->ReadFromIniFile(OpenDlg->FileName))
  228.     {
  229.         sbCFGRxPathLoss->Panels->Items[0]->Text = (AnsiString) "  Read CFG file fail";
  230.         Application->MessageBox( "Execution Failure : Read CFG file", "FAILURE", MB_OK );
  231.         return;
  232.     }
  233.     // N_PM
  234.     cfg->getN_PM( iN_PM );
  235.     edtN_PM->Text = IntToStr( iN_PM );
  236.     // M_PM
  237.     cfg->getM_PM( cM_PM );
  238.     cbM_PM->ItemIndex = IntToStr( cM_PM ) - 1;
  239.     // GSM850_MAX_RX_LOSS
  240.     cfg->getGSM850_MAX_RX_LOSS( as_MAX_RX_LOSS[FrequencyBand850] );
  241.     for( i=1; i<PLTABLE_SIZE; i++)
  242.     {
  243.         if(! getAnsiStrSubItem( as_MAX_RX_LOSS[FrequencyBand850], i, DEFAULT_SEP_CHAR, as_sub_max_rx_loss ))
  244.         {
  245.             sbCFGRxPathLoss->Panels->Items[0]->Text = (AnsiString) "  Get GSM850_MAX_RX_LOSS from file fail";
  246.             Application->MessageBox( "Execution Failure : Get GSM850_MAX_RX_LOSS from file fail", "FAILURE", MB_OK );
  247.             return;
  248.         }
  249.         edtMAX_RX_LOSS[FrequencyBand850][i-1]->Text = as_sub_max_rx_loss;
  250.     }
  251.     // GSM850_MIN_RX_LOSS
  252.     cfg->getGSM850_MIN_RX_LOSS( as_MIN_RX_LOSS[FrequencyBand850] );
  253.     for( i=1; i<PLTABLE_SIZE; i++)
  254.     {
  255.         if(! getAnsiStrSubItem( as_MIN_RX_LOSS[FrequencyBand850], i, DEFAULT_SEP_CHAR, as_sub_min_rx_loss ))
  256.         {
  257.             sbCFGRxPathLoss->Panels->Items[0]->Text = (AnsiString) "  Get GSM850_MIN_RX_LOSS from file fail";
  258.             Application->MessageBox( "Execution Failure : Get GSM850_MIN_RX_LOSS from file fail", "FAILURE", MB_OK );
  259.             return;
  260.         }
  261.         edtMIN_RX_LOSS[FrequencyBand850][i-1]->Text = as_sub_min_rx_loss;
  262.     }
  263.     // GSM900_MAX_RX_LOSS
  264.     cfg->getGSM900_MAX_RX_LOSS( as_MAX_RX_LOSS[FrequencyBand900] );
  265.     for( i=1; i<PLTABLE_SIZE; i++)
  266.     {
  267.         if(! getAnsiStrSubItem( as_MAX_RX_LOSS[FrequencyBand900], i, DEFAULT_SEP_CHAR, as_sub_max_rx_loss ))
  268.         {
  269.             sbCFGRxPathLoss->Panels->Items[0]->Text = (AnsiString) "  Get GSM900_MAX_RX_LOSS from file fail";
  270.             Application->MessageBox( "Execution Failure : Get GSM900_MAX_RX_LOSS from file fail", "FAILURE", MB_OK );
  271.             return;
  272.         }
  273.         edtMAX_RX_LOSS[FrequencyBand900][i-1]->Text = as_sub_max_rx_loss;
  274.     }
  275.     // GSM900_MIN_RX_LOSS
  276.     cfg->getGSM900_MIN_RX_LOSS( as_MIN_RX_LOSS[FrequencyBand900] );
  277.     for( i=1; i<PLTABLE_SIZE; i++)
  278.     {
  279.         if(! getAnsiStrSubItem( as_MIN_RX_LOSS[FrequencyBand900], i, DEFAULT_SEP_CHAR, as_sub_min_rx_loss ))
  280.         {
  281.             sbCFGRxPathLoss->Panels->Items[0]->Text = (AnsiString) "  Get GSM900_MIN_RX_LOSS from file fail";
  282.             Application->MessageBox( "Execution Failure : Get GSM900_MIN_RX_LOSS from file fail", "FAILURE", MB_OK );
  283.             return;
  284.         }
  285.         edtMIN_RX_LOSS[FrequencyBand900][i-1]->Text = as_sub_min_rx_loss;
  286.     }
  287.     // DCS1800_MAX_RX_LOSS
  288.     cfg->getDCS1800_MAX_RX_LOSS( as_MAX_RX_LOSS[FrequencyBand1800] );
  289.     for( i=1; i<PLTABLE_SIZE; i++)
  290.     {
  291.         if(! getAnsiStrSubItem( as_MAX_RX_LOSS[FrequencyBand1800], i, DEFAULT_SEP_CHAR, as_sub_max_rx_loss ))
  292.         {
  293.             sbCFGRxPathLoss->Panels->Items[0]->Text = (AnsiString) "  Get DCS1800_MAX_RX_LOSS from file fail";
  294.             Application->MessageBox( "Execution Failure : Get DCS1800_MAX_RX_LOSS from file fail", "FAILURE", MB_OK );
  295.             return;
  296.         }
  297.         edtMAX_RX_LOSS[FrequencyBand1800][i-1]->Text = as_sub_max_rx_loss;
  298.     }
  299.     // DCS1800_MIN_RX_LOSS
  300.     cfg->getDCS1800_MIN_RX_LOSS( as_MIN_RX_LOSS[FrequencyBand1800] );
  301.     for( i=1; i<PLTABLE_SIZE; i++)
  302.     {
  303.         if(! getAnsiStrSubItem( as_MIN_RX_LOSS[FrequencyBand1800], i, DEFAULT_SEP_CHAR, as_sub_min_rx_loss ))
  304.         {
  305.             sbCFGRxPathLoss->Panels->Items[0]->Text = (AnsiString) "  Get DCS1800_MIN_RX_LOSS from file fail";
  306.             Application->MessageBox( "Execution Failure : Get DCS1800_MIN_RX_LOSS from file fail", "FAILURE", MB_OK );
  307.             return;
  308.         }
  309.         edtMIN_RX_LOSS[FrequencyBand1800][i-1]->Text = as_sub_min_rx_loss;
  310.     }
  311.     // PCS1900_MAX_RX_LOSS
  312.     cfg->getPCS1900_MAX_RX_LOSS( as_MAX_RX_LOSS[FrequencyBand1900] );
  313.     for( i=1; i<PLTABLE_SIZE; i++)
  314.     {
  315.         if(! getAnsiStrSubItem( as_MAX_RX_LOSS[FrequencyBand1900], i, DEFAULT_SEP_CHAR, as_sub_max_rx_loss ))
  316.         {
  317.             sbCFGRxPathLoss->Panels->Items[0]->Text = (AnsiString) "  Get PCS1900_MAX_RX_LOSS from file fail";
  318.             Application->MessageBox( "Execution Failure : Get PCS1900_MAX_RX_LOSS from file fail", "FAILURE", MB_OK );
  319.             return;
  320.         }
  321.         edtMAX_RX_LOSS[FrequencyBand1900][i-1]->Text = as_sub_max_rx_loss;
  322.     }
  323.     // PCS1900_MIN_RX_LOSS
  324.     cfg->getPCS1900_MIN_RX_LOSS( as_MIN_RX_LOSS[FrequencyBand1900] );
  325.     for( i=1; i<PLTABLE_SIZE; i++)
  326.     {
  327.         if(! getAnsiStrSubItem( as_MIN_RX_LOSS[FrequencyBand1900], i, DEFAULT_SEP_CHAR, as_sub_min_rx_loss ))
  328.         {
  329.             sbCFGRxPathLoss->Panels->Items[0]->Text = (AnsiString) "  Get PCS1900_MIN_RX_LOSS from file fail";
  330.             Application->MessageBox( "Execution Failure : Get PCS1900_MIN_RX_LOSS from file fail", "FAILURE", MB_OK );
  331.             return;
  332.         }
  333.         edtMIN_RX_LOSS[FrequencyBand1900][i-1]->Text = as_sub_min_rx_loss;
  334.     }
  335. }
  336. //---------------------------------------------------------------------------
  337. void __fastcall TfrmCFGRxPathLoss::FormDestroy(TObject *Sender)
  338. {
  339.     if(cfg != NULL)
  340.     {
  341.         delete cfg;
  342.         cfg = NULL;
  343.     }
  344. }
  345. //---------------------------------------------------------------------------
  346. void __fastcall TfrmCFGRxPathLoss::btnSaveToCFGFileClick(TObject *Sender)
  347. {
  348.     bool ok;
  349.     int i;
  350.     AnsiString asPath, asFileName;
  351.     static bool isFirstSave = true;
  352.     if( ! CheckFields() )
  353.     {
  354.         sbCFGRxPathLoss->Panels->Items[0]->Text = (AnsiString) "  Save RX path loss setting to file fail";
  355.         Application->MessageBox( "Execution Failure : Save RX path loss setting to file", "FAILURE", MB_OK );
  356.         return;
  357.     }
  358.     
  359.     if( isFirstSave )
  360.     {
  361.         isFirstSave = false;
  362.         if( getPathFromStr( frmFatcory->stCFGFile->Caption, asPath ) )
  363.         {
  364.             SaveDlg->InitialDir = asPath;
  365.             if( getFilenameFromStr( frmFatcory->stCFGFile->Caption, asFileName ) )
  366.             {
  367.                 SaveDlg->FileName = asFileName;
  368.             }
  369.         }
  370.         else
  371.         {
  372.             if( getPathFromStr(Application->ExeName, asPath) )
  373.             {
  374.                 SaveDlg->InitialDir = asPath;
  375.             }
  376.             else
  377.             {
  378.                 SaveDlg->InitialDir = "C:\";
  379.             }
  380.         }
  381.     }
  382.     ok = SaveDlg->Execute();
  383.     if( !ok )
  384.     {
  385.         sbCFGRxPathLoss->Panels->Items[0]->Text = (AnsiString) "  Save RX path loss setting to file fail";
  386.         Application->MessageBox( "Execution Failure : Save RX path loss setting to file", "FAILURE", MB_OK );
  387.         return;
  388.     }
  389.     cfg->SaveRxPathLossToCfgFile( SaveDlg->FileName );
  390. }
  391. //---------------------------------------------------------------------------
  392. void __fastcall TfrmCFGRxPathLoss::FormClose(TObject *Sender,
  393.       TCloseAction &Action)
  394. {
  395.     if(cfg != NULL)
  396.     {
  397.         delete cfg;
  398.         cfg = NULL;
  399.     }    
  400. }
  401. //---------------------------------------------------------------------------
  402. void __fastcall TfrmCFGRxPathLoss::FormShow(TObject *Sender)
  403. {
  404.     static bool isFirstFormShow = true;
  405.     if(cfg == NULL)
  406.     {
  407.         cfg = new TMETA_factory_cfg();
  408.     }
  409.     
  410.     if( isFirstFormShow )
  411.     {
  412.         isFirstFormShow = false;
  413.         CheckFields();
  414.     }
  415. }
  416. //---------------------------------------------------------------------------
  417. bool  TfrmCFGRxPathLoss::CheckFields( void )
  418. {
  419.     int  i, j;
  420.     float  fdata[FrequencyBandCount][PLTABLE_SIZE];
  421.     char        str[2048];
  422.     AnsiString  text;
  423.     cM_PM = cbM_PM->ItemIndex + 1;
  424.     cfg->setM_PM( cM_PM );
  425.     text = edtN_PM->Text;   if( !IsValidCFGPMCount( text, cM_PM, iN_PM ) )         {  edtN_PMCheck(edtN_PM);   return(false);   }
  426.     cfg->setN_PM( iN_PM );
  427.     for(i=0; i<FrequencyBandCount; i++)
  428.     {
  429.         for(j=0; j<PLTABLE_SIZE-1; j++)
  430.         {
  431.             text = edtMAX_RX_LOSS[i][j]->Text;   if( !IsValidPathLoss( text, f_MAX_RX_LOSS[i][j] ) )         {  edtMaxPathLossCheck(i, edtMAX_RX_LOSS[i][j]);   return(false);   }
  432.             text = edtMIN_RX_LOSS[i][j]->Text;   if( !IsValidPathLoss( text, f_MIN_RX_LOSS[i][j] ) )         {  edtMinPathLossCheck(i, edtMIN_RX_LOSS[i][j]);   return(false);   }
  433.         }
  434.         Array_To_String_float( str, f_MAX_RX_LOSS[i], PLTABLE_SIZE-1, ',' );
  435.         strcat( str, "," );
  436.         cfg->setMAX_RX_LOSS( i, str );
  437.         Array_To_String_float( str, f_MIN_RX_LOSS[i], PLTABLE_SIZE-1, ',' );
  438.         strcat( str, "," );
  439.         cfg->setMIN_RX_LOSS( i, str );
  440.     }
  441.     return true;
  442. }
  443. //---------------------------------------------------------------------------
  444. void  TfrmCFGRxPathLoss::ShowHintLabel( TControl *sender, char* hint )
  445. {
  446.    TPoint pt0 = this->ClientOrigin;
  447.    TPoint pt1 = sender->ClientOrigin;
  448.    lblHint->Left = (pt1.x-pt0.x);
  449.    lblHint->Top  = (pt1.y-pt0.y)+sender->Height+3;
  450.    lblHint->Caption = hint;
  451.    lblHint->Visible = true;
  452.    HintTimer->Enabled = true;
  453. }
  454. //---------------------------------------------------------------------------
  455. void __fastcall TfrmCFGRxPathLoss::edtGSM400_MAX_RX_LOSS_Check(TObject *Sender)
  456. {
  457.     AnsiString  text;
  458.     float  fdata;
  459.     int  band;
  460.     TEdit *edit = (TEdit*)Sender;
  461.     char  hint[] = " character is not valid ";
  462.     text = edit->Text;
  463.     if( !IsValidPathLoss( text, fdata ) )
  464.     {
  465.         ShowHintLabel( edit, hint );
  466.         edit->SetFocus();
  467.         return;
  468.     }
  469.     f_MAX_RX_LOSS[FrequencyBand400][Tag] = fdata;
  470. }
  471. //---------------------------------------------------------------------------
  472. void __fastcall TfrmCFGRxPathLoss::edtGSM400_MIN_RX_LOSS_Check(
  473.       TObject *Sender)
  474. {
  475.     AnsiString  text;
  476.     float  fdata;
  477.     int  band;
  478.     TEdit *edit = (TEdit*)Sender;
  479.     char  hint[] = " character is not valid ";
  480.     text = edit->Text;
  481.     if( !IsValidPathLoss( text, fdata ) )
  482.     {
  483.         ShowHintLabel( edit, hint );
  484.         edit->SetFocus();
  485.         return;
  486.     }
  487.     f_MIN_RX_LOSS[FrequencyBand400][Tag] = fdata;
  488. }
  489. //---------------------------------------------------------------------------
  490. void __fastcall TfrmCFGRxPathLoss::edtGSM850_MAX_RX_LOSS_Check(
  491.       TObject *Sender)
  492. {
  493.     AnsiString  text;
  494.     float  fdata;
  495.     int  band;
  496.     TEdit *edit = (TEdit*)Sender;
  497.     char  hint[] = " character is not valid ";
  498.     text = edit->Text;
  499.     if( !IsValidPathLoss( text, fdata ) )
  500.     {
  501.         ShowHintLabel( edit, hint );
  502.         edit->SetFocus();
  503.         return;
  504.     }
  505.     f_MAX_RX_LOSS[FrequencyBand850][Tag] = fdata;
  506. }
  507. //---------------------------------------------------------------------------
  508. void __fastcall TfrmCFGRxPathLoss::edtGSM850_MIN_RX_LOSS_Check(
  509.       TObject *Sender)
  510. {
  511.     AnsiString  text;
  512.     float  fdata;
  513.     int  band;
  514.     TEdit *edit = (TEdit*)Sender;
  515.     char  hint[] = " character is not valid ";
  516.     text = edit->Text;
  517.     if( !IsValidPathLoss( text, fdata ) )
  518.     {
  519.         ShowHintLabel( edit, hint );
  520.         edit->SetFocus();
  521.         return;
  522.     }
  523.     f_MIN_RX_LOSS[FrequencyBand850][Tag] = fdata;
  524. }
  525. //---------------------------------------------------------------------------
  526. void __fastcall TfrmCFGRxPathLoss::edtGSM900_MAX_RX_LOSS_Check(
  527.       TObject *Sender)
  528. {
  529.     AnsiString  text;
  530.     float  fdata;
  531.     int  band;
  532.     TEdit *edit = (TEdit*)Sender;
  533.     char  hint[] = " character is not valid ";
  534.     text = edit->Text;
  535.     if( !IsValidPathLoss( text, fdata ) )
  536.     {
  537.         ShowHintLabel( edit, hint );
  538.         edit->SetFocus();
  539.         return;
  540.     }
  541.     f_MAX_RX_LOSS[FrequencyBand900][Tag] = fdata;
  542. }
  543. //---------------------------------------------------------------------------
  544. void __fastcall TfrmCFGRxPathLoss::edtGSM900_MIN_RX_LOSS_Check(
  545.       TObject *Sender)
  546. {
  547.     AnsiString  text;
  548.     float  fdata;
  549.     int  band;
  550.     TEdit *edit = (TEdit*)Sender;
  551.     char  hint[] = " character is not valid ";
  552.     text = edit->Text;
  553.     if( !IsValidPathLoss( text, fdata ) )
  554.     {
  555.         ShowHintLabel( edit, hint );
  556.         edit->SetFocus();
  557.         return;
  558.     }
  559.     f_MIN_RX_LOSS[FrequencyBand900][Tag] = fdata;
  560. }
  561. //---------------------------------------------------------------------------
  562. void __fastcall TfrmCFGRxPathLoss::edtDCS1800_MAX_RX_LOSS_Check(
  563.       TObject *Sender)
  564. {
  565.     AnsiString  text;
  566.     float  fdata;
  567.     int  band;
  568.     TEdit *edit = (TEdit*)Sender;
  569.     char  hint[] = " character is not valid ";
  570.     text = edit->Text;
  571.     if( !IsValidPathLoss( text, fdata ) )
  572.     {
  573.         ShowHintLabel( edit, hint );
  574.         edit->SetFocus();
  575.         return;
  576.     }
  577.     f_MAX_RX_LOSS[FrequencyBand1800][Tag] = fdata;
  578. }
  579. //---------------------------------------------------------------------------
  580. void __fastcall TfrmCFGRxPathLoss::edtDCS1800_MIN_RX_LOSS_Check(
  581.       TObject *Sender)
  582. {
  583.     AnsiString  text;
  584.     float  fdata;
  585.     int  band;
  586.     TEdit *edit = (TEdit*)Sender;
  587.     char  hint[] = " character is not valid ";
  588.     text = edit->Text;
  589.     if( !IsValidPathLoss( text, fdata ) )
  590.     {
  591.         ShowHintLabel( edit, hint );
  592.         edit->SetFocus();
  593.         return;
  594.     }
  595.     f_MIN_RX_LOSS[FrequencyBand1800][Tag] = fdata;
  596. }
  597. //---------------------------------------------------------------------------
  598. void __fastcall TfrmCFGRxPathLoss::edtPCS1900_MAX_RX_LOSS_Check(
  599.       TObject *Sender)
  600. {
  601.     AnsiString  text;
  602.     float  fdata;
  603.     int  band;
  604.     TEdit *edit = (TEdit*)Sender;
  605.     char  hint[] = " character is not valid ";
  606.     text = edit->Text;
  607.     if( !IsValidPathLoss( text, fdata ) )
  608.     {
  609.         ShowHintLabel( edit, hint );
  610.         edit->SetFocus();
  611.         return;
  612.     }
  613.     f_MAX_RX_LOSS[FrequencyBand1900][Tag] = fdata;
  614. }
  615. //---------------------------------------------------------------------------
  616. void __fastcall TfrmCFGRxPathLoss::edtPCS1900_MIN_RX_LOSS_Check(
  617.       TObject *Sender)
  618. {
  619.     AnsiString  text;
  620.     float  fdata;
  621.     int  band;
  622.     TEdit *edit = (TEdit*)Sender;
  623.     char  hint[] = " character is not valid ";
  624.     text = edit->Text;
  625.     if( !IsValidPathLoss( text, fdata ) )
  626.     {
  627.         ShowHintLabel( edit, hint );
  628.         edit->SetFocus();
  629.         return;
  630.     }
  631.     f_MIN_RX_LOSS[FrequencyBand1900][Tag] = fdata;
  632. }
  633. //---------------------------------------------------------------------------
  634. void TfrmCFGRxPathLoss::edtMaxPathLossCheck(int idx, TObject *Sender)
  635. {
  636.     switch( idx )
  637.     {
  638.         case FrequencyBand400:
  639.            edtGSM400_MAX_RX_LOSS_Check( Sender );
  640.         break;
  641.         case FrequencyBand850:
  642.            edtGSM850_MAX_RX_LOSS_Check( Sender );
  643.         break;
  644.         case FrequencyBand900:
  645.            edtGSM900_MAX_RX_LOSS_Check( Sender );
  646.         break;
  647.         case FrequencyBand1800:
  648.            edtDCS1800_MAX_RX_LOSS_Check( Sender );
  649.         break;
  650.         case FrequencyBand1900:
  651.            edtPCS1900_MAX_RX_LOSS_Check( Sender );
  652.         break;
  653.         default:
  654.            assert( false );
  655.         break;   
  656.     }
  657. }
  658. //---------------------------------------------------------------------------
  659. void TfrmCFGRxPathLoss::edtMinPathLossCheck(int idx, TObject *Sender)
  660. {
  661.     switch( idx )
  662.     {
  663.         case FrequencyBand400:
  664.            edtGSM400_MIN_RX_LOSS_Check( Sender );
  665.         break;
  666.         case FrequencyBand850:
  667.            edtGSM850_MIN_RX_LOSS_Check( Sender );
  668.         break;
  669.         case FrequencyBand900:
  670.            edtGSM900_MIN_RX_LOSS_Check( Sender );
  671.         break;
  672.         case FrequencyBand1800:
  673.            edtDCS1800_MIN_RX_LOSS_Check( Sender );
  674.         break;
  675.         case FrequencyBand1900:
  676.            edtPCS1900_MIN_RX_LOSS_Check( Sender );
  677.         break;
  678.         default:
  679.            assert( false );
  680.         break;   
  681.     }
  682. }
  683. //---------------------------------------------------------------------------
  684. void __fastcall TfrmCFGRxPathLoss::edtN_PMCheck(TObject *Sender)
  685. {
  686.     short sdata;
  687.     AnsiString  text;
  688.     TEdit *edit = (TEdit*)Sender;
  689.     char  hint[][256] =
  690.     {
  691.         " value shall be 0~2000 ",
  692.         " value shall be 0~1000 ",
  693.         " value shall be 0~666  ",
  694.         " value shall be 0~500  "
  695.     };
  696.     char m_pm = cbM_PM->ItemIndex + 1;
  697.     text = edit->Text;
  698.     if (!IsValidCFGPMCount(text, m_pm, sdata))
  699.     {
  700.         ShowHintLabel(edit, hint[m_pm-1]);
  701.         edit->SetFocus();
  702.         return;
  703.     }
  704.     iN_PM = sdata;
  705. }
  706. //---------------------------------------------------------------------------
  707. void __fastcall TfrmCFGRxPathLoss::HintTimerTimer(TObject *Sender)
  708. {
  709.     HintTimer->Enabled = false;
  710.     lblHint->Visible = false;    
  711. }
  712. //---------------------------------------------------------------------------
  713. void __fastcall TfrmCFGRxPathLoss::cbM_PMChange(TObject *Sender)
  714. {
  715.     edtN_PMCheck( edtN_PM );   
  716. }
  717. //---------------------------------------------------------------------------