2.0协议完善加简单交管配置
This commit is contained in:
@@ -10,13 +10,14 @@ namespace StandardScene.Fass2Simulator
|
||||
{
|
||||
public const byte StartStopPass = 1;
|
||||
public const byte StartStopStop = 2;
|
||||
public const byte StartStopControlStart = 11;
|
||||
public const byte StartStopControlStop = 12;
|
||||
public const byte StartStopPrecision = 22;
|
||||
|
||||
private static readonly (string Name, Func<Fass2SimNodeMessage, byte> Get)[] ActionFields =
|
||||
public static bool VerifyTrajectoryFields { get; set; }
|
||||
|
||||
private static readonly (string Name, Func<Fass2SimNodeMessage, byte> Get)[] MechanismFields =
|
||||
{
|
||||
("Direction", n => n.Direction),
|
||||
("Orientation", n => n.Orientation),
|
||||
("Byroad", n => n.Byroad),
|
||||
("Obstacle", n => n.Obstacle),
|
||||
("Audio", n => n.Audio),
|
||||
("Light", n => n.Light),
|
||||
@@ -29,6 +30,18 @@ namespace StandardScene.Fass2Simulator
|
||||
("Shutdown", n => n.Shutdown)
|
||||
};
|
||||
|
||||
private static readonly (string Name, Func<Fass2SimNodeMessage, byte> Get)[] TrajectoryFields =
|
||||
{
|
||||
("Direction", n => n.Direction),
|
||||
("Orientation", n => n.Orientation),
|
||||
("Byroad", n => n.Byroad)
|
||||
};
|
||||
|
||||
public static bool AllowsAutoContinue(byte startStop)
|
||||
{
|
||||
return startStop == StartStopPass || startStop == StartStopControlStart;
|
||||
}
|
||||
|
||||
public static bool RequiresActionWait(Fass2SimNodeMessage expected)
|
||||
{
|
||||
if (expected == null)
|
||||
@@ -36,12 +49,25 @@ namespace StandardScene.Fass2Simulator
|
||||
return false;
|
||||
}
|
||||
|
||||
if (expected.StartStop is StartStopStop or StartStopPrecision)
|
||||
if (expected.StartStop is StartStopStop or StartStopPrecision or StartStopControlStop or StartStopControlStart)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
foreach (var field in ActionFields)
|
||||
foreach (var field in MechanismFields)
|
||||
{
|
||||
if (field.Get(expected) != 0)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
if (!VerifyTrajectoryFields)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach (var field in TrajectoryFields)
|
||||
{
|
||||
if (field.Get(expected) != 0)
|
||||
{
|
||||
@@ -64,7 +90,7 @@ namespace StandardScene.Fass2Simulator
|
||||
return false;
|
||||
}
|
||||
|
||||
if (vehicleState == 1)
|
||||
if (vehicleState is 1 or 5)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -79,6 +105,11 @@ namespace StandardScene.Fass2Simulator
|
||||
return true;
|
||||
}
|
||||
|
||||
if (expected.StartStop == StartStopControlStop)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return ListPendingFields(expected, actual).Count == 0;
|
||||
}
|
||||
|
||||
@@ -95,12 +126,24 @@ namespace StandardScene.Fass2Simulator
|
||||
pending.Add("StartStop");
|
||||
}
|
||||
|
||||
if (expected.Speed != 0 && actual.Speed != expected.Speed)
|
||||
if (VerifyTrajectoryFields)
|
||||
{
|
||||
pending.Add("Speed");
|
||||
if (expected.Speed != 0 && actual.Speed != expected.Speed)
|
||||
{
|
||||
pending.Add("Speed");
|
||||
}
|
||||
|
||||
foreach (var field in TrajectoryFields)
|
||||
{
|
||||
var expectedValue = field.Get(expected);
|
||||
if (expectedValue != 0 && GetActualField(actual, field.Name) != expectedValue)
|
||||
{
|
||||
pending.Add(field.Name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
foreach (var field in ActionFields)
|
||||
foreach (var field in MechanismFields)
|
||||
{
|
||||
var expectedValue = field.Get(expected);
|
||||
if (expectedValue != 0 && GetActualField(actual, field.Name) != expectedValue)
|
||||
|
||||
Reference in New Issue
Block a user