public bool Execute()
        {
            int length = 19;
            int count  = _content.Length / length;

            byte[] DeviceType;
            string commandid;

            byte[] content;
            for (int i = 0; i < count; i++)
            {
                DeviceType = new byte[2];
                Array.Copy(_content, 7 + (length * i), DeviceType, 0, 2);
                commandid = _content[13 + (i * length)].ToString();
                content   = new byte[19];
                Array.Copy(_content, length * i, content, 0, length);
                ICommand cmd;
                switch (ConverUtil.ByteToStr_A(DeviceType))
                {
                case "8040":
                    cmd = new QZGK_61443_8040_01(content, StationId, PlatformTime);
                    break;

                default:
                    cmd = new IgnoreCommand();
                    break;
                }
                cmd.Execute();
            }
            return(true);
        }
 public CZW_61504_0430_08(byte[] _content, ulong _StationId, DateTime _PlatformTime)
 {
     this._content     = _content;
     this.StationId    = _StationId;
     this.PlatformTime = _PlatformTime;
     this.OriginalCode = ConverUtil.ByteToStr_A(_content);
 }
 public MJ2_61445_12(byte[] content, ulong _StationId, DateTime _PlatformTime)
 {
     this.Content      = content;
     this.StationId    = _StationId;
     this.PlatformTime = _PlatformTime;
     this.OriginalCode = ConverUtil.ByteToStr_A(content);
 }
 public DJJ_2049(byte[] content, ulong stationId, DateTime platformTime)
 {
     this.Content      = content;
     this.StationId    = stationId;
     this.PlatformTime = platformTime;
     this.OriginalCode = ConverUtil.ByteToStr_A(content);
 }
