AUTO_TIME_MODE = 0X01 MANUAL_TIME_MODE = 0x02 MANUAL_STEP_TIME_MODE = 0x03 FAST_TIME_MODE = 0x04 #a list containg the aboves modes so that the option class can do an 'in' check instead of == one by one #to check the legality of a received mode. LEGAL_TIME_MODES = [AUTO_TIME_MODE, MANUAL_TIME_MODE, MANUAL_STEP_TIME_MODE, FAST_TIME_MODE] class Options: """A class that contains options that should be given trough the interface)""" def __init__(self,maxIter = 10, mode = AUTO_TIME_MODE, scaleFactor = 1, delta = 0.001): """ a couple of options @param maxIter the number or iterations of 1 simulation @param mode the time mode @param scaleFactor the scale factor by which to run an iteration default 1 """ self.__max_iter = maxIter self.setTimeMode(mode) self.setDeltaT(delta) if scaleFactor >= 0: self.__factor = scaleFactor else: self.__factor = 1 def setMaxIterations(self, max): self.__max_iter = max def getMaxIterations(self): return self.__max_iter def setDeltaT(self, delta): self.__delta = delta def getDeltaT(self): return self.__delta def setScaleFactor(self, factor): if factor >= 0: self.__factor = factor #if value is illegal keep simply keep previous value def getScaleFactor(self): return self.__factor def setTimeMode(self, mode): """Set the time mode. If it isn't a legal value set it to AUTO_TIME_MODE""" 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 self.__mode = mode else: self.__mode = AUTO_TIME_MODE def getTimeMode(self): return self.__mode