MachineManagedJob and MouldAssembly updated

parent 3cacf8ad
......@@ -319,7 +319,7 @@ class CoreObject(object):
#if the receiver does not hold an Entity that is also critical
if not receiver.Res.users[0].isCritical:
receiver.shouldPreempt=True
# self.printTrace(self.id, preempt=receiver.id)
self.printTrace(self.id, preempt=receiver.id)
receiver.preempt()
receiver.timeLastEntityEnded=self.env.now #required to count blockage correctly in the preemptied station
# sort so that the critical entity is placed in front
......
......@@ -26,7 +26,8 @@ inherits from MachineJobShop. The difference is that it reads the operator from
checks if he is available before it takes it
'''
from SimPy.Simulation import Process, Resource, activate, now
# from SimPy.Simulation import Process, Resource, activate, now
import simpy
from OperatedPoolBroker import Broker
from OperatorPool import OperatorPool
......@@ -54,13 +55,15 @@ class MachineManagedJob(MachineJobShop):
self.operatorPool.operators=[]
#create a Broker
self.broker = Broker(self)
activate(self.broker,self.broker.run())
self.env.process(self.broker.run())
# activate(self.broker,self.broker.run())
#create a Router
# TODO: this is already performed in __init__ of Machine
from Globals import G
if not G.Router:
self.router=Router()
activate(self.router,self.router.run())
self.env.process(self.router.run())
# activate(self.router,self.router.run())
G.Router=self.router
# otherwise set the already existing router as the machines Router
else:
......@@ -189,4 +192,3 @@ class MachineManagedJob(MachineJobShop):
# maybe we should work this way in all CoreObjects???
return self.entityToGet
......@@ -62,7 +62,8 @@ 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 MachineManagedJob import MachineManagedJob
from SimPy.Simulation import Resource, reactivate, now
# from SimPy.Simulation import Resource, reactivate, now
import simpy
from Globals import G
# =======================================================================
......@@ -151,7 +152,7 @@ class MouldAssembly(MachineManagedJob):
def updateCapacity(self,capacity):
activeObject = self.getActiveObject()
self.capacity = capacity
self.Res=Resource(self.capacity)
self.Res=simpy.Resource(self.env, self.capacity)
# =======================================================================
# assemble method that assembles the components together to a mould (order
......@@ -271,6 +272,6 @@ class MouldAssembly(MachineManagedJob):
M.initialize()
except:
# added for testing
print 'the mould to be created', component.get('name', 'not found'), 'cannot be created', 'time', now()
print 'the mould to be created', component.get('name', 'not found'), 'cannot be created', 'time', self.env.now
raise
\ 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