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
00950a27
Commit
00950a27
authored
Jan 28, 2014
by
Ioannis Papagiannopoulos
Committed by
Jérome Perrin
Feb 07, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
MouldAssembly and MachineJobShop modified following the OperatedMachine collapse
parent
b3ed30f2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
70 additions
and
36 deletions
+70
-36
dream/simulation/Machine.py
dream/simulation/Machine.py
+2
-13
dream/simulation/MachineJobShop.py
dream/simulation/MachineJobShop.py
+19
-8
dream/simulation/MouldAssembly.py
dream/simulation/MouldAssembly.py
+49
-15
No files found.
dream/simulation/Machine.py
View file @
00950a27
...
...
@@ -181,7 +181,6 @@ class Machine(CoreObject):
self
.
loadTimeCurrentEntity
=
0
self
.
setupTimeCurrentEntity
=
0
# ++++++++++++++++++++++++++++++ New ++++++++++++++++++++++++++++++++++++
# ======= request a resource
if
(
self
.
operatorPool
!=
"None"
)
and
any
(
type
==
'Load'
for
type
in
self
.
multOperationTypeList
):
# when it's ready to accept (canAcceptAndIsRequested) then inform the broker
...
...
@@ -213,7 +212,6 @@ class Machine(CoreObject):
self
.
releaseOperator
()
# wait until the Broker has finished processing
yield
waituntil
,
self
,
self
.
broker
.
brokerIsSet
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# get the entity
# TODO: if there was loading time then we must solve the problem of getting an entity
...
...
@@ -221,7 +219,6 @@ class Machine(CoreObject):
# may fall in failure mode (assignExit()?)
self
.
currentEntity
=
self
.
getEntity
()
# ++++++++++++++++++++++++++++++ New ++++++++++++++++++++++++++++++++++++
# ======= request a resource if it is not already assigned an Operator
if
(
self
.
operatorPool
!=
"None"
)
\
and
any
(
type
==
"Processing"
or
type
==
"Setup"
for
type
in
self
.
multOperationTypeList
)
\
...
...
@@ -234,14 +231,12 @@ class Machine(CoreObject):
yield
waituntil
,
self
,
self
.
broker
.
brokerIsSet
self
.
timeWaitForOperatorEnded
=
now
()
self
.
operatorWaitTimeCurrentEntity
+=
self
.
timeWaitForOperatorEnded
-
self
.
timeWaitForOperatorStarted
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# variables dedicated to hold the processing times, the time when the Entity entered,
# and the processing time left
self
.
totalProcessingTimeInCurrentEntity
=
self
.
calculateProcessingTime
()
# get the processing time, tinMStarts holds the processing time of the machine
tinM
=
self
.
totalProcessingTimeInCurrentEntity
# timer to hold the processing time left
# ++++++++++++++++++++++++++++++ New ++++++++++++++++++++++++++++++++++++
# ======= setup the machine if the Setup is defined as one of the Operators' operation types
# in plantSim the setup is performed when the machine has to process a new type of Entity and only once
if
any
(
type
==
"Setup"
for
type
in
self
.
multOperationTypeList
)
and
self
.
isOperated
():
...
...
@@ -263,7 +258,6 @@ class Machine(CoreObject):
# print self.objName, 'operator released', now()
# wait until the Broker has finished processing
yield
waituntil
,
self
,
self
.
broker
.
brokerIsSet
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# variables used to flag any interruptions and the end of the processing
interruption
=
False
...
...
@@ -302,7 +296,7 @@ class Machine(CoreObject):
# passivate the Machine for as long as there is no repair
# start counting the down time at breatTime dummy variable
breakTime
=
now
()
# dummy variable that the interruption happened
# ++++++++++++++++++++++++++++++ New ++++++++++++++++++++++++++++++++++++
# =============== release the operator if there is interruption
if
(
self
.
operatorPool
!=
"None"
)
\
and
self
.
isOperated
()
\
...
...
@@ -310,7 +304,7 @@ class Machine(CoreObject):
self
.
releaseOperator
()
# print self.objName, 'operator released due to failure', now()
yield
waituntil
,
self
,
self
.
broker
.
brokerIsSet
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# if there is a failure in the machine it is passivated
yield
passivate
,
self
# use the timers to count the time that Machine is down and related
...
...
@@ -325,7 +319,6 @@ class Machine(CoreObject):
if
(
len
(
self
.
getActiveObjectQueue
())
==
0
and
self
.
shouldPreempt
):
break
# ++++++++++++++++++++++++++++++ New ++++++++++++++++++++++++++++++++++++
# =============== request a resource after the repair
if
(
self
.
operatorPool
!=
"None"
)
\
and
any
(
type
==
"Processing"
for
type
in
self
.
multOperationTypeList
)
\
...
...
@@ -335,7 +328,6 @@ class Machine(CoreObject):
yield
waituntil
,
self
,
self
.
broker
.
brokerIsSet
self
.
timeWaitForOperatorEnded
=
now
()
self
.
operatorWaitTimeCurrentEntity
+=
self
.
timeWaitForOperatorEnded
-
self
.
timeWaitForOperatorStarted
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# if no interruption occurred the processing in M1 is ended
else
:
...
...
@@ -353,15 +345,12 @@ class Machine(CoreObject):
except
IndexError
:
pass
# ++++++++++++++++++++++++++++++ New ++++++++++++++++++++++++++++++++++++
# =============== release resource after the end of processing
if
(
self
.
operatorPool
!=
'None'
)
\
and
any
(
type
==
"Processing"
for
type
in
self
.
multOperationTypeList
)
\
and
not
interruption
:
self
.
releaseOperator
()
yield
waituntil
,
self
,
self
.
broker
.
brokerIsSet
# +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
# set the variable that flags an Entity is ready to be disposed
self
.
waitToDispose
=
True
...
...
dream/simulation/MachineJobShop.py
View file @
00950a27
...
...
@@ -76,15 +76,26 @@ class MachineJobShop(Machine):
# it checks also the next station of the Entity
# and returns true only if the active object is the next station
# =======================================================================
def
canAccept
(
self
,
callerObject
=
None
):
if
callerObject
!=
None
:
def
canAccept
(
self
,
callerObject
=
None
):
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
activeObject
.
getActiveObjectQueue
()
thecaller
=
callerObject
if
(
thecaller
!=
None
):
#check it the caller object holds an Entity that requests for current object
if
len
(
callerObject
.
getActiveObjectQueue
())
>
0
:
activeEntity
=
callerObject
.
getActiveObjectQueue
()[
0
]
# if the machine's Id is in the list of the entity's next stations
if
self
.
id
in
activeEntity
.
remainingRoute
[
0
].
get
(
'stationIdsList'
,[]):
# if activeEntity.remainingRoute[0][0]==self.id:
return
len
(
self
.
getActiveObjectQueue
())
<
self
.
capacity
#return according to the state of the Queue
if
len
(
thecaller
.
getActiveObjectQueue
())
>
0
:
# TODO: make sure that the first entity of the callerObject is to be disposed
activeEntity
=
thecaller
.
getActiveObjectQueue
()[
0
]
# if the machine's Id is in the list of the entity's next stations
if
activeObject
.
id
in
activeEntity
.
remainingRoute
[
0
].
get
(
'stationIdsList'
,[]):
#return according to the state of the Queue
# also check if (if the machine is to be operated) there are available operators
if
(
activeObject
.
operatorPool
!=
'None'
and
any
(
type
==
'Load'
for
type
in
activeObject
.
multOperationTypeList
)):
return
activeObject
.
operatorPool
.
checkIfResourceIsAvailable
()
\
and
len
(
activeObject
.
getActiveObjectQueue
())
<
activeObject
.
capacity
\
and
activeObject
.
Up
else
:
return
len
(
activeObject
.
getActiveObjectQueue
())
<
activeObject
.
capacity
\
and
activeObject
.
Up
return
False
# =======================================================================
...
...
dream/simulation/MouldAssembly.py
View file @
00950a27
...
...
@@ -282,14 +282,25 @@ class MouldAssembly(MachinePreemptive):
# returns true if it is empty
# =======================================================================
def
canAccept
(
self
,
callerObject
=
None
):
if
callerObject
!=
None
:
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
activeObject
.
getActiveObjectQueue
()
thecaller
=
callerObject
if
thecaller
!=
None
:
#check it the caller object holds an Entity that requests for current object
if
len
(
callerObject
.
getActiveObjectQueue
())
>
0
:
activeEntity
=
callerObject
.
getActiveObjectQueue
()[
0
]
if
len
(
thecaller
.
getActiveObjectQueue
())
>
0
:
# TODO: make sure that the first entity of the callerObject is to be disposed
activeEntity
=
thecaller
.
getActiveObjectQueue
()[
0
]
# if the machine's Id is in the list of the entity's next stations
if
self
.
id
in
activeEntity
.
remainingRoute
[
0
].
get
(
'stationIdsList'
,[]):
if
activeObject
.
id
in
activeEntity
.
remainingRoute
[
0
].
get
(
'stationIdsList'
,[]):
#return according to the state of the Queue
return
len
(
self
.
getActiveObjectQueue
())
==
0
# check if (if the machine is to be operated) there are available operators
if
(
activeObject
.
operatorPool
!=
'None'
and
any
(
type
==
'Load'
for
type
in
activeObject
.
multOperationTypeList
)):
return
activeObject
.
operatorPool
.
checkIfResourceIsAvailable
()
\
and
len
(
activeObject
.
getActiveObjectQueue
())
==
0
\
and
activeObject
.
Up
else
:
return
len
(
activeObject
.
getActiveObjectQueue
())
==
0
\
and
activeObject
.
Up
return
False
# =======================================================================
...
...
@@ -304,13 +315,27 @@ class MouldAssembly(MachinePreemptive):
activeObject
=
self
.
getActiveObject
()
activeObjectQueue
=
self
.
getActiveObjectQueue
()
giverObject
=
self
.
getGiverObject
()
# if we have only one possible giver just check if the internal queue is empty
# and if the giver has to dispose something
# if we have only one predecessor just check if the machine is empty,
# the machine is up and the predecessor has an entity to dispose
if
(
len
(
activeObject
.
previous
)
==
1
):
return
giverObject
.
haveToDispose
(
activeObject
)
\
and
len
(
activeObjectQueue
)
==
0
\
# if the machine has to compete for an Operator that loads the entities onto it
# check if the predecessor if blocked by an other Machine
# if not then the machine has to block the predecessor giverObject to avoid conflicts
# with other competing machines
if
(
activeObject
.
operatorPool
!=
'None'
and
any
(
type
==
'Load'
for
type
in
activeObject
.
multOperationTypeList
)):
if
activeObject
.
operatorPool
.
checkIfResourceIsAvailable
()
\
and
activeObject
.
Up
\
and
len
(
activeObjectQueue
)
==
0
\
and
giverObject
.
haveToDispose
(
activeObject
)
\
and
not
giverObject
.
exitIsAssigned
():
activeObject
.
giver
.
assignExit
()
return
True
else
:
return
False
# otherwise, use the default behaviour
else
:
return
activeObject
.
Up
and
len
(
activeObjectQueue
)
==
0
\
and
giverObject
.
haveToDispose
(
activeObject
)
# dummy variables that help prioritise the objects requesting to give objects to the Machine (activeObject)
isRequested
=
False
# isRequested is dummyVariable checking if it is requested to accept an item
maxTimeWaiting
=
0
# dummy variable counting the time a predecessor is blocked
...
...
@@ -327,10 +352,19 @@ class MouldAssembly(MachinePreemptive):
# in any other case, it holds the time since the end of the Entity processing
else
:
timeWaiting
=
now
()
-
object
.
timeLastEntityEnded
#if more than one predecessor have to dispose, take the part from the one that is blocked longer
if
(
timeWaiting
>=
maxTimeWaiting
):
activeObject
.
giver
=
object
maxTimeWaiting
=
timeWaiting
return
len
(
activeObjectQueue
)
==
0
and
isRequested
maxTimeWaiting
=
timeWaiting
if
(
activeObject
.
operatorPool
!=
'None'
and
any
(
type
==
'Load'
for
type
in
activeObject
.
multOperationTypeList
)):
if
activeObject
.
operatorPool
.
checkIfResourceIsAvailable
()
\
and
activeObject
.
Up
\
and
len
(
activeObjectQueue
)
==
0
\
and
isRequested
\
and
not
activeObject
.
giver
.
exitIsAssigned
():
activeObject
.
giver
.
assignExit
()
return
True
else
:
return
False
else
:
return
activeObject
.
Up
and
len
(
activeObjectQueue
)
==
0
and
isRequested
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