Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
dream
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
1
Issues
1
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
dream
Commits
c68e6eb1
Commit
c68e6eb1
authored
May 19, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updateNext() and preemptReceiver() added to CoreObject
parent
f9071603
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
52 additions
and
38 deletions
+52
-38
dream/simulation/CoreObject.py
dream/simulation/CoreObject.py
+51
-34
dream/simulation/QueueManagedJob.py
dream/simulation/QueueManagedJob.py
+1
-4
No files found.
dream/simulation/CoreObject.py
View file @
c68e6eb1
...
...
@@ -229,44 +229,64 @@ class CoreObject(Process):
# #get the entity from the previous object and put it in front of the activeQ
# activeObjectQueue.append(activeEntity)
#append the time to schedule so that it can be read in the result
#remember that every entity has it's schedule which is supposed to be updated every time
# he entity enters a new object
activeEntity
.
schedule
.
append
([
activeObject
,
now
()])
#update variables
activeEntity
.
currentStation
=
self
self
.
timeLastEntityEntered
=
now
()
self
.
nameLastEntityEntered
=
activeEntity
.
name
# this holds the name of the last entity that got into Machine
self
.
downTimeProcessingCurrentEntity
=
0
# update the next list of the object
activeObject
.
updateNext
(
activeEntity
)
# local variable to inform if the receiver is operated for Loading
receiverOperated
=
False
# perform preemption when required
# if the object is not Exit
# TODO this has to be performed after updating the next list
# TODO: create a method that should check if preemption should be performed
# this should be done after the update of the next list
if
activeObject
.
receiver
:
# if the receiver has an operatorPool and its operationType is Load
try
:
if
activeObject
.
receiver
.
operatorPool
\
and
(
activeObject
.
receiver
.
type
==
'MachineJobShop'
\
or
activeObject
.
receiver
.
type
==
'MachineManagedJob'
):
# and the operationType list contains Load, the receiver is operated
if
(
activeObject
.
receiver
.
operatorPool
!=
"None"
)
\
and
any
(
type
==
"Load"
for
type
in
activeObject
.
receiver
.
multOperationTypeList
):
receiverOperated
=
True
except
:
pass
self
.
outputTrace
(
activeEntity
.
name
,
"got into "
+
self
.
objName
)
self
.
printTrace
(
activeEntity
.
name
,
"got into "
+
self
.
id
)
return
activeEntity
#===========================================================================
# updates the next list of the object
#===========================================================================
def
updateNext
(
self
,
entity
=
None
):
pass
#===========================================================================
# check whether there is a critical entity to be disposed
# and if preemption is required
#===========================================================================
def
preemptReceiver
(
self
):
self
.
printTrace
(
self
.
id
,
'trying to preempt a receiver'
)
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
self
.
getActiveObjectQueue
()
# find a critical order if any
critical
=
False
for
entity
in
activeObjectQueue
:
if
entity
.
isCritical
:
activeEntity
=
entity
critical
=
True
break
if
critical
:
# pick a receiver
receiver
=
next
(
object
for
object
in
activeObject
.
next
if
object
.
isPreemptive
and
object
.
checkIfActive
())
# if there is any receiver that can be preempted check if it is operated
if
receiver
:
receiverOperated
=
False
# local variable to inform if the receiver is operated for Loading
try
:
# TODO: implement preemption for simple machines
if
receiver
.
operatorPool
\
and
(
type
(
receiver
)
is
MachineJobShop
\
or
type
(
receiver
)
is
MachineManagedJob
):
# and the operationType list contains Load, the receiver is operated
if
(
receiver
.
operatorPool
!=
"None"
)
\
and
any
(
type
==
"Load"
for
type
in
receiver
.
multOperationTypeList
):
receiverOperated
=
True
except
:
pass
# if the obtained Entity is critical and the receiver is preemptive and not operated
# in the case that the receiver is operated the preemption is performed by the operators
# if the receiver is not Up then no preemption will be performed
if
activeEntity
.
isCritical
and
activeObject
.
receiver
.
isPreemptive
and
activeObject
.
receiver
.
Up
and
not
receiverOperated
:
if
not
receiverOperated
:
#if the receiver is not empty
if
len
(
self
.
receiver
.
getActiveObjectQueue
())
>
0
:
#if the receiver does not hold an Entity that is also critical
...
...
@@ -275,18 +295,11 @@ class CoreObject(Process):
self
.
printTrace
(
self
.
id
,
'preempting receiver'
+
self
.
receiver
.
id
+
'.. '
*
6
)
self
.
receiver
.
preempt
()
self
.
receiver
.
timeLastEntityEnded
=
now
()
#required to count blockage correctly in the preemptied station
self
.
outputTrace
(
activeEntity
.
name
,
"got into "
+
self
.
objName
)
self
.
printTrace
(
activeEntity
.
name
,
"got into "
+
self
.
id
)
# TODO: sort so that the critical entity is placed in front
activeObjectQueue
.
sort
(
key
=
lambda
x
:
x
==
activeEntity
,
reverse
=
True
)
# update wipStatList
if
self
.
gatherWipStat
:
self
.
wipStatList
.
append
([
now
(),
len
(
activeObjectQueue
)])
return
activeEntity
#===========================================================================
# updates the next list of the object
#===========================================================================
def
updateNext
(
self
,
entity
=
None
):
pass
#===========================================================================
# find possible receivers
...
...
@@ -302,7 +315,7 @@ class CoreObject(Process):
# signal the successor that the object can dispose an entity
# =======================================================================
def
signalReceiver
(
self
):
#
self.printTrace(self.id, 'trying to signal receiver')
self
.
printTrace
(
self
.
id
,
'trying to signal receiver'
)
activeObject
=
self
.
getActiveObject
()
possibleReceivers
=
activeObject
.
findReceivers
()
if
possibleReceivers
:
...
...
@@ -314,6 +327,8 @@ class CoreObject(Process):
if
not
possibleReceivers
:
receiversGiver
=
None
receiver
=
None
# if no receiver can accept then try to preempt a receive if the stations holds a critical order
self
.
preemptReceiver
()
return
False
receiver
=
activeObject
.
selectReceiver
(
possibleReceivers
)
receiversGiver
=
activeObject
...
...
@@ -330,6 +345,8 @@ class CoreObject(Process):
activeObject
.
receiver
.
assignEntryTo
()
activeObject
.
receiver
.
isRequested
.
signal
(
activeObject
)
return
True
# if no receiver can accept then try to preempt a receive if the stations holds a critical order
self
.
preemptReceiver
()
return
False
# =======================================================================
...
...
dream/simulation/QueueManagedJob.py
View file @
c68e6eb1
...
...
@@ -113,10 +113,7 @@ class QueueManagedJob(QueueJobShop):
if
receiver
.
identifyEntityToGet
().
manager
.
isAssignedTo
()
!=
receiver
:
from
Globals
import
G
if
not
G
.
Router
.
invoked
:
#===================================================================
# # TESTING
# print now(), self.id,' '*50, 'signalling router'
#===================================================================
self
.
printTrace
(
self
.
id
,
' '
*
50
+
'signalling router'
)
G
.
Router
.
invoked
=
True
G
.
Router
.
isCalled
.
signal
(
now
())
return
True
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment