public override void SimThink(Sim s) { switch (Action) { case AIMode.Idle: break; case AIMode.Init: lifetime = 0; nextSimAction = SimConsts.time[(int)SimConsts.times.t2]; Action = AIMode.Seek; break; case AIMode.Load: break; case AIMode.Seek: if (nextSimAction > 0) { --nextSimAction; } else if (!rodeElevator) { needRemoval = true; Action = AIMode.Idle; SEQ.Enqueue(new SimEvent(EventType.Idle, s.Time, EventTarg.Person, this.Name, Fl)); if (Fl == floor.first) { s.fl1Q.Enqueue(this); } else { s.fl2Q.Enqueue(this); } } else { SEQ.Enqueue(new SimEvent(EventType.Terminate, s.Time, EventTarg.Person, this.Name, Fl)); needRemoval = true; count--; } break; case AIMode.Unload: break; default: break; } ++lifetime; }
public override void SimThink(Sim s) { switch (Action) { case AIMode.Idle: break; case AIMode.Seek: if (lifetime >= nextSimAction) { Action = AIMode.Unload; SEQ.Enqueue(new SimEvent(EventType.Unload, s.Time, EventTarg.Elevator, this.Name, Fl)); } break; case AIMode.Load: if (Fl == floor.first) { if (s.fl1Q.Count > 0 && occupants.Count < SimConsts.ELEVATOR_CAR_CAPACITY) { Person p = s.fl1Q.Dequeue(); SEQ.Enqueue(new SimEvent(EventType.Load, s.Time, EventTarg.Person, p.Name, Fl)); occupants.Enqueue(p); } else { Fl = floor.second; SEQ.Enqueue(new SimEvent(EventType.Seek, s.Time, EventTarg.Elevator, this.Name, Fl)); Action = AIMode.Seek; nextSimAction = lifetime + SimConsts.time[(int)SimConsts.times.t3]; } } else { if (s.fl2Q.Count > 0 && occupants.Count < SimConsts.ELEVATOR_CAR_CAPACITY) { Person p = s.fl2Q.Dequeue(); SEQ.Enqueue(new SimEvent(EventType.Load, s.Time, EventTarg.Person, p.Name, Fl)); occupants.Enqueue(p); } else { Fl = floor.first; SEQ.Enqueue(new SimEvent(EventType.Seek, s.Time, EventTarg.Elevator, this.Name, Fl)); Action = AIMode.Seek; nextSimAction = lifetime + SimConsts.time[(int)SimConsts.times.t3]; } } break; case AIMode.Unload: if (Fl == floor.first) { if (occupants.Count > 0) { Person p = occupants.Dequeue(); p.postElevatorSeek(); SEQ.Enqueue(new SimEvent(EventType.Unload, s.Time, EventTarg.Person, p.Name, Fl)); s.fl2.AddLast(p); } else { Action = AIMode.Load; SEQ.Enqueue(new SimEvent(EventType.Load, s.Time, EventTarg.Elevator, this.Name, Fl)); } } else { if (occupants.Count > 0) { Person p = occupants.Dequeue(); p.postElevatorSeek(); SEQ.Enqueue(new SimEvent(EventType.Unload, s.Time, EventTarg.Person, p.Name, Fl)); s.fl1.AddLast(p); } else { Action = AIMode.Load; SEQ.Enqueue(new SimEvent(EventType.Load, s.Time, EventTarg.Elevator, this.Name, Fl)); } } break; default: break; } ++lifetime; }