📄 iscopechannel.pas
字号:
{*******************************************************}
{ }
{ TiScopeChannel Object }
{ }
{ Copyright (c) 1997,2003 Iocomp Software }
{ }
{*******************************************************}
{$I iInclude.inc}
{$ifdef iVCL}unit iScopeChannel;{$endif}
{$ifdef iCLX}unit QiScopeChannel;{$endif}
interface
uses
{$I iIncludeUses.inc}
{$IFDEF iVCL} iTypes, iGPFunctions, {$ENDIF}
{$IFDEF iCLX}QiTypes, QiGPFunctions,{$ENDIF}
{$IFDEF iVCL} iPlot, iPlotChannel, iPlotAxis, iPlotAnnotation, iPlotLimit, iPlotDataCompactIntervalList, iPlotDataScopeList; {$ENDIF}
{$IFDEF iCLX}QiPlot, QiPlotChannel, QiPlotAxis, QiPlotAnnotation, QiPlotLimit, QiPlotDataCompactIntervalList, QiPlotDataScopeList;{$ENDIF}
type
TiScopeChannelCoupling = (isccDC, isccAC, isccGround);
TiScopeChannel = class(TPersistent)
private
FScope : TWinControl;
FSettingPosition : Boolean;
FVoltsPerDivision : Double;
FPosition : Double;
FTitleText : String;
FColor : TColor;
FTraceLineWidth : Integer;
FTraceVisible : Boolean;
FCoupling : TiScopeChannelCoupling;
FRawData : TiPlotDataScopeList;
FYAxis : TiPlotYAxis;
FChannel : TiPlotChannel;
FCapacitor : Double;
FOnChange : TNotifyEvent;
FScalerMultiplier : Double;
FScalerOffset : Double;
FAnnotation : TiPlotAnnotation;
FRefLine : TiPlotLimit;
FRefLineShow : Boolean;
protected
procedure SetCoupling (const Value: TiScopeChannelCoupling);
procedure SetPosition (const Value: Double);
procedure SetVoltsPerDivision(const Value: Double);
procedure SetYAxis (const Value: TiPlotYAxis);
procedure SetChannel (const Value: TiPlotChannel);
procedure SetAnnotation (const Value: TiPlotAnnotation);
procedure SetRefLine (const Value: TiPlotLimit);
procedure SetTitleText (const Value: String);
procedure SetColor (const Value: TColor);
procedure SetTraceLineWidth (const Value: Integer);
procedure SetTraceVisible (const Value: Boolean);
procedure SetScalerMultiplier(const Value: Double);
procedure SetScalerOffset (const Value: Double);
procedure SetRefLineShow (const Value: Boolean);
procedure SetPositionVoltage (const Value: Double);
function GetTitleText : String;
function GetColor : TColor;
function GetTraceLineWidth : Integer;
function GetTraceVisible : Boolean;
function GetPositionVoltage: Double;
function GetBufferCount : Integer;
function GetYDisplay(Index: Integer): Double;
procedure DoChange;
procedure UpdateYAxis;
procedure AddData(Y: Double);
procedure RefLimitLineChange(NewValue: Double);
property RawData : TiPlotDataScopeList read FRawData;
property OnChange : TNotifyEvent read FOnChange write FOnChange;
property Scope : TWinControl read FScope write FScope;
property YAxis : TiPlotYAxis read FYAxis write SetYAxis;
property Channel : TiPlotChannel read FChannel write SetChannel;
property Annotation : TiPlotAnnotation read FAnnotation write SetAnnotation;
property RefLine : TiPlotLimit read FRefLine write SetRefLine;
public
constructor Create; virtual;
destructor Destroy; override;
property Capacitor : Double read FCapacitor;
property BufferCount : Integer read GetBufferCount;
property PositionVoltage : Double read GetPositionVoltage write SetPositionVoltage;
published
property VoltsPerDivision : Double read FVoltsPerDivision write SetVoltsPerDivision;
property Position : Double read FPosition write SetPosition;
property Coupling : TiScopeChannelCoupling read FCoupling write SetCoupling;
property ScalerMultiplier : Double read FScalerMultiplier write SetScalerMultiplier;
property ScalerOffset : Double read FScalerOffset write SetScalerOffset;
property TitleText : String read GetTitleText write SetTitleText;
property Color : TColor read GetColor write SetColor default clAqua;
property TraceVisible : Boolean read GetTraceVisible write SetTraceVisible default True;
property TraceLineWidth : Integer read GetTraceLineWidth write SetTraceLineWidth default 1;
property RefLineShow : Boolean read FRefLineShow write SetRefLineShow default True;
end;
implementation
uses
{$IFDEF iVCL} iScope;{$ENDIF}
{$IFDEF iCLX}QiScope;{$ENDIF}
type
TiScopeAccess = class(TiScope)end;
//****************************************************************************************************************************************************
constructor TiScopeChannel.Create;
begin
FRawData := TiPlotDataScopeList.Create;
FVoltsPerDivision := 5;
FPosition := 0;
FCoupling := isccAC;
FRefLineShow := True;
FTitleText := 'CH';
FColor := clAqua;
FTraceVisible := True;
FTraceLineWidth := 1;
end;
//****************************************************************************************************************************************************
destructor TiScopeChannel.Destroy;
begin
FRawData.Free;
if Assigned(FYAxis) then FYAxis.Free;
if Assigned(FChannel) then FChannel.Free;
if Assigned(FAnnotation) then FAnnotation.Free;
if Assigned(FRefLine) then FRefLine.Free;
inherited Destroy;
end;
//****************************************************************************************************************************************************
procedure TiScopeChannel.DoChange;
begin
if Assigned(FOnChange) then FOnChange(Self);
end;
//****************************************************************************************************************************************************
procedure TiScopeChannel.AddData(Y: Double);
var
ScaledData : Double;
begin
ScaledData := Y;
ScaledData := ScaledData + FScalerOffset;
if FScalerMultiplier <> 0 then ScaledData := ScaledData * FScalerMultiplier;
case FCoupling of
isccDC : FRawData.Add(0, ScaledData);
isccAC : begin
FCapacitor := FCapacitor - FCapacitor/25000;
FCapacitor := FCapacitor + ScaledData/25000;
FRawData.Add(0, ScaledData);
end;
isccGround : FRawData.Add(0, 0);
end;
end;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -