2.0协议完善加简单交管配置
This commit is contained in:
@@ -58,6 +58,15 @@ namespace StandardScene.Fass2Simulator
|
||||
}
|
||||
}
|
||||
|
||||
public void ResetForNewTask()
|
||||
{
|
||||
lock (_syncRoot)
|
||||
{
|
||||
_pendingActions.Clear();
|
||||
_expectedStation = null;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnActionCommand(ulong actionId, Fass2SimNodeMessage patch)
|
||||
{
|
||||
if (patch == null)
|
||||
@@ -67,13 +76,16 @@ namespace StandardScene.Fass2Simulator
|
||||
|
||||
lock (_syncRoot)
|
||||
{
|
||||
var targetNode = patch.Node != 0 ? patch.Node : _vehicle.Node;
|
||||
if (patch.Node != 0 && patch.Node != _vehicle.Node)
|
||||
{
|
||||
Fass2SimLog.WriteLine(
|
||||
$"[{Now()}] -> 0xA1 节点不匹配: patch={patch.Node}, current={_vehicle.Node},仍尝试应用");
|
||||
$"[{Now()}] -> 0xA1 忽略: patch node={patch.Node}, current={_vehicle.Node}");
|
||||
return;
|
||||
}
|
||||
|
||||
var delay = ResolveActionDelayMs(patch.Node != 0 ? patch.Node : _vehicle.Node);
|
||||
var delay = ResolveActionDelayMs(targetNode);
|
||||
MergeExpectedLocked(patch);
|
||||
SchedulePatch(patch, actionId, 0, delay);
|
||||
Fass2SimLog.WriteLine(
|
||||
$"[{Now()}] -> 0xA1 actionId={actionId} 已排队,delay={delay}ms, pending={DescribePatch(patch)}");
|
||||
@@ -161,6 +173,37 @@ namespace StandardScene.Fass2Simulator
|
||||
}
|
||||
}
|
||||
|
||||
public void MergeExpected(Fass2SimNodeMessage patch)
|
||||
{
|
||||
if (patch == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
lock (_syncRoot)
|
||||
{
|
||||
MergeExpectedLocked(patch);
|
||||
}
|
||||
}
|
||||
|
||||
private void MergeExpectedLocked(Fass2SimNodeMessage patch)
|
||||
{
|
||||
if (_expectedStation == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (patch.Node != 0 && patch.Node != _expectedStation.Node)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (patch.StartStop > 0)
|
||||
{
|
||||
_expectedStation.StartStop = patch.StartStop;
|
||||
}
|
||||
}
|
||||
|
||||
private bool IsStationCompleteLocked()
|
||||
{
|
||||
if (_pendingActions.Count > 0)
|
||||
@@ -229,9 +272,9 @@ namespace StandardScene.Fass2Simulator
|
||||
|
||||
private void ApplyPatch(Fass2SimNodeMessage patch)
|
||||
{
|
||||
if (patch.Node != 0)
|
||||
if (patch.Node != 0 && patch.Node != _vehicle.Node)
|
||||
{
|
||||
_vehicle.Node = patch.Node;
|
||||
return;
|
||||
}
|
||||
|
||||
if (patch.StartStop > 0)
|
||||
|
||||
Reference in New Issue
Block a user