1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
|
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.
|