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

📄 qiscopepaneltimebase.pas

📁 iocopm3.04源码,一套很好的工控开发工具
💻 PAS
📖 第 1 页 / 共 2 页
字号:
{*******************************************************}
{                                                       }
{       TiScopePanelTimeBase Component                  }
{                                                       }
{       Copyright (c) 1997,2003 Iocomp Software         }
{                                                       }
{*******************************************************}
{$I iInclude.inc}

{$ifdef iVCL}unit  iScopePanelTimeBase;{$endif}
{$ifdef iCLX}unit QiScopePanelTimeBase;{$endif}

interface

uses
  {$I iIncludeUses.inc}
  {$IFDEF iVCL} iTypes, iGPFunctions,   iEditorBasicComponents,  iSpinSelector,{$ENDIF}
  {$IFDEF iCLX}QiTypes, QiGPFunctions, QiEditorBasicComponents, QiSpinSelector,{$ENDIF}
  {$IFDEF iVCL} iPlot,  iPlotChannelCustom,  iPlotAxis,  iPlotAnnotation,{$ENDIF}
  {$IFDEF iCLX}QiPlot, QiPlotChannelCustom, QiPlotAxis, QiPlotAnnotation,{$ENDIF}
  {$IFDEF iVCL} iPlotDataScopeList,  iScopePanelChannels,  iScopePanelTrigger,  iScopeChannel;{$ENDIF}
  {$IFDEF iCLX}QiPlotDataScopeList, QiScopePanelChannels, QiScopePanelTrigger, QiScopeChannel;{$ENDIF}

type
  TiScopePanelTimeBase = class(TCustomControl)
  private
    FCreationComplete     : Boolean;
    FRequiredHeight       : Integer;

    FScope                : TWinControl;
    FXAxis                : TiPlotXAxis;
    FScrollAnnotation     : TiPlotAnnotation;
    FDisplayAnnotation    : TiPlotAnnotation;
    FLastTransferTime     : Double;

    FLabel                : TLabel;
    FSecPerDivLabel       : TLabel;
    FPositionLabel        : TLabel;
    FPreCaptureLabel      : TLabel;
    FPostCaptureLabel     : TLabel;

    FSecPerDivSelector    : TiSpinSelector;
    FPositionSelector     : TiSpinSelector;
    FPreCaptureSelector   : TiSpinSelector;
    FPostCaptureSelector  : TiSpinSelector;

    FFrameTime            : Double;
    FSampleInterval       : Double;
    FSamplesPerFrame      : Integer;
    FSamplesPerSecond     : Integer;

    FSweepSamples         : Integer;
    FPreSamples           : Integer;
    FPostSamples          : Integer;

    FMaxContinuousSamples : Integer;
    FNeedsManualTrigger   : Boolean;
    FEventActive          : Boolean;
  protected
    procedure SetSamplesPerSecond    (const Value: Integer);
    procedure SetSecPerDiv           (const Value: Double);
    procedure SetPosition            (const Value: Double);
    procedure SetPostCapture         (const Value: Double);
    procedure SetPreCapture          (const Value: Double);
    procedure SetMaxContinuousSamples(const Value: Integer);

    procedure SetXAxis               (const Value: TiPlotXAxis);
    procedure SetScrollAnnotation    (const Value: TiPlotAnnotation);
    procedure SetDisplayAnnotation   (const Value: TiPlotAnnotation);

    function GetPosition   : Double;
    function GetSecPerDiv  : Double;
    function GetPostCapture: Double;
    function GetPreCapture : Double;

    procedure SecondsPerDivisionSelectorChange(Sender: TObject);
    procedure PositionSelectorChangeEvent     (Sender: TObject);

    procedure Resize;  override;

    procedure UpdateAll;
    procedure RemoveRawSamples(Value: Integer);

    procedure Paint; override;
  public
    constructor Create(AOwner: TComponent); override;
    destructor  Destroy;                    override;

    procedure AdjustLayout;
    procedure DataBlockUpdate;

    procedure DoManualTrigger(Sender: Tobject);

    procedure ScrollEvent;
                                   
    property RequiredHeight       : Integer              read FRequiredHeight;
    property LastTransferTime     : Double               read FLastTransferTime;

    property Scope                : TWinControl          read FScope                write FScope;
    property XAxis                : TiPlotXAxis          read FXAxis                write SetXAxis;
    property ScrollAnnotation     : TiPlotAnnotation     read FScrollAnnotation     write SetScrollAnnotation;
    property DisplayAnnotation    : TiPlotAnnotation     read FDisplayAnnotation    write SetDisplayAnnotation;


    property SecPerDivSelector    : TiSpinSelector       read FSecPerDivSelector;
    property PositionSelector     : TiSpinSelector       read FPositionSelector;
    property PreCaptureSelector   : TiSpinSelector       read FPreCaptureSelector;
    property PostCaptureSelector  : TiSpinSelector       read FPostCaptureSelector;
  published
    property SamplesPerSecond     : Integer              read FSamplesPerSecond     write SetSamplesPerSecond;
    property MaxContinuousSamples : Integer              read FMaxContinuousSamples write SetMaxContinuousSamples;
    property SecPerDiv            : Double               read GetSecPerDiv          write SetSecPerDiv;
    property Position             : Double               read GetPosition           write SetPosition;

    property PreCapture           : Double               read GetPreCapture         write SetPreCapture;
    property PostCapture          : Double               read GetPostCapture        write SetPostCapture;
  end;

