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
4b5bce50
Commit
4b5bce50
authored
May 22, 2014
by
Ioannis Papagiannopoulos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
updateMoveTime() added to calculate the timeToWait of the conveyerMover
parent
4aeea5d2
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
54 additions
and
21 deletions
+54
-21
dream/simulation/Conveyer.py
dream/simulation/Conveyer.py
+54
-21
No files found.
dream/simulation/Conveyer.py
View file @
4b5bce50
...
...
@@ -98,13 +98,16 @@ class Conveyer(CoreObject):
while
1
:
#calculate the time to reach end. If this is greater than 0 (we did not already have an entity at the end)
#set it as the timeToWait of the conveyerMover and raise call=true so that it will be triggered
self
.
timeToReachEnd
=
0
if
self
.
position
:
if
(
not
self
.
length
-
self
.
position
[
0
]
<
0.000001
):
self
.
timeToReachEnd
=
((
self
.
length
-
self
.
position
[
0
])
/
float
(
self
.
speed
))
/
60
if
self
.
timeToReachEnd
>
0
:
self
.
conveyerMover
.
timeToWait
=
self
.
timeToReachEnd
self
.
conveyerMover
.
canMove
.
signal
(
now
())
# self.timeToReachEnd=0
# if self.position:
# if (not self.length-self.position[0]<0.000001):
# self.timeToReachEnd=((self.length-self.position[0])/float(self.speed))/60
# if self.timeToReachEnd>0:
# self.conveyerMover.timeToWait=self.timeToReachEnd
# self.conveyerMover.canMove.signal(now())
if
self
.
updateMoveTime
():
# print self.id, 'time to move', self.conveyerMover.timeToWait
self
.
conveyerMover
.
canMove
.
signal
(
now
())
self
.
printTrace
(
self
.
id
,
'will wait for event'
)
yield
waitevent
,
self
,
[
self
.
isRequested
,
self
.
canDispose
,
self
.
moveEnd
]
# , self.loadOperatorAvailable]
...
...
@@ -148,9 +151,35 @@ class Conveyer(CoreObject):
self
.
signalReceiver
()
#===========================================================================
# checks if there is any entity at the exit
# calculate move time
#===========================================================================
def
updateMoveTime
(
self
):
# calculate time to reach end
timeToReachEnd
=
0
if
self
.
position
:
if
(
not
self
.
length
-
self
.
position
[
0
]
<
0.000001
):
timeToReachEnd
=
((
self
.
length
-
self
.
position
[
0
])
/
float
(
self
.
speed
))
/
60
# calculate time to become available
timeToBecomeAvailable
=
0
if
self
.
position
:
if
self
.
currentRequestedLength
>
self
.
position
[
-
1
]:
timeToBecomeAvailable
=
((
self
.
currentRequestedLength
-
self
.
position
[
-
1
])
/
float
(
self
.
speed
))
/
60
# pick the smallest but not zero
timeToWait
=
0
if
timeToReachEnd
>
0
:
timeToWait
=
timeToReachEnd
if
timeToBecomeAvailable
>
0
:
if
timeToBecomeAvailable
<
timeToWait
:
timeToWait
=
timeToBecomeAvailable
self
.
conveyerMover
.
timeToWait
=
timeToWait
if
timeToWait
>
0.000001
:
return
True
return
False
#===========================================================================
def
entityAtExit
(
self
):
# calculate the requested length
#===========================================================================
def
requestedLength
(
self
):
pass
#===========================================================================
...
...
@@ -280,9 +309,14 @@ class Conveyer(CoreObject):
giverObject
=
callerObject
assert
giverObject
,
'there must be a caller for canAcceptAndIsRequested'
self
.
calculateAvailableLength
()
return
self
.
enoughSpaceFor
(
giverObject
)
and
\
if
self
.
enoughSpaceFor
(
giverObject
)
and
\
giverObject
.
haveToDispose
(
activeObject
)
and
\
giverObject
in
activeObject
.
previous
giverObject
in
activeObject
.
previous
:
# if the conveyer can accept an entity is not blocked and thus the requested length has to be reset
# print 'reseting requested length'
self
.
currentRequestedLength
=
0
return
True
return
False
#===========================================================================
# gets an entity from the predecessor
...
...
@@ -314,15 +348,14 @@ class Conveyer(CoreObject):
if
self
.
wasFull
:
# self.totalBlockageTime+=now()-self.timeBlockageStarted
self
.
wasFull
=
False
#calculate the time that the conveyer will become available again and trigger the conveyerMover
self
.
timeToBecomeAvailable
=
((
self
.
position
[
-
1
]
+
self
.
currentRequestedLength
)
/
float
(
self
.
speed
))
/
60
# print self.id, 'time to become available', self.timeToBecomeAvailable
self
.
conveyerMover
.
timeToWait
=
self
.
timeToBecomeAvailable
# #calculate the time that the conveyer will become available again and trigger the conveyerMover
# self.timeToBecomeAvailable=((self.position[-1]+self.currentRequestedLength)/float(self.speed))/60
# # print self.id, 'time to become available', self.timeToBecomeAvailable
# self.conveyerMover.timeToWait=self.timeToBecomeAvailable
# self.conveyerMover.canMove.signal(now())
if
self
.
updateMoveTime
():
# print self.id, 'time to move', self.conveyerMover.timeToWait
self
.
conveyerMover
.
canMove
.
signal
(
now
())
# # if the available length is not zero then try to signal a giver
# if self.canAccept():
# self.printTrace(self.id, 'will try to signal Giver from removeEntity')
# self.signalGiver()
# if there is anything to dispose of then signal a receiver
if
self
.
haveToDispose
():
self
.
printTrace
(
self
.
id
,
'will try to signal a receiver from removeEntity'
)
...
...
@@ -378,7 +411,7 @@ class Conveyer(CoreObject):
def
postProcessing
(
self
,
MaxSimtime
=
None
):
if
MaxSimtime
==
None
:
from
Globals
import
G
MaxSimtime
=
G
.
maxSimTime
MaxSimtime
=
G
.
maxSimTime
self
.
moveEntities
()
#move the entities to count the working time
#if the conveyer is full count the blockage time
if
self
.
isFull
():
...
...
@@ -386,7 +419,7 @@ class Conveyer(CoreObject):
#when the conveyer was nor working or blocked it was waiting
self
.
totalWaitingTime
=
MaxSimtime
-
self
.
totalWorkingTime
-
self
.
totalBlockageTime
#update the lists to hold data for multiple runs
self
.
Waiting
.
append
(
100
*
self
.
totalWaitingTime
/
MaxSimtime
)
self
.
Working
.
append
(
100
*
self
.
totalWorkingTime
/
MaxSimtime
)
...
...
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