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
c6d16db8
Commit
c6d16db8
authored
May 08, 2015
by
panos
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
UpdateStationsList script added to substitute the technology information with stationIDs
parent
c584e2ff
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
0 deletions
+85
-0
dream/KnowledgeExtraction/PilotCases/JobShop/UpdateStationList.py
...owledgeExtraction/PilotCases/JobShop/UpdateStationList.py
+85
-0
No files found.
dream/KnowledgeExtraction/PilotCases/JobShop/UpdateStationList.py
0 → 100644
View file @
c6d16db8
from
copy
import
copy
import
json
import
time
import
random
import
operator
from
datetime
import
datetime
import
copy
from
dream.plugins
import
plugin
class
UpdateStationList
(
plugin
.
InputPreparationPlugin
):
""" Input preparation
reads the data from external data base and substitutes the technology information with stationIDs lists
"""
# XXX hard-coded allowed station classes
STATION_CLASS_SET
=
set
([
"Dream.MouldAssembly"
,
"Dream.MachineJobShop"
])
# XXX hardcoded values for CAD1 and CAD2 stations
@
staticmethod
def
getStationTechnologies
():
'''returns the technologies that can be processed on the stations'''
return
{
"CAD1"
:
[
"ENG"
,
"CAD"
],
# XXX CAD1 is considered different than CAD2, they are not equivalent
"CAD2"
:
[
"CAD"
],
"CAM"
:
[
"CAM"
],
"MILL"
:
[
"MILL"
],
"TURN"
:
[
"TURN"
],
"DRILL"
:
[
"DRILL"
],
"EDM"
:
[
"EDM"
],
"WORK"
:
[
"QUAL"
,
"MAN"
],
# XXX currently we consider different stations for QUAL/MAN and ASSM
"ASSM"
:
[
"ASSM"
],
"INJM"
:
[
"INJM"
]}
def
getStationInitials
(
self
,
technology
):
'''get the stations that correspond to that technology'''
initialsList
=
[]
for
initials
,
corresponding_tech_list
in
self
.
getStationTechnologies
().
iteritems
():
for
tech
in
corresponding_tech_list
:
if
tech
==
technology
and
not
initials
in
initialsList
:
initialsList
.
append
(
initials
)
return
initialsList
def
getStationNames
(
self
):
node
=
self
.
data
[
"graph"
][
"node"
]
stations
=
[]
for
nodeID
in
node
.
keys
():
stations
.
append
(
nodeID
)
return
stations
def
preprocess
(
self
,
data
):
""" substitutes the technology information with stationIDs lists
"""
self
.
data
=
data
orders
=
data
[
"input"
].
get
(
"BOM"
,{}).
get
(
"productionOrders"
,{})
try
:
stations
=
data
[
"input"
][
"BOM"
][
'stations1'
]
except
:
stations
=
self
.
getStationNames
()
nodes
=
data
[
"graph"
][
"node"
]
for
order
in
orders
:
orderComponents
=
order
.
get
(
"componentsList"
,
[])
for
component
in
orderComponents
:
route
=
component
.
get
(
"route"
,
[])
for
index
,
step
in
enumerate
(
route
):
technology
=
step
.
get
(
"technology"
,
None
)
technology
=
technology
.
split
(
"-"
)[
0
]
assert
len
(
self
.
getStationInitials
(
technology
)),
'there is no corresponding station initial for that technology'
step
[
"technology"
]
=
technology
technologyStations
=
[]
for
station
in
stations
:
station
=
station
.
replace
(
" "
,
""
).
split
(
"-"
)[
0
]
for
initials
in
self
.
getStationInitials
(
technology
):
if
station
.
startswith
(
initials
)
\
and
data
[
"graph"
][
"node"
][
station
][
"_class"
]
in
self
.
STATION_CLASS_SET
:
found
=
False
# check that the id of the station provided by the db BOM exist in the nodes of the graph
for
node
in
nodes
.
keys
():
if
node
==
station
:
found
=
True
break
assert
found
==
True
,
"the station ids in the DB must be the same with the stations ids provided by the model"
technologyStations
.
append
(
station
)
assert
len
(
technologyStations
)
>
0
,
"the stations corresponding to the defined technology must be more than 0"
step
[
"stationIdsList"
]
=
technologyStations
return
data
if
__name__
==
'__main__'
:
pass
\ No newline at end of file
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