Ejemplo n.º 1
0
        void patientDeparture(int hospital)                             //病人离开函数
        {
            //判断实验终止条件,如果已经到达最大服务时间,则不进行处理
            if (currentEvent.occur_time < total_service_time)
            {
                //计算病人总逗留时间
                double stay_time = (currentEvent.occur_time - beds[currentEvent.EventType].getArriveTime());
                total_stay_time += stay_time;
                if (stay_time > max_stay_time)
                {
                    max_stay_time = stay_time;
                }

                //如果队列中还有病人,则立刻对下一位病人进行服务,并生成下一位病人的离开事件
                //优先处理救护车病人
                if (CarPatientQueue.Count > 0)
                {
                    avg_line_car += CarPatientQueue.Count * (currentEvent.occur_time - car_line_time);
                    car_line_time = currentEvent.occur_time;

                    avg_line_total += (CarPatientQueue.Count + SelfPatientQueue.Count) * (currentEvent.occur_time - total_line_time);
                    total_line_time = currentEvent.occur_time;

                    if (CarPatientQueue.Count + SelfPatientQueue.Count > max_line_total)
                    {
                        max_line_total = CarPatientQueue.Count + SelfPatientQueue.Count;
                    }

                    if (CarPatientQueue.Count > max_line_car)
                    {
                        max_line_car = CarPatientQueue.Count;
                    }

                    Patient patient = (Patient)CarPatientQueue[0];
                    CarPatientQueue.RemoveAt(0);
                    beds[currentEvent.EventType].servePatient(patient);       //从队列中取出下一位病人并分配至当前床位

                    double  InterTime  = RandExp(hosInfo[hospital, 1]);       //计算当前病人的治疗时间
                    double  time       = currentEvent.occur_time + InterTime; //计算下一位病人离开事件的发生时间
                    H_Event temp_event = new H_Event(time, currentEvent.EventType);
                    addEvent(events, temp_event);
                }

                else if (SelfPatientQueue.Count > 0)
                {
                    avg_line_self += SelfPatientQueue.Count * (currentEvent.occur_time - self_line_time);
                    self_line_time = currentEvent.occur_time;

                    avg_line_total += (CarPatientQueue.Count + SelfPatientQueue.Count) * (currentEvent.occur_time - total_line_time);
                    total_line_time = currentEvent.occur_time;

                    if (CarPatientQueue.Count + SelfPatientQueue.Count > max_line_total)
                    {
                        max_line_total = CarPatientQueue.Count + SelfPatientQueue.Count;
                    }

                    if (SelfPatientQueue.Count > max_line_self)
                    {
                        max_line_self = SelfPatientQueue.Count;
                    }

                    Patient patient = (Patient)SelfPatientQueue[0];
                    SelfPatientQueue.RemoveAt(0);
                    beds[currentEvent.EventType].servePatient(patient);       //从队列中取出下一位病人并分配至当前床位

                    double  InterTime  = RandExp(hosInfo[hospital, 1]);       //计算当前病人的治疗时间
                    double  time       = currentEvent.occur_time + InterTime; //计算下一位病人离开事件的发生时间
                    H_Event temp_event = new H_Event(time, currentEvent.EventType);
                    addEvent(events, temp_event);
                }

                else
                {
                    beds[currentEvent.EventType].setIdle();
                }
            }
        }
Ejemplo n.º 2
0
 public void servePatient(Patient patient)
 {
     this.patient = patient;
 }