现场调试更新

master
xjl 4 weeks ago
parent e6f9a74079
commit 08790cb902

@ -51,6 +51,7 @@ public class ChargerService
float? chargePower = EquipInfoRepository.QueryPowerByCode(binInfo.ChargerNo);
float? power = chargePower == null ? StaticStationInfo.ChargePower : chargePower;
power = power * 10;
return chargerClient.StartCharge(chargeSoc, (float)power, 1);
}
@ -79,19 +80,23 @@ public class ChargerService
}
//
WaterCoolClientMgr.Dictionary.TryGetValue(StaticStationInfo.RelationMap[chargerClient.Sn].WaterCoolerCode,
out WaterCoolClient client);
if (client == null)
{
return Result<bool>.Fail("未初始化液冷");
}
#region 水冷判断先屏蔽
//WaterCoolClientMgr.Dictionary.TryGetValue(StaticStationInfo.RelationMap[chargerClient.Sn].WaterCoolerCode,
// out WaterCoolClient client);
//if (client == null)
//{
// return Result<bool>.Fail("未初始化液冷");
//}
//if (!client.HeartManageStop())
//{
// return Result<bool>.Fail("液冷系统断开失败");
//}
//client.StopFlag = true;
#endregion
if (!client.HeartManageStop())
{
return Result<bool>.Fail("液冷系统断开失败");
}
client.StopFlag = true;
chargerClient.SendRemoteStopCharging();
@ -255,9 +260,11 @@ public class ChargerService
}
/// <summary>
/// 监控平台下发辅源控制指令
/// 监控平台下发电池仓的状态
/// </summary>
/// <param name="openFlag">打开辅助电源标志 1电池包辅助电源导通 0电池包辅助电源断开</param>
/// <param name="battery">是否有电池 0:无电池 1有电池</param>
/// <param name="connectionState">电接头连接状态 0:未连接 1: 已连接</param>
/// <param name="waterCondition">水接头状态 0:未连接 1: 已连接</param>
public Result<bool> SendBatteryHolderStatus(string binNo, byte battery, byte connectionState, byte waterCondition)
{
BinInfo? binInfo = BinInfoRepository.QueryByBinNo(binNo);
@ -279,4 +286,85 @@ public class ChargerService
chargerClient.SendBatteryHolderStatus(battery,connectionState,waterCondition);
return Result<bool>.Success(true);
}
/// <summary>
/// 监控平台下发掉线停止充电
/// </summary>
/// <param name="Value"> 0不使能 1使能</param>
public Result<bool> SendOfflineStopCharging(string binNo, byte Value)
{
BinInfo? binInfo = BinInfoRepository.QueryByBinNo(binNo);
if (binInfo == null)
{
return Result<bool>.Fail(@"充电仓不存在");
}
if (string.IsNullOrWhiteSpace(binInfo.ChargerNo))
{
return Result<bool>.Fail(@"充电仓未配置充电机编号");
}
ChargerClient? chargerClient = ClientMgr.GetBySn(binInfo.ChargerNo);
if (chargerClient == null || !chargerClient.Connected)
{
return Result<bool>.Fail(@"充电机未连接");
}
chargerClient.SendOfflineStopCharging(Value);
return Result<bool>.Success(true);
}
/// <summary>
/// 监控平台下发站外允许充电 SOC
/// </summary>
/// <param name="binNo"></param>
/// <param name="Value"></param>
/// <returns></returns>
public Result<bool> SendOutSideAllowChargingSoc(string binNo, byte Value)
{
BinInfo? binInfo = BinInfoRepository.QueryByBinNo(binNo);
if (binInfo == null)
{
return Result<bool>.Fail(@"充电仓不存在");
}
if (string.IsNullOrWhiteSpace(binInfo.ChargerNo))
{
return Result<bool>.Fail(@"充电仓未配置充电机编号");
}
ChargerClient? chargerClient = ClientMgr.GetBySn(binInfo.ChargerNo);
if (chargerClient == null || !chargerClient.Connected)
{
return Result<bool>.Fail(@"充电机未连接");
}
chargerClient.SendOutSideAllowChargingSoc(Value);
return Result<bool>.Success(true);
}
/// <summary>
/// 站控设备切换站内/站外充电切换
/// </summary>
/// <param name="Value"> 00:无效 01:站内 02:站外</param>
public Result<bool> SendChangeChargeMode(string binNo, byte Value)
{
BinInfo? binInfo = BinInfoRepository.QueryByBinNo(binNo);
if (binInfo == null)
{
return Result<bool>.Fail(@"充电仓不存在");
}
if (string.IsNullOrWhiteSpace(binInfo.ChargerNo))
{
return Result<bool>.Fail(@"充电仓未配置充电机编号");
}
ChargerClient? chargerClient = ClientMgr.GetBySn(binInfo.ChargerNo);
if (chargerClient == null || !chargerClient.Connected)
{
return Result<bool>.Fail(@"充电机未连接");
}
chargerClient.SendChangeChargeMode(Value);
return Result<bool>.Success(true);
}
}

