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
1eb1a536
Commit
1eb1a536
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
modified Machine and OperatorPreemptive
parent
99327cbd
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
82 additions
and
37 deletions
+82
-37
dream/simulation/ConditionalBuffer.py
dream/simulation/ConditionalBuffer.py
+1
-1
dream/simulation/Machine.py
dream/simulation/Machine.py
+39
-11
dream/simulation/ObjectResource.py
dream/simulation/ObjectResource.py
+1
-1
dream/simulation/OperatorPool.py
dream/simulation/OperatorPool.py
+20
-15
dream/simulation/OperatorPreemptive.py
dream/simulation/OperatorPreemptive.py
+21
-9
No files found.
dream/simulation/ConditionalBuffer.py
View file @
1eb1a536
...
@@ -92,7 +92,7 @@ class ConditionalBuffer(QueuePreemptive):
...
@@ -92,7 +92,7 @@ class ConditionalBuffer(QueuePreemptive):
and
activeObject
.
checkCondition
()
and
activeObject
.
checkCondition
()
# =======================================================================
# =======================================================================
# check w
ea
ther the condition is True
# check w
he
ther the condition is True
# =======================================================================
# =======================================================================
def
checkCondition
(
self
):
def
checkCondition
(
self
):
activeObject
=
self
.
getActiveObject
()
activeObject
=
self
.
getActiveObject
()
...
...
dream/simulation/Machine.py
View file @
1eb1a536
...
@@ -90,7 +90,7 @@ class Machine(CoreObject):
...
@@ -90,7 +90,7 @@ class Machine(CoreObject):
self
.
currentOperator
=
None
self
.
currentOperator
=
None
# define if load/setup/removal/processing are performed by the operator
# define if load/setup/removal/processing are performed by the operator
self
.
operationType
=
operationType
self
.
operationType
=
operationType
# boolean to check w
ea
ther the machine is being operated
# boolean to check w
he
ther the machine is being operated
self
.
toBeOperated
=
False
self
.
toBeOperated
=
False
# define the load times
# define the load times
self
.
loadDistType
=
loadDistribution
self
.
loadDistType
=
loadDistribution
...
@@ -162,6 +162,8 @@ class Machine(CoreObject):
...
@@ -162,6 +162,8 @@ class Machine(CoreObject):
self
.
loadOperatorWaitTimeCurrentEntity
=
0
# holds the time that the machine waits for operator to load the it
self
.
loadOperatorWaitTimeCurrentEntity
=
0
# holds the time that the machine waits for operator to load the it
self
.
loadTimeCurrentEntity
=
0
# holds the time to load the current entity
self
.
loadTimeCurrentEntity
=
0
# holds the time to load the current entity
self
.
setupTimeCurrentEntity
=
0
# holds the time to setup the machine before processing the current entity
self
.
setupTimeCurrentEntity
=
0
# holds the time to setup the machine before processing the current entity
# TODO: check whether the requestingEntity variable can be used in OperatorPreemptive
self
.
requestingEntity
=
None
# =======================================================================
# =======================================================================
# the main process of the machine
# the main process of the machine
...
@@ -214,6 +216,8 @@ class Machine(CoreObject):
...
@@ -214,6 +216,8 @@ class Machine(CoreObject):
# wait until the Broker has finished processing
# wait until the Broker has finished processing
yield
waituntil
,
self
,
self
.
broker
.
brokerIsSet
yield
waituntil
,
self
,
self
.
broker
.
brokerIsSet
# TODO: reset the requestinEntity before receiving the currentEntity
self
.
requestingEntity
=
None
# get the entity
# get the entity
# TODO: if there was loading time then we must solve the problem of getting an entity
# TODO: if there was loading time then we must solve the problem of getting an entity
# from an unidentified giver or not getting an entity at all as the giver
# from an unidentified giver or not getting an entity at all as the giver
...
@@ -467,11 +471,23 @@ class Machine(CoreObject):
...
@@ -467,11 +471,23 @@ class Machine(CoreObject):
if
(
len
(
activeObject
.
previous
)
==
1
):
if
(
len
(
activeObject
.
previous
)
==
1
):
if
(
activeObject
.
operatorPool
!=
'None'
and
(
any
(
type
==
'Load'
for
type
in
activeObject
.
multOperationTypeList
)
\
if
(
activeObject
.
operatorPool
!=
'None'
and
(
any
(
type
==
'Load'
for
type
in
activeObject
.
multOperationTypeList
)
\
or
any
(
type
==
'Setup'
for
type
in
activeObject
.
multOperationTypeList
))):
or
any
(
type
==
'Setup'
for
type
in
activeObject
.
multOperationTypeList
))):
if
activeObject
.
operatorPool
.
checkIfResourceIsAvailable
()
\
if
giverObject
.
haveToDispose
(
activeObject
):
and
activeObject
.
Up
and
len
(
activeObjectQueue
)
<
activeObject
.
capacity
\
# TODO:
and
giverObject
.
haveToDispose
(
activeObject
)
and
not
giverObject
.
exitIsAssigned
():
# check whether this entity is the one to be hand in
activeObject
.
giver
.
assignExit
()
# to be used in operatorPreemptive
return
True
activeObject
.
requestingEntity
=
giverObject
.
getActiveObjectQueue
()[
0
]
# TODO:
# update the objects requesting the operator
activeObject
.
operatorPool
.
requestingObject
=
activeObject
.
giver
# TODOD:
# update the last object calling the operatorPool
activeObject
.
operatorPool
.
receivingObject
=
activeObject
if
activeObject
.
operatorPool
.
checkIfResourceIsAvailable
()
\
and
activeObject
.
Up
and
len
(
activeObjectQueue
)
<
activeObject
.
capacity
\
and
not
giverObject
.
exitIsAssigned
():
activeObject
.
giver
.
assignExit
()
return
True
else
:
else
:
return
False
return
False
else
:
else
:
...
@@ -508,11 +524,23 @@ class Machine(CoreObject):
...
@@ -508,11 +524,23 @@ class Machine(CoreObject):
if
(
activeObject
.
operatorPool
!=
'None'
and
(
any
(
type
==
'Load'
for
type
in
activeObject
.
multOperationTypeList
)
\
if
(
activeObject
.
operatorPool
!=
'None'
and
(
any
(
type
==
'Load'
for
type
in
activeObject
.
multOperationTypeList
)
\
or
any
(
type
==
'Setup'
for
type
in
activeObject
.
multOperationTypeList
))):
or
any
(
type
==
'Setup'
for
type
in
activeObject
.
multOperationTypeList
))):
if
activeObject
.
operatorPool
.
checkIfResourceIsAvailable
()
\
if
isRequested
:
and
activeObject
.
Up
and
len
(
activeObjectQueue
)
<
activeObject
.
capacity
\
# TODO:
and
isRequested
and
not
activeObject
.
giver
.
exitIsAssigned
():
# check whether this entity is the one to be hand in
activeObject
.
giver
.
assignExit
()
# to be used in operatorPreemptive
return
True
activeObject
.
requestingEntity
=
activeObject
.
giver
.
getActiveObjectQueue
()[
0
]
# TODO:
# update the object requesting the operator
activeObject
.
operatorPool
.
requestingObject
=
activeObject
.
giver
# TODOD:
# update the last object calling the operatorPool
activeObject
.
operatorPool
.
receivingObject
=
activeObject
if
activeObject
.
operatorPool
.
checkIfResourceIsAvailable
()
\
and
activeObject
.
Up
and
len
(
activeObjectQueue
)
<
activeObject
.
capacity
\
and
isRequested
and
not
activeObject
.
giver
.
exitIsAssigned
():
activeObject
.
giver
.
assignExit
()
return
True
else
:
else
:
return
False
return
False
else
:
else
:
...
...
dream/simulation/ObjectResource.py
View file @
1eb1a536
...
@@ -39,7 +39,7 @@ class ObjectResource(object):
...
@@ -39,7 +39,7 @@ class ObjectResource(object):
self
.
totalWaitingTime
=
0
#holds the total waiting time
self
.
totalWaitingTime
=
0
#holds the total waiting time
self
.
timeLastOperationStarted
=
0
#holds the time that the last repair was started
self
.
timeLastOperationStarted
=
0
#holds the time that the last repair was started
self
.
Res
=
Resource
(
self
.
capacity
)
self
.
Res
=
Resource
(
self
.
capacity
)
# variable that checks w
ea
ther the resource is already initialized
# variable that checks w
he
ther the resource is already initialized
self
.
initialized
=
True
self
.
initialized
=
True
# =======================================================================
# =======================================================================
...
...
dream/simulation/OperatorPool.py
View file @
1eb1a536
...
@@ -52,6 +52,11 @@ class OperatorPool(ObjectResource):
...
@@ -52,6 +52,11 @@ class OperatorPool(ObjectResource):
self
.
coreObjects
=
[]
self
.
coreObjects
=
[]
# holds the object/Machine that currently handles the operator pool
# holds the object/Machine that currently handles the operator pool
self
.
currentObject
=
'None'
self
.
currentObject
=
'None'
# TODO: variables to be used by OperatorPreemptive
# TODO: the object requesting the OperatorPreemptive
self
.
requestingObject
=
None
# TODO: the last object calling the OperatorPool
self
.
receivingObject
=
None
# check if an operatorsList is 'None'
# check if an operatorsList is 'None'
if
operatorsList
==
'None'
or
(
operatorsList
!=
'None'
and
len
(
operatorsList
)
==
0
):
if
operatorsList
==
'None'
or
(
operatorsList
!=
'None'
and
len
(
operatorsList
)
==
0
):
...
@@ -89,28 +94,28 @@ class OperatorPool(ObjectResource):
...
@@ -89,28 +94,28 @@ class OperatorPool(ObjectResource):
# =======================================================================
# =======================================================================
# checks if there are operators available
# checks if there are operators available
# =======================================================================
# =======================================================================
def
checkIfResourceIsAvailable
(
self
,
callerObject
=
None
):
def
checkIfResourceIsAvailable
(
self
):
# maxTimeWaiting = 0
# for operator in self.operators:
# for machine in operator.coreObjects:
# timeWaiting = now()-machine.broker.timeWaitForOperatorStarted
# if (timeWaiting>=maxTimeWaiting):
# maxTimeWaiting=timeWaiting
# TODO: to discuss with George if using a callerObject is the proper way to inform the OperatorPreemptive
# TODO: to discuss with George if using a callerObject is the proper way to inform the OperatorPreemptive
# about the object that is requesting to know about its availability
# about the object that is requesting to know about its availability
thecaller
=
callerObject
# TODO: first check if there is any free operator, then check if the requesting entity is critical and preempt
# if callerOjbect is None then the checkIfResourceIsAvailable performs the default behaviour
# requestingEntity=thecaller.getActiveObjectQueue()[0]
# so initially it checks whether there is a free operator
# requestedOperator=requestingEntity.manager
isAvailable
=
any
(
operator
.
checkIfResourceIsAvailable
()
==
True
for
operator
in
self
.
operators
)
# isAvailable=requestedOperator.checkIfResourceIsAvailable(callerObject)
if
isAvailable
:
return
True
return
any
(
operator
.
checkIfResourceIsAvailable
(
callerObject
=
thecaller
)
==
True
for
operator
in
self
.
operators
)
# if there is no free operator, then check if any of the operators can preempt
return
any
(
operator
.
checkIfResourceIsAvailable
(
callerObject
=
self
)
==
True
for
operator
in
self
.
operators
)
# =======================================================================
# =======================================================================
# find the first available operator and return it
# find the first available operator and return it
# =======================================================================
# =======================================================================
def
findAvailableOperator
(
self
):
# may need to implement different sorting of the operators
def
findAvailableOperator
(
self
):
# may need to implement different sorting of the operators
return
next
(
x
for
x
in
self
.
operators
if
x
.
checkIfResourceIsAvailable
())
# find the free operator if any
freeOperator
=
next
(
x
for
x
in
self
.
operators
if
x
.
checkIfResourceIsAvailable
())
if
freeOperator
:
return
freeOperator
# if there is no free operator, return the operator that can preempt
return
next
(
x
for
x
in
self
.
operators
if
x
.
checkIfResourceIsAvailable
(
callerObject
=
self
))
# =======================================================================
# =======================================================================
# returns the resource
# returns the resource
...
...
dream/simulation/OperatorPreemptive.py
View file @
1eb1a536
...
@@ -49,25 +49,37 @@ class OperatorPreemptive(Operator):
...
@@ -49,25 +49,37 @@ class OperatorPreemptive(Operator):
activeResourceQueue
=
activeResource
.
getResourceQueue
()
activeResourceQueue
=
activeResource
.
getResourceQueue
()
# find out which station is requesting the operator?
# find out which station is requesting the operator?
thecaller
=
callerObject
thecaller
=
callerObject
# if the operator is occupied return True
# TODO: if the callerObject is None then
# perform then default behaviour. Used to find free operators
if
thecaller
==
None
:
# added for testing
len
(
self
.
Res
.
activeQ
)
<
self
.
capacity
# Otherwise check the operator has a reason to preempt the machine he is currently working on
# TODO: update the objects requesting the operator
requestingObject
=
thecaller
.
requestingObject
# TODO: update the last object calling the operatorPool
receivingObject
=
thecaller
.
receivingObject
# TODO: the entity that is requesting the operator
requestingEntity
=
receivingObject
.
requestingEntity
# if the operator is not occupied return True
if
len
(
activeResourceQueue
)
==
0
:
if
len
(
activeResourceQueue
)
==
0
:
return
True
return
True
# read the station currently operated by the operator
# read the station currently operated by the operator
# TODO: the victim of the operator is the Broker of the Machine. Modify to preempt the machine and not the broker
# TODO: the victim of the operator is the Broker of the Machine. Modify to preempt the machine and not the broker
victim
=
activeResourceQueue
[
0
]
victim
=
activeResourceQueue
[
0
]
.
victim
# read its activeQ
# read its activeQ
victimQueue
=
victim
.
getActiveObjectQueue
()
victimQueue
=
victim
.
getActiveObjectQueue
()
# if the callerObject is None then return False as the operator is occupied
if
thecaller
==
None
:
requestingObjectQueue
=
requestingObject
.
getActiveObjectQueue
()
return
False
receivingObjectQueue
=
receivingObject
.
getActiveObjectQueue
()
thecallerQueue
=
thecaller
.
getActiveObjectQueue
()
#if the receiver is not empty and the caller is not empty
#if the receiver is not empty and the caller is not empty
if
len
(
victimQueue
)
>
0
and
len
(
theCaller
Queue
):
if
len
(
victimQueue
)
and
len
(
requestingObject
Queue
):
try
:
try
:
#if the Entity to be forwarded to the station currently processed by the operator is critical
#if the Entity to be forwarded to the station currently processed by the operator is critical
if
thecaller
Queue
[
0
].
isCritical
:
if
requestingObject
Queue
[
0
].
isCritical
:
#if the receiver does not hold an Entity that is also critical
#if the receiver does not hold an Entity that is also critical
if
not
victimQueue
[
0
].
isCritical
:
if
not
victimQueue
[
0
].
isCritical
and
not
receivingObjectQueue
[
0
].
isCritical
:
# then the receiver must be preemptied before it can receive any entities from the calerObject
# then the receiver must be preemptied before it can receive any entities from the calerObject
victim
.
shouldPreempt
=
True
victim
.
shouldPreempt
=
True
victim
.
preempt
()
victim
.
preempt
()
...
...
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