Var
Form1: TForm1;
t:Integer;
i:Integer;
opros:Array[9..40]of Integer;
znac,tek:array[1..3]of Real;
//opros-ïåðèîä îïðîñà äàò÷èêà
//znac- èçìåðåííîå çíà÷åíèå äàò÷èêîì
//tek- âûîäèìîå çíà÷åíèå äàò÷èêîì
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
randomize;//ñáðàñûâàåò àëãîðèòìû ñëó÷àéíûõ ÷èñåë;
for i:=3 to 1 do opros[i]:=random(10)+3;
znac[1]:=Random(40);// ãåí ñë ÷èñëà îò 0..40
znac[2]:=Random(40)-10;// ãåí ñë ÷èñëà îò 30..9
znac[3]:=Random(400)-100/100;// ãåí ñë ÷èñëà îò 3..0
tek[1]:=znac[1];
tek[2]:=znac[2];
tek[3]:=znac[3];
with stringgrid1 do
begin
cells[0,0]:='Òåêóùåå âðåìÿ';
cells[1,0]:='1 äàò÷èê '+inttostr(opros[1])+' sek';
cells[1,0]:='2 äàò÷èê '+inttostr(opros[2])+' sek';
cells[1,0]:='3 äàò÷èê '+inttostr[opros[3]]+' sek';
end;
end;
procedure TForm1.tmr1Timer(Sender:TObject);
begin
//Òåêóùåå âðåìÿ
t:=t+1;
znac[1]:=Random(40);// ãåí ñë ÷èñëà îò 0..40
znac[2]:=Random(40)-10;// ãåí ñë ÷èñëà îò 30..9
znac[3]:=Random(400)-100/100;// ãåí ñë ÷èñëà îò 3..0
if (t mod opros[1])=0 then tek[1]:=znac[1];
if (t mod opros[2])=0 then tek[2]:=znac[2];
if (t mod opros[3])=0 then tek[3]:=znac[3];
//(400)-10)/10;random ãåíåðèðóåò ñëó÷àéíûå çíà÷åíèÿ îò 1,6,3
with stringgrid1 do
begin
rowcount:= rowcount+1;
cells[0,t]:=inttostr(t)+' cåêóíä';
cells[1,t]:= floattostr(tek[1]);
cells[2,t]:= floattostr(tek[2]);
cells[3,t]:= floattostr(tek[3]);
end;
end;
procedure TForm1.Button1Click(sender:TObject);
begin
Timer1.Enabled:=not timer1.Enabled;
end;
procedure TForm;Button2Click(Sender:TOBJecct);
begin
if timer1.Enabled then
begin
tek[1]:= znac[1];
ShowMessage('Òåêóùåå çíà÷åíèå äàò÷èêà 1'+floattostr(tek[1]));
end
else ShowMessage('ñèñòåìà íå ðàáîòàåò');
procedure TForm1.btn9Click(Sender: TObject);
begin
Timer1.Enabled:=True;
end;
end;
procedure TForm1.btn7Click(Sender: TObject);
begin
if Timer1.Enabled then ShowMessage('Çíà÷åíèå äàò÷èêà 1='+inttostr(tek[1]));
else ShowMessage('Ñèñòåìà íå çàïóùåíà');
end;
procedure TForm1.btn8Click(Sender: TObject);
begin
timer1.Enabled:=True;
end.
помогите пожалуйста с программой в делфи