⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 multiportflashdownloadtool.cpp

📁 多串口下载手机软件的软件
💻 CPP
📖 第 1 页 / 共 5 页
字号:
                {
                    as_reg_prefix = "+";
            	}

                p_list_item->SubItems->Add( as_reg_prefix + "0x" + IntToHex((int)rom_info[i].region_addr, 8) );
                p_list_item->SubItems->Add( "0x" + IntToHex((int)rom_info[i].begin_addr, 8) );
                p_list_item->SubItems->Add( "0x" + IntToHex((int)rom_info[i].end_addr, 8) );
            }
	}
    }
    return true;
}

//---------------------------------------------------------------------------
bool TMainForm::OpenReadROM_File(AnsiString asLoadFileName)
{
    #if 0
    int ret;

    // loading ROM Load

    if(ret=DL_Rom_LoadByFilepath(g_DL_HANDLE, ROM_LOAD_INDEX, asLoadFileName.c_str()))
    {
        if( FTHND_HANDLE_BUSY_NOW == ret )
        {
            ShowMessage("Program is busy! Can not reload scat file right now.");
        }
        else
        {
            ShowMessage("Incorrect ROM LOAD");
        }
        return false;
    }

    lblROMFileName->Caption = asLoadFileName;

    return true;
    #endif
}

//---------------------------------------------------------------------------
bool TMainForm::OpenReadFAT_File(AnsiString asFATFileName)
{
        #if 0
	int ret;

       // if( cbType->ItemIndex == DOWNLOAD_ROM_AND_FAT_INDEX )
      //  {
	    // loading FAT file
	  //  if(ret=DL_Rom_LoadByFilepath(g_DL_HANDLE, FAT_LOAD_INDEX, asFATFileName.c_str()))
          //  {
          //      if( FTHND_HANDLE_BUSY_NOW == ret )
          //      {
          //          ShowMessage("Program is busy! Can not reload scat file right now.");
          //      }
          //      else
          //      {
          //          ShowMessage("Incorrect FAT file");
          //      }
         //      return false;
         //   }
       //	}

        lblFATFileName->Caption = asFATFileName;
	return true;
        #endif
}

//---------------------------------------------------------------------------
bool  TMainForm::LoadFATFile( void )
{
    if( isFATFileLoaded == false )
    {
        int ret;

        if(ret=DL_Rom_LoadByFilepath(g_DL_HANDLE, FAT_LOAD_INDEX, asFATFileName.c_str()))
        {
            if( FTHND_HANDLE_BUSY_NOW == ret )
            {
                     ShowMessage("Program is busy! Can not reload FAT file right now.");
            }
            else
            {
                     ShowMessage("Incorrect FAT file, please check if scatter and FAT file are correct");
            }
            return false;
        }
        isFATFileLoaded = true;
    }
}

//---------------------------------------------------------------------------
bool TMainForm::OpenFATFile( void )
{

    int iLastDel=0;

    if (asFAT_Path.Length()>0)
    {
       OpenFATDialog->InitialDir = asFAT_Path;
    }

    if ( OpenFATDialog->Execute() )    // FAT file
    {
         if ( OpenReadFAT_File( OpenFATDialog->FileName ))
         {
            asFATFileName = OpenFATDialog->FileName;
            iLastDel = asFATFileName.LastDelimiter("\\:");

            if ( iLastDel > 0)
            {
               asFAT_Path = asFATFileName.SubString(1, iLastDel-1 );

            }

            return true;
         }
         else
           return false;
    }
    else
        return false;
}

//------------------------------------------------------------------------------
void __fastcall TMainForm::btnCOMDownloadClick( int index )
{
    COM_PORT_HANDLE ComPortNo;
    bool result;

    if( (result=DownloadCommonFunction()) == false )
    {
        return;
    }

  //  Get_Baudrate();

    if(cbCOMArray[index]->Checked == true)
    {
        if( miEnableFDLog->Checked )
        {
            // access
            TDateTime datetime;
            TDateTime date = datetime.CurrentDate();
            TDateTime time = datetime.CurrentTime();
            sTime     stime;
            time.DecodeTime( &stime.hour, &stime.min, &stime.sec, &stime.msec);
            MainForm->SetDnDate( index, date );
            MainForm->SetDnStartTime( index, time );
            MainForm->SetDnStartsTime( index, stime );
        }


        stopflag[index] = 0;
        Disable_UIComponent();
       // cbCOMArray[index]->Enabled = false;
       // cbAutoPollingArray[index]->Enabled = false;
       // btnCOMDownloadArray[index]->Enabled = false;
        Disable_SpecificMsUI(index);
        isStopTrigger[index] = false;
        // status and timer handling
        DownloadStatus[index] = DOWNLOAD_STATUS_RUNNING;
        pbCOMArray[index]->Progress = 0;
        DownLoadTimeSec[index] = 0;
        TimerCOMArray[index]->Enabled = true;


        ComPortNo.number = (index + m_TheFirstComNo);
        A_Thread[index] = new TBOOT1(FALSE, hPostMsgDestHandle, ComPortNo, Baseband_chip_type,
                                     External_clock_type, bCheckECOVersion, UART_baud_rate, bFormatNeeded);
    }


    new WaitForFinish(FALSE);
}

//---------------------------------------------------------------------------
void __fastcall TMainForm::btnSeperateDownloadClick(TObject *Sender)
{
    TButton *bt = (TButton*)Sender;
    btnCOMDownloadClick( bt->Tag );
}

