Commit 7e04278a authored by Georgios Dagkakis's avatar Georgios Dagkakis

comment cleanup and allow second as time unit in TimeSupport

parent 19a573e6
...@@ -12,7 +12,9 @@ class TimeSupportMixin(object): ...@@ -12,7 +12,9 @@ class TimeSupportMixin(object):
def initializeTimeSupport(self, data): def initializeTimeSupport(self, data):
self.timeUnit = data['general']['timeUnit'] self.timeUnit = data['general']['timeUnit']
if self.timeUnit == 'minute': if self.timeUnit == 'second':
self.timeUnitPerDay = 24 * 60 * 60
elif self.timeUnit == 'minute':
self.timeUnitPerDay = 24 * 60 self.timeUnitPerDay = 24 * 60
elif self.timeUnit == 'hour': elif self.timeUnit == 'hour':
self.timeUnitPerDay = 24 self.timeUnitPerDay = 24
...@@ -42,12 +44,8 @@ class TimeSupportMixin(object): ...@@ -42,12 +44,8 @@ class TimeSupportMixin(object):
"""Convert real world time (as python datetime object) to simulation clock time. """Convert real world time (as python datetime object) to simulation clock time.
""" """
assert self.initialized, "initializeTimeSupport has not been called" assert self.initialized, "initializeTimeSupport has not been called"
# XXX (real_world_time - self.now).total_seconds() gives seconds # get the seconds difference and divide by (24*60*60/self.timeUnitPerDay)
# we want to convert this to our units (minutes in batches, but generally). # 24*60*60 is timeUnitPerDay if the unit is seconds
# if our time unit was seconds, the timeUnitPerDay would be 24 * 60 *60 = 86400
# so we need to divide with 86400/self.timeUnitPerDay I think. If we have minutes it works
# if we had hours it would be self.timeUnitPerDay = 24, 86400/24=3600, which is what we need to divide a num of secs
# to produce hours
return (real_world_time - self.now).total_seconds()/(86400/self.timeUnitPerDay) return (real_world_time - self.now).total_seconds()/(86400/self.timeUnitPerDay)
def getTimeUnitText(self): def getTimeUnitText(self):
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment