Commit b5771317 authored by Gino Tosti's avatar Gino Tosti
Browse files

added script in test for GUI files generation

parent 367c869f
Loading
Loading
Loading
Loading
+3 −4
Original line number Original line Diff line number Diff line
@@ -39,11 +39,10 @@ import astri.TCSControlExceptions.INACTErrorEx;
import java.util.Optional;
import java.util.Optional;
import alma.acs.logging.AcsLogger;
import alma.acs.logging.AcsLogger;
import java.util.logging.Level;
import java.util.logging.Level;
import astri.TCS.THCUHelper;
import astri.TCS.THCU;


import astri.TCS.${Assembly}Helper;

import astri.TCS.${Assembly};
import astri.tcs.${Assembly}Helper;
import astri.tcs.${Assembly};


public class ${Assembly}GUIBridgeComponent {
public class ${Assembly}GUIBridgeComponent {


+65 −0
Original line number Original line Diff line number Diff line
from Cheetah.Template import Template
from datetime import date
import sys,os
from optparse import OptionParser
from GenDevice.excelIcd import excelIcd
from GenDevice.genFromTemplates import datatype
from shutil import copyfile
# Read the ICD excel file
DEF_DEST ="../test/gui"
TMPL_DIR="../templates/guiTmpl/"
TMPL=["Makefile1.tmpl","GUIBridge1.tmpl",
"GUIBridgeComponent1.tmpl",
"GUIBridgeController1.tmpl",
"GUIMainApp1.tmpl"]
 
def createGUIScript(book,dest):
	
	excel_file =book
	wb=excelIcd(excel_file)
	Main=wb.getMain()
	Get=wb.getSheet("GET")
	Set=wb.getSheet("SET")
	Cmd=wb.getSheet("CMD")
	Mode=wb.getSheet("MODE")
	print(Main['Assembly'])

	if not os.path.exists(dest):
		os.mkdir(dest)
	#'Filename': outfile,
	name_space = {'Author': "Gino Tosti", "Date":today.strftime("%y/%m/%d"),
			'Description':Main["Description"][0],
			'Assembly': Main['Assembly'][0],
			'x': wb, 'y':datatype}
	for i,tp in enumerate(TMPL):
		if i==1:
			outfile=dest+"/"+Main['Assembly'][0]+"_"+ tp.replace("1.tmpl",".fxml")
		elif i==0:
			outfile=dest+"/"+ tp.replace("1.tmpl","")
		else:
			outfile=dest+"/"+Main['Assembly'][0]+"_"+ tp.replace("1.tmpl",".java")
		template_file=TMPL_DIR+tp
		
		
		t1 = Template(file=template_file, searchList=[name_space])
		ff=open(outfile,"w")
		ff.write(str(t1))
		#print(t1)
		print("File:",outfile," created")

if __name__=="__main__":
	defdest=DEF_DEST
	parser = OptionParser(usage='usage: %prog [options] arguments')
	today = date.today()
	parser.add_option("-f", "--file", dest="book_file", default=None,
                  help="ICD Exel File ", metavar="FILE")
	parser.add_option("-o", "--outdir", dest="outdir", default=None,
                  help="outputdir will be outdir/gui/ ", metavar="OUTDIR")	  
	(options, args) = parser.parse_args()
	if not options.book_file:   # if filename is not given
		parser.error('ICD file not given')
	if options.outdir!=None :
		defdest=outdir+"/gui"
	#gen_dir=os.environ["PYGEN"]
	createGUIScript(options.book_file,defdest)