1 package DEOS; 20 21 import gov.nasa.jpf.jvm.Verify; 22 23 24 27 public class PeriodicClock { 28 int microSecsPeriod = 0; 29 int usedTime = 0; 30 int startingPeriodTime = 0; 31 boolean systemInterrupt = false; 32 int special_case_usedTime = 0; 34 39 public PeriodicClock (int periodIn) { 40 microSecsPeriod = periodIn; 41 } 42 43 48 public boolean isInterrupted () { 49 return systemInterrupt; 51 } 52 53 57 public int getPeriod () { 58 return microSecsPeriod; 59 } 60 61 64 public int getTimeToEOP () { 65 return microSecsPeriod - usedTime; 66 } 67 68 72 public void setUsedTime (int usedTimeIn) { 73 usedTime = usedTimeIn; 74 } 75 76 80 public int getUsedTime () { 81 if (systemInterrupt) { 82 return special_case_usedTime; 83 } 84 85 return usedTime; 86 } 87 88 91 public void clearInterrupt () { 92 systemInterrupt = false; 93 resetUsedTime(); 94 } 95 96 101 public void clockTicks (int currentTime) { 102 usedTime = currentTime % microSecsPeriod; 103 104 if (usedTime == 0) { 106 special_case_usedTime = microSecsPeriod; 107 systemInterrupt = true; 108 startingPeriodTime = currentTime; 109 } 110 } 111 112 public void resetUsedTime () { 113 special_case_usedTime = usedTime; 114 } 115 } | Popular Tags |