@ -239,7 +239,10 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
_chargeOrderRepository = chargeOrderRepository;
_binInfoRepository = binInfoRepository;
}
public ChargerClient()
{
}
private ILog Log()
{
var name = "Charger" + this.Sn;
@ -300,9 +303,9 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
/// </summary>
/// <param name="socLimit">SOC限制.百分比</param>
/// <param name="changePowerCmdType">功率调节指令类型.默认1 绝对功率值</param>
/// <param name="changePower">1kw/位,默认3600</param>
/// <param name="changePower">1kw/位,默认2400</param>
/// <param name="chargeOrderNo">充电流水号</param>
public Result<string> SendRemoteStartCharging(byte socLimit, float changePower = 360, byte changePowerCmdType = 1,
public Result<string> SendRemoteStartCharging(byte socLimit, float changePower = 2400, byte changePowerCmdType = 1,
string? chargeOrderNo = null)
{
if (!Connected)
@ -321,11 +324,11 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
CurrentCmd = JsonConvert.SerializeObject(remoteStartCharging, Formatting.Indented) + "\r\n" +
BitUtls.BytesToHexStr(remoteStartCharging.ToBytes());
AuxiliaryPower auxiliaryPower0 = new AuxiliaryPower(0);
AuxiliaryPower auxiliaryPower0 = new AuxiliaryPower(2);
AuxiliaryPower auxiliaryPower1 = new AuxiliaryPower(1);
this.Channel.WriteAndFlushAsync(auxiliaryPower0);
Thread.Sleep(3000);
this.Channel.WriteAndFlushAsync(auxiliaryPower1);
//this.Channel.WriteAndFlushAsync(auxiliaryPower0);
//Thread.Sleep(3000);
//this.Channel.WriteAndFlushAsync(auxiliaryPower1);
this.Channel.WriteAndFlushAsync(remoteStartCharging);
return Result<string>.Success(chargeOrderNo);
}
@ -358,7 +361,6 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
{
return Result<bool>.Fail($"charger-{BinNo} disconnect");
}
PowerRegulation powerRegulation = new PowerRegulation(expectedOperatingPower);
this.Channel.WriteAndFlushAsync(powerRegulation);
return Result<bool>.Success();
@ -501,7 +503,23 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
this.Channel.WriteAndFlushAsync(offlineStopCharging);
return Result<bool>.Success();
}
/// <summary>
/// 3.4.9 监控平台下发站外允许充电 SOC
/// </summary>
/// <param name="enabled"> </param>
public Result<bool> SendOutSideAllowChargingSoc(byte enabled)
{
if (!Connected)
{
return Result<bool>.Fail($"charger-{BinNo} disconnect");
}
OutSideAllowChargingSoc offlineStopCharging = new OutSideAllowChargingSoc(enabled);
CurrentCmd = JsonConvert.SerializeObject(offlineStopCharging, Formatting.Indented) + "\r\n" +
BitUtls.BytesToHexStr(offlineStopCharging.ToBytes());
this.Channel.WriteAndFlushAsync(offlineStopCharging);
return Result<bool>.Success();
}
/// <summary>
/// 3.4.12 站控设备切换站内/站外充电切换
/// </summary>
@ -592,7 +610,7 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
}
/// <summary>
///
///查询电池信息
/// </summary>
public Result<bool> SendQueryBattery()
{
@ -652,19 +670,23 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
//判断水冷继电器状态为断开
var relation = StaticStationInfo.RelationMap[Sn];
var waterCoolClient = WaterCoolClientMgr.GetBySn(relation.WaterCoolerCode)
;
if (waterCoolClient == null)
{
return Result<bool>.Fail($"液冷机组未初始化");
}
#region 水冷判断先屏蔽
// TODO 水冷判断先屏蔽
//var relation = StaticStationInfo.RelationMap[Sn];
//var waterCoolClient = WaterCoolClientMgr.GetBySn(relation.WaterCoolerCode)
// ;
//if (waterCoolClient == null)
//{
// return Result<bool>.Fail($"液冷机组未初始化");
//}
//if (!waterCoolClient.WaitIsClose())
//{
// return Result<bool>.Fail($"继电器未断开");
//}
#endregion
if (!waterCoolClient.WaitIsClose())
{
return Result<bool>.Fail($"继电器未断开");
}
RedisHelper redisHelper = AppInfo.Container.Resolve<RedisHelper>();
@ -693,7 +715,7 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
BatteryNo = BatteryNo,
CmdStatus = 0,
ChargerNo = BinNo,
ChargeMode = 1,
ChargeMode = 0,
SwapOrderSn = swapOrder?.SwapOrderSn,
StartMode = 1,
StartType = startType

@ -133,6 +133,9 @@ public class Decoder : ByteToMessageDecoder
ASDU asdu = cmd switch
{
5 => ModelConvert.Decode<UploadRemoteSignalData>(bytes),
11 => ModelConvert.Decode<UploadTelemetryData>(bytes),
42 => ModelConvert.Decode<RecordCharge>(bytes),
#region 45
45 => recordType switch
{
@ -255,8 +258,6 @@ public class Decoder : ByteToMessageDecoder
},
#endregion
42 => ModelConvert.Decode<RecordCharge>(bytes),
11 => ModelConvert.Decode<UploadTelemetryData>(bytes),
49 => ModelConvert.Decode<RemoteStartChargingRes>(bytes),
50 => ModelConvert.Decode<RemoteStopChargingRes>(bytes),

@ -34,7 +34,9 @@ namespace Service.Charger.Handler
client.UploadTelemetryData = msg;
//充电机实时充电功率
client.RealTimeChargePower = msg.HighVoltageAcquisitionCurrent * msg.HighVoltageAcquisitionVoltage;
//client.RealTimeChargePower = msg.HighVoltageAcquisitionCurrent * msg.HighVoltageAcquisitionVoltage;
client.RealTimeChargePower = msg.DcMeterCurrent * msg.DcMeterVoltage;
}
}
}

