示例#1
0
    static void engine_CognitivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
    {
        //Debug.LogError("CognitivEmoStateUpdated");
        isNotResponding = false;
        EmoState es = e.emoState;

        EdkDll.EE_CognitivAction_t cogAction = es.CognitivGetCurrentAction();
        //Debug.LogError(cogAction);
        float power = (float)es.CognitivGetCurrentActionPower();

        //Debug.LogError(power + ":" +(uint)cogAction);
        //CognitivActionPower[(uint)cogAction] = power;
        for (int i = 1; i < cognitivActionList.Length; i++)
        {
            if (cogAction == cognitivActionList[i])
            {
                CognitivActionPower[i] = power;
                //Debug.LogError(CognitivActionPower[i] + "----------------------");
            }
            else
            {
                CognitivActionPower[i] = 0;
            }
        }
    }
        //Update fields when Emo state updated
        void CognitivEmoStateUpdated()
        {
            if (FEmoState[0] != null)
            {
                EmoState es = FEmoState[0];

                mCogAction = es.CognitivGetCurrentAction();
                mPower     = es.CognitivGetCurrentActionPower();
                mIsActive  = es.CognitivIsActive();
            }
        }
示例#3
0
    private static void engine_CognitivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
    {
        EmoState emoState = e.emoState;

        EdkDll.EE_CognitivAction_t eE_CognitivAction_t = emoState.CognitivGetCurrentAction();
        float num = emoState.CognitivGetCurrentActionPower();

        for (int i = 1; i < EmoCognitiv.cognitivActionList.Length; i++)
        {
            if (eE_CognitivAction_t == EmoCognitiv.cognitivActionList[i])
            {
                EmoCognitiv.CognitivActionPower[i] = num;
            }
        }
    }
示例#4
0
        static void engine_CognitivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState es = e.emoState;

            Single timeFromStart = es.GetTimeFromStart();

            EdkDll.EE_CognitivAction_t cogAction = es.CognitivGetCurrentAction();
            Single  power    = es.CognitivGetCurrentActionPower();
            Boolean isActive = es.CognitivIsActive();

            cogLog.WriteLine(
                "{0},{1},{2},{3}",
                timeFromStart,
                cogAction, power, isActive);
            cogLog.Flush();
        }
示例#5
0
        private void engine_CognitivEmoStateUpdated(object sender, EmoStateUpdatedEventArgs e)
        {
            EmoState     es            = e.emoState;
            FlightWindow outer         = new FlightWindow();
            Single       timeFromStart = es.GetTimeFromStart();
            Single       power         = es.CognitivGetCurrentActionPower();      // get power

            EdkDll.EE_CognitivAction_t cogAction = es.CognitivGetCurrentAction(); // get detected command

            Boolean isActive = es.CognitivIsActive();

            textBox1.Text = "Action:" + cogAction.ToString() + "|" + "Power" + power;
            switch (cogAction)
            {
            case EdkDll.EE_CognitivAction_t.COG_NEUTRAL:
            {
                count_clear("tf");
                outer.manualHover();           //forcing manula hovering.
                break;
            }

            case EdkDll.EE_CognitivAction_t.COG_PUSH:
            {
                count_clear("tf");
                outer.button1_Click(sender, e);                // forward command
                break;
            }

            case EdkDll.EE_CognitivAction_t.COG_PULL:
            {
                count_clear("t");
                if (forward_count % 2 == 0)
                {
                    outer.Backwards_Click(sender, e);              // forwad backward
                }
                forward_count++;

                break;
            }

            case EdkDll.EE_CognitivAction_t.COG_LIFT:
            {
                // if (takeoff_bool == false)
                // {
                if (takeoff_count % 3 == 0)
                {
                    outer.Takeoff_Click(sender, e);             // takeoff
                }

                //takeoff_bool = true;

                //}
                //else
                //{
                //    // already take off so rotate
                //    if (takeoff_count % 2 == 0)
                //    {
                //        outer.button7_Click(sender, e); /// more up
                //    }
                takeoff_count++;
                //}
                count_clear("f");

                break;
            }

            case EdkDll.EE_CognitivAction_t.COG_DROP:
            {
                outer.Landing_Click(sender, e);          // landing
                count_clear("tf");
                takeoff_bool = false;
                break;
            }
            }


            // Console.Write("{0}", cogAction);
            cogLog.WriteLine("{0},{1},{2},{3}", timeFromStart, cogAction, power, isActive);   // writing to log file
            cogLog.Flush();
        }
示例#6
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;
                }
            }
        }