private void ARCLManager_SocketComms_SocketIO_UpdateEmOutputsEvent()
 {
     while (WaitingForInputUpdate)
     {
     }
     WaitingForOutputUpdate = EmIO_Manager.ReadAllOutputs();
 }
        private void ARCLManager_SocketComms_SocketIO_UpdateEmInputsEvent(SocketIOArgs data)
        {
            for (int i = 1; i <= EmIO_Manager.ActiveSets.Count(); i++)
            {
                EmIO_Manager.ActiveSets[i.ToString()].Inputs = new List <byte>()
                {
                    data.IO[i - 1]
                }
            }
            ;

            while (WaitingForOutputUpdate)
            {
            }

            WaitingForInputUpdate = EmIO_Manager.WriteAllInputs();
        }
        private void ConnectionCleanup()
        {
            if (Connection != null)
            {
                Connection.ConnectState   -= Connection_ConnectState;
                Connection.QueueJobUpdate -= Connection_QueueUpdate;
            }

            if (EmRobots_Manager != null)
            {
                EmRobots_Manager.InSync -= EmRobots_Manager_InSync;
                EmRobots_Manager.Stop();
                EmRobots_Manager = null;
            }
            this.Queue(false, new Action(() => EmRobots_InSync?.Invoke(this, false)));

            if (EmIO_Manager != null)
            {
                EmIO_Manager.InSync -= EmIO_Manager_InSync;
                EmIO_Manager.Stop();

                EmIO_Manager = null;
            }
            this.Queue(false, new Action(() => EmIO_InSync?.Invoke(this, false)));

            if (EmQueue_Manager != null)
            {
                EmQueue_Manager.InSync -= EmQueue_Manager_InSync;
                EmQueue_Manager.Stop();

                EmQueue_Manager = null;
            }
            this.Queue(false, new Action(() => EmQueue_InSync?.Invoke(this, false)));

            Connection?.Close();
            Connection?.Dispose();
            Connection = null;
        }