Beispiel #1
0
        private void Form1_FormClosing(object sender, FormClosingEventArgs e)
        {

            try
            {

                if (tstartMissonPlannerConn != null)
                {
                    tstartMissonPlannerConn.Abort();
                    Thread.Sleep(100);
                    tstartMissonPlannerConn = null;
                }

                closeThread(tstartMissonPlannerConn);
                closeThread(tstartmyServerConn);
                closeThread(tstartTrimaresConn);
                closeThread(tstartExoReadings);
                closeThread(Treadings);

                UDPComm.oktoReceive = false;

                if (MissionPlannerServer != null) 
                {
                    MissionPlannerServer.Close();
                    MissionPlannerServer = null;
                }

                if (TrimaresServer != null)
                {
                    TrimaresServer.Close();
                    TrimaresServer = null;
                }

                



                if (TCPClientConn != null)
                {
                    CloseStream(TCPClientConn.mydata.myLink.BaseStream);
                    TCPClientConn = null;
                }

                if (TCPMavLinkClient != null)
                {
                    TCPMavLinkClient = null;
                }

                if (TCPClientData != null)
                {
                    TCPClientData = null;
                }



                if (TrimaresUDPServerConn != null)
                {
                    CloseStream(TrimaresUDPServerConn.mydata.myLink.BaseStream);
                    TrimaresUDPServerConn = null;
                }

                if (TrimaresUDPServerData != null)
                    TrimaresUDPServerData = null;

                if (TrimaresUDPMavLinkServer != null)
                    TrimaresUDPMavLinkServer = null;

                foreach (Process p in System.Diagnostics.Process.GetProcessesByName("AP_Mavlink_router.exe"))
                {
                    p.Kill();
                    p.WaitForExit();
                }
            }
            catch 
            {
                Application.ExitThread();
                Application.Exit();
            }

            Application.ExitThread();
            Application.Exit();
         

        }
Beispiel #2
0
        /// <summary>
        /// inicializa comunicacao do router com o trimares
        /// </summary>
        private void startTrimaresConn()
        {
            try
            {
                TrimaresServer = new MAVcomm.Comms.UdpSerialServer();
                TrimaresServer.HostIP = tx_udpIP.Text;
                TrimaresServer.Port = tx_udpport.Text;
                TrimaresServer.newMsg += TrimaresUDP_PacketReceived;
                TrimaresServer.Open();
                TrimaresServer.rMessage += showMessages;
                //TrimaresUDPServerData = new MainCrossData();
                //TrimaresUDPServerConn = new MavLinkConnection("UDPSERVER", ref TrimaresUDPServerData);
                //TrimaresUDPServerConn.mydata.setMavlinkPointer(ref TrimaresUDPMavLinkServer);
                //TrimaresUDPServerConn.mydata.myLink.BaseStream.HostIP = tx_udpIP.Text;
                //TrimaresUDPServerConn.mydata.myLink.BaseStream.Port = tx_udpport.Text;
                //TrimaresUDPServerConn.PacketReceived += TrimaresUDP_PacketReceived;
                //TrimaresUDPServerConn.mydata.myLink.BaseStream.Open();
                //TrimaresUDPServerConn.mydata.myLink.BaseStream.rMessage += showMessages;
            }
            catch 
            {
                TrimaresServer.Close();
                TrimaresServer = null;

                TrimaresUDPMavLinkServer = null;
                TrimaresUDPServerData = null;
                TrimaresUDPServerConn = null;

            }
        }