Beispiel #1
0
        private void bt_closeall_Click(object sender, EventArgs e)
        {

            try
            {
                UDPComm.oktoReceive = false;

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


                if (TCPClientConn != null)
                    TCPClientConn = null;

                if (TCPClientData != null)
                    TCPClientData = null;


                if (TCPMavLinkClient != null)
                    TCPMavLinkClient = null;

                            

                if (TrimaresUDPServerConn != null)
                    TrimaresUDPServerConn = null;

                if (TrimaresUDPServerData != null)
                    TrimaresUDPServerData = null;

                if (TrimaresUDPMavLinkServer != null)
                    TrimaresUDPMavLinkServer = null;
            }
            catch { }


            
            //Application.ExitThread();
            //Application.Exit(); 
        }
Beispiel #2
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 #3
0
        void startAPMsimulation()
        {
            try
            {
                TrimaresUDPServerData = new MainCrossData();
                TrimaresUDPServerConn = new MavLinkConnection(tx_APcomport.Text, ref TrimaresUDPServerData);
                // TrimaresUDPServerConn.mydata.setMavlinkPointer(ref TrimaresUDPMavLinkServer);
                TrimaresUDPServerConn.connect();
                TrimaresUDPServerConn.PacketReceived += TrimaresUDP_PacketReceived;
               // TrimaresUDPServerConn.mydata.myLink.BaseStream.rMessage += showMessages;
                TrimaresUDPServerConn.mydata.myLink.requestDatastream(MAVLink.MAV_DATA_STREAM.ALL, MainCrossData.cs.rateattitude);
            }
            catch
            {
                TrimaresUDPMavLinkServer = null;
                TrimaresUDPServerData = null;
                TrimaresUDPServerConn = null;

            }

            //TCPClientData = new MainCrossData();
            //TCPClientConn = new MavLinkConnection(tx_APcomport.Text, ref TCPClientData);
            //TCPClientConn.mydata.setMavlinkPointer(ref TCPMavLinkClient);
            ////TCPClientConn.mydata.myLink.BaseStream.Open();

            //TCPClientConn.connect();

            //TCPClientConn.mydata.myLink.BaseStream.rMessage += showMessages;
            //TCPClientConn.PacketReceived += APSerialConn_PacketReceived; 
            //TCPClientData.myLink.requestDatastream(MAVLink.MAV_DATA_STREAM.ALL, MainCrossData.cs.rateattitude);



            gb_robot.Enabled = false;
        }
Beispiel #4
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;

            }
        }
Beispiel #5
0
        private void bt_client_Click(object sender, EventArgs e)
        {
            try
            {
                TCPClientData = new MainCrossData();
                TCPClientConn = new MavLinkConnection("TCP", ref TCPClientData);
                TCPClientConn.mydata.setMavlinkPointer(ref TCPMavLinkClient);
                TCPClientConn.mydata.myLink.BaseStream.HostIP = tx_clientIP.Text;
                TCPClientConn.mydata.myLink.BaseStream.Port = tx_clientPort.Text;
                TCPClientConn.PacketReceived += APSerialConn_PacketReceived;
                TCPClientConn.mydata.myLink.BaseStream.Open();
                TCPClientConn.mydata.myLink.BaseStream.rMessage += showMessages;

                //MavLinkClient = new MAVLink();
                //MavLinkClient.DefaultConnection("TCP", 115200);
                //MavLinkClient.BaseStream.HostIP = tx_clientIP.Text;
                //MavLinkClient.BaseStream.Port = tx_clientPort.Text;
                //MavLinkClient.BaseStream.newMsg += Client_PacketReceived;
                //MavLinkClient.BaseStream.Open();

                gb_robot.Enabled = false;
            }
            catch { }


        }