优化自动充电策略

master
lxw 4 weeks ago
parent 19c335511f
commit 897aeaae45

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

Loading…
Cancel
Save