Track sub state
This commit is contained in:
parent
3125911eaf
commit
1cbe018642
@ -240,6 +240,7 @@ internal sealed class InfluxStatisticsClient : IDisposable
|
|||||||
.Tag("build", sub.Build)
|
.Tag("build", sub.Build)
|
||||||
.Field("level", sub.Level)
|
.Field("level", sub.Level)
|
||||||
.Field("predicted_level", sub.PredictedLevel)
|
.Field("predicted_level", sub.PredictedLevel)
|
||||||
|
.Field("state", (int)sub.State)
|
||||||
.Timestamp(date, WritePrecision.S));
|
.Timestamp(date, WritePrecision.S));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
8
Influx/SubmarineTracker/EState.cs
Normal file
8
Influx/SubmarineTracker/EState.cs
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
namespace Influx.SubmarineTracker;
|
||||||
|
|
||||||
|
public enum EState
|
||||||
|
{
|
||||||
|
NoVoyage,
|
||||||
|
Returned,
|
||||||
|
Voyage,
|
||||||
|
}
|
@ -14,6 +14,13 @@ public sealed class Submarine
|
|||||||
{
|
{
|
||||||
(uint predictedLevel, double _) = ((uint, double))@delegate.GetType().GetMethod("PredictExpGrowth")!.Invoke(@delegate, Array.Empty<object?>())!;
|
(uint predictedLevel, double _) = ((uint, double))@delegate.GetType().GetMethod("PredictExpGrowth")!.Invoke(@delegate, Array.Empty<object?>())!;
|
||||||
PredictedLevel = (ushort)predictedLevel;
|
PredictedLevel = (ushort)predictedLevel;
|
||||||
|
|
||||||
|
bool onVoyage = (bool)@delegate.GetType().GetMethod("IsOnVoyage")!.Invoke(@delegate, Array.Empty<object>())!;
|
||||||
|
bool returned = (bool)@delegate.GetType().GetMethod("IsDone")!.Invoke(@delegate, Array.Empty<object>())!;
|
||||||
|
if (onVoyage)
|
||||||
|
State = returned ? EState.Returned : EState.Voyage;
|
||||||
|
else
|
||||||
|
State = EState.NoVoyage;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception)
|
||||||
{
|
{
|
||||||
@ -25,4 +32,5 @@ public sealed class Submarine
|
|||||||
public ushort Level { get; }
|
public ushort Level { get; }
|
||||||
public ushort PredictedLevel { get; }
|
public ushort PredictedLevel { get; }
|
||||||
public Build Build { get; }
|
public Build Build { get; }
|
||||||
|
public EState State { get; }
|
||||||
}
|
}
|
||||||
|
@ -12,4 +12,5 @@ public sealed class SubmarineStats
|
|||||||
public required string Bow { get; init; }
|
public required string Bow { get; init; }
|
||||||
public required string Bridge { get; init; }
|
public required string Bridge { get; init; }
|
||||||
public required string Build { get; init; }
|
public required string Build { get; init; }
|
||||||
|
public required EState State { get; init; }
|
||||||
}
|
}
|
||||||
|
@ -52,6 +52,7 @@ internal sealed class SubmarineTrackerIpc
|
|||||||
Bow = y.Build.BowIdentifier,
|
Bow = y.Build.BowIdentifier,
|
||||||
Bridge = y.Build.BridgeIdentifier,
|
Bridge = y.Build.BridgeIdentifier,
|
||||||
Build = y.Build.FullIdentifier,
|
Build = y.Build.FullIdentifier,
|
||||||
|
State = y.State,
|
||||||
}).ToList());
|
}).ToList());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
Loading…
Reference in New Issue
Block a user