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
dca04b5e
Commit
dca04b5e
authored
Aug 06, 2014
by
Georgios Dagkakis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cleanup, duplicate code moved in separate method
parent
9515ab9e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
32 deletions
+22
-32
dream/simulation/CapacityStationController.py
dream/simulation/CapacityStationController.py
+22
-32
No files found.
dream/simulation/CapacityStationController.py
View file @
dca04b5e
...
...
@@ -206,22 +206,8 @@ class CapacityStationController(EventGenerator):
# loop through the entities
for
entity
in
entitiesInBuffer
:
if
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
station
):
# calculate what is the capacity that should proceed and what that should remain
capacityToMove
=
totalAvailableCapacity
*
(
entity
.
requiredCapacity
)
/
float
(
totalRequestedCapacity
)
capacityToStay
=
entity
.
requiredCapacity
-
capacityToMove
# remove the capacity entity by the buffer so that the broken ones are created
buffer
.
getActiveObjectQueue
().
remove
(
entity
)
entityToMoveName
=
entity
.
capacityProjectId
+
'_'
+
station
.
objName
+
'_'
+
str
(
capacityToMove
)
entityToMove
=
CapacityEntity
(
name
=
entityToMoveName
,
capacityProjectId
=
entity
.
capacityProjectId
,
requiredCapacity
=
capacityToMove
)
entityToMove
.
initialize
()
entityToMove
.
currentStation
=
buffer
entityToMove
.
shouldMove
=
True
entityToStayName
=
entity
.
capacityProjectId
+
'_'
+
station
.
objName
+
'_'
+
str
(
capacityToStay
)
entityToStay
=
CapacityEntity
(
name
=
entityToStayName
,
capacityProjectId
=
entity
.
capacityProjectId
,
requiredCapacity
=
capacityToStay
)
entityToStay
.
initialize
()
entityToStay
.
currentStation
=
buffer
import
Globals
Globals
.
setWIP
([
entityToMove
,
entityToStay
])
#set the new components as wip
self
.
breakEntity
(
entity
,
buffer
,
station
,
totalAvailableCapacity
,
totalRequestedCapacity
)
# if the buffer is assembly there are different calculations
else
:
# calculate the total capacity that is requested
...
...
@@ -245,22 +231,26 @@ class CapacityStationController(EventGenerator):
# break only the assembled projects
if
self
.
checkIfProjectAssembledInBuffer
(
entity
.
capacityProject
,
buffer
)
and
\
self
.
checkIfProjectCanStartInStation
(
entity
.
capacityProject
,
station
):
# calculate what is the capacity that should proceed and what that should remain
capacityToMove
=
totalAvailableCapacity
*
(
entity
.
requiredCapacity
)
/
float
(
totalRequestedCapacity
)
capacityToStay
=
entity
.
requiredCapacity
-
capacityToMove
# remove the capacity entity by the buffer so that the broken ones are created
buffer
.
getActiveObjectQueue
().
remove
(
entity
)
entityToMoveName
=
entity
.
capacityProjectId
+
'_'
+
station
.
objName
+
'_'
+
str
(
capacityToMove
)
entityToMove
=
CapacityEntity
(
name
=
entityToMoveName
,
capacityProjectId
=
entity
.
capacityProjectId
,
requiredCapacity
=
capacityToMove
)
entityToMove
.
initialize
()
entityToMove
.
currentStation
=
buffer
entityToMove
.
shouldMove
=
True
entityToStayName
=
entity
.
capacityProjectId
+
'_'
+
station
.
objName
+
'_'
+
str
(
capacityToStay
)
entityToStay
=
CapacityEntity
(
name
=
entityToStayName
,
capacityProjectId
=
entity
.
capacityProjectId
,
requiredCapacity
=
capacityToStay
)
entityToStay
.
initialize
()
entityToStay
.
currentStation
=
buffer
import
Globals
Globals
.
setWIP
([
entityToMove
,
entityToStay
])
#set the new components as wip
self
.
breakEntity
(
entity
,
buffer
,
station
,
totalAvailableCapacity
,
totalRequestedCapacity
)
# breaks an entity in the part that should move and the one that should stay
def
breakEntity
(
self
,
entity
,
buffer
,
station
,
totalAvailableCapacity
,
totalRequestedCapacity
):
# calculate what is the capacity that should proceed and what that should remain
capacityToMove
=
totalAvailableCapacity
*
(
entity
.
requiredCapacity
)
/
float
(
totalRequestedCapacity
)
capacityToStay
=
entity
.
requiredCapacity
-
capacityToMove
# remove the capacity entity by the buffer so that the broken ones are created
buffer
.
getActiveObjectQueue
().
remove
(
entity
)
entityToMoveName
=
entity
.
capacityProjectId
+
'_'
+
station
.
objName
+
'_'
+
str
(
capacityToMove
)
entityToMove
=
CapacityEntity
(
name
=
entityToMoveName
,
capacityProjectId
=
entity
.
capacityProjectId
,
requiredCapacity
=
capacityToMove
)
entityToMove
.
initialize
()
entityToMove
.
currentStation
=
buffer
entityToMove
.
shouldMove
=
True
entityToStayName
=
entity
.
capacityProjectId
+
'_'
+
station
.
objName
+
'_'
+
str
(
capacityToStay
)
entityToStay
=
CapacityEntity
(
name
=
entityToStayName
,
capacityProjectId
=
entity
.
capacityProjectId
,
requiredCapacity
=
capacityToStay
)
entityToStay
.
initialize
()
entityToStay
.
currentStation
=
buffer
import
Globals
Globals
.
setWIP
([
entityToMove
,
entityToStay
])
#set the new components as wip
# merges the capacity entities if they belong to the same project
def
mergeEntities
(
self
):
...
...
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