示例#1
0
        public float TimeSpent(CommunicationMediums messageType, bool send, byte randomLevelValue)
        {
            switch (messageType)
            {
            case CommunicationMediums.Irc:
                return(send ? Irc.CostToSend(randomLevelValue) : Irc.CostToReceive(randomLevelValue));

            case CommunicationMediums.Email:
                return(send ? Email.CostToSend(randomLevelValue) : Email.CostToReceive(randomLevelValue));

            case CommunicationMediums.Phone:
                return(send ? Phone.CostToSend(randomLevelValue) : Phone.CostToReceive(randomLevelValue));

            case CommunicationMediums.Meeting:
                return(send ? Meeting.CostToSend(randomLevelValue) : Meeting.CostToReceive(randomLevelValue));

            case CommunicationMediums.FaceToFace:
                return(send ? FaceToFace.CostToSend(randomLevelValue) : FaceToFace.CostToReceive(randomLevelValue));

            case CommunicationMediums.ViaAPlatform:
                return(send
                        ? Platform.CostToSend(randomLevelValue)
                        : Platform.CostToReceive(randomLevelValue));

            case CommunicationMediums.System:
                return(0);

            default:
                throw new NotImplementedException();
            }
        }
示例#2
0
        public void Reply(IAgentId receiverId, MessageAction action, byte content, MessageAttachments parameter,
                          CommunicationMediums communicationMedium)
        {
            var message = new Message(AgentId, receiverId, action, content, parameter, communicationMedium);

            Reply(message);
        }
示例#3
0
        public CommunicationTemplate TemplateFromChannel(CommunicationMediums channel)
        {
            switch (channel)
            {
            case CommunicationMediums.Irc:
                return(Irc);

            case CommunicationMediums.Email:
                return(Email);

            case CommunicationMediums.Phone:
                return(Phone);

            case CommunicationMediums.Meeting:
                return(Meeting);

            case CommunicationMediums.FaceToFace:
                return(FaceToFace);

            case CommunicationMediums.ViaAPlatform:
                return(Platform);

            case CommunicationMediums.System:
                return(null);

            default:
                throw new ArgumentOutOfRangeException(nameof(channel), channel, null);
            }
        }
示例#4
0
        public void AskOnWhichChannelTest1()
        {
            const CommunicationMediums mediums = CommunicationMediums.Email | CommunicationMediums.FaceToFace;
            var result = CommunicationMediumsModel.NextMedium(mediums);

            Assert.IsTrue(result == CommunicationMediums.Email || result == CommunicationMediums.FaceToFace);
        }
示例#5
0
 public void CountTest()
 {
     Assert.AreEqual(0, CommunicationMediumsModel.Count(_messages));
     _messages |= CommunicationMediums.Email;
     Assert.AreEqual(1, CommunicationMediumsModel.Count(_messages));
     _messages |= CommunicationMediums.ViaAPlatform;
     Assert.AreEqual(2, CommunicationMediumsModel.Count(_messages));
 }
示例#6
0
        /// <summary>
        ///     Common method to reply help for Murphy type MurphyIncomplete (Knowledge, Information, Beliefs)
        /// </summary>
        /// <param name="task"></param>
        /// <param name="blocker"></param>
        /// <param name="medium"></param>
        /// <param name="internalHelp"></param>
        public void ReplyHelpIncomplete(SymuTask task, Blocker blocker, CommunicationMediums medium, bool internalHelp)
        {
            if (task == null)
            {
                throw new ArgumentNullException(nameof(task));
            }

            // Take some time to learn, allocate this time on KeyActivity
            ImpactOfTheCommunicationMediumOnTimeSpent(medium, false, task.KeyActivity);
            task.Recover(blocker, internalHelp ? BlockerResolution.Internal : BlockerResolution.External);
        }
示例#7
0
文件: Message.cs 项目: lmorisse/Symu
        public Message(IAgentId senderId, IAgentId receiverId, MessageAction action, byte subject,
                       MessageAttachments attachments, CommunicationMediums medium)
            : this(senderId, receiverId, action, subject, medium)
        {
            if (attachments == null)
            {
                return;
            }

            Attachments = attachments;
        }
示例#8
0
 public void ToArrayTest()
 {
     Assert.AreEqual(0, CommunicationMediumsModel.ToArray(_messages).Length);
     _messages |= CommunicationMediums.Email;
     Assert.AreEqual(1, CommunicationMediumsModel.ToArray(_messages).Length);
     Assert.AreEqual(CommunicationMediums.Email,
                     (CommunicationMediums)CommunicationMediumsModel.ToArray(_messages)[0]);
     _messages |= CommunicationMediums.ViaAPlatform;
     Assert.AreEqual(2, CommunicationMediumsModel.ToArray(_messages).Length);
     Assert.AreEqual(CommunicationMediums.ViaAPlatform,
                     (CommunicationMediums)CommunicationMediumsModel.ToArray(_messages)[1]);
 }
示例#9
0
文件: Message.cs 项目: lmorisse/Symu
        public Message(IAgentId senderId, IAgentId receiverId, MessageAction action, byte subject, object attachment,
                       CommunicationMediums medium)
            : this(senderId, receiverId, action, subject, medium)
        {
            if (attachment == null)
            {
                return;
            }

            Attachments = new MessageAttachments();
            Attachments.Add(attachment);
        }
示例#10
0
        public void AskOnWhichChannelTest1()
        {
            var mediums = new CommunicationMediums();

            mediums |= CommunicationMediums.ViaAPlatform;
            var medium = CommunicationMediumsModel.NextMedium(mediums);

            Assert.IsTrue(medium == CommunicationMediums.ViaAPlatform);
            mediums |= CommunicationMediums.Email;
            medium   = CommunicationMediumsModel.NextMedium(mediums);
            Assert.IsTrue(medium == CommunicationMediums.Email || medium == CommunicationMediums.ViaAPlatform);
        }
