Esempio n. 1
0
        public PacketRecv Parse(string recv)
        {
            PacketRecv PacketRecv0000;

            try
            {
                RecvType rt;
                int      iAddress = int.Parse(recv.Substring(0, 4), NumberStyles.AllowHexSpecifier);

                switch (recv.Substring(12, 2).ToUpper())
                {
                case "10":
                    rt       = RecvType.Correct;
                    iAddress = int.Parse(recv.Substring(14, 2), NumberStyles.AllowHexSpecifier);
                    goto Label_0114;

                case "11":
                    rt       = RecvType.CheckError;
                    iAddress = int.Parse(recv.Substring(14, 2), NumberStyles.AllowHexSpecifier);
                    goto Label_0114;

                case "12":
                    rt       = RecvType.EndError;
                    iAddress = int.Parse(recv.Substring(14, 2), NumberStyles.AllowHexSpecifier);
                    goto Label_0114;

                case "13":
                    rt       = RecvType.SRamFull;
                    iAddress = int.Parse(recv.Substring(14, 2), NumberStyles.AllowHexSpecifier);
                    goto Label_0114;

                case "1C":
                    rt = RecvType.DeleteTable;
                    goto Label_0114;

                case "1D":
                    rt = RecvType.KeyEvent;
                    goto Label_0114;

                case "18":
                    if (!(recv.Substring(14, 2).ToUpper() == "00"))
                    {
                        break;
                    }
                    rt = RecvType.ResetCorrect;
                    goto Label_0114;

                default:
                    rt = RecvType.Others;
                    goto Label_0114;
                }
                rt = RecvType.ResetError;
Label_0114:
                PacketRecv0000 = new PacketRecv(rt, iAddress, recv);
            }
            catch (Exception)
            {
                PacketRecv0000 = new PacketRecv(RecvType.Others, 0, recv);
            }
            return(PacketRecv0000);
        }
Esempio n. 2
0
        public PacketRecv Parse(string recv)
        {
            PacketRecv PacketRecv0000;
            try
            {
                RecvType rt;
                int iAddress = int.Parse(recv.Substring(0, 4), NumberStyles.AllowHexSpecifier);

                switch (recv.Substring(12, 2).ToUpper())
                {
                    case "10":
                        rt = RecvType.Correct;
                        iAddress = int.Parse(recv.Substring(14, 2), NumberStyles.AllowHexSpecifier);
                        goto Label_0114;

                    case "11":
                        rt = RecvType.CheckError;
                        iAddress = int.Parse(recv.Substring(14, 2), NumberStyles.AllowHexSpecifier);
                        goto Label_0114;

                    case "12":
                        rt = RecvType.EndError;
                        iAddress = int.Parse(recv.Substring(14, 2), NumberStyles.AllowHexSpecifier);
                        goto Label_0114;

                    case "13":
                        rt = RecvType.SRamFull;
                        iAddress = int.Parse(recv.Substring(14, 2), NumberStyles.AllowHexSpecifier);
                        goto Label_0114;

                    case "1C":
                        rt = RecvType.DeleteTable;
                        goto Label_0114;

                    case "1D":
                        rt = RecvType.KeyEvent;
                        goto Label_0114;

                    case "18":
                        if (!(recv.Substring(14, 2).ToUpper() == "00"))
                        {
                            break;
                        }
                        rt = RecvType.ResetCorrect;
                        goto Label_0114;

                    default:
                        rt = RecvType.Others;
                        goto Label_0114;
                }
                rt = RecvType.ResetError;
            Label_0114:
                PacketRecv0000 = new PacketRecv(rt, iAddress, recv);
            }
            catch (Exception)
            {
                PacketRecv0000 = new PacketRecv(RecvType.Others, 0, recv);
            }
            return PacketRecv0000;
        }
Esempio n. 3
0
        public override void com_Data_Return(object Data)
        {
            try
            {
                PacketRecv pr = (PacketRecv)Data;
                if (pr.recvType != RecvType.Correct && Ack == null)
                {
                    return;
                }
                switch (pr.recvType)
                {
                case RecvType.Correct:
                    if (this.CurrentData != null && pr.address == ((CmdData)this.CurrentData.data).address)
                    {
                        this.CurrentData = null;
                    }
                    break;

                case RecvType.KeyEvent:
                    string recv   = pr.message;
                    string data   = recv.Substring(14, 4);
                    byte[] btData = new byte[2];
                    int    keyNo  = 0;
                    btData[0] = byte.Parse(data.Substring(0, 2), NumberStyles.HexNumber);
                    btData[1] = byte.Parse(data.Substring(2, 2), NumberStyles.HexNumber);
                    if ((btData[0] & 0x10) == 0)
                    {
                        this.DeleteData(pr.address);
                    }
                    else
                    {
                        this.ExecuteCmd(pr.address, CmdType.KeyRaisedAck, btData);
                    }
                    if ((btData[0] & 1) == 1)
                    {
                        keyNo = 1;
                    }
                    if ((btData[0] & 2) == 2)
                    {
                        keyNo = 2;
                    }
                    if ((btData[0] & 4) == 4)
                    {
                        keyNo = 3;
                    }

                    Ack(pr.address, keyNo.ToString(), "key");
                    break;

                case RecvType.DeleteTable:
                    this.DeleteData(pr.address);
                    Ack(pr.address, "DeleteTable!", "err");
                    break;

                case RecvType.CheckError:
                    Ack(pr.address, "CheckError", "err");
                    break;

                case RecvType.EndError:
                    Ack(pr.address, "EndError", "err");
                    break;

                case RecvType.NotExist:
                    Ack(pr.address, "NotExist", "err");
                    break;

                case RecvType.SRamFull:
                    Ack(pr.address, "SRamFull", "err");
                    break;

                case RecvType.Timeout:
                    Ack(pr.address, "Timeout", "err");
                    break;

                case RecvType.ResetCorrect:
                    Ack(pr.address, "控制卡复位成功!", "success");
                    break;

                case RecvType.ResetError:
                    Ack(pr.address, "控制卡复位失败!", "err");
                    break;

                case RecvType.Others:
                    Ack(pr.address, "控制卡其他不可识别错误!", "err");
                    break;

                default:
                    break;
                }
            }
            catch { }
        }