尖峰平谷下发修改

master
xjl 5 months ago
parent ac9e1caaeb
commit 56eb384644

@ -114,30 +114,30 @@ public class ChargerService
SetPeakValleyTime setPeakValleyTime = new SetPeakValleyTime()
{
NumberTime = Convert.ToByte(elecPriceModelVersionDetails.Count),
StartHH1 = Convert.ToByte(elecPriceModelVersionDetails[0].StartHour),
StartHH2 = Convert.ToByte(elecPriceModelVersionDetails[1].StartHour),
StartHH3 = Convert.ToByte(elecPriceModelVersionDetails[2].StartHour),
StartHH4 = Convert.ToByte(elecPriceModelVersionDetails[3].StartHour),
StartHH5 = Convert.ToByte(elecPriceModelVersionDetails[4].StartHour),
StartHH6 = Convert.ToByte(elecPriceModelVersionDetails[5].StartHour),
StartHH7 = Convert.ToByte(elecPriceModelVersionDetails[6].StartHour),
StartHH8 = Convert.ToByte(elecPriceModelVersionDetails[7].StartHour),
StartMM1 = Convert.ToByte(elecPriceModelVersionDetails[0].StartMinute),
StartMM2 = Convert.ToByte(elecPriceModelVersionDetails[1].StartMinute),
StartMM3 = Convert.ToByte(elecPriceModelVersionDetails[2].StartMinute),
StartMM4 = Convert.ToByte(elecPriceModelVersionDetails[3].StartMinute),
StartMM5 = Convert.ToByte(elecPriceModelVersionDetails[4].StartMinute),
StartMM6 = Convert.ToByte(elecPriceModelVersionDetails[5].StartMinute),
StartMM7 = Convert.ToByte(elecPriceModelVersionDetails[6].StartMinute),
StartMM8 = Convert.ToByte(elecPriceModelVersionDetails[7].StartMinute),
TimePeak1 = Convert.ToByte(elecPriceModelVersionDetails[0].Type),
TimePeak2 = Convert.ToByte(elecPriceModelVersionDetails[1].Type),
TimePeak3 = Convert.ToByte(elecPriceModelVersionDetails[2].Type),
TimePeak4 = Convert.ToByte(elecPriceModelVersionDetails[3].Type),
TimePeak5 = Convert.ToByte(elecPriceModelVersionDetails[4].Type),
TimePeak6 = Convert.ToByte(elecPriceModelVersionDetails[5].Type),
TimePeak7 = Convert.ToByte(elecPriceModelVersionDetails[6].Type),
TimePeak8 = Convert.ToByte(elecPriceModelVersionDetails[7].Type)
StartHH1 = (byte)(elecPriceModelVersionDetails.Count > 0?Convert.ToByte(elecPriceModelVersionDetails[0].StartHour) :0),
StartHH2 = (byte)(elecPriceModelVersionDetails.Count > 1?Convert.ToByte(elecPriceModelVersionDetails[1].StartHour) : 0),
StartHH3 = (byte)(elecPriceModelVersionDetails.Count > 2?Convert.ToByte(elecPriceModelVersionDetails[2].StartHour):0),
StartHH4 = (byte)(elecPriceModelVersionDetails.Count > 3?Convert.ToByte(elecPriceModelVersionDetails[3].StartHour):0),
StartHH5 = (byte)(elecPriceModelVersionDetails.Count > 4?Convert.ToByte(elecPriceModelVersionDetails[4].StartHour):0),
StartHH6 = (byte)(elecPriceModelVersionDetails.Count > 5?Convert.ToByte(elecPriceModelVersionDetails[5].StartHour):0),
StartHH7 = (byte)(elecPriceModelVersionDetails.Count > 6?Convert.ToByte(elecPriceModelVersionDetails[6].StartHour):0),
StartHH8 = (byte)(elecPriceModelVersionDetails.Count > 7?Convert.ToByte(elecPriceModelVersionDetails[7].StartHour) : 0),
StartMM1 = (byte)(elecPriceModelVersionDetails.Count > 0?Convert.ToByte(elecPriceModelVersionDetails[0].StartMinute):0),
StartMM2 = (byte)(elecPriceModelVersionDetails.Count > 1?Convert.ToByte(elecPriceModelVersionDetails[1].StartMinute):0),
StartMM3 = (byte)(elecPriceModelVersionDetails.Count > 2?Convert.ToByte(elecPriceModelVersionDetails[2].StartMinute):0),
StartMM4 = (byte)(elecPriceModelVersionDetails.Count > 3?Convert.ToByte(elecPriceModelVersionDetails[3].StartMinute):0),
StartMM5 = (byte)(elecPriceModelVersionDetails.Count > 4?Convert.ToByte(elecPriceModelVersionDetails[4].StartMinute):0),
StartMM6 = (byte)(elecPriceModelVersionDetails.Count > 5?Convert.ToByte(elecPriceModelVersionDetails[5].StartMinute):0),
StartMM7 = (byte)(elecPriceModelVersionDetails.Count > 6?Convert.ToByte(elecPriceModelVersionDetails[6].StartMinute) : 0),
StartMM8 = (byte)(elecPriceModelVersionDetails.Count > 7 ? Convert.ToByte(elecPriceModelVersionDetails[7].StartMinute) : 0),
TimePeak1 = (byte)(elecPriceModelVersionDetails.Count > 0 ? Convert.ToByte(elecPriceModelVersionDetails[0].Type):0),
TimePeak2 = (byte)(elecPriceModelVersionDetails.Count > 1?Convert.ToByte(elecPriceModelVersionDetails[1].Type):0),
TimePeak3 = (byte)(elecPriceModelVersionDetails.Count > 2?Convert.ToByte(elecPriceModelVersionDetails[2].Type):0),
TimePeak4 = (byte)(elecPriceModelVersionDetails.Count > 3?Convert.ToByte(elecPriceModelVersionDetails[3].Type):0),
TimePeak5 = (byte)(elecPriceModelVersionDetails.Count > 4?Convert.ToByte(elecPriceModelVersionDetails[4].Type):0),
TimePeak6 = (byte)(elecPriceModelVersionDetails.Count > 5?Convert.ToByte(elecPriceModelVersionDetails[5].Type):0),
TimePeak7 = (byte)(elecPriceModelVersionDetails.Count > 6?Convert.ToByte(elecPriceModelVersionDetails[6].Type):0),
TimePeak8 = (byte)(elecPriceModelVersionDetails.Count > 7?Convert.ToByte(elecPriceModelVersionDetails[7].Type):0)
};
return setPeakValleyTime;
}

