Skip to content

Commit

Permalink
Merge b836996 into 4be8028
Browse files Browse the repository at this point in the history
  • Loading branch information
TetsuOtter authored Jul 26, 2024
2 parents 4be8028 + b836996 commit 86bcd56
Show file tree
Hide file tree
Showing 38 changed files with 1,303 additions and 607 deletions.
27 changes: 27 additions & 0 deletions TRViS.ILocationService/ILocationLonLat_deg.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System;

namespace TRViS.Services;

public interface ILocationLonLat_deg : IEquatable<ILocationLonLat_deg>
{
bool HasLonLatLocation { get; }
double Location_lon_deg { get; }
double Location_lat_deg { get; }

bool IEquatable<ILocationLonLat_deg>.Equals(ILocationLonLat_deg? other)
{
if (other is null)
return false;

if (ReferenceEquals(this, other))
return true;

return
HasLonLatLocation == other.HasLonLatLocation
&&
Location_lon_deg == other.Location_lon_deg
&&
Location_lat_deg == other.Location_lat_deg
;
}
}
22 changes: 22 additions & 0 deletions TRViS.ILocationService/ILocationService.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
using System;

namespace TRViS.Services;

public interface ILocationService
{
bool IsEnabled { get; set; }
bool CanUseService { get; }
event EventHandler<bool>? CanUseServiceChanged;

event EventHandler<LocationStateChangedEventArgs>? LocationStateChanged;

StaLocationInfo[]? StaLocationInfo { get; set; }

int CurrentStationIndex { get; }

bool IsRunningToNextStation { get; }

void ResetLocationInfo();

void ForceSetLocationInfo(int stationIndex, bool isRunningToNextStation);
}
48 changes: 48 additions & 0 deletions TRViS.ILocationService/LocationLonLat_deg.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
using System;

namespace TRViS.Services;

public class LocationLonLat_deg : ILocationLonLat_deg, IEquatable<LocationLonLat_deg>
{
public bool HasLonLatLocation { get; }
public double Location_lon_deg { get; }
public double Location_lat_deg { get; }

public LocationLonLat_deg(
double location_lon_deg,
double location_lat_deg
)
{
Location_lon_deg = location_lon_deg;
Location_lat_deg = location_lat_deg;
HasLonLatLocation = true;
}

public bool Equals(LocationLonLat_deg? other)
{
if (other is null)
return false;

if (ReferenceEquals(this, other))
return true;

return
((IEquatable<ILocationLonLat_deg>)this).Equals(other)
&&
Location_lon_deg == other.Location_lon_deg
&&
Location_lat_deg == other.Location_lat_deg
;
}

public override bool Equals(object obj)
=> Equals(obj as LocationLonLat_deg);

public override int GetHashCode()
=> HashCode.Combine(Location_lon_deg, Location_lat_deg);

public override string ToString()
{
return $"{nameof(LocationLonLat_deg)} {{ lon:{Location_lon_deg}, lat:{Location_lat_deg} }}";
}
}
38 changes: 38 additions & 0 deletions TRViS.ILocationService/LocationStateChangedEventArgs.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
using System;

namespace TRViS.Services;

public class LocationStateChangedEventArgs(
int newStationIndex,
bool isRunningToNextStation
) : EventArgs, IEquatable<LocationStateChangedEventArgs>
{
public int NewStationIndex { get; } = newStationIndex;
public bool IsRunningToNextStation { get; } = isRunningToNextStation;

public bool Equals(LocationStateChangedEventArgs? other)
{
if (other is null)
return false;

if (ReferenceEquals(this, other))
return true;

return
NewStationIndex == other.NewStationIndex
&&
IsRunningToNextStation == other.IsRunningToNextStation
;
}

public override bool Equals(object obj)
=> Equals(obj as LocationStateChangedEventArgs);

public override int GetHashCode()
=> HashCode.Combine(NewStationIndex, IsRunningToNextStation);

public override string ToString()
{
return $"{nameof(LocationStateChangedEventArgs)} {{ {nameof(NewStationIndex)}: {NewStationIndex}, {nameof(IsRunningToNextStation)}: {IsRunningToNextStation} }}";
}
}
Original file line number Diff line number Diff line change
@@ -1,73 +1,6 @@
namespace TRViS.Services;

public interface ILocationLonLat_deg : IEquatable<ILocationLonLat_deg>
{
bool HasLonLatLocation { get; }
double Location_lon_deg { get; }
double Location_lat_deg { get; }

bool IEquatable<ILocationLonLat_deg>.Equals(ILocationLonLat_deg? other)
{
if (other is null)
return false;
using System;

if (ReferenceEquals(this, other))
return true;

return
HasLonLatLocation == other.HasLonLatLocation
&&
Location_lon_deg == other.Location_lon_deg
&&
Location_lat_deg == other.Location_lat_deg
;
}
}

public class LocationLonLat_deg : ILocationLonLat_deg, IEquatable<LocationLonLat_deg>
{
public bool HasLonLatLocation { get; }
public double Location_lon_deg { get; }
public double Location_lat_deg { get; }

public LocationLonLat_deg(
double location_lon_deg,
double location_lat_deg
)
{
Location_lon_deg = location_lon_deg;
Location_lat_deg = location_lat_deg;
HasLonLatLocation = true;
}

public bool Equals(LocationLonLat_deg? other)
{
if (other is null)
return false;

if (ReferenceEquals(this, other))
return true;

return
((IEquatable<ILocationLonLat_deg>)this).Equals(other)
&&
Location_lon_deg == other.Location_lon_deg
&&
Location_lat_deg == other.Location_lat_deg
;
}

public override bool Equals(object obj)
=> Equals(obj as LocationLonLat_deg);

public override int GetHashCode()
=> HashCode.Combine(Location_lon_deg, Location_lat_deg);

public override string ToString()
{
return $"{nameof(LocationLonLat_deg)} {{ lon:{Location_lon_deg}, lat:{Location_lat_deg} }}";
}
}
namespace TRViS.Services;

public class StaLocationInfo : ILocationLonLat_deg, IEquatable<StaLocationInfo>
{
Expand Down
9 changes: 9 additions & 0 deletions TRViS.ILocationService/TRViS.ILocationService.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<LangVersion>12.0</LangVersion>
<Nullable>enable</Nullable>
</PropertyGroup>

</Project>
4 changes: 2 additions & 2 deletions TRViS.IO.Tests/TRViS.IO.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.9.0" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.10.0" />
<PackageReference Include="NUnit" Version="4.1.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.5.0" />
<PackageReference Include="NUnit3TestAdapter" Version="4.6.0" />
<PackageReference Include="NUnit.Analyzers" Version="4.2.0"><IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
6 changes: 3 additions & 3 deletions TRViS.IO/Loaders/ILoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ public interface ILoader : IDisposable
{
IReadOnlyList<TrainDataGroup> GetTrainDataGroupList();

TrainData? GetTrainData(int trainId);
TrainData? GetTrainData(string trainId);

IReadOnlyList<Models.DB.WorkGroup> GetWorkGroupList();

IReadOnlyList<Models.DB.Work> GetWorkList(int workGroupId);
IReadOnlyList<Models.DB.Work> GetWorkList(string workGroupId);

IReadOnlyList<Models.DB.TrainData> GetTrainDataList(int workId);
IReadOnlyList<Models.DB.TrainData> GetTrainDataList(string workId);
}
Loading

0 comments on commit 86bcd56

Please sign in to comment.