コード例 #1
0
        static void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;


            float timeFromStart = es.GetTimeFromStart();

            file.Write(timeFromStart + ",");
            Console.WriteLine("Time: " + timeFromStart);

            EdkDll.IEE_SignalStrength_t signalStrength = es.GetWirelessSignalStatus();
            file.Write(signalStrength + ",");

            Int32 chargeLevel    = 0;
            Int32 maxChargeLevel = 0;

            es.GetBatteryChargeLevel(out chargeLevel, out maxChargeLevel);
            file.Write(chargeLevel + ",");

            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_AF3) + ",");
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_T7) + ",");
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_O1) + ",");   // Pz
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_T8) + ",");
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_AF4) + ",");

            file.WriteLine("");
        }
コード例 #2
0
        static void engine_EmoEngineEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            Single timeFromStart = es.GetTimeFromStart();

            Int32 headsetOn = es.GetHeadsetOn();
            Int32 numCqChan = es.GetNumContactQualityChannels();

            EdkDll.EE_EEG_ContactQuality_t[] cq = es.GetContactQualityFromAllChannels();
            for (Int32 i = 0; i < numCqChan; ++i)
            {
                if (cq[i] != es.GetContactQuality(i))
                {
                    throw new Exception();
                }
            }
            EdkDll.EE_SignalStrength_t signalStrength = es.GetWirelessSignalStatus();
            Int32 chargeLevel    = 0;
            Int32 maxChargeLevel = 0;

            es.GetBatteryChargeLevel(out chargeLevel, out maxChargeLevel);

            engineLog.Write(
                "{0},{1},{2},{3},{4},",
                timeFromStart,
                headsetOn, signalStrength, chargeLevel, maxChargeLevel);

            for (int i = 0; i < cq.Length; ++i)
            {
                engineLog.Write("{0},", cq[i]);
            }
            engineLog.WriteLine("");
            engineLog.Flush();
        }
コード例 #3
0
    static void engine_EmoEngineEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
    {
        EmoState es        = e.emoState;
        Int32    numCqChan = es.GetNumContactQualityChannels();

        EdkDll.EE_EEG_ContactQuality_t[] cq = es.GetContactQualityFromAllChannels();
        nChan = numCqChan;
        int temp = 0;

        for (Int32 i = 0; i < numCqChan; ++i)
        {
            if (cq[i] != es.GetContactQuality(i))
            {
                throw new Exception();
            }

            switch (cq[i])
            {
            case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_NO_SIGNAL:
                Cq[i] = 0;
                break;

            case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_VERY_BAD:
                Cq[i] = 1;
                break;

            case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_POOR:
                Cq[i] = 2;
                break;

            case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_FAIR:
                Cq[i] = 3;
                break;

            case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_GOOD:
                temp++;
                Cq[i] = 4;
                break;
            }

            //---------------------
        }
        numOfGoodContacts = temp;
        //EdkDll.EE_SignalStrength_t signalStrength = es.GetWirelessSignalStatus();
        Int32 chargeLevel    = 0;
        Int32 maxChargeLevel = 0;

        es.GetBatteryChargeLevel(out chargeLevel, out maxChargeLevel);

        EdkDll.EE_SignalStrength_t signalStrength = es.GetWirelessSignalStatus();
        if (signalStrength == EdkDll.EE_SignalStrength_t.NO_SIGNAL)
        {
            for (Int32 i = 0; i < numCqChan; ++i)
            {
                Cq[i] = 0;
            }
        }
    }
コード例 #4
0
        static void emoEngine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            if (e.userId != 0)
            {
                return;
            }

            float timeFromStart = es.GetTimeFromStart();

            Console.Write(timeFromStart + ",");

            EdkDll.IEE_SignalStrength_t signalStrength = es.GetWirelessSignalStatus();
            Console.Write(signalStrength + ",");
            MainForm.headsetStatus.SetSignalStrength(signalStrength);

            Int32 chargeLevel    = 0;
            Int32 maxChargeLevel = 0;

            es.GetBatteryChargeLevel(out chargeLevel, out maxChargeLevel);
            Console.Write(chargeLevel + "," + maxChargeLevel + ",");
            if (signalStrength == EdkDll.IEE_SignalStrength_t.NO_SIG)
            {
                chargeLevel = 0;
            }
            MainForm.headsetStatus.SetBatteryLevel(chargeLevel);

            foreach (var item in new[] {
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_CMS, chStr = "CMS" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_DRL, chStr = "DRL" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_FP1, chStr = "FP1" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_FP2, chStr = "FP2" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_F7, chStr = "F7" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_F3, chStr = "F3" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_F4, chStr = "F4" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_F8, chStr = "F8" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_FC5, chStr = "FC5" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_FC6, chStr = "FC6" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_T7, chStr = "T7" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_T8, chStr = "T8" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_P7, chStr = "P7" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_P8, chStr = "P8" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_O1, chStr = "O1" },
                new { ch = EdkDll.IEE_InputChannels_t.IEE_CHAN_O2, chStr = "O2" }
            })
            {
                int val = (int)es.GetContactQuality((int)item.ch);
                Console.Write(val + ",");
                if (signalStrength == EdkDll.IEE_SignalStrength_t.NO_SIG)
                {
                    val = 0;
                }
                MainForm.headsetStatus.SetSensor(item.chStr, val);
            }

            Console.WriteLine();
        }
