Skip to content
Permalink
Browse files

show reason why astrometry failed

  • Loading branch information...
pchev committed Mar 25, 2019
1 parent 6eb1b4f commit 7c6f4794533fa84083d75cadeef4a56299d1dccb
Showing with 40 additions and 16 deletions.
  1. +7 −2 src/cu_astrometry.pas
  2. +23 −12 src/cu_astrometry_engine.pas
  3. +10 −2 src/pu_main.pas
@@ -39,6 +39,7 @@ TAstrometry = class(TComponent)
FonEndAstrometry: TNotifyEvent;
FonShowMessage: TNotifyMsg;
FBusy, FSlewBusy, FLastResult: Boolean;
FLastError: string;
FLastSlewErr,FInitra,FInitdec,FStartTime: double;
Fmount: T_mount;
Fcamera: T_camera;
@@ -61,7 +62,7 @@ TAstrometry = class(TComponent)
constructor Create(AOwner: TComponent);override;
function StartAstrometry(infile,outfile: string; terminatecmd:TNotifyEvent): boolean;
procedure StopAstrometry;
procedure AstrometryDone;
procedure AstrometryDone(errstr:string);
function CurrentCoord(out cra,cde,eq,pa: double):boolean;
procedure SolveCurrentImage(wait: boolean);
procedure SyncCurrentImage(wait: boolean);
@@ -73,6 +74,7 @@ TAstrometry = class(TComponent)
property SlewBusy: Boolean read FSlewBusy;
property LastSlewErr: double read FLastSlewErr;
property LastResult: Boolean read FLastResult;
property LastError: String read FLastError;
property InitRA: double read Finitra;
property InitDEC: double read Finitdec;
property StartTime: double read FStartTime;
@@ -96,6 +98,7 @@ constructor TAstrometry.Create(AOwner: TComponent);
FBusy:=false;
FSlewBusy:=false;
FLastResult:=false;
FLastError:='';
FLastSlewErr:=0;
AstrometryTimeout:=60;
TimerAstrometrySolve:=TTimer.Create(self);
@@ -156,6 +159,7 @@ function TAstrometry.StartAstrometry(infile,outfile: string; terminatecmd:TNotif
msg(Format(rsCannotFindAp, [crlf]),2);
end;
FLastResult:=false;
FLastError:='';
FInitra:=ra;
FInitdec:=de;
FStartTime:=now;
@@ -225,13 +229,14 @@ function TAstrometry.StartAstrometry(infile,outfile: string; terminatecmd:TNotif
end;
end;

procedure TAstrometry.AstrometryDone;
procedure TAstrometry.AstrometryDone(errstr:string);
begin
if FileExistsUTF8(savefile) and FileExistsUTF8(solvefile) then
FLastResult:=true
else
FLastResult:=false;
FBusy:=false;
FLastError:=errstr;
if Assigned(FonEndAstrometry) then FonEndAstrometry(self);
if Assigned(Fterminatecmd) then Fterminatecmd(self);
Fterminatecmd:=nil;
@@ -423,7 +423,7 @@ procedure TAstrometry_engine.Execute;
const READ_BYTES = 65536;
var n: LongInt;
f: file;
buf: string;
buf,err: string;
logok: boolean;
cbuf: array[0..READ_BYTES] of char;
ft,fl: TextFile;
@@ -432,6 +432,7 @@ procedure TAstrometry_engine.Execute;
endtime: double;
mem: TMemoryStream;
begin
err:='';
if FResolver=ResolverAstrometryNet then begin
cbuf:='';
if (FLogFile<>'') then begin
@@ -466,6 +467,7 @@ procedure TAstrometry_engine.Execute;
end;
if now>endtime then begin
Stop;
err:=rsTimeout+'!';
if logok then begin
buf:=rsTimeout+'!';
cbuf:=buf;
@@ -480,21 +482,24 @@ procedure TAstrometry_engine.Execute;
n := process.Output.Read(cbuf, READ_BYTES);
if n>=0 then BlockWrite(f,cbuf,n);
until (n<=0)or(process.Output=nil);
process.Free;
process:=TProcessUTF8.Create(nil);
if (Fresult<>0)and(err='') then
err:=Format(rsErrorResult, [IntToStr(Fresult)]);
if logok and (Fresult<>0) then begin
buf:=Format(rsErrorResult, [IntToStr(Fresult)]);
cbuf:=buf;
BlockWrite(f,cbuf,Length(buf));
end;
except
Fresult:=1;
err:=Format(rsErrorStartin, [Fcmd]);
if logok then begin
buf:=Format(rsErrorStartin, [Fcmd]);
cbuf:=buf;
BlockWrite(f,cbuf,Length(buf));
end;
end;
process.Free;
process:=TProcessUTF8.Create(nil);
if logok then CloseFile(f);
// merge wcs result
if (Fresult=0)and(not FileExistsUTF8(FOutFile))and(FileExistsUTF8(wcsfile)) then begin
@@ -512,7 +517,7 @@ procedure TAstrometry_engine.Execute;
mem.Free;
end;
end;
PostMessage(MsgHandle, LM_CCDCIEL, M_AstrometryDone, 0);
PostMessage(MsgHandle, LM_CCDCIEL, M_AstrometryDone, PtrInt(strnew(PChar(err))));
end
else if FResolver=ResolverElbrus then begin
fn:=slash(FElbrusDir)+'elbrus.txt';
@@ -533,6 +538,7 @@ procedure TAstrometry_engine.Execute;
repeat
sleep(500);
until FileExistsUTF8(slash(FElbrusDir)+'elbrus.sta') or (now>endtime);
if (now>endtime) then err:=rsTimeout+'!';
sleep(1000);
if (FLogFile<>'') then begin
if FileExistsUTF8(slash(FElbrusDir)+'elbrus.sta') then begin
@@ -576,7 +582,7 @@ procedure TAstrometry_engine.Execute;
CloseFile(ft);
end;
end;
PostMessage(MsgHandle, LM_CCDCIEL, M_AstrometryDone, 0);
PostMessage(MsgHandle, LM_CCDCIEL, M_AstrometryDone, PtrInt(strnew(PChar(err))));
end
else if FResolver=ResolverPlateSolve then begin
process.Executable:=Fcmd;
@@ -592,24 +598,26 @@ procedure TAstrometry_engine.Execute;
process.Execute;
while process.Running do begin
if now>endtime then begin
err:=rsTimeout+'!';
Stop;
break;
end;
sleep(100);
end;
Fresult:=process.ExitStatus;
process.Free;
process:=TProcessUTF8.Create(nil);
except
on E: Exception do begin
Fresult:=1;
err:='Fail to start Platesolve2:'+E.Message;
AssignFile(ft,FLogFile);
Append(ft);
WriteLn(ft,'Fail to start Platesolve2:');
WriteLn(ft,E.Message);
CloseFile(ft);
end;
end;
process.Free;
process:=TProcessUTF8.Create(nil);
// merge apm result
if (Fresult=0)and(FileExistsUTF8(apmfile)) then begin
if (FLogFile<>'') then begin
@@ -641,7 +649,7 @@ procedure TAstrometry_engine.Execute;
end;
end;
end;
PostMessage(MsgHandle, LM_CCDCIEL, M_AstrometryDone, 0);
PostMessage(MsgHandle, LM_CCDCIEL, M_AstrometryDone, PtrInt(strnew(PChar(err))));
end
else if FResolver=ResolverAstap then begin
cbuf:='';
@@ -662,14 +670,13 @@ procedure TAstrometry_engine.Execute;
process.Execute;
while process.Running do begin
if now>endtime then begin
err:=rsTimeout+'!';
Stop;
break;
end;
sleep(100);
end;
Fresult:=process.ExitStatus;
process.Free;
process:=TProcessUTF8.Create(nil);
except
on E: Exception do begin
Fresult:=1;
@@ -678,8 +685,11 @@ procedure TAstrometry_engine.Execute;
WriteLn(ft,'Fail to start Astap:');
WriteLn(ft,E.Message);
CloseFile(ft);
err:='Fail to start Astap:'+E.Message;
end;
end;
process.Free;
process:=TProcessUTF8.Create(nil);
// merge wcs result
if (Fresult=0)and(FileExistsUTF8(wcsfile)) then begin
Ftmpfits:=TFits.Create(nil);
@@ -697,16 +707,17 @@ procedure TAstrometry_engine.Execute;
mem.Free;
end;
end;
PostMessage(MsgHandle, LM_CCDCIEL, M_AstrometryDone, 0);
PostMessage(MsgHandle, LM_CCDCIEL, M_AstrometryDone, PtrInt(strnew(PChar(err))));
end
else if FResolver=ResolverNone then begin
err:=rsNoResolverCo;
if (FLogFile<>'') then begin
AssignFile(ft,FLogFile);
rewrite(ft);
WriteLn(ft,rsNoResolverCo);
CloseFile(ft);
end;
PostMessage(MsgHandle, LM_CCDCIEL, M_AstrometryDone, 0);
PostMessage(MsgHandle, LM_CCDCIEL, M_AstrometryDone, PtrInt(strnew(PChar(err))));
end;
end;

@@ -8698,7 +8698,7 @@ procedure Tf_main.AstrometryEnd(Sender: TObject);
end;
NewMessage(Format(rsResolveSucce, [astrometry.Resolver])+resulttxt,2);
end else begin
NewMessage(Format(rsResolveError, [astrometry.Resolver]),1);
NewMessage(Format(rsResolveError, [astrometry.Resolver])+' '+astrometry.LastError,1);
end;
end;

@@ -9424,7 +9424,15 @@ procedure Tf_main.CCDCIELMessageHandler(var Message: TLMessage);
autoguider.ErrorDesc:='';
NewMessage(buf,1);
end;
M_AstrometryDone: astrometry.AstrometryDone;
M_AstrometryDone: begin
try
buf:=PChar(Message.LParam);
StrDispose(PChar(Message.LParam));
except
buf:='';
end;
astrometry.AstrometryDone(buf);
end
else
NewMessage(Format(rsReceiveUnkno, [inttostr(Message.wParam)]),1);
end;

0 comments on commit 7c6f479

Please sign in to comment.
You can’t perform that action at this time.