unit Unit1 interface uses Windows Messages SysUtils Variants Classes G

  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
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, TeEngine, Series, TeeProcs, Chart, StdCtrls, ComCtrls,
Menus, Grids;
type
TForm1 = class(TForm)
Timer1: TTimer;
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
N6: TMenuItem;
N7: TMenuItem;
Label6: TLabel;
PageControl1: TPageControl;
TabSheet3: TTabSheet;
Image2: TImage;
TabSheet4: TTabSheet;
Image3: TImage;
TabSheet5: TTabSheet;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label7: TLabel;
Label8: TLabel;
Label9: TLabel;
Label10: TLabel;
Label11: TLabel;
Label12: TLabel;
Label13: TLabel;
Button7: TButton;
Button2: TButton;
Button3: TButton;
Edit1: TEdit;
Edit2: TEdit;
Edit3: TEdit;
Edit4: TEdit;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
Edit8: TEdit;
Edit9: TEdit;
Edit10: TEdit;
ComboBox1: TComboBox;
ComboBox2: TComboBox;
ComboBox3: TComboBox;
ComboBox4: TComboBox;
ComboBox5: TComboBox;
TabSheet11: TTabSheet;
Chart1: TChart;
Series1: TLineSeries;
TabSheet14: TTabSheet;
Memo2: TMemo;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
CheckBox4: TCheckBox;
CheckBox5: TCheckBox;
StringGrid1: TStringGrid;
Chart2: TChart;
Series2: TLineSeries;
Label1: TLabel;
ComboBox6: TComboBox;
RadioGroup1: TRadioGroup;
Label2: TLabel;
Edit11: TEdit;
procedure Button1Click(Sender: TObject);
procedure Timer1Timer(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Button6Click(Sender: TObject);
procedure Button7Click(Sender: TObject);
procedure N7Click(Sender: TObject);
procedure TabSheet11Show(Sender: TObject);
procedure ComboBox6Change(Sender: TObject);
procedure Edit11Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
glob,kk,ged,Port1:byte;
tc,co:real;
MyDIR:string;
toc:integer;
Data1,Data2,Data3:array of double;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
form1.Close;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
var
tcx,N,i:integer;
cox:real;
d:string;
begin
if kk<120 then
if glob=1 then
begin
tcx:= round(tc+(random)*6);
cox:= round((co/100+(random)*0.05)*10000)/10000;
kk:=kk+1;
chart1.Series[0].Clear;
Data1[toc-1]:=round(18+(random)*8);
chart1.Series[0].AddArray(Data1);
if combobox6.text='Графік зміни температури' then
begin
stringgrid1.Cells[1,0]:='Дата';
stringgrid1.Cells[2,0]:='Темп.';
stringgrid1.Cells[1,toc]:=datetostr(Date)+' '+timetostr(time);
stringgrid1.Cells[2,toc]:=floattostr(Data1[toc-1])+' °С';
end;
chart2.Series[0].Clear;
Data2[toc-1]:=round(70+(random)*10);
chart2.Series[0].AddArray(Data2);
if combobox6.text='Графік зміни вологості' then
begin
stringgrid1.Cells[1,0]:='Дата';
stringgrid1.Cells[2,0]:='Волог.';
stringgrid1.Cells[1,toc]:=datetostr(Date)+' '+timetostr(time);
stringgrid1.Cells[2,toc]:=floattostr(Data2[toc-1])+' %';
end;
///////////
with image3.Canvas do begin
Font.Name := 'Tahoma';
Font.Size := 20;
Brush.Style := bsClear; // область вывода текста не закраши-
brush.Color:=clMoneyGreen;
Rectangle(50,155,50,155);
TextOut(50,155, floattostr(Data2[toc-1])+'%'); //'83.7');
TextOut(50,480, floattostr(Data1[toc-1])+'°С');
///
TextOut(201,193, floattostr(60+round(random*200)/10)+'°С');
TextOut(201,255, floattostr(20+round(random*200)/10)+'°С');
TextOut(201,447, floattostr(60+round(random*200)/10)+'°С');
TextOut(201,503, floattostr(20+round(random*200)/10)+'°С');
end;
toc:=toc+1;
end;
end;
function iDdev(var ii:byte):byte;
begin
if ii<1 then
iDdev:=0
else
if ii<3 then iDdev:=Port1;
end;
procedure GetInput(var ii:byte);
var
i,j:integer;
s:string;
begin
if length(inttostr(ged))=2 then
begin
ged:=ii+1;
for i:=1 to (kk+ged) do
begin
Data1[i]:=iDdev(Port1);
end;
end;
end;
procedure MyIdGet();
var
s:string;
begin
GetInput(kk);
if Data1[0]>256 then
begin
s:='Датчик працює коректно';
end
else
s:='Датчик працює не коректно';
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
glob:=0;
kk:=0;
tc:=0;
co:=0;
toc:=1;
Ged:=1;
MyDIR:=ExtractFileDir(Application.ExeName);
//richedit1.Lines.LoadFromFile(MyDIR+'\about.txt');
SetLength(Data1,120);
SetLength(Data2,120);
SetLength(Data3,120);
end;
procedure TForm1.Button6Click(Sender: TObject);
begin
glob:=2;
kk:=0;
end;
procedure TForm1.Button7Click(Sender: TObject);
begin
glob:=1;
kk:=0;
randomize;
GetInput(kk);
end;
procedure TForm1.N7Click(Sender: TObject);
begin
form1.Close;
end;
procedure TForm1.TabSheet11Show(Sender: TObject);
begin
if toc>1 then
begin
chart1.Visible:=true;
label1.Caption:='Графік зміни температури';
end
else label1.Caption:='Зачекайте! Проводиться налаштування датчика.';
end;
procedure TForm1.ComboBox6Change(Sender: TObject);
var
i,j:integer;
begin
toc:=1;
if combobox6.text='Графік зміни температури' then
begin
for i:=1 to 2 do
for j:=0 to 150 do
stringgrid1.Cells[i,j]:='';
chart1.Visible:=true;
chart2.Visible:=false;
label1.caption:='Графік зміни температури';
chart1.Series[0].Clear;
end;
if combobox6.text='Графік зміни вологості' then
begin
for i:=1 to 2 do
for j:=0 to 150 do
stringgrid1.Cells[i,j]:='';
chart2.Visible:=true;
chart1.Visible:=false;
label1.caption:='Графік зміни вологості';
chart2.Series[0].Clear;
end;
end;
procedure TForm1.Edit11Change(Sender: TObject);
var
interr:integer;
begin
if edit11.text<>'' then
begin
MyIdGet();
interr:=strtoint(edit11.Text);
timer1.Interval:=interr*1000;
end;
end;
end.