fix: Mag2 环线补锁失败时不再派车
TrafficReset 失败则跳过 AssignCarToTarget,避免无锁占用仍打上 goalSite。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -2,6 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using LessokajiWeaverUtilities.Utilities;
|
||||||
using SimpleCore;
|
using SimpleCore;
|
||||||
using SimpleCore.Library;
|
using SimpleCore.Library;
|
||||||
using Simple3;
|
using Simple3;
|
||||||
@@ -64,9 +65,9 @@ namespace StandardScene
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected override void AssignCarToTarget(Car car, int targetSiteId)
|
protected override void AssignCarToTarget(Car car, int targetSiteId)
|
||||||
{
|
{
|
||||||
if (car is Mag2Car mag2)
|
if (car is Mag2Car mag2 && !EnsureMag2HoldingCurrentSite(mag2))
|
||||||
{
|
{
|
||||||
EnsureMag2HoldingCurrentSite(mag2);
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
base.AssignCarToTarget(car, targetSiteId);
|
base.AssignCarToTarget(car, targetSiteId);
|
||||||
@@ -183,26 +184,31 @@ namespace StandardScene
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
private static void EnsureMag2HoldingCurrentSite(Mag2Car car)
|
private static bool EnsureMag2HoldingCurrentSite(Mag2Car car)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (car.status?.holdingLocks != null && car.status.holdingLocks.Length == 1)
|
if (car.status?.holdingLocks != null && car.status.holdingLocks.Length == 1)
|
||||||
return;
|
return true;
|
||||||
|
|
||||||
var siteId = car.siteID > 0 ? car.siteID : car.GetLastSite();
|
var siteId = car.siteID > 0 ? car.siteID : car.GetLastSite();
|
||||||
if (siteId <= 0)
|
if (siteId <= 0)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
var site = SimpleLib.GetSite(siteId);
|
var site = SimpleLib.GetSite(siteId);
|
||||||
if (site == null)
|
if (site == null)
|
||||||
return;
|
return false;
|
||||||
|
|
||||||
car.TrafficReset(site, true, strict: false);
|
car.TrafficReset(site, true, strict: false);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
catch (Exception)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
// 交管失败时仍允许打上 goalSite,后续 GoSite/状态机会再处理
|
Diagnosis.Post(
|
||||||
|
$"Mag2 补交管锁失败,跳过派车 car={car?.id}:{ex.Message}",
|
||||||
|
"Mag2Loop",
|
||||||
|
true);
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user