unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, jpeg, ExtCtrls, StdCtrls, ComCtrls, inifiles, MPlayer, Grids;
type
TForm1 =
class(TForm)
Label21: TLabel;
Label23: TLabel;
Timer1: TTimer;
Label26: TLabel;
Timer2: TTimer;
MediaPlayer1: TMediaPlayer;
PageControl1: TPageControl;
Eingaben: TTabSheet;
Felder: TTabSheet;
Dorf: TTabSheet;
Wecker: TTabSheet;
GroupBox1: TGroupBox;
Image6: TImage;
Image7: TImage;
Image8: TImage;
Image9: TImage;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Eingabe: TGroupBox;
Image2: TImage;
Image4: TImage;
Image1: TImage;
Image3: TImage;
Label1: TLabel;
Label2: TLabel;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Image10: TImage;
Image11: TImage;
Image12: TImage;
Image13: TImage;
RadioButton1: TRadioButton;
RadioButton2: TRadioButton;
RadioButton3: TRadioButton;
RadioButton4: TRadioButton;
Label13: TLabel;
TrackBar1: TTrackBar;
Label9: TLabel;
Label11: TLabel;
Label12: TLabel;
Label10: TLabel;
GroupBox2: TGroupBox;
Label14: TLabel;
Label15: TLabel;
Label16: TLabel;
Label17: TLabel;
Label18: TLabel;
Label19: TLabel;
Label20: TLabel;
Button1: TButton;
Button2: TButton;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
Label28: TLabel;
Label27: TLabel;
Button3: TButton;
Label24: TLabel;
Label25: TLabel;
Label29: TLabel;
Panel1: TPanel;
Image5: TImage;
Panel2: TPanel;
Image15: TImage;
Panel3: TPanel;
Image14: TImage;
StringGrid1: TStringGrid;
Button4: TButton;
Image16: TImage;
Label22: TLabel;
ComboBox3: TComboBox;
TrackBar2: TTrackBar;
Label30: TLabel;
Label31: TLabel;
Label32: TLabel;
Label33: TLabel;
GroupBox3: TGroupBox;
Label34: TLabel;
Label35: TLabel;
Label36: TLabel;
Label37: TLabel;
Label38: TLabel;
Label39: TLabel;
Label40: TLabel;
Label41: TLabel;
Label42: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure Timer2Timer(Sender: TObject);
procedure ImageChange(Sender: TObject);
procedure Button4Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
bst_H, bst_L, bst_E, bst_G: integer;
zt_H, zt_L, zt_E, zt_G: integer;
pro_H, pro_L, pro_E, pro_G: real;
lvl, dauer, ende_min, ende_h, ende_day: integer;
produkt, zeit, zeit_min, zeit_save:
string;
ini: TIniFile;
implementation
uses Unit2;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
//Daten einlesen
begin
zeit_save:=zeit_min;
if RadioButton1.checked=true
then produkt:='
Lehm';
if RadioButton2.checked=true
then produkt:='
Holz';
if RadioButton3.checked=true
then produkt:='
Getreide';
if RadioButton4.checked=true
then produkt:='
Eisen';
lvl:=TrackBar1.Position;
//Bestand
bst_H:=StrToInt(Edit5.text);
bst_L:=StrToInt(Edit6.text);
bst_E:=StrToInt(Edit7.text);
bst_G:=StrToInt(Edit8.text);
//Produktion
pro_H:=StrToFloat(Edit1.text);
pro_L:=StrToFloat(Edit2.text);
pro_E:=StrToFloat(Edit3.text);
pro_G:=StrToFloat(Edit4.text);
ini:=TIniFile.Create(ExtractFilePath(ParamStr(0))+'
werte.ini');
ini.WriteInteger('
values','
bst_H',bst_H);
ini.WriteInteger('
values','
bst_L',bst_L);
ini.WriteInteger('
values','
bst_E',bst_E);
ini.WriteInteger('
values','
bst_G',bst_G);
ini.WriteInteger('
values','
pro_H',StrToInt(Edit1.text));
ini.WriteInteger('
values','
pro_L',StrToInt(Edit2.text));
ini.WriteInteger('
values','
pro_E',StrToInt(Edit3.text));
ini.WriteInteger('
values','
pro_G',StrToInt(Edit4.text));
ini.free;
if produkt='
Holz'
then //"Holz" StringBelegung
begin
StringGrid1.Cells[1,1]:='
40';
StringGrid1.Cells[2,1]:='
100';
StringGrid1.Cells[3,1]:='
50';
StringGrid1.Cells[4,1]:='
60';
.
.
.
StringGrid1.Cells[1,10]:='
4040';
StringGrid1.Cells[2,10]:='
10105';
StringGrid1.Cells[3,10]:='
5050';
StringGrid1.Cells[4,10]:='
6060';
end;
if produkt='
Lehm'
then //"Holz" StringBelegung
begin
StringGrid1.Cells[1,1]:='
80';
StringGrid1.Cells[2,1]:='
40';
StringGrid1.Cells[3,1]:='
80';
StringGrid1.Cells[4,1]:='
50';
.
.
.
StringGrid1.Cells[1,10]:='
8080';
StringGrid1.Cells[2,10]:='
4040';
StringGrid1.Cells[3,10]:='
8080';
StringGrid1.Cells[4,10]:='
5050';
end;
if produkt='
Getreide'
then //"Holz" StringBelegung
begin
StringGrid1.Cells[1,1]:='
70';
StringGrid1.Cells[2,1]:='
90';
StringGrid1.Cells[3,1]:='
70';
StringGrid1.Cells[4,1]:='
20';
.
.
.
StringGrid1.Cells[1,10]:='
7070';
StringGrid1.Cells[2,10]:='
9095';
StringGrid1.Cells[3,10]:='
7070';
StringGrid1.Cells[4,10]:='
2020';
end;
if produkt='
Eisen'
then //"Holz" StringBelegung
begin
StringGrid1.Cells[1,1]:='
100';
StringGrid1.Cells[2,1]:='
80';
StringGrid1.Cells[3,1]:='
30';
StringGrid1.Cells[4,1]:='
60';
.
.
.
StringGrid1.Cells[1,10]:='
10105';
StringGrid1.Cells[2,10]:='
8080';
StringGrid1.Cells[3,10]:='
3030';
StringGrid1.Cells[4,10]:='
6060';
end;
bst_H:=bst_H-StrToInt(StringGrid1.cells[1,lvl]);
bst_L:=bst_L-StrToInt(StringGrid1.cells[2,lvl]);
bst_E:=bst_E-StrToInt(StringGrid1.cells[3,lvl]);
bst_G:=bst_G-StrToInt(StringGrid1.cells[4,lvl]);
pro_H:=pro_H/60;
//h -> min
pro_L:=pro_L/60;
pro_E:=pro_E/60;
pro_G:=pro_G/60;
zt_H:=Round(bst_H/pro_H)*(-1);
//Defizitszeit (positiv)
zt_L:=Round(bst_L/pro_L)*(-1);
zt_E:=Round(bst_E/pro_E)*(-1);
zt_G:=Round(bst_G/pro_G)*(-1);
//**Größtes Defizit bestimmen**
if (zt_H>=zt_L)
AND (zt_H>=zt_E)
AND (zt_H>=zt_G)
//Holz
then begin
Label14.caption:=IntToStr(zt_H)+'
Minuten';
Label15.caption:='
('+FloatToStr(bst_H)+'
Defizit an Holz)';
Label17.caption:= IntToStr(zt_H
div 60);
Label18.caption:= IntToStr(zt_H-(60*(zt_H
div 60)));
end;
if (zt_L>=zt_H)
AND (zt_L>=zt_E)
AND (zt_L>=zt_G)
//Lehm
then begin
Label14.caption:=IntToStr(zt_L)+'
Minuten';
Label15.caption:='
('+FloatToStr(bst_L)+'
Defizit an Lehm)';
Label17.caption:= IntToStr(zt_L
div 60);
Label18.caption:= IntToStr(zt_L-(60*(zt_L
div 60)));
end;
if (zt_E>=zt_H)
AND (zt_E>=zt_L)
AND (zt_E>=zt_G)
//Eisen
then begin
Label14.caption:=IntToStr(zt_E)+'
Minuten';
Label15.caption:='
('+FloatToStr(bst_E)+'
Defizit an Eisen)';
Label17.caption:= IntToStr(zt_E
div 60);
Label18.caption:= IntToStr(zt_E-(60*(zt_E
div 60)));
end;
if (zt_G>=zt_H)
AND (zt_G>=zt_L)
AND (zt_G>=zt_E)
//Getreide
then begin
Label14.caption:=IntToStr(zt_G)+'
Minuten';
Label15.caption:='
('+FloatToStr(bst_G)+'
Defizit an Getreide)';
Label17.caption:= IntToStr(zt_G
div 60);
Label18.caption:= IntToStr(zt_G-(60*(zt_G
div 60)));
end;
ende_min:=StrToInt(copy(TimeToStr(Now), 4, 2))+StrToInt(Label18.caption);
//Endzeitberechnung
ende_h:=StrToInt(copy(TimeToStr(Now), 0, 2))+StrToInt(Label17.caption);
while ende_min > 59
do
begin
ende_min:=ende_min-60;
ende_h:=ende_h+1;
end;
while ende_h > 24
do
begin
ende_h:=ende_h-24;
ende_day:=ende_day+1;
end;
if (ende_h>0)
AND (ende_min>0)
then
begin
Label24.Caption:='
um '+IntToStr(ende_h)+'
:'+IntToStr(ende_min)+'
:0';
Label25.Caption:='
kann ausgebaut werden';
end;
if ende_day>0
then Label26.caption:='
(in '+IntToStr(ende_day)+'
Tagen)'
else Label26.caption:='
';
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Form2.Visible:=true;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
Label23.caption:=TimeToStr(Now);
end;
procedure TForm1.FormCreate(Sender: TObject);
// Werte aus INI lesen
var k:integer;
begin
StringGrid1.cells[0,0]:='
Level';
for k:=1
to 20
do StringGrid1.Cells[0,k]:=IntToStr(k);
StringGrid1.cells[1,0]:='
Holz';
StringGrid1.cells[2,0]:='
Lehm';
StringGrid1.cells[3,0]:='
Eisen';
StringGrid1.cells[4,0]:='
Getreide';
ende_day:=0;
ini:=TIniFile.Create(ExtractFilePath(ParamStr(0))+'
werte.ini');
Edit5.Text:= IntToStr(ini.ReadInteger('
values','
bst_H',0));
Edit6.Text:= IntToStr(ini.ReadInteger('
values','
bst_L',0));
Edit7.Text:= IntToStr(ini.ReadInteger('
values','
bst_E',0));
Edit8.Text:= IntToStr(ini.ReadInteger('
values','
bst_G',0));
Edit1.Text:= IntToStr(ini.ReadInteger('
values','
pro_H',0));
Edit2.Text:= IntToStr(ini.ReadInteger('
values','
pro_L',0));
Edit3.Text:= IntToStr(ini.ReadInteger('
values','
pro_E',0));
Edit4.Text:= IntToStr(ini.ReadInteger('
values','
pro_G',0));
ini.free;
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
Timer2.Enabled:=true;
Label29.Caption:='
[aktiviert]';
end;
procedure TForm1.Timer2Timer(Sender: TObject);
begin
if TimeToStr(Now)=Combobox1.text+'
:'+ComboBox2.text+'
:00'
then begin
Label29.caption:='
';
MediaPlayer1.Play;
end;
end;
procedure TForm1.ImageChange(Sender: TObject);
begin
Image16.Picture.LoadFromFile('
pics\'+Combobox3.text+'
.jpg');
Label22.Caption:=Combobox3.Text;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
zeit_save:=zeit_min;
produkt:=ComboBox3.Text;
lvl:=TrackBar2.Position;
//Bestand
bst_H:=StrToInt(Edit5.text);
bst_L:=StrToInt(Edit6.text);
bst_E:=StrToInt(Edit7.text);
bst_G:=StrToInt(Edit8.text);
//Produktion
pro_H:=StrToFloat(Edit1.text);
pro_L:=StrToFloat(Edit2.text);
pro_E:=StrToFloat(Edit3.text);
pro_G:=StrToFloat(Edit4.text);
ini:=TIniFile.Create(ExtractFilePath(ParamStr(0))+'
werte.ini');
ini.WriteInteger('
values','
bst_H',bst_H);
ini.WriteInteger('
values','
bst_L',bst_L);
ini.WriteInteger('
values','
bst_E',bst_E);
ini.WriteInteger('
values','
bst_G',bst_G);
ini.WriteInteger('
values','
pro_H',StrToInt(Edit1.text));
ini.WriteInteger('
values','
pro_L',StrToInt(Edit2.text));
ini.WriteInteger('
values','
pro_E',StrToInt(Edit3.text));
ini.WriteInteger('
values','
pro_G',StrToInt(Edit4.text));
ini.free;
if produkt='
Akademie'
then //"Holz" StringBelegung
begin
StringGrid1.Cells[1,1]:='
220';
StringGrid1.Cells[2,1]:='
160';
StringGrid1.Cells[3,1]:='
90';
StringGrid1.Cells[4,1]:='
40';
.
.
.
StringGrid1.Cells[1,20]:='
23955';
StringGrid1.Cells[2,20]:='
17420';
StringGrid1.Cells[3,20]:='
9800';
StringGrid1.Cells[4,20]:='
4355';
end;
bst_H:=bst_H-StrToInt(StringGrid1.cells[1,lvl]);
bst_L:=bst_L-StrToInt(StringGrid1.cells[2,lvl]);
bst_E:=bst_E-StrToInt(StringGrid1.cells[3,lvl]);
bst_G:=bst_G-StrToInt(StringGrid1.cells[4,lvl]);
pro_H:=pro_H/60;
//h -> min
pro_L:=pro_L/60;
pro_E:=pro_E/60;
pro_G:=pro_G/60;
zt_H:=Round(bst_H/pro_H)*(-1);
//Defizitszeit (positiv)
zt_L:=Round(bst_L/pro_L)*(-1);
zt_E:=Round(bst_E/pro_E)*(-1);
zt_G:=Round(bst_G/pro_G)*(-1);
//**Größtes Defizit bestimmen**
if (zt_H>=zt_L)
AND (zt_H>=zt_E)
AND (zt_H>=zt_G)
//Holz
then begin
Label34.caption:=IntToStr(zt_H)+'
Minuten';
Label35.caption:='
('+FloatToStr(bst_H)+'
Defizit an Holz)';
Label37.caption:= IntToStr(zt_H
div 60);
Label38.caption:= IntToStr(zt_H-(60*(zt_H
div 60)));
end;
if (zt_L>=zt_H)
AND (zt_L>=zt_E)
AND (zt_L>=zt_G)
//Lehm
then begin
Label34.caption:=IntToStr(zt_L)+'
Minuten';
Label35.caption:='
('+FloatToStr(bst_L)+'
Defizit an Lehm)';
Label37.caption:= IntToStr(zt_L
div 60);
Label38.caption:= IntToStr(zt_L-(60*(zt_L
div 60)));
end;
if (zt_E>=zt_H)
AND (zt_E>=zt_L)
AND (zt_E>=zt_G)
//Eisen
then begin
Label34.caption:=IntToStr(zt_E)+'
Minuten';
Label35.caption:='
('+FloatToStr(bst_E)+'
Defizit an Eisen)';
Label37.caption:= IntToStr(zt_E
div 60);
Label38.caption:= IntToStr(zt_E-(60*(zt_E
div 60)));
end;
if (zt_G>=zt_H)
AND (zt_G>=zt_L)
AND (zt_G>=zt_E)
//Getreide
then begin
Label34.caption:=IntToStr(zt_G)+'
Minuten';
Label35.caption:='
('+FloatToStr(bst_G)+'
Defizit an Getreide)';
Label37.caption:= IntToStr(zt_G
div 60);
Label38.caption:= IntToStr(zt_G-(60*(zt_G
div 60)));
end;
ende_min:=StrToInt(copy(TimeToStr(Now), 4, 2))+StrToInt(Label38.caption);
//Endzeitberechnung
ende_h:=StrToInt(copy(TimeToStr(Now), 0, 2))+StrToInt(Label37.caption);
while ende_min > 59
do
begin
ende_min:=ende_min-60;
ende_h:=ende_h+1;
end;
while ende_h > 24
do
begin
ende_h:=ende_h-24;
ende_day:=ende_day+1;
end;
if (ende_h>0)
AND (ende_min>0)
then
begin
Label41.Caption:='
um '+IntToStr(ende_h)+'
:'+IntToStr(ende_min)+'
:0';
Label42.Caption:='
kann ausgebaut werden';
end;
if ende_day>0
then Label26.caption:='
(in '+IntToStr(ende_day)+'
Tagen)'
else Label26.caption:='
';
end;
end.