program ROM; {$DEFINE UseCThreads} {$mode objfpc}{$H+} uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} Classes { you can add units after this }, SysUtils,ROMunit, mathunit, Math; var inPulsO,inPuls,refPuls,surTraj,cRefPuls: tExtPointArray; i,smooth: longint; tmax,wmax,absShift: extended; force,fourier: boolean; const Verwendung='Verwendung: ROM ($Einfallspuls_Datei $Ausfallspuls_Datei)/(- $trace-Datei-Prefix) $output_inPuls $output_refPuls $output_Trajektorie $output_cRefPuls '+ '[-s/--smooth $n] [-f/--force] [-t/--tmax $t] [-w/--wmax $w] [-F/--FFT] [-d/--dt $dt]'; begin if paramcount<6 then Fehler(Verwendung); i:=7; force:=false; smooth:=1; tmax:=-1; wmax:=-1; fourier:=false; absShift:=-1e9; while i<=paramcount do begin if (paramstr(i)='--force') or (paramstr(i)='-f') then begin force:=true; inc(i); continue; end; if (paramstr(i)='--smooth') or (paramstr(i)='-s') then begin inc(i); smooth:=strtoint(paramstr(i)); inc(i); continue; end; if (paramstr(i)='--tmax') or (paramstr(i)='-t') then begin inc(i); tmax:=strtofloat(paramstr(i)); inc(i); continue; end; if (paramstr(i)='--wmax') or (paramstr(i)='-w') then begin inc(i); wmax:=strtofloat(paramstr(i)); fourier:=true; inc(i); continue; end; if (paramstr(i)='--dt') or (paramstr(i)='-d') then begin inc(i); if paramstr(i)='auto' then begin absShift:=-1e9; inc(i); continue; end; if paramstr(i)='input' then begin if paramstr(1)<>'-' then Fehler('Ich brauche zur Bestimmung der Gesamtverschiebung die Inputdatei vom LPIC!'); absShift:=-2e9; inc(i); continue; end; absShift:=strtofloat(paramstr(i)); inc(i); continue; end; if (paramstr(i)='--FFT') or (paramstr(i)='-F') then begin fourier:=true; inc(i); continue; end; Fehler(Verwendung); end; if paramstr(1)='-' then readRawInputs(paramstr(2),inPulsO,refPuls,absShift) else begin readTextInput(paramstr(1),inPulsO); readTextInput(paramstr(2),refPuls); end; write(stderr,'Input sortieren ...'); sort(inPulsO); sort(refPuls); writeln(stderr,' fertig'); uniq(inPulsO,false); uniq(refPuls,false); write(stderr,'Input interpolieren ...'); interpoliere(inPulsO); interpoliere(refPuls); writeln(stderr,' fertig'); flip(refPuls); integrate(inPulsO,inPuls); integrate(refPuls); removeLinearOffset(inPuls); removeLinearOffset(refPuls); if smooth>1 then begin write(stderr,'glätten ...'); smoothen(inPuls,smooth); smoothen(refPuls,smooth); writeln(stderr,' fertig'); end; cut(inPuls,tmax); cut(refPuls,tmax); for i:=3 to 5 do if (paramstr(i)<>'-') and fileexists(paramstr(i)) and not force then Fehler('Die Ausgabedatei '''+paramstr(i)+''' existiert bereits!'); gesamtverschiebung(inPuls,refPuls,absShift); write(stderr,'Trajektorie berechnen ...'); berechneTrajektorie(inPuls,refPuls,surTraj,absShift*byte(not fourier)); writeln(stderr,' fertig'); write(stderr,'Ergebnis sortieren ...'); sort(surTraj); writeln(stderr,' fertig'); uniq(surTraj,false); if fourier then begin write(stderr,'Ergebnis interpolieren ...'); interpoliere(surTraj); writeln(stderr,' fertig'); fft(inPuls); fft(refPuls); fft(surTraj); inPuls[0].y:=0; refPuls[0].y:=0; surTraj[0].y:=0; if wmax<0 then begin cut(surTraj,min(refPuls[length(refPuls)-1].x,inPuls[length(inPuls)-1].x)/2); cut(inPuls,surTraj[length(surTraj)-1].x); cut(refPuls,surTraj[length(surTraj)-1].x); end else begin cut(surTraj,wmax); cut(inPuls,wmax); cut(refPuls,wmax); end; write(stderr,'alles normieren ...'); normiere(inPuls); normiere(refPuls); normiere(surTraj); writeln(stderr,' fertig'); end else begin write(stderr,'Reflektierten Puls berechnen ...'); berechneRefPuls(inPulsO,surTraj,cRefPuls); integrate(cRefPuls); writeln(stderr,' fertig'); end; if paramstr(3)<>'-' then writeOutput(paramstr(3),inPuls); if paramstr(4)<>'-' then writeOutput(paramstr(4),refPuls); if paramstr(5)<>'-' then writeOutput(paramstr(5),surTraj); if (paramstr(6)<>'-') and not fourier then writeOutput(paramstr(6),cRefPuls); end.