예제 #1
0
 public ManufacturerTask(ClientAgent client)
 {
     clientAgent = client;
       supplierAgent = null;
       transportAgent = null;
       agents = new List<TaskComparer>();
 }
예제 #2
0
 /// <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;
 }
예제 #3
0
 /// <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;
       }
 }
예제 #4
0
 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;
 }
예제 #5
0
 /// <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;
 }