void EmoteCommonMessages.IAffectPerceptionEvents.UserState(string AffectPerceptionInfo_AffectiveStates)
        {
            Console.WriteLine("Got User State from Affect Perception");
            AffectPerceptionInfo api = AffectPerceptionInfo.DeserializeFromJson(AffectPerceptionInfo_AffectiveStates);
            String mapEventId = api.mMapEventId;
            if (mapEventId != null && mapEventId != "")
            {
                //We have a map even id to use.
                Console.WriteLine("Map event id:" + mapEventId);
                 if (LearnerStateInfo_learnerStates.ContainsKey(mapEventId))
                    {
                        Console.WriteLine("Sending message to IM mapEventId:" + mapEventId + " Reason:" + EmoteCommonMessages.LearnerModelUpdateReason.StepAnswerAttempt);
                    
                        LMPublisher.learnerModelValueUpdateAfterAffectPerceptionUpdate(LearnerStateInfo_learnerStates[mapEventId], AffectPerceptionInfo_AffectiveStates);
                    }
                 else
                 {
                        LearnerStateInfo lsi;
                        if (LearnerStateInfo_learnerState != null)
                        {
                            lsi = LearnerStateInfo.DeserializeFromJson(LearnerStateInfo_learnerState);
                        }
                        else
                        {
                           lsi = new LearnerStateInfo(0, 0, 0, 0, 0, true, mapEventId); 
                        }
                      lsi.reasonForUpdate = EmoteCommonMessages.LearnerModelUpdateReason.StepAnswerAttempt;
                      LearnerStateInfo_learnerState = LearnerStateInfo_learnerState = lsi.SerializeToJson();
                      Console.WriteLine("Sending message to IM mapEventId:" + mapEventId + " Reason:" + EmoteCommonMessages.LearnerModelUpdateReason.StepAnswerAttempt);
                     LMPublisher.learnerModelValueUpdateAfterAffectPerceptionUpdate(LearnerStateInfo_learnerState, AffectPerceptionInfo_AffectiveStates);
                    
                 }
            }
            else
            {
                //we have no map event id to use.
                // This is due to an affect update so set the reason appropriatly for the IM to take acount of. 
                LearnerStateInfo lsi;
                        if (LearnerStateInfo_learnerState != null)
                        {
                            lsi = LearnerStateInfo.DeserializeFromJson(LearnerStateInfo_learnerState);
                        }
                        else
                        {
                           lsi = new LearnerStateInfo(0, 0, 0, 0, 0, true, ""); 
                        }
                    lsi.reasonForUpdate = EmoteCommonMessages.LearnerModelUpdateReason.AffectUpdate;
                      LearnerStateInfo_learnerState = LearnerStateInfo_learnerState = lsi.SerializeToJson();
                      Console.WriteLine("Sending message to IM  Reason:" + EmoteCommonMessages.LearnerModelUpdateReason.AffectUpdate);
                    
                     LMPublisher.learnerModelValueUpdateAfterAffectPerceptionUpdate(LearnerStateInfo_learnerState, AffectPerceptionInfo_AffectiveStates);
                   
            
            }


           
           
         /*   AffectPerceptionInfo api = AffectPerceptionInfo.DeserializeFromJson(AffectPerceptionInfo_AffectiveStates);




            Dictionary<String, String> parametersForJson = new Dictionary<String, String>();
            parametersForJson["mapEventId"] = api.mMapEventId.ToString();

            foreach (EmoteEvents.AffectPerceptionInfo.AffectType affect in api.mAffectiveStates)
            {


            }

            JavaWebRequest("thalamusMapAction", parametersForJson);*/
        }
        public void TaskUpdateCallback(LearnerStateInfo lsi)
        {
            if (mInternalState.mState != Status.OKAO_ONLY)
            {

                if (lsi.reasonForUpdate == LearnerModelUpdateReason.StepAnswerAttempt)
                    AddTaskData(lsi.correct, lsi.competencyItems[0].competencyCorrect, lsi.competencyItems[0].comptencyValue, lsi.competencyItems[1].competencyCorrect, lsi.competencyItems[1].comptencyValue, lsi.competencyItems[2].competencyCorrect, lsi.competencyItems[2].comptencyValue);
                else if (lsi.reasonForUpdate == LearnerModelUpdateReason.ToolUse)
                    UpdateTaskActivity();
            }

            UpdateLM(lsi.learnerId, lsi.mapEventId);
        }
        void EmoteMapReadingEvents.ITaskEvents.stepAnswerAttempt(int learnerId, int stepId, int activityId, int scenarioId, int sessionId, bool correct, string[] competencyName, bool[] competencyCorrect, string[] competencyActual, string[] competencyExpected, String mapEventId, String[] comptencyValue, String[] competencyConfidence, String[] oldCompetencyValue, String[] competencyDelta)
        {


            LearnerStateInfo lsi = new LearnerStateInfo( learnerId,  stepId,  activityId,  scenarioId,  sessionId,  correct,  mapEventId);
             if (LearnerNames.ContainsKey(learnerId.ToString()))
            {
                lsi.learnerName = LearnerNames[learnerId.ToString()];
                
            }
             else
             {
                   lsi.learnerName = "friend";
                  
             }
             Console.WriteLine("Got LM Update for learner ID:" + learnerId.ToString() + " Name:" + lsi.learnerName + " EventId" + mapEventId);
            for (int i = 0; i < competencyName.Length; i++)
            {
                lsi.competencyItems.Add(new LearnerStateInfo.CompetencyItem(competencyName[i], competencyCorrect[i], competencyActual[i], competencyExpected[i], Convert.ToDouble(comptencyValue[i]), Convert.ToInt16(competencyConfidence[i]), Convert.ToDouble(oldCompetencyValue[i]), Convert.ToDouble(competencyDelta[i]), EmoteCommonMessages.EvidenceType.numerical, EmoteCommonMessages.Impact.Neutral));
            }
            LearnerStateInfo_learnerState = lsi.SerializeToJson();
            LearnerStateInfo_learnerStates[lsi.mapEventId] =LearnerStateInfo_learnerState;

            Console.WriteLine("Sending Learner State To Java:" + mapEventId);
            JavaWebRequest("learnerModelUpdate", LearnerStateInfo_learnerState);

            
            //TODO this should come after the learner model responds...
          //  Console.WriteLine("Sending Learner State:" + mapEventId);
          //  LMPublisher.learnerModelValueUpdateBeforeAffectPerceptionUpdate(LearnerStateInfo_learnerState);      
        
        }