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
|
unit pegelunit;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, Graphics;
type
tPegelZeitGroesze = (pzgJahr,pzgMonat,pzgTag,pzgStunde,pzgMin15);
tPegelZeit = array[tPegelZeitgroesze] of integer;
tPegelStation = (psBlankenstein,psKaulsdorf,psSaalfeld,psRudolstadt,
psRothenstein,psCamburg,psMoeschlitz,psProbstzella,psKaulsdorfEichicht,
psKatzhuette,psSchwarzburg,psFreienorla);
tPegel = record
zeit: tPegelZeit;
hoehe: longint;
end;
pTPegel = ^tPegel;
tPegelStaende = class
werte: array[tPegelStation] of tList;
constructor create;
destructor destroy; override;
// procedure einlesen(was: string);
procedure laden(von: string);
procedure speichern(nach: string);
end;
implementation
uses systemunit;
const
pegelStationsNamen: array[tPegelstation] of array[0..1] of string =
(('Blankenstein','Blankenstein-Ros.'),
('Kaulsdorf',''),
('Saalfeld-Remschütz',''),
('Rudolstadt',''),
('Rothenstein',''),
('Camburg-Stöben',''),
('Möschlitz',''),
('Probstzella',''),
('Kaulsdorf-Eichicht',''),
('Katzhütte',''),
('Schwarzburg',''),
('Freienorla',''));
pegelStationsNummern: array[tPegelstation] of extended =
(57021,57025,57026,57027,57028,57033,57170,57200,57201,57211,57211.5,57240);
pegelGrenzen: array[tPegelstation,0..3] of longint =
((210,230,270,310),(195,210,225,240),(200,230,260,290),(150,180,210,240),
(250,290,330,370),(280,330,380,430),(180,200,220,240),(0,0,0,0),
(130,170,210,230),(200,230,260,290),(130,150,170,190),(0,0,0,0));
pFarben: array[tPegelstation] of tColor =
($000000,$000000,$000000,$FF0000,$7F0000,$000000,$000000,$000000,$000000,$000000,$000000,$000000);
// tPegelStaende ***************************************************************
constructor tPegelStaende.create;
var
ps: tPegelStation;
begin
inherited create;
for ps:=low(tPegelStation) to high(tPegelStation) do
werte[ps]:=tList.create;
end;
destructor tPegelStaende.destroy;
var
ps: tPegelStation;
begin
for ps:=low(tPegelStation) to high(tPegelStation) do
werte[ps].free;
inherited destroy;
end;
procedure tPegelStaende.laden(von: string);
var
f: textfile;
s: string;
ps: tPegelstation;
pzg: tPegelzeitgroesze;
psda,gefunden: boolean;
np: pTPegel;
i: longint;
begin
if not fileexists(von) then exit;
assignfile(f,von);
reset(f);
psda:=false;
ps:=low(TPegelstation);
while not eof(f) do begin
readln(f,s);
if pos('Station: ',s)=1 then begin
delete(s,1,pos(' ',s));
ps:=low(TPegelstation);
gefunden:=false;
while ps<=high(TPegelstation) do begin
for i:=0 to length(Pegelstationsnamen[psBlankenstein])-1 do
gefunden:=gefunden or ((Pegelstationsnamen[ps,i]<>'') and (Pegelstationsnamen[ps,i]=s));
if gefunden then break;
inc(ps);
end;
if not gefunden then begin
closefile(f);
raise exception.create('Pegelstation '''+s+''' nicht gefunden!');
end;
psda:=true;
continue;
end;
if not psda then
raise exception.create('Es wurde noch keine Pegelstation erwähnt!');
getmem(np,sizeof(TPegel));
werte[ps].Add(np);
for pzg:=low(tPegelZeitGroesze) to high(tPegelZeitGroesze) do begin
np^.Zeit[pzg]:=strtoint(copy(s,1,pos(' ',s)-1));
delete(s,1,pos(' ',s));
end;
np^.Hoehe:=strtoint(s);
end;
closefile(f);
end;
procedure tPegelStaende.speichern(nach: string);
var
dateischonda: boolean;
f: textfile;
ps: tPegelStation;
pzg: tPegelZeitGroesze;
i: longint;
s: string;
begin
dateischonda:=fileexists(nach);
if dateischonda then
assignfile(f,mkTemp(nach+'.XXXXXX'))
else
assignfile(f,nach);
rewrite(f);
for ps:=low(tPegelStation) to high(tPegelStation) do begin
writeln(f,'Station: '+Pegelstationsnamen[ps,0]);
for i:=0 to werte[ps].Count-1 do begin
s:='';
for pzg:=low(tPegelZeitGroesze) to high(tPegelZeitGroesze) do
s:=s+inttostr(pTPegel(werte[ps][i])^.zeit[pzg])+' ';
writeln(f,s+inttostr(pTPegel(werte[ps][i])^.hoehe));
end;
end;
closefile(f);
if dateischonda then begin
deletefile(nach);
rename(f,nach);
end;
end;
(*
procedure tPegelStaende.einlesen(von: string);
var t: string;
PS: TPegelstation;
psda,wsda,gefunden: boolean;
PZ: TPegelZeit;
posi: extended;
nps: PTPegel;
PZG: TPegelZeitGroesze;
i: longint;
begin
s:=s+#10;
result:=false;
psda:=false;
wsda:=false;
PS:=low(TPegelstation);
while pos(#13,s)>0 do begin
t:=copy(s,1,pos(#10,s)-1);
delete(s,1,pos(#10,s));
while pos(#13,t)>0 do
delete(t,pos(#13,t),1);
if length(t)=0 then continue;
if pos('Pegelname: ',t)=1 then begin
delete(t,1,pos(' ',t));
PS:=low(TPegelstation);
gefunden:=false;
while PS<=high(TPegelstation) do begin
for i:=0 to length(Pegelstationsnamen[psBlankenstein])-1 do
gefunden:=gefunden or ((Pegelstationsnamen[PS,i]<>'') and (Pegelstationsnamen[PS,i]=t));
if gefunden then break;
inc(PS);
end;
if not gefunden then begin
Messagedlg('Unbekannter Pegelname: '''+t+'''!',mterror,[mbOk],0);
exit;
end;
psda:=true;
continue;
end;
if t='Durchfluss [m3/s]' then begin
wsda:=false;
continue;
end;
if t='Wasserstand [cm]' then begin
wsda:=true;
continue;
end;
if not (wsda and psda) then continue;
if pos('Fluss: ',t)=1 then continue;
if pos('Flusseinzugsgebiet: ',t)=1 then continue;
if pos('Stationsnummer: ',t)=1 then begin
delete(t,1,pos(' ',t));
while pos(' ',t)=1 do delete(t,1,1);
while pos('.',t)>0 do t[pos('.',t)]:=',';
if round(10*strtofloat(t))<>round(10*Pegelstationsnummern[PS]) then begin
Messagedlg('erwartete Pegelstationsnummer ('+floattostr(Pegelstationsnummern[PS])+
') für '+Pegelstationsnamen[PS,0]+' ist verschieden von der angegebenen Nummer ('+t+')!',mtError,[mbOk],0);
exit;
end;
continue;
end;
if pos('Hinweise: ',t)=1 then continue;
if pos('keine Werte',t)>0 then continue;
PZ:=strToPegelZeit(t);
posi:=findePegelZeit(Pegelstaende[PS],PZ);
if odd(round(2*posi)) then begin
result:=true;
getmem(nps,sizeof(TPegel));
for PZG:=low(TPegelZeitGroesse) to high(TPegelZeitGroesse) do
nps^.Zeit[PZG]:=PZ[PZG];
delete(t,1,pos(',',t)+1);
nps^.Hoehe:=strtoint(t);
Pegelstaende[PS].Insert(round(posi+0.5),nps);
end;
end;
Zeichnen;
end;
*)
end.
|