优化自动充电策略

master
lxw 4 weeks ago
parent 19c335511f
commit 897aeaae45

@ -32,7 +32,7 @@ public class AutoChargeTask : ITask
public int Interval()
{
return 1000 * 10;
return 1000 * 15;
}
public void Handle()
@ -142,7 +142,7 @@ public class AutoChargeTask : ITask
int needBatteryCount = opModelDetails[0].BatteryCount ?? 8;
List<BinInfo> canSwapList = allBinInfos.Where(it =>
it.Soc != null && Convert.ToSingle(it.Soc) >= StaticStationInfo.SwapSoc && it.CanSwapFlag == 1)
it.Soc != null && Convert.ToSingle(it.Soc) >= StaticStationInfo.SwapSoc && it.CanSwapFlag == 1 && it.ChargeStatus!=1)
.ToList();
/*if (canSwapList.Count == needBatteryCount)
{
@ -171,25 +171,27 @@ public class AutoChargeTask : ITask
}*/
#endregion
int stopCount = chargingList.Count + canSwapList.Count - needBatteryCount;
Log.Info($"chargingList.Count={chargingList.Count}, canSwapList.Count={canSwapList.Count},needBatteryCount={needBatteryCount}");
Log.Info($"stopCount={stopCount}");
if (canSwapList.Count < needBatteryCount)
{
int stopCount = chargingList.Count + canSwapList.Count - needBatteryCount;
if (stopCount < 0)
{
Log.Info($"stopCount={stopCount}");
// Log.Info($"stopCount={stopCount}");
List<BinInfo> canChargeList = binInfos.Where(it =>
it.Soc != null && Convert.ToSingle(it.Soc) < StaticStationInfo.SwapSoc &&
it.CanChargeFlag == 1 && it.Exists == 1 && it.ChargeStatus != 1)
.ToList();
//启动电量高的
canChargeList.Sort((a, b) => (b.Soc ?? 0).CompareTo(a.Soc ?? 0));
stopCount = Math.Abs(stopCount);
byte chargeSoc = StaticStationInfo.ChargeSoc;
// int count = needBatteryCount - canSwapList.Count;
Log.Info(
$"need start count={stopCount}, canChargeList={JsonConvert.SerializeObject(canChargeList.Select(info => info.Code + "," + info.ChargerNo).ToList())}");
$"need start count={-stopCount}, canChargeList={JsonConvert.SerializeObject(canChargeList.Select(info => info.Code + "," + info.ChargerNo).ToList())}");
int number = 0;
foreach (var binInfo in canChargeList)
{
@ -206,17 +208,16 @@ public class AutoChargeTask : ITask
number++;
}
if (stopCount == number)
if (-stopCount == number)
{
Log.Info($"auto start charge count {stopCount}");
Log.Info($"auto start charge count {-stopCount}");
break;
}
}
}
}
else
{
Log.Info($"stopCount={stopCount}");
}
if (stopCount > 0)
{
if (chargingList.Count > 0)
@ -238,8 +239,6 @@ public class AutoChargeTask : ITask
}
}
}
}
}
#region 达到充电SOC自动停

Loading…
Cancel
Save