コード例 #5
0
    private static void engine_EmoEngineEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
    {
        EmoState emoState = e.emoState;
        int      numContactQualityChannels = emoState.GetNumContactQualityChannels();

        EdkDll.EE_EEG_ContactQuality_t[] contactQualityFromAllChannels = emoState.GetContactQualityFromAllChannels();
        EmoEngineInst.nChan = numContactQualityChannels;
        EdkDll.EE_SignalStrength_t wirelessSignalStatus = emoState.GetWirelessSignalStatus();
        int num = 0;

        if (wirelessSignalStatus != EdkDll.EE_SignalStrength_t.NO_SIGNAL)
        {
            for (int i = 0; i < numContactQualityChannels; i++)
            {
                if (contactQualityFromAllChannels[i] != emoState.GetContactQuality(i))
                {
                    throw new Exception();
                }
                switch (contactQualityFromAllChannels[i])
                {
                case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_NO_SIGNAL:
                    EmoEngineInst.Cq[i] = 0;
                    break;

                case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_VERY_BAD:
                    EmoEngineInst.Cq[i] = 1;
                    break;

                case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_POOR:
                    EmoEngineInst.Cq[i] = 2;
                    break;

                case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_FAIR:
                    EmoEngineInst.Cq[i] = 3;
                    break;

                case EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_GOOD:
                    num++;
                    EmoEngineInst.Cq[i] = 4;
                    break;
                }
            }
        }
        else
        {
            for (int j = 0; j < numContactQualityChannels; j++)
            {
                EmoEngineInst.Cq[j] = 0;
            }
        }
        EmoEngineInst.numOfGoodContacts = num;
        int num2 = 0;
        int num3 = 0;

        EmoEngineInst.signalStrength = emoState.GetWirelessSignalStatus();
        emoState.GetBatteryChargeLevel(out num2, out num3);
    }
コード例 #6
0
        void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;
            //Console.WriteLine("User has lower face expression : " + es.ExpressivGetLowerFaceAction().ToString()+ " of strength " + es.ExpressivGetLowerFaceActionPower().ToString() );
            Int32 numCqChan = es.GetNumContactQualityChannels();

            EdkDll.EE_EEG_ContactQuality_t[] cq = es.GetContactQualityFromAllChannels();

            for (Int32 i = 0; i < numCqChan; ++i)
            {
                if (cq[i] != es.GetContactQuality(i))
                {
                    throw new Exception();
                }
            }
            #region declare Contact Quality to store in datastructure
            ContactQuality contact = new ContactQuality()
            {
                CMS  = (double)cq[0],
                DRL  = (double)cq[1],
                AF4  = (double)cq[16],
                F8   = (double)cq[15],
                F4   = (double)cq[14],
                FC6  = (double)cq[13],
                T8   = (double)cq[12],
                P8   = (double)cq[11],
                O2   = (double)cq[10],
                O1   = (double)cq[9],
                P7   = (double)cq[8],
                T7   = (double)cq[7],
                FC5  = (double)cq[6],
                F3   = (double)cq[5],
                F7   = (double)cq[4],
                AF3  = (double)cq[3],
                date = DateTime.Now
            };
            #endregion
            scForm.updateContactQuality(contact);
            scForm.textChange();
            CQCollector.Add(contact);
        }
