Commit 294c28e3 authored by Georgios Dagkakis's avatar Georgios Dagkakis Committed by Jérome Perrin

objects updated and JSON main script set to read Order and OrderDecomposition objects

parent d0ab96e8
......@@ -99,7 +99,7 @@ def setWIP(entityList):
object=entity.currentStation #identify the object
object.getActiveObjectQueue().append(entity) #append the entity to its Queue
entity.schedule.append([object,now()]) #append the time to schedule so that it can be read in the result
elif entity.type=='Job' or 'OrderComponent':
elif entity.type=='Job' or 'OrderComponent' or 'Order':
object=findObjectById(entity.remainingRoute[0][0]) # find the object in the 'G.ObjList
object.getActiveObjectQueue().append(entity) # append the entity to its Queue
object.receiver=findObjectById(entity.remainingRoute[1][0])
......@@ -107,3 +107,4 @@ def setWIP(entityList):
entity.schedule.append([object,now()]) #append the time to schedule so that it can be read in the result
entity.currentStation=object # update the current station of the entity
......@@ -87,6 +87,8 @@ from M3 import M3
from OrderComponent import OrderComponent
from ScheduledMaintenance import ScheduledMaintenance
from Failure import Failure
from Order import Order
from OrderDecomposition import OrderDecomposition
import ExcelHandler
import time
......@@ -160,6 +162,7 @@ def createObjects():
G.BatchScrapMachineList=[]
G.MachinePreemptiveList=[]
G.QueuePreemptiveList=[]
G.OrderDecompositionList=[]
# -----------------------------------------------------------------------
# loop through all the model resources
......@@ -637,6 +640,13 @@ def createObjects():
G.MachineList.append(OM) # add machine to global MachineList
G.ObjList.append(OM) # add machine to ObjList
elif objClass=='Dream.OrderDecomposition':
id=element.get('id', 'not found')
name=element.get('name', 'not found')
OD=OrderDecomposition(id, name)
G.OrderDecompositionList.append(OD)
G.ObjList.append(OD)
# -----------------------------------------------------------------------
# loop through all the nodes to
# search for Event Generator and create them
......@@ -766,6 +776,7 @@ def createWIP():
G.EntityList=[]
G.PartList=[]
G.OrderComponentList=[]
G.OrderList=[]
json_data = G.JSONData
#Read the json data
......@@ -895,6 +906,52 @@ def createWIP():
object=Globals.findObjectById(element['id'])
P.currentStation=object
if entityClass=='Dream.Order':
id=entity.get('id', 'not found')
name=entity.get('name', 'not found')
priority=int(entity.get('priority', '0'))
dueDate=float(entity.get('dueDate', '0'))
orderDate=float(entity.get('orderDate', '0'))
isCritical=bool(int(entity.get('isCritical', '0')))
basicsEnded=bool(int(entity.get('basicsEnded', '0')))
manager=entity.get('manager', None)
if manager:
for operator in G.OperatorsList:
if manager==operator.id:
manager=operator
break
componentsList=entity.get('componentsList', {})
JSONRoute=entity.get('route', []) # dummy variable that holds the routes of the jobs
# the route from the JSON file
# is a sequence of dictionaries
route = [None for i in range(len(JSONRoute))] # variable that holds the argument used in the Job initiation
# hold None for each entry in the 'route' list
for routeentity in JSONRoute: # for each 'step' dictionary in the JSONRoute
stepNumber=int(routeentity.get('stepNumber', '0')) # get the stepNumber
nextId=routeentity.get('stationId', 'not found') # the stationId
processingTime=routeentity['processingTime'] # and the 'processingTime' dictionary
distributionType=processingTime.get('distributionType', 'not found')# and from that dictionary
# get the 'mean'
mean=float(processingTime.get('mean', 'not found'))
route[stepNumber]=[nextId, mean] # finally add the 'nextId' and 'mean'
# to the job route
# keep a reference of all extra properties passed to the job
extraPropertyDict = {}
for key, value in entity.items():
if key not in ('_class', 'id'):
extraPropertyDict[key] = value
# initiate the Order
O=Order(id, name, route, priority=priority, dueDate=dueDate,
isCritical=isCritical, basicsEnded=basicsEnded, manager=manager, componentsList=componentsList,
orderDate=orderDate, extraPropertyDict=extraPropertyDict)
G.OrderList.append(O)
G.WipList.append(O)
G.EntityList.append(O)
# ===========================================================================
# reads the interruptions of the stations
# ===========================================================================
......
......@@ -26,18 +26,18 @@ Order is an Entity that can have its design, get broken to sub-components
'''
from Globals import G
from Entity import Entity
from Job import Job
# ============================ The Order object ==============================
class Order(Entity):
class Order(Job):
type="Order"
def __init__(self, id=None, name=None, priority=0, dueDate=None, orderDate=None, isCritical=False,
componentsList=[], designTime=0, manager=None, basicsEnded=False):
Entity. __init__(self, id=id, name=name, priority=priority, dueDate=dueDate, orderDate=orderDate)
def __init__(self, id=None, name=None, route=[], priority=0, dueDate=None, orderDate=None, isCritical=False,
componentsList=[], manager=None, basicsEnded=False, extraPropertyDict=None):
Job. __init__(self, id=id, name=name, route=route, priority=priority, dueDate=dueDate, orderDate=orderDate,
extraPropertyDict=extraPropertyDict)
self.isCritical=isCritical
self.componentsList=componentsList
self.designTime=designTime
self.manager=manager
self.basicsEnded=basicsEnded
......
......@@ -43,12 +43,17 @@ from OrderComponent import OrderComponent
class OrderDecomposition(CoreObject):
def __init__(self, id, name):
CoreObject.__init__(self)
self.id=id
self.objName=name
self.type='OrderDecomposition'
def initialize(self):
self.previous=G.ObjList
self.next=G.ObjList
CoreObject.initialize(self) # using the default CoreObject Functionality
self.Res=Resource(infinity) # initialize the Internal resource (Queue) functionality. This is a dummy object so
# infinite capacity is assumed
self.newlyCreatedComponents=[]
#run just waits until there is something to get and gets it
def run(self):
......@@ -66,7 +71,6 @@ class OrderDecomposition(CoreObject):
activeObject=self.getActiveObject()
activeObjectQueue=self.getActiveObjectQueue()
giverObject=self.getGiverObject()
# if we have only one possible giver just check if there is a place,
# the machine is up and the predecessor has an entity to dispose
# this is done to achieve better (cpu) processing time
......@@ -104,9 +108,9 @@ class OrderDecomposition(CoreObject):
activeEntity=activeObjectQueue[0]
import Globals
self.receiver=Globals.findObjectById(activeEntity.remainingRoute[1][0]) #read the next station
self.receiver=Globals.findObjectById(activeEntity.remainingRoute[0][0]) #read the next station
#return True if the OrderDecomposition in the state of disposing and the caller is the receiver
return activeObject.Up and (callerObject is self.receiver)
return self.Up and (callerObject is self.receiver)
#decomposes the order to its components
def decompose(self):
......@@ -117,5 +121,65 @@ class OrderDecomposition(CoreObject):
activeObjectQueue.remove(entity) #remove the order from the internal Queue
#append the components in the internal queue
for component in entity.componentsList:
activeObjectQueue.append(component)
self.createOrderComponent(component)
import Globals
Globals.setWIP(self.newlyCreatedComponents)
self.newlyCreatedComponents=[]
def createOrderComponent(self, component):
id=component.get('id', 'not found')
name=component.get('name', 'not found')
priority=int(component.get('priority', '0'))
dueDate=float(component.get('dueDate', '0'))
orderDate=float(component.get('orderDate', '0'))
isCritical=bool(int(component.get('isCritical', '0')))
JSONRoute=component.get('route', []) # dummy variable that holds the routes of the jobs
# the route from the JSON file
# is a sequence of dictionaries
route = [None for i in range(len(JSONRoute))] # variable that holds the argument used in the Job initiation
# hold None for each entry in the 'route' list
for routeentity in JSONRoute: # for each 'step' dictionary in the JSONRoute
stepNumber=int(routeentity.get('stepNumber', '0')) # get the stepNumber
nextId=routeentity.get('stationId', 'not found') # the stationId
processingTime=routeentity['processingTime'] # and the 'processingTime' dictionary
distributionType=processingTime.get('distributionType', 'not found')# and from that dictionary
# get the 'mean'
mean=float(processingTime.get('mean', 'not found'))
route[stepNumber]=[nextId, mean] # finally add the 'nextId' and 'mean'
# to the job route
# keep a reference of all extra properties passed to the job
extraPropertyDict = {}
for key, value in component.items():
if key not in ('_class', 'id'):
extraPropertyDict[key] = value
#Below it is to assign an exit if it was not assigned in JSON
#have to talk about it with NEX
exitAssigned=False
for element in route:
elementId=element[0]
for obj in G.ObjList:
if obj.id==elementId and obj.type=='Exit':
exitAssigned=True
if not exitAssigned:
exitId=None
for obj in G.ObjList:
if obj.type=='Exit':
exitId=obj.id
break
if exitId:
route.append([exitId, 0])
# initiate the OrderComponent
OC=OrderComponent(id, name, route, priority=priority, dueDate=dueDate,
orderDate=orderDate, extraPropertyDict=extraPropertyDict, isCritical=isCritical)
G.OrderComponentList.append(OC)
G.JobList.append(OC)
G.WipList.append(OC)
G.EntityList.append(OC)
self.newlyCreatedComponents.append(OC)
OC.initialize()
\ 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