Q&A

  • Class를 이용한 플그램이 잘안되네요 소스 분석좀 부탁
소스 분석좀 부탁드립니다..

unit Turning;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, jpeg, Motion, Hull, Propeller, Rudder, MotionSolver,
  DBTables;

type
  TFrTurn = class(TForm)
    Imaturn: TImage;
    GBTrun: TGroupBox;
    la1: TLabel;
    Ed1: TEdit;
    la2: TLabel;
    Ed2: TEdit;
    la3: TLabel;
    la4: TLabel;
    Gb2: TGroupBox;
    Label1: TLabel;
    Label2: TLabel;
    Label3: TLabel;
    Label4: TLabel;
    ed3: TEdit;
    ed4: TEdit;
    GroupBox2: TGroupBox;
    Label5: TLabel;
    Label6: TLabel;
    LA7: TLabel;
    Label8: TLabel;
    ed5: TEdit;
    ED6: TEdit;
    Bt1: TButton;
    Label7: TLabel;
    Ed7: TEdit;
    Label9: TLabel;
//
    procedure FormShow(Sender: TObject);
    procedure Bt1Click(Sender: TObject);
//    procedure HullData(fHull : THull);
  private
    { Private declarations }
    Procedure OnCalculate;
  public
    { Public declarations }
  end;

var
  FrTurn : TFrTurn;
  m_RPM, m_RudderAngle, m_DT, m_TMax, m_ResultVelStrkKt : Double;
  m_InitialRPM : Double;
  m_WritingTime :Double;
  fMotion : TMotion;
  fHull : THull;
  fPropeller : TPropeller;
  fRudder : TRudder;
  fMotionSolver : TMotionSolver;
//  Qr_NonLinear : TQuery;

implementation

uses Maneuvrability;

{$R *.dfm}

{*procedure TFrTurn.HullData(fHull : THull);
begin
  fHull := Hull.THull.Create;
  Qr_NonLinear := TQuery.Create(Self);
  Qr_NonLinear.DatabaseName := Maneuvrability.FrMain.ed1.Text;
  Qr_NonLinear.SQL.Clear;
  Qr_NonLinear.SQL.Add('Select * From NonLinear');
  Qr_NonLinear.ExecSQL;
  Qr_NonLinear.Open;
  Qr_NonLinear.First;
  While Qr_NonLinear.Bof do begin
  fHull.sh_Xvr := Qr_NonLinear.FieldByName('Nonlinear_Value1').AsFloat;
  Qr_NonLinear.Next;
  fHull.sh_Nvvr := Qr_NonLinear.FieldByName('Nonlinear_Value1').AsFloat;
  Qr_NonLinear.Next;
  fHull.sh_Nuvrr := Qr_NonLinear.FieldByName('Nonlinear_Value1').AsFloat;
  Qr_NonLinear.Next;
  fHull.sh_Nrr := Qr_NonLinear.FieldByName('Nonlinear_Value1').AsFloat;
  Qr_NonLinear.Next;
  fHull.sh_Xuu := Qr_NonLinear.FieldByName('Nonlinear_Value1').AsFloat;
  Qr_NonLinear.Next;
  fHull.sh_Yv := Qr_NonLinear.FieldByName('Nonlinear_Value1').AsFloat;
  Qr_NonLinear.Next;
  fHull.sh_Yur := Qr_NonLinear.FieldByName('Nonlinear_Value1').AsFloat;
  Qr_NonLinear.Next;
  fHull.sh_Yvv := Qr_NonLinear.FieldByName('Nonlinear_Value1').AsFloat;
  Qr_NonLinear.Next;
  fHull.sh_Yvr := Qr_NonLinear.FieldByName('Nonlinear_Value1').AsFloat;
  Qr_NonLinear.Next;
  fHull.sh_Yurr := Qr_NonLinear.FieldByName('Nonlinear_Value1').AsFloat;
  Qr_NonLinear.Next;
  fHull.sh_Nv := Qr_NonLinear.FieldByName('Nonlinear_Value1').AsFloat;
  Qr_NonLinear.Next;
  fHull.sh_Nuv := Qr_NonLinear.FieldByName('Nonlinear_Value1').AsFloat;
  Qr_NonLinear.Next;
  fHull.sh_Nr := Qr_NonLinear.FieldByName('Nonlinear_Value1').AsFloat;
  end;
//  Qr_NonLinear.Close;
//  Qr_NonLinear.Free;
end;*}

procedure TFrTurn.FormShow(Sender: TObject);
begin
  Ed1.Text := '15.0';
  Ed2.Text := '72.0';
  Ed3.Text := '0.5';
  Ed4.Text := '2000';
  Ed5.Text := '72.0';
  Ed6.Text := '0.0';
  Ed7.Text := '1.0';
  m_RPM := 0.0;
  m_RudderAngle := 0.0;
  m_DT := 0.0;
  m_TMax := 0.0;
  m_ResultVelStrkKt := 15.0;
  m_InitialRPM := 72.0;
  m_WritingTime := 1.0;
end;

procedure TFrTurn.OnCalculate;
var N, NN, KK : integer;
    k, i : integer;
begin
  fMotion := Motion.TMotion.Create;
  fPropeller := Propeller.TPropeller.Create;
  fHull := Hull.THull.Create;
  fRudder := Rudder.TRudder.Create;
  fMotionSolver := MotionSolver.TMotionSolver.Create;
  m_RPM := StrToFloat(Ed2.Text);
  m_RudderAngle := StrToFloat(Ed6.Text);
  m_DT := StrToFloat(Ed3.Text);
  m_TMax := StrToFloat(Ed4.Text);
  m_ResultVelStrkKt := StrToFloat(Ed1.Text);
  m_InitialRPM := StrToFloat(Ed5.Text);
  m_WritingTime := StrToFloat(Ed7.Text);
  fMotion.sh_Resultvelstar := 0.5144444*m_ResultVelStrkKt;
  fMotion.sh_SurgeVel := fMotion.sh_Resultvelstar*Cos(fMotion.sh_DriftAngle);
  fMotion.sh_SwayVel := -1.0*fMotion.sh_Resultvelstar*Sin(fMotion.sh_DriftAngle);
  fPropeller.sh_RPS := m_InitialRPM / 60.0;
  fPropeller.sh_OrderRPM := m_RPM;
  fRudder.sh_OrderRudderAngleD := m_RudderAngle;
  fMotionSolver.Dt := m_Dt;
  k := Round(m_Tmax/m_Dt);
// i := -1;
  N := 0;
  For i:= 0 to k do begin
    fMotionSolver.RungeKuttaGill(fMotion,fhull,fPropeller,fRudder);
    N := N+1;
    KK := Trunc(m_WritingTime/fMotionSolver.Dt+0.1);
    NN := Trunc(N/KK);
  end;
  if ((N-NN*KK) = 0) then begin
    Application.MessageBox('The Calculation End!!!','Information',mb_Ok+mb_iconinformation);
  end;
  fMotion.Free;
  fPropeller.Free;
  fHull.Free;
  fRudder.Free;
  fMotionSolver.Free;
end;

procedure TFrTurn.Bt1Click(Sender: TObject);
begin
Oncalculate;
end;

end.

저는 루프를 돌려서 계속 계산을 하고 싶은데 계산이 안되네요...
그리고 각 클래스의 함수에서는 계속해서 계산을 합니다.
그러니까 계산된 변수는 계속 변화지요...
그리고 Time에 따라 계산하게 되어 있어요...
부탁드립니다.
0  COMMENTS