优化自动充电策略

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,35 +208,32 @@ 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
}
if (stopCount > 0)
{
if (chargingList.Count > 0)
{
Log.Info($"stopCount={stopCount}");
if (stopCount > 0)
chargingList = chargingList.OrderByDescending(i => i.Soc).ToList();
int count = 0;
foreach (var ch in chargingList)
{
if (chargingList.Count > 0)
if (ch.Soc < StaticStationInfo.ChargeSoc)
{
chargingList = chargingList.OrderByDescending(i => i.Soc).ToList();
int count = 0;
foreach (var ch in chargingList)
Log.Info($"auto stop charge by more charging bin {ch.No} soc:{ch.Soc}");
ClientMgr.GetBySn(ch.ChargerNo)?.SendRemoteStopCharging();
count++;
if (count == stopCount)
{
if (ch.Soc < StaticStationInfo.ChargeSoc)
{
Log.Info($"auto stop charge by more charging bin {ch.No} soc:{ch.Soc}");
ClientMgr.GetBySn(ch.ChargerNo)?.SendRemoteStopCharging();
count++;
if (count == stopCount)
{
break;
}
}
break;
}
}
}

Loading…
Cancel
Save