public MessageUnit GetMessageUnitFromTask(TaskNode taskNode) { MessageUnit msgUnit; msgUnit = new MessageUnit(); msgUnit.Message = taskNode.Name; msgUnit.Occurrence = taskNode.RecursionCount; // Only task node has interaction property if (taskNode.Type == NODE_TYPE.TASK) { _roleModel.GetRoleFromMessage(msgUnit.Message, ref msgUnit.From, ref msgUnit.To); msgUnit.From = _agentModel.GetAgentFromRole(msgUnit.From); msgUnit.To = _agentModel.GetAgentFromRole(msgUnit.To); } return msgUnit; }
/// <summary> /// MessageReceived event to keep in track of every interaction among constituents in SoS /// </summary> /// <param name="from">A reference object to the sender of the message</param> /// <param name="target">A reference type to the receiver of the message</param> /// <param name="msgText"></param> /// <param name="info"></param> protected override void OnMessageReceived(object from, Type target, string msgText, params object[] info) { MessageUnit entry; entry = new MessageUnit(); // Create MessageUnit using the received message entry.From = from.GetType().Name.ToString(); entry.To = target.Name.ToString(); entry.Message = msgText.ToString(); entry.Cycle = this.Cycle; entry.Parameter = info; // Add current message to the simulation log _simLog.Add(entry); // update visual text if (OnTextUpdate != null) { // Format message as follows: // (SenderAgent->ReceiverAgent).MessageText OnTextUpdate(entry.ToString()); } }