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

📄 qiscope.pas

📁 iocopm3.04源码,一套很好的工控开发工具
💻 PAS
📖 第 1 页 / 共 3 页
字号:

  FPanelTrigger := TiScopePanelTrigger.Create(Self);
  with FPanelTrigger do
    begin
      Parent        := Self;
      PanelChannels := FPanelChannels;
      Level         := 50;
      Auto          := True;
    end;

  FPanelTimeBase := TiScopePanelTimeBase.Create(Self);
  with FPanelTimeBase do
    begin
      Parent             := Self;
      Scope              := Self;
      ScrollAnnotation   := FPlot.Annotation[0];
      DisplayAnnotation  := FPlot.Annotation[1];
      XAxis              := FPlot.XAxis[1];
      SamplesPerSecond   := 10 * 100 *200;
      SecPerDiv          := 0.001;
    end;

  FDisplay := TiScopeDisplay.Create;
  with TiScopeDisplayAccess(FDisplay) do
    begin
      Plot                 := FPlot;
      PanelChannels        := FPanelChannels;
      HorzScrollAnnotation := FPlot.Annotation[0];
      TimeBaseAnnotation   := FPlot.Annotation[1];

      GridColor            := $808000;
      TextShow             := False;
      HorzScrollShow       := False;
    end;

  FPanelTrigger.OnManualTrigger := FPanelTimeBase.DoManualTrigger;

  FTimeBase := TiScopeTimeBase.Create(FPanelTimeBase);
  FTrigger  := TiScopeTrigger.Create (FPanelTrigger);
  FToolBar  := TiScopeToolBar.Create (FPanelToolBar);

  AddChannel;

  FCreationComplete := True;
end;
//****************************************************************************************************************************************************
destructor TiScope.Destroy;
begin
  FTimeBase.Free;
  FTrigger.Free;
  FToolBar.Free;

  FPanelChannels.Free;
  FPanelTimeBase.Free;
  FPanelTrigger.Free;
  FPanelToolBar.Free;
  FDisplay.Free;

  FPlot.Free;
  inherited;
end;
//****************************************************************************************************************************************************
procedure TiScope.Loaded;
begin
  inherited;
  AdjustLayout;
end;
//*************************************************************************************************************************************
procedure TiScope.SetHideControlPanels(const Value: Boolean);
begin
  if FHideControlPanels <> Value then
    begin
      FHideControlPanels := Value;

      AdjustLayout;
    end;
end;
//****************************************************************************************************************************************************
procedure TiScope.AdjustLayout;
var
  MaxHeight : Integer;
begin
  if not FCreationComplete then Exit;

  if FHideControlPanels then
    begin
      FPanelChannels.Width := 0;
      FPanelTimeBase.Width := 0;
      FPanelTrigger.Width  := 0;
      FPanelToolBar.Width  := 0;

      FPlot.Left   := 0;
      FPlot.Top    := 0;
      FPlot.Height := Height;
      FPlot.Width  := Width;
    end
  else
    begin
      FPanelChannels.Width := 210;
      FPanelTimeBase.Width := 190;
      FPanelTrigger.Width  := 190;
      FPanelToolBar.Width  := 200;

      FPanelTimeBase.AdjustLayout;
      FPanelTrigger.AdjustLayout;

      MaxHeight := 0;
      if FPanelTimeBase.RequiredHeight > MaxHeight then MaxHeight := FPanelTimeBase.RequiredHeight;
      if FPanelTrigger.RequiredHeight  > MaxHeight then MaxHeight := FPanelTrigger.RequiredHeight;

      FPlot.Left   := 0;
      FPlot.Top    := 0;
      FPlot.Height := Height;
      FPlot.Width  := Width  - FPanelTimeBase.Width - FPanelTrigger.Width;

      FPanelToolBar.Left    := FPlot.Left + FPlot.Width;
      FPanelToolBar.Width   := Width - FPlot.Width;

      FPanelTimeBase.Top    := FPanelToolBar.Height;
      FPanelTimeBase.Left   := FPlot.Left + FPlot.Width;
      FPanelTimeBase.Height := MaxHeight;

      FPanelTrigger.Top     := FPanelToolBar.Height;
      FPanelTrigger.Left    := FPanelTimeBase.Left + FPanelTimeBase.Width;
      FPanelTrigger.Height  := MaxHeight;

      FPanelChannels.Top    := FPanelTimeBase.Top + FPanelTimeBase.Height-1;
      FPanelChannels.Left   := FPanelTimeBase.Left;
      FPanelChannels.Height := Height - FPanelToolBar.Height - MaxHeight;
      FPanelChannels.Width  := Width - FPanelChannels.Left;
    end;