コード例 #7
0
        void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;
            //   Console.WriteLine("User has lower face expression : " + es.ExpressivGetLowerFaceAction().ToString()+ " of strength " + es.ExpressivGetLowerFaceActionPower().ToString() );
            Int32 numCqChan = es.GetNumContactQualityChannels();

            EdkDll.EE_EEG_ContactQuality_t[] cq = es.GetContactQualityFromAllChannels();

            for (Int32 i = 0; i < numCqChan; ++i)
            {
                if (cq[i] != es.GetContactQuality(i))
                {
                    throw new Exception();
                }
            }
            for (int i = 0; i < cq.Length; ++i)
            {
                //     Console.WriteLine("{0},", cq[i]);
//              engineLog.Write("{0},", cq[i]);
            }
        }
コード例 #8
0
    EdkDll.IEE_EEG_ContactQuality_t[] getContactQuality(EmoState state)
    {
        EdkDll.IEE_EEG_ContactQuality_t[] cq;
        if (headsetType == HeadsetType.Epoc)
        {
            //epoc contact quality
            cq = new EdkDll.IEE_EEG_ContactQuality_t[16];

            cq[0]  = state.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_AF3);
            cq[1]  = state.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_AF4);
            cq[2]  = state.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_F3);
            cq[3]  = state.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_F4);
            cq[4]  = state.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_F7);
            cq[5]  = state.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_F8);
            cq[6]  = state.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_FC5);
            cq[7]  = state.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_FC6);
            cq[8]  = state.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_O1);
            cq[9]  = state.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_O2);
            cq[10] = state.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_P7);
            cq[11] = state.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_P8);
            cq[12] = state.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_T7);
            cq[13] = state.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_T8);
            cq[14] = state.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_CMS);
            cq[15] = state.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_DRL);
            return(cq);
        }

        //insight contact quality
        cq    = new EdkDll.IEE_EEG_ContactQuality_t[6];
        cq[0] = EdkDll.IEE_EEG_ContactQuality_t.IEEG_CQ_VERY_BAD;
        cq[1] = state.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_AF3);
        cq[2] = state.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_T7);
        cq[3] = state.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_O1);
        cq[4] = state.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_T8);
        cq[5] = state.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_AF4);
        for (int i = 1; i < cq.Length; i++)
        {
            if (cq[i] > EdkDll.IEE_EEG_ContactQuality_t.IEEG_CQ_VERY_BAD)
            {
                cq[0] = EdkDll.IEE_EEG_ContactQuality_t.IEEG_CQ_GOOD;
                break;
            }
        }
        return(cq);
    }
コード例 #9
0
        private void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)  // update emotiv state and get channels statuses
        {
            es = e.emoState;
            if (e.userId == currentUser)
            {
                lock (_lockThis2)
                {
                    var    b1 = es.CognitivGetCurrentAction();
                    string c1 = b1.ToString();

                    var    b2 = es.ExpressivGetLowerFaceAction();
                    string c2 = b2.ToString();

                    var    b3 = es.ExpressivGetUpperFaceAction();
                    string c3 = b3.ToString();

                    EdkDll.EE_SignalStrength_t b4  = es.GetWirelessSignalStatus();              // emotiv wireless signal Status
                    int getWirelessSignalStatusInt = -1;
                    if (b4 == EdkDll.EE_SignalStrength_t.NO_SIGNAL)                             // emotiv wireless signal Status = NO_SIGNAL
                    {
                        getWirelessSignalStatusInt = 0;
                    }
                    else if (b4 == EdkDll.EE_SignalStrength_t.BAD_SIGNAL)                       // emotiv wireless signal Status = BAD_SIGNAL
                    {
                        getWirelessSignalStatusInt = 1;
                    }
                    else if (b4 == EdkDll.EE_SignalStrength_t.GOOD_SIGNAL)                      // emotiv wireless signal Status = GOOD_SIGNAL
                    {
                        getWirelessSignalStatusInt = 2;
                    }

                    bool Connected = false;
                    if (getWirelessSignalStatusInt != 0)
                    {
                        Connected = true;
                    }
                    //New_emotivConnected = Connected;
                    //New_emotiv_wireless_signal_status = getWirelessSignalStatusInt;

                    int batteryChargeLevel;                                                     // emotiv battery level
                    int maxChargeLevel;                                                         // emotiv max battery level
                    es.GetBatteryChargeLevel(out batteryChargeLevel, out maxChargeLevel);       // get emotiv battery level
                    float bat = ((float)batteryChargeLevel) / ((float)maxChargeLevel);          // bat = % current's user emotiv battery level
                    //New_emotiv_battery_level = bat;                                                 // % current's user emotiv battery level

                    EdkDll.EE_EEG_ContactQuality_t[] CQTable = new EdkDll.EE_EEG_ContactQuality_t[15];  // emotiv Contact Quality for all channels
                    int[]  CQTableInt = new int[15];
                    string cq         = "";
                    for (int i = 0; i < 14; i++)
                    {
                        CQTable[i] = es.GetContactQuality(i + 3);                               // emotiv Contact Quality for i channels
                        if (CQTable[i] == EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_NO_SIGNAL)      // if emotiv Contact Quality for i channels = NO_SIGNAL
                        {
                            CQTableInt[i] = 0;
                        }
                        else if (CQTable[i] == EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_VERY_BAD)  // if emotiv Contact Quality for i channels = VERY_BAD
                        {
                            CQTableInt[i] = 1;
                        }
                        else if (CQTable[i] == EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_POOR)      // if emotiv Contact Quality for i channels = POOR
                        {
                            CQTableInt[i] = 2;
                        }
                        else if (CQTable[i] == EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_FAIR)      // if emotiv Contact Quality for i channels = FAIR
                        {
                            CQTableInt[i] = 3;
                        }
                        else if (CQTable[i] == EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_GOOD)      // if emotiv Contact Quality for i channels = GOOD
                        {
                            CQTableInt[i] = 4;
                        }
                        else
                        {
                            CQTableInt[i] = -1;
                        }
                        cq = cq + CQTableInt[i].ToString() + ",";
                    }

                    cq = cq.Remove(cq.Length - 1); // remove the invalid character

                    New_emotivConnected = Connected;
                    New_emotiv_wireless_signal_status = getWirelessSignalStatusInt;
                    New_emotiv_battery_level          = bat;                                        // % current's user emotiv battery level
                    New_emotiv_contacts_quality       = cq;
                }
            }
        }
