View Issue Details

IDProjectCategoryView StatusLast Update
0003069SAS.ПланетаХотелка / Feature requestpublic27-03-2019 08:32
ReporterDJ VK Assigned To 
PrioritynormalSeverityfeatureReproducibilityhave not tried
Status confirmedResolutionreopened 
PlatformWindowsOS7OS VersionUltimate
Product Version160606 
Target Version43xxxx 
Summary0003069: Добавить автоматическую паузу в скачивание
DescriptionГуглобан достал. И ведь есть один простой, но рабочий метод.

1.Добавить в конечный автомат потока скачивания еще одно состояние - автоматическая пауза. Включается автоматом по достижению заданного условия(для визуализвции состояния прогресс бар можно перекрасить в другой цвет или что-то еще нарисовать), а по истечению заданного времени скачивание продолжается.
2. В окно настроек скачивания добавить строчку:
|v|(TCheckBox) пауза 60(TEdit) сек. каждые 5000(TEdit) тайлов(TComboBox : тайлов, секунд)
3. При скачивании в несколько потоков опцию сделать недоступной.
Tagsантибан, скачка
Attached Files
9475.patch (23,804 bytes)   
# HG changeset patch
# User DJ VK
# Date 1467529374 -10800
#      Sun Jul 03 10:02:54 2016 +0300
# Node ID 2e76d2ea9d1bc8ffa1820a3c49463c59ff1d9dc5
# Parent  ae9410e4b71287b86695200718bcf2e0b9bc861b
��������� ������������ ����� (������� 0003069)

diff -r ae9410e4b712 -r 2e76d2ea9d1b Src/RegionProcess/Download/fr_TilesDownload.dfm
--- a/Src/RegionProcess/Download/fr_TilesDownload.dfm	Fri Jul 01 18:56:39 2016 +0300
+++ b/Src/RegionProcess/Download/fr_TilesDownload.dfm	Sun Jul 03 10:02:54 2016 +0300
@@ -251,6 +251,79 @@
           Value = 2
         end
       end
+      object pnlAutoPause: TFlowPanel
+        Left = 5
+        Top = 171
+        Width = 421
+        Height = 30
+        Align = alTop
+        AutoSize = True
+        BevelOuter = bvNone
+        Padding.Top = 2
+        TabOrder = 6
+        object chkAutoPause: TCheckBox
+          AlignWithMargins = True
+          Left = 0
+          Top = 5
+          Width = 17
+          Height = 22
+          Margins.Left = 0
+          Margins.Right = 0
+          Margins.Bottom = 0
+          TabOrder = 0
+        end
+        object lblAutoPauseName: TLabel
+          AlignWithMargins = True
+          Left = 17
+          Top = 9
+          Width = 52
+          Height = 13
+          Margins.Left = 0
+          Margins.Top = 7
+          Caption = 'Autopause'
+        end
+        object seAutoPauseDur: TSpinEdit
+          AlignWithMargins = True
+          Left = 75
+          Top = 5
+          Width = 61
+          Height = 22
+          MaxValue = 100000
+          MinValue = 1
+          TabOrder = 1
+          Value = 200
+        end
+        object lblAutoPauseEvery: TLabel
+          AlignWithMargins = True
+          Left = 139
+          Top = 9
+          Width = 39
+          Height = 13
+          Margins.Left = 0
+          Margins.Top = 7
+          Caption = 's  every'
+        end
+        object seAutoPauseCondValue: TSpinEdit
+          AlignWithMargins = True
+          Left = 184
+          Top = 5
+          Width = 66
+          Height = 22
+          MaxValue = 1000000
+          MinValue = 10
+          TabOrder = 2
+          Value = 5000
+        end
+        object cbAutoPauseCondUnit: TComboBox
+          AlignWithMargins = True
+          Left = 256
+          Top = 5
+          Width = 68
+          Height = 21
+          Style = csDropDownList
+          TabOrder = 3
+        end
+      end
     end
   end
   object pnlMapSelect: TPanel
diff -r ae9410e4b712 -r 2e76d2ea9d1b Src/RegionProcess/Download/fr_TilesDownload.pas
--- a/Src/RegionProcess/Download/fr_TilesDownload.pas	Fri Jul 01 18:56:39 2016 +0300
+++ b/Src/RegionProcess/Download/fr_TilesDownload.pas	Sun Jul 03 10:02:54 2016 +0300
@@ -33,6 +33,7 @@
   StdCtrls,
   Windows,
   Spin,
