Commit 024147b4 authored by Gino Tosti's avatar Gino Tosti
Browse files

added management of multiple devices for a single assembly

parent e7aee8fa
......@@ -39,7 +39,7 @@ class excelIcd:
siz=self.sheets[sheet_name].shape
if(self.debug):
print(self.sheets[sheet_name].columns,siz[0],siz[1])
self.getMain()
self.MainSheet=self.getSheet("Main")
self.GetSheet=self.getSheet("GET")
self.SetSheet=self.getSheet("SET")
self.CmdSheet=self.getSheet("CMD")
......@@ -48,9 +48,9 @@ class excelIcd:
def getMain(self):
self.MainSheet["NCols"]=(self.sheets["Main"].shape)[1]
self.MainSheet["NRows"]=(self.sheets["Main"].shape)[0] -2
self.MainSheet["Colnames"]= self.sheets["Main"].columns[1:]
for colind,coname in enumerate (self.sheets["Main"].loc[0]):
self.MainSheet["NRows"]=(self.sheets["Main"].shape)[0]
self.MainSheet["Colnames"]= self.sheets["Main"].columns
for colind,coname in enumerate (self.sheets["Main"]):
#print "CCC",coname
colval=[]
......@@ -59,7 +59,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+1,colind])
colval.append(self.sheets["Main"].iat[idx,colind])
self.MainSheet[coname]=colval
if(self.debug):
......@@ -69,23 +69,27 @@ class excelIcd:
def getSheet(self, name):
Sheet={}
Sheet["NCols"]=(self.sheets[name].shape)[1]
Sheet["NRows"]=(self.sheets[name].shape)[0]
Sheet["Colnames"]= self.sheets[name].columns
#print(Sheet["Colnames"])
for colind,coname in enumerate (self.sheets[name]):
#coname=self.sheets["Main"].cell(1,colind).value
#print "CCC",coname
colval=[]
#colname=(str(coname)).replace(' ','_')
for idx in range(0,Sheet["NRows"]):
#print "BBBBB", self.sheets["Main"].cell(idx,colind).value
colval.append(self.sheets[name].iat[idx,colind])
Sheet[coname]=colval
#print(coname,Sheet[coname])
print("Read Sheet:",name," from:", self.bookfile )
return Sheet
try:
Sheet["NCols"]=(self.sheets[name].shape)[1]
Sheet["NRows"]=(self.sheets[name].shape)[0]
Sheet["Colnames"]= self.sheets[name].columns
#print(Sheet["Colnames"])
for colind,coname in enumerate (self.sheets[name]):
#coname=self.sheets["Main"].cell(1,colind).value
#print "CCC",coname
colval=[]
#colname=(str(coname)).replace(' ','_')
for idx in range(0,Sheet["NRows"]):
#print "BBBBB", self.sheets["Main"].cell(idx,colind).value
colval.append(self.sheets[name].iat[idx,colind])
Sheet[coname]=colval
#print(coname,Sheet[coname])
print("Read Sheet:",name," from:", self.bookfile )
return Sheet
except:
print("sheet:",name,"does not exist")
return None
......
......@@ -67,43 +67,43 @@ class genFromTemplates:
self.gendir+"/templates/GUIBridgeController1.tmpl",
self.gendir+"/templates/GUIBridgeComponent1.tmpl",
self.gendir+"/templates/GUIBridge1.tmpl",
self.gendir+"/templates/Makefile1.tmpl",]
self.genFile=[wbook.MainSheet["Assembly"][0]+"Base.midl",
wbook.MainSheet["Assembly"][0]+"Base.xsd",
wbook.MainSheet["Assembly"][0]+".xml",
wbook.MainSheet["Assembly"][0]+"_component.xml",
wbook.MainSheet["Assembly"][0]+"BaseImpl.java",
wbook.MainSheet["Assembly"][0]+".idl", "Makefile",
wbook.MainSheet["Assembly"][0]+"Impl.java",
wbook.MainSheet["Assembly"][0]+"Server.txt",
wbook.MainSheet["Assembly"][0]+"Main.java",
wbook.MainSheet["Assembly"][0]+"GUIBridgeController.java",
wbook.MainSheet["Assembly"][0]+"GUIBridgeComponent.java",
wbook.MainSheet["Assembly"][0]+"GUIBridge.fxml", "MakefileGui"]
self.genFileNoGUI=[wbook.MainSheet["Assembly"][0]+"Base.midl",
wbook.MainSheet["Assembly"][0]+"Base.xsd",
wbook.MainSheet["Assembly"][0]+".xml",
wbook.MainSheet["Assembly"][0]+"_component.xml",
wbook.MainSheet["Assembly"][0]+"BaseImpl.java",
wbook.MainSheet["Assembly"][0]+".idl", "Makefile",
wbook.MainSheet["Assembly"][0]+"Impl.java",
wbook.MainSheet["Assembly"][0]+"ComponentHelper.java",
wbook.MainSheet["Assembly"][0]+"BaseComponentHelper.java",
self.gendir+"/templates/Makefile1.tmpl"]
self.genFile=[wbook.MainSheet["Component Name"][0]+"Base.midl",
wbook.MainSheet["Component Name"][0]+"Base.xsd",
wbook.MainSheet["Component Name"][0]+".xml",
wbook.MainSheet["Component Name"][0]+"_component.xml",
wbook.MainSheet["Component Name"][0]+"BaseImpl.java",
wbook.MainSheet["Component Name"][0]+".idl", "Makefile",
wbook.MainSheet["Component Name"][0]+"Impl.java",
wbook.MainSheet["Component Name"][0]+"Server.txt",
wbook.MainSheet["Component Name"][0]+"Main.java",
wbook.MainSheet["Component Name"][0]+"GUIBridgeController.java",
wbook.MainSheet["Component Name"][0]+"GUIBridgeComponent.java",
wbook.MainSheet["Component Name"][0]+"GUIBridge.fxml", "MakefileGui"]
self.genFileNoGUI=[wbook.MainSheet["Component Name"][0]+"Base.midl",
wbook.MainSheet["Component Name"][0]+"Base.xsd",
wbook.MainSheet["Component Name"][0]+".xml",
wbook.MainSheet["Component Name"][0]+"_component.xml",
wbook.MainSheet["Component Name"][0]+"BaseImpl.java",
wbook.MainSheet["Component Name"][0]+".idl", "Makefile",
wbook.MainSheet["Component Name"][0]+"Impl.java",
wbook.MainSheet["Component Name"][0]+"ComponentHelper.java",
wbook.MainSheet["Component Name"][0]+"BaseComponentHelper.java",
"__init__.py",
wbook.MainSheet["Assembly"][0]+"Base.py",
('AddSQL_'+wbook.MainSheet["Assembly"][0]+".sql")]
#'AddSQL_'+wbook.MainSheet["Assembly"][0]+'.sql']
#wbook.MainSheet["Assembly"][0]+"Server.txt",
#wbook.MainSheet["Assembly"][0]+"Main.java",
#wbook.MainSheet["Assembly"][0]+"GUIBridgeController.java",
#wbook.MainSheet["Assembly"][0]+"GUIBridgeComponent.java",
#wbook.MainSheet["Assembly"][0]+"GUIBridge.fxml", "MakefileGui"]
wbook.MainSheet["Component Name"][0]+"Base.py",
('AddSQL_'+wbook.MainSheet["Component Name"][0]+".sql")]
#'AddSQL_'+wbook.MainSheet["Component Name"][0]+'.sql']
#wbook.MainSheet["Component Name"][0]+"Server.txt",
#wbook.MainSheet["Component Name"][0]+"Main.java",
#wbook.MainSheet["Component Name"][0]+"GUIBridgeController.java",
#wbook.MainSheet["Component Name"][0]+"GUIBridgeComponent.java",
#wbook.MainSheet["Component Name"][0]+"GUIBridge.fxml", "MakefileGui"]
today = date.today()
self.service =[1,2,3,4,5]
self.devdir=self.wb.MainSheet["Assembly"][0]
self.devdir=self.wb.MainSheet["Component Name"][0]
self.outdir=os.path.join(basedir,self.devdir)
self.nameSpace = {'Author': "Gino Tosti", "Date":today.strftime("%y/%m/%d"),
'Description':wbook.MainSheet["Description"][0],
'Description':wbook.MainSheet["Description"][0],'Component Name':wbook.MainSheet["Component Name"][0],
'URL':wbook.MainSheet["OPC UA address"][0],'prefix':prefix,'module':module,
'Assembly': wbook.MainSheet["Assembly"][0], 'x': wbook,'y':datatype}
self.nameSpacePy = {'Author': "Gino Tosti", "Date":today.strftime("%y/%m/%d"),
......@@ -122,8 +122,8 @@ class genFromTemplates:
self._dirs['tcl']=self._dirs['src']+'TCL/'
self._dirs['prefix']=self._dirs['src']+'/'+self.nameSpace['prefix']
self._dirs['module']=self._dirs['prefix']+'/'+self.nameSpace['module']
self._dirs['Impl']=self._dirs['module']+'/'+self.nameSpace['Assembly']+'Impl/'
self._dirs['BaseImpl']=self._dirs['module']+'/'+self.nameSpace['Assembly']+'BaseImpl/'
self._dirs['Impl']=self._dirs['module']+'/'+self.nameSpace['Component Name']+'Impl/'
self._dirs['BaseImpl']=self._dirs['module']+'/'+self.nameSpace['Component Name']+'BaseImpl/'
def generateFiles(self):
for i in range(0,len(self.genFile)):
print ("Generating file:",self.genFile[i],self.templFiles[i])
......@@ -210,14 +210,14 @@ class genFromTemplates:
cdirMaci=os.path.join(cdbdir,"MACI/Components")
print (cdirMaci)
#os.chdir(cdirMaci)
xmldir=os.path.join(cdbdir,"alma/"+self.nameSpace['Assembly'])
xmldir=os.path.join(cdbdir,"alma/"+self.nameSpace['Component Name'])
if not os.path.exists(xmldir):
os.mkdir(xmldir)
else:
print ("Directory:", xmldir," already exists")
self._generateFile(2,xmldir+"/")
compdir=os.path.join(cdirMaci,self.nameSpace['Assembly'])
compdir=os.path.join(cdirMaci,self.nameSpace['Component Name'])
if not os.path.exists(compdir):
os.mkdir(compdir)
else:
......
python setup.py bdist_wheel
python -m pip install dist/GenDevice-0.1-py3-none-any.whl
......@@ -35,20 +35,60 @@ if __name__ =="__main__":
print ("ACS Enviroment is not set")
exit()
pwd=os.getcwd()
mygen=genFromTemplates(options.bookfile, options.prefix,options.module,options.basedir)
mygen.generateFileInDir()
if options.install :
introot = os.environ["INTROOT"]
if introot=="":
print("INTROOT variable is not set")
exit()
os.chdir(mygen._dirs['src'])
print ("Make Build ")
command="make clean all"
print (command)
if execACSCommand(command):
print ("ERROR executing: ",command,)
excel_file =options.book_file
wb=excelIcd(excel_file)
devs=wb.MainSheet['Device Name']
comp=wb.MainSheet['Component Name']
assembly=wb.MainSheet['Assembly']
outdir="/media/sf_Desktop/Useful_SW/"
outfile=[]
if len(assembly)>1 :
print ("the Assembly:"+assembly[0]+" includes more than one device\n",devs)
for dev in devs:
query="`Device Name` =="+ "'"+dev+"'"
print("working On:", query)
main=(wb.book.parse("Main")).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')
print("Working on files:",dev)
mygen=genFromTemplates(outfile[-1],options.prefix,options.module,options.basedir)
mygen.generateFileInDir()
if options.install :
introot = os.environ["INTROOT"]
if introot=="":
print("INTROOT variable is not set")
exit()
os.chdir(mygen._dirs['src'])
print ("Make Build ")
command="make clean all"
print (command)
if execACSCommand(command):
print ("ERROR executing: ",command,)
os.chdir(pwd)
else:
mygen=genFromTemplates(options.book_file,options.prefix,options.module,options.basedir)
mygen.generateFileInDir()
if options.install :
introot = os.environ["INTROOT"]
if introot=="":
print("INTROOT variable is not set")
exit()
os.chdir(mygen._dirs['src'])
print ("Make Build ")
command="make clean all"
print (command)
if execACSCommand(command):
print ("ERROR executing: ",command,)
os.chdir(pwd)
"""else:
command ="make install"
if execACSCommand(command):
......
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