Example #1
0
        public void TimerCallback()
        {
            /*
             * there should be a call back in this method if there is another timer in the same path. It should ask if you would like to start that one next
             * I think this whole method needs to be reworked to have that function correctly thouhgt
             */
            Console.WriteLine("running");
            do
            {
                if (firstTimer != null)
                {
                    if (firstTimer.getNextMed() == null)
                    {
                        timerScanner = firstTimer;
                        while (timerScanner != null)
                        {
                            TimeSpan Delta = DateTime.Now - timerScanner.getStart();
                            timerScanner.setTimeRemaing(timerScanner.getRunTime() - Delta);
                            //Console.WriteLine(timerScanner.getTimeRemaining());
                            if (timerScanner.getTimeRemaining().TotalSeconds <= 0)
                            {
                                Console.WriteLine("Timer " + timerScanner.getMedication().getMedicationName() + " Has Finished");
                                removeTimer(timerScanner);
                            }
                            timerScanner = timerScanner.getNextMed();
                        }
                    }

                    else
                    {
                        timerScanner = firstTimer;
                        while (timerScanner != null)
                        {
                            TimeSpan Delta = DateTime.Now - timerScanner.getStart();
                            timerScanner.setTimeRemaing(timerScanner.getRunTime() - Delta);
                            //Console.WriteLine(timerScanner.getTimeRemaining());
                            if (timerScanner.getTimeRemaining().TotalSeconds <= 0)
                            {
                                Console.WriteLine("Timer " + timerScanner.getMedication().getMedicationName() + " Has Finished");
                                removeTimer(timerScanner);
                            }
                            timerScanner = timerScanner.getNextMed();
                        }
                    }
                }
            } while (true);
        }
        public void TimerCallback()
        {
            Console.WriteLine("running");
            do
            {
                if (firstTimer != null)
                {
                    if (firstTimer.getNextMed() == null)
                    {
                        timerScanner = firstTimer;
                        while (timerScanner != null)
                        {
                            TimeSpan Delta = DateTime.Now - timerScanner.getStart();
                            timerScanner.setTimeRemaing(timerScanner.getRunTime() - Delta);
                            Console.WriteLine(timerScanner.getTimeRemaining());
                            if (timerScanner.getTimeRemaining().TotalSeconds <= 0)
                            {
                                Console.WriteLine("Timer " + timerScanner.getMedication().getMedicationName() + " Has Finished");
                                if (timerScanner.getNextMed() != null)
                                {
                                    timerScanner.getNextMed().setPrevMed(timerScanner.getPrevMed());
                                }

                                if (timerScanner.getPrevMed() != null)
                                {
                                    timerScanner.getPrevMed().setNextMed(timerScanner.getNextMed());
                                }

                                firstTimer = null;
                            }
                            timerScanner = timerScanner.getNextMed();
                        }
                    }

                    else
                    {
                        timerScanner = firstTimer;
                        while (timerScanner != null)
                        {
                            TimeSpan Delta = DateTime.Now - timerScanner.getStart();
                            timerScanner.setTimeRemaing(timerScanner.getRunTime() - Delta);
                            Console.WriteLine(timerScanner.getTimeRemaining());
                            if (timerScanner.getTimeRemaining().TotalSeconds <= 0)
                            {
                                Console.WriteLine("Timer " + timerScanner.getMedication().getMedicationName() + " Has Finished");
                                if (timerScanner.getNextMed() != null)
                                {
                                    timerScanner.getNextMed().setPrevMed(timerScanner.getPrevMed());
                                }

                                if (timerScanner.getPrevMed() != null)
                                {
                                    timerScanner.getPrevMed().setNextMed(timerScanner.getNextMed());
                                }
                            }
                            timerScanner = timerScanner.getNextMed();
                        }
                    }
                }
            } while (true);
        }