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.

204 lines
13 KiB

using BatCharging.Model;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BatCharging.Service
{
/// <summary>
/// 数据上报解析类
/// </summary>
public class MsgRemoteDataDecoder
{
/// <summary>
/// 解析遥信数据上报
/// </summary>
/// <returns></returns>
public RemoteData BRemoteDataToValue(byte[] data)
{
RemoteData mRemoteData = null;
mRemoteData = new RemoteData();
if (data.Count() > 30)
{
mRemoteData.WorkDev = MsgBits.ByteToBitsValue(data, 24, 0, 2);
mRemoteData.TotalFault = MsgBits.ByteToBitsValue(data, 24, 2, 1);
mRemoteData.CommonAlarm = MsgBits.ByteToBitsValue(data, 24, 3, 1);
mRemoteData.EmergencyStop = MsgBits.ByteToBitsValue(data, 24, 4, 1);
mRemoteData.SmokeFault = MsgBits.ByteToBitsValue(data, 24, 5, 1);
mRemoteData.CirBreFailureIn = MsgBits.ByteToBitsValue(data, 24, 6, 1);
mRemoteData.AGunPositiveFault = MsgBits.ByteToBitsValue(data, 24, 7, 1);
mRemoteData.AGunNegativeEleFault = MsgBits.ByteToBitsValue(data, 25, 0, 1);
mRemoteData.AGunPFuseFaulty = MsgBits.ByteToBitsValue(data, 25, 1, 1);
mRemoteData.AGunNPositiveFuseFaulty = MsgBits.ByteToBitsValue(data, 25, 2, 1);
mRemoteData.MagneticLockFaulty = MsgBits.ByteToBitsValue(data, 25, 3, 1);
mRemoteData.FanFailure = MsgBits.ByteToBitsValue(data, 25, 4, 1);
mRemoteData.ArresterFaulty = MsgBits.ByteToBitsValue(data, 25, 5, 1);
mRemoteData.InsMonAlarm = MsgBits.ByteToBitsValue(data, 25, 6, 1);
mRemoteData.InsMonFault = MsgBits.ByteToBitsValue(data, 25, 7, 1);
mRemoteData.BatPReverseConFault = MsgBits.ByteToBitsValue(data, 26, 0, 1); //协议中16行
mRemoteData.VeConGuidanceFailure = MsgBits.ByteToBitsValue(data, 26, 1, 1);
mRemoteData.OveCausesBarrier = MsgBits.ByteToBitsValue(data, 26, 2, 1);
mRemoteData.InterfaceOverFaulty = MsgBits.ByteToBitsValue(data, 26, 3, 1);
mRemoteData.ChaGunNotRetAlarm = MsgBits.ByteToBitsValue(data, 26, 4, 1);
mRemoteData.BMSComFaulty = MsgBits.ByteToBitsValue(data, 26, 5, 1);
mRemoteData.ChaPilePnpVolOveFault = MsgBits.ByteToBitsValue(data, 26, 6, 1);
mRemoteData.InputVoltageUndFault = MsgBits.ByteToBitsValue(data, 26, 7, 1); //协议中23行
mRemoteData.OvervoltageFault = MsgBits.ByteToBitsValue(data, 27, 0, 1);
mRemoteData.UndervoltageFault = MsgBits.ByteToBitsValue(data, 27, 1, 1);
mRemoteData.OvercurrentFault = MsgBits.ByteToBitsValue(data, 27, 2, 1);
mRemoteData.ConnectionStatus = MsgBits.ByteToBitsValue(data, 27, 3, 1);
mRemoteData.ChaGunHolderStatus = MsgBits.ByteToBitsValue(data, 27, 4, 1);
mRemoteData.IntEleLockStatus = MsgBits.ByteToBitsValue(data, 27, 5, 1);
mRemoteData.AGunPCntactorCon = MsgBits.ByteToBitsValue(data, 27, 6, 1);
mRemoteData.AGunNContactorCon = MsgBits.ByteToBitsValue(data, 27, 7, 1);
mRemoteData.AccessConFailure = MsgBits.ByteToBitsValue(data, 28, 0, 1);
mRemoteData.AGunPConA3dhesionFailure = MsgBits.ByteToBitsValue(data, 28, 1, 1);
mRemoteData.AGunNConadhesionFailure = MsgBits.ByteToBitsValue(data, 28, 2, 1);
mRemoteData.DischargeLoopFaulty = MsgBits.ByteToBitsValue(data, 28, 3, 1);
mRemoteData.ConActivated = MsgBits.ByteToBitsValue(data, 28, 4, 1);
mRemoteData.ConAdhesionFailure = MsgBits.ByteToBitsValue(data, 28, 5, 1);
mRemoteData.OutputReverseCon = MsgBits.ByteToBitsValue(data, 28, 6, 1);
mRemoteData.ModuleOutputRev = MsgBits.ByteToBitsValue(data, 28, 7, 1); //协议中39行
mRemoteData.AcConStatus = MsgBits.ByteToBitsValue(data, 29, 0, 1);
mRemoteData.ChaGunOvertAlarmGen = MsgBits.ByteToBitsValue(data, 29, 1, 1);
mRemoteData.ChaPileOvertAlarm = MsgBits.ByteToBitsValue(data, 29, 2, 1);
mRemoteData.AGunMeterComAbnormal = MsgBits.ByteToBitsValue(data, 29, 3, 1);
mRemoteData.AGunMeterAbnormal = MsgBits.ByteToBitsValue(data, 29, 4, 1);
mRemoteData.FloodingAlarm = MsgBits.ByteToBitsValue(data, 29, 5, 1);
mRemoteData.BatPackAuxPowerStatus = MsgBits.ByteToBitsValue(data, 29, 6, 1);
mRemoteData.ReversePowerAlarm = MsgBits.ByteToBitsValue(data, 29, 7, 1); //协议中47行
mRemoteData.Mod01sts01 = MsgBits.ByteToBitsValue(data, 30, 0, 1);
mRemoteData.Mod01sts02 = MsgBits.ByteToBitsValue(data, 30, 1, 1);
mRemoteData.Mod01sts03 = MsgBits.ByteToBitsValue(data, 30, 2, 1);
mRemoteData.Mod01sts04 = MsgBits.ByteToBitsValue(data, 30, 3, 1);
mRemoteData.Mod01sts05 = MsgBits.ByteToBitsValue(data, 30, 4, 1);
mRemoteData.Mod01sts06 = MsgBits.ByteToBitsValue(data, 30, 5, 1);
mRemoteData.Mod01sts07 = MsgBits.ByteToBitsValue(data, 30, 6, 1);
mRemoteData.Mod01sts08 = MsgBits.ByteToBitsValue(data, 30, 7, 1); //协议中49行
mRemoteData.Mod01sts09 = MsgBits.ByteToBitsValue(data, 31, 0, 1);
mRemoteData.Mod01sts10 = MsgBits.ByteToBitsValue(data, 31, 1, 1);
mRemoteData.Mod01sts11 = MsgBits.ByteToBitsValue(data, 31, 2, 1);
mRemoteData.Mod01sts12 = MsgBits.ByteToBitsValue(data, 31, 3, 1); //协议中50行
mRemoteData.Mod02sts01 = MsgBits.ByteToBitsValue(data, 32, 0, 1);
mRemoteData.Mod02sts02 = MsgBits.ByteToBitsValue(data, 32, 1, 1);
mRemoteData.Mod02sts03 = MsgBits.ByteToBitsValue(data, 32, 2, 1);
mRemoteData.Mod02sts04 = MsgBits.ByteToBitsValue(data, 32, 3, 1);
mRemoteData.Mod02sts05 = MsgBits.ByteToBitsValue(data, 32, 4, 1);
mRemoteData.Mod02sts06 = MsgBits.ByteToBitsValue(data, 32, 5, 1);
mRemoteData.Mod02sts07 = MsgBits.ByteToBitsValue(data, 32, 6, 1);
mRemoteData.Mod02sts08 = MsgBits.ByteToBitsValue(data, 32, 7, 1);
mRemoteData.Mod02sts09 = MsgBits.ByteToBitsValue(data, 33, 0, 1);
mRemoteData.Mod02sts10 = MsgBits.ByteToBitsValue(data, 33, 1, 1);
mRemoteData.Mod02sts11 = MsgBits.ByteToBitsValue(data, 33, 2, 1);
mRemoteData.Mod02sts12 = MsgBits.ByteToBitsValue(data, 33, 3, 1);
mRemoteData.Mod03sts01 = MsgBits.ByteToBitsValue(data, 34, 0, 1);
mRemoteData.Mod03sts02 = MsgBits.ByteToBitsValue(data, 34, 1, 1);
mRemoteData.Mod03sts03 = MsgBits.ByteToBitsValue(data, 34, 2, 1);
mRemoteData.Mod03sts04 = MsgBits.ByteToBitsValue(data, 34, 3, 1);
mRemoteData.Mod03sts05 = MsgBits.ByteToBitsValue(data, 34, 4, 1);
mRemoteData.Mod03sts06 = MsgBits.ByteToBitsValue(data, 34, 5, 1);
mRemoteData.Mod03sts07 = MsgBits.ByteToBitsValue(data, 34, 6, 1);
mRemoteData.Mod03sts08 = MsgBits.ByteToBitsValue(data, 34, 7, 1);
mRemoteData.Mod03sts09 = MsgBits.ByteToBitsValue(data, 35, 0, 1);
mRemoteData.Mod03sts10 = MsgBits.ByteToBitsValue(data, 35, 1, 1);
mRemoteData.Mod03sts11 = MsgBits.ByteToBitsValue(data, 35, 2, 1);
mRemoteData.Mod03sts12 = MsgBits.ByteToBitsValue(data, 35, 3, 1);
mRemoteData.Mod04sts01 = MsgBits.ByteToBitsValue(data, 36, 0, 1);
mRemoteData.Mod04sts02 = MsgBits.ByteToBitsValue(data, 36, 1, 1);
mRemoteData.Mod04sts03 = MsgBits.ByteToBitsValue(data, 36, 2, 1);
mRemoteData.Mod04sts04 = MsgBits.ByteToBitsValue(data, 36, 3, 1);
mRemoteData.Mod04sts05 = MsgBits.ByteToBitsValue(data, 36, 4, 1);
mRemoteData.Mod04sts06 = MsgBits.ByteToBitsValue(data, 36, 5, 1);
mRemoteData.Mod04sts07 = MsgBits.ByteToBitsValue(data, 36, 6, 1);
mRemoteData.Mod04sts08 = MsgBits.ByteToBitsValue(data, 36, 7, 1);
mRemoteData.Mod04sts09 = MsgBits.ByteToBitsValue(data, 37, 0, 1);
mRemoteData.Mod04sts10 = MsgBits.ByteToBitsValue(data, 37, 1, 1);
mRemoteData.Mod04sts11 = MsgBits.ByteToBitsValue(data, 37, 2, 1);
mRemoteData.Mod04sts12 = MsgBits.ByteToBitsValue(data, 37, 3, 1);
mRemoteData.Mod05sts01 = MsgBits.ByteToBitsValue(data, 38, 0, 1);
mRemoteData.Mod05sts02 = MsgBits.ByteToBitsValue(data, 38, 1, 1);
mRemoteData.Mod05sts03 = MsgBits.ByteToBitsValue(data, 38, 2, 1);
mRemoteData.Mod05sts04 = MsgBits.ByteToBitsValue(data, 38, 3, 1);
mRemoteData.Mod05sts05 = MsgBits.ByteToBitsValue(data, 38, 4, 1);
mRemoteData.Mod05sts06 = MsgBits.ByteToBitsValue(data, 38, 5, 1);
mRemoteData.Mod05sts07 = MsgBits.ByteToBitsValue(data, 38, 6, 1);
mRemoteData.Mod05sts08 = MsgBits.ByteToBitsValue(data, 38, 7, 1);
mRemoteData.Mod05sts09 = MsgBits.ByteToBitsValue(data, 39, 0, 1);
mRemoteData.Mod05sts10 = MsgBits.ByteToBitsValue(data, 39, 1, 1);
mRemoteData.Mod05sts11 = MsgBits.ByteToBitsValue(data, 39, 2, 1);
mRemoteData.Mod05sts12 = MsgBits.ByteToBitsValue(data, 39, 3, 1);
mRemoteData.Mod06sts01 = MsgBits.ByteToBitsValue(data, 40, 0, 1);
mRemoteData.Mod06sts02 = MsgBits.ByteToBitsValue(data, 40, 1, 1);
mRemoteData.Mod06sts03 = MsgBits.ByteToBitsValue(data, 40, 2, 1);
mRemoteData.Mod06sts04 = MsgBits.ByteToBitsValue(data, 40, 3, 1);
mRemoteData.Mod06sts05 = MsgBits.ByteToBitsValue(data, 40, 4, 1);
mRemoteData.Mod06sts06 = MsgBits.ByteToBitsValue(data, 40, 5, 1);
mRemoteData.Mod06sts07 = MsgBits.ByteToBitsValue(data, 40, 6, 1);
mRemoteData.Mod06sts08 = MsgBits.ByteToBitsValue(data, 40, 7, 1);
mRemoteData.Mod06sts09 = MsgBits.ByteToBitsValue(data, 41, 0, 1);
mRemoteData.Mod06sts10 = MsgBits.ByteToBitsValue(data, 41, 1, 1);
mRemoteData.Mod06sts11 = MsgBits.ByteToBitsValue(data, 41, 2, 1);
mRemoteData.Mod06sts12 = MsgBits.ByteToBitsValue(data, 41, 3, 1);
mRemoteData.Mod07sts01 = MsgBits.ByteToBitsValue(data, 42, 0, 1);
mRemoteData.Mod07sts02 = MsgBits.ByteToBitsValue(data, 42, 1, 1);
mRemoteData.Mod07sts03 = MsgBits.ByteToBitsValue(data, 42, 2, 1);
mRemoteData.Mod07sts04 = MsgBits.ByteToBitsValue(data, 42, 3, 1);
mRemoteData.Mod07sts05 = MsgBits.ByteToBitsValue(data, 42, 4, 1);
mRemoteData.Mod07sts06 = MsgBits.ByteToBitsValue(data, 42, 5, 1);
mRemoteData.Mod07sts07 = MsgBits.ByteToBitsValue(data, 42, 6, 1);
mRemoteData.Mod07sts08 = MsgBits.ByteToBitsValue(data, 42, 7, 1);
mRemoteData.Mod07sts09 = MsgBits.ByteToBitsValue(data, 43, 0, 1);
mRemoteData.Mod07sts10 = MsgBits.ByteToBitsValue(data, 43, 1, 1);
mRemoteData.Mod07sts11 = MsgBits.ByteToBitsValue(data, 43, 2, 1);
mRemoteData.Mod07sts12 = MsgBits.ByteToBitsValue(data, 43, 3, 1);
mRemoteData.Mod08sts01 = MsgBits.ByteToBitsValue(data, 44, 0, 1);
mRemoteData.Mod08sts02 = MsgBits.ByteToBitsValue(data, 44, 1, 1);
mRemoteData.Mod08sts03 = MsgBits.ByteToBitsValue(data, 44, 2, 1);
mRemoteData.Mod08sts04 = MsgBits.ByteToBitsValue(data, 44, 3, 1);
mRemoteData.Mod08sts05 = MsgBits.ByteToBitsValue(data, 44, 4, 1);
mRemoteData.Mod08sts06 = MsgBits.ByteToBitsValue(data, 44, 5, 1);
mRemoteData.Mod08sts07 = MsgBits.ByteToBitsValue(data, 44, 6, 1);
mRemoteData.Mod08sts08 = MsgBits.ByteToBitsValue(data, 44, 7, 1);
mRemoteData.Mod08sts09 = MsgBits.ByteToBitsValue(data, 45, 0, 1);
mRemoteData.Mod08sts10 = MsgBits.ByteToBitsValue(data, 45, 1, 1);
mRemoteData.Mod08sts11 = MsgBits.ByteToBitsValue(data, 45, 2, 1);
mRemoteData.Mod08sts12 = MsgBits.ByteToBitsValue(data, 45, 3, 1);
mRemoteData.BGunPositiveFault = MsgBits.ByteToBitsValue(data, 46, 0, 1);
mRemoteData.BGunNegativeEleFault = MsgBits.ByteToBitsValue(data, 46, 1, 1);
mRemoteData.BGunPFuseFaulty = MsgBits.ByteToBitsValue(data, 46, 2, 1);
mRemoteData.BGunNPositiveFuseFaulty = MsgBits.ByteToBitsValue(data, 46, 3, 1);
mRemoteData.BGunPCntactorCon = MsgBits.ByteToBitsValue(data, 46, 4, 1);
mRemoteData.BGunNContactorCon = MsgBits.ByteToBitsValue(data, 46, 5, 1);
mRemoteData.BGunPConA3dhesionFailure = MsgBits.ByteToBitsValue(data, 46, 6, 1);
mRemoteData.BGunNConadhesionFailure = MsgBits.ByteToBitsValue(data, 46, 7, 1);
mRemoteData.BGunMeterComAbnormal = MsgBits.ByteToBitsValue(data, 47, 0, 1);
mRemoteData.BGunMeterAbnormal = MsgBits.ByteToBitsValue(data, 47, 1, 1);
}
return mRemoteData;
}
}
}