Exemplo n.º 1
0
        private void engine_EmoEngineEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            Single timeFromStart = es.GetTimeFromStart();

            Int32 headsetOn = es.GetHeadsetOn();

            EdkDll.EE_SignalStrength_t signalStrength = es.GetWirelessSignalStatus();

            Int32 chargeLevel    = 0;
            Int32 maxChargeLevel = 0;

            es.GetBatteryChargeLevel(out chargeLevel, out maxChargeLevel);
            textBox2.Text = chargeLevel.ToString() + '/' + maxChargeLevel.ToString();
            // HT_Signalstrt.Text = signalStrength.ToString();

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


            engineLog.WriteLine("");
            engineLog.Flush();
        }
Exemplo n.º 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();
        }
Exemplo n.º 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;
            }
        }
    }
Exemplo n.º 4
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);
    }
Exemplo n.º 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);
 }
        protected void EmoEngineEmoStateUpdatedCB(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            //Update connexion status
            lock (syncLock)
            {
                mEmoState       = es;
                mIsHeadsetOn    = es.GetHeadsetOn() != 0;
                mCQ             = es.GetContactQualityFromAllChannels();
                mSignalStrength = es.GetWirelessSignalStatus();
                es.GetBatteryChargeLevel(out mBatteryCharge, out mBatteryMaxCharge);
                mTimeFromStart = es.GetTimeFromStart();
            }
        }
        protected void EmoEngineDisconnectedCB(object sender, EmoEngineEventArgs e)
        {
            mIsConnected = false;

            //Reset device status
            lock (syncLock)
            {
                mIsHeadsetOn      = false;
                mCQ               = new EdkDll.EE_EEG_ContactQuality_t[] { EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_NO_SIGNAL };
                mSignalStrength   = EdkDll.EE_SignalStrength_t.NO_SIGNAL;
                mBatteryCharge    = 0;
                mBatteryMaxCharge = 0;
                mTimeFromStart    = 0;
            }
        }
Exemplo n.º 8
0
 void engine_EmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
 {
     EmoState es = e.emoState;
     //Console.WriteLine("{0} ; excitement: {1} ", e.userId, es.AffectivGetEngagementBoredomScore());
     //EdkDll.EE_SignalStrength_t strength = es.GetWirelessSignalStatus();
     //String dd = strength.ToString();
     //int i = es.GetNumContactQualityChannels();
     //es.GetContactQualityFromAllChannels();
     if (es.GetHeadsetOn() == 1)
     {
         isConnected = true;
         this.timeFromStart = es.GetTimeFromStart();
         this.numContactQualityChannels = es.GetNumContactQualityChannels();
         this.contactQualityFromAllChannels = es.GetContactQualityFromAllChannels();
         this.signalStrength = es.GetWirelessSignalStatus();
         this.chargeLevel = 0;
         this.maxChargeLevel = 0;
         es.GetBatteryChargeLevel(out chargeLevel, out maxChargeLevel);
     }
     else
     {
         isConnected = false;
     }
 }
        protected void EmoEngineEmoStateUpdatedCB(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            //Update connexion status
            lock(syncLock)
            {
                mEmoState = es;
                mIsHeadsetOn = es.GetHeadsetOn() != 0;
                mCQ = es.GetContactQualityFromAllChannels();
                mSignalStrength = es.GetWirelessSignalStatus();
                es.GetBatteryChargeLevel(out mBatteryCharge, out mBatteryMaxCharge);
                mTimeFromStart = es.GetTimeFromStart();
            }
        }
 protected void EmoEngineDisconnectedCB(object sender, EmoEngineEventArgs e)
 {
     mIsConnected = false;
     
     //Reset device status
     lock(syncLock)
     {
         mIsHeadsetOn = false;
         mCQ = new EdkDll.EE_EEG_ContactQuality_t[] {EdkDll.EE_EEG_ContactQuality_t.EEG_CQ_NO_SIGNAL};
         mSignalStrength = EdkDll.EE_SignalStrength_t.NO_SIGNAL;
         mBatteryCharge = 0;
         mBatteryMaxCharge = 0;
         mTimeFromStart = 0;
     }
 }
Exemplo n.º 11
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;
                }
            }
        }