コード例 #10
0
        static void Engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            hsOn = es.GetHeadsetOn();
            My_Program.myForm.textBox2.Text = $"ESUpdate.";


            My_Program.myForm.textBox7.Text = "";
            //If HS is swiched OFF during run, it does not changes, so it only reacts
            //on switching HS ON for the first time After UserAdded Event only. Useless.
            My_Program.myForm.textBox7.Text = $"{hsOn}";
            //Getting events is useless or impossible. None of the below doesn't work as promised!
            // es.GetHandle() returns the State of the event.
            EdkDll.IEE_Event_t thisEvent = EdkDll.IEE_EmoEngineEventGetType(es.GetHandle());

            //My_Program.myForm.textBox7.Text = $"{EdkDll.IEE_EmoEngineEventGetType(myEvent)}";
            //My_Program.myForm.textBox7.Text = $"{EdkDll.IEE_EngineGetNextEvent(myEvent)}";
            //My_Program.myForm.textBox7.Text = $"{EdkDll.IEE_EngineGetNextEvent(es.GetHandle())}";
            //EdkDll.IEE_Event_t eventType = EdkDll.IEE_EmoEngineEventGetType(hEvent);
            //My_Program.myForm.textBox1.Text = $"State:{myState};Now:{thisEvent.GetTypeCode()}";

            float timeFromStart = es.GetTimeFromStart();

            My_Program.myForm.textBox6.Text = $"{timeFromStart}";

            //When USB dongle plugged in, WiFi for some reason jumps to 2, even if HeadSet if OFF.
            //but if HS if off later, this doesn't change.
            if (hsOn != 0)
            {
                EdkDll.IEE_SignalStrength_t signalStrength = es.GetWirelessSignalStatus();
                WiFi = (int)signalStrength;
                //My_Program.myForm.textBox4.Text = $"{WiFi}";
                //The only way to reset headset ON switch if headset is OFF!!!
                if (WiFi == 0)
                {
                    hsOn = 0;
                    My_Program.myForm.textBox7.Text = $"{hsOn}";
                }
                else
                {
                    My_Program.myForm.textBox7.Text = $"{hsOn}";
                    Int32 chargeLevel    = 0;
                    Int32 maxChargeLevel = 0;
                    es.GetBatteryChargeLevel(out chargeLevel, out maxChargeLevel);
                    My_Program.myForm.textBox5.Text = $"{chargeLevel}";
                    //string myStr = "";
                    //EdkDll.IEE_InputChannels_t myChannelsList = new EdkDll.IEE_InputChannels_t();
                    //Get EEG Electrode Contact Quality and change the electrode image on the Form.
                    Dictionary <string, int> electrodeQuality = new Dictionary <string, int>();
                    foreach (EdkDll.IEE_InputChannels_t chan in Enum.GetValues(typeof(EdkDll.IEE_InputChannels_t)))
                    {
                        electrodeQuality.Add($"{chan}", (int)es.GetContactQuality((int)chan));
                        foreach (var myElectrode in My_Program.myElectrodes)
                        {
                            // myStr += chan;
                            if (myElectrode.Name == $"{chan}")
                            {
                                string newImage = $@"{My_Program.myEpoc.myPath}";
                                if (myElectrode.Name == "IEE_CHAN_CMS" || myElectrode.Name == "IEE_CHAN_DRL")
                                {
                                    newImage += $@"\relectrode_q{(int)es.GetContactQuality((int)chan)}.png";
                                }
                                else
                                {
                                    newImage += $@"\electrode_q{(int)es.GetContactQuality((int)chan)}.png";
                                }

                                myElectrode.Image = System.Drawing.Image.FromFile(newImage);
                                //myStr += chan + "WILL BE:" + (int)es.GetContactQuality((int)chan) + " | ";
                                //myStr += newImage;
                            }
                        }
                        //myStr += $"{(int)chan}";
                        // myStr += chan + ":" + (int)es.GetContactQuality((int)chan) + " | ";
                    }
                    //Individual electrode signal quality output
                    //EdkDll.IEE_WindowingTypes myWType = new EdkDll.IEE_WindowingTypes();
                    //My_Program.myForm.textBox1.Text = $"{EdkDll.IEE_FFTGetWindowingType((uint)userID, myWType)}";
                    //My_Program.myEpoc.myEngine.IEE_FFTGetWindowingType((uint)userID, myWType);
                    //My_Program.myForm.textBox1.Text = $"{myWType}";
                    outputBuffer["Type"] = "EpocRawBuffer";
                    Harvest_EEG_Headset();
                    Harvest_Wavebands_Headset();
                    outputBuffer["EQ"] = electrodeQuality;

                    //string json = new JavaScriptSerializer().Serialize(outputBuffer);
                    //if (My_Program.SRV)
                    //{
                    //    My_Program.myServer.Broadcast(json);
                    // }
                }
            }
        }
コード例 #11
0
        //definimos una subrutina mediante la cual recibamos los datos de la diadema
        static void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            //creamos un objeto para la diadema
            EmoState es = e.emoState;

            //obtenemos los datos de la primera diadema conectada
            if (e.userId != 0)
            {
                return;
            }
            //definimos las variables: Tiempo, Señal y Batería
            float timeFromStart = es.GetTimeFromStart();

            EdkDll.IEE_SignalStrength_t signalStrength = es.GetWirelessSignalStatus();

            Int32 chargeLevel    = 0;
            Int32 maxChargeLevel = 0;

            es.GetBatteryChargeLevel(out chargeLevel, out maxChargeLevel);
            //escribimos dichos datos en el archivo
            // * y también por consola
            Console.WriteLine(" Time: " + timeFromStart);
            file.Write(timeFromStart + ",");

            Console.WriteLine(" Signal Strength: " + signalStrength);
            file.Write(signalStrength + ",");

            Console.WriteLine(" Battery level: " + chargeLevel);
            file.Write(chargeLevel + ",");
            //leemos los datos de cada uno de los sensores y los escribimos en el archivo

            /*** Emotiv Insight's Sensors ***/

            /*
             * file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_AF3) + ",");
             * file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_T7) + ",");
             * file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_O1) + ",");    // Pz
             * file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_T8) + ",");
             * file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_AF4) + ",");
             */

            /*** Emotiv Epoc+'s Sensors ***/

            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_CMS) + ","); //0 ¿?
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_DRL) + ","); //1 ¿?
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_FP1) + ","); //2
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_AF3) + ","); //3
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_F7) + ",");  //4
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_F3) + ",");  //5
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_FC5) + ","); //6
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_T7) + ",");  //7
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_P7) + ",");  //8
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_O1) + ",");  //9
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_O2) + ",");  //10
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_P8) + ",");  //11
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_T8) + ",");  //12
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_FC6) + ","); //13
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_F4) + ",");  //14
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_F8) + ",");  //15
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_AF4) + ","); //16
            file.Write((int)es.GetContactQuality((int)EdkDll.IEE_InputChannels_t.IEE_CHAN_FP2) + ","); //17

            //acabamos la línea en la que estamos escribiendo. En el caso de un csv, pasamos a una nueva fila
            file.WriteLine("");
        }