+  t_CommonTypes,
   i_MapType,
   i_Listener,
   i_Notifier,
@@ -70,6 +71,18 @@
 
     function GetSplitCount: Integer;
     property SplitCount: Integer read GetSplitCount;
+
+    function GetAutoPausedDownload: Boolean;
+    property AutoPausedDownload: Boolean read GetAutoPausedDownload;
+
+    function GetAutoPauseDuration: Integer;
+    property AutoPauseDuration: Integer read GetAutoPauseDuration;
+
+    function GetAutoPauseConditionValue: Integer;
+    property AutoPauseConditionValue: Integer read GetAutoPauseConditionValue;
+
+    function GetAutoPauseConditionUnit: TConditionCountType;
+    property AutoPauseConditionUnit: TConditionCountType read GetAutoPauseConditionUnit;
   end;
 
 type
@@ -107,6 +120,13 @@
     sePartsCount: TSpinEdit;
     flwpnlSplitRegionParams: TFlowPanel;
     lblSplitRegionHint: TLabel;
+    pnlAutoPause: TFlowPanel;
+    chkAutoPause: TCheckBox;
+    lblAutoPauseName: TLabel;
+    seAutoPauseDur: TSpinEdit;
+    lblAutoPauseEvery: TLabel;
+    seAutoPauseCondValue: TSpinEdit;
+    cbAutoPauseCondUnit: TComboBox;
     procedure chkReplaceClick(Sender: TObject);
     procedure chkReplaceOlderClick(Sender: TObject);
     procedure cbbZoomChange(Sender: TObject);
@@ -151,6 +171,10 @@
     function GetReplaceDate: TDateTime;
     function GetAllowDownload(const AMapType: IMapType): boolean; // ����� �� ��������
     function GetSplitCount: Integer;
