Exemple #1
0
 public bool Compare(UserState other)
 {
     return ((mValence != other.mValence) || (mArousal != other.mArousal) || (mTaskEngagement != other.mTaskEngagement) ||
          (mSocialEngagement != other.mSocialEngagement) || (mAttentionFocus != other.mAttentionFocus) || (mAttention != other.mAttention) 
          //|| (mValenceCI > other.mValenceCI) || (mArousalCI != other.mArousalCI) || (mSocialEngagementCI != other.mSocialEngagementCI) || (mTaskEngagementCI != other.mTaskEngagementCI)
          );
 }
Exemple #2
0
        public UserState(UserState other)
        {
            mValence = other.mValence;
            mArousal = other.mArousal;
            mTaskEngagement = other.mTaskEngagement;
            mSocialEngagement = other.mSocialEngagement;

            mAttentionFocus = other.mAttentionFocus;
            mAttention = other.mAttention;
        }
        /* Constructor */
        public InteractionAnalysis()
        {


            for (int i = 0; i < 3; i++)
            {
                if(i < 2) mEvents[i] = new AutoResetEvent(false);
                mMutex[i] = new Mutex(true);
                mMutex[i].ReleaseMutex();   
            }

            mUserState = new UserState();
            mPreviousUserState = new UserState(mUserState);

            mInternalState.SetupTimer();
        }
/* THREAD 3 */

        /* When the maximum number of LLI states has been reached, process the segment */
        public void ProcessSegment()
        {
            while(true)
            {
                mMutex[2].WaitOne();
                
                if (mProcessFlag == true)
                {
                    mProcessFlag = false;

                    Console.Clear();
                    Console.ForegroundColor = ConsoleColor.DarkRed;
                    Console.Out.Write("\n****************************************");
                    Console.Out.Write("\n******** ");
                    Console.ResetColor();
                    Console.Out.Write("Interaction Analysis ");
                    Console.ForegroundColor = ConsoleColor.DarkRed;
                    Console.Out.Write("**********");
                    Console.Out.Write("\n\n****************************************\n");
                    Console.ResetColor();
                    
                    // Extract features using the data we have...
                    string parseMs = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(ExtractFeatures());

                    string[] featureVector = parseMs.Split('\t');
                    int count = featureVector.Count();
                                      
                    double[,] cls = new double[,] { { 0.75, 0.75 }, { 0.75, 0.75 }, { 0.75, 0.75 }, { 0.75, 0.75 }, { 0.75, 0.75 } };
                    
                    
                    
                    if (mInternalState.mState == Status.OKAO_ONLY)
                    {
                        Console.ForegroundColor = ConsoleColor.DarkRed;
                        Console.Out.Write("\n\n****************************************");
                        Console.ResetColor();
                        Console.Out.Write("\n******* Basic Affective Output *********\n");

                        if (featureVector[90] == "0")
                            mUserState.mValence = Charge.Negative;
                        else if (featureVector[90] == "1")
                            mUserState.mValence = Charge.Neutral;
                        else if (featureVector[90] == "2")
                            mUserState.mValence = Charge.Positive;
                        if (mArousaltemp == 0) //no q sensor data, use OKAO instead for arousal
                        {
                            if (featureVector[91] == "0")
                                mUserState.mArousal = Charge.Negative;
                            else if (featureVector[91] == "1")
                                mUserState.mArousal = Charge.Neutral;
                            else if (featureVector[91] == "2")
                                mUserState.mArousal = Charge.Positive;
                        }
                    }

                    if (mInternalState.mModuleStatus == ModuleStatus.Ready)
                    {
                        //confidence here from OKAO
                        //mUserState.mValenceCI = 1000 * cls[0, 1];
                        //mUserState.mArousalCI = 1000 * cls[1, 1];
                        mConf = mConftemp / mconfcounter;

                        //arousal calc if q sensor sents data
                        if (mArousaltemp > 0)
                        {
                            oldArousal = currentArousal;
                            currentArousal = Math.Round((mArousaltemp / mconfcounter),2);

                            

                            //compare old arousal with new
                            if (currentArousal - thresArousal > oldArousal)
                            {//positive arousal
                                
                                mUserState.mArousal = Charge.Positive;
                            }
                            else if (currentArousal + thresArousal < oldArousal)
                            {//negative arousal
                                mUserState.mArousal = Charge.Negative;
                                
                            }
                            else //same as before
                            {
                                mUserState.mArousal = Charge.Neutral;
                                
                            }
                            if(currentArousal!=oldArousal)
                            thresArousal = Math.Abs(currentArousal - oldArousal) / 1;

                        }
                        

                        mUserState.mValenceCI =  mConf;
                        mUserState.mArousalCI = mConf; 
                        cls[0, 1] = mConf / 1000;//valence confidence
                        cls[1, 1] = mConf / 1000;//arousal confidence
                        //reset confidence for next interval
                        mConf = 0;
                        mConftemp = 0;
                        mconfcounter = 0;
                        Console.Out.Write("\n\n");
                        
                        if (mUserState.mValence == Charge.Negative)
                            Console.Out.WriteLine("\tV: Negative - CI: " + cls[0, 1].ToString("0.00"));
                        else if (mUserState.mValence == Charge.Neutral)
                            Console.Out.WriteLine("\tV: Neutral - CI: " + cls[0, 1].ToString("0.00"));
                        else if (mUserState.mValence == Charge.Positive)
                            Console.Out.WriteLine("\tV: Positive - CI: " + cls[0, 1].ToString("0.00"));

                        Console.Out.Write("\n");

                        if (mUserState.mArousal == Charge.Negative)
                            Console.Out.WriteLine("\tA: Negative - CI: " + cls[1, 1].ToString("0.00"));
                        else if (mUserState.mArousal == Charge.Neutral)
                            Console.Out.WriteLine("\tA: Neutral - CI: " + cls[1, 1].ToString("0.00"));
                        else if (mUserState.mArousal == Charge.Positive)
                            Console.Out.WriteLine("\tA: Positive - CI: " + cls[1, 1].ToString("0.00"));
                        Console.Out.WriteLine("\n");
                        if (mArousaltemp == 0)
                            Console.Out.WriteLine("\tNO Q Sensor data!!!");
                        else
                        {

                            Console.Out.WriteLine("\tQ Sensor data:");
                            Console.Out.WriteLine("\tOldArousal: " + oldArousal.ToString("0.00"));
                            Console.Out.WriteLine("\tThreshold: " + thresArousal.ToString("0.00"));
                            Console.Out.WriteLine("\tCurrentArousal: " + currentArousal.ToString("0.00"));
                        }
                        mArousaltemp = 0;
                    }
                    else
                        Console.Out.Write("\n\tInitialising...\n");

                    Console.ForegroundColor = ConsoleColor.DarkRed; 
                    Console.Out.WriteLine("\n****************************************");
                    Console.ResetColor();

                    
                    /////////////////////////////////////
                    // Has there been a change in state?
                    if (mUserState.Compare(mPreviousUserState))
                        UpdateLM();

                    mPreviousUserState = new UserState(mUserState);
                }

                mMutex[2].ReleaseMutex();
                Thread.Sleep(1000);
            }
        }