//for random invoked patients


        public Patient(DateTime arrivedTime, Point location, Injury injury, Bitmap image)
        {
            PatientID   = nextID++;
            ArrivedTime = arrivedTime;
            Location    = location;
            Injury      = injury;
            Image       = image;
        }
Ejemplo n.º 2
0
        public void AddBeds(int nr)
        {
            Point[] bedLocations = new Point[] { new Point((int)(Location.X + SIZE / 10), (int)(Location.Y + SIZE / 10)),
                                                 new Point((int)(Location.X + SIZE - SIZE / 10 - Patient.SIZE), (int)(Location.Y + SIZE / 10)),
                                                 new Point((int)(Location.X + SIZE / 10), (int)(Location.Y + SIZE - SIZE / 10 - Patient.SIZE)),
                                                 new Point((int)(Location.X + SIZE - SIZE / 10 - Patient.SIZE), (int)(Location.Y + SIZE - SIZE / 5 - Patient.SIZE)) };

            for (int i = 0; i < nr; i++)
            {
                // for testing
                Bed bed = new Bed(Injury.GetColor(Category), bedLocations[i], this);
                Beds.Add(bed);
            }
        }
        private void Treat(Patient p)
        {
            Category category = p.Injury.Category;

            TimeSpan[] interval = Injury.GetTimeInterval(category);     //index 0 = min     index 1 = max
            int        seconds  = rnd.Next(interval[0].Seconds, interval[1].Seconds + 1);

            p.Timer          = new TimeSpan(0, 0, seconds);
            p.TreatmentStart = DateTime.Now;

            lock (roomPatientsLock)
            {
                RoomPatients.Add(p);
                p.Room.AddPatient(p);
                p.Managed = true;
            }
        }
        public void AddPatients(int nr, Category category)
        {
            for (int i = 0; i < nr; i++)
            {
                int   x     = rnd.Next(Details.waitingRoomStartLocation.X, Details.waitingRoomEndLocation.X);
                int   y     = rnd.Next(Details.waitingRoomStartLocation.Y, Details.waitingRoomEndLocation.Y);
                Point point = new Point(x, y);

                Injury injury = new Injury(category);
                Bitmap image;

                switch (category)
                {
                case Category.A:
                    image = new Bitmap(Resources.a, Patient.SIZE, Patient.SIZE);
                    break;

                case Category.B:
                    image = new Bitmap(Resources.b, Patient.SIZE, Patient.SIZE);
                    break;

                case Category.C:
                    image = new Bitmap(Resources.c, Patient.SIZE, Patient.SIZE);
                    break;

                default:
                    image = new Bitmap(Resources.d, Patient.SIZE, Patient.SIZE);
                    break;
                }

                Patient p = new Patient(DateTime.Now, point, injury, image);

                lock (allPatientsLock)
                {
                    AllPatients.Add(p);
                }

                lock (DataPatients)
                {
                    DataPatients.Add(p);
                }

                AddPatientToWaitingList(p);
            }
        }