diff options
author | Erich Eckner <git@eckner.net> | 2015-11-17 13:31:40 +0100 |
---|---|---|
committer | Erich Eckner <git@eckner.net> | 2015-11-17 13:31:40 +0100 |
commit | b80559044ffc627e897bba6df2c15c1b28d732de (patch) | |
tree | 65b77f7cf8347c98744405982bb383e8849e527a /unit1.pas | |
parent | b861e26f594e1fd8472d513430da1296eed023ba (diff) | |
download | FH-Wetter-b80559044ffc627e897bba6df2c15c1b28d732de.tar.xz |
soweit lauffähig
ToDo: Taskbaricon
Diffstat (limited to 'unit1.pas')
-rw-r--r-- | unit1.pas | 53 |
1 files changed, 39 insertions, 14 deletions
@@ -3,7 +3,8 @@ unit Unit1; interface uses - Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, pegelUnit; + Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls, + pegelUnit, fhUnit, lowLevelUnit; type @@ -17,9 +18,10 @@ type procedure FormDestroy(Sender: TObject); private { private declarations } - datenZeitRaum: extended; - pegel: tPegelStaende; - pegelDatei: string; + datenZeitRaum: extended; + pegel: tPegelStaende; + wetter: tMessPunkte; + pegelDatei,wetterDatei: string; public { public declarations } procedure zeichnen; @@ -31,10 +33,7 @@ var fehler: boolean; const - - DateiName = 'letztes_Wetter.txt'; - PegelDateiName = 'letzte_Pegel.txt'; - anzDaten = 7*24*6*4; + bufLengMin = 1024*1024; (* @@ -49,14 +48,16 @@ function letzterMonat(t: TDateTime): TPoint; // x=Monat, y=Jahr function MyIntToStr(I,Ziff: longint): string; *) -function wertZuX(w: extended; startZeit,stopZeit: extended; breite: longint): longint; -function wertZuY(w: extended; miMa: tPoint; hoehe: longint): longint; +function wertZuX(w: extended; startZeit,stopZeit: extended; breite: longint): longint; inline; +function wertZuY(w: extended; miMa: tPoint; hoehe: longint): longint; inline; overload; +function wertZuY(w: extended; miMa: tExtPoint; hoehe: longint): longint; inline; overload; +function wertZuY(w: extended; mi,ma: extended; hoehe: longint): longint; inline; overload; implementation {$R *.lfm} -uses process, myStringListUnit, lowLevelUnit, systemUnit, matheunit, math; +uses process, myStringListUnit, systemUnit, matheunit, math; { TForm1 } @@ -67,17 +68,18 @@ var fi: textfile; args: array of string; begin + fehler:=true; __ausgabenMaske:=1; pidDatei:=''; pegelDatei:=''; datenZeitRaum:=1; - fehler:=true; s:=extractfilepath(application.exename)+'wetter.konf'; t:=''; if not fileexists(s) then raise exception.create('Kann Konfigurationsdatei '''+s+''' nicht finden!'); pegel:=tPegelStaende.create(image1); + wetter:=tMessPunkte.create(image1); f:=tMyStringList.create; f.loadFromFile(s); f.unfoldMacros; @@ -118,6 +120,13 @@ begin pegel.laden(pegelDatei); continue; end; + if startetMit('wetterDatei:',s) then begin + wetterDatei:=s; + if pos('/',wetterDatei)=0 then + wetterDatei:=extractFilePath(application.exename)+wetterDatei; + wetter.laden(wetterDatei); + continue; + end; if startetMit('datenZeitRaum:',s) then begin datenZeitRaum:=exprtofloat(false,s,nil,nil); continue; @@ -136,6 +145,7 @@ end; procedure TForm1.FormClose(Sender: TObject; var CloseAction: TCloseAction); begin pegel.putBeenden; + wetter.mutBeenden; end; procedure TForm1.FormDestroy(Sender: TObject); @@ -145,8 +155,11 @@ begin if not fehler then begin if pegelDatei<>'' then pegel.speichern(pegelDatei); + if wetterDatei<>'' then + wetter.speichern(wetterDatei); end; pegel.free; + wetter.free; end; procedure TForm1.zeichnen; @@ -160,6 +173,7 @@ begin startZeit:=stopZeit-datenZeitRaum; pegel.achsenZeichnen([psRudolstadt,psRothenstein],startZeit,stopZeit); + wetter.achsenZeichnen([mgTemperatur],startZeit,stopZeit); image1.canvas.pen.color:=$000000; tmp:=floor(startZeit); @@ -170,6 +184,7 @@ begin end; pegel.graphenZeichnen([psRudolstadt,psRothenstein],now-datenZeitRaum,now); + wetter.graphenZeichnen([mgTemperatur,mgLuftfeuchte,mgNiederschlag,mgGlobalstrahlung,mgLuftdruck],now-datenZeitRaum,now); fehler:=false; end; @@ -182,12 +197,22 @@ var tmp: extended; begin tmp:=(w-startZeit)/(stopZeit-startZeit); - result:=round(-breite*ln(1+tmp*(exp(-xScale)-1))/xScale); + result:=1+round(-(breite-2)*ln(1+tmp*(exp(-xScale)-1))/xScale); end; function wertZuY(w: extended; miMa: tPoint; hoehe: longint): longint; begin - result:=round((w-miMa.x)/(miMa.y-miMa.x)*hoehe); + result:=wertZuY(w,miMa.x,miMa.y,hoehe); +end; + +function wertZuY(w: extended; miMa: tExtPoint; hoehe: longint): longint; +begin + result:=wertZuY(w,miMa['x'],miMa['y'],hoehe); +end; + +function wertZuY(w: extended; mi,ma: extended; hoehe: longint): longint; +begin + result:=hoehe-1-round((w-mi)/(ma-mi)*(hoehe-2)); end; end. |