private void SocketIO_ProcessMessage(object sender, SocketIOArgs data)
        {
            if (EmIO_Manager == null)//Not connected to Em
            {
                SocketIO_Client.Write(data.GetSocketCommandString(data.Command + 2));
                return;
            }
            else if (!EmIO_Manager.IsSynced)//Not ready for IO updates.
            {
                SocketIO_Client.Write(data.GetSocketCommandString(data.Command + 2));
                return;
            }

            if (!SocketIO_InSync)
            {
                SocketIO_InSync = true;
                this.Queue(false, new Action(() => SocketIO_InSyncEvent?.Invoke(this, true)));
            }

            switch (data.Command)
            {
            case 1:     //Write Outputs
                this.Queue(false, new Action(() => SocketIO_UpdateEmInputsEvent?.Invoke(data)));
                break;

            case 10:     //Read Inputs
                this.Queue(false, new Action(() => SocketIO_UpdateEmOutputsEvent?.Invoke()));
                break;
            }
        }
        private void EmIO_Manager_InSync(object sender, bool state)
        {
            EmIO_InSync?.Invoke(sender, state);

            if (SocketIO_Client == null)
            {
                return;
            }

            if (state)
            {
                List <byte> toSend = new List <byte>();

                if (WaitingForInputUpdate)
                {
                    for (int i = 1; i <= EmIO_Manager.ActiveSets.Count(); i++)
                    {
                        toSend.AddRange(EmIO_Manager.ActiveSets[i.ToString()].Inputs);
                    }

                    SocketIO_Client.Write(new SocketIOArgs(toSend).GetSocketCommandString(2));

                    WaitingForInputUpdate = false;

                    return;
                }

                if (WaitingForOutputUpdate)
                {
                    for (int i = 1; i <= EmIO_Manager.ActiveSets.Count(); i++)
                    {
                        toSend.AddRange(EmIO_Manager.ActiveSets[i.ToString()].Outputs);
                    }

                    SocketIO_Client.Write(new SocketIOArgs(toSend).GetSocketCommandString(11));

                    WaitingForOutputUpdate = false;

                    return;
                }
            }
        }