Главный модуль программы (часть 12) - SwitchToAT

Рубрика: Исходники
Среда, 21 апреля 2010 г.
Просмотров: 131
последняя версия: 3.0.9 build 961 beta
от 07 декабря 2007 г.
procedure TForm1.SwitchToAT;
var
  x: THandle;
label lbl_01;  
begin
Screen.Cursor:= crHourGlass;
Application.ProcessMessages;
try
//если открыт OBEX, то закрыть
  try
    DisconnectingAT

  except
  end;
  sleep(50);  
  if IsOBEXConnected then begin
                            try
                              Logger('OBEX режим активен. Выключаю его.');
                              frmOBEXFM.OBEX_Disconnect;
                              frmOBEXFM.VaComm1.Close;
                              IsOBEXConnected:= false;
                              Logger('OBEX режим отключен');
                            except
                              IsOBEXConnected:= true;
                              Logger('*** OBEX режим не отключился');
                            end;    
                          end;
//если открыт Flash, то перегрузить
  //if IsFlashConnected then
  //  begin
  //    try
  //      IsFlashConnected:= not P2K.FlashReset;
  //      sleep(SwitchModeTimeOut);
  //    except
  //    end;
  //  end;
//если открыт P2K, то переключить
  if IsP2KConnected then
    begin
      Logger('P2K режим активен. Выключаю его.');
      Screen.Cursor:= crHourGlass;
      Application.ProcessMessages;
      try
        p2k.Close;
        lblModel.Caption:= '';
        SetStatusConnected(false, '');
        Application.ProcessMessages;
        Logger('Жду ' + IntToStr(SwitchModeTimeOut) + 'мс...');
        sleep(SwitchModeTimeOut);
        IsP2KConnected:= false;
        Application.ProcessMessages;
        Logger('P2K режим отключен');
      except
        IsP2KConnected:= true;
        Logger('*** P2K режим не отключился');
      end;
      //Form1.Enabled:= true;
      Screen.Cursor:= crDefault;
    end;
//загрузить АТ
 IsATConnected:= ConnectingInATMode;
 if IsATConnected then
   begin
lbl_01:
     xModel:= GetModel_AT;
     xPlatform:= GetPlatform_AT;
     SetVarsByPlatform;
     lblModel.Caption:= xModel;     
     SetStatusConnected(IsATConnected, '');
     btnPhoneBookRefresh.Enabled:= true;
   end
 else begin
        // проверяем, может режим P2K ???
        try
          HDEv:= FindUSBInterface(MotTestInt, $102);
          if HDev > 0 then
            begin
              TelStatus:= true;
              P2K.SwitchToAT;
              sleep(SwitchModeTimeOut);
              TelStatus:= false;
              HDev:= 0;
              IsATConnected:= ConnectingInATMode;
            end;
        except
          HDev:= 0;
          IsATConnected:= false;
          TelStatus:= false;
        end;
        if IsATConnected then goto lbl_01;
        // проверяем режим MMC
        x:= FindUSBDiskInterface('MOTOROLA', $105);
        if x > 0 then
          begin
            sleep(SwitchModeTimeOut);
            IsATConnected:= ConnectingInATMode;
          end;
        if IsATConnected then goto lbl_01;  
      end;
finally
  Screen.Cursor:= crDefault;
end;
end;
Rambler's Top100