Beispiel #1
0
        public override void Execute(BloodBank bloodBank, DonationPoint donationPoint, EventList scheduler,
                                     ref int clock, PatientService patientService)
        {
            Random random = new Random();

            // Planning next accident
            var processTime = random.Next(400, 500);

            Console.WriteLine("Next accident in about " + processTime + " units of time");
            Activate(processTime, ref clock, scheduler);
            //

            // Accident
            if (bloodBank.BloodLevel > donationPoint.GetTK)
            {
                bloodBank.RemoveBlood(donationPoint.GetTK);
                Console.WriteLine("Take blood needed to accident");
                donationPoint.AccidentCounter++;
            }
            else
            {
                Console.WriteLine("Adding patient from accident to queue");
                patientService.Queue.AccidentPatient(donationPoint.GetTK);
                donationPoint.AccidentDeniedCounter++;
            }
            //
        }
Beispiel #2
0
        public override void Execute(BloodBank bloodBank, DonationPoint donationPoint, EventList scheduler,
                                     ref int clock, PatientService patientService)
        {
            //planning next donor
            Random random = new Random();
            int    processTime;

            processTime = random.Next(50, 100);
            Console.WriteLine("NEW DONOR, next donor in about " + processTime + " units of time");
            Activate(processTime, ref clock, scheduler);
            //

            //adding blood to bank
            Console.WriteLine("Increased blood level by 1 unit");
            bloodBank.AddBlood(expTime: clock + donationPoint.GetT2, bloodUnits: 1);
            bloodBank.ShowBloodList();
            Console.WriteLine(bloodBank.BloodLevel);
            Console.WriteLine("Adding blood to list");
            donationPoint.DonorCounter++;
            //

            // Planning time of utilization
            Console.WriteLine("Utilization in about " + donationPoint.GetT2 + " units of time");
            bloodBank.Utilization.Activate(donationPoint.GetT2, ref clock, scheduler);
            //
        }
 public override void Execute(BloodBank bloodBank, DonationPoint donationPoint, EventList scheduler,
                              ref int clock, PatientService patientService)
 {
     // Utilization
     foreach (Blood blood in bloodBank.BloodList.ToList())
     {
         if (clock < blood.ExpTime)
         {
             continue;
         }
         bloodBank.BloodLevel        -= blood.BloodUnits;
         bloodBank.BloodTaken        += blood.BloodUnits;
         donationPoint.UtilizedUnits += blood.BloodUnits;
         bloodBank.BloodList.Remove(blood);
         Console.WriteLine("Utilization of expired blood");
         Console.WriteLine("Decreasing blood level");
     }
 }
Beispiel #4
0
        static void Main(string[] args)
        {
            //INITIALIZING PARAMETRES
            int            clock      = 0;     //System time
            int            systemTime = 10000; //How long we want to simulate system
            Process        current;
            EventList      scheduler      = new EventList();
            PatientService patientService = new PatientService();
            DonationPoint  donationPoint  = new DonationPoint();
            BloodBank      bloodBank      = new BloodBank();
            Donor          donor          = new Donor();
            Accident       accident       = new Accident();

            //patientService.Queue.FillQueue(15);
            //bloodBank.FillBloodList(1);
            bloodBank.Utilization.Activate(300, ref clock, scheduler); //planning utilization
            donationPoint.BloodNeeded = patientService.Queue.BloodQueueDemand;
            patientService.Activate(0, ref clock, scheduler);
            donor.Activate(10, ref clock, scheduler);
            accident.Activate(400, ref clock, scheduler);
            Console.WriteLine("NUMBER OF EVENTS: " + scheduler.eventList.Count + "///////////////////////////");
            bloodBank.SortBloodList();
            bloodBank.ShowBloodList();
            Console.WriteLine(bloodBank.BloodLevel);
            Console.WriteLine();
            patientService.Queue.ShowQueue();
            Console.WriteLine();
            bloodBank.phase = 1;

            Console.WriteLine("Wybierz tryb pracy symulatora:");
            Console.WriteLine("1. Ciagly");
            Console.WriteLine("2. Krokowy");

            bool   check = true;
            string line  = Console.ReadLine();
            int    type  = int.Parse(line);

            if (type == 1 || type == 2)
            {
                while (clock <= systemTime)
                {
                    Console.Write("//////// NEW PROCESS ////////");
                    current = scheduler.GetFirst().Process;
                    clock   = scheduler.GetFirst().EventTime;
                    Console.WriteLine();
                    Console.WriteLine("SYSTEM TIME: " + clock);
                    scheduler.RemoveFirst();
                    Console.WriteLine("NUMBER OF PROCESSES: " + scheduler.eventList.Count);
                    current.Execute(bloodBank, donationPoint, scheduler, ref clock, patientService);
                    Console.WriteLine("/////////////////////////// \n");
                    if (type != 2)
                    {
                        continue;
                    }
                    Console.WriteLine("Wcisnij dowolny klawisz");
                    Console.ReadLine();
                }
            }
            else
            {
                Console.WriteLine("Nie ma takiej opcji!");
                check = false;
            }


            if (!check)
            {
                return;
            }
            Console.WriteLine();
            patientService.Queue.ShowQueue();
            bloodBank.ShowBloodList();
            Console.WriteLine("Blood queue demand: " + patientService.Queue.BloodQueueDemand);
            Console.WriteLine("Blood level: " + bloodBank.BloodLevel);
            Console.WriteLine("SYSTEM TIME: " + clock);
            Console.WriteLine("NUMBER OF PRECESSES LEFT: " + scheduler.eventList.Count);
            Console.WriteLine("SIMPLE ORDERS: " + donationPoint.SimOrderCounter);
            Console.WriteLine("EMERGENCY ORDERS: " + donationPoint.EmOrderCounter);
            Console.WriteLine("ACCIDENTS: " + donationPoint.AccidentCounter);
            Console.WriteLine("ACCIDENT DELAYS: " + donationPoint.AccidentDeniedCounter);
            Console.WriteLine("DONORS: " + donationPoint.DonorCounter);
            Console.WriteLine("PATIENTS: " + donationPoint.PatientCounter);
            Console.WriteLine("BLOOD ADDED: " + bloodBank.BloodAdded);
            Console.WriteLine("BLOOD TAKEN: " + bloodBank.BloodTaken);
            Console.WriteLine("UTILIZED UNITS: " + donationPoint.UtilizedUnits);
        }
Beispiel #5
0
 public virtual void Execute(BloodBank bloodBank, DonationPoint donationPoint, EventList eventList, ref int clock, PatientService patientService)
 {
 }