Exemple #1
0
        public void closeDebuggerSession(bool changeWorkspace)
        {
            if (AcceptedEmulator != null)
            {
                AcceptedEmulator.Send("EXIT\n");
                AcceptedEmulator.Disconnect();

                //AcceptedEmulator.OnReceive -= new ASyncSocket.OnReceiveEventHandler(server_OnReceive);
                //AcceptedEmulator.OnSend -= new ASyncSocket.OnSendEventHandler(server_OnSend);
                //AcceptedEmulator.OnDisconnect -= new ASyncSocket.OnDisconnectEventHandler(server_OnDisconnect);
                //AcceptedEmulator.OnReceiveFailed -= new ASyncSocket.OnReceiveFailedEventHandler(server_OnReceiveFailed);
                //AcceptedEmulator.OnSendFailed -= new ASyncSocket.OnSendFailedEventHandler(server_OnSendFailed);
            }

            if (server != null)
            {
                server.OnAccept        -= new ASyncSocket.OnAcceptEventHandler(server_OnAccept);
                server.OnReceive       -= new ASyncSocket.OnReceiveEventHandler(server_OnReceive);
                server.OnSend          -= new ASyncSocket.OnSendEventHandler(server_OnSend);
                server.OnListen        -= new ASyncSocket.OnListenEventHandler(server_OnListen);
                server.OnAcceptFailed  -= new ASyncSocket.OnAcceptFailedEventHandler(server_OnAcceptFailed);
                server.OnListenFailed  -= new ASyncSocket.OnListenFailedEventHandler(server_OnListenFailed);
                server.OnReceiveFailed -= new ASyncSocket.OnReceiveFailedEventHandler(server_OnReceiveFailed);
                server.OnSendFailed    -= new ASyncSocket.OnSendFailedEventHandler(server_OnSendFailed);
                server.StopListenSocket();
            }

            server = null;

            if (changeWorkspace == true)
            {
                this.closeAllTempFilesFromEditor();
                this.mainForm.cgEeditor1.setCurrentMode("EDITOR");
                this.mainForm.setWorkSpace("GLOBAL");
            }

            if (this.mainForm != null)
            {
                this.mainForm.cgEeditor1.SetDebuggerAtLine(-1);
                setHandLostWithSimulator(true);
                this.mainForm.workspaceViewToolStripMenuItem.Enabled = true;
            }
        }
Exemple #2
0
 private void OnReceiveCallBack(IAsyncResult IAsyncResult)
 {
     if ((!(bool)IsConnected) || (Socket == null) || (IAsyncResult == null) || (!StateIs(SocketStates.IsReceving)))
     {
         return;
     }
     try
     {
         int Bytes = Socket.EndReceive(IAsyncResult);
         States.Remove(SocketStates.IsReceving);
         if (Bytes > 0)
         {
             string Stream = Encoding.Default.GetString(Buffer);
             Array.Clear(Buffer, 0, Buffer.Length - 1);
             if (OnReceive != null)
             {
                 OnReceive(Stream, this);
             }
         }
         else
         {
             Socket sSocket = (Socket)IAsyncResult.AsyncState;
             if (sSocket != null)
             {
                 ASyncSocket AsyncSocket = new ASyncSocket(sSocket, true);
                 AsyncSocket.Disconnect();
             }
         }
         ListenData();
     }
     catch (Exception Exception)
     {
         States.Remove(SocketStates.IsReceving);
         if (OnReceiveFailed != null)
         {
             OnReceiveFailed(Exception);
         }
     }
 }
Exemple #3
0
    private void OnReceiveCallBack(IAsyncResult IAsyncResult)
    {
        if ((!(bool)IsConnected) || (Socket == null) || (IAsyncResult == null) || (!StateIs(SocketStates.IsReceving))) return;
        try
        {
            int Bytes = Socket.EndReceive(IAsyncResult);
            States.Remove(SocketStates.IsReceving);
            if (Bytes > 0)
            {

                string Stream = Encoding.Default.GetString(Buffer);
                Array.Clear(Buffer, 0, Buffer.Length - 1);
                if (OnReceive != null)
                {
                    OnReceive(Stream, this);
                }
            }
            else
            {

                Socket sSocket = (Socket)IAsyncResult.AsyncState;
                if (sSocket != null)
                {
                    ASyncSocket AsyncSocket = new ASyncSocket(sSocket, true);
                    AsyncSocket.Disconnect();

                }

            }
            ListenData();
        }
        catch (Exception Exception)
        {
            States.Remove(SocketStates.IsReceving);
            if (OnReceiveFailed != null)
            {
                OnReceiveFailed(Exception);
            }
        }
    }