end;
//****************************************************************************************************************************************************
procedure TiScope.Resize;
begin
  inherited Resize;
  AdjustLayout;
end;
//****************************************************************************************************************************************************
function TiScope.GetAutoFrameRate    : Boolean;            begin Result := FPlot.AutoFrameRate;            end;
function TiScope.GetUpdateFrameRate  : Integer;            begin Result := FPlot.UpdateFrameRate;          end;
function TiScope.GetPrintDocumentName: String;             begin Result := FPlot.PrintDocumentName;        end;
function TiScope.GetPrinterName      : String;             begin Result := FPlot.PrinterName;              end;
function TiScope.GetPrintMarginBottom: Double;             begin Result := FPlot.PrintMarginBottom;        end;
function TiScope.GetPrintMarginLeft  : Double;             begin Result := FPlot.PrintMarginLeft;          end;
function TiScope.GetPrintMarginRight : Double;             begin Result := FPlot.PrintMarginRight;         end;
function TiScope.GetPrintMarginTop   : Double;             begin Result := FPlot.PrintMarginTop;           end;
function TiScope.GetPrintOrientation : TPrinterOrientation;begin Result := FPlot.PrintOrientation;         end;
function TiScope.GetPrintShowDialog  : Boolean;            begin Result := FPlot.PrintShowDialog;          end;
function TiScope.GetSamplesPerSecond : Integer;            begin Result := FPanelTimeBase.SamplesPerSecond;end;
//****************************************************************************************************************************************************
procedure TiScope.SetAutoFrameRate    (const Value: Boolean);            begin FPlot.AutoFrameRate             := Value;end;
procedure TiScope.SetUpdateFrameRate  (const Value: Integer);            begin FPlot.UpdateFrameRate           := Value;end;
procedure TiScope.SetPrintDocumentName(const Value: String);             begin FPlot.PrintDocumentName         := Value;end;
procedure TiScope.SetPrinterName      (const Value: String);             begin FPlot.PrinterName               := Value;end;
procedure TiScope.SetPrintMarginBottom(const Value: Double);             begin FPlot.PrintMarginBottom         := Value;end;
procedure TiScope.SetPrintMarginLeft  (const Value: Double);             begin FPlot.PrintMarginLeft           := Value;end;
procedure TiScope.SetPrintMarginRight (const Value: Double);             begin FPlot.PrintMarginRight          := Value;end;
procedure TiScope.SetPrintMarginTop   (const Value: Double);             begin FPlot.PrintMarginTop            := Value;end;
procedure TiScope.SetPrintOrientation (const Value: TPrinterOrientation);begin FPlot.PrintOrientation          := Value;end;
procedure TiScope.SetPrintShowDialog  (const Value: Boolean);            begin FPlot.PrintShowDialog           := Value;end;
procedure TiScope.SetSamplesPerSecond (const Value: Integer);            begin FPanelTimeBase.SamplesPerSecond := Value;end;
//****************************************************************************************************************************************************
procedure TiScope.DataBlockBegin;
begin
  FPanelChannels.DataBlockBegin;
end;
//****************************************************************************************************************************************************
procedure TiScope.DataBlockEnd;
begin
  FTransferringData := True;
  try
    FPanelChannels.DataBlockEnd;
    FPanelTimeBase.DataBlockUpdate;
  finally
    FTransferringData := False;
  end;
end;
//*************************************************************************************************************************************
function TiScope.GetDataBlockSynchronized: Boolean;
begin
  Result := FPanelChannels.DataBlockSynchronized;
