Data Type Object Class for the representation of an Emotion
Ejemplo n.º 1
0
        public void Test_RPC_ActiveEmotions()
        {
            var rpc = BuildEmotionalRPCAsset();

            PopulateEventSet(1);

            var events = new List <Name>();

            foreach (var eve in eventSets[1])
            {
                events.Add((Name)eve);
            }

            rpc.Perceive(events);


            Assert.IsNotEmpty(rpc.GetAllActiveEmotions());


            var intensity = -1.0f;

            EmotionalAppraisal.DTOs.EmotionDTO maxEmotion = new EmotionalAppraisal.DTOs.EmotionDTO();
            foreach (var e in rpc.GetAllActiveEmotions())
            {
                if (e.Intensity > intensity)
                {
                    intensity  = e.Intensity;
                    maxEmotion = e;
                }
            }


            Assert.AreEqual(maxEmotion.Type, rpc.GetStrongestActiveEmotion().EmotionType);
        }
 public void AddEmotion(EmotionDTO newEmotion)
 {
     var resultingEmotion = _emotionalAppraisalAsset.AddActiveEmotion(newEmotion);
     Emotions.DataSource.Add(resultingEmotion);
     Emotions.Refresh();
     _mainForm.SetModified();
 }
        private void addOrEditButton_Click(object sender, EventArgs e)
        {
            try
            {
                var newEmotion = new EmotionDTO
                {
                    Type = comboBoxEmotionType.Text,
                    Intensity = int.Parse(comboBoxIntensity.Text),
                    CauseEventId = uint.Parse(textBoxCauseId.Text)
                };

                if (_emotionToEdit == null)
                {
                    _emotionalStateVm.AddEmotion(newEmotion);
                }
                else
                {
                    this._emotionalStateVm.UpdateEmotion(_emotionToEdit, newEmotion);
                }
                Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, Resources.ErrorDialogTitle, MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
 public void UpdateEmotion(EmotionDTO oldEmotion, EmotionDTO newEmotion)
 {
     _emotionalAppraisalAsset.RemoveEmotion(oldEmotion);
     _emotionalAppraisalAsset.AddActiveEmotion(newEmotion);
     Emotions.DataSource = _emotionalAppraisalAsset.ActiveEmotions.ToList();
     Emotions.Refresh();
     _mainForm.SetModified();
 }
Ejemplo n.º 5
0
 //TODO: Discuss with Pedro this hierarchy. Problem: ActiveEmotion might be a bit too tied to OCCEmotion
 public ActiveEmotion(EmotionDTO emotionDTO, int threshold, int decay)
 {
     var occType = OCCEmotionType.Parse(emotionDTO.Type);
     if(occType == null)
         throw new Exception("Unknown emotion type");
     this.EmotionType = occType.Name;
     this.Valence = occType.Valence;
     this.AppraisalVariables = occType.AppraisalVariables.ToArray();
     this.InfluenceMood = occType.InfluencesMood;
     this.CauseId = emotionDTO.CauseEventId;
     this.Direction = null; //TODO: handle direction correctly
     this.Threshold = threshold;
     this.Decay = decay;
     this.Intensity = emotionDTO.Intensity;
 }
            public EmotionDTO AddActiveEmotion(EmotionDTO emotion)
            {
                EmotionDisposition disposition = GetEmotionDisposition(emotion.Type);
                var activeEmotion = new ActiveEmotion(emotion, disposition.Threshold, disposition.Decay);
                string hash = calculateHashString(activeEmotion, m_parent.m_am);

                if (emotionPool.ContainsKey(hash))
                {
                    throw new ArgumentException("This given emotion is already related to given cause",nameof(emotion));
                }

                emotionPool.Add(hash, activeEmotion);
                activeEmotion.GetCause(m_parent.m_am).LinkEmotion(activeEmotion.EmotionType);

                return activeEmotion.ToDto(m_parent.m_am);
            }
        public AddOrEditEmotionForm(EmotionalStateVM emotionalStateVM, EmotionDTO emotionToEdit = null)
        {
            InitializeComponent();

            _emotionalStateVm = emotionalStateVM;
            _emotionToEdit = emotionToEdit;

            //Default Values
            comboBoxIntensity.Text = "1";
            comboBoxEmotionType.DataSource = EmotionalAppraisalAsset.EmotionTypes;

            if (emotionToEdit != null)
            {
                this.Text = Resources.EditEmotionFormTitle;
                this.addOrEditButton.Text = Resources.UpdateButtonLabel;

                comboBoxIntensity.Text = Math.Round(emotionToEdit.Intensity).ToString();
                comboBoxEmotionType.Text = emotionToEdit.Type;
                textBoxCauseId.Text = emotionToEdit.CauseEventId.ToString();
            }
        }
 public void RemoveEmotion(EmotionDTO emotion)
 {
     var activeEmotion = new ActiveEmotion(emotion, this.DefaultEmotionDisposition.Decay,this.DefaultEmotionDisposition.Threshold);
     string hash = calculateHashString(activeEmotion, m_parent.m_am);
     emotionPool.Remove(hash);
 }