Exemple #4
0
        private void analyseReceivedMessage(string stream, ASyncSocket AcceptedSocket)
        {
            if (this.CurrentCommandReceive.StartsWith("EXIT"))
            {
                this.AcceptedClients.Remove(AcceptedSocket);
                AcceptedSocket.OnReceive -= new ASyncSocket.OnReceiveEventHandler(server_OnReceive);
                AcceptedSocket.OnSend -= new ASyncSocket.OnSendEventHandler(server_OnSend);

                AcceptedSocket.OnDisconnect -= new ASyncSocket.OnDisconnectEventHandler(server_OnDisconnect);

                AcceptedSocket.OnReceiveFailed -= new ASyncSocket.OnReceiveFailedEventHandler(server_OnReceiveFailed);
                AcceptedSocket.OnSendFailed -= new ASyncSocket.OnSendFailedEventHandler(server_OnSendFailed);
                AcceptedSocket.Disconnect();
                AcceptedSocket = null;

                return;
            }

            this.currentBuffer += stream;

            //SPlit the message
            string[] messages = currentBuffer.Split('|');
            for (int i = 0; i < messages.Length; i++)
            {
                string message = messages[i].Replace("\0", "");

                if (message.StartsWith("[EXIT]"))
                {
                    this.AcceptedClients.Remove(AcceptedSocket);
                    AcceptedSocket.OnReceive -= new ASyncSocket.OnReceiveEventHandler(server_OnReceive);
                    AcceptedSocket.OnSend -= new ASyncSocket.OnSendEventHandler(server_OnSend);

                    AcceptedSocket.OnDisconnect -= new ASyncSocket.OnDisconnectEventHandler(server_OnDisconnect);

                    AcceptedSocket.OnReceiveFailed -= new ASyncSocket.OnReceiveFailedEventHandler(server_OnReceiveFailed);
                    AcceptedSocket.OnSendFailed -= new ASyncSocket.OnSendFailedEventHandler(server_OnSendFailed);
                    AcceptedSocket.Disconnect();
                    AcceptedSocket = null;

                    deserializer = null;
                    return;
                }

                else if(message.StartsWith("[DEVICE]") && message.EndsWith("[END]"))
                {
                    AcceptedSocket.isSimulator = false;

                    int indexMessage = this.currentBuffer.IndexOf(message);
                    if (indexMessage > -1)
                    {
                        this.currentBuffer = this.currentBuffer.Remove(indexMessage, message.Length);
                    }

                    this.currentBuffer.Replace("||", "|");
                    message = message.Replace("[DEVICE]", "").Replace("[END]", "");

                }
                else if (message.StartsWith("[SIMULATOR]") && message.EndsWith("[END]"))
                {
                    AcceptedSocket.isSimulator = true;
                    int indexMessage = this.currentBuffer.IndexOf(message);
                    if (indexMessage > -1)
                    {
                        this.currentBuffer = this.currentBuffer.Remove(indexMessage, message.Length);
                    }

                    this.currentBuffer.Replace("||", "|");
                    message = message.Replace("[SIMULATOR]", "").Replace("[END]", "");

                }
                else
                {
                    continue;
                }

                this.sendEvent(message);
                if (!message.Equals(""))
                {
                    try
                    {
                        Dictionary<string, object> dico = deserializer.Deserialize<Dictionary<string, object>>(message);

                        object eventNameOBJ = null;
                        if (dico.TryGetValue("name", out eventNameOBJ) == true)
                        {
                            string eventNameSTR = eventNameOBJ.ToString();
                            //------------------------------------------------------------------------------------------------------------------------
                            //---------------------------------------------ACCELEROMETER -------------------------------------------------------------
                            //------------------------------------------------------------------------------------------------------------------------
                            if (eventNameSTR.Equals("accelerometer"))
                            {
                                object xGravityOBJ = null;
                                if(dico.TryGetValue("xGravity", out xGravityOBJ) ==true)
                                {
                                    double value = Convert.ToDouble(xGravityOBJ);
                                    int intValue = Convert.ToInt32(value * (float)1000);
                                    if (intValue > this.acceleromterXTrackBar.Maximum) intValue = this.acceleromterXTrackBar.Maximum;
                                    if (intValue < this.acceleromterXTrackBar.Minimum) intValue = this.acceleromterXTrackBar.Minimum;
                                    this.acceleromterXTrackBar.Value = intValue;

                                }

                                object yGravityOBJ = null;
                                if (dico.TryGetValue("yGravity", out yGravityOBJ) == true)
                                {
                                    double value = Convert.ToDouble(yGravityOBJ);
                                    int intValue = Convert.ToInt32(value * (float)1000);
                                    if (intValue > this.acceleromterYTrackBar.Maximum) intValue = this.acceleromterYTrackBar.Maximum;
                                    if (intValue < this.acceleromterYTrackBar.Minimum) intValue = this.acceleromterYTrackBar.Minimum;
                                    this.acceleromterYTrackBar.Value = intValue;

                                }

                                object zGravityOBJ = null;
                                if (dico.TryGetValue("zGravity", out zGravityOBJ) == true)
                                {
                                    double value = Convert.ToDouble(zGravityOBJ);
                                    int intValue = Convert.ToInt32(value * (float)1000);
                                    if (intValue > this.acceleromterZTrackBar.Maximum) intValue = this.acceleromterZTrackBar.Maximum;
                                    if (intValue < this.acceleromterZTrackBar.Minimum) intValue = this.acceleromterZTrackBar.Minimum;
                                    this.acceleromterZTrackBar.Value = intValue;

                                }

                                object xInstantOBJ = null;
                                if (dico.TryGetValue("xInstant", out xInstantOBJ) == true)
                                {
                                    double value = Convert.ToDouble(xInstantOBJ);
                                    int intValue = Convert.ToInt32(value * (float)1000);
                                    if (intValue > this.accelerometerXInstantTrackBar.Maximum) intValue = this.accelerometerXInstantTrackBar.Maximum;
                                    if (intValue < this.accelerometerXInstantTrackBar.Minimum) intValue = this.accelerometerXInstantTrackBar.Minimum;
                                    this.accelerometerXInstantTrackBar.Value = intValue;

                                }

                                object yInstantOBJ = null;
                                if (dico.TryGetValue("yInstant", out yInstantOBJ) == true)
                                {
                                    double value = Convert.ToDouble(yInstantOBJ);
                                    int intValue = Convert.ToInt32(value * (float)1000);
                                    if (intValue > this.accelerometerYInstantTrackBar.Maximum) intValue = this.accelerometerYInstantTrackBar.Maximum;
                                    if (intValue < this.accelerometerYInstantTrackBar.Minimum) intValue = this.accelerometerYInstantTrackBar.Minimum;
                                    this.accelerometerYInstantTrackBar.Value = intValue;

                                }

                                object zInstantOBJ = null;
                                if (dico.TryGetValue("zInstant", out zInstantOBJ) == true)
                                {
                                    double value = Convert.ToDouble(zInstantOBJ);
                                    int intValue = Convert.ToInt32(value * (float)1000);
                                    if (intValue > this.accelerometerZInstantTrackBar.Maximum) intValue = this.accelerometerZInstantTrackBar.Maximum;
                                    if (intValue < this.accelerometerZInstantTrackBar.Minimum) intValue = this.accelerometerZInstantTrackBar.Minimum;
                                    this.accelerometerZInstantTrackBar.Value = intValue;

                                }

                            }

                            //------------------------------------------------------------------------------------------------------------------------
                            //---------------------------------------------COMPASS -------------------------------------------------------------
                            //------------------------------------------------------------------------------------------------------------------------
                            else if (eventNameSTR.Equals("heading"))
                            {
                                object geographicOBJ = null;
                                if (dico.TryGetValue("geographic", out geographicOBJ) == true)
                                {
                                    float value = (float)Convert.ToDouble(geographicOBJ);
                                    this.geographicCompassView.applyAngleFromCompassValues(value);
                                    this.geographicCompassView.refreshGUI();
                                }

                                object magneticOBJ = null;
                                if (dico.TryGetValue("magnetic", out magneticOBJ) == true)
                                {
                                    float value = (float)Convert.ToDouble(magneticOBJ);
                                    this.magneticCompassView.applyAngleFromCompassValues(value);
                                    this.magneticCompassView.refreshGUI();

                                }

                            }

                            //------------------------------------------------------------------------------------------------------------------------
                            //---------------------------------------------GYROSCOPE -------------------------------------------------------------
                            //------------------------------------------------------------------------------------------------------------------------
                            else if (eventNameSTR.Equals("gyroscope"))
                            {
                                object xRotationOBJ = null;
                                if (dico.TryGetValue("xRotation", out xRotationOBJ) == true)
                                {
                                    double value = Convert.ToDouble(xRotationOBJ);
                                    int intValue = Convert.ToInt32(value * (float)1000);
                                    if (intValue > this.gyroscopeXAxisTrackBar.Maximum) intValue = this.gyroscopeXAxisTrackBar.Maximum;
                                    if (intValue < this.gyroscopeXAxisTrackBar.Minimum) intValue = this.gyroscopeXAxisTrackBar.Minimum;
                                    this.gyroscopeXAxisTrackBar.Value = intValue;

                                }

                                object yRotationOBJ = null;
                                if (dico.TryGetValue("yRotation", out yRotationOBJ) == true)
                                {
                                    double value = Convert.ToDouble(yRotationOBJ);
                                    int intValue = Convert.ToInt32(value * (float)1000);
                                    if (intValue > this.gyroscopeYAxisTrackBar.Maximum) intValue = this.gyroscopeYAxisTrackBar.Maximum;
                                    if (intValue < this.gyroscopeYAxisTrackBar.Minimum) intValue = this.gyroscopeYAxisTrackBar.Minimum;
                                    this.gyroscopeYAxisTrackBar.Value = intValue;

                                }

                                object zRotationOBJ = null;
                                if (dico.TryGetValue("zRotation", out zRotationOBJ) == true)
                                {
                                    double value = Convert.ToDouble(zRotationOBJ);
                                    int intValue = Convert.ToInt32(value * (float)1000);
                                    if (intValue > this.gyroscopeZAxisTrackBar.Maximum) intValue = this.gyroscopeZAxisTrackBar.Maximum;
                                    if (intValue < this.gyroscopeZAxisTrackBar.Minimum) intValue = this.gyroscopeZAxisTrackBar.Minimum;
                                    this.gyroscopeZAxisTrackBar.Value = intValue;

                                }
                            }

                            //------------------------------------------------------------------------------------------------------------------------
                            //---------------------------------------------KEY -------------------------------------------------------------
                            //------------------------------------------------------------------------------------------------------------------------
                            else if (eventNameSTR.Equals("key"))
                            {
                                //Recuperer le nom du bouton
                                object keyNameOBJ = null;
                                if(dico.TryGetValue("keyName",out keyNameOBJ) == true)
                                {
                                    string keyNameSTR = keyNameOBJ.ToString();

                                    object phaseOBJ = null;
                                    if(dico.TryGetValue("phase",out phaseOBJ) == true)
                                    {
                                        string phaseSTR = phaseOBJ.ToString();
                                        this.keyView1.refreshButtonStateFromRemote(keyNameSTR, phaseSTR);
                                    }

                                }
                            }

                            //------------------------------------------------------------------------------------------------------------------------
                            //---------------------------------------------GPS -------------------------------------------------------------
                            //------------------------------------------------------------------------------------------------------------------------
                            else if (eventNameSTR.Equals("location"))
                            {
                                PointLatLng location = new PointLatLng();
                                 object latitudeOBJ = null;

                                 if (dico.TryGetValue("latitude", out latitudeOBJ) == true)
                                 {
                                     location.Lat= Convert.ToDouble(latitudeOBJ);
                                 }

                                 object longitudeOBJ = null;

                                 if (dico.TryGetValue("longitude", out longitudeOBJ) == true)
                                 {
                                     location.Lng = Convert.ToDouble(longitudeOBJ);
                                 }
                                 if (this.gpsTimer.Enabled == true)
                                     this.stopRouteBt_Click(null, null);

                                 this.googleMapControl1.setRemoteGGPSMarkerLocation(location);

                                 object speedOBJ = null;
                                 if (dico.TryGetValue("speed", out speedOBJ) == true)
                                 {
                                     this.speedTxtBx.Text = Convert.ToDouble(speedOBJ).ToString();
                                 }

                                 object accuracyOBJ = null;
                                 if (dico.TryGetValue("accuracy", out accuracyOBJ) == true)
                                 {
                                     this.accuracyTxtBx.Text = Convert.ToDouble(accuracyOBJ).ToString();
                                 }

                                 object altitudeOBJ = null;
                                 if (dico.TryGetValue("altitude", out altitudeOBJ) == true)
                                 {
                                     this.altitudeTxtBx.Text = Convert.ToDouble(altitudeOBJ).ToString();
                                 }

                                 object timeOBJ = null;
                                 if (dico.TryGetValue("time", out timeOBJ) == true)
                                 {
                                     this.timeTxtBx.Text = Convert.ToDouble(timeOBJ).ToString();
                                 }

                            }
                        }

                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("Error MESSAGE : " + ex.Message);
                    }

                }

            }
        }
Exemple #5
0
        private void analyseMessage(string stream, ASyncSocket AcceptedSocket)
        {
            if (this.CurrentCommandReceive.Contains("EXIT"))
            {
                this.AcceptedClients.Remove(AcceptedSocket);
                AcceptedSocket.OnReceive -= new ASyncSocket.OnReceiveEventHandler(server_OnReceive);
                AcceptedSocket.OnSend -= new ASyncSocket.OnSendEventHandler(server_OnSend);

                AcceptedSocket.OnDisconnect -= new ASyncSocket.OnDisconnectEventHandler(server_OnDisconnect);

                AcceptedSocket.OnReceiveFailed -= new ASyncSocket.OnReceiveFailedEventHandler(server_OnReceiveFailed);
                AcceptedSocket.OnSendFailed -= new ASyncSocket.OnSendFailedEventHandler(server_OnSendFailed);
                AcceptedSocket.Disconnect();
                AcceptedSocket = null;

                return;
            }

            bool hasFoundAccelerometerValues = false;
            bool hasFoundCompassValues = false;
            bool hasFoundGyroscopeValues = false;
            bool hasFoundGPSValues = false;

            //SPlit the message
            string[] messages = stream.Split('|');
            for (int i = 0; i < messages.Length; i++)
            {
                string message = messages[i];
                string[] commands = message.Split(',');
                for (int j = 0; j < commands.Length; j++)
                {
                    string currentCommand = commands[j];
                    if (currentCommand.Equals("DEVICE"))
                        AcceptedSocket.isSimulator = false;
                    else if (currentCommand.Equals("SIMULATOR"))
                        AcceptedSocket.isSimulator = true;
                    else if (currentCommand.Contains("ACCELEROMETER_XGRAVITY"))
                    {
                        string[] keyValue = currentCommand.Split('=');
                        if (keyValue.Length < 2) continue;

                        float value = -1;
                        if (keyValue.Length < 2) continue;
                        bool res = float.TryParse(keyValue[1].Replace(".", ","), out value);
                        if (res == true)
                        {
                            int intValue = Convert.ToInt32(value * (float)1000);
                            if (intValue > this.acceleromterXTrackBar.Maximum) intValue = this.acceleromterXTrackBar.Maximum;
                            if (intValue < this.acceleromterXTrackBar.Minimum) intValue = this.acceleromterXTrackBar.Minimum;
                            this.acceleromterXTrackBar.Value = intValue;
                            hasFoundAccelerometerValues = true;
                        }
                    }
                    else if (currentCommand.Contains("ACCELEROMETER_YGRAVITY"))
                    {
                        string[] keyValue = currentCommand.Split('=');
                        float value = -1;
                        if (keyValue.Length < 2) continue;
                        bool res = float.TryParse(keyValue[1].Replace(".", ","), out value);
                        if (res == true)
                        {
                            int intValue = Convert.ToInt32(value * (float)1000);
                            if (intValue > this.acceleromterYTrackBar.Maximum) intValue = this.acceleromterYTrackBar.Maximum;
                            if (intValue < this.acceleromterYTrackBar.Minimum) intValue = this.acceleromterYTrackBar.Minimum;
                            this.acceleromterYTrackBar.Value = intValue;
                            hasFoundAccelerometerValues = true;

                        }
                    }
                    else if (currentCommand.Contains("ACCELEROMETER_ZGRAVITY"))
                    {
                        string[] keyValue = currentCommand.Split('=');
                        float value = -1;
                        if (keyValue.Length < 2) continue;
                        bool res = float.TryParse(keyValue[1].Replace(".", ","), out value);
                        if (res == true)
                        {
                            int intValue = Convert.ToInt32(value * (float)1000);
                            if (intValue > this.acceleromterZTrackBar.Maximum) intValue = this.acceleromterZTrackBar.Maximum;
                            if (intValue < this.acceleromterZTrackBar.Minimum) intValue = this.acceleromterZTrackBar.Minimum;
                            this.acceleromterZTrackBar.Value = intValue;
                            hasFoundAccelerometerValues = true;

                        }
                    }
                    else if (currentCommand.Contains("ACCELEROMETER_XINSTANT"))
                    {
                        string[] keyValue = currentCommand.Split('=');
                        if (keyValue.Length < 2) continue;

                        float value = -1;
                        if (keyValue.Length < 2) continue;
                        bool res = float.TryParse(keyValue[1].Replace(".", ","), out value);
                        if (res == true)
                        {
                            int intValue = Convert.ToInt32(value * (float)1000);
                            if (intValue > this.accelerometerXInstantTrackBar.Maximum) intValue = this.accelerometerXInstantTrackBar.Maximum;
                            if (intValue < this.accelerometerXInstantTrackBar.Minimum) intValue = this.accelerometerXInstantTrackBar.Minimum;
                            this.accelerometerXInstantTrackBar.Value = intValue;
                            hasFoundAccelerometerValues = true;
                        }
                    }
                    else if (currentCommand.Contains("ACCELEROMETER_YINSTANT"))
                    {
                        string[] keyValue = currentCommand.Split('=');
                        float value = -1;
                        if (keyValue.Length < 2) continue;
                        bool res = float.TryParse(keyValue[1].Replace(".", ","), out value);
                        if (res == true)
                        {
                            int intValue = Convert.ToInt32(value * (float)1000);
                            if (intValue > this.accelerometerYInstantTrackBar.Maximum) intValue = this.accelerometerYInstantTrackBar.Maximum;
                            if (intValue < this.accelerometerYInstantTrackBar.Minimum) intValue = this.accelerometerYInstantTrackBar.Minimum;
                            this.accelerometerYInstantTrackBar.Value = intValue;
                            hasFoundAccelerometerValues = true;
                        }
                    }
                    else if (currentCommand.Contains("ACCELEROMETER_ZINSTANT"))
                    {
                        string[] keyValue = currentCommand.Split('=');
                        float value = -1;
                        if (keyValue.Length < 2) continue;
                        bool res = float.TryParse(keyValue[1].Replace(".", ","), out value);
                        if (res == true)
                        {
                            int intValue = Convert.ToInt32(value * (float)1000);
                            if (intValue > this.accelerometerZInstantTrackBar.Maximum) intValue = this.accelerometerZInstantTrackBar.Maximum;
                            if (intValue < this.accelerometerZInstantTrackBar.Minimum) intValue = this.accelerometerZInstantTrackBar.Minimum;
                            this.accelerometerZInstantTrackBar.Value = intValue;
                            hasFoundAccelerometerValues = true;
                        }
                    }
                    //------------------------COMPASS------------------------------------------------------------------------------------------------------------
                    else if (currentCommand.Contains("COMPASS_GEOGRAPHIC"))
                    {
                        string[] keyValue = currentCommand.Split('=');
                        float value = -1;
                        if (keyValue.Length < 2) continue;
                        bool res = float.TryParse(keyValue[1].Replace(".", ","), out value);
                        if (res == true)
                        {
                            this.geographicCompassView.applyAngleFromCompassValues(value);
                            hasFoundCompassValues = true;
                        }
                    }
                    else if (currentCommand.Contains("COMPASS_MAGNETIC"))
                    {
                        string[] keyValue = currentCommand.Split('=');
                        float value = -1;
                        if (keyValue.Length < 2) continue;
                        bool res = float.TryParse(keyValue[1].Replace(".", ","), out value);
                        if (res == true)
                        {
                            this.magneticCompassView.applyAngleFromCompassValues(value);
                            hasFoundCompassValues = true;
                        }
                    }
                    //------------------------GYROSCOPE------------------------------------------------------------------------------------------------------------
                    else if (currentCommand.Contains("GYROSCOPE_DELTATIME"))
                    {
                        string[] keyValue = currentCommand.Split('=');
                        float value = -1;
                        if (keyValue.Length < 2) continue;
                        bool res = float.TryParse(keyValue[1].Replace(".", ","), out value);
                        if (res == true)
                        {
                            hasFoundGyroscopeValues = true;
                        }
                    }

                    else if (currentCommand.Contains("GYROSCOPE_XROTATION"))
                    {
                        string[] keyValue = currentCommand.Split('=');
                        float value = -1;
                        if (keyValue.Length < 2) continue;
                        bool res = float.TryParse(keyValue[1].Replace(".", ","), out value);
                        if (res == true)
                        {
                            int intValue = Convert.ToInt32(value *10);
                            if (intValue > this.gyroscopeXAxisTrackBar.Maximum) intValue = this.gyroscopeXAxisTrackBar.Maximum;
                            if (intValue < this.gyroscopeXAxisTrackBar.Minimum) intValue = this.gyroscopeXAxisTrackBar.Minimum;
                            this.gyroscopeXAxisTrackBar.Value = intValue;
                            hasFoundGyroscopeValues = true;
                        }
                    }

                    else if (currentCommand.Contains("GYROSCOPE_YROTATION"))
                    {
                        string[] keyValue = currentCommand.Split('=');
                        float value = -1;
                        if (keyValue.Length < 2) continue;
                        bool res = float.TryParse(keyValue[1].Replace(".", ","), out value);
                        if (res == true)
                        {
                            int intValue = Convert.ToInt32(value * 10);
                            if (intValue > this.gyroscopeYAxisTrackBar.Maximum) intValue = this.gyroscopeYAxisTrackBar.Maximum;
                            if (intValue < this.gyroscopeYAxisTrackBar.Minimum) intValue = this.gyroscopeYAxisTrackBar.Minimum;
                            this.gyroscopeYAxisTrackBar.Value = intValue;
                            hasFoundGyroscopeValues = true;
                        }
                    }

                    else if (currentCommand.Contains("GYROSCOPE_ZROTATION"))
                    {
                        string[] keyValue = currentCommand.Split('=');
                        float value = -1;
                        if (keyValue.Length < 2) continue;
                        bool res = float.TryParse(keyValue[1].Replace(".", ","), out value);
                        if (res == true)
                        {
                            int intValue = Convert.ToInt32(value * 10);
                            if (intValue > this.gyroscopeZAxisTrackBar.Maximum) intValue = this.gyroscopeZAxisTrackBar.Maximum;
                            if (intValue < this.gyroscopeZAxisTrackBar.Minimum) intValue = this.gyroscopeZAxisTrackBar.Minimum;
                            this.gyroscopeZAxisTrackBar.Value = intValue;
                            hasFoundGyroscopeValues = true;
                        }
                    }
                    //------------------------GPS------------------------------------------------------------------------------------------------------------
                    else if (currentCommand.Contains("GYROSCOPE_ZROTATION"))
                    {
                        string[] keyValue = currentCommand.Split('=');
                        float value = -1;
                        if (keyValue.Length < 2) continue;
                        bool res = float.TryParse(keyValue[1].Replace(".", ","), out value);
                        if (res == true)
                        {
                            int intValue = Convert.ToInt32(value * 10);
                            if (intValue > this.gyroscopeZAxisTrackBar.Maximum) intValue = this.gyroscopeZAxisTrackBar.Maximum;
                            if (intValue < this.gyroscopeZAxisTrackBar.Minimum) intValue = this.gyroscopeZAxisTrackBar.Minimum;
                            this.gyroscopeZAxisTrackBar.Value = intValue;
                            hasFoundGyroscopeValues = true;
                        }
                    }
                }

                if (hasFoundAccelerometerValues == true)
                {
                    this.sendAccelerometerEvent();
                    hasFoundAccelerometerValues = false;
                }

                if (hasFoundCompassValues == true)
                {
                    this.sendCompassEvent();
                    hasFoundCompassValues = false;
                    this.magneticCompassView.refreshGUI();
                    this.geographicCompassView.refreshGUI();
                }

                if (hasFoundGyroscopeValues == true)
                {
                    this.sendGyroscopeEvent();
                    hasFoundGyroscopeValues = false;

                }

            }
        }