@ -1,4 +1,5 @@
using System.Collections.Concurrent;
using System.Reflection;
using Autofac;
using Entity.DbModel.Station;
using HybirdFrameworkCore.Autofac;
@ -10,6 +11,7 @@ using HybirdFrameworkDriver.Session;
using HybirdFrameworkDriver.TcpClient;
using log4net;
using Newtonsoft.Json;
using Org.BouncyCastle.Asn1.Cmp;
using Repository.Station;
using Service.Charger.Codec;
using Service.Charger.Common;
@ -462,8 +464,15 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
}
setPeakValleyTime= GetMsgContents(setPeakValleyTime);
CurrentCmd = JsonConvert.SerializeObject(setPeakValleyTime, Formatting.Indented) + "\r\n" +
BitUtls.BytesToHexStr(setPeakValleyTime.ToBytes());
this.Channel.WriteAndFlushAsync(setPeakValleyTime);
Log().Info($"SendSetPeakValleyTime{CurrentCmd} to chargeOrderNo={BinNo}");
@ -692,4 +701,33 @@ public class ChargerClient : TcpClient<IBaseHandler, Decoder, Encoder>
ChannelUtils.AddAttr(Channel, ChargerConst.EqmCode, sn);
ChannelUtils.AddAttr(Channel, ChargerConst.DestAddr, destAddr);
}
/// <summary>
/// 获取尖峰平谷字节数组
/// </summary>
/// <param name="auth"></param>
/// <returns>鉴权消息体字节数组</returns>
private SetPeakValleyTime GetMsgContents(SetPeakValleyTime timeRng)
{
for (int i = 0; i < timeRng.NumberTime; i++)
{
PropertyInfo propertyStartTimePeriod1 = timeRng.GetType().GetProperty("StartHH" + (i + 1));
propertyStartTimePeriod1.SetValue(timeRng, BitUtls.ByteToBCD(Convert.ToByte(timeRng.GetType().GetProperty("StartHH" + (i + 1)).GetValue(timeRng))));
PropertyInfo propertyStartTimePeriod2 = timeRng.GetType().GetProperty("StartMM" + (i + 1));
propertyStartTimePeriod2.SetValue(timeRng, BitUtls.ByteToBCD(Convert.ToByte(timeRng.GetType().GetProperty("StartMM" + (i + 1)).GetValue(timeRng))));
PropertyInfo propertyTimePeriodPeakIden = timeRng.GetType().GetProperty("TimePeak" + (i + 1));
propertyTimePeriodPeakIden.SetValue(timeRng, timeRng.GetType().GetProperty("TimePeak" + (i + 1)).GetValue(timeRng));
}
return timeRng;
}
}

Loading…
Cancel
Save