Skip to content

Commit

Permalink
Merge pull request #45 from Tralsys/44-bveex
Browse files Browse the repository at this point in the history
BveEX対応
  • Loading branch information
TetsuOtter authored Dec 22, 2024
2 parents 7ee651f + ee2a7bb commit 31eb611
Show file tree
Hide file tree
Showing 13 changed files with 61 additions and 36 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/publish-to-nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ jobs:
VERSION: ${{ steps.get-project-info.outputs.VERSION }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Get Project Info
id: get-project-info
shell: pwsh
run: ./.github/workflows/get-version.ps1 -ProjectName ${{ inputs.project }}

- name: Setup .NET
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: 6.0.x

Expand All @@ -49,7 +49,7 @@ jobs:
run: dotnet pack ${{ inputs.project }} -c Release --no-build -o dst

- name: Upload nupkg to Artifact
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: ${{ steps.get-project-info.outputs.ASSEMBLY_NAME }}.${{ steps.get-project-info.outputs.VERSION }}.nupkg
path: dst/${{ steps.get-project-info.outputs.ASSEMBLY_NAME }}.${{ steps.get-project-info.outputs.VERSION }}.nupkg
Expand All @@ -61,7 +61,7 @@ jobs:

steps:
- name: Download nupkg from Artifact
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: ${{ needs.build.outputs.ASSEMBLY_NAME }}.${{ needs.build.outputs.VERSION }}.nupkg

Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/unit-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,10 @@ jobs:
- TR.SMemIF.Tests

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Setup .NET Core SDK ${{ matrix.dotnet-version }}
uses: actions/setup-dotnet@v3
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ matrix.dotnet-version }}

Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/upload-docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- run: sudo apt update

Expand All @@ -32,13 +32,13 @@ jobs:

- name: Setup Pages
id: pages
uses: actions/configure-pages@v2
uses: actions/configure-pages@v5

- name: Build with Doxygen
run: doxygen

- name: Upload artifact
uses: actions/upload-pages-artifact@v1
uses: actions/upload-pages-artifact@v3
with:
path: docs/html

Expand All @@ -55,4 +55,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1
uses: actions/deploy-pages@v4
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
<TargetFramework>netstandard2.0</TargetFramework>
<Nullable>enable</Nullable>
<LangVersion>12.0</LangVersion>
<AssemblyName>TR.BIDSSMemLib.AtsEX</AssemblyName>
<AssemblyName>TR.BIDSSMemLib.BveEX</AssemblyName>
<RootNamespace>TR.BIDSSMemLib</RootNamespace>
<Version>1.0.0</Version>
<Version>1.1.0</Version>
<Authors>Tetsu Otter</Authors>
<Company>Tech Otter</Company>
<Product>BIDS Project</Product>
Expand All @@ -26,8 +26,8 @@

<ItemGroup>
<PackageReference
Include="AtsEx.PluginHost"
Version="1.0.0-rc4">
Include="BveEx.PluginHost"
Version="2.0.0">
<PrivateAssets>all</PrivateAssets>
</PackageReference>
</ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
using System;

using AtsEx.PluginHost.Plugins;
using AtsEx.PluginHost.Plugins.Extensions;
using BveEx.PluginHost.Plugins;
using BveEx.PluginHost.Plugins.Extensions;

using BveTypes.ClassWrappers;

namespace TR.BIDSSMemLib;

