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
e133362f
Commit
e133362f
authored
Mar 24, 2015
by
panos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CapacityStations.outputPreparation set up as method
parent
3da8ae76
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
72 additions
and
78 deletions
+72
-78
dream/KnowledgeExtraction/PilotCases/CapacityStations/OutputPreparation.py
...traction/PilotCases/CapacityStations/OutputPreparation.py
+72
-78
No files found.
dream/KnowledgeExtraction/PilotCases/CapacityStations/OutputPreparation.py
View file @
e133362f
...
...
@@ -25,87 +25,81 @@ def getBuffer(data,stationId):
for
(
edge_id
,
edge
)
in
data
[
'graph'
][
'edge'
].
iteritems
():
if
edge
[
'destination'
]
==
stationId
:
return
edge
[
'source'
]
# configuration=open("PilotCases\CapacityStations\sampleConfiguration.json", "r")
configuration
=
open
(
"sampleConfiguration.json"
,
"r"
)
configurationData
=
configuration
.
read
()
configurationJSON
=
json
.
loads
(
configurationData
)
# db=open("PilotCases\CapacityStations\sampleDBExtraction.json", "r")
db
=
open
(
"sampleDBExtraction.json"
,
"r"
)
dbData
=
db
.
read
()
dbJSON
=
json
.
loads
(
dbData
)
operations
=
dbJSON
.
get
(
'operations'
,{})
stations
=
configurationJSON
[
'graph'
][
'node'
]
currentDate
=
configurationJSON
[
'general'
][
'currentDate'
]
currentDate
=
datetime
.
strptime
(
currentDate
,
'%Y/%m/%d'
)
# set the interval capacity of the stations
for
operationId
,
operation
in
operations
.
iteritems
():
intervalCapacity
=
operation
.
get
(
'intervalCapacity'
,[])
for
stationId
,
station
in
stations
.
iteritems
():
if
stationId
==
operationId
:
station
[
'intervalCapacity'
]
=
intervalCapacity
orders
=
dbJSON
.
get
(
'orders'
,{})
configurationJSON
[
'input'
][
'BOM'
][
'productionOrders'
]
=
[]
capacityRequirementDict
=
{}
earliestStartDict
=
{}
for
order
in
orders
:
for
operation
in
order
[
'sequence'
]:
operationId
=
operation
.
keys
()[
0
]
capacityRequirementDict
[
operationId
]
=
operation
[
operationId
][
'requiredCapacity'
]
earliestStart
=
operation
[
operationId
].
get
(
'earliestStart'
,
None
)
if
earliestStart
:
earliestStart
=
datetime
.
strptime
(
earliestStart
,
'%Y-%m-%d'
)
earliestStartDict
[
operationId
]
=
(
earliestStart
-
currentDate
).
days
assemblySpaceRequirement
=
order
.
get
(
'floorSpaceRequired'
,
100
)
orderId
=
order
[
'orderID'
]
dueDate
=
order
.
get
(
'dueDate'
,
100
)
dueDate
=
datetime
.
strptime
(
dueDate
,
'%Y-%m-%d'
)
dueDate
=
(
dueDate
-
currentDate
).
days
orderDate
=
order
.
get
(
'orderDate'
,
0
)
orderDate
=
datetime
.
strptime
(
orderDate
,
'%Y-%m-%d'
)
orderDate
=
(
orderDate
-
currentDate
).
days
name
=
order
.
get
(
'orderName'
,
orderId
)
configurationJSON
[
'input'
][
'BOM'
][
'productionOrders'
].
append
({
"capacityRequirementDict"
:
capacityRequirementDict
,
"assemblySpaceRequirement"
:
assemblySpaceRequirement
,
"name"
:
name
,
"id"
:
orderId
,
"earliestStartDict"
:
earliestStartDict
,
"_class"
:
"dream.simulation.applications.CapacityStations.CapacityProject.CapacityProject"
,
"dueDate"
:
dueDate
,
"orderDate"
:
orderDate
})
def
OutputPreparation
(
data
,
extractedData
):
configurationJSON
=
data
dbJSON
=
extractedData
operations
=
dbJSON
.
get
(
'operations'
,{})
stations
=
configurationJSON
[
'graph'
][
'node'
]
currentDate
=
configurationJSON
[
'general'
][
'currentDate'
]
currentDate
=
datetime
.
strptime
(
currentDate
,
'%Y/%m/%d'
)
WIP
=
dbJSON
.
get
(
'WIP'
,{})
if
WIP
:
node
=
configurationJSON
[
'graph'
][
'node'
]
#create an empty wip list in all CapacityStationBuffers
for
(
node_id
,
node_data
)
in
node
.
iteritems
():
if
node_data
[
'_class'
]
==
'dream.simulation.applications.CapacityStations.CapacityStationBuffer.CapacityStationBuffer'
:
node_data
[
'wip'
]
=
[]
for
taskid
,
wip
in
WIP
.
iteritems
():
oper
=
wip
.
get
(
'operation'
,[])
requiredCapacity
=
wip
.
get
(
'Capacity required'
,
0
)
buffered
=
wip
.
get
(
'buffered'
,
0
)
orderId
=
wip
.
get
(
'order_id'
,[])
if
requiredCapacity
or
buffered
:
capacityBuffer
=
getBuffer
(
configurationJSON
,
oper
)
configurationJSON
[
'graph'
][
'node'
][
capacityBuffer
][
'wip'
].
append
({
"_class"
:
"dream.simulation.applications.CapacityStations.CapacityEntity.CapacityEntity"
,
"requiredCapacity"
:
max
([
requiredCapacity
,
buffered
]),
"capacityProjectId"
:
orderId
,
"name"
:
orderId
+
'_'
+
oper
+
'_'
+
str
(
requiredCapacity
)
})
updatedModelJSONString
=
json
.
dumps
(
configurationJSON
,
indent
=
5
)
updatedModel
=
open
(
'UpdatedModel.json'
,
mode
=
'w'
)
updatedModel
.
write
(
updatedModelJSONString
)
# set the interval capacity of the stations
for
operationId
,
operation
in
operations
.
iteritems
():
intervalCapacity
=
operation
.
get
(
'intervalCapacity'
,[])
for
stationId
,
station
in
stations
.
iteritems
():
if
stationId
==
operationId
:
station
[
'intervalCapacity'
]
=
intervalCapacity
orders
=
dbJSON
.
get
(
'orders'
,{})
configurationJSON
[
'input'
][
'BOM'
][
'productionOrders'
]
=
[]
capacityRequirementDict
=
{}
earliestStartDict
=
{}
for
order
in
orders
:
for
operation
in
order
[
'sequence'
]:
operationId
=
operation
.
keys
()[
0
]
capacityRequirementDict
[
operationId
]
=
operation
[
operationId
][
'requiredCapacity'
]
earliestStart
=
operation
[
operationId
].
get
(
'earliestStart'
,
None
)
if
earliestStart
:
earliestStart
=
datetime
.
strptime
(
earliestStart
,
'%Y-%m-%d'
)
earliestStartDict
[
operationId
]
=
(
earliestStart
-
currentDate
).
days
assemblySpaceRequirement
=
order
.
get
(
'floorSpaceRequired'
,
100
)
orderId
=
order
[
'orderID'
]
dueDate
=
order
.
get
(
'dueDate'
,
100
)
dueDate
=
datetime
.
strptime
(
dueDate
,
'%Y-%m-%d'
)
dueDate
=
(
dueDate
-
currentDate
).
days
orderDate
=
order
.
get
(
'orderDate'
,
0
)
orderDate
=
datetime
.
strptime
(
orderDate
,
'%Y-%m-%d'
)
orderDate
=
(
orderDate
-
currentDate
).
days
name
=
order
.
get
(
'orderName'
,
orderId
)
configurationJSON
[
'input'
][
'BOM'
][
'productionOrders'
].
append
({
"capacityRequirementDict"
:
capacityRequirementDict
,
"assemblySpaceRequirement"
:
assemblySpaceRequirement
,
"name"
:
name
,
"id"
:
orderId
,
"earliestStartDict"
:
earliestStartDict
,
"_class"
:
"dream.simulation.applications.CapacityStations.CapacityProject.CapacityProject"
,
"dueDate"
:
dueDate
,
"orderDate"
:
orderDate
})
WIP
=
dbJSON
.
get
(
'WIP'
,{})
if
WIP
:
node
=
configurationJSON
[
'graph'
][
'node'
]
#create an empty wip list in all CapacityStationBuffers
for
(
node_id
,
node_data
)
in
node
.
iteritems
():
if
node_data
[
'_class'
]
==
'dream.simulation.applications.CapacityStations.CapacityStationBuffer.CapacityStationBuffer'
:
node_data
[
'wip'
]
=
[]
for
taskid
,
wip
in
WIP
.
iteritems
():
oper
=
wip
.
get
(
'operation'
,[])
requiredCapacity
=
wip
.
get
(
'Capacity required'
,
0
)
buffered
=
wip
.
get
(
'buffered'
,
0
)
orderId
=
wip
.
get
(
'order_id'
,[])
if
requiredCapacity
or
buffered
:
capacityBuffer
=
getBuffer
(
configurationJSON
,
oper
)
configurationJSON
[
'graph'
][
'node'
][
capacityBuffer
][
'wip'
].
append
({
"_class"
:
"dream.simulation.applications.CapacityStations.CapacityEntity.CapacityEntity"
,
"requiredCapacity"
:
max
([
requiredCapacity
,
buffered
]),
"capacityProjectId"
:
orderId
,
"name"
:
orderId
+
'_'
+
oper
+
'_'
+
str
(
requiredCapacity
)
})
# updatedModelJSONString=json.dumps(configurationJSON, indent=5)
# updatedModel=open('UpdatedModel.json', mode='w')
# updatedModel.write(updatedModelJSONString)
return
configurationJSON
...
...
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