@ -44,13 +44,13 @@ namespace Service.Charger.Msg.Charger.Req
/// <summary>
/// 当前SOH 分辨率1%/位偏移量0%,数值范围 0%~100%
/// </summary>
[Property(80, 8, scale: 0.01)]
[Property(80, 8)]
public float SOH { get; set; }
///// <summary>
///// 保留
///// </summary>
//[Property(88, 8)]
//public byte Reserve { get; set; }
/// <summary>
/// 保留
/// </summary>
[Property(88, 8)]
public byte Reserve { get; set; }
}
}

@ -43,4 +43,5 @@ public class QueryBatterySnRes : ASDU
/// </summary>
[Property(start: 48, length: 27, PropertyReadConstant.Byte)]
public byte[] BatterSnBytes { get; set; }
}

@ -29,107 +29,107 @@ namespace Service.Charger.Msg.Charger.Resp
/// <summary>
/// 单体蓄电池或蓄电池模块电压越限
/// </summary>
[Property(32, 16)]
public short SingleBattery { get; set; }
[Property(32, 2)]
public byte SingleBattery { get; set; }
/// <summary>
/// 电压偏差越限
/// </summary>
[Property(48, 16)]
public short VoltageOvershoot { get; set; }
[Property(34, 2)]
public byte VoltageOvershoot { get; set; }
/// <summary>
/// 温度越限
/// </summary>
[Property(64, 16)]
public short TemperatureExceedance { get; set; }
[Property(36, 2)]
public byte TemperatureExceedance { get; set; }
/// <summary>
/// 温度偏差越限
/// </summary>
[Property(80, 16)]
public short TemperatureDifference { get; set; }
[Property(38, 2)]
public byte TemperatureDifference { get; set; }
/// <summary>
/// SOC 低
/// </summary>
[Property(96, 16)]
public short LowSOC { get; set; }
[Property(40, 2)]
public byte LowSOC { get; set; }
/// <summary>
/// 放电电流越限
/// </summary>
[Property(112, 16)]
[Property(42, 2)]
public short DischargeCurrent { get; set; }
/// <summary>
/// 充电电流限
/// </summary>
[Property(128, 16)]
[Property(44, 2)]
public short ChargingCurrentLimit { get; set; }
/// <summary>
/// 总正负极柱温度越限
/// </summary>
[Property(144, 16)]
[Property(46, 2)]
public short TotalTemp { get; set; }
/// <summary>
/// 电池系统故障码
/// 电池系统故障码 2字节
/// </summary>
[Property(160, 16)]
[Property(48, 16)]
public short BatteryFaultCode { get; set; }
/// <summary>
/// 高压绝缘低
/// </summary>
[Property(176, 16)]
[Property(64, 2)]
public short HighVoltageLow { get; set; }
/// <summary>
/// 单体蓄电池或蓄电池模块电压越极限
/// </summary>
[Property(192, 16)]
[Property(66, 2)]
public short MonomerLimit { get; set; }
/// <summary>
/// 电压偏差越极限a
/// </summary>
[Property(200, 16)]
[Property(68, 2)]
public short VoltageDifference { get; set; }
/// <summary>
/// 温度越极限
/// </summary>
[Property(216, 16)]
[Property(70, 2)]
public short TemperatureOvershoot { get; set; }
/// <summary>
/// 温度偏差越极限
/// </summary>
[Property(232, 16)]
[Property(72 ,2)]
public short TempDifference { get; set; }
/// <summary>
/// SOC 极低
/// </summary>
[Property(248, 16)]
[Property(74, 2)]
public short VeryLowSOC { get; set; }
/// <summary>
/// 放电电流越极限
/// </summary>
[Property(264, 16)]
[Property(76, 2)]
public short DischargeCurrentLimit { get; set; }
/// <summary>
/// 充电电流越极限
/// </summary>
[Property(280, 16)]
[Property(78, 2)]
public short ChargingCurrent { get; set; }
/// <summary>
/// 总正负极柱温度越极限
/// </summary>
[Property(296, 16)]
[Property(80, 2)]
public short TotalTempLimit { get; set; }
/// <summary>
/// 高压绝缘极低
/// </summary>
[Property(312, 16)]
[Property(82, 2)]
public short highVoltageInsulation { get; set; }
/// <summary>
/// 硬件故障
/// </summary>
[Property(328, 16)]
[Property(84, 2)]
public short HardwareFailure { get; set; }
/// <summary>
/// 保留
/// </summary>
[Property(344, 16)]
[Property(86, 2)]
public short Reserve { get; set; }
}
}

