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
0da9016c
Commit
0da9016c
authored
Feb 03, 2014
by
Ioannis Papagiannopoulos
Committed by
Jérome Perrin
Feb 07, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
QueuePreemptive code collapsed to CoreObject
parent
19784fcb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
17 deletions
+38
-17
dream/simulation/CoreObject.py
dream/simulation/CoreObject.py
+20
-1
dream/simulation/MachinePreemptive.py
dream/simulation/MachinePreemptive.py
+3
-1
dream/simulation/QueuePreemptive.py
dream/simulation/QueuePreemptive.py
+15
-15
No files found.
dream/simulation/CoreObject.py
View file @
0da9016c
...
...
@@ -171,7 +171,20 @@ class CoreObject(Process):
self
.
timeLastEntityEntered
=
now
()
self
.
nameLastEntityEntered
=
activeEntity
.
name
# this holds the name of the last entity that got into Machine
self
.
downTimeProcessingCurrentEntity
=
0
# perform preemption when required
# if the object is not Exit
if
activeObject
.
receiver
:
# if the obtained Entity is critical
if
activeEntity
.
isCritical
:
#if the receiver is not empty
if
len
(
self
.
receiver
.
getActiveObjectQueue
())
>
0
:
#if the receiver does not hold an Entity that is also critical
if
not
self
.
receiver
.
getActiveObjectQueue
()[
0
].
isCritical
:
self
.
receiver
.
shouldPreempt
=
True
self
.
receiver
.
preempt
()
self
.
receiver
.
timeLastEntityEnded
=
now
()
#required to count blockage correctly in the preemptied station
self
.
outputTrace
(
activeEntity
.
name
,
"got into "
+
self
.
objName
)
return
activeEntity
...
...
@@ -348,6 +361,12 @@ class CoreObject(Process):
def
unAssignExit
(
self
):
self
.
exitAssignedToReceiver
=
False
# =======================================================================
# actions to be carried whenever the object is preemptied
# =======================================================================
def
preempt
(
self
):
pass
# =======================================================================
# actions to be carried whenever the object is interrupted
# (failure, break, preemption, etc)
...
...
dream/simulation/MachinePreemptive.py
View file @
0da9016c
...
...
@@ -54,6 +54,7 @@ class MachinePreemptive(MachineJobShop):
# method to execute the preemption
# =======================================================================
def
preempt
(
self
):
activeObject
=
self
.
getActiveObject
()
activeEntity
=
self
.
getActiveObjectQueue
()[
0
]
#get the active Entity
#calculate the remaining processing time
#if it is reset then set it as the original processing time
...
...
@@ -77,7 +78,8 @@ class MachinePreemptive(MachineJobShop):
#set the receiver as the object where the active entity was preempted from
self
.
receiver
=
self
.
lastGiver
self
.
next
=
[
self
.
receiver
]
self
.
waitToDispose
=
True
#set that I have to dispose
self
.
waitToDispose
=
True
#set that I have to dispose
self
.
receiver
.
timeLastEntityEnded
=
now
()
#required to count blockage correctly in the preemptied station
reactivate
(
self
)
...
...
dream/simulation/QueuePreemptive.py
View file @
0da9016c
...
...
@@ -32,21 +32,21 @@ from SimPy.Simulation import now
# the QueuePreemptive object
# ===========================================================================
class
QueuePreemptive
(
QueueJobShop
):
# =======================================================================
# extend he default so that it can interrupt the receiver if need be
# =======================================================================
def
getEntity
(
self
):
activeEntity
=
QueueJobShop
.
getEntity
(
self
)
#execute default behaviour
#if the obtained Entity is critical
if
activeEntity
.
isCritical
:
#if the receiver is not empty
if
len
(
self
.
receiver
.
getActiveObjectQueue
())
>
0
:
#if the receiver does not hold an Entity that is also critical
if
not
self
.
receiver
.
getActiveObjectQueue
()[
0
].
isCritical
:
self
.
receiver
.
shouldPreempt
=
True
self
.
receiver
.
preempt
()
self
.
receiver
.
timeLastEntityEnded
=
now
()
#required to count blockage correctly in the preemptied station
return
activeEntity
#
# =======================================================================
#
# extend he default so that it can interrupt the receiver if need be
#
# =======================================================================
#
def getEntity(self):
#
activeEntity=QueueJobShop.getEntity(self) #execute default behaviour
#
#if the obtained Entity is critical
#
if activeEntity.isCritical:
#
#if the receiver is not empty
#
if len(self.receiver.getActiveObjectQueue())>0:
#
#if the receiver does not hold an Entity that is also critical
#
if not self.receiver.getActiveObjectQueue()[0].isCritical:
#
self.receiver.shouldPreempt=True
#
self.receiver.preempt()
#
self.receiver.timeLastEntityEnded=now() #required to count blockage correctly in the preemptied station
#
return activeEntity
# =======================================================================
# for future use
...
...
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