using BatCharging.Model;
using Monitor.LogService;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BatCharging.Service
{
public class MsgTelDataDecoder
{
///
/// 解析遥测数据上报
///
///
public TelemetryData BTelemetryDataToValue(byte[] data)
{
TelemetryData mTelemetryData = null;
if (data.Count() >= 68)
{
mTelemetryData = new TelemetryData();
mTelemetryData.Soc = data[24];
mTelemetryData.MaxTemperature = data[25] - 50;
mTelemetryData.MaxTemperatureNo = data[26];
mTelemetryData.MinTemperature = data[27] - 50;
mTelemetryData.MinTemperatureNo = data[28];
mTelemetryData.MaxBatteryVoltage = Convert.ToSingle(BitConverter.ToUInt16(data, 29) * 0.01);
mTelemetryData.MinBatteryVoltage = Convert.ToSingle(BitConverter.ToUInt16(data, 31) * 0.01);
mTelemetryData.AmbientTemCharger = data[33] - 50;
mTelemetryData.ChaGuiVoltage = Convert.ToSingle(BitConverter.ToUInt16(data, 34) * 0.01);
mTelemetryData.BmsDemandVoltage = Convert.ToSingle(BitConverter.ToUInt16(data, 36) * 0.1);
mTelemetryData.BmsDemandCurrent = Convert.ToSingle(BitConverter.ToUInt16(data, 38) * 0.1) - 400;
mTelemetryData.ChargingMode = data[40];
mTelemetryData.BmsMeaChaVol = Convert.ToSingle(BitConverter.ToUInt16(data, 41) * 0.1);
mTelemetryData.BmsChaCurMea = Convert.ToSingle(BitConverter.ToUInt16(data, 43) * 0.1) - 400;
mTelemetryData.EstRemCharTime = BitConverter.ToUInt16(data, 45);
mTelemetryData.ChaIntTemProbeTem1 = data[47] - 50;
mTelemetryData.ChaIntTemProbeTem2 = data[48] - 50;
mTelemetryData.ChaIntTemProbeTem3 = data[49] - 50;
mTelemetryData.ChaIntTemProbeTem4 = data[50] - 50;
mTelemetryData.CurPowerDCMeterAGun = Convert.ToSingle(BitConverter.ToUInt32(data, 51) * 0.01);
mTelemetryData.ChargingVoltageAGun = Convert.ToSingle(BitConverter.ToUInt16(data, 55) * 0.1);
mTelemetryData.ChargeCurrentAGun = Convert.ToSingle(BitConverter.ToUInt16(data, 57) * 0.1);
mTelemetryData.HighVoltageAcquisitionVoltage = Convert.ToSingle(BitConverter.ToUInt16(data, 59) * 0.1);
mTelemetryData.HighVoltageAcquisitionCurrent = Convert.ToSingle(BitConverter.ToUInt16(data, 61) * 0.1);
mTelemetryData.IntTemPile = data[63];
mTelemetryData.ChargingTime = BitConverter.ToUInt16(data, 64);
mTelemetryData.ModuleAirIntakeTem = data[66];
mTelemetryData.ModuleAirOuttakeTem = data[67];
}
return mTelemetryData;
}
}
}