/// <summary> /// Handle an inform message from the logistics agent. /// </summary> /// <param name="agent">Logistics agent which sent the inform message</param> /// <param name="content">Message contained in the message</param> protected void HandleInformMessage(TransportAgent agent, TransportTask content) { // If the manufacturer agent is the destination then it is a supply delivery // Reset the demand and make a new request env.UpdateStat(STATISTIC.PRODUCTDELIVERED, demand); demand = 0; assignedTask.Status = true; assignedTask = null; }
/// <summary> /// Logistics request. Find an agent that can provide it. /// </summary> /// <param name="manufacturer">The supplier agent making the request</param> private void HandleRequestMessage(Agent author, TransportTask task) { // Request the payoff results from the agents in the environment // which can provide the required service Task lTask = task; Message agentRequest = new RequestMessage(this, ref lTask); messageQueue.SendPost(switchboard, agentRequest); }
/// <summary> /// Handles a logistics agent request. /// </summary> /// <param name="destination">Original agent which made the request</param> /// <param name="task">Logistics task to be assigned</param> private void HandleInformMessage(TransportTask task) { if (task.RegisteredAgents.Count > 0) { // Generate a Supplier task InformMessage i = new InformMessage(this, task); task.Agent = task.RegisteredAgents[0].TaskAgent; // Send the message first to the client messageQueue.SendPost(task.Source, i); // Send the message also to the logistics agent messageQueue.SendPost(task.RegisteredAgents[0].TaskAgent, i); } }
/// <summary> /// When the manufacturer performs a sensor action it will determine the following. /// Is the Manufacturer part of a coordination group with a client agent /// * If so it will determine if it has enough product on hand to supply the client agent /// * If not a failure might have occured, ensure that the missing client is intentional /// If the manufacturer needs stock it will need to coordinate with a supplier, else /// if will need to coordinate with a logistics agent to deliver the product. /// </summary> protected override void Sensor() { // Check if the agent is part of a coordination group if (assignedTask != null) { // Check if the agent has enough product. If so send a request for a logistics // agent. if (product >= ((ManufacturerTask)assignedTask).Demand && ((ManufacturerTask)assignedTask).Transport == null) { // Request a logistics agent to collect the product for the client Task task = new TransportTask(this, ((ManufacturerTask)assignedTask).Client, ((ManufacturerTask)assignedTask).Demand); RequestMessage m = new RequestMessage(this, ref task); messageQueue.SendPost(manager, m); } else if (stock < ((ManufacturerTask)assignedTask).Demand && ((ManufacturerTask)assignedTask).Supplier == null) { // Request a supplier agent to deliver the stock for the manufacturer RequestMessage m = new RequestMessage(this, assignedTask); messageQueue.SendPost(manager, m); } } }
/// <summary> /// Handle an inform message from the logistics agent. /// </summary> /// <param name="agent">Logistics agent which sent the inform message</param> /// <param name="content">Message contained in the message</param> protected void HandleInformMessage(TransportAgent agent, TransportTask content) { // If the manufacturer agent is the destination then it is a supply delivery if (content.Destination.Equals(this)) { stock += content.Load; env.UpdateStat(STATISTIC.STOCKDELIVERED, content.Load); } else { // Transport agent has now collected the stock. The manufacturer agent // is free to handle other requests now. product -= content.Load; env.UpdateStat(STATISTIC.PRODUCTPRODUCEDUSED, content.Load); assignedTask.Status = true; assignedTask = null; } }
/// <summary> /// Handles the response for the transport request /// </summary> /// <param name="agent">Controller agent</param> /// <param name="content">The transport task the manufacturer requested</param> protected void HandleInformMessage(Controller agent, TransportTask content) { ((ManufacturerTask)assignedTask).Transport = content.Agent; }
/// <summary> /// Handles the request for a potential supplier for the manufacturer. /// </summary> /// <param name="author">Controller agent which sent the reply</param> /// <param name="content">A Supplier task with a potential supplier agent provided.</param> private void HandleInformMessage(Controller author, TransportTask content) { coordinationNode.AddEdge(content.Agent.CoordinationNode); communicationNode.AddEdge(content.Agent.CommunicationNode); assignedTask = content; manager = author; }
/// <summary> /// The supplier will check if it has any current tasks that it /// needs to fufill. /// </summary> protected override void Sensor() { if (assignedTask != null) { // Check when the supplier has got enough stock on hand to deliver to the // manufacturer if (supply >= ((SupplierTask)assignedTask).OrderAmount && ((SupplierTask)assignedTask).Transport == null) { // Send a request for a logistics agent to come and collect the order Task task = new TransportTask(this, ((SupplierTask)assignedTask).Manufacturer, ((SupplierTask)assignedTask).OrderAmount); RequestMessage m = new RequestMessage(this, ref task); messageQueue.SendPost(manager, m); } } }
/// <summary> /// Handle an inform message from the logistics agent. The supplier will /// be free for another task after this. /// </summary> /// <param name="agent">Logistics agent which sent the inform message</param> /// <param name="content">Message contained in the message</param> protected void HandleInformMessage(TransportAgent agent, TransportTask content) { if (supply < content.Load) throw new Exception("Supplier can not supply a load when internal stock is less then the demand."); supply -= content.Load; env.UpdateStat(STATISTIC.STOCKSENT, content.Load); assignedTask.Status = true; assignedTask = null; }
/// <summary> /// Informs the Supplier agent that the transport request is completed. /// </summary> /// <param name="author">Controller agent</param> /// <param name="content">Transport Task request</param> protected void HandleInformMessage(Agent author, TransportTask content) { // Update the coordination information ((SupplierTask)assignedTask).Transport = content.RegisteredAgents[0].TaskAgent; communicationNode.AddEdge(content.RegisteredAgents[0].TaskAgent.CommunicationNode); }