using BatCharging.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BatCharging.Service
{
///
/// 解析充放电机上送充电启动完成帧
///
public class MsgStaComFraDecoder
{
///
/// 解析充放电机上送充电启动完成帧
///
///
///
public StartComFrame GetMsgStartComFrame(byte[] data)
{
StartComFrame startComFrame = null;
if (data.Count() >= 73)
{
startComFrame = new StartComFrame();
startComFrame.SuccessMark = data[25];
startComFrame.CauseFailure = data[26];
startComFrame.BMSIndProVersion = data[27]+"."+ data[28] + "."+ data[29];
startComFrame.BMSHandResult = data[30];
startComFrame.TypeBattery = data[31];
startComFrame.MaxPerTem = data[32];
startComFrame.BMSMaxAllChaVol = ByteUtils.ToUInt16(data, 33);
startComFrame.MaxAllChaVolUnit = ByteUtils.ToUInt16(data, 35);
startComFrame.MaxAllChaCur = ByteUtils.ToUInt16(data, 37);
startComFrame.RatTotalVolVehPowBat = ByteUtils.ToUInt16(data, 39);
startComFrame.CurVolVehPowBat = ByteUtils.ToUInt16(data, 41);
startComFrame.RatCapVehPowBat = ByteUtils.ToUInt16(data, 43);
startComFrame.NomCapVehPowBat = ByteUtils.ToUInt16(data, 45);
startComFrame.MaxOutVolCha = ByteUtils.ToUInt16(data, 47);
startComFrame.MinOutVolCha = ByteUtils.ToUInt16(data, 49);
startComFrame.MaxOutCurCha = ByteUtils.ToUInt16(data, 51);
startComFrame.MinOutCurCha = ByteUtils.ToUInt16(data, 53);
byte[] vehIdeNums = new byte[17];
Array.Copy(data, 55, vehIdeNums, 0, 17);
startComFrame.VehIdeNum = System.Text.ASCIIEncoding.ASCII.GetString(vehIdeNums);
startComFrame.LoaStaVehPowBat = data[72];
}
return startComFrame;
}
}
}