Пример #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();
         

        }
Пример #2
0
        /// <summary>
        /// Inicializa comunicaçao do router com o ExoMonitor
        /// </summary>
        private void startExoMonitorConn()
        {
            int port;
            try
            {
                try
                {
                    port = int.Parse(tx_ExoPort.Text);
                }
                catch 
                {
                    MessageBox.Show("Erro na definição de porta");
                    return;
                }
                ExoMonitorServer = new TCPCommServer(port);
                ExoMonitorServer.Open();
                ExoMonitorServer.rMessage += showMessages;
                ExoMonitorServer.newMsg += TCPServer_packetReceived;
                ExoMonitorServer.StartSendingHB();


            }
            catch
            {
                ExoMonitorServer.Close();
                ExoMonitorServer = null;
            }
        }
Пример #3
0
        /// <summary>
        /// Inicializa comunicaçao do router com o mission planner
        /// </summary>
        private void startMissionPlannerConn() 
        {
            try
            {

                MissionPlannerServer = new TCPCommServer();
                MissionPlannerServer.Open();
                MissionPlannerServer.rMessage += showMessages;
                MissionPlannerServer.newMsg += TCPServer_packetReceived;
                MissionPlannerServer.StartSendingHB();

               
            }
            catch
            {
                MissionPlannerServer.Close();
                MissionPlannerServer = null;
            }
        }
Пример #4
0
        public void DefaultConnection(string portName, int baudRate)
        {

            switch (portName)
            {
                case "TCPSERVER":
                    BaseStream = new TCPCommServer();
                    break;
                case "TCP":
                    BaseStream = new TcpSerial();
                    break;
                case "UDP":
                    BaseStream = new UdpSerial();
                    break;
                default:
                    //BaseStream = new Comms.SerialPort();
                    BaseStream = new SerialPort();
                    break;
            }
            

            this.BaseStream.DataBits = 8;
            this.BaseStream.StopBits = (System.IO.Ports.StopBits)Enum.Parse(typeof(System.IO.Ports.StopBits), "1");
            this.BaseStream.Parity = (System.IO.Ports.Parity)Enum.Parse(typeof(System.IO.Ports.Parity), "None");
            try
            {
                this.BaseStream.BaudRate = 115200;
                this.BaseStream.PortName = portName;
            }
            catch (Exception exp) { }

            // false here
            this.BaseStream.DtrEnable = false;
            this.BaseStream.RtsEnable = false;
        }