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
Show 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):
...
@@ -229,44 +229,64 @@ class CoreObject(Process):
# #get the entity from the previous object and put it in front of the activeQ
# #get the entity from the previous object and put it in front of the activeQ
# activeObjectQueue.append(activeEntity)
# activeObjectQueue.append(activeEntity)
#append the time to schedule so that it can be read in the result
#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
#remember that every entity has it's schedule which is supposed to be updated every time
# he entity enters a new object
# he entity enters a new object
activeEntity
.
schedule
.
append
([
activeObject
,
now
()])
activeEntity
.
schedule
.
append
([
activeObject
,
now
()])
#update variables
#update variables
activeEntity
.
currentStation
=
self
activeEntity
.
currentStation
=
self
self
.
timeLastEntityEntered
=
now
()
self
.
timeLastEntityEntered
=
now
()
self
.
nameLastEntityEntered
=
activeEntity
.
name
# this holds the name of the last entity that got into Machine
self
.
nameLastEntityEntered
=
activeEntity
.
name
# this holds the name of the last entity that got into Machine
self
.
downTimeProcessingCurrentEntity
=
0
self
.
downTimeProcessingCurrentEntity
=
0
# update the next list of the object
# update the next list of the object
activeObject
.
updateNext
(
activeEntity
)
activeObject
.
updateNext
(
activeEntity
)
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
()
# local variable to inform if the receiver is operated for Loading
# find a critical order if any
receiverOperated
=
False
critical
=
False
# perform preemption when required
for
entity
in
activeObjectQueue
:
# if the object is not Exit
if
entity
.
isCritical
:
# TODO this has to be performed after updating the next list
activeEntity
=
entity
# TODO: create a method that should check if preemption should be performed
critical
=
True
# this should be done after the update of the next list
break
if
activeObject
.
receiver
:
if
critical
:
# if the receiver has an operatorPool and its operationType is Load
# 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
:
try
:
if
activeObject
.
receiver
.
operatorPool
\
# TODO: implement preemption for simple machines
and
(
activeObject
.
receiver
.
type
==
'MachineJobShop'
\
if
receiver
.
operatorPool
\
or
activeObject
.
receiver
.
type
==
'MachineManagedJob'
):
and
(
type
(
receiver
)
is
MachineJobShop
\
or
type
(
receiver
)
is
MachineManagedJob
):
# and the operationType list contains Load, the receiver is operated
# and the operationType list contains Load, the receiver is operated
if
(
activeObject
.
receiver
.
operatorPool
!=
"None"
)
\
if
(
receiver
.
operatorPool
!=
"None"
)
\
and
any
(
type
==
"Load"
for
type
in
activeObject
.
receiver
.
multOperationTypeList
):
and
any
(
type
==
"Load"
for
type
in
receiver
.
multOperationTypeList
):
receiverOperated
=
True
receiverOperated
=
True
except
:
except
:
pass
pass
# if the obtained Entity is critical and the receiver is preemptive and not operated
# 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
# 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 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 the receiver is not empty
if
len
(
self
.
receiver
.
getActiveObjectQueue
())
>
0
:
if
len
(
self
.
receiver
.
getActiveObjectQueue
())
>
0
:
#if the receiver does not hold an Entity that is also critical
#if the receiver does not hold an Entity that is also critical
...
@@ -275,18 +295,11 @@ class CoreObject(Process):
...
@@ -275,18 +295,11 @@ class CoreObject(Process):
self
.
printTrace
(
self
.
id
,
'preempting receiver'
+
self
.
receiver
.
id
+
'.. '
*
6
)
self
.
printTrace
(
self
.
id
,
'preempting receiver'
+
self
.
receiver
.
id
+
'.. '
*
6
)
self
.
receiver
.
preempt
()
self
.
receiver
.
preempt
()
self
.
receiver
.
timeLastEntityEnded
=
now
()
#required to count blockage correctly in the preemptied station
self
.
receiver
.
timeLastEntityEnded
=
now
()
#required to count blockage correctly in the preemptied station
self
.
outputTrace
(
activeEntity
.
name
,
"got into "
+
self
.
objName
)
# TODO: sort so that the critical entity is placed in front
self
.
printTrace
(
activeEntity
.
name
,
"got into "
+
self
.
id
)
activeObjectQueue
.
sort
(
key
=
lambda
x
:
x
==
activeEntity
,
reverse
=
True
)
# update wipStatList
# update wipStatList
if
self
.
gatherWipStat
:
if
self
.
gatherWipStat
:
self
.
wipStatList
.
append
([
now
(),
len
(
activeObjectQueue
)])
self
.
wipStatList
.
append
([
now
(),
len
(
activeObjectQueue
)])
return
activeEntity
#===========================================================================
# updates the next list of the object
#===========================================================================
def
updateNext
(
self
,
entity
=
None
):
pass
#===========================================================================
#===========================================================================
# find possible receivers
# find possible receivers
...
@@ -302,7 +315,7 @@ class CoreObject(Process):
...
@@ -302,7 +315,7 @@ class CoreObject(Process):
# signal the successor that the object can dispose an entity
# signal the successor that the object can dispose an entity
# =======================================================================
# =======================================================================
def
signalReceiver
(
self
):
def
signalReceiver
(
self
):
#
self.printTrace(self.id, 'trying to signal receiver')
self
.
printTrace
(
self
.
id
,
'trying to signal receiver'
)
activeObject
=
self
.
getActiveObject
()
activeObject
=
self
.
getActiveObject
()
possibleReceivers
=
activeObject
.
findReceivers
()
possibleReceivers
=
activeObject
.
findReceivers
()
if
possibleReceivers
:
if
possibleReceivers
:
...
@@ -314,6 +327,8 @@ class CoreObject(Process):
...
@@ -314,6 +327,8 @@ class CoreObject(Process):
if
not
possibleReceivers
:
if
not
possibleReceivers
:
receiversGiver
=
None
receiversGiver
=
None
receiver
=
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
return
False
receiver
=
activeObject
.
selectReceiver
(
possibleReceivers
)
receiver
=
activeObject
.
selectReceiver
(
possibleReceivers
)
receiversGiver
=
activeObject
receiversGiver
=
activeObject
...
@@ -330,6 +345,8 @@ class CoreObject(Process):
...
@@ -330,6 +345,8 @@ class CoreObject(Process):
activeObject
.
receiver
.
assignEntryTo
()
activeObject
.
receiver
.
assignEntryTo
()
activeObject
.
receiver
.
isRequested
.
signal
(
activeObject
)
activeObject
.
receiver
.
isRequested
.
signal
(
activeObject
)
return
True
return
True
# if no receiver can accept then try to preempt a receive if the stations holds a critical order
self
.
preemptReceiver
()
return
False
return
False
# =======================================================================
# =======================================================================
...
...
dream/simulation/QueueManagedJob.py
View file @
c68e6eb1
...
@@ -113,10 +113,7 @@ class QueueManagedJob(QueueJobShop):
...
@@ -113,10 +113,7 @@ class QueueManagedJob(QueueJobShop):
if
receiver
.
identifyEntityToGet
().
manager
.
isAssignedTo
()
!=
receiver
:
if
receiver
.
identifyEntityToGet
().
manager
.
isAssignedTo
()
!=
receiver
:
from
Globals
import
G
from
Globals
import
G
if
not
G
.
Router
.
invoked
:
if
not
G
.
Router
.
invoked
:
#===================================================================
self
.
printTrace
(
self
.
id
,
' '
*
50
+
'signalling router'
)
# # TESTING
# print now(), self.id,' '*50, 'signalling router'
#===================================================================
G
.
Router
.
invoked
=
True
G
.
Router
.
invoked
=
True
G
.
Router
.
isCalled
.
signal
(
now
())
G
.
Router
.
isCalled
.
signal
(
now
())
return
True
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