checkWip updated so as not to check for WIP when Sources are available

parent 0764df35
...@@ -31,19 +31,27 @@ import os.path ...@@ -31,19 +31,27 @@ import os.path
import Globals import Globals
import ast import ast
SOURCE_TYPE_SET=set(['Dream.Source', 'Dream.BatchSource'])
def checkWIP(): def checkWIP():
'''checks if there is WIP given, if there is no WIP given returns False''' '''checks if there is WIP given, if there is no WIP given returns False'''
# XXX have to check whether it is a JOBSHOP that must have WIP or something else
# if there is source in the model then return true
json_data = G.JSONData json_data = G.JSONData
totalWip=[] totalWip=[]
#Read the json data #Read the json data
nodes = json_data['nodes'] # read from the dictionary the dicts with key 'nodes' nodes = json_data['nodes'] # read from the dictionary the dicts with key 'nodes'
sourcePresent=False
for (element_id, element) in nodes.iteritems(): for (element_id, element) in nodes.iteritems():
type=element.get('_class')
if type in SOURCE_TYPE_SET:
sourcePresent=True
wip=element.get('wip', []) wip=element.get('wip', [])
if wip: if wip:
totalWip.append(wip) totalWip.append(wip)
return len(totalWip)>0 if not sourcePresent:
return len(totalWip)>0
return True
class WIPreadError(Exception): class WIPreadError(Exception):
"""Exception raised for errors in the WIP. """Exception raised for errors in the WIP.
...@@ -276,7 +284,7 @@ def getRouteList(steps_list): ...@@ -276,7 +284,7 @@ def getRouteList(steps_list):
setup_step=None # a step that is of type SETUP setup_step=None # a step that is of type SETUP
next_step=None # the next step of the last SETUP step next_step=None # the next step of the last SETUP step
for j, sequence_step in enumerate(technology_list): for j, sequence_step in enumerate(technology_list):
print j, sequence_step # print j, sequence_step
#======================================================================= #=======================================================================
# check whether the current step is SETUP-step # check whether the current step is SETUP-step
#======================================================================= #=======================================================================
...@@ -370,9 +378,9 @@ def getRouteList(steps_list): ...@@ -370,9 +378,9 @@ def getRouteList(steps_list):
route = {"stationIdsList": successor_list,} route = {"stationIdsList": successor_list,}
route_list.append(route) route_list.append(route)
# XXX INJM-MAN/INJM+INJM-SET must be set as one step of the route, the same stands for the other ***-SET steps # XXX INJM-MAN/INJM+INJM-SET must be set as one step of the route, the same stands for the other ***-SET steps
print '='*90 # print '='*90
print route_list # print route_list
print '='*90 # print '='*90
return route_list return route_list
def getListFromString(self, my_string): def getListFromString(self, my_string):
...@@ -401,9 +409,9 @@ def getComponets(orderDict,Order): ...@@ -401,9 +409,9 @@ def getComponets(orderDict,Order):
id=component.get('componentID','') id=component.get('componentID','')
name=component.get('componentName','') name=component.get('componentName','')
#======================================================================= #=======================================================================
print '* '*50 # print '* '*50
print name, '- '*45 # print name, '- '*45
print '* '*50 # print '* '*50
#======================================================================= #=======================================================================
dictRoute=component.get('route',[]) dictRoute=component.get('route',[])
route = [x for x in dictRoute] # copy dictRoute route = [x for x in dictRoute] # copy dictRoute
...@@ -445,8 +453,8 @@ def getComponets(orderDict,Order): ...@@ -445,8 +453,8 @@ def getComponets(orderDict,Order):
# find the new route of the component if it is no design or mould # find the new route of the component if it is no design or mould
if not mould_step_list and not design_step_list: if not mould_step_list and not design_step_list:
#=================================================================== #===================================================================
print '/^\\'*30 # print '/^\\'*30
print 'normal component' # print 'normal component'
#=================================================================== #===================================================================
route_list=getRouteList(step_list) route_list=getRouteList(step_list)
componentType='Basic' # XXX have to figure out the component type componentType='Basic' # XXX have to figure out the component type
...@@ -457,7 +465,7 @@ def getComponets(orderDict,Order): ...@@ -457,7 +465,7 @@ def getComponets(orderDict,Order):
OC=OrderComponent(id, name, route_list, priority=Order.priority, dueDate=Order.dueDate,orderDate=Order.orderDate, OC=OrderComponent(id, name, route_list, priority=Order.priority, dueDate=Order.dueDate,orderDate=Order.orderDate,
componentType=componentType, order=Order, readyForAssembly=readyForAssembly, componentType=componentType, order=Order, readyForAssembly=readyForAssembly,
isCritical=Order.isCritical, extraPropertyDict=extraPropertyDict) isCritical=Order.isCritical, extraPropertyDict=extraPropertyDict)
print '_'*90,'>', OC.id, 'created' # print '_'*90,'>', OC.id, 'created'
G.OrderComponentList.append(OC) G.OrderComponentList.append(OC)
G.JobList.append(OC) G.JobList.append(OC)
G.WipList.append(OC) G.WipList.append(OC)
...@@ -474,8 +482,8 @@ def getComponets(orderDict,Order): ...@@ -474,8 +482,8 @@ def getComponets(orderDict,Order):
# create to different routes for the design and for the mould (and different entities) # create to different routes for the design and for the mould (and different entities)
if mould_step_list: if mould_step_list:
#=================================================================== #===================================================================
print '/^\\'*30 # print '/^\\'*30
print 'mould' # print 'mould'
#=================================================================== #===================================================================
route_list=getRouteList(mould_step_list) route_list=getRouteList(mould_step_list)
# XXX if the component is not in the WipIDList then do not create it but append it the componentsList of the Order O # XXX if the component is not in the WipIDList then do not create it but append it the componentsList of the Order O
...@@ -495,7 +503,7 @@ def getComponets(orderDict,Order): ...@@ -495,7 +503,7 @@ def getComponets(orderDict,Order):
# initiate the job # initiate the job
M=Mould('M'+id, 'mould'+name, route_list, priority=Order.priority, dueDate=Order.dueDate,orderDate=Order.orderDate, M=Mould('M'+id, 'mould'+name, route_list, priority=Order.priority, dueDate=Order.dueDate,orderDate=Order.orderDate,
isCritical=Order.isCritical, extraPropertyDict=extraPropertyDict, order=Order) isCritical=Order.isCritical, extraPropertyDict=extraPropertyDict, order=Order)
print '_'*90,'>', M.id, 'created' # print '_'*90,'>', M.id, 'created'
G.MouldList.append(M) G.MouldList.append(M)
G.JobList.append(M) G.JobList.append(M)
G.WipList.append(M) G.WipList.append(M)
...@@ -509,8 +517,8 @@ def getComponets(orderDict,Order): ...@@ -509,8 +517,8 @@ def getComponets(orderDict,Order):
Order.componentsList.append(componentDict) Order.componentsList.append(componentDict)
if design_step_list: if design_step_list:
#=================================================================== #===================================================================
print '/^\\'*30 # print '/^\\'*30
print 'design' # print 'design'
#=================================================================== #===================================================================
route_list=getRouteList(design_step_list) route_list=getRouteList(design_step_list)
# XXX if the design is not in the WipIDList then do create if the Order is not being processed at the moment # XXX if the design is not in the WipIDList then do create if the Order is not being processed at the moment
...@@ -521,7 +529,7 @@ def getComponets(orderDict,Order): ...@@ -521,7 +529,7 @@ def getComponets(orderDict,Order):
# initiate the job # initiate the job
OD=OrderDesign(id, name,route_list,priority=Order.priority,dueDate=Order.dueDate,orderDate=Order.orderDate, OD=OrderDesign(id, name,route_list,priority=Order.priority,dueDate=Order.dueDate,orderDate=Order.orderDate,
isCritical=Order.isCritical, order=Order,extraPropertyDict=extraPropertyDict) isCritical=Order.isCritical, order=Order,extraPropertyDict=extraPropertyDict)
print '_'*90,'>', OD.id, 'created' # print '_'*90,'>', OD.id, 'created'
G.OrderComponentList.append(OD) G.OrderComponentList.append(OD)
G.DesignList.append(OD) G.DesignList.append(OD)
G.JobList.append(OD) G.JobList.append(OD)
...@@ -580,16 +588,16 @@ def setStartWip(): ...@@ -580,16 +588,16 @@ def setStartWip():
json_data = G.wip_Data json_data = G.wip_Data
#Read the json data #Read the json data
WIP = json_data['WIP'] # read from the dictionary the dict with key 'WIP' WIP = json_data['WIP'] # read from the dictionary the dict with key 'WIP'
print '/'*200 # print '/'*200
print 'SETTING THE WIP' # print 'SETTING THE WIP'
print '\\'*200 # print '\\'*200
#=========================================================================== #===========================================================================
# OrderDesign type # OrderDesign type
print 'setting desings as wip' # print 'setting desings as wip'
#=========================================================================== #===========================================================================
# for all the entities in the entityList # for all the entities in the entityList
for entity in G.DesignList: for entity in G.DesignList:
print entity.id # print entity.id
# if the entity is not in the WIP dict then move it to the starting station. # if the entity is not in the WIP dict then move it to the starting station.
if not entity.id in WIP.keys(): if not entity.id in WIP.keys():
# perform the default action # perform the default action
...@@ -597,7 +605,7 @@ def setStartWip(): ...@@ -597,7 +605,7 @@ def setStartWip():
# if the entity is in the WIP dict then move it to the station defined. # if the entity is in the WIP dict then move it to the station defined.
elif entity.id in WIP.keys(): elif entity.id in WIP.keys():
objectID=WIP[entity.id]["station"] objectID=WIP[entity.id]["station"]
print objectID # print objectID
assert objectID!='', 'there must be a stationID given to set the WIP' assert objectID!='', 'there must be a stationID given to set the WIP'
from Globals import findObjectById from Globals import findObjectById
object=Globals.findObjectById(objectID) object=Globals.findObjectById(objectID)
...@@ -658,7 +666,7 @@ def setStartWip(): ...@@ -658,7 +666,7 @@ def setStartWip():
G.pendingEntities.append(entity) G.pendingEntities.append(entity)
#=========================================================================== #===========================================================================
# OrderComponent type # OrderComponent type
print 'setting normal components as wip' # print 'setting normal components as wip'
#=========================================================================== #===========================================================================
# for all the entities of Type orderComponent # for all the entities of Type orderComponent
for entity in [x for x in G.OrderComponentList if not x in (G.DesignList+G.MouldList)]: for entity in [x for x in G.OrderComponentList if not x in (G.DesignList+G.MouldList)]:
...@@ -726,7 +734,7 @@ def setStartWip(): ...@@ -726,7 +734,7 @@ def setStartWip():
G.pendingEntities.append(entity) G.pendingEntities.append(entity)
#=========================================================================== #===========================================================================
# Mould type # Mould type
print 'setting mould as wip' # print 'setting mould as wip'
#=========================================================================== #===========================================================================
# for all the entities in the entityList # for all the entities in the entityList
for entity in G.MouldList: for entity in G.MouldList:
...@@ -793,7 +801,7 @@ def setStartWip(): ...@@ -793,7 +801,7 @@ def setStartWip():
def breakOrderDesing(orderDesign): def breakOrderDesing(orderDesign):
'''break down the orderDesign into OrderComponents '''break down the orderDesign into OrderComponents
''' '''
print 'breaking down' # print 'breaking down'
G.newlyCreatedComponents=[] G.newlyCreatedComponents=[]
G.orderToBeDecomposed=None G.orderToBeDecomposed=None
#loop in the internal Queue. Decompose only if an Entity is of type order #loop in the internal Queue. Decompose only if an Entity is of type order
......
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