コード例 #1
0
        public MedicationNode getNextMedRemove()
        {
            MedicationNode returnValue = nextMed;

            nextMed = nextMed.getNextMed();
            return(returnValue);
        }
コード例 #2
0
 public pathNode(pathNode nextPathX, pathNode prevPathX, String pathNameX)
 {
     nextPath   = nextPathX;
     prevPath   = prevPathX;
     pathName   = pathNameX;
     medScanner = null;
 }
コード例 #3
0
        public void removeTimer(MedicationNode toRemove)
        {
            if (!toRemove.Equals(firstTimer))
            {
                if (toRemove.getNextMed() != null)
                {
                    toRemove.getNextMed().setPrevMed(toRemove.getPrevMed());
                }

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

            else
            {
                if (toRemove.getNextMed() != null)
                {
                    toRemove.getNextMed().setPrevMed(null);
                }

                firstTimer = toRemove.getNextMed();
            }
        }
コード例 #4
0
 public pathNode()
 {
     nextPath   = null;
     prevPath   = null;
     pathName   = null;
     medScanner = null;
 }
コード例 #5
0
        public counter()
        {
            Thread burner = new Thread(() => TimerCallback());             //Lambda thread?? I don't know I asked the internet and it works, leave off. I'll read more about it later.

            burner.Start();
            firstTimer   = null;
            timerScanner = null;
        }
コード例 #6
0
 public MedicationNode()
 {
     treatmentTime = 0;
     nextMed       = null;
     prevMed       = null;
     medication    = null;
     meds          = new medicationControl();
 }
コード例 #7
0
        public void removeNode()
        {
            if (this.nextMed != null)
            {
                this.nextMed.prevMed = this.prevMed;
            }

            if (this.prevMed != null)
            {
                this.prevMed.nextMed = this.nextMed;
            }
        }
コード例 #8
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);
        }
コード例 #9
0
        public void addMedication(double treatmentTime, medication medToAdd)
        {
            if (nextMed != null)
            {
                medScanner = nextMed;
                while (nextMed.getNextMed() != null)
                {
                    medScanner = medScanner.getNextMed();
                }

                medScanner.addMedicationNode(treatmentTime, medToAdd);
            }

            else
            {
                nextMed = new MedicationNode(treatmentTime, medToAdd);
            }
        }
コード例 #10
0
 public void addTimer(MedicationNode timerToAdd)
 {
     if (firstTimer == null)
     {
         firstTimer = timerToAdd;
         timerToAdd.calculateEndTime();
         timerToAdd.removeNode();
         firstTimer.setNextMed(null);
         firstTimer.setPrevMed(null);
     }
     else
     {
         timerScanner = firstTimer;
         while (timerScanner.getNextMed() != null)
         {
             timerScanner = timerScanner.getNextMed();
         }
         timerScanner.setNextMed(timerToAdd);
         timerToAdd.setNextMed(timerScanner);
     }
 }
コード例 #11
0
        public MedicationNode(double treatmentTimeX, MedicationNode nextMedX, MedicationNode prevMedX, medication medicationX)
        {
            if (treatmentTimeX >= 0)
            {
                treatmentTime = treatmentTimeX;
            }

            if (nextMedX != null)
            {
                nextMed = nextMedX;
            }

            if (prevMedX != null)
            {
                prevMed = prevMedX;
            }
            if (medicationX != null)
            {
                medication = medicationX;
            }
            meds = new medicationControl();
        }
コード例 #12
0
 public void setPrevMed(MedicationNode prevMedX)
 {
     prevMed = prevMedX;
 }
コード例 #13
0
 public void setNextMed(MedicationNode nextMedX)
 {
     nextMed = nextMedX;
 }
コード例 #14
0
 public void addMedicationNode()
 {
     this.nextMed = new MedicationNode();
     this.nextMed.setPrevMed(this);
 }
コード例 #15
0
 public void addMedicationNode(double treatmentTime, medication medication)
 {
     this.nextMed = new MedicationNode(treatmentTime, medication);
     this.nextMed.setPrevMed(this);
 }
コード例 #16
0
 public void addMedicationNode(MedicationNode medToAdd)
 {
     this.nextMed         = medToAdd;
     this.nextMed.prevMed = this;
 }
コード例 #17
0
        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);
        }