-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: [BveTypes]自列車の車体の揺れに関するメンバーを追加
- Loading branch information
1 parent
068cfbf
commit b1d3ed7
Showing
7 changed files
with
414 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using FastMember; | ||
using TypeWrapping; | ||
|
||
namespace BveTypes.ClassWrappers | ||
{ | ||
/// <summary> | ||
/// 空気ばねのモデルを表します。 | ||
/// </summary> | ||
public class AirSpring : Spring | ||
{ | ||
[InitializeClassWrapper] | ||
private static void Initialize(BveTypeSet bveTypes) | ||
{ | ||
ClassMemberSet members = bveTypes.GetClassInfoOf<AirSpring>(); | ||
} | ||
|
||
/// <summary> | ||
/// オリジナル オブジェクトから <see cref="AirSpring"/> クラスの新しいインスタンスを初期化します。 | ||
/// </summary> | ||
/// <param name="src">ラップするオリジナル オブジェクト。</param> | ||
protected AirSpring(object src) : base(src) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// オリジナル オブジェクトからラッパーのインスタンスを生成します。 | ||
/// </summary> | ||
/// <param name="src">ラップするオリジナル オブジェクト。</param> | ||
/// <returns>オリジナル オブジェクトをラップした <see cref="AirSpring"/> クラスのインスタンス。</returns> | ||
[CreateClassWrapperFromSource] | ||
public static new AirSpring FromSource(object src) => src is null ? null : new AirSpring(src); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using FastMember; | ||
using TypeWrapping; | ||
|
||
namespace BveTypes.ClassWrappers | ||
{ | ||
/// <summary> | ||
/// 6DoF (3 次元における剛体の運動の自由度) を表します。 | ||
/// </summary> | ||
/// <remarks> | ||
/// このクラスのオリジナル型は構造体であることに注意してください。 | ||
/// </remarks> | ||
public class SixDof : ClassWrapperBase | ||
{ | ||
private static Type OriginalType; | ||
|
||
[InitializeClassWrapper] | ||
private static void Initialize(BveTypeSet bveTypes) | ||
{ | ||
ClassMemberSet members = bveTypes.GetClassInfoOf<SixDof>(); | ||
|
||
OriginalType = members.OriginalType; | ||
|
||
XField = members.GetSourceFieldOf(nameof(X)); | ||
YField = members.GetSourceFieldOf(nameof(Y)); | ||
ZField = members.GetSourceFieldOf(nameof(Z)); | ||
RotationXField = members.GetSourceFieldOf(nameof(RotationX)); | ||
RotationYField = members.GetSourceFieldOf(nameof(RotationY)); | ||
RotationZField = members.GetSourceFieldOf(nameof(RotationZ)); | ||
|
||
AddMethod = members.GetSourceMethodOf(nameof(Add)); | ||
MultiplyMethod = members.GetSourceMethodOf(nameof(Multiply)); | ||
} | ||
|
||
/// <summary> | ||
/// オリジナル オブジェクトから <see cref="SixDof"/> クラスの新しいインスタンスを初期化します。 | ||
/// </summary> | ||
/// <param name="src">ラップするオリジナル オブジェクト。</param> | ||
protected SixDof(object src) : base(src) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// オリジナル オブジェクトからラッパーのインスタンスを生成します。 | ||
/// </summary> | ||
/// <param name="src">ラップするオリジナル オブジェクト。</param> | ||
/// <returns>オリジナル オブジェクトをラップした <see cref="SixDof"/> クラスのインスタンス。</returns> | ||
[CreateClassWrapperFromSource] | ||
public static SixDof FromSource(object src) => src is null ? null : new SixDof(src); | ||
|
||
public static SixDof operator +(SixDof x, SixDof y) => Add(x, y); | ||
public static SixDof operator *(double x, SixDof y) => Multiply(x, y); | ||
|
||
/// <summary> | ||
/// 座標、回転を指定して <see cref="SixDof"/> クラスの新しいインスタンスを初期化します。 | ||
/// </summary> | ||
/// <param name="x">X 座標。</param> | ||
/// <param name="y">Y 座標。</param> | ||
/// <param name="z">Z 座標。</param> | ||
/// <param name="rotationX">X 軸まわりの回転 (ピッチ)。</param> | ||
/// <param name="rotationY">Y 軸まわりの回転 (ヨー)。</param> | ||
/// <param name="rotationZ">Z 軸まわりの回転 (ロール)。</param> | ||
public SixDof(double x, double y, double z, double rotationX, double rotationY, double rotationZ) | ||
: this(Activator.CreateInstance(OriginalType, x, y, z, rotationX, rotationY, rotationZ)) | ||
{ | ||
} | ||
|
||
private static FastField XField; | ||
/// <summary> | ||
/// X 座標を取得・設定します。 | ||
/// </summary> | ||
public double X | ||
{ | ||
get => XField.GetValue(Src); | ||
set => XField.SetValue(Src, value); | ||
} | ||
|
||
private static FastField YField; | ||
/// <summary> | ||
/// Y 座標を取得・設定します。 | ||
/// </summary> | ||
public double Y | ||
{ | ||
get => YField.GetValue(Src); | ||
set => YField.SetValue(Src, value); | ||
} | ||
|
||
private static FastField ZField; | ||
/// <summary> | ||
/// Z 座標を取得・設定します。 | ||
/// </summary> | ||
public double Z | ||
{ | ||
get => ZField.GetValue(Src); | ||
set => ZField.SetValue(Src, value); | ||
} | ||
|
||
private static FastField RotationXField; | ||
/// <summary> | ||
/// X 軸まわりの回転 (ピッチ) を取得・設定します。 | ||
/// </summary> | ||
public double RotationX | ||
{ | ||
get => RotationXField.GetValue(Src); | ||
set => RotationXField.SetValue(Src, value); | ||
} | ||
|
||
private static FastField RotationYField; | ||
/// <summary> | ||
/// Y 軸まわりの回転 (ヨー) を取得・設定します。 | ||
/// </summary> | ||
public double RotationY | ||
{ | ||
get => RotationYField.GetValue(Src); | ||
set => RotationYField.SetValue(Src, value); | ||
} | ||
|
||
private static FastField RotationZField; | ||
/// <summary> | ||
/// Z 軸まわりの回転 (ロール) を取得・設定します。 | ||
/// </summary> | ||
public double RotationZ | ||
{ | ||
get => RotationZField.GetValue(Src); | ||
set => RotationZField.SetValue(Src, value); | ||
} | ||
|
||
private static FastMethod AddMethod; | ||
private static SixDof Add(SixDof x, SixDof y) => SixDof.FromSource(AddMethod.Invoke(null, new object[] { x.Src, y.Src })); | ||
|
||
private static FastMethod MultiplyMethod; | ||
private static SixDof Multiply(double x, SixDof y) => SixDof.FromSource(MultiplyMethod.Invoke(null, new object[] { x, y.Src })); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
using FastMember; | ||
using TypeWrapping; | ||
|
||
namespace BveTypes.ClassWrappers | ||
{ | ||
/// <summary> | ||
/// ばねのモデルを表します。 | ||
/// </summary> | ||
public class Spring : ClassWrapperBase | ||
{ | ||
[InitializeClassWrapper] | ||
private static void Initialize(BveTypeSet bveTypes) | ||
{ | ||
ClassMemberSet members = bveTypes.GetClassInfoOf<Spring>(); | ||
|
||
UpperPositionGetMethod = members.GetSourcePropertyGetterOf(nameof(UpperPosition)); | ||
UpperPositionSetMethod = members.GetSourcePropertySetterOf(nameof(UpperPosition)); | ||
|
||
UpperSpeedGetMethod = members.GetSourcePropertyGetterOf(nameof(UpperSpeed)); | ||
UpperSpeedSetMethod = members.GetSourcePropertySetterOf(nameof(UpperSpeed)); | ||
} | ||
|
||
/// <summary> | ||
/// オリジナル オブジェクトから <see cref="Spring"/> クラスの新しいインスタンスを初期化します。 | ||
/// </summary> | ||
/// <param name="src">ラップするオリジナル オブジェクト。</param> | ||
protected Spring(object src) : base(src) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// オリジナル オブジェクトからラッパーのインスタンスを生成します。 | ||
/// </summary> | ||
/// <param name="src">ラップするオリジナル オブジェクト。</param> | ||
/// <returns>オリジナル オブジェクトをラップした <see cref="Spring"/> クラスのインスタンス。</returns> | ||
[CreateClassWrapperFromSource] | ||
public static Spring FromSource(object src) => src is null ? null : new Spring(src); | ||
|
||
private static FastMethod UpperPositionGetMethod; | ||
private static FastMethod UpperPositionSetMethod; | ||
/// <summary> | ||
/// ばね上端の位置 [m] を取得・設定します。 | ||
/// </summary> | ||
public double UpperPosition | ||
{ | ||
get => UpperPositionGetMethod.Invoke(Src, null); | ||
set => UpperPositionSetMethod.Invoke(Src, new object[] { value }); | ||
} | ||
|
||
private static FastMethod UpperSpeedGetMethod; | ||
private static FastMethod UpperSpeedSetMethod; | ||
/// <summary> | ||
/// ばね上端の速度 [m/s] を取得・設定します。 | ||
/// </summary> | ||
public double UpperSpeed | ||
{ | ||
get => UpperSpeedGetMethod.Invoke(Src, null); | ||
set => UpperSpeedSetMethod.Invoke(Src, new object[] { value }); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.