public override void inAct() { pastTime.Enqueue(getTcurr()); Pacient pacient = null; double minT = double.MaxValue; Random rand = new Random(); double num = rand.NextDouble(); // ----------- Select the type ----------------- if (num > 0 && num <= 0.5) { pacient = new Pacient(Type.First); } if (num > 0.5 && num <= 0.6) { pacient = new Pacient(Type.Second); } if (num > 0.6 && num <= 1) { pacient = new Pacient(Type.Third); } // ---------------------------------------------- for (int i = 0; i < Devices.Count; i++) { if (Devices[i].getState() == 0) { Devices[i].setState(1); Devices[i].setTnext(base.getTcurr() + base.getDelay()); Devices[i].setType((int)pacient.Type); foreach (var x in Devices) { if (minT > x.getTnext() && x.getState() == 1) { minT = x.getTnext(); } } base.setTnext(minT); base.setZeroToMax(); return; } } if (getQueue().Count < getMaxqueue()) { addToQueue(pacient); } else { failure++; } }
public void inActFromLab(double time) { pastTime.Enqueue(time); Pacient pacient = new Pacient(Type.First); double minT = double.MaxValue; for (int i = 0; i < Devices.Count; i++) { if (Devices[i].getState() == 0) { Devices[i].setState(1); Devices[i].setTnext(base.getTcurr() + base.getDelay()); Devices[i].setType((int)pacient.Type); foreach (var x in Devices) { if (minT > x.getTnext() && x.getState() == 1) { minT = x.getTnext(); } } base.setTnext(minT); base.setZeroToMax(); return; } } if (getQueue().Count < getMaxqueue()) { addToQueue(pacient); } else { failure++; } }
public void addToQueue(Pacient item) { this.queue.Enqueue(item); }