//==============================================================================
bool TMainForm::DownloadCommonFunction( void )
{
    int ret;

    // flag
    isShowNoFormatInfo = false;
    isShowFileNotLoaded = false;

    #ifndef SERVICE_CENTER
    if( cbType->ItemIndex == FORMAT_INDEX )
    {
        i_FlashToolFunction = FLASHTOOL_FORMAT;
    }
    else
    #endif
    {
        i_FlashToolFunction = FLASHTOOL_DOWNLOAD;
    }

    #ifndef SERVICE_CENTER
    if( as_Type.AnsiCompareIC("Download ROM and Format") == 0 )
    {
         bFormatNeeded = true;
    }
    else
    #endif
    {
        bFormatNeeded = false;
    }
    return true;
}




//---------------------------------------------------------------------------
UART_BAUDRATE TMainForm::Get_Baudrate( AnsiString as_baudrate )
{
     UART_BAUDRATE baud_rate;

     as_Baudrate = as_Baudrate.LowerCase();

     if ( as_Baudrate.AnsiCompareIC("115200") == 0 )
     {
          baud_rate =  UART_BAUD_115200;
     }
     else if ( as_Baudrate.AnsiCompareIC("230400") == 0 )
     {
          baud_rate =  UART_BAUD_230400;
     }
     else if( as_Baudrate.AnsiCompareIC("460800") == 0 )
     {
          baud_rate =  UART_BAUD_460800;
     }
     else if( as_Baudrate.AnsiCompareIC("921600") == 0 )
     {
          baud_rate =  UART_BAUD_921600;
     }
     else // default set to 460800
     {
           ShowMessage("Baud Rate setting is wrong. Set Default 460800");
           baud_rate =  UART_BAUD_460800;
     }
     return baud_rate;
}

//============================================================================
void TMainForm::Disable_UIComponent( void )
{
     Disable_FileMenu();
     Disable_FactoryDatabaseMenu();
     Disable_OptionMenu();
     Disable_FormatFatRangeRadioButton();
     Disable_BaudrateComboBox();
     Disable_TypeComboBox();
}

//----------------------------------------------------------------------------
void TMainForm::Enable_UIComponent( void )
{
    Enable_FileMenu();
    Enable_FactoryDatabaseMenu();
    Enable_OptionMenu();
    Enable_lvListView();
    Enable_FormatFatRangeRadioButton();
    Enable_BaudrateComboBox();
    Enable_TypeComboBox();
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void TMainForm::Disable_FileMenu( void )
{
    miFile->Enabled = false;
}

//----------------------------------------------------------------------------
void TMainForm::Enable_FileMenu( void )
{
    miFile->Enabled = true;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void TMainForm::Disable_FactoryDatabaseMenu( void )
{
    miFactoryDatabase->Enabled = false;
}

//----------------------------------------------------------------------------
void TMainForm::Enable_FactoryDatabaseMenu( void )
{
    miFactoryDatabase->Enabled = true;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void TMainForm::Disable_OptionMenu( void )
{
    miOption->Enabled = false;
}

//----------------------------------------------------------------------------
void TMainForm::Enable_OptionMenu( void )
{
    miOption->Enabled = true;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void TMainForm::Disable_lvListView( void )
{
    lv->Enabled = false;
}

//----------------------------------------------------------------------------
void TMainForm::Enable_lvListView( void )
{
    lv->Enabled = true;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void TMainForm::Disable_FormatFatRangeRadioButton( void )
{
     rbAuto->Enabled = false;
     rbManual->Enabled = false;
}

//----------------------------------------------------------------------------
void TMainForm::Enable_FormatFatRangeRadioButton( void )
{
     rbAuto->Enabled = true;
     rbManual->Enabled = true;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void TMainForm::Disable_BaudrateComboBox( void )
{
    cbBaudrate->Enabled = false;
}

//----------------------------------------------------------------------------
void TMainForm::Enable_BaudrateComboBox( void )
{
    cbBaudrate->Enabled = true;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void TMainForm::Disable_TypeComboBox( void )
{
     cbType->Enabled = false;
}

//----------------------------------------------------------------------------
void TMainForm::Enable_TypeComboBox( void )
{
     cbType->Enabled = true;
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void TMainForm::Disable_SeperateDownloadButton( void )
{

     for (int i=0; i<MAX_SUPPORT_PORT_NUM; i++)
     {
         btnCOMStartArray[i]->Enabled = false;
     }
}

//----------------------------------------------------------------------------
void TMainForm::Enable_SeperateDownloadButton( void )
{
     for (int i=0; i<MAX_SUPPORT_PORT_NUM; i++)
     {
         btnCOMStartArray[i]->Enabled = true;
     }
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void TMainForm::Disable_AllDownloadButton( void )
{
     Disable_SeperateDownloadButton();
}

//----------------------------------------------------------------------------
void TMainForm::Enable_AllDownloadButton( void )
{
     Enable_SeperateDownloadButton();
}

//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void TMainForm::Disable_SpecificMsUI( int index )
{
    cbCOMArray[index]->Enabled = false;
    cbAutoPollingArray[index]->Enabled = false;
    btnCOMStartArray[index]->Enabled = false;
}

//----------------------------------------------------------------------------
void TMainForm::Enable_SpecificMsUI( int index )
{
    cbCOMArray[index]->Enabled = true;
    cbAutoPollingArray[index]->Enabled = true;
    btnCOMStartArray[index]->Enabled = true;
}

//============================================================================
void __fastcall TMainForm::RedrawLVCheckBox( void )
{
    unsigned short rom_count;
    lv->Items->Clear();

    if(!DL_GetCount(g_DL_HANDLE, &rom_count))
    {

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -