level 1
贴吧用户_025X6EN
楼主
程序实现的界面
我这个显示界面是Delphi在SQL 2005的基础上设计的,将采集器采集的传感器的数据在界面中显示。
一.根据这个框图对程序设计思路分块进行介绍
二.从这四个功能模块进行介绍1.系统初始化的程序 2.系统自动采集和显示程序3.更新阀值程序4.更改图表中的数据的程序
三.注释下列程序的每一句
程序
adoconn.Connected :=true;
self.tmSample.Enabled :=true;
//开始读入预设值
adods.Connection :=adoconn;
adods.Active :=false;
adods.CommandText :='select * from lv_device order by id ';
adods.Active :=true;
if not adods.Eof then
begin
sdMaxValue.Text := adods.fieldbyname('maxvalue').AsString ;
sdMinValue.Text := adods.fieldbyname('minvalue').AsString ;
end;
adods.Next();
if not adods.Eof then
begin
wdMaxValue.Text := adods.fieldbyname('maxvalue').AsString ;
wdMinValue.Text := adods.fieldbyname('minvalue').AsString ;
end;
adods.Next();
if not adods.Eof then
begin
gzMaxValue.Text := adods.fieldbyname('maxvalue').AsString ;
gzMinValue.Text := adods.fieldbyname('minvalue').AsString ;
end;
adods.Next();
adods.Active :=false;
self.ComboBox1.ItemIndex :=0;
这是系统初始化的代码
var
sd:double;
devicetypeid:integer;
tmp:string;
begin
tmSample.Enabled :=false;
adods.Connection :=adoconn;
adods.Active :=false;
adods.CommandText :='select top 4 * from lv_sampledata order by id desc ';
adods.Active :=true;
while not adods.Eof do
begin
lblTime.Caption :='采集时间: ' + adods.fieldbyname('createtime').AsString +' ' ;
devicetypeid:=adods.fieldbyname('devicetypeid').AsInteger;
case devicetypeid of
1: txtWD.Text := adods.fieldbyname('showvalue').AsString + ' ℃';
2:
begin
sd:= adods.fieldbyname('showvalue').AsFloat*100;
txtSD.Text := floattostr(sd)+ ' %';
end;
3: txtGZ.Text := adods.fieldbyname('showvalue').AsString + ' LUX';
4: self.txtCO2.Text := adods.fieldbyname('showvalue').AsString + ' PPM';
end;
adods.Next
end;
adods.Active :=false;
tmp:=inttostr( self.ComboBox1.ItemIndex +1);
adodschart.Active :=false;
adodschart.Connection :=adoconn;
adodschart.CommandText :='select top 100 showvalue from lv_sampledata where devicetypeid=''' +tmp +''' order by id desc ';
adodschart.Active :=true;
tmSample.Enabled :=true;
这是系统自动采集和显示的代码
adocomm.Connection :=adoconn;
adocomm.CommandText :='update lv_device set maxvalue=''' + trim(wdmaxvalue.Text) +''' ,minvalue=''' + trim(wdminvalue.Text)+''' where devicetypeid=''1''';
adocomm.Execute();
adocomm.Connection :=adoconn;
adocomm.CommandText :='update lv_device set maxvalue=''' + trim(sdmaxvalue.Text) +''' ,minvalue=''' + trim(sdminvalue.Text)+''' where devicetypeid=''2''';
adocomm.Execute();
adocomm.Connection :=adoconn;
adocomm.CommandText :='update lv_device set maxvalue=''' + trim(gzmaxvalue.Text) +''' ,minvalue=''' + trim(gzminvalue.Text)+''' where devicetypeid=''3''';
adocomm.Execute();
showmessage('数据更新完毕');
这是更新阀值的代码
var
tmp:string;
begin
tmp:=inttostr( self.ComboBox1.ItemIndex +1);
adodschart.Active :=false;
adodschart.Connection :=adoconn;
adodschart.CommandText :='select top 100 showvalue from lv_sampledata where devicetypeid=''' +tmp +''' order by id desc ';
adodschart.Active :=true;
end;
这是更改图表中的数据的代码
2014年05月06日 14点05分
1
我这个显示界面是Delphi在SQL 2005的基础上设计的,将采集器采集的传感器的数据在界面中显示。
一.根据这个框图对程序设计思路分块进行介绍
二.从这四个功能模块进行介绍1.系统初始化的程序 2.系统自动采集和显示程序3.更新阀值程序4.更改图表中的数据的程序
三.注释下列程序的每一句
程序
adoconn.Connected :=true;
self.tmSample.Enabled :=true;
//开始读入预设值
adods.Connection :=adoconn;
adods.Active :=false;
adods.CommandText :='select * from lv_device order by id ';
adods.Active :=true;
if not adods.Eof then
begin
sdMaxValue.Text := adods.fieldbyname('maxvalue').AsString ;
sdMinValue.Text := adods.fieldbyname('minvalue').AsString ;
end;
adods.Next();
if not adods.Eof then
begin
wdMaxValue.Text := adods.fieldbyname('maxvalue').AsString ;
wdMinValue.Text := adods.fieldbyname('minvalue').AsString ;
end;
adods.Next();
if not adods.Eof then
begin
gzMaxValue.Text := adods.fieldbyname('maxvalue').AsString ;
gzMinValue.Text := adods.fieldbyname('minvalue').AsString ;
end;
adods.Next();
adods.Active :=false;
self.ComboBox1.ItemIndex :=0;
这是系统初始化的代码
var
sd:double;
devicetypeid:integer;
tmp:string;
begin
tmSample.Enabled :=false;
adods.Connection :=adoconn;
adods.Active :=false;
adods.CommandText :='select top 4 * from lv_sampledata order by id desc ';
adods.Active :=true;
while not adods.Eof do
begin
lblTime.Caption :='采集时间: ' + adods.fieldbyname('createtime').AsString +' ' ;
devicetypeid:=adods.fieldbyname('devicetypeid').AsInteger;
case devicetypeid of
1: txtWD.Text := adods.fieldbyname('showvalue').AsString + ' ℃';
2:
begin
sd:= adods.fieldbyname('showvalue').AsFloat*100;
txtSD.Text := floattostr(sd)+ ' %';
end;
3: txtGZ.Text := adods.fieldbyname('showvalue').AsString + ' LUX';
4: self.txtCO2.Text := adods.fieldbyname('showvalue').AsString + ' PPM';
end;
adods.Next
end;
adods.Active :=false;
tmp:=inttostr( self.ComboBox1.ItemIndex +1);
adodschart.Active :=false;
adodschart.Connection :=adoconn;
adodschart.CommandText :='select top 100 showvalue from lv_sampledata where devicetypeid=''' +tmp +''' order by id desc ';
adodschart.Active :=true;
tmSample.Enabled :=true;
这是系统自动采集和显示的代码
adocomm.Connection :=adoconn;
adocomm.CommandText :='update lv_device set maxvalue=''' + trim(wdmaxvalue.Text) +''' ,minvalue=''' + trim(wdminvalue.Text)+''' where devicetypeid=''1''';
adocomm.Execute();
adocomm.Connection :=adoconn;
adocomm.CommandText :='update lv_device set maxvalue=''' + trim(sdmaxvalue.Text) +''' ,minvalue=''' + trim(sdminvalue.Text)+''' where devicetypeid=''2''';
adocomm.Execute();
adocomm.Connection :=adoconn;
adocomm.CommandText :='update lv_device set maxvalue=''' + trim(gzmaxvalue.Text) +''' ,minvalue=''' + trim(gzminvalue.Text)+''' where devicetypeid=''3''';
adocomm.Execute();
showmessage('数据更新完毕');
这是更新阀值的代码
var
tmp:string;
begin
tmp:=inttostr( self.ComboBox1.ItemIndex +1);
adodschart.Active :=false;
adodschart.Connection :=adoconn;
adodschart.CommandText :='select top 100 showvalue from lv_sampledata where devicetypeid=''' +tmp +''' order by id desc ';
adodschart.Active :=true;
end;
这是更改图表中的数据的代码