+    function GetAutoPausedDownload: Boolean;
+    function GetAutoPauseDuration: Integer;
+    function GetAutoPauseConditionValue: Integer;
+    function GetAutoPauseConditionUnit: TConditionCountType;
   public
     constructor Create(
       const ALanguageManager: ILanguageManager;
@@ -278,6 +302,11 @@
 procedure TfrTilesDownload.chkSplitRegionClick(Sender: TObject);
 begin
   sePartsCount.Enabled := chkSplitRegion.Checked;
+  chkAutoPause.Enabled := chkSplitRegion.Checked;
+  seAutoPauseDur.Enabled := chkSplitRegion.Checked;
+  seAutoPauseCondValue.Enabled := chkSplitRegion.Checked;
+  cbAutoPauseCondUnit.Enabled := chkSplitRegion.Checked;
+  if(chkSplitRegion.Checked) then chkAutoPause.Checked := False;
 end;
 
 constructor TfrTilesDownload.Create(
@@ -315,6 +344,12 @@
   FTimer.Interval := 300;
   FTimer.OnTimer := Self.OnTimer;
   FTimer.Enabled := True;
+
+  cbAutoPauseCondUnit.Items.Clear;
+  cbAutoPauseCondUnit.Items.Add(SAS_STR_UnitQueries);
+  cbAutoPauseCondUnit.Items.Add(SAS_STR_UnitTiles);
+  cbAutoPauseCondUnit.Items.Add(SAS_STR_UnitSeconds);
+  cbAutoPauseCondUnit.ItemIndex := 0;
 end;
 
 procedure TfrTilesDownload.OnTimer(Sender: TObject);
@@ -437,6 +472,43 @@
   end;
 end;
 
+function TfrTilesDownload.GetAutoPausedDownload: Boolean;
+begin
+  Result := chkAutoPause.Checked and not chkSplitRegion.Checked;
+end;
+
+function TfrTilesDownload.GetAutoPauseDuration: Integer;
+begin
+  if chkAutoPause.Checked then begin
+    Result := seAutoPauseDur.Value;
+  end else begin
+    Result := 0;
+  end;
+end;
+
+function TfrTilesDownload.GetAutoPauseConditionValue: Integer;
+begin
+  if chkAutoPause.Checked then begin
+    Result := seAutoPauseCondValue.Value;
+  end else begin
+    Result := 0;
+  end;
+end;
+
+function TfrTilesDownload.GetAutoPauseConditionUnit: TConditionCountType;
+begin
+  if chkAutoPause.Checked then begin
+    case cbAutoPauseCondUnit.ItemIndex of
+      0: Result := ctQueriesCount;
+      1: Result := ctTilesCount;
+      2: Result := ctSecondsCount;
+      else Result := ctQueriesCount;
+    end;
+  end else begin
+    Result := ctQueriesCount;
+  end;
+end;
+
 function TfrTilesDownload.GetZoomArray: TByteDynArray;
 begin
   Result := FfrZoomsSelect.GetZoomList;
diff -r ae9410e4b712 -r 2e76d2ea9d1b Src/RegionProcess/Download/i_DownloadSession.pas
--- a/Src/RegionProcess/Download/i_DownloadSession.pas	Fri Jul 01 18:56:39 2016 +0300
+++ b/Src/RegionProcess/Download/i_DownloadSession.pas	Sun Jul 03 10:02:54 2016 +0300
@@ -24,6 +24,7 @@
 
 uses
   Types,
+  t_CommonTypes,
   i_GeometryLonLat,
   i_GeometryLonLatFactory,
   i_MapType,
@@ -74,6 +75,18 @@
     function GetCheckTileDate: TDateTime;
     property CheckTileDate: TDateTime read GetCheckTileDate;
 
+    function GetAutoPausedDownload: Boolean;
+    property AutoPausedDownload: Boolean read GetAutoPausedDownload;
+
+    function GetAutoPauseTime: Integer;
+    property AutoPauseTime: Integer read GetAutoPauseTime;
+
+    function GetAutoPauseConditionValue: Integer;
+    property AutoPauseConditionValue: Integer read GetAutoPauseConditionValue;
+
+    function GetAutoPauseConditionUnit: TConditionCountType;
+    property AutoPauseConditionUnit: TConditionCountType read GetAutoPauseConditionUnit;
+
     function GetProcessed: Int64;
     procedure SetProcessed(const Value: Int64);
     property Processed: Int64 read GetProcessed write SetProcessed;
diff -r ae9410e4b712 -r 2e76d2ea9d1b Src/RegionProcess/Download/u_DownloadSession.pas
--- a/Src/RegionProcess/Download/u_DownloadSession.pas	Fri Jul 01 18:56:39 2016 +0300
+++ b/Src/RegionProcess/Download/u_DownloadSession.pas	Sun Jul 03 10:02:54 2016 +0300
@@ -24,6 +24,7 @@
 
 uses
   Types,
+  t_CommonTypes,
   i_GeometryLonLat,
   i_GeometryLonLatFactory,
   i_MapType,
@@ -59,6 +60,10 @@
     FLastProcessedPoint: TPoint;
     FLastProcessedCount: Int64;
     FLastSuccessfulPoint: TPoint;
+    FAutoPausedDownload: Boolean;
+    FAutoPauseTime : Integer;
+    FAutoPauseConditionValue: Integer;
+    FAutoPauseConditionUnit: TConditionCountType;
     FAutoCloseAtFinish: Boolean;
     FWorkersCount: Integer;
     FWorkerIndex: Integer;
@@ -87,6 +92,10 @@
     function GetAutoCloseAtFinish: Boolean;
     function GetWorkersCount: Integer;
     function GetWorkerIndex: Integer;
+    function GetAutoPausedDownload: Boolean;
+    function GetAutoPauseTime: Integer;
+    function GetAutoPauseConditionValue: Integer;
+    function GetAutoPauseConditionUnit: TConditionCountType;
 
     procedure SetZoom(const Value: Byte);
     procedure SetLastSuccessfulPoint(const Value: TPoint);
@@ -121,6 +130,10 @@
       const ACheckExistTileSize: Boolean;
       const ACheckExistTileDate: Boolean;
       const ACheckTileDate: TDateTime;
+      const AAutoPausedDownload: Boolean;
+      const AAutoPauseDuration: Integer;
+      const AAutoPauseConditionValue: Integer;
+      const AAutoPauseConditionUnit: TConditionCountType;
       const AWorkersCount: Integer;
       const AWorkerIndex: Integer
     ); overload;
@@ -159,6 +172,10 @@
   const AReplaceTneOlderDate: TDateTime;
   const AReplaceExistTiles, ACheckExistTileSize, ACheckExistTileDate: Boolean;
   const ACheckTileDate: TDateTime;
+  const AAutoPausedDownload: Boolean;
+  const AAutoPauseDuration: Integer;
+  const AAutoPauseConditionValue: Integer;
+  const AAutoPauseConditionUnit: TConditionCountType;
   const AWorkersCount: Integer;
   const AWorkerIndex: Integer
 );
@@ -177,6 +194,10 @@
   FCheckTileDate := ACheckTileDate;
   FSecondLoadTNE := ASecondLoadTNE;
   FReplaceTneOlderDate := AReplaceTneOlderDate;
+  FAutoPausedDownload := AAutoPausedDownload;
+  FAutoPauseTime := 1000 * AAutoPauseDuration;
+  FAutoPauseConditionValue := AAutoPauseConditionValue;
+  FAutoPauseConditionUnit := AAutoPauseConditionUnit;
   FPolygon := APolygon;
   FWorkersCount := AWorkersCount;
   FWorkerIndex := AWorkerIndex;
@@ -207,6 +228,10 @@
   FAutoCloseAtFinish := False;
   FWorkerIndex := 0;
   FWorkersCount := 1;
+  FAutoPausedDownload := False;
+  FAutoPauseTime := 1;
+  FAutoPauseConditionValue := 1;
+  FAutoPauseConditionUnit := ctQueriesCount;
 end;
 
 procedure TDownloadSession.Save(
@@ -260,6 +285,11 @@
   ASessionSection.WriteInteger('WorkersCount', FWorkersCount);
   ASessionSection.WriteInteger('WorkerIndex', FWorkerIndex);
 
+  ASessionSection.WriteBool('AutoPausedDownload', FAutoPausedDownload);
+  ASessionSection.WriteInteger('AutoPauseTime', FAutoPauseTime);
+  ASessionSection.WriteInteger('AutoPauseConditionValue', FAutoPauseConditionValue);
+  ASessionSection.WriteInteger('AutoPauseConditionUnit', Integer(FAutoPauseConditionUnit));
+
   WritePolygon(ASessionSection, FPolygon);
 end;
 
@@ -330,6 +360,10 @@
   VAutoCloseAtFinish: Boolean;
   VWorkersCount: Integer;
   VWorkerIndex: Integer;
+  VAutoPausedDownload: Boolean;
+  VAutoPauseTime : Integer;
+  VAutoPauseConditionValue: Integer;
+  VAutoPauseConditionUnit: TConditionCountType;
 begin
   Assert(AFullMapsSet <> nil);
   Assert(ADownloadConfig <> nil);
@@ -393,6 +427,11 @@
   VWorkersCount := ASessionSection.ReadInteger('WorkersCount', 1);
   VWorkerIndex := ASessionSection.ReadInteger('WorkerIndex', 0);
 
+  VAutoPausedDownload := ASessionSection.ReadBool('AutoPausedDownload', False);
+  VAutoPauseTime := ASessionSection.ReadInteger('AutoPauseTime', 1);
+  VAutoPauseConditionValue := ASessionSection.ReadInteger('AutoPauseConditionValue', 1);
+  VAutoPauseConditionUnit := TConditionCountType(ASessionSection.ReadInteger('AutoPauseConditionUnit', 1));
+
   VLastSuccessfulPoint.X := ASessionSection.ReadInteger('LastSuccessfulStartX', -1);
   VLastSuccessfulPoint.Y := ASessionSection.ReadInteger('LastSuccessfulStartY', -1);
 
@@ -445,6 +484,11 @@
   FWorkersCount := VWorkersCount;
   FWorkerIndex := VWorkerIndex;
 
+  FAutoPausedDownload := VAutoPausedDownload;
+  FAutoPauseTime := VAutoPauseTime;
+  FAutoPauseConditionValue := VAutoPauseConditionValue;
+  FAutoPauseConditionUnit := VAutoPauseConditionUnit;
+
   FLastProcessedPoint := VLastProcessedPoint;
   FLastSuccessfulPoint := VLastSuccessfulPoint;
 
@@ -616,4 +660,24 @@
   end;
 end;
 
+function TDownloadSession.GetAutoPausedDownload: Boolean;
+begin
+  Result := FAutoPausedDownload;
+end;
+
+function TDownloadSession.GetAutoPauseTime: Integer;
+begin
+  Result := FAutoPauseTime;
+end;
+
+function TDownloadSession.GetAutoPauseConditionValue: Integer;
+begin
+  Result := FAutoPauseConditionValue;
+end;
+
+function TDownloadSession.GetAutoPauseConditionUnit: TConditionCountType;
+begin
+  Result := FAutoPauseConditionUnit;
+end;
+
 end.
diff -r ae9410e4b712 -r 2e76d2ea9d1b Src/RegionProcess/Download/u_ProviderTilesDownload.pas
--- a/Src/RegionProcess/Download/u_ProviderTilesDownload.pas	Fri Jul 01 18:56:39 2016 +0300
+++ b/Src/RegionProcess/Download/u_ProviderTilesDownload.pas	Sun Jul 03 10:02:54 2016 +0300
@@ -351,6 +351,10 @@
         (ParamsFrame as IRegionProcessParamsFrameTilesDownload).IsReplaceIfDifSize,
         (ParamsFrame as IRegionProcessParamsFrameTilesDownload).IsReplaceIfOlder,
         (ParamsFrame as IRegionProcessParamsFrameTilesDownload).ReplaceDate,
+        (ParamsFrame as IRegionProcessParamsFrameTilesDownload).AutoPausedDownload,
+        (ParamsFrame as IRegionProcessParamsFrameTilesDownload).AutoPauseDuration,
+        (ParamsFrame as IRegionProcessParamsFrameTilesDownload).AutoPauseConditionValue,
+        (ParamsFrame as IRegionProcessParamsFrameTilesDownload).AutoPauseConditionUnit,
         VWorkersCount,
         I // worker index
      );
diff -r ae9410e4b712 -r 2e76d2ea9d1b Src/RegionProcess/Download/u_ThreadDownloadTiles.pas
--- a/Src/RegionProcess/Download/u_ThreadDownloadTiles.pas	Fri Jul 01 18:56:39 2016 +0300
+++ b/Src/RegionProcess/Download/u_ThreadDownloadTiles.pas	Sun Jul 03 10:02:54 2016 +0300
@@ -84,6 +84,7 @@
     FRES_Noconnectionstointernet: string;
     FRES_FileExistsShort: string;
     FRES_ProcessFilesComplete: string;
+    FRES_AutoPause: string;
 
     FOperationID: Integer;
     FCancelNotifier: INotifierOperation;
@@ -298,6 +299,13 @@
         end;
         FProgressInfo.SetStarted;
       end;
+      if FProgressInfo.IsAutoPauseCondition then begin
+        FProgressInfo.SetAutoPaused;
+        FProgressInfo.Log.WriteText(Format(FRES_AutoPause, [FProgressInfo.AutoPauseTime div 1000]), 10);
+        SleepCancelable(FProgressInfo.AutoPauseTime);
+        FProgressInfo.ResetAutoPauseCounts;
+        FProgressInfo.SetAutoStarted;
+      end;
       if FCancelNotifier.IsOperationCanceled(FOperationID) then begin
         Exit;
       end;
@@ -367,6 +375,7 @@
             if FCancelNotifier.IsOperationCanceled(FOperationID) then begin
               Exit;
             end;
+            FProgressInfo.IncQueriesCount();
             VGotoNextTile := ProcessResultAndCheckGotoNextTile(FTileRequestResult);
             if FCancelNotifier.IsOperationCanceled(FOperationID) then begin
               Exit;
@@ -487,6 +496,7 @@
   FRES_Noconnectionstointernet := SAS_ERR_Noconnectionstointernet;
   FRES_FileExistsShort := SAS_ERR_FileExistsShort;
   FRES_ProcessFilesComplete := SAS_MSG_ProcessFilesComplete;
+  FRES_AutoPause := SAS_MSG_DownloadAutoPaused;
 end;
 
 function TThreadDownloadTiles.ProcessResultAndCheckGotoNextTile(
@@ -511,6 +521,7 @@
         // tile downloaded successfully
         FProgressInfo.Log.WriteText('(Ok!)', 0);
         FProgressInfo.AddDownloadedTile(AResult.Request.Tile, VResultOk.Data.Size);
+        FProgressInfo.IncTilesCount();
         Result := True;
       end;
       FDownloadInfo.Add(1, VResultOk.Data.Size);
@@ -518,6 +529,7 @@
       // same file size - assuming file the same
       FProgressInfo.Log.WriteText(FRES_FileBeCreateLen, 0);
       FProgressInfo.AddNotNecessaryTile(AResult.Request.Tile);
+      FProgressInfo.IncTilesCount();
       Result := True;
     end else if Supports(VResultWithDownload.DownloadResult, IDownloadResultProxyError) then begin
       FProgressInfo.Log.WriteText(FRES_Authorization + #13#10 + Format(FRES_WaitTime, [FProxyAuthErrorSleepTime div 1000]), 10);
diff -r ae9410e4b712 -r 2e76d2ea9d1b Src/RegionProcess/i_RegionProcessProgressInfoDownload.pas
--- a/Src/RegionProcess/i_RegionProcessProgressInfoDownload.pas	Fri Jul 01 18:56:39 2016 +0300
+++ b/Src/RegionProcess/i_RegionProcessProgressInfoDownload.pas	Sun Jul 03 10:02:54 2016 +0300
@@ -80,9 +80,20 @@
     procedure SetNeedPause(AValue: Boolean);
     property NeedPause: Boolean read GetNeedPause write SetNeedPause;
 
+    function GetAutoPauseTime: Integer;
+    property AutoPauseTime: Integer read GetAutoPauseTime;
+
     procedure Finish;
     procedure SetPaused;
     procedure SetStarted;
+    procedure SetAutoPaused;
+    procedure SetAutoStarted;
+
+    procedure IncTilesCount;
+    procedure IncQueriesCount;
+    function IsAutoPauseCondition: Boolean;
+    procedure ResetAutoPauseCounts;
+
     procedure AddManyProcessedTile(
       const ALastTile: TPoint;
       const ACnt: Cardinal
diff -r ae9410e4b712 -r 2e76d2ea9d1b Src/RegionProcess/u_RegionProcessProgressInfoDownload.pas
--- a/Src/RegionProcess/u_RegionProcessProgressInfoDownload.pas	Fri Jul 01 18:56:39 2016 +0300
+++ b/Src/RegionProcess/u_RegionProcessProgressInfoDownload.pas	Sun Jul 03 10:02:54 2016 +0300
@@ -25,6 +25,7 @@
 uses
   Types,
   SysUtils,
+  t_CommonTypes,
   i_LogSimple,
   i_LogSimpleProvider,
   i_DownloadSession,
@@ -49,9 +50,13 @@
     FFinished: Boolean;
     FNeedPause: Boolean;
     FPaused: Boolean;
+    FAutoPaused: Boolean;
     FStartTime: TDateTime;
     FTotalInRegion: Int64;
     FLastSuccessfulSize: Integer;
+    FTilesCount: Integer;
+    FQueriesCount: Integer;
+    FTimeBeforeAutoPause: TDateTime;
   private
     function GetProcessedRatio: Double;
     function GetFinished: Boolean;
@@ -73,15 +78,25 @@
     );
 
     function GetIsPaused: Boolean;
+    function GetIsAutoPaused: Boolean;
     procedure Pause;
     procedure Resume;
     procedure SaveState(const ASLSSection: IConfigDataWriteProvider);
   private
     function GetNeedPause: Boolean;
     procedure SetNeedPause(AValue: Boolean);
+
+    function GetAutoPauseTime: Integer;
     procedure Finish;
     procedure SetPaused;
     procedure SetStarted;
+    procedure SetAutoPaused;
+    procedure SetAutoStarted;
+    procedure IncTilesCount;
+    procedure IncQueriesCount;
+    function IsAutoPauseCondition: Boolean;
+    procedure ResetAutoPauseCounts;
+
     procedure AddManyProcessedTile(
       const ALastTile: TPoint;
       const ACnt: Cardinal
@@ -128,9 +143,13 @@
   FSession := ASession;
   FPaused := APaused;
   FNeedPause := APaused;
+  FAutoPaused := False;
   FFinished := False;
   FStartTime := Now;
   FLastSuccessfulSize := -1;
+  FTilesCount := 0;
+  FQueriesCount := 0;
+  FTimeBeforeAutoPause := 1.0 * FSession.AutoPauseConditionValue / 86400.0;
 end;
 
 procedure TRegionProcessProgressInfoDownload.AddDownloadedTile(
@@ -253,6 +272,16 @@
   end;
 end;
 
+function TRegionProcessProgressInfoDownload.GetIsAutoPaused: Boolean;
+begin
+  FCS.BeginRead;
+  try
+    Result := FAutoPaused;
+  finally
+    FCS.EndRead;
+  end;
+end;
+
 function TRegionProcessProgressInfoDownload.GetLog: ILogSimple;
 begin
   Result := FLog;
@@ -438,6 +467,76 @@
   end;
 end;
 
+procedure TRegionProcessProgressInfoDownload.SetAutoPaused;
+begin
+  FCS.BeginWrite;
+  try
+    FAutoPaused := True;
+    FSession.ElapsedTime := FSession.ElapsedTime + (Now - FStartTime);
+  finally
+    FCS.EndWrite;
+  end;
+end;
+
+procedure TRegionProcessProgressInfoDownload.SetAutoStarted;
+begin
+  FCS.BeginWrite;
+  try
+    FAutoPaused := False;
+    FStartTime := Now;
+  finally
+    FCS.EndWrite;
+  end;
+end;
+
+procedure TRegionProcessProgressInfoDownload.IncTilesCount;
+begin
+  FCS.BeginWrite;
+  try
+    Inc(FTilesCount);
+  finally
+    FCS.EndWrite;
+  end;
+end;
+
+procedure TRegionProcessProgressInfoDownload.IncQueriesCount;
+begin
+  FCS.BeginWrite;
+  try
+    Inc(FQueriesCount);
+  finally
+    FCS.EndWrite;
+  end;
+end;
+
+function TRegionProcessProgressInfoDownload.IsAutoPauseCondition: Boolean;
+begin
+  FCS.BeginRead;
+  try
+    if FSession.AutoPausedDownload then
+    case FSession.AutoPauseConditionUnit of
+      ctQueriesCount: Result := (FQueriesCount >= FSession.AutoPauseConditionValue);
+      ctTilesCount: Result := (FTilesCount >= FSession.AutoPauseConditionValue);
+      ctSecondsCount: Result := ((Now - FStartTime) > FTimeBeforeAutoPause);
+      else Result := False;
+    end
+    else Result := False;
+  finally
+    FCS.EndRead;
+  end;
+end;
+
+procedure TRegionProcessProgressInfoDownload.ResetAutoPauseCounts;
+begin
+  FCS.BeginWrite;
+  try
+    FQueriesCount := 0;
+    FTilesCount := 0;
+  finally
+    FCS.EndWrite;
+  end;
+end;
+
 procedure TRegionProcessProgressInfoDownload.SetAutoCloseAtFinish(
   const Value: Boolean
 );
@@ -460,4 +559,14 @@
   end;
 end;
 
+function TRegionProcessProgressInfoDownload.GetAutoPauseTime: Integer;
+begin
+  FCS.BeginRead;
+  try
+    Result := FSession.AutoPauseTime;
+  finally
+    FCS.EndRead;
+  end;
+end;
+
 end.
diff -r ae9410e4b712 -r 2e76d2ea9d1b Src/t_CommonTypes.pas
--- a/Src/t_CommonTypes.pas	Fri Jul 01 18:56:39 2016 +0300
+++ b/Src/t_CommonTypes.pas	Sun Jul 03 10:02:54 2016 +0300
@@ -36,6 +36,8 @@
   TAreaStrFormat = (asfAuto = 0, asfSqM = 1, asfSqKm = 2, asfHa = 3);
 
   TStringTypeSupport = (stsAscii = 0, stsAnsi = 1, stsUnicode = 2);
+
+  TConditionCountType = (ctQueriesCount, ctTilesCount, ctSecondsCount);
   
 implementation
 
diff -r ae9410e4b712 -r 2e76d2ea9d1b Src/u_ResStrings.pas
--- a/Src/u_ResStrings.pas	Fri Jul 01 18:56:39 2016 +0300
+++ b/Src/u_ResStrings.pas	Sun Jul 03 10:02:54 2016 +0300
@@ -53,6 +53,7 @@
   SAS_MSG_FileBeCreateLen = 'The tile size is equal to the existing one, skipping.';
   SAS_MSG_ProcessFilesComplete = 'The task is completed!';
   SAS_MSG_LoadComplete = 'Download completed';
+  SAS_MSG_DownloadAutoPaused = 'Auto pause %0:d seconds...';
   SAS_MSG_NoFlyOnTrackSource = 'No source for Fly-on-Track mode';
   SAS_MSG_UnknownGPSOrigin = 'GPS origin misconfiguration: unknown mode %d';
   SAS_MSG_NoGPSdetected = 'No GPS receiver found';
@@ -77,7 +78,7 @@
   SAS_ERR_LonLat2 = 'Latitude of upper left corner must be less than '#13#10 +
     'latitude of lower right corner';
   SAS_ERR_Authorization = 'Proxy authorization error';
-  SAS_ERR_WaitTime = 'Wait %0:d secons...';
+  SAS_ERR_WaitTime = 'Wait %0:d seconds...';
   SAS_ERR_Ban = 'Most likely you''ve been banned by the server!';
   SAS_ERR_TileNotExists = 'Tile is not found!';
   SAS_ERR_Noconnectionstointernet = 'Error connecting to server';
@@ -215,6 +216,9 @@
   SAS_STR_SensorReset = 'Reset';
   SAS_STR_Zoom = 'Zoom';
   SAS_STR_Tiles = 'Tiles';
+  SAS_STR_UnitQueries = 'Queries';
+  SAS_STR_UnitTiles = 'Tiles';
+  SAS_STR_UnitSeconds = 'Seconds';
 
   SAS_STR_SensorGPSRecorderLastSpeedCaption = 'Current speed, km/h:';
   SAS_STR_SensorGPSRecorderLastSpeedDescription = 'Shows current speed';
9475.patch (23,804 bytes)   

Activities

DJ VK

02-07-2016 18:53

manager   ~0017480

Сегодня реализовал хотелку. Но еще не отладил. Как заработает - выложу.

zed

02-07-2016 20:24

manager   ~0017481

Не "выложу", а сделаю пул-реквест ;)

DJ VK

03-07-2016 07:15

manager   ~0017482

Last edited: 03-07-2016 07:18

Попробовал коммит, пишет ошибку авторизации. Проталкивание прервано. ошибка 255.
Спрашивает имя пользователя и пароль. Мои с битбукета не берет, увы. Пока в виде патча.

DJ VK

03-07-2016 07:51

manager   ~0017483

Last edited: 03-07-2016 09:27

Tortoise Hg Из коробки работать не желает.
Аналогично ведет себя SourceTree. Ошибка авторизации, неверные имя и пароль.
В браузере bitbucket работает.
Пароль для приложения сгенерил на сайте, тоже не подходит.

zed

03-07-2016 09:17

manager   ~0017484

Пуш надо делать в свой форк на битбакете, а уже потом, через веб-интерфейс битбакета, из своего форка, отправлять пул-реквест.

Права на запись в основной репо имеет ограниченный круг лиц, и вы в него пока не входите.

DJ VK

03-07-2016 10:46

manager   ~0017485

Last edited: 03-07-2016 10:47

Вроде получилось с реквестом. забирайте, закрывайте.

zed

03-07-2016 19:12

manager   ~0017487

С багом получилось: https://bitbucket.org/sas_team/sas.planet.src/pull-requests/377/0003069/diff#comment-20537456

vdemidov

03-07-2016 20:38

manager   ~0017489

На будущее. Переводить в состояние Fixed нужно только после принятия пулреквеста, а то и после билда ночнушки.

Issue History

Date Modified Username Field Change
18-06-2016 07:10 DJ VK New Issue
18-06-2016 08:07 DJ VK Tag Attached: антибан
18-06-2016 08:07 DJ VK Tag Attached: скачка
20-06-2016 16:41 vdemidov Status new => confirmed
20-06-2016 16:41 vdemidov Product Version .Nightly => 160606
20-06-2016 16:41 vdemidov Target Version .Nightly => 42xxxx
02-07-2016 18:53 DJ VK Note Added: 0017480
02-07-2016 18:54 DJ VK Assigned To => DJ VK
02-07-2016 18:54 DJ VK Status confirmed => assigned
02-07-2016 20:24 zed Note Added: 0017481
03-07-2016 07:06 DJ VK Status assigned => resolved
03-07-2016 07:06 DJ VK Resolution open => fixed
03-07-2016 07:13 DJ VK File Added: 9475.patch
03-07-2016 07:15 DJ VK Note Added: 0017482
03-07-2016 07:16 DJ VK Note Edited: 0017482
03-07-2016 07:18 DJ VK Note Edited: 0017482
03-07-2016 07:51 DJ VK Note Added: 0017483
03-07-2016 09:17 zed Note Added: 0017484
03-07-2016 09:27 DJ VK Note Edited: 0017483
03-07-2016 10:46 DJ VK Note Added: 0017485
03-07-2016 10:47 DJ VK Note Edited: 0017485
03-07-2016 19:12 zed Note Added: 0017487
03-07-2016 19:13 zed Status resolved => assigned
03-07-2016 19:13 zed Target Version 42xxxx => 160707
03-07-2016 20:38 vdemidov Note Added: 0017489
03-07-2016 20:38 vdemidov Resolution fixed => reopened
06-07-2016 08:12 vdemidov Target Version 160707 => 191221
27-03-2019 08:32 vdemidov Assigned To DJ VK =>
27-03-2019 08:32 vdemidov Status assigned => confirmed
27-03-2019 08:32 vdemidov Target Version 191221 => 43xxxx
08-08-2025 13:24 zed Category Хотелка => Хотелка / Feature request