public MedicationNode getNextMedRemove() { MedicationNode returnValue = nextMed; nextMed = nextMed.getNextMed(); return(returnValue); }
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); } }
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(); } }
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 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); } }
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); }