/// <summary> /// Handles an inform message from the Operator /// </summary> /// <param name="aOperator">The Operator agent that sent the message</param> private void HandleInformMessage(Operator aOperator) { if (post.Content == null) // Operator is Letting me know that it exists switchboard = post.Author; else if (post.Content is Controller) { manager = (Controller)post.Content; communicationNode.AddEdge(((Controller)post.Content).CommunicationNode); } }
public Agent AddNewAgent(AGENT_TYPE agentType, Image image) { Agent newAgent = null; Environment a = this; // Set a random location for the agent RectangleF bounds = device.Graphics.VisibleClipBounds; PointF location = new PointF((float)(bounds.Width * rnd.NextDouble()), (float)(bounds.Height * rnd.NextDouble())); switch (agentType) { case AGENT_TYPE.AGENT_CONTROLLER: { newAgent = new Controller(ref a, ref messageQueue, image, device.Graphics); break; } case AGENT_TYPE.AGENT_OPERATOR: { newAgent = new Operator(ref a, ref messageQueue, image, device.Graphics); break; } case AGENT_TYPE.AGENT_LOGISTICS: { // Logistics Agent newAgent = new TransportAgent(ref a, ref messageQueue, location, agents.Count, image, device.Graphics); break; } case AGENT_TYPE.AGENT_SUPPLIER: { newAgent = new SupplierAgent(ref a, ref messageQueue, location, agents.Count, image, device.Graphics); break; } case AGENT_TYPE.AGENT_MANUFACTURE: { newAgent = new ManufacturerAgent(ref a, ref messageQueue, location, agents.Count, image, device.Graphics); break; } case AGENT_TYPE.AGENT_CLIENT: { newAgent = new ClientAgent(ref a, ref messageQueue, location, agents.Count, image, device.Graphics); break; } } agents.Add(newAgent); if (NewAgent != null) NewAgent(this, ref newAgent); return newAgent; }