小弟用delphi作工业控制的采数用!现在怎么实现动态曲线的显示阿?? rt xiexie 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 补充:例如假定原来的信号是周期信号,一个周期是1ms,则你可以把定时器设为1000ms(1秒),这时二者的时间比例为1:1000。你把原信号在1ms内的整个变化,在1秒的时间间隔内依次展开,打点画在窗体的画布canvas上即可。1秒钟画一次,图形显示出来就是动态的。若是非周期信号,则可以取一个较长的时间间隔(能够反映原信号的变化规律),然后依比例用同样方法画出。 同意大羽呵呵,还有一种更省事的画图方法,用chart控件,把转换好的数字量写到数据库中,通过chart和数据库中相应的表、字段关联就行,呵呵 楼上两位有理。因为我没用过Dbchart,所以只会用笨办法。这里抛砖引玉,方知还有Dbchart。度人也度己,好啊! TeeChart,我自己写过的。我的毕业设计就是做的温度数据采集,我用TeeChart做的数据采集,如果你要源码的话。可以和我联系,我先申明啊,是免费的。嘿嘿 用IMAGE的canvas直接画!procedure ImageInit(Fimage: TImage; HdivCount, OdivCount, Amplitude, fcolor: integer; var XScale: TScale);//.................................................////功能:初始化屏幕,画出坐标系// Amplitude:振幅//.................................................//var i, k, tmp, Ymod: integer; PerHeight: integer; //Y轴的每刻度值 PerWeight: integer; //X轴的每刻度值begin PerHeight := Fimage.Height div HdivCount; PerWeight := Fimage.Width div OdivCount; Ymod := Fimage.Width mod OdivCount; k := 0; tmp := Amplitude; XScale.Amplitude := Amplitude; XScale.PerHeight := PerHeight; XScale.PerWeight := PerWeight; XScale.Perx := (OdivCount - 2) * PerWeight / 10000; XScale.Pery := (HdivCount - 2) * PerHeight / HdivCount; XScale.Ymod := Ymod; Fimage.Canvas.Brush.Color := 0; Fimage.Canvas.FillRect(Fimage.Canvas.ClipRect); Fimage.Canvas.Pen.Color := fColor; Fimage.Canvas.Pen.Style := stScale.PenStyle; Fimage.Canvas.Font.Color := fColor; //画水平线 for i := 1 to HdivCount - 1 do begin Fimage.Canvas.MoveTo(PerWeight, i * PerHeight); Fimage.Canvas.LineTo(Fimage.Width - PerWeight - Ymod, i * PerHeight); if tmp <> 0 then begin Fimage.Canvas.Font.Color := fcolor; Fimage.Canvas.TextOut(2, i * Perheight - 5, format('%4d.00', [tmp])); end else begin GiveCoordinate(k, i, PerWeight, PerHeight); Fimage.Canvas.Font.Color := clRed; Fimage.Canvas.TextOut(0, i * Perheight - 5, '通道' + IntTostr(k)); end; tmp := tmp - 1; if tmp = -(Amplitude + 1) then begin tmp := Amplitude; k := k + 1; end; end; //画垂直线 for i := 1 to OdivCount - 1 do begin Fimage.Canvas.MoveTo(i * PerWeight, PerHeight); Fimage.Canvas.LineTo(i * PerWeight, (HdivCount - 1) * Perheight); Fimage.Canvas.Font.Color := fcolor; Fimage.Canvas.TextOut(i * PerWeight, trunc((HdivCount - 0.5) * Perheight), IntTostr(i - 1)); end;end;procedure TfrmMain.ShowWave(i: integer; pp: single);begin//i为通道号 case i of 1: with StChanal[0] do begin CurrentX := CurrentX + StScale.PerX; CurrentY := y - pp * StScale.PerHeight; CurIntegerX := Trunc(CurrentX); CurIntegerY := Trunc(CurrentY); ImgShowWave.Canvas.Pixels[CurIntegerX, CurIntegerY] := StChanal[1].color; end; 3: with StChanal[1] do begin CurrentX := CurrentX + StScale.PerX; CurrentY := y - pp * StScale.PerHeight; CurIntegerX := Trunc(CurrentX); CurIntegerY := Trunc(CurrentY); ImgShowWave.Canvas.Pixels[CurIntegerX, CurIntegerY] := StChanal[3].color; end; end;end; dbchart 不够灵活! 想自己画 希望大家 给点这方面源代码 谢谢 我是新手 谢谢各位大家乐!!! 我做过一个实时曲线的程序,由于用的控件,因此程需也很简单,你若想要可以给你。[email protected] 谢谢了! valorman(程浩) 我已经给你发邮件了! [email protected] 昨天喝高了。有些话没说清楚。问我要代码的两位朋友,代码我已经寄出了。Delphi 里Timer组件精度不够的。我做过一个大概的测试,1秒钟也就100次左右,不可能达到所谓1ms级的。如果想得到更小的时间间隔,建议使用API,或者是媒体计时器。 看到楼上几位的观点,我感觉你们可能都是没有真正用到实际的项目中,我在一个项目中也涉及到了这个,但是没有很好的实现方法。1、使用chart当然可以显示数据,曲线和柱图,但是你如果用一用就知道了,切实非常不方便,并且速度慢,如果你下面向显示时间的话,他的距离非常大,看起来非常不舒服。2、使用image或者tpaintbox的cavas自己画图,我也想过,但是看了以后发现问题很大,这些控件都是必须在底层,因此你处理起来就不太好。3、我在vb中用过他的paintbox,使用起来比较方便,也是可以浮在其他控件之上,可以设定背景,然后在其上画图,因此我一直在delphi里找这个东西,好像没发现啊 DELPHI 多线程数据库查询 100分:遇到问题一筹莫展,发个讨论,解解闷 提问````DELPHI新手问题!帮帮我``` socket通讯(P2P)狂找管理员 求高手帮手。。。。急 请问我在另一台机器上做的APPLICATION窗体怎么引用 delphi中停止闪烁语句的是什么,像pb中的setredraw是什么啊,谢谢 怎样做回车操作? 关于MDI窗体的问题 查找文件夾的API或Delphi函數﹐象Windows的查找文件夾的瀏覽按鈕中的一樣 哈哈,终于找到了 发新帖子的连接! 俺的FR不支持自定义纸张,、`````
例如假定原来的信号是周期信号,一个周期是1ms,则你可以把定时器设为1000ms(1秒),这时二者的时间比例为1:1000。你把原信号在1ms内的整个变化,在1秒的时间间隔内依次展开,打点画在窗体的画布canvas上即可。1秒钟画一次,图形显示出来就是动态的。
若是非周期信号,则可以取一个较长的时间间隔(能够反映原信号的变化规律),然后依比例用同样方法画出。
嘿嘿
procedure ImageInit(Fimage: TImage; HdivCount, OdivCount, Amplitude, fcolor:
integer; var XScale: TScale);
//.................................................//
//功能:初始化屏幕,画出坐标系
// Amplitude:振幅
//.................................................//
var
i, k, tmp, Ymod: integer;
PerHeight: integer; //Y轴的每刻度值
PerWeight: integer; //X轴的每刻度值
begin
PerHeight := Fimage.Height div HdivCount;
PerWeight := Fimage.Width div OdivCount;
Ymod := Fimage.Width mod OdivCount;
k := 0;
tmp := Amplitude;
XScale.Amplitude := Amplitude;
XScale.PerHeight := PerHeight;
XScale.PerWeight := PerWeight;
XScale.Perx := (OdivCount - 2) * PerWeight / 10000;
XScale.Pery := (HdivCount - 2) * PerHeight / HdivCount;
XScale.Ymod := Ymod;
Fimage.Canvas.Brush.Color := 0;
Fimage.Canvas.FillRect(Fimage.Canvas.ClipRect);
Fimage.Canvas.Pen.Color := fColor;
Fimage.Canvas.Pen.Style := stScale.PenStyle;
Fimage.Canvas.Font.Color := fColor; //画水平线
for i := 1 to HdivCount - 1 do
begin
Fimage.Canvas.MoveTo(PerWeight, i * PerHeight);
Fimage.Canvas.LineTo(Fimage.Width - PerWeight - Ymod, i * PerHeight);
if tmp <> 0 then
begin
Fimage.Canvas.Font.Color := fcolor;
Fimage.Canvas.TextOut(2, i * Perheight - 5, format('%4d.00', [tmp]));
end
else
begin
GiveCoordinate(k, i, PerWeight, PerHeight);
Fimage.Canvas.Font.Color := clRed;
Fimage.Canvas.TextOut(0, i * Perheight - 5, '通道' + IntTostr(k));
end;
tmp := tmp - 1;
if tmp = -(Amplitude + 1) then
begin
tmp := Amplitude;
k := k + 1;
end;
end;
//画垂直线
for i := 1 to OdivCount - 1 do
begin
Fimage.Canvas.MoveTo(i * PerWeight, PerHeight);
Fimage.Canvas.LineTo(i * PerWeight, (HdivCount - 1) * Perheight);
Fimage.Canvas.Font.Color := fcolor;
Fimage.Canvas.TextOut(i * PerWeight, trunc((HdivCount - 0.5) * Perheight),
IntTostr(i - 1));
end;
end;procedure TfrmMain.ShowWave(i: integer; pp: single);
begin//i为通道号
case i of
1:
with StChanal[0] do
begin
CurrentX := CurrentX + StScale.PerX;
CurrentY := y - pp * StScale.PerHeight;
CurIntegerX := Trunc(CurrentX);
CurIntegerY := Trunc(CurrentY);
ImgShowWave.Canvas.Pixels[CurIntegerX, CurIntegerY] :=
StChanal[1].color;
end;
3:
with StChanal[1] do
begin
CurrentX := CurrentX + StScale.PerX;
CurrentY := y - pp * StScale.PerHeight;
CurIntegerX := Trunc(CurrentX);
CurIntegerY := Trunc(CurrentY);
ImgShowWave.Canvas.Pixels[CurIntegerX, CurIntegerY] :=
StChanal[3].color;
end;
end;
end;
[email protected]
问我要代码的两位朋友,代码我已经寄出了。Delphi 里Timer组件精度不够的。我做过一个大概的测试,1秒钟也就100次左右,不可能达到所谓1ms级的。如果想得到更小的时间间隔,建议使用API,或者是媒体计时器。
1、使用chart当然可以显示数据,曲线和柱图,但是你如果用一用就知道了,切实非常不方便,并且速度慢,如果你下面向显示时间的话,他的距离非常大,看起来非常不舒服。
2、使用image或者tpaintbox的cavas自己画图,我也想过,但是看了以后发现问题很大,这些控件都是必须在底层,因此你处理起来就不太好。
3、我在vb中用过他的paintbox,使用起来比较方便,也是可以浮在其他控件之上,可以设定背景,然后在其上画图,因此我一直在delphi里找这个东西,好像没发现啊