unit Simulator.Manual;

// #ToDo1 -oMvR: 2-9-2017: configurable speed for full fan power

interface
uses
  System.Classes,
  Vcl.Controls,
  Vcl.ExtCtrls,
  Vcl.Forms,
  Vcl.StdCtrls,

  Simulator.Base,
  Simulator.Registry, Vcl.Samples.Spin, Vcl.ComCtrls;


type
  TManualFrame = class(TSimulatorBaseFrame)
    UpdateTimer: TTimer;
    ValueTrackBar: TTrackBar;

    procedure UpdateTimerTimer(Sender: TObject);
  public
    procedure Start; override;
    procedure Stop; override;
  end;


implementation
uses
  System.SysUtils;


{$R *.dfm}


{ TManualFrame }
procedure TManualFrame.UpdateTimerTimer(Sender: TObject);
begin
  Fans.SetAll(ValueTrackBar.Position);
end;


procedure TManualFrame.Start;
begin
  inherited Start;

  UpdateTimer.Enabled := True;
end;


procedure TManualFrame.Stop;
begin
  UpdateTimer.Enabled := False;

  inherited Stop;
end;


initialization
  RegisterSimulator('Manual', 'Manual fan control',
    function(AFans: ISimulatorFans): ISimulator
    begin
      Result := TSimulatorFrame<TManualFrame>.Create(AFans);
    end);

end.
