Exemple #1
0
 // The connect/disconnect buton
 private void btnToggleConnection_Click(object sender, EventArgs e)
 {
     if (FSUIPCConnection.IsOpen)
     {
         // Connection is currently open
         // Stop the main timer
         this.timerMain.Stop();
         // Close the connection
         FSUIPCConnection.Close();
     }
     else
     {
         // Try to open the connection
         try
         {
             this.lblConnectionStatus.Text      = "Looking for a flight simulator...";
             this.lblConnectionStatus.ForeColor = Color.Goldenrod;
             FSUIPCConnection.Open();
             // If there was no problem, start the main timer
             this.timerMain.Start();
         }
         catch (Exception ex)
         {
             // An error occured. Tell the user.
             MessageBox.Show("Connection Failed\n\n" + ex.Message, "FSUIPC", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
     }
     configureForm();
 }
Exemple #2
0
 private void MainForm_FormClosing(object sender, FormClosingEventArgs e)
 {
     Logger.Log("Closing application");
     FSUIPCConnection.Close();
     SoundFactory.Dispose();
     notifyIcon.Dispose();
 }
Exemple #3
0
        public bool Close()
        {
            try
            {
                var delAddresses = currentValues.Keys.Where(adr => !persistentValues.Contains(adr)).ToList();
                foreach (var address in delAddresses)
                {
                    currentValues.Remove(address);
                    currentRegistrations.Remove(address);
                }
            }
            catch
            {
                Log.Logger.Error("IPCManager: Exception while removing Registrations!");
            }

            try
            {
                FSUIPCConnection.Close();

                if (!FSUIPCConnection.IsOpen)
                {
                    Log.Logger.Information("IPCManager: FSUIPC Closed");
                }
            }
            catch
            {
                Log.Logger.Error("IPCManager: Exception while closing FSUIPC");
            }

            return(!IsConnected);
        }
        private void button3_Click(object sender, EventArgs e)
        {
            FSUIPCConnection.Close();
            UserControl1.timerOn = false;
            userControl11.Hide();
            button2.Hide();
            button4.Hide();
            button6.Hide();
            button5.Hide();
            button7.Hide();
            button3.Hide();
            signIn1.Visible = false;
            pictureBox1.Show();
            label3.Visible = false;
            Connect.Show();
            label1.Show();
            serverList1.Hide();
            options1.Hide();
            button1.Hide();
            atcComms1.Visible    = false;
            lrmDatabase1.Visible = false;

            label3.Text      = "Not Connected";
            label3.ForeColor = Color.Red;
        }
Exemple #5
0
 private static void OnTimedEvent(Object source, ElapsedEventArgs e)
 {
     if (!isConnectedtoFSUIPC)
     {
         try
         {
             Console.Write(".");
             FSUIPCConnection.Open();
             isConnectedtoFSUIPC = true;
         } catch (Exception ex)
         {
             isConnectedtoFSUIPC = false;
         }
     }
     else
     {
         try
         {
             FSUIPCConnection.Process();
         } catch (Exception ex)
         {
             Errormessage.sendErrorMessage("FSUIPC Process", ex.Message);
             FSUIPCConnection.Close();
             isConnectedtoFSUIPC = false;
         }
     }
 }
Exemple #6
0
        private void btnConnect_Click(object sender, EventArgs e)
        {
            switch (btnConnect.Text)
            {
            case "Connect":

                switch (cboxServer.Text)
                {
                case "Beta":
                    sck.Connect("192.168.56.102", 6809);

                    FSUIPCConnection.Open();

                    LATandLON.Start();

                    txtCallsign.Enabled = false;
                    txtAircraft.Enabled = false;
                    txtChatText.Enabled = true;
                    btnChatSend.Enabled = true;

                    lblStatus.Text      = "Connected";
                    lblStatus.ForeColor = Color.ForestGreen;
                    txtChat.Text        = "You are now connect on network server!";

                    btnConnect.Text  = "Flight Plan";
                    btnClose.Enabled = true;
                    break;

                default:
                    LATandLON.Stop();
                    FSUIPCConnection.Close();
                    sck.Close();
                    sck.Dispose();

                    txtCallsign.Enabled = true;
                    txtAircraft.Enabled = true;
                    txtChatText.Enabled = false;
                    btnChatSend.Enabled = false;
                    btnClose.Enabled    = false;
                    btnConnect.Enabled  = false;

                    lblStatus.Text      = "Server Error";
                    lblStatus.ForeColor = Color.DarkRed;

                    btnConnect.Text = "Connect";
                    txtChat.Text    = txtChat.Text + "\r\nSelect one server!";
                    break;
                }

                break;

            case "Flight Plan":
                f.Show();
                break;

            default:
                break;
            }
        }
Exemple #7
0
        private void RUNTIMERTick(Object myObject, EventArgs myEventArgs)
        {
            try
            {
                FSUIPCConnection.Process();

                double airpeedKnots     = (double)airspeed.Value / 128d;
                double groundspeedKnots = (double)groundspeed.Value / 128d;
                double vspeedFT         = (double)vspeed.Value * 60 * 3.28084 / 256;
                this.airspeedLabel.Text = "airspeed: " + airpeedKnots.ToString("f1");
                this.vspeedLabel.Text   = "vspeed: " + vspeedFT;
                this.onGroundLabel.Text = "onGround: " + ((onground.Value == 1) ? "YES" : "NO");
                this.parkingLabel.Text  = "parkingBrake: " + ((parkingBrake.Value == 32767) ? "ON" : "OFF");

                if (!trackingFinished && !tracking && !trackingAllowed && parkingBrake.Value == 0)
                {
                    sendMessage("Semik requires to apply parking brake before you start flight tracking.", 0);
                }
                if (!trackingFinished && !trackingAllowed && !tracking && parkingBrake.Value == 32767)
                {
                    if (onground.Value == 1)
                    {
                        trackingAllowed = true;
                        sendMessage("Semik is now connected and ready.", 10);
                    }
                    else
                    {
                        sendMessage("Semik also wants you to start the flight on ground.", 10);
                    }
                }
                if (!trackingFinished && !tracking && trackingAllowed && parkingBrake.Value == 0 && Math.Abs(groundspeedKnots) < 4)
                {
                    sendMessage("Semik started the flight tracking...", 10);
                    mainForm.setStatus("Tracking in progress...");
                    tracking = true;
                }
                if (!trackingFinished && tracking && !wasAirborne && onground.Value == 0)
                {
                    wasAirborne = true;
                }
                if (!trackingFinished && tracking && wasAirborne && parkingBrake.Value == 32767 && onground.Value == 1 && Math.Abs(groundspeedKnots) < 4)
                {
                    tracking         = false;
                    trackingFinished = true;
                    sendMessage("Semik finished tracking, thank you!", 5);
                    mainForm.setStatus("Tracking finished.");
                }

                this.trackingLabel.Text = "tracking : " + ((tracking) ? "ON" : "OFF");
                this.finishedLabel.Text = "tracking finished : " + ((trackingFinished) ? "YES" : "NO");
            }
            catch (FSUIPCException ex)
            {
                Logger.Log("Connection to FS was lost - " + ex);
                FSUIPCConnection.Close();
                mainForm.setStatus("Connection lost");
                RUNTIMER.Stop();
            }
        }
Exemple #8
0
 private void FSUIPCReconnectTimer_Tick(object sender, EventArgs e)
 {
     try
     {
         FSUIPCConnection.Close();
         FSUIPCConnection.Open();
     }
     catch
     {
     }
 }
Exemple #9
0
        private void btnConnectar_Click(object sender, EventArgs e)
        {
            try
            {
                // Attempt to open a connection to FSUIPC (running on any version of Flight Sim)
                FSUIPCConnection.Open();
                // Opened OK so disable the Connect button
                this.btnConnectar.Enabled     = false;
                this.chkEnableAIRadar.Enabled = true;
                // Start the timer ticking to drive the rest of the application
                this.timer1.Interval = 200;
                this.timer1.Enabled  = true;
                // Set the AI object
                AI = FSUIPCConnection.AITrafficServices;
            }
            catch (Exception ex)
            {
                // Badness occurred - show the error message
                MessageBox.Show(ex.Message, AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
                FSUIPCConnection.Close();
                Debug.WriteLine(ex.Message);
            }

            if (simconnect == null)
            {
                try
                {
                    // the constructor is similar to SimConnect_Open in the native API
                    // the ConfigIndex enables you to choose which Simconnect profile to use (in a SimConnect.cfg) if you are
                    // connecting over a network. Leaving it to zero for a local connection here.
                    simconnect = new SimConnect("C# Monitoring AI Objects", this.Handle, WM_USER_SIMCONNECT, null, 0);

                    // setButtons(false, true, true);

                    initDataRequest();
                }
                catch
                {
                    MessageBox.Show("Make sure Microsoft ESP is running and that you have the SimConnect client installed.", "Unable to connect to ESP");
                }
            }

            // Store the current object type being monitored
            monitoredObjectType = SIMCONNECT_SIMOBJECT_TYPE.AIRCRAFT;

            // Refresh the list of monitored objects for this specific request
            // first, Clear any current objects and stop all data requests for those objects
            ResetDataAndShutDownRequests();

            // Now, Initiate a request for the list of objects we are interested in monitoring in the given radius
            simconnect.RequestDataOnSimObjectType(DATA_REQUESTS.REQUEST_AI_OBJECT_ID_BYTYPE,
                                                  DEFINITIONS.AI_Entity_Definition, MONITOR_RADIUS, monitoredObjectType);
        }
Exemple #10
0
 // Window closing so stop all the timers and close the connection
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     this.timerDiscord.Stop();
     this.timerConnection.Stop();
     this.timerMain.Stop();
     if (this.client != null)
     {
         this.client.Dispose();
     }
     FSUIPCConnection.Close();
     Properties.Settings.Default.Save();
 }
Exemple #11
0
 public bool DwcOpen()
 {
     try
     {
         FSUIPCConnection.Close();
         FSUIPCConnection.Open();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #12
0
 /// <summary>
 /// Tries to connect to FSX
 /// </summary>
 /// <returns></returns>
 private bool ConnectToFSX()
 {
     try
     {
         // Attempt to open a connection to FSUIPC (running on any version of Flight Sim)
         FSUIPCConnection.Open();
         return(true);
     }
     catch (Exception)
     {
         FSUIPCConnection.Close();
         return(false);
     }
 }
Exemple #13
0
 public static void sendMessage(string mes, int timeout)
 {
     message.Value        = mes;
     messageControl.Value = timeout;
     try
     {
         FSUIPCConnection.Process();
     }
     catch (Exception) {
         //Logger.Log("Connection to FS was lost");
         FSUIPCConnection.Close();
         mainForm.setStatus("Connection lost");
     }
 }
Exemple #14
0
 private Boolean openFSUIPC()
 {
     try
     {
         // Attempt to open a connection to FSUIPC (running on any version of Flight Sim)
         //FSUIPCConnection.Open();
         return(false);
     }
     catch (Exception)
     {
         // Badness occurred - show the error message
         FSUIPCConnection.Close();
         return(true);
     }
 }
Exemple #15
0
 private void openFSUIPC()
 {
     try
     {
         FSUIPCConnection.Open();
         bridgeTimer.Interval = 200;
         bridgeTimer.Enabled  = true;
     }
     catch (Exception ex)
     {
         // Badness occurred - show the error message
         MessageBox.Show(ex.Message, "Bridge Test", MessageBoxButtons.OK, MessageBoxIcon.Error);
         FSUIPCConnection.Close();
     }
 }
Exemple #16
0
 private static void CheckConnected(Object myObject, EventArgs myEventArgs)
 {
     try
     {
         FSUIPCConnection.Process();
     }
     catch (Exception)
     {
         //Logger.Log("Connection to FS was lost");
         FSUIPCConnection.Close();
         mainForm.setStatus("Connection lost");
         FLIGHTTIMER.Stop();
         TIMER.Stop();
         connected = false;
         Connect();
     }
 }
Exemple #17
0
        public static void Reconnect()
        {
            try
            {
                FSUIPCConnection.Close();
                FSUIPCConnection.Open();

                /*FSUIPCConnection.Open();
                 * connected = true;
                 * Logger.Log("Connected to FS");
                 * Logger.Log("DLL version:" + FSUIPCConnection.DLLVersion.ToString());
                 * mainForm.setStatus("Connected to FS");
                 * mainForm.setProgress(false);
                 * sendMessage(AppTitle + " is now connected!", 10);*/
            }
            catch (Exception ex)
            {
                string e = ex.ToString();
            }
        }
Exemple #18
0
        public Boolean Close()
        {
            try
            {
                if (FSUIPCConnection.IsOpen)
                {
                    FSUIPCConnection.Close();
                }

                status = "Connection is closed";
                isopen = FSUIPCConnection.IsOpen;
            }
            catch (Exception e)
            {
                isopen = false;
                status = e.Message;
            }

            return(!isopen);
        }
Exemple #19
0
 private static void updateData(Object myObject, EventArgs myEventArgs)
 {
     mainForm.fsData.update();
     try
     {
         if (connected) // paranoia
         {
             FSUIPCConnection.Process();
         }
     }
     catch (Exception)
     {
         //Logger.Log("Connection to FS was lost");
         FSUIPCConnection.Close();
         mainForm.setStatus("Connection lost");
         FLIGHTTIMER.Stop();
         TIMER.Stop();
         connected = false;
         Connect();
     }
 }
Exemple #20
0
        public static void FSUIPC_Connect()
        {
            try
            {
                FSUIPCConnection.Open();

                FsuiipcOpen = true;
            }
            catch (Exception crap)
            {
                Console.WriteLine("{0} Exception caught.", crap);

                if (FSUIPCConnection.FlightSimVersionConnected.ToString() == "Any")
                {
                    FsuiipcOpen = false;

                    FSUIPCConnection.Close();
                    FSUIPC_Connect();
                }
            }
        }
Exemple #21
0
        /// <summary>
        /// Disconnects us from FSX and ORTC
        /// </summary>
        private void Disconnect()
        {
            Log("Disconnecting");

            // Stops the timer
            requestTimer.Stop();
            requestTimer.Enabled = false;

            FSUIPCConnection.Close();    // Disconnects from FSX
            ortcClient.Disconnect();     // Disconnects from ORTC

            gbxRealtime.Enabled  = true; // enables UI again
            gbxBroadcast.Enabled = true; // enables UI again

            btnDisconnect.Text    = "Disconnected";
            btnDisconnect.Enabled = false;
            btnConnect.Text       = "Connect";
            btnConnect.Enabled    = true;

            Log("Disconnected");
        }
Exemple #22
0
 public bool Disconnect()
 {
     if (!ValueBag.Connected)
     {
         return(false);
     }
     try
     {
         FSUIPCConnection.Close();
         updateThread.Abort();
         updateThread = null;
         ValueBag.Clear();
         ValueBag.Connected = false;
         FsxiDisconnected?.Invoke(this, EventArgs.Empty);
         FsxiValueBagUpdated?.Invoke(this, EventArgs.Empty);
         return(true);
     }
     catch (FSUIPCException)
     {
         return(false);
     }
 }
Exemple #23
0
 public bool DwcClose()
 {
     this.FSUIPCProcessTimer.Stop();
     this.WindDirWriteTimer.Stop();
     this.WindSpdWriteTimer.Stop();
     this.WindReadMagTimer.Stop();
     this.GustsSpdTimer.Stop();
     this.GustsDirTimer.Stop();
     this.TurbWriteTimer.Stop();
     this.TurbWriteOnOffTimer.Stop();
     this.VarianceTimer.Stop();
     this.DebugTimer.Stop();
     try
     {
         FSUIPCConnection.Close();
         return(true);
     }
     catch
     {
         return(false);
     }
 }
Exemple #24
0
 // Send Data to FSUIPC and get actual offsets
 public void FSUIPCProcess(string s = "")
 {
     try
     {
         FSUIPCConnection.Process(s);
     }
     catch (FSUIPCException ex)
     {
         if (ex.FSUIPCErrorCode == FSUIPCError.FSUIPC_ERR_SENDMSG)
         {
             FSUIPCConnection.Close();
             isConnectedtoFSUIPC = false;
         }
         else
         {
             throw ex;
         }
     }
     catch (Exception)
     {
     }
 }
Exemple #25
0
        private void btnClose_Click(object sender, EventArgs e)
        {
            // terminate = true;
            // while (terminated == false) { }
            LATandLON.Stop();
            FSUIPCConnection.Close();
            sck.Close();
            sck.Dispose();

            txtCallsign.Enabled = true;
            txtAircraft.Enabled = true;
            txtChatText.Enabled = false;
            btnChatSend.Enabled = false;
            btnClose.Enabled    = false;
            btnConnect.Enabled  = false;

            lblStatus.Text      = "Disconnected";
            lblStatus.ForeColor = Color.DarkRed;

            btnConnect.Text = "Connect";
            txtChat.Text    = txtChat.Text + "\r\nYou are now disconnected on network server!";
        }
Exemple #26
0
        private bool InitFS()
        {
            bool success = true;

            fsInitMessage = "connected";

            try
            {
                // Attempt to open a connection to FSUIPC (running on any version of Flight Sim)
                FSUIPCConnection.Open();
            }
            catch (Exception ex)
            {
                // Badness occurred - show the error message
                FSUIPCConnection.Close();
                Debug.Print(ex.Message);
                fsInitMessage = ex.Message;
                success       = false;
            }

            return(success);
        }
Exemple #27
0
 private void btnFS_Click(object sender, RoutedEventArgs e)
 {
     if (FSUIPCConnection.IsOpen)
     {
         HandleDroneActions(false);
         FSUIPCConnection.Close();
     }
     else
     {
         lblStatus.Content = "Looking for a flight simulator...";
         try
         {
             FSUIPCConnection.Open();
             HandleDroneActions(true);
         }
         catch (FSUIPCException ex)
         {
             System.Windows.MessageBox.Show(ex.Message, "Connection Failed. ");
         }
     }
     setConnectionStatus();
 }
Exemple #28
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     // Process the default group
     try
     {
         FSUIPCConnection.Process();
     }
     catch (FSUIPCException ex)
     {
         if (ex.FSUIPCErrorCode == FSUIPCError.FSUIPC_ERR_SENDMSG)
         {
             // Send message error - connection to FSUIPC lost.
             // Show message, disable the main timer loop and relight the
             // connection button:
             // Also Close the broken connection.
             this.timer1.Enabled           = false;
             this.btnConnectar.Enabled     = true;
             this.chkEnableAIRadar.Enabled = false;
             this.chkEnableAIRadar.Checked = false;
             this.AIRadarTimer.Enabled     = false;
             FSUIPCConnection.Close();
             MessageBox.Show("The connection to Flight Sim has been lost.", AppTitle, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         }
         else
         {
             // not the disonnect error so some other baddness occured.
             // just rethrow to halt the application
             throw ex;
         }
     }
     catch (Exception)
     {
         // Sometime when the connection is lost, bad data gets returned
         // and causes problems with some of the other lines.
         // This catch block just makes sure the user doesn't see any
         // other Exceptions apart from FSUIPCExceptions.
     }
 }
Exemple #29
0
 void btnToggleConnection_Click(object sender, RoutedEventArgs e)
 {
     if (FSUIPCConnection.IsOpen)
     {
         this.timerMain.Stop();
         FSUIPCConnection.Close();
     }
     else
     {
         try
         {
             this.lblConnectionStatus.Text       = "Looking for Simulator";
             this.lblConnectionStatus.Foreground = Brushes.Goldenrod;
             FSUIPCConnection.Open();
             this.timerMain.Start();
         }
         catch (Exception ex)
         {
             MessageBox.Show("Connection Failed\n\n" + ex.Message, "FSUIPC", MessageBoxButton.OK, MessageBoxImage.Exclamation);
         }
     }
     configureForm();
 }
Exemple #30
0
 private void Form1_FormClosed(object sender, FormClosedEventArgs e)
 {
     FSUIPCConnection.Close();
     _fsuipcConnected = false;
     for (var i = 0; i < NumPorts; i++)
     {
         if (_sp[i] != null && _sp[i].IsOpen)
         {
             _sp[i].Close();
         }
     }
     foreach (var port in _availablePorts)
     {
         if (port.Value != null && port.Value.IsOpen)
         {
             try
             {
                 port.Value.Close();
             }
             catch (Exception) { }
         }
     }
 }