Beispiel #1
0
        public void MakeUpByte(byte[] buffer, string[] arr)
        {
            switch (Provider.GetValue <byte>(CSDefineType.headSign, buffer))
            {
            case FlagType.CS_AskReplay:
                if (CheckSum(true, buffer))
                {
                    if (Provider.GetValue <byte>(CSDefineType.modeText, buffer) == CS_AskReply.Multi &&
                        Provider.GetValue <byte>(CSDefineType.sendDirection, buffer) == SendDirection.S_C)
                    {
                        ClearSet();
                        packaddress.cust_id  = Provider.GetValue <ushort>(CSDefineType.cust, buffer);
                        packaddress.group_id = Provider.GetValue <byte>(CSDefineType.packGroup, buffer);
                        packaddress.pack_id  = Provider.GetValue <byte>(CSDefineType.pack, buffer);
                        packaddress.dataType = Provider.GetValue <byte>(CSDefineType.reservedBit1, buffer);
                        totalPackNum         = BitConverter.ToInt32(buffer, Provider.CT.defineIndex);
                        timeoutTimer.Start();
                    }
                    else
                    {
                        ReceiveEvent = new SocketEvent(SocketEventType.ReceEvent, buffer, buffer.Length, arr[0], int.Parse(arr[1]));
                    }
                }
                break;

            case FlagType.CS_Multi:
                if (CheckSum(true, buffer))
                {
                    Thread.Sleep(1);
                    if (receiveNum == Provider.GetValue <ushort>(CSDefineType.multiID, buffer) &&
                        packaddress.cust_id == Provider.GetValue <ushort>(CSDefineType.cust, buffer) &&
                        packaddress.group_id == Provider.GetValue <byte>(CSDefineType.packGroup, buffer) &&
                        packaddress.pack_id == Provider.GetValue <byte>(CSDefineType.pack, buffer) &&
                        packaddress.dataType == Provider.GetValue <byte>(CSDefineType.modeText, buffer))
                    {
                        //此包的数据长度
                        int dataNum = Provider.GetValue <int>(CSDefineType.contentLength, buffer);
                        for (int i = 0; i < dataNum; i++)
                        {
                            multiByte.Add(buffer[i + Provider.CT.defineIndex]);
                        }
                        //if (receiveNum % 50 == 0)
                        //{
                        //    BLLCommon.SendToServer(CS_AskReply.MultiReply, bq_Client.Properties.Settings.Default.DTUIndex,
                        //        Convert.ToByte(packaddress.group_id), Convert.ToByte(packaddress.pack_id), BitConverter.GetBytes(receiveNum));
                        //}
                        receiveNum++;
                        if (receiveNum == totalPackNum + 1)
                        {
                            multiByte.Insert(Provider.HS.defineIndex, FlagType.CS_Multi);
                            multiByte.Insert(Provider.MT.defineIndex, packaddress.dataType);
                            multiByte.Insert(Provider.SD.defineIndex, SendDirection.S_C);
                            multiByte.InsertRange(Provider.CU.defineIndex, BitConverter.GetBytes(packaddress.cust_id));
                            multiByte.Insert(Provider.PC.defineIndex, Convert.ToByte(packaddress.group_id));
                            multiByte.Insert(Provider.PA.defineIndex, Convert.ToByte(packaddress.pack_id));
                            multiByte.InsertRange(Provider.RB1.defineIndex, BitConverter.GetBytes((ushort)0xffff));
                            multiByte.InsertRange(Provider.CL.defineIndex, BitConverter.GetBytes((uint)0xffffffff));
                            ReceiveEvent = new SocketEvent(SocketEventType.ReceEvent, multiByte.ToArray(), multiByte.Count, arr[0], int.Parse(arr[1]));
                            ClearSet();
                        }
                    }
                    else
                    {
                        ClearSet();
                    }
                }
                break;

            case FlagType.BMSPlause:
                if (CheckSum(false, buffer))
                {
                    ReceiveEvent = new SocketEvent(SocketEventType.ReceEvent, buffer, buffer.Length, arr[0], int.Parse(arr[1]));
                }
                break;

            default:
                ReceiveEvent = new SocketEvent(SocketEventType.ReceEvent, buffer, buffer.Length, arr[0], int.Parse(arr[1]));
                break;
            }
        }
Beispiel #2
0
 private void timeoutTimer_Tick(object sender, EventArgs e)
 {
     ReceiveEvent = null;
     ClearSet();
 }