예제 #1
0
        protected override void Run()
        {
            try
            {
                if (isCanSendNext)
                {
                    if (SendPacketQueue.Instance.IsHasData())
                    {
                        SendBasePacket sp = SendPacketQueue.Instance.Dequeue();// SendPacketQueue.Instance.Peek();//
                        AgvServerManager.Instance.Send(sp);
                        //isCanSendNext = false;

                        //RunPacket sp = (RunPacket)SendPacketQueue.Instance.Dequeue();
                        //AgvServerManager.Instance.Send(sp);
                        //uint x = sp.Locations.MidPoint.X/1000;
                        //uint y = sp.Locations.MidPoint.Y/1000;
                        //uint endX = sp.Locations.DesPoint.X/1000;
                        //uint endY = sp.Locations.DesPoint.Y/1000;
                        Console.WriteLine("send success,序列号:" + sp.SerialNum);
                    }
                }
            }
            catch (Exception e)
            {
                Logs.Error("sendpacketThread" + e);
            }
        }
 public void Send(SendBasePacket pack)
 {
     try
     {
         pack.Send(_server);
     }
     catch { }
 }
예제 #3
0
 public void BroadCast(SendBasePacket packet)
 {
     for (int i = 0; i < _clientList.Count; i++)
     {
         try { _clientList[i].SendPacket(packet); settings.SendedPackets++; }
         catch { }
     }
 }
        private void SendPack(int vnum, SendBasePacket sendPacket)
        {
            CheckAlarmState(vnum);
            AgvServerManager.Instance.SendTo(sendPacket, vnum);

            vehicles[vnum].LastSendPacket = sendPacket;
            vehicles[vnum].IsAgvReceived  = false;
            vehicles[vnum].WaitEndTime    = DateTime.Now.AddMilliseconds(WAIT_TIME);

            PrintInfomation(vnum, sendPacket);
        }
 //public void Send(SendBasePacket pack)
 //{
 //    try
 //    {
 //        pack.Send(_server);
 //    }
 //    catch { }
 //}
 public void SendTo(SendBasePacket pack, int vnum)
 {
     try
     {
         //if (vnum == 5)
         //{
         //    vnum = 25;
         //}
         pack.SendTo(_server, vnum);
     }
     catch { }
 }
 //public void Send(SendBasePacket pack)
 //{
 //    try
 //    {
 //        pack.Send(_server);
 //    }
 //    catch { }
 //}
 public void SendTo(SendBasePacket pack, int vnum)
 {
     try
     {
         if (vnum == 5)
         {
             vnum = 13;
         }
         pack.SendTo(_server, vnum);
     }
     catch { }
 }
        void PrintInfomation(int vnum, SendBasePacket sendPacket)
        {
            Console.WriteLine();
            Logs.Info("------------------------------------------------------");
            String log = String.Format("<-给小车{0}发送{1}报文", vnum, (PacketType)sendPacket.Type);

            uint x    = Convert.ToUInt32(vehicles[vnum].BeginX);
            uint y    = Convert.ToUInt32(vehicles[vnum].BeginY);
            uint endX = Convert.ToUInt32(vehicles[vnum].EndX);
            uint endY = Convert.ToUInt32(vehicles[vnum].EndY);

            Logs.Info(String.Format(log + "(" + x + "," + y + ")终点:(" + endX + "," + endY + "),实际位置:(" + vehicles[vnum].agvInfo.CurLocation.CurNode.X / 1000.0 + "," + vehicles[vnum].agvInfo.CurLocation.CurNode.Y / 1000.0 + ") 序列号:" + vehicles[vnum].Serinum));
        }
예제 #8
0
        public void SendPacket(SendBasePacket packet)
        {
            lock (this)
            {
                packet.Write();
                byte[] pck = packet.ToByteArray();

                byte PacketId = pck[0];
                pck = CryptEngine.Crypt(pck, NetworkKey);

                List <Byte> FullPacket = new List <Byte>();
                FullPacket.AddRange(BitConverter.GetBytes((short)(pck.Length + 2))); //+2 Packet Length
                FullPacket.AddRange(pck);
                try { _socket.Send(FullPacket.ToArray()); } catch { }
                settings.SendedPackets++;
            }
        }
예제 #9
0
 public bool SendPacket(SendBasePacket packet)
 {
     lock (this)
     {
         try
         {
             packet.Write();
             byte[]      pck        = CryptEngine.Crypt(packet.ToByteArray());
             List <Byte> FullPacket = new List <Byte>();
             FullPacket.AddRange(BitConverter.GetBytes((short)(pck.Length + 2))); //+2 Packet Length
             FullPacket.AddRange(pck);                                            //Packet
             _client.Send(FullPacket.ToArray());
         }
         catch
         {
             return(false);
         }
         return(true);
     }
 }
예제 #10
0
        public void SendPacket(SendBasePacket packet)
        {
            lock (this)
            {
                packet.Write();
                byte[] pck = CryptEngine.Crypt(packet.ToByteArray());

                if (packet.Length > 60000)
                {
                    return;
                }

                List <Byte> FullPacket = new List <Byte>();
                FullPacket.AddRange(BitConverter.GetBytes((short)(pck.Length + 2))); //+2 Packet Length
                FullPacket.AddRange(pck);                                            //Packet
                try
                {
                    _client.Send(FullPacket.ToArray());
                } catch {}
            }
        }
예제 #11
0
 protected override void Run()
 {
     try
     {
         if (isCanSendNext)
         {
             if (SendPacketQueue.Instance.IsHasData())
             {
                 SendBasePacket sp = SendPacketQueue.Instance.Peek();
                 // ReSendPacketQueue.Instance.Enqueue(sp);
                 AgvServerManager.Instance.Send(sp);
                 isCanSendNext = false;
                 Console.WriteLine("iscanSendNext=false");
             }
         }
     }
     catch (Exception e)
     {
         Logs.Error("sendpacketThread" + e);
     }
 }