예제 #1
0
        public static Boolean Initialize()
        {
            eegChannels = new int[channels];

            if (!Initialized & !InitError)
            {
                PortForm formPort = new PortForm();
                if (formPort.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        // Set the amount of channels
                        channels      = formPort.Channels;
                        Algorithm     = formPort.Algorithm;
                        BlinkInterval = formPort.BlinkInterval / 10;
                        Threshold     = formPort.Threshold;

                        // Open the COM port
                        serialPort               = new SerialPort(formPort.SelectedPort);
                        serialPort.BaudRate      = 57600;
                        serialPort.Parity        = Parity.None;
                        serialPort.DataBits      = 8;
                        serialPort.StopBits      = StopBits.One;
                        serialPort.Handshake     = Handshake.None;
                        serialPort.ReadTimeout   = 500;
                        serialPort.WriteTimeout  = 500;
                        serialPort.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived);
                        serialPort.Open();
                    }
                    catch (Exception ex)
                    {
                        if (!InitError)
                        {
                            MessageBox.Show(ex.Message, "LucidScribe.InitializePlugin()", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        InitError = true;
                    }
                }
                else
                {
                    InitError = true;
                    return(false);
                }

                Initialized = true;
            }
            return(true);
        }
        public static Boolean Initialize()
        {
            eegChannels = new int[channels];

            if (!Initialized & !InitError)
            {
                PortForm formPort = new PortForm();
                if (formPort.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        // Set the amount of channels
                        channels = formPort.Channels;
                        Algorithm = formPort.Algorithm;
                        BlinkInterval = formPort.BlinkInterval / 10;
                        Threshold = formPort.Threshold;

                        // Open the COM port
                        serialPort = new SerialPort(formPort.SelectedPort);
                        serialPort.BaudRate = 57600;
                        serialPort.Parity = Parity.None;
                        serialPort.DataBits = 8;
                        serialPort.StopBits = StopBits.One;
                        serialPort.Handshake = Handshake.None;
                        serialPort.ReadTimeout = 500;
                        serialPort.WriteTimeout = 500;
                        serialPort.DataReceived += new SerialDataReceivedEventHandler(serialPort_DataReceived);
                        serialPort.Open();
                    }
                    catch (Exception ex)
                    {
                        if (!InitError)
                        {
                            MessageBox.Show(ex.Message, "LucidScribe.InitializePlugin()", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        }
                        InitError = true;
                    }
                }
                else
                {
                    InitError = true;
                    return false;
                }

                Initialized = true;
            }
            return true;
        }