rt   xiexie

解决方案 »

  1.   

    补充:
    例如假定原来的信号是周期信号,一个周期是1ms,则你可以把定时器设为1000ms(1秒),这时二者的时间比例为1:1000。你把原信号在1ms内的整个变化,在1秒的时间间隔内依次展开,打点画在窗体的画布canvas上即可。1秒钟画一次,图形显示出来就是动态的。
    若是非周期信号,则可以取一个较长的时间间隔(能够反映原信号的变化规律),然后依比例用同样方法画出。
      

  2.   

    同意大羽呵呵,还有一种更省事的画图方法,用chart控件,把转换好的数字量写到数据库中,通过chart和数据库中相应的表、字段关联就行,呵呵
      

  3.   

    楼上两位有理。因为我没用过Dbchart,所以只会用笨办法。这里抛砖引玉,方知还有Dbchart。度人也度己,好啊!
      

  4.   

    TeeChart,我自己写过的。我的毕业设计就是做的温度数据采集,我用TeeChart做的数据采集,如果你要源码的话。可以和我联系,我先申明啊,是免费的。
    嘿嘿
      

  5.   

    用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;
      

  6.   

    dbchart 不够灵活! 想自己画 希望大家 给点这方面源代码 谢谢  我是新手  谢谢各位大家乐!!!
      

  7.   

    我做过一个实时曲线的程序,由于用的控件,因此程需也很简单,你若想要可以给你。
    [email protected]
      

  8.   

    谢谢了! valorman(程浩) 我已经给你发邮件了! [email protected]
      

  9.   

    昨天喝高了。有些话没说清楚。
    问我要代码的两位朋友,代码我已经寄出了。Delphi 里Timer组件精度不够的。我做过一个大概的测试,1秒钟也就100次左右,不可能达到所谓1ms级的。如果想得到更小的时间间隔,建议使用API,或者是媒体计时器。
      

  10.   

    看到楼上几位的观点,我感觉你们可能都是没有真正用到实际的项目中,我在一个项目中也涉及到了这个,但是没有很好的实现方法。
    1、使用chart当然可以显示数据,曲线和柱图,但是你如果用一用就知道了,切实非常不方便,并且速度慢,如果你下面向显示时间的话,他的距离非常大,看起来非常不舒服。
    2、使用image或者tpaintbox的cavas自己画图,我也想过,但是看了以后发现问题很大,这些控件都是必须在底层,因此你处理起来就不太好。
    3、我在vb中用过他的paintbox,使用起来比较方便,也是可以浮在其他控件之上,可以设定背景,然后在其上画图,因此我一直在delphi里找这个东西,好像没发现啊