end;
//*************************************************************************************************************************************
procedure TiScope.DataBlockClear;
begin
  FPanelChannels.DataBlockClear;
end;
//*************************************************************************************************************************************
function TiScope.GetNeedPacketsNow: Boolean;
var
  ElapsedTime     : Double;
  Second          : Double;
  FrameTime       : Double;
begin
  if UpdateFrameRate <> 0 then
    begin
      ElapsedTime := Now - FPanelTimeBase.LastTransferTime;
      Second      := 1/(24*60*60);
      FrameTime   := (1/UpdateFrameRate)*Second;

      if ElapsedTime > FrameTime then
        Result := True
      else
        Result := False;
    end
  else Result := True;
end;
//*************************************************************************************************************************************
function TiScope.GetDataBlockActive: Boolean;
begin
  Result := FPanelChannels.DataBlockActive;
end;
//****************************************************************************************************************************************************
function TiScope.AddChannel: Integer;
begin
  Result := FPanelChannels.AddChannel;
                                         
  FPanelTrigger.SetupSourceSelector;

end;
//****************************************************************************************************************************************************
procedure TiScope.AddChannelData(Channel: Integer; Y: Double);
begin
  FPanelChannels.AddChannelData(Channel, Y);
end;
//****************************************************************************************************************************************************
procedure TiScope.AddDataBlock(Data: Variant);
var
  LowBoundDim1  : Integer;
  LowBoundDim2  : Integer;
  HighBoundDim1 : Integer;
  HighBoundDim2 : Integer;
  ChannelIndex  : Integer;
  DataIndex     : Integer;
begin
  if VarArrayDimCount(Data) <> 2 then raise Exception.Create('Add Data Block array must be 2 dimensional');

  LowBoundDim1  := VarArrayLowBound (Data, 1);
  LowBoundDim2  := VarArrayLowBound (Data, 2);
  HighBoundDim1 := VarArrayHighBound(Data, 1);
  HighBoundDim2 := VarArrayHighBound(Data, 2);

  for DataIndex := LowBoundDim2 to HighBoundDim2 do
    for ChannelIndex := LowBoundDim1 to HighBoundDim1 do
      AddChannelData(ChannelIndex, Data[ChannelIndex, DataIndex]);
end;
//*************************************************************************************************************************************
procedure TiScope.AddDataBlockChannel(Index: Integer; Data: Variant);
var
  LowBound   : Integer;
  HighBound  : Integer;
  DataIndex  : Integer;
begin
  if VarArrayDimCount(Data) <> 1 then raise Exception.Create('Add Data Block Channel array must be 1 dimensional');

  LowBound  := VarArrayLowBound (Data, 1);
  HighBound := VarArrayHighBound(Data, 1);

  for DataIndex := LowBound to HighBound do
    AddChannelData(Index, Data[DataIndex]);
end;
//****************************************************************************************************************************************************
function TiScope.GetChannel(Index: Integer): TiScopeChannel;
begin
  Result := FPanelChannels.ScopeChannel[Index];
end;
//****************************************************************************************************************************************************
function TiScope.GetChannelCount: Integer;
begin
  Result := FPanelChannels.Count;
end;
//****************************************************************************************************************************************************
procedure TiScope.RemoveAllChannels;
begin
  FPanelChannels.RemoveAllChannels;
  FPlot.ClearAllData;
  TiComponentAccess(FPlot).InvalidateNow;
end;
//****************************************************************************************************************************************************
procedure TiScope.DeleteChannel(Index: Integer);
begin
  FPanelChannels.DeleteChannel(Index);
  FPlot.ClearAllData;
  TiComponentAccess(FPlot).InvalidateNow;
end;
//****************************************************************************************************************************************************
procedure TiScope.DoEditClick(Sender: TObject);
var
  x : Integer;
begin
  FScopeEditor := TiScopeEditorForm.Create(Application);
  try
    with FScopeEditor do
      begin
        Scope := Self;
        Left := Screen.Width  div 2 - Width  div 2;
        Top  := Screen.Height div 2 - Height div 2;

⌨️ 快捷键说明

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