Commit 26fe907a authored by Gino Tosti's avatar Gino Tosti
Browse files

update code to allow less programming to Pietro Bruno

parent 260cd676
......@@ -47,9 +47,12 @@ class excelIcd:
def getMain(self):
self.sheets["Main"].columns=self.sheets["Main"].iloc[0]
self.sheets["Main"] = self.sheets["Main"].loc[1:,self.sheets["Main"].columns]
self.MainSheet["NCols"]=(self.sheets["Main"].shape)[1]
self.MainSheet["NRows"]=(self.sheets["Main"].shape)[0]
self.MainSheet["NRows"]=(self.sheets["Main"].shape)[0]-1
self.MainSheet["Colnames"]= self.sheets["Main"].columns
#print("*******LINEA",self.sheets["Main"].iloc[0])
for colind,coname in enumerate (self.sheets["Main"]):
#print "CCC",coname
......@@ -59,7 +62,7 @@ class excelIcd:
#colname=(str(coname)).replace(' ','_')
for idx in range(0,self.MainSheet["NRows"]):
#print "BBBBB", self.sheets["Main"].cell(idx,colind).value
colval.append(self.sheets["Main"].iat[idx,colind])
colval.append(self.sheets["Main"].iat[idx+1,colind])
self.MainSheet[coname]=colval
if(self.debug):
......
......@@ -23,7 +23,7 @@ datatype={"BOOLEAN":["boolean","b","0","1","boolean","boolean","Boolean"],
"BOOLEAN[]":["booleanSeq","b","0","1","boolean","boolean","boolean[]"],
"DOUBLE[]":["doubleSeq","9.4lf","-1e50","1e50","double","double","double[]"],
"FLOAT[]":["floatSeq","9.4f","-1e20","1e20","float","float","Float"],
"FLOAT[]":["floatSeq","9.4f","-1e20","1e20","float","float","float[]"],
"INT16[]":["longSeq","2d","-2147483648","2147483647","int","long","int[]"],
"INT32[]":["longSeq","2d","-2147483648","2147483647","int","long","int[]"],
"INT64[]":["longSeq","2d","-2147483648","2147483647","long","long long","long[]"],
......
......@@ -38,9 +38,13 @@ if __name__ =="__main__":
pwd=os.getcwd()
excel_file =options.bookfile
wb=excelIcd(excel_file)
devs=wb.MainSheet['Device Name']
comp=wb.MainSheet['Component Name']
assembly=wb.MainSheet['Assembly']
tmp=wb.book.parse("Main")
smain=pd.DataFrame(data=tmp.loc[1:,tmp.columns].values,columns=tmp.loc[0,tmp.columns])
print (smain)
#devs= wb.MainSheet['Device Name']
devs= smain['Device Name']
comp=smain['Component Name']
assembly=smain['Assembly']
outdir="/media/sf_Desktop/Useful_SW/"
outfile=[]
if len(assembly)>1 :
......@@ -48,18 +52,18 @@ if __name__ =="__main__":
for dev in devs:
print("working On device:", dev)
query="`Device Name` =="+ "'"+dev+"'"
main=(wb.book.parse("Main")).query(query)
main=smain.query(query)
get=(wb.book.parse("GET")).query(query)
sett=(wb.book.parse("SET")).query(query)
cmd=(wb.book.parse("CMD")).query(query)
mode=(wb.book.parse("MODE")).query(query)
outfile.append(outdir+dev+".xlsx")
with pd.ExcelWriter(outfile[-1]) as writer:
main.to_excel(writer,sheet_name='Main')
get.to_excel(writer,sheet_name='GET')
sett.to_excel(writer,sheet_name='SET')
cmd.to_excel(writer,sheet_name='CMD')
mode.to_excel(writer,sheet_name='MODE')
main.to_excel(writer,sheet_name='Main', index=False)
get.to_excel(writer,sheet_name='GET',index=False)
sett.to_excel(writer,sheet_name='SET',index=False)
cmd.to_excel(writer,sheet_name='CMD',index=False)
mode.to_excel(writer,sheet_name='MODE',index=False)
print("Working on files:",dev)
mygen=genFromTemplates(outfile[-1],options.prefix,options.module,options.basedir)
mygen.generateFileInDir()
......
......@@ -18,11 +18,9 @@ if __name__=="__main__":
gen_dir=os.environ["PYGEN"]
excel_file =options.book_file
wb=excelIcd(excel_file)
wb.getMain()
get=wb.getSheet("MODE")
for idx in range(0,get["NRows"]):
name=(get["OPC_UA node"][idx].split(";")[1]).split("=")[1].replace(".","_")
print(name)
#wb.getMain()
get=wb.getSheet("Main")
print(get)
Supports Markdown
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