summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorErich Eckner <git@eckner.net>2015-11-17 16:24:24 +0100
committerErich Eckner <git@eckner.net>2015-11-17 16:24:24 +0100
commit9b75646e386074fae0bc6002a0d32eaaa7fb0d95 (patch)
tree9b75f161082dcad4f24cf4a30fa9a09a0d54ed4a
parente76fc83959686d0a77343dd29371a232d1973a1e (diff)
downloadFH-Wetter-9b75646e386074fae0bc6002a0d32eaaa7fb0d95.tar.xz
Dateien können jetzt komprimiert abgespeichert werden
-rw-r--r--.gitignore2
-rw-r--r--fhunit.pas42
-rw-r--r--pegelunit.pas47
-rw-r--r--wetter.konf4
-rw-r--r--wetter.lps121
5 files changed, 106 insertions, 110 deletions
diff --git a/.gitignore b/.gitignore
index 8893041..18c24c9 100644
--- a/.gitignore
+++ b/.gitignore
@@ -9,3 +9,5 @@ Log*
socket
*.txt
*.txt.save
+*.txt.gz
+*.txt.gz.save
diff --git a/fhunit.pas b/fhunit.pas
index bfd6899..3c7aec6 100644
--- a/fhunit.pas
+++ b/fhunit.pas
@@ -110,7 +110,7 @@ const
implementation
-uses unit1, math, systemUnit;
+uses unit1, math, myStringListUnit;
// tMessPunkt ******************************************************************
@@ -450,7 +450,7 @@ end;
procedure tMessPunkte.laden(von: string);
var
- f: textfile;
+ f: tMyStringList;
s: string;
i: longint;
begin
@@ -459,13 +459,15 @@ begin
raise exception.create('Messwertedatei '''+von+''' existiert nicht!');
exit;
end;
- assignfile(f,von);
- reset(f);
- while not eof(f) do begin
- readln(f,s);
+ f:=tMyStringList.create;
+ if rightStr(von,3)='.gz' then
+ f.loadFromGz(von)
+ else
+ f.loadFromFile(von);
+ while f.readln(s) do
werte.add(s);
- end;
- closefile(f);
+ f.free;
+
if length(muts)=0 then begin
setlength(muts,20);
for i:=0 to length(muts)-1 do
@@ -475,23 +477,17 @@ end;
procedure tMessPunkte.speichern(nach: string);
var
- dateischonda: boolean;
- f: textfile;
- i: longint;
+ f: tMyStringList;
+ i: longint;
begin
- dateischonda:=fileexists(nach);
- if dateischonda then
- assignfile(f,mkTemp(nach+'.XXXXXX'))
- else
- assignfile(f,nach);
- rewrite(f);
+ f:=tMyStringList.create;
for i:=0 to werte.count-1 do
- writeln(f,werte[i].schreibe);
- closefile(f);
- if dateischonda then begin
- deletefile(nach);
- rename(f,nach);
- end;
+ f.add(werte[i].schreibe);
+ if rightStr(nach,3)='.gz' then
+ f.saveToGz(nach)
+ else
+ f.saveToFile(nach);
+ f.free;
end;
procedure tMessPunkte.achsenZeichnen(zuZeichnen: tMessGroeszenSet; startZeit,stopZeit: extended);
diff --git a/pegelunit.pas b/pegelunit.pas
index f5951b6..e63a799 100644
--- a/pegelunit.pas
+++ b/pegelunit.pas
@@ -83,7 +83,7 @@ type
implementation
-uses systemunit, math, unit1;
+uses math, unit1, myStringListUnit;
const
pegelStationsNamen: array[tPegelstation] of array[0..1] of string =
@@ -434,7 +434,7 @@ end;
procedure tPegelStaende.laden(von: string);
var
- f: textfile;
+ f: tMyStringList;
s: string;
ps: tPegelstation;
psda,gefunden: boolean;
@@ -445,12 +445,14 @@ begin
raise exception.create('Pegeldatei '''+von+''' existiert nicht!');
exit;
end;
- assignfile(f,von);
- reset(f);
+ f:=tMyStringList.create;
+ if rightStr(von,3)='.gz' then
+ f.loadFromGz(von)
+ else
+ f.loadFromFile(von);
psda:=false;
ps:=low(TPegelstation);
- while not eof(f) do begin
- readln(f,s);
+ while f.readln(s) do begin
if pos('Station: ',s)=1 then begin
delete(s,1,pos(' ',s));
ps:=low(TPegelstation);
@@ -462,7 +464,7 @@ begin
inc(ps);
end;
if not gefunden then begin
- closefile(f);
+ f.free;
writeln('Pegelstation '''+s+''' nicht gefunden '''+Pegelstationsnamen[psSaalfeld,0]+'''!');
raise exception.create('Pegelstation '''+s+''' nicht gefunden '''+Pegelstationsnamen[psSaalfeld,0]+'''!');
end;
@@ -470,39 +472,34 @@ begin
continue;
end;
if not psda then begin
+ f.free;
writeln('Es wurde noch keine Pegelstation erwähnt!');
raise exception.create('Es wurde noch keine Pegelstation erwähnt!');
end;
werte[ps].add(s);
end;
- closefile(f);
+ f.free;
if not assigned(put) then
put:=tPegelUpdateThread.create(self);
end;
procedure tPegelStaende.speichern(nach: string);
var
- dateischonda: boolean;
- f: textfile;
- ps: tPegelStation;
- i: longint;
+ f: tMyStringList;
+ ps: tPegelStation;
+ i: longint;
begin
- dateischonda:=fileexists(nach);
- if dateischonda then
- assignfile(f,mkTemp(nach+'.XXXXXX'))
- else
- assignfile(f,nach);
- rewrite(f);
+ f:=tMyStringList.create;
for ps:=low(tPegelStation) to high(tPegelStation) do begin
- writeln(f,'Station: '+Pegelstationsnamen[ps,0]);
+ f.add('Station: '+Pegelstationsnamen[ps,0]);
for i:=0 to werte[ps].Count-1 do
- writeln(f,werte[ps][i].schreibe);
- end;
- closefile(f);
- if dateischonda then begin
- deletefile(nach);
- rename(f,nach);
+ f.add(werte[ps][i].schreibe);
end;
+ if rightStr(nach,3)='.gz' then
+ f.saveToGz(nach)
+ else
+ f.saveToFile(nach);
+ f.free;
end;
procedure tPegelStaende.achsenZeichnen(zuZeichnen: tPegelStationsSet; startZeit,stopZeit: extended);
diff --git a/wetter.konf b/wetter.konf
index 264a14e..36c71f9 100644
--- a/wetter.konf
+++ b/wetter.konf
@@ -1,4 +1,4 @@
pidDatei: /tmp/wetter.pid
-wetterDatei: letztes_Wetter.txt
-pegelDatei: letzte_Pegel.txt
+wetterDatei: letztes_Wetter.txt.gz
+pegelDatei: letzte_Pegel.txt.gz
datenZeitRaum: 7*4
diff --git a/wetter.lps b/wetter.lps
index 9effad0..6563059 100644
--- a/wetter.lps
+++ b/wetter.lps
@@ -34,25 +34,23 @@
<Filename Value="fhunit.pas"/>
<IsPartOfProject Value="True"/>
<EditorIndex Value="2"/>
- <TopLine Value="441"/>
- <CursorPos X="70" Y="473"/>
+ <TopLine Value="445"/>
+ <CursorPos Y="476"/>
<UsageCount Value="44"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
<Filename Value="original/Unit1.pas"/>
- <EditorIndex Value="4"/>
- <TopLine Value="664"/>
- <CursorPos Y="678"/>
+ <EditorIndex Value="-1"/>
+ <TopLine Value="1043"/>
+ <CursorPos X="5" Y="1083"/>
<UsageCount Value="22"/>
- <Loaded Value="True"/>
</Unit4>
<Unit5>
<Filename Value="pegelunit.pas"/>
- <IsVisibleTab Value="True"/>
<EditorIndex Value="3"/>
- <TopLine Value="447"/>
- <CursorPos X="48" Y="477"/>
+ <TopLine Value="78"/>
+ <CursorPos X="20" Y="86"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
</Unit5>
@@ -88,9 +86,12 @@
</Unit9>
<Unit10>
<Filename Value="../units/mystringlistunit.pas"/>
- <EditorIndex Value="-1"/>
- <CursorPos X="47" Y="8"/>
- <UsageCount Value="8"/>
+ <IsVisibleTab Value="True"/>
+ <EditorIndex Value="4"/>
+ <TopLine Value="11"/>
+ <CursorPos X="6" Y="46"/>
+ <UsageCount Value="10"/>
+ <Loaded Value="True"/>
</Unit10>
<Unit11>
<Filename Value="../units/lowlevelunit.pas"/>
@@ -111,123 +112,123 @@
<JumpHistory Count="30" HistoryIndex="29">
<Position1>
<Filename Value="unit1.pas"/>
- <Caret Line="194" Column="30" TopLine="174"/>
+ <Caret Line="188" Column="60" TopLine="168"/>
</Position1>
<Position2>
<Filename Value="unit1.pas"/>
- <Caret Line="195" Column="30" TopLine="175"/>
+ <Caret Line="179" TopLine="174"/>
</Position2>
<Position3>
<Filename Value="unit1.pas"/>
- <Caret Line="196" Column="30" TopLine="176"/>
+ <Caret Line="7" Column="34"/>
</Position3>
<Position4>
- <Filename Value="unit1.pas"/>
- <Caret Line="197" Column="30" TopLine="177"/>
+ <Filename Value="pegelunit.pas"/>
+ <Caret Line="552" TopLine="523"/>
</Position4>
<Position5>
- <Filename Value="unit1.pas"/>
- <Caret Line="200" Column="3" TopLine="173"/>
+ <Filename Value="fhunit.pas"/>
+ <Caret Line="599" TopLine="572"/>
</Position5>
<Position6>
- <Filename Value="unit1.pas"/>
- <Caret Line="11" Column="35"/>
+ <Filename Value="fhunit.pas"/>
+ <Caret Line="91" Column="14" TopLine="79"/>
</Position6>
<Position7>
- <Filename Value="unit1.pas"/>
- <Caret Line="8" Column="3"/>
+ <Filename Value="pegelunit.pas"/>
+ <Caret Line="81" Column="14" TopLine="60"/>
</Position7>
<Position8>
<Filename Value="unit1.pas"/>
- <Caret Line="173" Column="3" TopLine="153"/>
+ <Caret Line="244" TopLine="211"/>
</Position8>
<Position9>
- <Filename Value="unit1.pas"/>
- <Caret Line="7" Column="34"/>
+ <Filename Value="fhunit.pas"/>
+ <Caret Line="614" TopLine="582"/>
</Position9>
<Position10>
- <Filename Value="unit1.pas"/>
- <Caret Line="186" Column="3" TopLine="162"/>
+ <Filename Value="fhunit.pas"/>
+ <Caret Line="92" Column="15" TopLine="79"/>
</Position10>
<Position11>
<Filename Value="unit1.pas"/>
- <Caret Line="189" Column="74" TopLine="189"/>
+ <Caret Line="241" Column="15" TopLine="221"/>
</Position11>
<Position12>
<Filename Value="unit1.pas"/>
- <Caret Line="188" Column="60" TopLine="168"/>
+ <Caret Line="243" Column="27" TopLine="223"/>
</Position12>
<Position13>
<Filename Value="unit1.pas"/>
- <Caret Line="179" TopLine="174"/>
+ <Caret Line="244" Column="13" TopLine="224"/>
</Position13>
<Position14>
- <Filename Value="unit1.pas"/>
- <Caret Line="7" Column="34"/>
+ <Filename Value="fhunit.pas"/>
+ <Caret Line="92" Column="13" TopLine="71"/>
</Position14>
<Position15>
- <Filename Value="pegelunit.pas"/>
- <Caret Line="552" TopLine="523"/>
+ <Filename Value="fhunit.pas"/>
+ <Caret Line="621" Column="69" TopLine="594"/>
</Position15>
<Position16>
<Filename Value="fhunit.pas"/>
- <Caret Line="599" TopLine="572"/>
+ <Caret Line="101" TopLine="78"/>
</Position16>
<Position17>
<Filename Value="fhunit.pas"/>
- <Caret Line="91" Column="14" TopLine="79"/>
+ <Caret Line="626" TopLine="606"/>
</Position17>
<Position18>
- <Filename Value="pegelunit.pas"/>
- <Caret Line="81" Column="14" TopLine="60"/>
+ <Filename Value="fhunit.pas"/>
+ <Caret Line="100" Column="26" TopLine="78"/>
</Position18>
<Position19>
- <Filename Value="unit1.pas"/>
- <Caret Line="244" TopLine="211"/>
+ <Filename Value="fhunit.pas"/>
+ <Caret Line="108" Column="23" TopLine="100"/>
</Position19>
<Position20>
<Filename Value="fhunit.pas"/>
- <Caret Line="614" TopLine="582"/>
+ <Caret Line="462" Column="27" TopLine="433"/>
</Position20>
<Position21>
<Filename Value="fhunit.pas"/>
- <Caret Line="92" Column="15" TopLine="79"/>
+ <Caret Line="453" Column="6" TopLine="433"/>
</Position21>
<Position22>
- <Filename Value="unit1.pas"/>
- <Caret Line="241" Column="15" TopLine="221"/>
+ <Filename Value="fhunit.pas"/>
+ <Caret Line="113" Column="47" TopLine="98"/>
</Position22>
<Position23>
- <Filename Value="unit1.pas"/>
- <Caret Line="243" Column="27" TopLine="223"/>
+ <Filename Value="fhunit.pas"/>
+ <Caret Line="491" TopLine="464"/>
</Position23>
<Position24>
- <Filename Value="unit1.pas"/>
- <Caret Line="244" Column="13" TopLine="224"/>
+ <Filename Value="fhunit.pas"/>
+ <Caret Line="480" Column="6" TopLine="454"/>
</Position24>
<Position25>
- <Filename Value="fhunit.pas"/>
- <Caret Line="92" Column="13" TopLine="71"/>
+ <Filename Value="pegelunit.pas"/>
+ <Caret Line="437" Column="18" TopLine="417"/>
</Position25>
<Position26>
- <Filename Value="fhunit.pas"/>
- <Caret Line="621" Column="69" TopLine="594"/>
+ <Filename Value="pegelunit.pas"/>
+ <Caret Line="86" Column="47" TopLine="78"/>
</Position26>
<Position27>
- <Filename Value="fhunit.pas"/>
- <Caret Line="101" TopLine="78"/>
+ <Filename Value="pegelunit.pas"/>
+ <Caret Line="456" TopLine="438"/>
</Position27>
<Position28>
- <Filename Value="fhunit.pas"/>
- <Caret Line="626" TopLine="606"/>
+ <Filename Value="pegelunit.pas"/>
+ <Caret Line="448" Column="19" TopLine="427"/>
</Position28>
<Position29>
<Filename Value="fhunit.pas"/>
- <Caret Line="100" Column="26" TopLine="78"/>
+ <Caret Line="113" Column="19" TopLine="92"/>
</Position29>
<Position30>
- <Filename Value="fhunit.pas"/>
- <Caret Line="108" Column="23" TopLine="100"/>
+ <Filename Value="pegelunit.pas"/>
+ <Caret Line="490" Column="44" TopLine="483"/>
</Position30>
</JumpHistory>
</ProjectSession>