[PluginType(PluginType.Extension)]
public partial class AtsExInterface : AssemblyPluginBase, IExtension
[Plugin(PluginType.Extension)]
public partial class BveExInterface : AssemblyPluginBase, IExtension
{
readonly SMemLib smemLib = new(
isNoSMemMode: false,
isNoEventMode: true,
isNoOptionalEventMode: true
);

public AtsExInterface(PluginBuilder builder) : base(builder)
public BveExInterface(PluginBuilder builder) : base(builder)
{
smemLib.Write(bsmd);
smemLib.Write(openD);
Expand Down Expand Up @@ -49,7 +49,7 @@ public override void Dispose()
readonly bool[] keyStateArray = new bool[CtrlInput.KeyArrSizeMax];
BveInstanceManager? bveInstanceManager = null;

public override TickResult Tick(TimeSpan elapsed)
public override void Tick(TimeSpan elapsed)
{
if (BveHacker.IsScenarioCreated)
{
Expand Down Expand Up @@ -121,8 +121,6 @@ public override TickResult Tick(TimeSpan elapsed)
}
else if (bsmd.IsEnabled)
OnScenarioClosed();

return new ExtensionTickResult();
}
static bool isHandsEqual(in Hands a, in Hands b)
=> (
Expand Down Expand Up @@ -158,23 +156,23 @@ class BveInstanceManager
readonly SideDoorSet rightDoorSet;
readonly CarInfo motorCarInfo;
readonly CarInfo trailerCarInfo;
readonly UserVehicleLocationManager locationManager;
readonly VehicleLocation vehicleLocation;
public readonly HandleSet handles;
readonly TimeManager timeManager;
readonly VehicleStateStore vehicleStateStore;
public readonly AtsPlugin atsPlugin;

public BveInstanceManager(Scenario scenario)
{
Route route = scenario.Route;
preTrainObj = route.PreTrainObjects;
Map map = scenario.Map;
preTrainObj = map.PreTrainObjects;

MyTrack track = route.MyTrack;
MyTrack track = map.MyTrack;
curves = track.Curves;
cants = track.Cants;

vehicle = scenario.Vehicle;
locationManager = scenario.LocationManager;
vehicleLocation = scenario.VehicleLocation;
timeManager = scenario.TimeManager;

DoorSet doorSet = vehicle.Doors;
Expand Down Expand Up @@ -222,7 +220,7 @@ ref BIDSSharedMemoryData bsmd
I = (float)vehicleStateStore.Current[0],
T = (int)timeManager.TimeMilliseconds,
V = (float)vehicleStateStore.Speed[0],
Z = locationManager.Location,
Z = vehicleLocation.Location,
};
bsmd.HandleData = new()
{
Expand All @@ -249,8 +247,8 @@ in TimeSpan elapsed
double preTrainLocation = preTrainObj.GetPreTrainLocation(timeManager.TimeMilliseconds);
double preTrainSpeed_mps = (preTrainLocation - preTrainLastLocation) / elapsed.TotalSeconds;
double preTrainSpeed_kmph = preTrainSpeed_mps * 3.6;
Cant? cant = cants.GoToAndGetCurrent(locationManager.Location) as Cant;
Curve? curve = curves.GoToAndGetCurrent(locationManager.Location) as Curve;
Cant? cant = cants.GoToAndGetCurrent(vehicleLocation.Location) as Cant;
Curve? curve = curves.GoToAndGetCurrent(vehicleLocation.Location) as Curve;
double curvature = curve?.Curvature ?? 0;
double curveRadius = curvature != 0 ? 1 / curvature
: openD.Radius < 0 ? double.NegativeInfinity : double.PositiveInfinity;
Expand All @@ -269,7 +267,7 @@ in TimeSpan elapsed
PreTrain = new()
{
IsEnabled = false,
Distance = preTrainLocation - locationManager.Location,
Distance = preTrainLocation - vehicleLocation.Location,
Location = preTrainLocation,
Speed = preTrainSpeed_kmph,
},
Expand Down
16 changes: 16 additions & 0 deletions BIDSSMemLib.BveEX/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# BIDSSMemLib BveEX Extension Plugin

zip解凍前にブロック解除を行ったうえで、`C:\Users\Public\Documents\BveEx\2.0\Extensions` に、`TR.BIDSSMemLib.BveEX.dll``TR.BIDSSMemLib.BveEX.deps` を配置してください。

BIDSSMemLibのATSプラグイン版や入力デバイスプラグイン版と競合せずに動作しますが、基本的にはどちらも削除したうえでご利用ください。

現時点では、以下の機能が未実装です。

- キー入力機能
- カント高さ (高さではなく角度で入っている)
- 勾配情報

## 更新履歴

- 1.0.0 新規公開
- 1.1.0 BveEX対応
4 changes: 2 additions & 2 deletions BIDSSMemLib.CtrlInput/CtrlInput.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ public static class CtrlInput
public static readonly int KeyArrSizeMax = 128;
public static bool IsDisposed { get; private set; }

static SMemIF SMIF_CtrlH = null;
static SMemIF SMIF_CtrlK = null;
static readonly SMemIF SMIF_CtrlH;
static readonly SMemIF SMIF_CtrlK;

static CtrlInput()
{
Expand Down
2 changes: 1 addition & 1 deletion BIDSSMemLib.sln
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BIDSSMemLib.RandomWriter",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BIDSSMemLib.CtrlInput", "BIDSSMemLib.CtrlInput\BIDSSMemLib.CtrlInput.csproj", "{783FDE97-8558-45DA-BCB1-AD7A245CDB3E}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BIDSSMemLib.AtsEX", "BIDSSMemLib.AtsEX\BIDSSMemLib.AtsEX.csproj", "{82EFFCCC-E021-4E39-BC33-4F3D189D7245}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BIDSSMemLib.BveEX", "BIDSSMemLib.BveEX\BIDSSMemLib.BveEX.csproj", "{82EFFCCC-E021-4E39-BC33-4F3D189D7245}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
2 changes: 1 addition & 1 deletion BIDSSMemLib_Mac.sln
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BIDSSMemLib.ValueChecker",
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BIDSSMemLib.CtrlInput", "BIDSSMemLib.CtrlInput\BIDSSMemLib.CtrlInput.csproj", "{7391C730-6776-4DF1-B645-6FBC85F2C682}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BIDSSMemLib.AtsEX", "BIDSSMemLib.AtsEX\BIDSSMemLib.AtsEX.csproj", "{82EFFCCC-E021-4E39-BC33-4F3D189D7245}"
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BIDSSMemLib.BveEX", "BIDSSMemLib.BveEX\BIDSSMemLib.BveEX.csproj", "{82EFFCCC-E021-4E39-BC33-4F3D189D7245}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand Down
4 changes: 4 additions & 0 deletions TR.ISMemCtrler/ValueChangedEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
namespace TR;

/// <summary>
/// 値に変化があったことを通知するイベントの情報
/// </summary>
/// <typeparam name="T">対象の値の型</typeparam>
public class ValueChangedEventArgs<T>
{
/// <summary>更新前の値</summary>
Expand Down
2 changes: 1 addition & 1 deletion TR.SMemCtrler/ArrayDataSMemCtrler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ public void Add(in T item)
}

CheckAndUpdateMMF4ArrayInstance(newLen);
_ = MMF4Array.WriteArray(0, Value.ToArray(), 0, newLen);
_ = MMF4Array?.WriteArray(0, Value.ToArray(), 0, newLen);
}

/// <summary>リストを空にします</summary>
Expand Down
1 change: 1 addition & 0 deletions TR.SMemCtrler/SMemCtrler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public bool TryReadInObject(out object obj)
public bool TryWriteInObject(in object obj) => TryWrite((T)obj);
#endregion

/// <inheritdoc/>
protected override bool IsValueSame(T v1, T v2)
=> Equals(v1, v2);
}
Expand Down
6 changes: 6 additions & 0 deletions TR.SMemCtrler/SMemCtrlerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,12 @@ protected void CheckAndNotifyPropertyChanged(in T newValue, in bool doWriteToSMe
}
}

/// <summary>
/// 値が同じかどうかを判定します
/// </summary>
/// <param name="v1">値1</param>
/// <param name="v2">値2</param>
/// <returns>値が同じかどうか</returns>
protected abstract bool IsValueSame(T v1, T v2);

/// <summary>インスタンスを初期化する</summary>
Expand Down

0 comments on commit 31eb611

Please sign in to comment.