You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

121 lines
3.2 KiB

/*using System.Collections.Concurrent;
5 months ago
using Common.Util;
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.AutoTask;
using log4net;
using Repository.Station;
5 months ago
using Service.Charger.Client;
using Service.Charger.Common;
5 months ago
using Service.Charger.Msg.Charger.OutCharger.Req;
using Service.Charger.Msg.Http.Req;
using Service.Charger.Server;
5 months ago
using Service.Init;
namespace Service.Charger.MyTask;
/// <summary>
/// 9.2.1.5 站控上报充电枪实时数据上报
/// </summary>
[Scope]
public class PileRealtimeTask : ITask
{
private static readonly ILog Log = LogManager.GetLogger(typeof(PileRealtimeTask));
private volatile bool _stop;
private readonly BinGunInfoRepository _binGunInfoRepository;
public PileRealtimeTask(BinGunInfoRepository binGunInfoRepository)
{
_binGunInfoRepository = binGunInfoRepository;
}
5 months ago
public string Name()
{
return "PileRealtimeTask";
}
public int Interval()
{
return 1000 * 5;
}
public void Handle()
{
if (ChargerConst._dictionary.Count <= 0)
{
var binGunInfo = _binGunInfoRepository.QueryAsync();
foreach (var binGun in binGunInfo.Result)
{
ChargerConst._dictionary.Add(new Tuple<string, int>(binGun.ChargerNo,binGun.GunNo),binGun.ChargerGunNo);
}
} if (ChargerConst._dictionary.Count <= 0)return;
ConcurrentDictionary<string, ChargerClient> chargerClients = ServerMgr.Dictionary;
5 months ago
if (chargerClients.Values.Count <= 0)
{
return;
}
foreach (var kvp in chargerClients)
{
ChargerClient client = kvp.Value;
HandleChargerPile(client, 1);
HandleChargerPile(client, 2);
}
}
public bool Stoped()
{
return _stop;
}
public void Stop()
{
_stop = true;
}
public void ResetStop()
{
_stop = false;
}
private void HandleChargerPile(ChargerClient client, byte pileIndex)
{
if (client.Connected)
5 months ago
{
ChargerPile chargerPile = pileIndex == 1 ? client.ChargerPile1 : client.ChargerPile2;
5 months ago
PileUploadTelemetry pileUploadTelemetry = client.PileUploadTelemetry[pileIndex];
PileUploadRemoteSignal pileUploadRemoteSignal = client.PileUploadRemoteSignal[pileIndex];
5 months ago
PileRealtimeReq req = new PileRealtimeReq
{
sn = StaticStationInfo.StationNo,
pn = ChargerConst._dictionary[new Tuple<string, int>(client.Sn,pileIndex)],//chargerPile.pn,
ps = GetPileStatus(client.WorkStatus[pileIndex]),
5 months ago
pov = pileUploadTelemetry.BmsChargingVoltage,
poe = pileUploadTelemetry.BmsChargingCurrent,
con = pileUploadRemoteSignal.ChargeStationGunHolderStatus?0:1,
5 months ago
ec = 0
};
HttpUtil.SendPostRequest(req, "http://127.0.0.1:5034/api/OutCharger/SendPileRealtime");
}
}
private int GetPileStatus(int workStatus)
{
return workStatus switch
{
0 => 1,
1 => 3,
2 => 4,
3 => 5,
_ => 1
};
}
}*/