implementation

uses
  {$IFDEF iVCL} iScope;{$ENDIF}
  {$IFDEF iCLX}QiScope;{$ENDIF}

type
  TiScopeAccess             = class(TiScope            )end;
  TiScopeChannelAccess      = class(TiScopeChannel     )end;
  TiPlotChannelCustomAccess = class(TiPlotChannelCustom)end;
//****************************************************************************************************************************************************
constructor TiScopePanelTimeBase.Create(AOwner: TComponent);
var
  x : Integer;
begin
  inherited Create(AOwner);

  Width      := 150;
  Height     := 125;

  FLabel := TLabel.Create(Self);
  with FLabel do
    begin
      Parent      := Self;
      Top         := 3;
      Left        := 3;
      Font.Size   := 10;
      Font.Style  := [fsBold, fsItalic, fsUnderline];
      Caption     := 'Time Base';
      Transparent := True;
    end;

  FSecPerDivLabel := TLabel.Create(Self);
  with FSecPerDivLabel do
    begin
      Parent      := Self;
      Font.Size   := 8;
      Font.Style  := [fsBold];
      Caption     := 'SEC/DIV';
      Transparent := True;
    end;

  FSecPerDivSelector := TiSpinSelector.Create(Self);
  with FSecPerDivSelector do
    begin
      Parent         := Self;
      Height         := 24;
      Width          := 93;
      RepeatInterval := 200;
      DefaultValue   := 0.001;
      OnChange       := SecondsPerDivisionSelectorChange;

      AddItem('10 ns',   0.000000010);
      AddItem('20 ns',   0.000000020);
      AddItem('50 ns',   0.000000050);
      AddItem('0.1 us',  0.000000100);
      AddItem('0.2 us',  0.000000200);
      AddItem('0.5 us',  0.000000500);
      AddItem('1 us',    0.000001000);
      AddItem('2 us',    0.000002000);
      AddItem('5 us',    0.000005000);
      AddItem('10 us',   0.000010000);
      AddItem('20 us',   0.000020000);
      AddItem('50 us',   0.000050000);
      AddItem('0.1 ms',  0.000100000);
      AddItem('0.2 ms',  0.000200000);
      AddItem('0.5 ms',  0.000500000);
      AddItem('1 ms',    0.001000000);
      AddItem('2 ms',    0.002000000);
      AddItem('5 ms',    0.005000000);
      AddItem('10 ms',   0.010000000);
      AddItem('20 ms',   0.020000000);
      AddItem('50 ms',   0.050000000);
      AddItem('0.1 s',   0.100000000);
      FSecPerDivSelector.Value := 0.001;
    end;

  FPositionLabel := TLabel.Create(Self);
  with FPositionLabel do
    begin                                                
      Parent      := Self;
      Font.Size   := 8;
      Font.Style  := [fsBold];
      Caption     := 'Position';
      Transparent := True;
    end;

  FPositionSelector := TiSpinSelector.Create(Self);
  with FPositionSelector do
    begin
      Parent         := Self;
      Height         := 24;
      Width          := 93;
      RepeatInterval := 50;
      FastIncrement  := 10;
      OnChange       := PositionSelectorChangeEvent;

      for x := -500 to 500 do
        AddItem(FormatFloat('0.0%', x/10), x/10);

      FPositionSelector.Value := 0;
    end;

  FPreCaptureLabel := TLabel.Create(Self);
  with FPreCaptureLabel do
    begin
      Parent      := Self;
      Font.Size   := 8;
      Font.Style  := [fsBold];
      Caption     := 'Pre-Capture';
      Transparent := True;                                         
    end;

  FPreCaptureSelector := TiSpinSelector.Create(Self);
  with FPreCaptureSelector do
    begin
      Parent         := Self;
      Height         := 24;
      Width          := 93;
      RepeatInterval := 50;

      for x := 0 to 5 do
        AddItem(FormatFloat('0. DIV', x), x);

      FPreCaptureSelector.Value := 0;
    end;

  FPostCaptureLabel := TLabel.Create(Self);
  with FPostCaptureLabel do
    begin
      Parent      := Self;
      Font.Size   := 8;
      Font.Style  := [fsBold];
      Caption     := 'Post-Capture';
      Transparent := True;
    end;

  FPostCaptureSelector := TiSpinSelector.Create(Self);
  with FPostCaptureSelector do
    begin
      Parent         := Self;
      Height         := 24;
      Width          := 93;
      RepeatInterval := 50;

      for x := 0 to 5 do
        AddItem(FormatFloat('0. DIV', x), x);

      FPostCaptureSelector.Value := 0;
    end;

⌨️ 快捷键说明

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