program ROM; {$DEFINE UseCThreads} {$mode objfpc}{$H+} uses {$IFDEF UNIX}{$IFDEF UseCThreads} cthreads, {$ENDIF}{$ENDIF} Classes { you can add units after this }, SysUtils,ROMunit, matheunit, Math, systemunit, lowlevelunit, mystringlistunit; var inPulsO,inPuls,refPulsO,refPuls,surTraj,cRefPuls, surVel: tExtPointArray; smooth,betaSmooth,veloSmooth: longint; tmax,absShift,betaBound,veloBound: extended; force,mitAmplMod: boolean; f,bekannteBefehle: tMyStringList; s,lpicIn,rohIn,rohRef,outIn, outRef,outRefC,outSur,outVel: string; const Verwendung='Verwendung: ROM $Parameterdatei'; begin if (paramcount<>1) or not fileexists(paramstr(1)) then Fehler(Verwendung); force:=false; smooth:=1; betaSmooth:=1; tmax:=-1; absShift:=-1e9; betaBound:=0.95; mitAmplMod:=true; veloSmooth:=1; veloBound:=1; lpicIn:=''; rohIn:=''; rohRef:=''; outIn:=''; outRef:=''; outRefC:=''; outSur:=''; outVel:=''; f:=tMyStringList.create; f.loadFromFile(paramstr(1)); f.unfoldMacros; bekannteBefehle:=tMyStringList.create; while f.readln(s) do begin bekannteBefehle.clear; if istDasBefehl('mit Gewalt',s,bekannteBefehle,false) then begin force:=true; continue; end; if istDasBefehl('ohne Gewalt',s,bekannteBefehle,false) then begin force:=false; continue; end; if istDasBefehl('mit Amplitudenmodulation',s,bekannteBefehle,false) then begin mitAmplMod:=true; continue; end; if istDasBefehl('ohne Amplitudenmodulation',s,bekannteBefehle,false) or istDasBefehl('nur Phasenmodulation',s,bekannteBefehle,false) then begin mitAmplMod:=false; continue; end; if istDasBefehl('Glätte:',s,bekannteBefehle,true) then begin smooth:=strtoint(s); continue; end; if istDasBefehl('Trajektoriengeschwindigkeitsglätte:',s,bekannteBefehle,true) then begin veloSmooth:=strtoint(s); continue; end; if istDasBefehl('Trajektorien-Maximalgeschwindigkeit:',s,bekannteBefehle,true) then begin veloBound:=strtofloat(s); continue; end; if istDasBefehl('Betaglätte:',s,bekannteBefehle,true) then begin betaSmooth:=strtoint(s); continue; end; if istDasBefehl('AM-Maximalgeschwindigkeit:',s,bekannteBefehle,true) then begin betaBound:=strtofloat(s); continue; end; if istDasBefehl('tmax:',s,bekannteBefehle,true) then begin tmax:=strtofloat(s); continue; end; if istDasBefehl('Absolutverschiebung:',s,bekannteBefehle,true) then begin if s='auto' then begin absShift:=-1e9; continue; end; if s='input' then begin absShift:=-2e9; continue; end; absShift:=strtofloat(s); continue; end; if istDasBefehl('lpic-Quelle:',s,bekannteBefehle,true) then begin lpicIn:=s; continue; end; if istDasBefehl('in-Quelle:',s,bekannteBefehle,true) then begin rohIn:=s; continue; end; if istDasBefehl('reflex-Quelle:',s,bekannteBefehle,true) then begin rohRef:=s; continue; end; if istDasBefehl('in-Ziel:',s,bekannteBefehle,true) then begin outIn:=s; continue; end; if istDasBefehl('reflex-Ziel:',s,bekannteBefehle,true) then begin outRef:=s; continue; end; if istDasBefehl('reflex-Approx-Ziel:',s,bekannteBefehle,true) then begin outRefC:=s; continue; end; if istDasBefehl('trajektorie-Ziel:',s,bekannteBefehle,true) then begin outSur:=s; continue; end; if istDasBefehl('geschwindigkeit-Ziel:',s,bekannteBefehle,true) then begin outVel:=s; continue; end; bekannteBefehle.sort; Fehler('Unbekannter Parameter '''+s+''' in Inputdatei '''+paramstr(1)+'''!'#10'Ich kenne nur:'#10+bekannteBefehle.text); end; bekannteBefehle.free; f.free; if (absShift<-1.5e9) and (lpicIn='') then Fehler('Ich brauche zur Bestimmung der Gesamtverschiebung die Inputdatei vom LPIC!'); if (lpicIn<>'') and ((rohIn<>'') or (rohRef<>'')) then Fehler('lpic-Quelle und rohe Input-/Reflex-Quelle können nicht gleichzeitig angegeben werden!'); if ((rohIn<>'') xor (rohRef<>'')) then Fehler('Ich brauche den rohen Input- und Reflex-Puls, oder aber nur die lpic-Quelle!'); if (not force) and (outIn<>'') and fileexists(outIn+'.ori') then Fehler('Die Ausgabedatei '''+outIn+'.ori'' existiert bereits!'); if (not force) and (outIn<>'') and fileexists(outIn) then Fehler('Die Ausgabedatei '''+outIn+''' existiert bereits!'); if (not force) and (outRef<>'') and fileexists(outRef+'.ori') then Fehler('Die Ausgabedatei '''+outRef+'.ori'' existiert bereits!'); if (not force) and (outRef<>'') and fileexists(outRef) then Fehler('Die Ausgabedatei '''+outRef+''' existiert bereits!'); if (not force) and (outRefC<>'') and fileexists(outRefC) then Fehler('Die Ausgabedatei '''+outRefC+''' existiert bereits!'); if (not force) and (outSur<>'') and fileexists(outSur) then Fehler('Die Ausgabedatei '''+outSur+''' existiert bereits!'); if lpicIn<>'' then readRawInputs(lpicIn,inPulsO,refPulsO,absShift) else begin readTextInput(rohIn,inPulsO); readTextInput(rohRef,refPulsO); end; write(stderr,'Input sortieren ...'); sort(inPulsO); sort(refPulsO); writeln(stderr,' fertig'); uniq(inPulsO,false); uniq(refPulsO,false); write(stderr,'Input interpolieren ...'); interpoliere(inPulsO); interpoliere(refPulsO); writeln(stderr,' fertig'); flip(inPulsO); if mitAmplMod then begin integrate(inPulsO,inPuls); integrate(refPulsO,refPuls); end else begin copyArray(inPulsO,inPuls); copyArray(refPulsO,refPuls); end; 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); if (outVel<>'') or (outRefC<>'') or (outSur<>'') then begin gesamtverschiebung(inPuls,refPuls,absShift); write(stderr,'Trajektorie berechnen ...'); berechneTrajektorie(inPuls,refPuls,surTraj,absShift); writeln(stderr,' fertig'); write(stderr,'Ergebnis sortieren ...'); sort(surTraj); writeln(stderr,' fertig'); uniq(surTraj,false); end; if (outVel<>'') or (outRefC<>'') then begin write(stderr,'Geschwindigkeit berechnen ...'); ableiten(surTraj,surVel,veloSmooth,veloBound); writeln(stderr,' fertig'); end; if outRefC<>'' then begin write(stderr,'Reflektierten Puls berechnen ...'); berechneRefPuls(inPulsO,surTraj,betaSmooth,betaBound,cRefPuls); writeln(stderr,' fertig'); end; write(stderr,'Ergebnis interpolieren ...'); if outSur<>'' then interpoliere(surTraj); if outVel<>'' then interpoliere(surVel); writeln(stderr,' fertig'); if outIn<>'' then begin writeOutput(outIn+'.ori',inPulsO); writeOutput(outIn,inPuls); end; if outRef<>'' then begin writeOutput(outRef+'.ori',refPulsO); writeOutput(outRef,refPuls); end; if outSur<>'' then writeOutput(outSur,surTraj); if outVel<>'' then writeOutput(outVel,surVel); if outRefC<>'' then writeOutput(outRefC,cRefPuls); end.