Beispiel #5
0
 public MJ_33_0296(byte[] _content, ulong _StationId, DateTime _PlatformTime)
 {
     this._content     = _content;
     this.StationId    = _StationId;
     this.PlatformTime = _PlatformTime;
     this.OriginalCode = ConverUtil.ByteToStr_A(_content);
 }
        public bool Execute()
        {
            try
            {
                int    length = 19;
                int    count  = _content.Length / length;
                byte[] DeviceType;
                byte[] content;
                for (int i = 0; i < count; i++)
                {
                    DeviceType = new byte[2];
                    Array.Copy(_content, 7 + length * i, DeviceType, 0, 2);
                    content = new byte[19];
                    Array.Copy(_content, length * i, content, 0, length);
                    ICommand cmd;
                    switch (ConverUtil.ByteToStr_A(DeviceType))
                    {
                    case "0444":
                        cmd = new CeXie_61443_0444(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    cmd.Execute();
                }
            }
            catch (Exception ex)
            {
                MyLibrary.Log.Error("处理协议格式命令错误:" + ex.Message);
            }

            return(true);
        }
Beispiel #7
0
        private string StationLat;      //基站维度。

        public QZGK_61443_8040_01(byte[] _content, ulong _StationId, DateTime _PlatformTime)
        {
            this._content     = _content;
            this.StationId    = _StationId;
            this.PlatformTime = _PlatformTime;
            this.OriginalCode = ConverUtil.ByteToStr_A(_content);
        }
Beispiel #8
0
        public bool Execute()
        {
            try
            {
                byte[] sqkNumberByte = null;
                string sqkNumberInt;
                int    length = 4;
                int    count  = Content.Length / length;
                for (int i = 0; i < count; i++)
                {
                    sqkNumberByte = new byte[4];
                    Array.Copy(Content, i * length, sqkNumberByte, 0, 4);
                    Array.Reverse(sqkNumberByte);
                    sqkNumberInt = (Convert.ToUInt32(ConverUtil.ByteToStr_A(sqkNumberByte), 16)).ToString();
                    int    resultNo;
                    string ResultInfo;
                    MenJinShouQuanDal.Insert(Devid, sqkNumberInt, 2, out resultNo, out ResultInfo);
                    if (resultNo == 1)
                    {
                        MyLibrary.Log.Debug(string.Format(Name + "出错, ID:{0} 卡号:{1} Result:{2} 原始代码: {3}", Devid, sqkNumberInt, ResultInfo, OriginalCode));
                    }
                }
            }
            catch (Exception ex)
            {
                MyLibrary.Log.Error(Name + "出错:" + ex.Message + " 原始代码:" + OriginalCode);
            }

            return(true);
        }
 public MJ_33_0003(byte[] _content, ulong _devid, DateTime _time)
 {
     this._devid       = _devid;
     this._content     = _content;
     this._time        = _time;
     this.OriginalCode = ConverUtil.ByteToStr_A(_content);
 }
 public CZW_540(string _cmdId, byte[] _content, ulong _StationId, DateTime _PlatformTime)
 {
     this.CmdId        = _cmdId;
     this._content     = _content;
     this.StationId    = _StationId;
     this.PlatformTime = _PlatformTime;
     this.OriginalCode = ConverUtil.ByteToStr_A(_content);
 }
        public YKGC_01(byte[] content, ulong stationId, DateTime platformTime)
        {
            this.Content      = content;
            this.StationId    = stationId;
            this.PlatformTime = platformTime;
            this.OriginalCode = ConverUtil.ByteToStr_A(content);

            // MyLibrary.ConverUtil.StrToBytes(info.Content.Trim().Replace(" ", ""));
        }
        public bool Execute()
        {
            try
            {
                if (_content.Length != 50)
                {
                    MyLibrary.Log.Debug(NAME + "数据长度无效:原始代码:" + OriginalCode);
                    return(true);
                }

                if (FileManagement.Commands.MenJin.Filter_Bll.IsRepeat(this.OriginalCode))
                {
                    MyLibrary.Log.RepeatDataInfo("基站编号:" + StationId.ToString() + " 原始代码:" + OriginalCode);
                    return(true);
                }


                //    DateTime time = ConverUtil.Time(_content, 0); //设备时间。
                //  string CardId = ConverUtil.ByteToStr_4(_content,6);   //IC卡

                byte[] IdentytyCardNoByte = new byte[9];  //身份证
                Array.Copy(_content, 11, IdentytyCardNoByte, 0, 9);
                string IdCardReplace  = ConverUtil.ByteToStr_A(IdentytyCardNoByte).Replace('b', 'B').Replace('c', 'C').Replace('d', 'D').Replace('e', 'E').Replace('f', 'F');
                string IdentytyCardNo = IdCardReplace.Replace('A', 'X').TrimStart('0');

                byte[] phoneByte = new byte[6];  //电话
                Array.Copy(_content, 20, phoneByte, 0, 6);
                string Phone = ConverUtil.ByteToStr_A(phoneByte).Replace("F", "");

                byte[] addressByte = new byte[24];
                Array.Copy(_content, 26, addressByte, 0, 24);
                string UserRoom = BitConverter.ToString(addressByte).Replace("-", "");

                MJInfo info = new MJInfo();
                info.Protocol     = "1";
                info.DeviceTime   = ConverUtil.Time(_content, 0);        //设备时间。
                info.CardId       = ConverUtil.ByteToStr_4(_content, 6); //IC卡
                info.CardType     = _content[10].ToString();
                info.ChineseName  = "";
                info.Identitycard = IdentytyCardNo;
                info.DeviceId     = StationId.ToString();

                info.DataIntegrity = string.IsNullOrWhiteSpace(IdentytyCardNo) ? "0" : "1";
                info.UserPhoneNum  = Phone;
                info.UserRoom      = UserRoom;

                IMjDal.Handle(NAME, OriginalCode, info);
            }
            catch (Exception ex)
            {
                MyLibrary.Log.Error(NAME + "错误:" + ex.Message + " 原始代码:" + OriginalCode);
            }
            return(true);
        }
 public static string SFZ_Str(byte[] value, int start)
 {
     if (ConverUtil.ByteToStr_A(value) != "FFFFFFFFFFFFFFFFFF")
     {
         return(SFZUtil.ByteToStr(value, start));
     }
     else
     {
         return("");
     }
 }
        public bool Execute()
        {
            try
            {
                if (_content.Length < 28)
                {
                    MyLibrary.Log.Debug(NAME + "数据长度无效:原始代码:" + OriginalCode);
                    return(true);
                }


                if (FileManagement.Commands.MenJin.Filter_Bll.IsRepeat(this.OriginalCode))
                {
                    MyLibrary.Log.RepeatDataInfo("基站编号:" + StationId.ToString() + " 原始代码:" + OriginalCode);
                    return(true);
                }


                DateTime time   = ConverUtil.Time(_content, 0);        //设备时间。
                string   CardId = ConverUtil.ByteToStr_4(_content, 6); //卡Id

                byte[] IdentytyCardNoByte = new byte[9];               //身份证
                Array.Copy(_content, 11, IdentytyCardNoByte, 0, 9);
                string IdCardReplace  = ConverUtil.ByteToStr_A(IdentytyCardNoByte).Replace('b', 'B').Replace('c', 'C').Replace('d', 'D').Replace('e', 'E').Replace('f', 'F');
                string IdentytyCardNo = IdCardReplace.Replace('A', 'X').TrimStart('0');

                //byte[] phoneByte = new byte[6];  //电话
                //Array.Copy(_content, 20, phoneByte, 0, 6);
                //string phone = ConverUtil.ByteToStr_A(phoneByte).Replace("F", "");

                //byte[] roomIdByte = new byte[2];  //房间Id
                //Array.Copy(_content, 26, roomIdByte, 0, 2);
                MJInfo info = new MJInfo();
                info.Protocol      = "18";
                info.DeviceId      = StationId.ToString();
                info.CardId        = CardId;
                info.CardType      = _content[10].ToString();
                info.Identitycard  = IdentytyCardNo;
                info.IsOpenDoor    = "0";
                info.IsOpenByCard  = "1";
                info.DataIntegrity = "0";
                info.DeviceTime    = time;

                IMjDal.Handle(NAME, OriginalCode, info);
            }
            catch (Exception ex)
            {
                MyLibrary.Log.Error(NAME + "错误:" + ex.Message + " 原始代码:" + OriginalCode);
            }
            return(true);
        }
        public bool Execute()
        {
            try
            {
                DateTime DeviceTime             = ConverUtil.Time(_content, 0);           //设备时间。
                string   HomeCardType           = _content[6].ToString();                 //房东卡类型.
                string   HomeCardIdentitycardId = ConverUtil.ByteToStr_Q(_content, 7, 8); //房东卡身份证ID.
                string   CardType   = _content[15].ToString();                            //卡类型。
                string   CardId     = "";
                byte[]   EJUcardNum = new byte[4];                                        //E居卡卡号
                Array.Copy(_content, 16, EJUcardNum, 0, 4);
                if (CardType == "9")
                {
                    CardId = ConverUtil.ByteToStr_A(EJUcardNum);
                }
                else
                {
                    CardId = (Convert.ToUInt32(ConverUtil.ByteToStr_A(EJUcardNum), 16)).ToString();
                }
                string UserIdentitycardId = ConverUtil.ByteToStr_Q(_content, 20, 8); //用户身份证ID。
                string Identitycard       = SFZUtil.ByteToStr(_content, 28);         //身份证。
                string HomeNum            = _content[37].ToString();                 //房东编号。
                string RoomNum            = ConverUtil.ByteToStr_2(_content, 38);    //房间号。

                MenJinInfo info = new MenJinInfo();
                info.pi_bigtype            = "61443"; //0xF004
                info.pi_devicetime         = DeviceTime;
                info.pi_devicecode         = StationId.ToString();
                info.pi_protocoltype       = "4"; //0x01
                info.pi_lordcardtype       = HomeCardType;
                info.pi_lordidentitycardid = HomeCardIdentitycardId;
                info.pi_cardtype           = CardType;
                info.pi_cardid             = CardId;
                info.pi_identitycardid     = UserIdentitycardId;
                info.pi_identitycard       = Identitycard;
                info.pi_houseno            = HomeNum;
                info.pi_roomno             = RoomNum;
                info.pi_servicetime        = PlatformTime;
                string Result = IMj2Dal.Insert(info);
                if (Result != "0")
                {
                    MyLibrary.Log.Debug(NAME + "出错:" + Result + " 原始代码:" + OriginalCode);
                }
            }
            catch (Exception ex)
            {
                MyLibrary.Log.Error(NAME + "出错:" + ex.Message + " 原始代码:" + OriginalCode);
            }

            return(true);
        }
        public bool Execute()
        {
            try
            {
                DateTime DeviceTime         = ConverUtil.Time(_content, 0);           //设备时间。
                string   HomeCardType       = _content[6].ToString();                 //房东卡类型。
                string   HomeIdentitycardId = ConverUtil.ByteToStr_Q(_content, 7, 8); //房东身份Id.
                string   CardType           = _content[15].ToString();                //卡类型。

                string pi_cardid      = "";
                byte[] ShenFenZhengID = new byte[8];
                Array.Copy(_content, 16, ShenFenZhengID, 0, 8);
                if (CardType == "5")
                {
                    pi_cardid = (Convert.ToUInt64(ConverUtil.ByteToStr_A(ShenFenZhengID), 16)).ToString();
                }
                if (CardType == "9")
                {
                    pi_cardid = ConverUtil.ByteToStr_A(ShenFenZhengID);
                }
                string HomeNum = _content[24].ToString();              //房东编号。
                string RoomNum = ConverUtil.ByteToStr_2(_content, 25); //房间号。


                MenJinInfo info = new MenJinInfo();
                info.pi_bigtype            = "61443"; //0xF004
                info.pi_devicetime         = DeviceTime;
                info.pi_devicecode         = StationId.ToString();
                info.pi_protocoltype       = "7"; //0x01
                info.pi_lordcardtype       = HomeCardType;
                info.pi_lordidentitycardid = HomeIdentitycardId;
                info.pi_cardtype           = CardType;
                info.pi_cardid             = pi_cardid;
                info.pi_houseno            = HomeNum;
                info.pi_roomno             = RoomNum;
                info.pi_servicetime        = PlatformTime;
                string Result = IMj2Dal.Insert(info);
                if (Result != "0")
                {
                    MyLibrary.Log.Debug(NAME + "出错:" + Result + " 原始代码:" + OriginalCode);
                }
            }
            catch (Exception ex)
            {
                MyLibrary.Log.Error(NAME + "出错:" + ex.Message + " 原始代码:" + OriginalCode);
            }
            return(true);
        }
Beispiel #17
0
        public bool Execute()
        {
            try
            {
                DateTime DeviceTime = ConverUtil.Time(_content, 0); //设备时间。
                string   CardType   = _content[6].ToString();       //卡类型。
                byte[]   CardNum    = new byte[8];
                Array.Copy(_content, 7, CardNum, 0, 8);
                string CardId = "";
                if (CardType == "9")
                {
                    CardId = ConverUtil.ByteToStr_A(CardNum);
                }
                else
                {
                    CardId = Convert.ToUInt64(ConverUtil.ByteToStr_A(CardNum), 16).ToString();
                }
                string Identitycard = SFZUtil.ByteToStr(_content, 15); //身份证号码。

                string HomeNum = _content[24].ToString();              //房东编号
                string RoomNum = ConverUtil.ByteToStr_2(_content, 25); //房间号。

                MenJinInfo info = new MenJinInfo();
                info.pi_bigtype      = "61444"; //0xF004
                info.pi_devicetime   = DeviceTime;
                info.pi_devicecode   = StationId.ToString();
                info.pi_protocoltype = "2"; //0x01
                info.pi_cardtype     = CardType;
                info.pi_cardid       = CardId;
                info.pi_identitycard = Identitycard;
                info.pi_houseno      = HomeNum;
                info.pi_roomno       = RoomNum;
                info.pi_servicetime  = PlatformTime;
                string Result = IMj2Dal.Insert(info);
                if (Result != "0")
                {
                    MyLibrary.Log.Debug(NAME + "出错:" + Result + " 原始代码:" + OriginalCode);
                }
            }
            catch (Exception ex)
            {
                MyLibrary.Log.Error(NAME + "出错:" + ex.Message + " 原始代码:" + OriginalCode);
            }

            return(true);
        }
        public bool Execute()
        {
            try
            {
                byte[] bDianBiao1 = new byte[4];
                Array.Copy(_content, 0, bDianBiao1, 0, 4);
                string dianbiao1 = (Convert.ToUInt32(ConverUtil.ByteToStr_A(bDianBiao1), 16)).ToString();

                string dianbiaoState1 = _content[4].ToString();

                byte[] bDianBiao2 = new byte[4];
                Array.Copy(_content, 5, bDianBiao2, 0, 4);
                string dianbiao2 = (Convert.ToInt32(ConverUtil.ByteToStr_A(bDianBiao2), 16)).ToString();

                string dianbiaoState2 = _content[9].ToString();
                string sblx           = "257";

                string room    = Tb_DeviceInfo_Dal.Select(sblx, dianbiao1, dianbiaoState1);
                string bfState = dianbiaoState1 == "1" ? "1" : "2";


                Info = Tb_AutoDeployLog_Info(room, bfState);
                Tb_AutoDeployLog_Dal.Insert(Info);
                if (!string.IsNullOrEmpty(room))
                {
                    Tb_RoomInfo_Dal.Update(room, bfState);
                }
                room = Tb_DeviceInfo_Dal.Select(sblx, dianbiao2, dianbiaoState2);
                string bfState2 = dianbiaoState2 == "1" ? "1" : "2";

                Info = Tb_AutoDeployLog_Info(room, bfState2);
                Tb_AutoDeployLog_Dal.Insert(Info);

                if (!string.IsNullOrEmpty(room))
                {
                    Tb_RoomInfo_Dal.Update(room, bfState2);
                }
            }
            catch (Exception ex)
            {
                MyLibrary.Log.Error(Name + "错误: " + ex.Message + " 原始代码:" + OriginalCode);
            }

            return(true);
        }
        public bool Execute()
        {
            try
            {
                byte[] DeviceTypeByte = new byte[2];                           //设备类型
                Array.Copy(_content, 1, DeviceTypeByte, 0, 2);
                string DeviceType = Convert.ToUInt16(ConverUtil.ByteToStr_A(DeviceTypeByte), 16).ToString();

                byte[] DeviceIdByte = new byte[4];                             //设备Id
                Array.Copy(_content, 3, DeviceIdByte, 0, 4);
                string DeviceId = Convert.ToUInt32(ConverUtil.ByteToStr_A(DeviceIdByte), 16).ToString();

                string CommandWord = _content[7].ToString();                  //命令字

                byte[] XAxisAngleValueByte = new byte[2];                     //X轴值
                Array.Copy(_content, 8, XAxisAngleValueByte, 0, 2);
                string XAxisAngleValue = DataJM.GetAngleValue(ConverUtil.ByteToStr_A(XAxisAngleValueByte));

                byte[] YAxisAngleValueByte = new byte[2];                                 //Y轴值
                Array.Copy(_content, 10, YAxisAngleValueByte, 0, 2);
                string YAxisAngleValue = DataJM.GetAngleValue(ConverUtil.ByteToStr_A(YAxisAngleValueByte));

                string Version = _content[12].ToString();                      //版本号。

                CeXieInfo info = new CeXieInfo();
                info.DeviceTime   = DateTime.Now;
                info.DeviceType   = DeviceType;
                info.DeviceId     = DeviceId;
                info.ProtocolType = CommandWord;
                info.Reserved1    = XAxisAngleValue;
                info.Reserved2    = YAxisAngleValue;
                info.Version      = Version;
                info.StationNo    = StationId.ToString();
                info.ServiceTime  = PlatformTime;

                ICeXieDal.Handle(Name, OriginalCode, info);
            }
            catch (Exception ex)
            {
                MyLibrary.Log.Error(Name + "错误:" + ex.Message + " 基站编号:" + StationId.ToString() + " 原始代码:" + OriginalCode);
            }

            return(true);
        }
        public bool Execute()
        {
            try
            {
                byte[] bKaHao = new byte[4];
                Array.Copy(_content, 0, bKaHao, 0, 4);
                string YouYuanKa = (Convert.ToUInt32(ConverUtil.ByteToStr_A(bKaHao), 16)).ToString();

                byte[] bEsiteNum = new byte[4];
                Array.Copy(_content, 4, bEsiteNum, 0, 4);
                string EJKaHao = (Convert.ToUInt32(ConverUtil.ByteToStr_A(bEsiteNum), 16)).ToString();

                byte[] IdentitycardByte = new byte[9];
                Array.Copy(_content, 8, IdentitycardByte, 0, 9);
                string Identitycard = ConverUtil.ByteToStr_A(IdentitycardByte).Replace('A', 'X').TrimStart('0');

                Pro_IndateBase_Mod info = new Pro_IndateBase_Mod();
                info.pi_bigtype      = "3";
                info.pi_devicetime   = PlatformTime;
                info.pi_devicetype   = "270";
                info.pi_devicecode   = YouYuanKa;
                info.pi_protocoltype = EJKaHao;
                info.pi_param1       = EJKaHao;
                info.pi_param2       = Identitycard;
                info.pi_stationno    = StationId.ToString();

                int    resultNo;
                string reason;
                int    status;
                string wechatid;


                Pro_IndateBase_Dal.Exec(info, out resultNo, out reason, out status, out wechatid);
                if (resultNo == 1)
                {
                    MyLibrary.Log.Debug(Name + "出错" + " Reason:" + reason + " 原始代码:" + OriginalCode);
                }
            }
            catch (Exception ex)
            {
                MyLibrary.Log.Error(Name + "出错:" + ex.Message + " 原始代码:" + OriginalCode);
            }
            return(true);
        }
Beispiel #21
0
        public bool Execute()
        {
            try
            {
                int    length = 16;
                int    count  = _content.Length / length;
                byte[] DeviceType;
                byte[] content;
                for (int i = 0; i < count; i++)
                {
                    string ddd = _content[i * 16].ToString();
                    if (ddd == "170")
                    {
                        DeviceType = new byte[2];
                        Array.Copy(_content, 2 + (length * i), DeviceType, 0, 2);
                        content = new byte[length - 3];
                        Array.Copy(_content, (length * i) + 1, content, 0, length - 3);
                        ICommand cmd;
                        switch (ConverUtil.ByteToStr_A(DeviceType))
                        {
                        case "0444":
                            cmd = new CeXie_66_0444(content, StationId, PlatformTime);
                            break;

                        default:
                            cmd = new IgnoreCommand();
                            break;
                        }
                        cmd.Execute();
                    }
                }
            }
            catch (Exception ex)
            {
                MyLibrary.Log.Error("处理协议格式命令错误:" + ex.Message);
            }

            return(true);
        }
Beispiel #22
0
        private string vvssss(byte[] content)
        {
            string Str     = "";
            string StrTemp = "";

            byte[] Data;
            int    Num = content.Length;

            if (Num >= 2)
            {
                if (Num % 2 == 0)
                {
                    for (int i = 0; i < Num / 2; i++)
                    {
                        Data = new byte[2];
                        Array.Copy(content, i * 2, Data, 0, 2);
                        StrTemp = ConverUtil.ByteToStr_A(Data);
                        if (StrTemp == "0000")
                        {
                            return(Str);
                        }
                        else
                        {
                            Str += Encoding.Default.GetString(Data);
                        }
                    }
                    return(Str);
                }
                else
                {
                    return("");
                }
            }
            else
            {
                return("");
            }
        }
Beispiel #23
0
 public MenJinKaShanChuCommand(string _devid, byte[] _content)
 {
     this.Content      = _content;
     this.Devid        = _devid;
     this.OriginalCode = ConverUtil.ByteToStr_A(_content);
 }
        public bool Execute()
        {
            int length = 19;
            int count  = _content.Length / length;

            byte[] DeviceType;
            string commandid;

            byte[] SubContent;
            for (int i = 0; i < count; i++)
            {
                DeviceType = new byte[2];
                Array.Copy(_content, 7 + length * i, DeviceType, 0, 2);
                commandid  = _content[13 + i * length].ToString();
                SubContent = new byte[19];
                Array.Copy(_content, length * i, _content, 0, length);
                ICommand cmd;
                switch (ConverUtil.ByteToStr_A(DeviceType))
                {
                case "0406":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new QYFH_61443_0406_1(SubContent, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "0600":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new QYFH_61443_0600_1(SubContent, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "0601":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new QYFH_61443_0601_1(SubContent, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "0602":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new QYFH_61443_0602_1(SubContent, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                default:
                    cmd = new IgnoreCommand();
                    break;
                }
                cmd.Execute();
            }
            return(true);
        }
Beispiel #25
0
        public bool Execute()
        {
            try
            {
                int    CycleNum = 0;
                string CommandIdStr;
                UInt16 lengthInt;
                byte[] CommandId = new byte[2];
                byte[] length    = new byte[2];
                byte[] SubContent;
                for (int i = 0; i < _content.Length; i += CycleNum)
                {
                    Array.Copy(_content, i, CommandId, 0, 2);
                    Array.Copy(_content, 2 + i, length, 0, 2);
                    CommandIdStr = ConverUtil.ByteToStr_A(CommandId);
                    lengthInt    = Convert.ToUInt16(ConverUtil.ByteToStr_A(length), 16);
                    SubContent   = new byte[lengthInt];
                    Array.Copy(_content, 4 + i, SubContent, 0, lengthInt);
                    ICommand cmd;
                    switch (CommandIdStr)
                    {
                    case "0001":
                        cmd = new MJ_33_0001(SubContent, StationId, PlatformTime);     //小写的b到f转成大写的B到F。
                        break;

                    case "0002":
                        cmd = new MJ_33_0002(SubContent, StationId, PlatformTime);
                        break;

                    case "0003":
                        cmd = new MJ_33_0003(SubContent, StationId, PlatformTime);
                        break;

                    case "0012":
                        cmd = new MJ_33_0012(SubContent, StationId, PlatformTime);     //12
                        break;

                    case "0046":
                        cmd = new MJ_33_0046(SubContent, StationId, PlatformTime);
                        break;

                    case "0291":
                        cmd = new MJ_33_0291(SubContent, StationId, PlatformTime);
                        break;

                    case "0292":
                        cmd = new MJ_33_0292(SubContent, StationId, PlatformTime);
                        break;

                    case "0293":
                        cmd = new MJ_33_0293(SubContent, StationId, PlatformTime);
                        break;

                    case "0294":
                        cmd = new MJ_33_0294(SubContent, StationId, PlatformTime);
                        break;

                    case "0295":
                        cmd = new MJ_33_0295(SubContent, StationId, PlatformTime);
                        break;

                    case "0296":
                        cmd = new MJ_33_0296(SubContent, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    cmd.Execute();
                    CycleNum = 4 + lengthInt;
                }
            }
            catch (Exception ex)
            {
                MyLibrary.Log.Error("解析命令:" + ex.Message + " 原始代码:" + ConverUtil.ByteToStr_A(_content));
            }
            return(true);
        }
        public bool Execute()
        {
            try
            {
                #region 测斜统计



                DateTime time        = ConverUtil.Time(_content, 0);        //设备时间。
                string   ZhongJiId   = _content[6].ToString();              //中继号
                string   DeviceType  = ConverUtil.ByteToStr_2(_content, 7);
                string   DeviceId    = ConverUtil.ByteToStr_4(_content, 9); // 设备Id
                string   CommandWord = _content[13].ToString();             //命令字

                byte[] XAxisAngleValueByte = new byte[2];                   //X轴值
                Array.Copy(_content, 14, XAxisAngleValueByte, 0, 2);
                string XAxisAngleValue = DataJM.GetAngleValue(ConverUtil.ByteToStr_A(XAxisAngleValueByte));

                byte[] YAxisAngleValueByte = new byte[2];                                 //Y轴值
                Array.Copy(_content, 16, YAxisAngleValueByte, 0, 2);
                string YAxisAngleValue = DataJM.GetAngleValue(ConverUtil.ByteToStr_A(YAxisAngleValueByte));

                string Version = _content[18].ToString();                    //版本号。

                CeXieInfo info = new CeXieInfo();
                info.DeviceTime   = time;
                info.DeviceType   = DeviceType;
                info.DeviceId     = DeviceId;
                info.ProtocolType = CommandWord;
                info.Reserved1    = XAxisAngleValue;
                info.Reserved2    = YAxisAngleValue;
                info.Version      = Version;
                info.StationNo    = StationId.ToString();
                info.ServiceTime  = PlatformTime;
                CeXieDal.AgreementFormat_Insert(info);

                #endregion



                #region 处理后发送短信

                //byte[] timeByte = new byte[6];                                 //设备时间
                //Array.Copy(_content, 0, timeByte, 0, 6);
                //DateTime time = Utils.GetTime(timeByte);
                //string ZhongJiId = _content[6].ToString();                     //中继号
                //byte[] DeviceTypeByte = new byte[2];                           //设备类型
                //Array.Copy(_content, 7, DeviceTypeByte, 0, 2);
                //string DeviceType = Convert.ToUInt64(ConverUtil.ByteToStr_A(DeviceTypeByte), 16).ToString();
                //byte[] DeviceIdByte = new byte[4];                             //设备Id
                //Array.Copy(_content, 9, DeviceIdByte, 0, 4);
                //string DeviceId = Convert.ToUInt64(ConverUtil.ByteToStr_A(DeviceIdByte), 16).ToString();
                //string CommandWord = _content[13].ToString();                  //命令字

                //byte[] XAxisAngleValueByte = new byte[2];                                 //X轴值
                //Array.Copy(_content, 14, XAxisAngleValueByte, 0, 2);
                //string XAxisAngleValue = Utils.GetAngleValue(ConverUtil.ByteToStr_A(XAxisAngleValueByte));

                //byte[] YAxisAngleValueByte = new byte[2];                                 //Y轴值
                //Array.Copy(_content, 16, YAxisAngleValueByte, 0, 2);
                //string YAxisAngleValue = Utils.GetAngleValue(ConverUtil.ByteToStr_A(YAxisAngleValueByte));

                //string Version = _content[18].ToString();                      //版本号。

                //CeXieInfo info = new CeXieInfo();
                //info.DeviceTime = time;
                //info.DeviceType = DeviceType;
                //info.DeviceId = DeviceId;
                //info.ProtocolType = CommandWord;
                //info.Reserved1 = XAxisAngleValue;
                //info.Reserved2 = YAxisAngleValue;
                //info.Version = Version;
                //info.StationNo = StationId.ToString();
                //info.ServiceTime = PlatformTime;

                //ICeXieDal.Handle(Name, OriginalCode, info);



                #endregion
            }
            catch (Exception ex)
            {
                MyLibrary.Log.Error(Name + "错误:" + ex.Message + " 基站编号:" + StationId.ToString() + " 原始代码:" + OriginalCode);
            }

            return(true);
        }
        public bool Execute()
        {
            int length = 19;
            int count  = _content.Length / length;

            byte[] DeviceType;
            string commandid;

            byte[] content;
            for (int i = 0; i < count; i++)
            {
                DeviceType = new byte[2];
                Array.Copy(_content, 7 + (length * i), DeviceType, 0, 2);
                commandid = _content[13 + (i * length)].ToString();
                content   = new byte[19];
                Array.Copy(_content, length * i, content, 0, length);
                ICommand cmd;
                switch (ConverUtil.ByteToStr_A(DeviceType))
                {
                case "0410":
                    cmd = new CZW_61444_0410(content, StationId, PlatformTime);
                    break;

                case "0406":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_0406_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_0406_02(content, StationId, PlatformTime);
                        break;

                    case "4":
                        cmd = new CZW_61444_0406_04(content, StationId, PlatformTime);
                        break;

                    case "10":
                        cmd = new CZW_61444_0406_10(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "0407":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_0407_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_0407_02(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "0408":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_0408_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_0408_02(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "0409":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_0409_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_0409_02(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "0480":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_0480_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_0480_02(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "040A":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_040A_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_040A_02(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "040C":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_040C_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_040C_02(content, StationId, PlatformTime);
                        break;

                    case "4":
                        cmd = new CZW_61444_040C_04(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "040D":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_040D_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_040D_02(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "040B":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_040B_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_040B_02(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "0440":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_0440_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_0440_02(content, StationId, PlatformTime);
                        break;

                    case "3":
                        cmd = new CZW_61444_0440_03(content, StationId, PlatformTime);
                        break;

                    case "4":
                        cmd = new CZW_61444_0440_04(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "0441":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_0441_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_0441_02(content, StationId, PlatformTime);
                        break;

                    case "3":
                        cmd = new CZW_61444_0441_03(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "0442":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_0442_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_0442_02(content, StationId, PlatformTime);
                        break;

                    case "3":
                        cmd = new CZW_61444_0442_03(content, StationId, PlatformTime);
                        break;

                    case "4":
                        cmd = new CZW_61444_0442_04(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                case "0417":
                    switch (commandid)
                    {
                    case "1":
                        cmd = new CZW_61444_0417_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61444_0417_02(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                default:
                    cmd = new IgnoreCommand();
                    break;
                }
                cmd.Execute();
            }
            return(true);
        }
        public bool Execute()
        {
            int length = 27;
            int count  = _content.Length / length;

            byte[] DeviceType;
            string CommandId;

            byte[] content;
            for (int i = 0; i < count; i++)
            {
                DeviceType = new byte[2];
                Array.Copy(_content, 7 + (length * i), DeviceType, 0, 2);
                CommandId = _content[13 + (i * length)].ToString();
                content   = new byte[27];
                Array.Copy(_content, length * i, content, 0, length);
                ICommand cmd;
                switch (ConverUtil.ByteToStr_A(DeviceType))
                {
                case "0430":
                    switch (CommandId)
                    {
                    case "1":
                        cmd = new CZW_61504_0430_01(content, StationId, PlatformTime);
                        break;

                    case "2":
                        cmd = new CZW_61504_0430_02(content, StationId, PlatformTime);
                        break;

                    case "3":
                        cmd = new CZW_61504_0430_03(content, StationId, PlatformTime);
                        break;

                    //case "4":
                    //    cmd = new CZW_61504_0430_04(content, StationId, PlatformTime);  //振川说暂时不用。
                    //    break;
                    //case "5":
                    //    cmd = new CZW_61504_0430_05(content, StationId, PlatformTime);  //振川说暂时不用。
                    //    break;
                    //case "7":
                    //    cmd = new CZW_61504_0430_07(content, StationId, PlatformTime);
                    //    break;
                    //case "8":
                    //    cmd = new CZW_61504_0430_08(content, StationId, PlatformTime);
                    //    break;
                    //case "10":
                    //    cmd = new CZW_61504_0430_10(content, StationId, PlatformTime);
                    //    break;
                    //case "12":
                    //    cmd = new CZW_61504_0430_12(content, StationId, PlatformTime);
                    //    break;
                    //case "14":
                    //    cmd = new CZW_61504_0430_14(content, StationId, PlatformTime);
                    //    break;
                    case "16":
                        cmd = new CZW_61504_0430_16(content, StationId, PlatformTime);
                        break;

                    case "48":
                        cmd = new CZW_61504_0430_48(content, StationId, PlatformTime);
                        break;

                    default:
                        cmd = new IgnoreCommand();
                        break;
                    }
                    break;

                default:
                    cmd = new IgnoreCommand();
                    break;
                }
                cmd.Execute();
            }
            return(true);
        }