Commit 60618dce authored by Georgios Dagkakis's avatar Georgios Dagkakis

plugin to use KE tool and report in order to create wip

parent 8f5bac92
......@@ -5,12 +5,6 @@ Created on 24 Aug 2015
'''
import xlrd
#Read from the given directory the Excel document with the input data
workbook = xlrd.open_workbook('WIP_test report.xls')
worksheets = workbook.sheet_names()
main= workbook.sheet_by_name('WIP & Static Detail Section')
worksheet_WIP = worksheets[0] #Define the worksheet with the production data
# columns that are used (static)
CONTAINERNAME=0
STATIONNAME=16
......@@ -19,53 +13,52 @@ WORKCELL=17
def findStation(dictStory):
for key,value in dictStory.iteritems():
if value[0]=="Proximal Balloon Attach-CREFW" and value[1]=="CRE FW FRONT END LINE 1":
dictStory[key]=[]
dictStory[key].append("2_P_B_A_A")
dictStory[key]="2_P_B_A_A"
elif value[0]=="Proximal Balloon Attach-CREFW" and value[1]=="CRE FW FRONT END LINE 2":
dictStory[key]=[]
dictStory[key].append("2_P_B_A_B")
dictStory[key]="2_P_B_A_B"
elif value[0]=="RO/Exit Marker-CREFW" and value[1]=="CRE FW FRONT END LINE 1":
dictStory[key]=[]
dictStory[key].append("1_RO_E_M_A_A")
dictStory[key]="1_RO_E_M_A_A"
elif value[0]=="RO/Exit Marker-CREFW" and value[1]=="CRE FW FRONT END LINE 2":
dictStory[key]=[]
dictStory[key].append("1_RO_E_M_A_B")
dictStory[key]="1_RO_E_M_A_B"
elif value[0]=="Distal Balloon Attach-CREFW" and value[1]=="CRE FW FRONT END LINE 1":
dictStory[key]=[]
dictStory[key].append("3_D_B_A_A")
dictStory[key]="3_D_B_A_A"
elif value[0]=="Distal Balloon Attach-CREFW" and value[1]=="CRE FW FRONT END LINE 2":
dictStory[key]=[]
dictStory[key].append("3_D_B_A_B")
dictStory[key]="3_D_B_A_B"
elif value[0]=="Carding Cell-CREFW":
dictStory[key]=[]
dictStory[key].append("8_Carding")
dictStory[key]="8_Carding"
elif value[0]=="Flag Label Attach-CREFW":
dictStory[key]=[]
dictStory[key].append("6_Flag Labelling")
dictStory[key]="6_Flag Labelling"
elif value[0]=="Pressure Test-CREFW" and value[1]=="CRE FW BACK END LINE 2":
dictStory[key]=[]
dictStory[key].append("7_Pressure B")
dictStory[key]="7_Pressure B"
elif value[0]=="Pressure Test-CREFW" and value[1]=="CRE FW BACK END LINE 1":
dictStory[key]=[]
dictStory[key].append("7_Pressure A")
dictStory[key]="7_Pressure A"
elif value[0]=="Moulding Cell-CREFW":
dictStory[key]=[]
dictStory[key].append("5_Moulding")
dictStory[key]="5_Moulding"
elif value[0]=="Cut and Bend Corewire":
dictStory[key]=[]
dictStory[key].append("4_Cut & Bend")
dictStory[key]="4_Cut & Bend"
elif value[0]=="Fixed Wire Pack Cell 1-CREFW" and value[1]=="CRE FW BACK END LINE 1":
dictStory[key]=[]
dictStory[key].append("9_Packaging A")
dictStory[key]="9_Packaging A"
elif value[0]=="Fixed Wire Pack Cell 2-CRE" and value[1]=="CRE FW BACK END LINE 2":
dictStory[key]=[]
dictStory[key].append("9_Packaging B")
dictStory[key]="9_Packaging B"
return dictStory
def main(input):
#Read from the given directory the Excel document with the input data
# workbook = xlrd.open_workbook('WIP_test report.xls')
mime_type, attachement_data = input[len('data:'):].split(';base64,', 1)
attachement_data = attachement_data.decode('base64')
workbook = xlrd.open_workbook(file_contents=attachement_data)
worksheets = workbook.sheet_names()
main= workbook.sheet_by_name('WIP & Static Detail Section')
worksheet_WIP = worksheets[0] #Define the worksheet with the production data
contIds=[]
contDetails={}
for sheet in workbook.sheets():
contIds=[]
contDetails={}
for sheet in workbook.sheets():
if worksheet_WIP:
for i in range(1,main.nrows):
Id=main.cell(i,CONTAINERNAME).value
......@@ -77,7 +70,7 @@ for sheet in workbook.sheets():
contDetails[Id].append(statName)
contDetails[Id].append(workcell)
print findStation(contDetails)
return findStation(contDetails)
......
......@@ -6,6 +6,8 @@ import operator
import datetime
from dream.plugins import plugin
from dream.KnowledgeExtraction.PilotCases.BatchModel.WIPExtraction import main as KEtoolWIP
class BatchesWIPKEtool(plugin.InputPreparationPlugin):
""" Input preparation
......@@ -14,8 +16,79 @@ class BatchesWIPKEtool(plugin.InputPreparationPlugin):
def preprocess(self, data):
nodes=data['graph']['node']
print 2
# get the number of units for a standard batch
standardBatchUnits=0
for node_id, node in nodes.iteritems():
if node['_class']=='Dream.BatchSource':
standardBatchUnits=int(node['batchNumberOfUnits'])
node['wip']=[]
data_uri_encoded_input_data = data['input'].get(self.configuration_dict['input_id'], {})
wipData=KEtoolWIP(data_uri_encoded_input_data)
for batchId,stationId in wipData.iteritems():
nextBufferId=self.getNextBuffer(data, stationId)
if not nextBufferId:
continue
subline=self.checkIfSubline(data, stationId)
# for stations that we have to create sub-batches
if subline and (not self.checkIfNextStationIsReassembly(data, stationId)):
workingBatchSize=nodes[stationId]['workingBatchSize']
numberOfSubBatches=standardBatchUnits/workingBatchSize
for i in range(numberOfSubBatches):
data['graph']['node'][nextBufferId]['wip'].insert(0,{
"_class": 'Dream.SubBatch',
"id": 'Batch_'+str(batchId)+'_SB_'+str(i)+'_wip',
"name":'Batch_'+str(batchId)+'_SB_'+str(i)+'_wip',
"numberOfUnits":int(standardBatchUnits/numberOfSubBatches),
"parentBatchId":'Batch_'+str(batchId),
"parentBatchName":'Batch_'+str(batchId)
})
# for stations that we have to create batches
else:
data['graph']['node'][nextBufferId]['wip'].insert(0,{
"_class": 'Dream.Batch',
"id": 'Batch_'+str(batchId),
"name":'Batch_'+str(batchId),
"numberOfUnits":int(standardBatchUnits)
})
return data
# returns true if the station is in a subline
def checkIfSubline(self,data,stationId):
nodes=data['graph']['node']
current=stationId
# find all the predecessors that may share batches
while 1:
previous=self.getPredecessors(data, current)[0]
# when a decomposition is reached break
if 'Decomposition' in nodes[previous]['_class']:
return True
if 'Reassembly' in nodes[previous]['_class']:
return False
current=previous
# returns true if the station is reassembly
def checkIfNextStationIsReassembly(self,data,stationId):
nodes=data['graph']['node']
next=self.getSuccessors(data, stationId)[0]
if 'Reassembly' in nodes[next]['_class']:
return True
return False
def getNextBuffer(self,data,stationId):
nodes=data['graph']['node']
current=stationId
# find all the successors that may share batches
while 1:
next=self.getSuccessors(data, current)[0]
if 'Queue' in nodes[next]['_class'] or 'Clearance' in nodes[next]['_class']:
return next
if 'Exit' in nodes[next]['_class']:
return None
current=next
\ No newline at end of file
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment