Skip to content

Commit

Permalink
Fix target retry message, show reason for retry
Browse files Browse the repository at this point in the history
  • Loading branch information
pchev committed Dec 15, 2020
1 parent f7d1a03 commit 1e84568
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 53 deletions.
54 changes: 36 additions & 18 deletions src/cu_targets.pas
Expand Up @@ -104,6 +104,7 @@ T_Targets = class(TComponent)
FSequenceFile: T_SequenceFile;
FRestarting, FRealRestart: boolean;
Fslewing: boolean;
InitTargetError: string;
function GetBusy: boolean;
procedure SetTargetName(val: string);
procedure SetPreview(val: Tf_preview);
Expand Down Expand Up @@ -1610,7 +1611,7 @@ procedure T_Targets.NextTargetAsync(Data: PtrInt);
f_pause.Caption:=rsTargetInitia;
f_pause.Text:=rsTargetInitia+' '+Targets[FCurrentTarget].objectname+
crlf+rsDoYouWantToR;
if f_pause.Wait(WaitResponseTime,false) then begin
if f_pause.Wait(WaitResponseTime,false, rsRetry, rsNextTarget) then begin
Dec(FCurrentTarget);
end;
NextTarget;
Expand Down Expand Up @@ -1647,17 +1648,16 @@ procedure T_Targets.NextTargetAsync(Data: PtrInt);
end
else begin
msg(Targets[FCurrentTarget].objectname+', '+rsTargetInitia,0);
if EmailTargetInitialisation then email(rsTargetInitia,Targets[FCurrentTarget].objectname+', '+rsTargetInitia);
if EmailTargetInitialisation then email(rsTargetInitia,Targets[FCurrentTarget].objectname+', '+rsTargetInitia+', '+InitTargetError);
if FUnattended then begin
FInitializing:=false;
NextTarget;
exit;
end else begin
FInitializing:=false;
f_pause.Caption:=rsTargetInitia;
f_pause.Text:=rsTargetInitia+' '+Targets[FCurrentTarget].objectname+
crlf+rsDoYouWantToR;
if f_pause.Wait(WaitResponseTime,false) then begin
f_pause.Text:=rsTargetInitia+' '+Targets[FCurrentTarget].objectname+crlf+crlf+InitTargetError+crlf+rsDoYouWantToR;
if f_pause.Wait(WaitResponseTime, false, rsRetry, rsNextTarget) then begin
Dec(FCurrentTarget);
end;
NextTarget;
Expand Down Expand Up @@ -1710,6 +1710,7 @@ function T_Targets.InitTarget(restart:boolean=false):boolean;
autofocusstart, astrometrypointing, autostartguider,isCalibrationTarget: boolean;
skipmsg, buf: string;
begin
InitTargetError:='';
SkipTarget:=false;
result:=false;
if not FRunning then exit;
Expand All @@ -1721,13 +1722,15 @@ function T_Targets.InitTarget(restart:boolean=false):boolean;
if t.repeatcount=0 then begin
SkipTarget:=true;
result:=false;
msg(Format(rsSkipTarget, [t.objectname+', '+rsRepeat+'=0']), 3);
InitTargetError:=Format(rsSkipTarget, [t.objectname+', '+rsRepeat+'=0']);
msg(InitTargetError, 3);
exit;
end;
if t.repeatdone>=t.repeatcount then begin
SkipTarget:=true;
result:=false;
msg(Format(rsSkipTarget, [t.objectname+', '+Format(rsSeqFinished,[t.planname])]), 3);
InitTargetError:=Format(rsSkipTarget, [t.objectname+', '+Format(rsSeqFinished,[t.planname])]);
msg(InitTargetError, 3);
exit;
end;
msg(Format(rsInitializeTa, [t.objectname]),1);
Expand Down Expand Up @@ -1778,7 +1781,8 @@ function T_Targets.InitTarget(restart:boolean=false):boolean;
ObjRise(appra,appde,hr,ri);
// check object visibility
if ri=2 then begin
msg(Format(rsSkipTarget, [t.objectname])+', '+rsThisObjectIs2, 3);
InitTargetError:=Format(rsSkipTarget, [t.objectname])+', '+rsThisObjectIs2;
msg(InitTargetError, 3);
SkipTarget:=true;
result:=false;
exit;
Expand Down Expand Up @@ -1850,14 +1854,16 @@ function T_Targets.InitTarget(restart:boolean=false):boolean;
end;
end;
if SkipTarget then begin
msg(Format(rsSkipTarget, [t.objectname])+skipmsg, 3);
InitTargetError:=Format(rsSkipTarget, [t.objectname])+skipmsg;
msg(InitTargetError, 3);
result:=false;
exit;
end;
end;
// start / stop timer
if (intime>0) then begin
msg(Format(rsTargetCancel, [t.objectname])+', '+Format(rsStopTimeAlre, [TimeToStr(t.endtime)]),3);
InitTargetError:=Format(rsTargetCancel, [t.objectname])+', '+Format(rsStopTimeAlre, [TimeToStr(t.endtime)]);
msg(InitTargetError,3);
result:=false;
exit;
end;
Expand All @@ -1866,7 +1872,8 @@ function T_Targets.InitTarget(restart:boolean=false):boolean;
msg(Format(rsWaitToStartA, [TimeToStr(t.starttime)]),1);
wtok:=WaitTill(TimeToStr(t.starttime),true);
if not wtok then begin
msg(Format(rsTargetCancel, [t.objectname]),1);
InitTargetError:=Format(rsTargetCancel, [t.objectname]);
msg(InitTargetError,1);
result:=false;
exit;
end;
Expand All @@ -1879,7 +1886,8 @@ function T_Targets.InitTarget(restart:boolean=false):boolean;
StopTargetTimer.Interval:=1000*stw;
StopTargetTimer.Enabled:=true;
end else begin
msg(Format(rsTargetCancel, [t.objectname])+', '+Format(rsStopTimeAlre, [TimeToStr(t.endtime)]),3);
InitTargetError:=Format(rsTargetCancel, [t.objectname])+', '+Format(rsStopTimeAlre, [TimeToStr(t.endtime)]);
msg(InitTargetError,3);
result:=false;
exit;
end;
Expand All @@ -1900,7 +1908,10 @@ function T_Targets.InitTarget(restart:boolean=false):boolean;
if (Autoguider<>nil)and(Autoguider.AutoguiderType<>agNONE)and(Autoguider.AutoguiderType<>agDITHER) then begin
// stop guiding
if Autoguider.State<>GUIDER_DISCONNECTED then begin
if not StopGuider then exit;
if not StopGuider then begin
InitTargetError:=rsFailToStopTh;
exit;
end;
Wait(2);
if not FRunning then exit;
if WeatherCancelRestart then exit;
Expand All @@ -1919,14 +1930,15 @@ function T_Targets.InitTarget(restart:boolean=false):boolean;
buf:='Dome is: ';
if not dome.Shutter then buf:=buf+'closed, ';
if dome.hasSlaving and(not dome.Slave) then buf:=buf+'not slaved ';
msg('Dome is not ready',1);
msg(buf,1);
InitTargetError:='Dome is not ready: '+buf;
msg(InitTargetError,1);
StopSequence(true);
exit;
end;
// check mount not parked
if mount.Park then begin
msg(rsTheTelescope, 1);
InitTargetError:=rsTheTelescope;
msg(InitTargetError, 1);
StopSequence(true);
exit;
end;
Expand All @@ -1937,7 +1949,10 @@ function T_Targets.InitTarget(restart:boolean=false):boolean;
// slew to coordinates
FSlewRetry:=1;
ok:=Slew(t.ra,t.de,astrometrypointing,t.astrometrypointing);
if not ok then exit;
if not ok then begin
InitTargetError:=rsTelescopeSle3;
exit;
end;
Wait;
end;
if not FRunning then exit;
Expand All @@ -1963,7 +1978,10 @@ function T_Targets.InitTarget(restart:boolean=false):boolean;
((not autofocusstart)or (InplaceAutofocus and (not AutofocusPauseGuider))) and
(not isCalibrationTarget);
if autostartguider then begin
if not StartGuider then exit;
if not StartGuider then begin
InitTargetError:=rsFailedToStar;
exit;
end;
Wait;
if not FRunning then exit;
if WeatherCancelRestart then exit;
Expand Down
89 changes: 55 additions & 34 deletions src/pu_pause.lfm
@@ -1,57 +1,78 @@
object f_pause: Tf_pause
Left = 0
Height = 131
Height = 153
Top = 0
Width = 322
Width = 329
ActiveControl = BtnContinue
AutoSize = True
BorderWidth = 5
BorderWidth = 8
Caption = 'Pause'
ClientHeight = 131
ClientWidth = 322
ClientHeight = 153
ClientWidth = 329
FormStyle = fsStayOnTop
OnCloseQuery = FormCloseQuery
OnCreate = FormCreate
OnShow = FormShow
Position = poMainFormCenter
object BtnContinue: TButton
Left = 213
Height = 25
Top = 101
Width = 91
Caption = 'Continue...'
OnClick = BtnContinueClick
ParentFont = False
TabOrder = 0
end
object PauseLabel: TLabel
Left = 5
Height = 64
Top = 5
Width = 312
AutoSize = False
Left = 8
Height = 68
Top = 8
Width = 313
Align = alTop
Caption = 'Pause'#10'2'#10'3'#10'4'
ParentColor = False
ParentFont = False
WordWrap = True
end
object BtnCancel: TButton
Left = 101
Height = 25
Top = 101
Width = 75
Caption = 'Cancel'
OnClick = BtnCancelClick
ParentFont = False
TabOrder = 1
end
object Label1: TLabel
Left = 5
Height = 13
Top = 77
Width = 20
Left = 8
Height = 17
Top = 88
Width = 313
Align = alTop
Caption = ' '
ParentColor = False
ParentFont = False
end
object Panel1: TPanel
Left = 8
Height = 40
Top = 105
Width = 313
Align = alTop
BevelOuter = bvNone
ClientHeight = 40
ClientWidth = 313
TabOrder = 0
object BtnContinue: TButton
Left = 213
Height = 25
Top = 8
Width = 100
Caption = 'Continue...'
OnClick = BtnContinueClick
ParentFont = False
TabOrder = 0
end
object BtnCancel: TButton
Left = 101
Height = 25
Top = 8
Width = 100
Caption = 'Cancel'
OnClick = BtnCancelClick
ParentFont = False
TabOrder = 1
end
end
object Panel2: TPanel
Left = 8
Height = 12
Top = 76
Width = 313
Align = alTop
BevelOuter = bvNone
TabOrder = 1
end
end
4 changes: 3 additions & 1 deletion src/pu_pause.pas
Expand Up @@ -29,7 +29,7 @@
interface

uses u_global, UScaleDPI, u_utils, u_translation, u_speech,
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls;
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls, ExtCtrls;

type

Expand All @@ -39,6 +39,8 @@ Tf_pause = class(TForm)
BtnContinue: TButton;
BtnCancel: TButton;
Label1: TLabel;
Panel1: TPanel;
Panel2: TPanel;
PauseLabel: TLabel;
procedure BtnContinueClick(Sender: TObject);
procedure BtnCancelClick(Sender: TObject);
Expand Down
3 changes: 3 additions & 0 deletions src/u_translation.pas
Expand Up @@ -1295,6 +1295,9 @@ function Translate(lang: string = ''): string;
rsSelectTheFil = 'Select the file to delete';
rsSelectTheFil2 = 'Select the file to edit';
rsSelectTheFil3 = 'Select the file to load';
rsRetry = 'Retry';
rsNextTarget = 'Next target';
rsFailToStopTh = 'Fail to stop the autoguider';

implementation

Expand Down

0 comments on commit 1e84568

Please sign in to comment.