@ -13,7 +13,7 @@ namespace Service.Charger.Msg.Host.Req
[Property(0, 8)]
public byte RecordType { get; set; }
/// <summary>
///打开辅助电源标志 1电池包辅助电源导通 0:电池包辅助电源断开
///打开辅助电源标志 1电池包辅助电源导通 2:电池包辅助电源断开
/// </summary>
[Property(8, 8)]
public byte OpenFlag { get; set; }

@ -3,7 +3,7 @@
namespace Service.Charger.Msg.Host.Req.Bms
{
/// <summary>
/// 3.4.1 监控平台发送功率调节指令
/// 3.6.2.1 监控平台下发PGN查询电池信息(PGN:0x00F82C)
/// </summary>
public class QueryBattery : ASDU
{
@ -14,13 +14,13 @@ namespace Service.Charger.Msg.Host.Req.Bms
public byte RecordType { get; set; }
/// <summary>
/// 记录类型
/// PGN 码
/// </summary>
[Property(8, 3, PropertyReadConstant.Byte)]
public byte[] Pgn { get; set; } = { 0x00, 0xf8, 0x2c };
/// <summary>
/// 记录类型
/// 要查询的PGN
/// </summary>
[Property(32, 3, PropertyReadConstant.Byte)]
public byte[] QueryPgn { get; set; }

@ -7,11 +7,32 @@ namespace Service.Charger.Msg.Host.Req
/// </summary>
public class OutSideAllowChargingSoc : ASDU
{
/// <summary>
/// SOC 限制值
/// 记录类型
/// </summary>
[Property(0, 8)]
public byte RecordType { get; set; }
/// <summary>
/// SOC 限制值
/// </summary>
[Property(8, 8)]
public byte SocValue { get; set; }
public OutSideAllowChargingSoc(byte enabled)
{
FrameTypeNo = 45;
MsgBodyCount = 1;
TransReason = 3;
PublicAddr = 0;
MsgBodyAddr = new byte[] { 0, 0, 0 };
RecordType = 45;
SocValue = enabled;
}
}
}

@ -33,7 +33,8 @@ public class AutoChargeTask : ITask
public int Interval()
{
return 1000 * 10;
//充电机说启动失败不要频繁发商定1分钟
return 1000 * 60;
}
public void Handle()

@ -5,6 +5,9 @@ using Service.Charger.Client;
namespace Service.Charger.MyTask;
/// <summary>
/// 查询电池信息任务
/// </summary>
[Scope]
public class QueryBatteryInfoTask : ITask
{
@ -27,7 +30,8 @@ public class QueryBatteryInfoTask : ITask
{
foreach (var (key, client) in ClientMgr.Dictionary)
{
client.SendQueryBattery();
//取消查询,充电机会主动上报
//client.SendQueryBattery();
}
}
catch (Exception e)

@ -43,9 +43,27 @@ public class BinInfoService : BaseServices<BinInfo>
if (chargerClient.BatteryPackTotalElectricity != null)
binInfoResp.OnceElectricCharge = chargerClient.BatteryPackTotalElectricity.OnceElectricCharge;
binInfoResp.BmsNeedVoltage = chargerClient.UploadTelemetryData.BmsNeedVoltage;
//binInfoResp.BmsNeedCurrent = chargerClient.UploadTelemetryData.BmsNeedCurrent;
//if (chargerClient.BatteryPackData != null)
// binInfoResp.TotalCurrent = chargerClient.BatteryPackData.TotalCurrent;
#region 正负显示统一
if (binInfoResp.ChargeStatus == 1)
{
binInfoResp.BmsNeedCurrent = chargerClient.UploadTelemetryData.BmsNeedCurrent;
binInfoResp.BmsNeedCurrent = 0 - binInfoResp.BmsNeedCurrent;
}
else
{ binInfoResp.BmsNeedCurrent = 0; }
if (chargerClient.BatteryPackData != null)
binInfoResp.TotalCurrent = chargerClient.BatteryPackData.TotalCurrent;
{
if (binInfoResp.ChargeStatus == 1)
{ binInfoResp.TotalCurrent = chargerClient.BatteryPackData.TotalCurrent; }
else
{ binInfoResp.TotalCurrent = 0; }
}
#endregion
if (chargerClient.BatteryPackDataVoltage != null)
binInfoResp.CellTemperatureMax = chargerClient.BatteryPackDataVoltage.CellTemperatureMax;
if (chargerClient.BatteryPackDataVoltage != null)

@ -72,9 +72,9 @@ public class ChargeController : ControllerBase
[Route("SendPowerRegulation/{code}/{power}")]
public Result<bool> SendPowerRegulation(string code, float power)
{
if (power <=0 || power > 360)
if (power <=0 || power > 240)
{
return Result<bool>.Fail("功率值范围1到360");
return Result<bool>.Fail("功率值范围1到240");
}
string _code = _binInfoService.QueryByClause(i => i.Code == code).ChargerNo;
@ -198,4 +198,41 @@ public class ChargeController : ControllerBase
{
return _chargerService.SendBatteryHolderStatus( binNo,battery,connectionState,waterCondition);
}
/// <summary>
/// 下发掉线停止充电
/// </summary>
/// <returns></returns>
[HttpGet]
[Route("SendOfflineStopCharging")]
public Result<bool> SendOfflineStopCharging(string binNo, byte openFlag)
{
return _chargerService.SendOfflineStopCharging(binNo, openFlag);
}
/// <summary>
/// 站控设备切换站内/站外充电切换
/// </summary>
/// <param name="Value"> 00:无效 01:站内 02:站外</param>
[HttpGet]
[Route("SendChangeChargeMode")]
public Result<bool> SendChangeChargeMode(string binNo, byte Value)
{
return _chargerService.SendChangeChargeMode(binNo, Value);
}
/// <summary>
/// 监控平台下发站外允许充电 SOC
/// </summary>
/// <param name="Value"> 限制值</param>
[HttpGet]
[Route("SendOutSideAllowChargingSoc")]
public Result<bool> SendOutSideAllowChargingSoc(string binNo, byte Value)
{
return _chargerService.SendOutSideAllowChargingSoc(binNo, Value);
}
}

@ -119,6 +119,6 @@ StaticStationInfo.Init();
// 水冷连接
WaterCoolClientMgr.InitClient();
//WaterCoolClientMgr.InitClient();
app.Run();

@ -2,7 +2,7 @@
"ConnectionStrings": {
"ConfigId": "master",
"DbType": "MySql",
"SqlConnection": "server=180.76.133.253;Port=16306;Database=nhet_dev;Uid=root;Pwd=Rszn123;Charset=utf8;"
"SqlConnection": "server=127.0.0.1;Port=3306;Database=nhet_cn_dev;Uid=root;Pwd=123456;Charset=utf8;"
},
"Update": {
"AutoUpdate": "false",
@ -10,7 +10,7 @@
"Url": "http://121.4.95.243:8090/Updates/AutoUpdaterStarter.xml"
},
"Redis": {
"Connection": "192.168.2.2:6379,password=dev",
"Connection": "127.0.0.1:6379,password=123456",
"InstanceName": "local",
"DefaultDB": "8"
},

@ -2,7 +2,7 @@
"ConnectionStrings": {
"ConfigId": "master",
"DbType": "MySql",
"SqlConnection": "server=localhost;Port=3306;Database=huanneng_dev;Uid=root;Pwd=123456;Charset=utf8;"
"SqlConnection": "server=localhost;Port=3306;Database=nhet_cn_dev;Uid=root;Pwd=123456;Charset=utf8;"
},
"Update": {
"AutoUpdate": "false",
@ -35,8 +35,8 @@
"Job": {
"Enabled": false
},
"Task": {
"Disabled": "UploadTelemetryData"
},
//"Task": {
// "Disabled": "UploadTelemetryData"
//},
"AllowedHosts": "*"
}

Loading…
Cancel
Save