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
fd1d12d3
Commit
fd1d12d3
authored
Jun 06, 2014
by
Georgios Dagkakis
Committed by
Jérome Perrin
Jun 10, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
capacity station controller added and main script synched
parent
1f0fc35b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
135 additions
and
2 deletions
+135
-2
dream/simulation/CapacityStationController.py
dream/simulation/CapacityStationController.py
+114
-0
dream/simulation/LineGenerationJSON.py
dream/simulation/LineGenerationJSON.py
+21
-2
No files found.
dream/simulation/CapacityStationController.py
0 → 100644
View file @
fd1d12d3
# ===========================================================================
# Copyright 2013 University of Limerick
#
# This file is part of DREAM.
#
# DREAM is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# DREAM is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with DREAM. If not, see <http://www.gnu.org/licenses/>.
# ===========================================================================
'''
Created on 6 June 2013
@author: George
'''
'''
event generator that controls the capacity station objects
'''
import
simpy
from
EventGenerator
import
EventGenerator
from
Globals
import
G
class
CapacityStationController
(
EventGenerator
):
def
__init__
(
self
,
id
=
id
,
name
=
None
,
start
=
None
,
stop
=
None
,
interval
=
None
,
duration
=
None
,
method
=
None
,
argumentDict
=
None
):
EventGenerator
.
__init__
(
self
,
id
,
name
,
start
,
stop
,
interval
,
duration
,
method
,
argumentDict
)
def
initialize
(
self
):
EventGenerator
.
initialize
(
self
)
self
.
stepsAreComplete
=
self
.
env
.
event
()
def
run
(
self
):
yield
self
.
env
.
timeout
(
self
.
start
)
#wait until the start time
#loop until the end of the simulation
while
1
:
#if the stop time is exceeded then break the loop
if
self
.
stop
:
if
self
.
env
.
now
>
self
.
stop
:
break
self
.
env
.
process
(
self
.
steps
())
yield
self
.
stepsAreComplete
self
.
stepsAreComplete
=
self
.
env
.
event
()
yield
self
.
env
.
timeout
(
self
.
interval
)
#wait for the predetermined interval
def
steps
(
self
):
print
1
# unlock all the capacity station exits
for
exit
in
G
.
CapacityStationExitList
:
exit
.
isLocked
==
False
# Send canDispose to all the Stations
print
2
for
station
in
G
.
CapacityStationList
:
print
station
.
id
station
.
canDispose
.
succeed
()
# give control until all the Stations become empty
print
3
while
not
self
.
checkIfStationsEmpty
():
yield
self
.
env
.
timeout
(
0
)
print
4
# Lock all StationExits canAccept
for
exit
in
G
.
CapacityStationExitList
:
exit
.
isLocked
==
True
# Calculate from the last moves in Station->StationExits
# what should be created in StationBuffers and create it
print
5
self
.
createInCapacityStationBuffers
()
# Calculate what should be given in every Station
# and set the flags to the entities of StationBuffers
print
6
self
.
calculateWhatIsToBeProcessed
()
# Unlock all Stations canAccept
print
7
for
station
in
G
.
CapacityStationList
:
station
.
isLocked
=
False
# Send canDispose to all the StationBuffers
print
8
for
buffer
in
G
.
CapacityStationBufferList
:
buffer
.
canDispose
.
succeed
()
# give control until all StationBuffers hold only Entities that are not to be given
print
9
while
not
self
.
checkIfBuffersFinished
():
yield
self
.
env
.
timeout
(
0
)
self
.
stepsAreComplete
.
succeed
()
def
checkIfStationsEmpty
(
self
):
for
station
in
G
.
CapacityStationList
:
if
len
(
station
.
getActiveObjectQueue
()):
return
False
return
True
def
createInCapacityStationBuffers
(
self
):
pass
def
calculateWhatIsToBeProcessed
(
self
):
pass
def
checkIfBuffersFinished
(
self
):
for
buffer
in
G
.
CapacityStationBufferList
:
for
entity
in
buffer
.
getActiveObjectQueue
():
if
entity
.
shouldMove
:
return
False
return
True
\ No newline at end of file
dream/simulation/LineGenerationJSON.py
View file @
fd1d12d3
...
...
@@ -92,6 +92,7 @@ from CapacityStationBuffer import CapacityStationBuffer
from
CapacityStationController
import
CapacityStationController
from
CapacityEntity
import
CapacityEntity
from
CapacityProject
import
CapacityProject
from
CapacityStationController
import
CapacityStationController
import
ExcelHandler
import
time
...
...
@@ -178,7 +179,7 @@ def createObjects():
G
.
CapacityStationBufferList
=
[]
G
.
CapacityStationList
=
[]
G
.
CapacityStationExitList
=
[]
CapacityStationCont
ollerList
=
[]
G
.
CapacityStationContr
ollerList
=
[]
# -----------------------------------------------------------------------
# loop through all the model resources
...
...
@@ -813,7 +814,7 @@ def createObjects():
name
=
element
.
get
(
'name'
,
'not found'
)
nextCapacityStationBufferId
=
element
.
get
(
'nextCapacityStationBufferId'
,
None
)
CE
=
CapacityStationExit
(
id
,
name
,
nextCapacityStationBufferId
=
nextCapacityStationBufferId
)
G
.
CapacityStationList
.
append
(
CE
)
G
.
CapacityStation
Exit
List
.
append
(
CE
)
G
.
ObjList
.
append
(
CE
)
# -----------------------------------------------------------------------
...
...
@@ -848,6 +849,24 @@ def createObjects():
# calling the getSuccessorList() method on the repairman
G
.
EventGeneratorList
.
append
(
EV
)
# add the Event Generator to the RepairmanList
elif
elementClass
==
'Dream.CapacityStationController'
:
# check the object type
id
=
element
.
get
(
'id'
,
'not found'
)
# get the id of the element / default 'not_found'
name
=
element
.
get
(
'name'
,
'not found'
)
# get the name of the element / default 'not_found'
start
=
float
(
element
.
get
(
'start'
)
or
0
)
stop
=
float
(
element
.
get
(
'stop'
)
or
-
1
)
# infinity (had to be done to make it as float)
if
stop
<
0
:
stop
=
float
(
'inf'
)
interval
=
float
(
element
.
get
(
'interval'
)
or
1
)
duration
=
float
(
element
.
get
(
'duration'
)
or
0
)
argumentDict
=
(
element
.
get
(
'argumentDict'
,
{}))
# get the arguments of the method as a dict / default {}
CSC
=
CapacityStationController
(
id
,
name
,
start
=
start
,
stop
=
stop
,
interval
=
interval
,
duration
=
duration
,
argumentDict
=
argumentDict
)
# create the EventGenerator object
# calling the getSuccessorList() method on the repairman
G
.
EventGeneratorList
.
append
(
CSC
)
# add the Event Generator to the RepairmanList
G
.
CapacityStationControllerList
.
append
(
CSC
)
# -----------------------------------------------------------------------
# loop through all the core objects
# to read predecessors
...
...
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