Commit 22968359 authored by Ioannis Papagiannopoulos's avatar Ioannis Papagiannopoulos Committed by Jérome Perrin

changes to outputResultJSON of Job and corrections to MouldAssembly/Buffer + OrderDecomposition

parent 680276e7
......@@ -65,6 +65,17 @@ class Job(Entity): # inherits from the Entity c
if self.schedule[-1][0].type=='Exit':
json['results']['completionTime']=self.schedule[-1][1]
completionTime=self.schedule[-1][1]
# TODO
# if the entity is of type Mould and the last object holding it is orderDecomposition
elif self.type=='Order' and self.schedule[-1][0].type=='OrderDecomposition': #
json['results']['completionTime']=self.schedule[-1][1]
completionTime=self.schedule[-1][1]
# TODO : check if there is a need for setting a different 'type' for the MouldAssembly than 'Machine'
# ask Georgios if the method __class__.__name__ of finding the class type of the last step is correct
# if the entity is of type orderComponent and the last step in it's schedule is Assembly
elif self.type=='OrderComponent' and self.schedule[-1][0].__class__.__name__=='MouldAssembly':
json['results']['completionTime']=self.schedule[-1][1]
completionTime=self.schedule[-1][1]
#else input "still in progress"
else:
json['results']['completionTime']="still in progress"
......
......@@ -64,7 +64,7 @@ There is no need to assign an exit, exit is assigned automatically by the create
TODOs: check the case when a mould is already in the WIP by the beginning of the simulation
'''
from MachinePreemptive import MachinePreemptive
from SimPy.Simulation import reactivate, now
from SimPy.Simulation import Resource, reactivate, now
from Globals import G
# =======================================================================
......@@ -77,7 +77,7 @@ class AssembleMouldError(Exception):
# ===========================================================================
# the MachineJobShop object
# ===========================================================================
class MouldAssemble(MachinePreemptive):
class MouldAssembly(MachinePreemptive):
# =======================================================================
# the initialize method
# =======================================================================
......@@ -110,7 +110,7 @@ class MouldAssemble(MachinePreemptive):
capacity = len(activeEntity.order.basicComponentsList\
+activeEntity.order.secondaryComponentsList)
# clear the active object queue
del activeObjectQueue[:]
del activeObject.getActiveObjectQueue()[:]
# and set the capacity of the internal queue of the assembler
activeObject.updateCapacity(capacity)
# append the activeEntity to the activeObjectQueue
......@@ -173,7 +173,9 @@ class MouldAssemble(MachinePreemptive):
# assert that there is a parent order
assert self.mouldParent.type=='Order', 'the type of the assembled to be mould\' s parent is not correct'
# delete the contents of the internal queue
del activeObjectQueue[:]
for element in activeObjectQueue:
activeObjectQueue.remove(element)
# del activeObjectQueue[:]
# after assembling reset the capacity
activeObject.updateCapacity(1)
#if there is a mould to be assembled
......@@ -181,7 +183,7 @@ class MouldAssemble(MachinePreemptive):
if self.mouldParent:
# find the component which is of type Mould
# there must be only one mould component
for entity in mouldParent.componentsList:
for entity in self.mouldParent.componentsList:
entityClass=entity.get('_class', None)
if entityClass=='Dream.Mould':
self.mouldToBeCreated=entity
......@@ -191,6 +193,8 @@ class MouldAssemble(MachinePreemptive):
# set the created mould as WIP
import Globals
Globals.setWIP([self.mouldToBeCreated])
# read the activeObjectQueue again as it has been updated by the setWIP()
activeObjectQueue=activeObject.getActiveObjectQueue()
# reset attributes
self.mouldParent = None
self.mouldToBeCreated = None
......@@ -220,9 +224,9 @@ class MouldAssemble(MachinePreemptive):
route[stepNumber]=routeentity
# assert that the assembler is in the moulds route and update the initial step of the mould's route
firstStep = route.pop(0)
assert self.id in route[0].get('stationIdsList',[]),\
'the assembler must be in the mould-to-be-created route\' initial step'
processingTime=firstStep.get('processingTime','not found')
assert (self.id in firstStep.get('stationIdsList',[])),\
'the assembler must be in the mould-to-be-created route\' initial step'
processingTime=firstStep['processingTime']
# update the activeObject's processing time according to the readings in the mould's route
self.distType=processingTime.get('distributionType','not found')
self.procTime=float(processingTime.get('mean', 0))
......
......@@ -40,7 +40,13 @@ class NoCallerError(Exception):
# the MouldAssemblyBuffer object
# ===========================================================================
class MouldAssemblyBuffer(QueuePreemptive):
# =======================================================================
# the default __init__ method of the QueuePreemptive class
# whereas the default capacity is set to infinity
# =======================================================================
def __init__(self, id, name, capacity=-1, dummy=False, schedulingRule="FIFO"):
QueuePreemptive.__init__(self, id=id, name=name, capacity=capacity, dummy=dummy, schedulingRule=schedulingRule)
# =======================================================================
# Sort the entities of the activeQ
# bring the entities that are ready for assembly to the front
......@@ -75,7 +81,7 @@ class MouldAssemblyBuffer(QueuePreemptive):
# if the activeEntity is of type orderComponent
try:
if activeEntity.componentType=='Basic' or 'Secondary':
activeEntity.readyForAssembly==1
activeEntity.readyForAssembly=1
# check if all the basics have finished being processed in the previous machines
# if the componentType of the activeEntity just received is 'Basic',
# go through the components of its parent order
......
......@@ -37,6 +37,13 @@ from Entity import Entity
from Order import Order
from OrderComponent import OrderComponent
# ===========================================================================
# Error in the setting up of the WIP
# ===========================================================================
class MouldComponentException(Exception):
def __init__(self, mouldException):
Exception.__init__(self, mouldException)
# ===========================================================================
# the Order-Decomposition Object
# ===========================================================================
......@@ -195,10 +202,12 @@ class OrderDecomposition(CoreObject):
#read attributes from the json or from the orderToBeDecomposed
id=component.get('id', 'not found')
name=component.get('name', 'not found')
# there is the case were the component of the componentsList of the parent Order
# is of type Mould and therefore has no argument componentType
# in this case no Mould object should be initiated
try:
# there is the case were the component of the componentsList of the parent Order
# is of type Mould and therefore has no argument componentType
# in this case no Mould object should be initiated
if component.get('_class', 'not found')=='Dream.Mould':
raise MouldComponentException('there is a mould in the componentList')
# variable that holds the componentType which can be Basic/Secondary/Auxiliary
componentType=component.get('componentType', 'Basic')
# the component that needs the auxiliary (if the componentType is "Auxiliary") during its processing
......@@ -210,7 +219,6 @@ class OrderDecomposition(CoreObject):
for routeentity in JSONRoute: # for each 'step' dictionary in the JSONRoute
stepNumber=int(routeentity.get('stepNumber', '0')) # get the stepNumber
# routeentity.pop(str(stepNumber),None) # remove the stepNumber key
route[stepNumber]=routeentity
# keep a reference of all extra properties passed to the job
......@@ -265,8 +273,10 @@ class OrderDecomposition(CoreObject):
G.EntityList.append(OC)
self.newlyCreatedComponents.append(OC) #keep these to pass them to setWIP
OC.initialize() #initialize the component
except:
# added for testing
print 'the component of the order', sefl.orderToBeDecomposed.name, 'is of type Mould\
and thus nothing is created', 'time', now()
except MouldComponentException as mouldException:
pass
# # added for testing
# print 'Mould component exception: {0}'.format(mouldException)
# print 'the component of the order', self.orderToBeDecomposed.name, 'is of type Mould \
# and thus nothing is created', 'time', now()
\ No newline at end of file
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