public void SendConfigurations(ConfigurationData confData)
        {
            AutoResetEvent are             = new AutoResetEvent(false);
            Thread         newConfigThread = new Thread(() =>
            {
                ConfigurationData temp = new ConfigurationData();
                while (!temp.Equals(confData)) // Sends configurations until the configurations on the robot is equal to the desired
                {
                    WriteConfigurationBytes(confData);
                    Thread.Sleep(10); // 100 hZ frequency
                    temp = GetConfigurations();
                }
                are.Set();
            });

            newConfigThread.IsBackground = true;
            newConfigThread.Start();

            Thread waitThread = new Thread(() =>
            {
                bool configSent = are.WaitOne(_timeout, false);
                if (configSent)
                {
                    Data.Instance.ReceiveConfiguration(confData);
                }
            });

            waitThread.IsBackground = true;
            waitThread.Start();
        }
        /// <summary>Sends the configurations to the modbus server to change the configurations of the robot.</summary>
        /// <param name="configData">Object containing the desired configurations.</param>
        public void SetConfigurations(ConfigurationData configData)
        {
            AutoResetEvent are             = new AutoResetEvent(false);
            Thread         newConfigThread = new Thread(() =>
            {
                ConfigurationData temp = new ConfigurationData();
                while (!temp.Equals(configData))                                    // Sends configurations until the configurations on the robot is equal to the desired
                {
                    modBus.SendConfigurations(configData);                          // Sends the desired configuration
                    Thread.Sleep(10);                                               // Sleep thread to optain a frequency on 100Hz
                    temp = modBus.GetConfigurations();                              // Gets the current configurations on the robot
                }
                are.Set();
            });

            newConfigThread.IsBackground = true;
            newConfigThread.Start();

            Thread waitThread = new Thread(() =>
            {
                if (OnConfigCompleted != null)
                {
                    OnConfigCompleted(are.WaitOne(timeout, false));                 // Event is thrown when the AutoResetEvent is set or when timeout has run out.
                }
            });

            waitThread.IsBackground = true;
            waitThread.Start();
        }