⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abmtrend.pas

📁 著名的虚拟仪表控件,包含全部源码, 可以在,delphi2007 下安装运行
💻 PAS
📖 第 1 页 / 共 2 页
字号:
unit AbMTrend;

{******************************************************************************}
{ Abakus VCL                                                                   }
{                          Component TAbMiniTrend                              }
{                                                                              }
{******************************************************************************}
{        e-Mail: support@abaecker.de , Web: http://www.abaecker.com            }
{------------------------------------------------------------------------------}
{          (c) Copyright 1998..2000 A.Baecker, All rights Reserved             }
{******************************************************************************}

{$I abks.inc}

interface

uses
  Windows,
  Classes,
  Graphics,
  Controls,
  extctrls,
  Messages,
  SysUtils,
  {****** Abakus VCL - Units ******}
  _GClass,
  _AbInfo,
  _AbProc,
  AbFlashT;


type


  TMiniTrendOption = (opBevelInner, opBevelOuter, opCaption, opScaleCh1,
    opScaleCh2, opSignDescCh1, opSignDescCh2,
    opGrid, opTimeLine);
  TMiniTrendOptions = set of TMiniTrendOption;


  TAbMiniTrend = class(TAbGraphicControl)
  private
    { Private-Deklarationen }
    FBevelInner: TAbSBevel;
    FBevelOuter: TAbSBevel;
    FCaptionFont: TFont;
    FFlow: Boolean;
    FDigitCh1: Smallint;
    FDigitCh2: Smallint;
    FSignalSettingsCh1: TSignalSettings;
    FSignalSettingsCh2: TSignalSettings;
    FTimeScale: Smallint;
    FValueCh1: Single;
    FValueCh2: Single;
    FBkColor: TColor;
    FOptions: TMiniTrendOptions;
    FInterval: LongInt;
    GridX_Pixel: Smallint;
    FSignalColorCh1: TColor;
    FSignalColorCh2: TColor;
    FGridColor: TColor;
    FTimeLineColor: TColor;

    yPosCh1: Smallint;
    yLastPosCh1: Smallint;
    yPosCh2: Smallint;
    yLastPosCh2: Smallint;
    TimeStamp: Smallint;
    TimeDiv: string;
    FirstDraw: Boolean;
    TrendBmp: TBitmap;
    PixelNo: Smallint;
    xOrg: Smallint;
    yOrg: Smallint;
    Gridy: array[0..9] of Smallint;
    FirstPuls: Boolean;
    Count: Smallint;
    Painting : Boolean;
  protected
    { Protected-Deklarationen }
    procedure SetDigitCh1(Value: Smallint);
    procedure SetDigitCh2(Value: Smallint);
    procedure SetValueCh1(Value: Single);
    procedure SetValueCh2(Value: Single);
    procedure WMFlash(var Message: TMessage); message WM_FLASH;
    procedure CMTextChanged(var msg: TMessage); message CM_TEXTCHANGED;
    procedure Paint; override;
    procedure ParamChange(Sender: TObject); override;
    procedure SetOptions(Value: TMiniTrendOptions);
    procedure SetInterval(Value: LongInt);
    procedure SetGridColor(Value: TColor);
    procedure SetTimeLineColor(Value: TColor);
    procedure SetSignalColorCh1(Value: TColor);
    procedure SetSignalColorCh2(Value: TColor);
    procedure SetBkColor(Value: TColor);
    procedure SetTimeScale(Value: Smallint);
    procedure SetCaptionFont(Value: TFont);
    procedure SetFlow(Value: Boolean);
    procedure DrawBackground;
    property Interval: LongInt read FInterval write SetInterval default 1000;
  public
    { Public-Deklarationen }
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
    procedure Loaded; override;
  published
    { Published-Deklarationen }

    property OnClick;
    property OnDblClick;
    property OnDragDrop;
    property OnDragOver;
    property OnEndDrag;
    property OnMouseDown;
    property OnMouseUp;
    property OnStartDrag;

    property Font;
    property ParentFont;
    property Visible;

    property CaptionFont: TFont read FCaptionFont
    write SetCaptionFont;

    property BevelInner: TAbSBevel read FBevelInner
    write FBevelInner;

    property BevelOuter: TAbSBevel read FBevelOuter
    write FBevelOuter;

    property DigitCh1: Smallint read FDigitCh1
    write SetDigitCh1 default 300;

    property DigitCh2: Smallint read FDigitCh2
    write SetDigitCh2 default 700;

    property SignalSettingsCh1: TSignalSettings read FSignalSettingsCh1
    write FSignalSettingsCh1;

    property SignalSettingsCh2: TSignalSettings read FSignalSettingsCh2
    write FSignalSettingsCh2;

    property ValueCh1: Single read FValueCh1
    write SetValueCh1;

    property ValueCh2: Single read FValueCh2
    write SetValueCh2;

    property TimeScale: Smallint read FTimeScale
    write SetTimeScale default 5;

    property Options: TMiniTrendOptions read FOptions
    write SetOptions;

    property GridColor: TColor read FGridColor
    write SetGridColor default clBtnShadow;

    property TimeLineColor: TColor read FTimeLineColor
    write SetTimeLineColor default clFuchsia;

    property BkColor: TColor read FBkColor
    write SetBkColor default clBlack;

    property SignalColorCh1: TColor read FSignalColorCh1
    write SetSignalColorCh1 default clLime;

    property SignalColorCh2: TColor read FSignalColorCh2
    write SetSignalColorCh2 default clYellow;
    property Caption;

    property Flow: Boolean read FFlow
    write SetFlow default true;
  end;

implementation

constructor TAbMiniTrend.Create(AOwner: TComponent);
begin
  BeginUpdate;
  inherited Create(AOwner);
  if (AOwner is TWinControl) then Parent := AOwner as TWinControl;

  FirstDraw := true;

  Width := 400;
  Height := 300;

  TrendBmp := TBitmap.Create;
  TrendBmp.Height := Height;
  TrendBmp.Width := Width;

  FSignalSettingsCh1 := TSignalSettings.Create;
  FSignalSettingsCh1.Name1 := 'Name1';
  FSignalSettingsCh1.Name2 := 'Name2';
  FSignalSettingsCh1.ValueFormat := '##0';

  FSignalSettingsCh2 := TSignalSettings.Create;
  FSignalSettingsCh2.Name1 := 'Name1';
  FSignalSettingsCh2.Name2 := 'Name2';
  FSignalSettingsCh2.ValueFormat := '##0';

  FBevelInner := TAbSBevel.Create;
  FBevelInner.Style := bsLowered;
  FBevelInner.Spacing := 0;
  FBevelInner.Width := 2;
  FBevelInner.BevelLine := blNone;

  FBevelOuter := TAbSBevel.Create;
  FBevelOuter.Spacing := 10;
  FBevelOuter.Width := 2;
  FBevelOuter.BevelLine := blOuter;

  FOptions := [opBevelInner, opBevelOuter, opCaption, opScaleCh1, opScaleCh2,
    opSignDescCh1, opSignDescCh2, opGrid, opTimeLine];

  DigitCh1 := 700;
  DigitCh2 := 300;

  TimeScale := 5;
  BkColor := clBlack;
  GridColor := clBtnShadow;
  TimeLineColor := clFuchsia;
  SignalColorCh1 := clLime;
  SignalColorCh2 := clYellow;
  Caption := Name;

  FCaptionFont := TFont.Create;
  FCaptionFont.Name := 'Arial';
  FCaptionFont.Size := 14;
  FCaptionFont.Style := [fsUnderline];

  TimeStamp := 5;
  PixelNo := 1;
  GridX_Pixel := 100;

  Flow := true;
  if (csDesigning in Componentstate) then Loaded;

end;

procedure TAbMiniTrend.Loaded;
begin
  inherited Loaded;


  FSignalSettingsCh1.OnChange := ParamChange;


  FSignalSettingsCh2.OnChange := ParamChange;


  FBevelInner.OnChange := ParamChange;


  FBevelOuter.OnChange := ParamChange;

  EndUpdate;
end;

procedure TAbMiniTrend.CMTextChanged(var msg: TMessage);
begin
  if (UpdateCount = 0) then ParamChange(self);
end;

procedure TAbMiniTrend.SetFlow(Value: Boolean);
begin
  FFlow := Value;
  Interval := FInterval;
end;

procedure TAbMiniTrend.SetCaptionFont(Value: TFont);
begin
  FCaptionFont.Assign(Value);
  Change;
end;

procedure TAbMiniTrend.SetGridColor(Value: TColor);
begin
  FGridColor := Value;
  if (UpdateCount = 0) then DrawBackground;
end;

procedure TAbMiniTrend.SetTimeLineColor(Value: TColor);
begin
  FTimeLineColor := Value;
  if (UpdateCount = 0) then DrawBackground;
end;

procedure TAbMiniTrend.SetSignalColorCh1(Value: TColor);
begin
  FSignalColorCh1 := Value;
  if (UpdateCount = 0) then
  begin
    DrawBackground;
    Change;
  end;
end;

procedure TAbMiniTrend.SetSignalColorCh2(Value: TColor);
begin
  FSignalColorCh2 := Value;
  if (UpdateCount = 0) then
  begin
    DrawBackground;
    Change;
  end;
end;

procedure TAbMiniTrend.SetBkColor(Value: TColor);
begin
  FBkColor := Value;
  if (UpdateCount = 0) then DrawBackground;
end;

procedure TAbMiniTrend.SetInterval(Value: LongInt);
begin
  if Value > 0 then
  begin
    FInterval := Value;
    if Flow then
    begin
      if FInterval > 200 then
      begin
        AddControl(self, 200);
        FirstPuls := true;
      end
      else
        AddControl(self, Value);
      TimeStamp := 5;
    end
    else
    begin
      DelControl(self);
    end;
  end;
end;

procedure TAbMiniTrend.SetTimeScale(Value: Smallint);
begin
  if Value > 0 then
  begin
    FTimeScale := Value;
    if (UpdateCount = 0) then DrawBackground;
  end;
end;

procedure TAbMiniTrend.SetDigitCh1(Value: Smallint);
begin
  FDigitCh1 := Value;
  FValueCh1 := SignalSettingsCh1.ValueFrom +
    (FDigitCh1 - SignalSettingsCh1.DigitalFrom) *
    SignalSettingsCh1.ValuePerDigit;
end;

procedure TAbMiniTrend.SetDigitCh2(Value: Smallint);
begin
  FDigitCh2 := Value;
  FValueCh2 := SignalSettingsCh2.ValueFrom +
    (FDigitCh2 - SignalSettingsCh2.DigitalFrom) *
    SignalSettingsCh2.ValuePerDigit;
end;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -