unit BatEd;

interface

uses
  Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
  StdCtrls, RXSpin, ExtCtrls;

type
  TfmBatEd = class(TForm)
    Panel1: TPanel;
    edBateryCap: TRxSpinEdit;
    Label1: TLabel;
    edSafeBatCoef: TRxSpinEdit;
    Label3: TLabel;
    stBatCapA: TStaticText;
    Label4: TLabel;
    Label2: TLabel;
    edBatVoltage: TRxSpinEdit;
    Label5: TLabel;
    edBatLossesPerHour: TRxSpinEdit;
    Label6: TLabel;
    procedure edBateryCapChange(Sender: TObject);
    procedure FormCreate(Sender: TObject);
    procedure edBatLossesPerHourChange(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  fmBatEd: TfmBatEd;

implementation

uses Data;

{$R *.DFM}

procedure TfmBatEd.edBateryCapChange(Sender: TObject);
begin
  if edBatVoltage.Value<>0 then
     stBatCapA.Caption:= Format('%0.3f',[edBateryCap.Value/edBatVoltage.Value])
  else
     stBatCapA.Caption  := 'Ä/Õ'
end;

procedure TfmBatEd.FormCreate(Sender: TObject);
begin
  edBateryCap.Value   := MaxBateryCapacity;
  edSafeBatCoef.Value := SafeBateryCoef;
  edBatVoltage.Value  := BateryVoltage;
  edBatLossesPerHour.Value := BatLossesPerHour * 100;
  edBateryCapChange(edBateryCap);
end;

procedure TfmBatEd.edBatLossesPerHourChange(Sender: TObject);
begin
  BatLossesPerHour := edBatLossesPerHour.Value / 100;
end;

end.
