Options.py 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. AUTO_TIME_MODE = 0X01
  2. MANUAL_TIME_MODE = 0x02
  3. MANUAL_STEP_TIME_MODE = 0x03
  4. FAST_TIME_MODE = 0x04
  5. #a list containg the aboves modes so that the option class can do an 'in' check instead of == one by one
  6. #to check the legality of a received mode.
  7. LEGAL_TIME_MODES = [AUTO_TIME_MODE, MANUAL_TIME_MODE, MANUAL_STEP_TIME_MODE, FAST_TIME_MODE]
  8. class Options:
  9. """A class that contains options that should be given trough the interface)"""
  10. def __init__(self,maxIter = 10, mode = AUTO_TIME_MODE, scaleFactor = 1, delta = 0.001):
  11. """
  12. a couple of options
  13. @param maxIter the number or iterations of 1 simulation
  14. @param mode the time mode
  15. @param scaleFactor the scale factor by which to run an iteration default 1
  16. """
  17. self.__max_iter = maxIter
  18. self.setTimeMode(mode)
  19. self.setDeltaT(delta)
  20. if scaleFactor >= 0:
  21. self.__factor = scaleFactor
  22. else:
  23. self.__factor = 1
  24. def setMaxIterations(self, max):
  25. self.__max_iter = max
  26. def getMaxIterations(self):
  27. return self.__max_iter
  28. def setDeltaT(self, delta):
  29. self.__delta = delta
  30. def getDeltaT(self):
  31. return self.__delta
  32. def setScaleFactor(self, factor):
  33. if factor >= 0:
  34. self.__factor = factor
  35. #if value is illegal keep simply keep previous value
  36. def getScaleFactor(self):
  37. return self.__factor
  38. def setTimeMode(self, mode):
  39. """Set the time mode. If it isn't a legal value set it to AUTO_TIME_MODE"""
  40. if (mode in LEGAL_TIME_MODES): #since there is no enumeration in python this is a check to make sure a level has been added and not a random int
  41. self.__mode = mode
  42. else:
  43. self.__mode = AUTO_TIME_MODE
  44. def getTimeMode(self):
  45. return self.__mode