示例#11
0
        public void SendToMany(IEnumerable <IAgentId> receivers, MessageAction action, byte content,
                               MessageAttachments parameter, CommunicationMediums communicationMedium)
        {
            if (receivers is null)
            {
                return;
            }

            foreach (var a in receivers.Shuffle())
            {
                Send(a, action, content, parameter, communicationMedium);
            }
        }
示例#12
0
        /// <summary>
        ///     an agent ask for help, but he can choose different mediums like email, phone, ...
        /// </summary>
        /// <returns></returns>
        public static CommunicationMediums NextMedium(CommunicationMediums mediums)
        {
            var count = Count(mediums);

            if (count == 0)
            {
                return(CommunicationMediums.System);
            }

            var index    = DiscreteUniform.SampleToByte(count - 1);
            var channels = ToArray(mediums);

            return((CommunicationMediums)channels[index]);
        }
示例#13
0
        /// <summary>
        ///     Impact of the Communication channels on the time spent
        ///     Allocate this time on the keyActivity
        /// </summary>
        /// <param name="medium"></param>
        /// <param name="keyActivity">the keyActivity activity of the task, to track TimeSpent</param>
        /// <param name="send">If set, it is an ask help task, otherwise it is a reply help task</param>
        /// <remarks>Impact on capacity is done in OnBeforeSendMessage and OnAfterPostMessage</remarks>
        public void ImpactOfTheCommunicationMediumOnTimeSpent(CommunicationMediums medium, bool send,
                                                              IAgentId keyActivity)
        {
            if (keyActivity == null || keyActivity.IsNull)
            {
                return;
            }

            var impact =
                Environment.MainOrganization.Communication.TimeSpent(medium, send,
                                                                     Environment.RandomLevelValue);

            AddTimeSpent(keyActivity, impact);
        }
示例#14
0
        private bool SelectNextMessage(CommunicationMediums medium, out SymuTask symuTask)
        {
            if (ToDo.Exists(t => t.Type == medium.ToString()))
            {
                var task = ToDo.Find(t => t.Type == medium.ToString());
                SetInProgress(task);
                {
                    symuTask = task;
                    return(true);
                }
            }

            symuTask = null;
            return(false);
        }
示例#15
0
        /// <summary>
        ///     Increment numberMessagesPerPeriod if the message is not a system message
        /// </summary>
        /// <param name="messageType"></param>
        /// <param name="sentMessage">if set message is a posted message, otherwise it's a received message</param>
        public void IncrementMessagesPerPeriod(CommunicationMediums messageType, bool sentMessage)
        {
            if (messageType == CommunicationMediums.System || NumberMessagesPerStep >= ushort.MaxValue)
            {
                return;
            }

            NumberMessagesPerStep++;
            if (sentMessage)
            {
                NumberSentPerPeriod++;
            }
            else
            {
                NumberReceivedPerPeriod++;
            }
        }
示例#16
0
        public static int[] ToArray(CommunicationMediums messageTypes)
        {
            var array = new int[Count(messageTypes)];
            var index = 0;

            if (messageTypes.HasFlag(CommunicationMediums.Irc))
            {
                array[index] = (int)CommunicationMediums.Irc;
                index++;
            }

            if (messageTypes.HasFlag(CommunicationMediums.Email))
            {
                array[index] = (int)CommunicationMediums.Email;
                index++;
            }

            if (messageTypes.HasFlag(CommunicationMediums.Phone))
            {
                array[index] = (int)CommunicationMediums.Phone;
                index++;
            }

            if (messageTypes.HasFlag(CommunicationMediums.Meeting))
            {
                array[index] = (int)CommunicationMediums.Meeting;
                index++;
            }

            if (messageTypes.HasFlag(CommunicationMediums.FaceToFace))
            {
                array[index] = (int)CommunicationMediums.FaceToFace;
                index++;
            }

            if (messageTypes.HasFlag(CommunicationMediums.ViaAPlatform))
            {
                array[index] = (int)CommunicationMediums.ViaAPlatform;
            }

            return(array);
        }
示例#17
0
        public CommunicationMediums Get(Int64 ixCommunicationMedium)
        {
            CommunicationMediums communicationmediums = _context.CommunicationMediums.AsNoTracking().Where(x => x.ixCommunicationMedium == ixCommunicationMedium).First();

            return(communicationmediums);
        }
示例#18
0
 public static int Count(CommunicationMediums messageTypes)
 {
     return(new BitArray(new[] { (int)messageTypes }).OfType <bool>().Count(x => x));
 }
示例#19
0
文件: Message.cs 项目: lmorisse/Symu
 /// <summary>
 ///     Initializes a new instance of the Message class.
 /// </summary>
 /// <param name="senderId">The name of the agent that sends the message</param>
 /// <param name="receiverId">The name of the agent that needs to receive the message</param>
 /// <param name="action"></param>
 /// <param name="subject">The subject of the message</param>
 /// <param name="medium"></param>
 public Message(IAgentId senderId, IAgentId receiverId, MessageAction action, byte subject,
                CommunicationMediums medium) : this(senderId, receiverId, action, subject)
 {
     Medium = medium;
 }
示例#20
0
        public void AskOnWhichChannelTest()
        {
            const CommunicationMediums mediums = new CommunicationMediums();

            Assert.AreEqual(CommunicationMediums.System, CommunicationMediumsModel.NextMedium(mediums));
        }
示例#21
0
        public void Send(IAgentId receiverId, MessageAction action, byte content, CommunicationMediums mediums)
        {
            var message = new Message(AgentId, receiverId, action, content, mediums);

            Send(message);
        }