Commit 0d0b517a authored by panos's avatar panos

A bug fixed in this script

parent 2db09441
...@@ -39,13 +39,13 @@ class DateTimeConvert(plugin.InputPreparationPlugin, TimeSupportMixin): ...@@ -39,13 +39,13 @@ class DateTimeConvert(plugin.InputPreparationPlugin, TimeSupportMixin):
timeIn = entity.pop('timeIn', 'NA') timeIn = entity.pop('timeIn', 'NA')
if not timeIn=='NA': if not timeIn=='NA':
timeIn = strptime(timeIn, '%Y-%m-%d %H:%M:%S') timeIn = strptime(timeIn, '%Y-%m-%d %H:%M:%S')
print timeIn
if timeOut: if timeOut:
entity['remainingProcessingTime'] = 0 entity['remainingProcessingTime'] = 0
else: else:
#calculate the time difference between the TIMEIN and the moment the user wants to run the simulation (e.g. datetime.now()) #calculate the time difference between the TIMEIN and the moment the user wants to run the simulation (e.g. datetime.now())
print type(now)
print type(timeIn)
timeDelta= now - timeIn timeDelta= now - timeIn
print timeDelta
if self.timeUnit == 'second': if self.timeUnit == 'second':
timeDiff = timeDelta.total_seconds() #24 * 60 * 60 timeDiff = timeDelta.total_seconds() #24 * 60 * 60
elif self.timeUnit == 'minute': elif self.timeUnit == 'minute':
...@@ -62,7 +62,7 @@ class DateTimeConvert(plugin.InputPreparationPlugin, TimeSupportMixin): ...@@ -62,7 +62,7 @@ class DateTimeConvert(plugin.InputPreparationPlugin, TimeSupportMixin):
timeDiff = timeDelta.total_seconds()/(60*60*24*7*30*360) #1 / 360. timeDiff = timeDelta.total_seconds()/(60*60*24*7*30*360) #1 / 360.
else: else:
raise ValueError("Unsupported time unit %s" % self.timeUnit) raise ValueError("Unsupported time unit %s" % self.timeUnit)
print timeDiff
for order in orders: for order in orders:
comps = order.get('componentsList', []) comps = order.get('componentsList', [])
for comp in comps: for comp in comps:
...@@ -70,14 +70,13 @@ class DateTimeConvert(plugin.InputPreparationPlugin, TimeSupportMixin): ...@@ -70,14 +70,13 @@ class DateTimeConvert(plugin.InputPreparationPlugin, TimeSupportMixin):
for step in comp.get('route', []): for step in comp.get('route', []):
if step.get('task_id', None) == task_id: if step.get('task_id', None) == task_id:
proc_time = step.get('processingTime', {}).get('Fixed',{}).get('mean', 0) proc_time = step.get('processingTime', {}).get('Fixed',{}).get('mean', 0)
print proc_time
break break
if proc_time: if proc_time:
break break
if proc_time: if proc_time:
break break
#calculate the remaining time the part needs to be processed #calculate the remaining time the part needs to be processed
entity['remainingProcessingTime']= round((proc_time - timeDiff),2) entity['remainingProcessingTime']= max([round((proc_time - timeDiff),2),0.1])
for order in orders: for order in orders:
orderDate = order.get('orderDate', None) orderDate = order.get('orderDate', None)
......
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