Exemplo n.º 1
0
    public static int ES_GetContactQualityFromAllChannels(IntPtr state, out EdkDll.EE_EEG_ContactQuality_t[] contactQuality)
    {
        int num = EdkDll.ES_GetNumContactQualityChannels(state);

        contactQuality = new EdkDll.EE_EEG_ContactQuality_t[num];
        return(EdkDll.Unmanaged_ES_GetContactQualityFromAllChannels(state, contactQuality, (uint)contactQuality.Length));
    }
Exemplo n.º 2
0
 public static int ES_GetContactQualityFromAllChannels(IntPtr state, out EdkDll.EE_EEG_ContactQuality_t[] contactQuality)
 {
     int num = EdkDll.ES_GetNumContactQualityChannels(state);
     contactQuality = new EdkDll.EE_EEG_ContactQuality_t[num];
     return EdkDll.Unmanaged_ES_GetContactQualityFromAllChannels(state, contactQuality, (uint)contactQuality.Length);
 }
Exemplo n.º 3
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;
                }
            }
        }