enhance generate.py

This commit is contained in:
2023-09-11 09:53:01 +02:00
parent 907f91dd9d
commit 7ea859926b

View File

@@ -26,7 +26,7 @@ class Generate:
'SAR-CPPM-EXPMX2' : ('SAR-CPPM-EXPMX2' , 50001 , '7.0.7' , 'eldk42-ppc4xxFP' , 'eldk42-ppc4xxFP' , 'eldk42-ppc4xxFP' , ) , 'SAR-CPPM-EXPMX2' : ('SAR-CPPM-EXPMX2' , 50001 , '7.0.7' , 'eldk42-ppc4xxFP' , 'eldk42-ppc4xxFP' , 'eldk42-ppc4xxFP' , ) ,
'SAR-CPPM-EXPMX3' : ('SAR-CPPM-EXPMX3' , 50001 , '7.0.7' , 'eldk42-ppc4xxFP' , 'eldk42-ppc4xxFP' , 'eldk42-ppc4xxFP' , ) , 'SAR-CPPM-EXPMX3' : ('SAR-CPPM-EXPMX3' , 50001 , '7.0.7' , 'eldk42-ppc4xxFP' , 'eldk42-ppc4xxFP' , 'eldk42-ppc4xxFP' , ) ,
'SAR-CPPM-EXPMX4' : ('SAR-CPPM-EXPMX4' , 50001 , '7.0.7' , 'eldk42-ppc4xxFP' , 'eldk42-ppc4xxFP' , 'eldk42-ppc4xxFP' , ) , 'SAR-CPPM-EXPMX4' : ('SAR-CPPM-EXPMX4' , 50001 , '7.0.7' , 'eldk42-ppc4xxFP' , 'eldk42-ppc4xxFP' , 'eldk42-ppc4xxFP' , ) ,
'SARES30-CPCL-MCSSMX' : ('saresc-softioc-11' , 50001 , '7.0.6' , 'x86_64' , 'RHEL7' , 'rhel' , ) , 'SARES30-CPCL-MCSSMX' : ('saresc-softioc-11' , 50001 , '7.0.7' , 'x86_64' , 'RHEL7' , 'rhel' , ) ,
} }
iocSmarAct={ iocSmarAct={
@@ -36,24 +36,25 @@ class Generate:
'host':'129.129.244.32', # 00:04:a3:a2:71:35, MCS0060 Serial: 3762 'host':'129.129.244.32', # 00:04:a3:a2:71:35, MCS0060 Serial: 3762
'prefix':'SARES30-SMX', 'prefix':'SARES30-SMX',
'loc':'EH.057 MobRack', 'loc':'EH.057 MobRack',
'fmt':'{{{PORT:5},{S:14},{M:6},{ADDR:>4},{DESC:14},{DIR:3},{VELO:4},{DHLM:>6},{DLLM:>6},{EGU:4},{PTYP:4},{RTRY:4}}}\n',
'motLst':( 'motLst':(
# description , PV name , axis , hlm , llm , dir , egu , sens , # dir: Pos:0 Neg:1
('COLLI:TX' , 'MCS1' , 0 , 12 , -10 , 1 , 'mm' , 'S' ) , ( 'DESC' , 'M' , 'ADDR', 'DHLM', 'DLLM', 'DIR', 'EGU', 'PTYP'),
('COLLI:TY' , 'MCS2' , 1 , 12 , -10 , 1 , 'mm' , 'S' ) , ('COLLI:TX' , 'MCS1' , 0 , 12 , -10 , 1 , 'mm' , 'S' ) ,
('Motor3' , 'MCS3' , 2 , 10 , -10 , 0 , 'mm' , 'S' ) , ('COLLI:TY' , 'MCS2' , 1 , 12 , -10 , 1 , 'mm' , 'S' ) ,
('POSTTUBE:TX1' , 'MCS4' , 3 , 10 , -10 , 0 , 'mm' , 'S' ) , ('Motor3' , 'MCS3' , 2 , 10 , -10 , 0 , 'mm' , 'S' ) ,
('POSTTUBE:TX2' , 'MCS5' , 4 , 10 , -10 , 0 , 'mm' , 'S' ) , ('POSTTUBE:TX1', 'MCS4' , 3 , 10 , -10 , 0 , 'mm' , 'S' ) ,
('POSTTUBE:TY1' , 'MCS6' , 5 , 15 , -20 , 0 , 'mm' , 'S' ) , ('POSTTUBE:TX2', 'MCS5' , 4 , 10 , -10 , 0 , 'mm' , 'S' ) ,
('POSTTUBE:TY2' , 'MCS7' , 6 , 15 , -20 , 0 , 'mm' , 'S' ) , ('POSTTUBE:TY1', 'MCS6' , 5 , 15 , -20 , 0 , 'mm' , 'S' ) ,
('POSTTUBE:TZ' , 'MCS8' , 7 , 10 , -10 , 1 , 'mm' , 'S' ) , ('POSTTUBE:TY2', 'MCS7' , 6 , 15 , -20 , 0 , 'mm' , 'S' ) ,
('Motor9' , 'MCS9' , 8 , 10 , -10 , 0 , 'mm' , 'S' ) , ('POSTTUBE:TZ' , 'MCS8' , 7 , 10 , -10 , 1 , 'mm' , 'S' ) ,
('SLITS:X1' , 'MCS10' , 9 , 10 , -10 , 1 , 'mm' , 'S' ) , ('Motor9' , 'MCS9' , 8 , 10 , -10 , 0 , 'mm' , 'S' ) ,
('SLITS:X2' , 'MCS11' , 10 , 10 , -10 , 1 , 'mm' , 'S' ) , ('SLITS:X1' , 'MCS10', 9 , 10 , -10 , 1 , 'mm' , 'S' ) ,
('SLITS:Y1' , 'MCS12' , 11 , 10 , -10 , 1 , 'mm' , 'S' ) , ('SLITS:X2' , 'MCS11', 10 , 10 , -10 , 1 , 'mm' , 'S' ) ,
('SLITS:Y2' , 'MCS13' , 12 , 10 , -10 , 1 , 'mm' , 'S' ) , ('SLITS:Y1' , 'MCS12', 11 , 10 , -10 , 1 , 'mm' , 'S' ) ,
('XEYE:TX' , 'MCS14' , 13 , 10 , -10 , 0 , 'mm' , 'S' ) , ('SLITS:Y2' , 'MCS13', 12 , 10 , -10 , 1 , 'mm' , 'S' ) ,
('XEYE:TY' , 'MCS15' , 14 , 10 , -10 , 0 , 'mm' , 'S' ) , ('XEYE:TX' , 'MCS14', 13 , 10 , -10 , 0 , 'mm' , 'S' ) ,
('XEYE:TY' , 'MCS15', 14 , 10 , -10 , 0 , 'mm' , 'S' ) ,
), ),
} }
} }
@@ -141,8 +142,14 @@ os: {osys}
os_id: {osys_id} os_id: {osys_id}
''' '''
lutSensMcs={'S':0, 'SR':1, 'SP':2, 'SC':3, 'SR20':4, 'M':5, 'SD':6, 'SR2':7, 'MD':8, 'SC500':9, 'User Def':10, # /home/zamofing_t/Documents/doc-ext/SmaractMCS/MCS2PositionerTypes.pdf Positioner Types Cross Reference
'None':11, 'LC':12, 'L':13} lutPSENS={ # abrev_(MCS2code, MCS1code)
'S':(300,1),'SD':(301,21),'SP':(302,5),'SC':(303,6),'SCD':(304,24),'SC500':(307,18),'SR20':(309,8),
'SR':(312,2),'SR2':(313,23),'SR77':(316,20),'SR120':(320,37),'G605DS':(325,48),'G775DS':(328,49),
'LE':(342,43),'LED':(343,44),'L':(345,41),'LD':(346,42),'LC':(348,38),'LCD':(349,40),'LR':(354,39),
'M':(357,9),'MD':(358,32),'GD':(363,11),'GE':(366,12),'G605L':(381,50),'G775L':(383,51),'G605LE':(387,53),
'G775LE':(389,54),'G605LC':(396,57),'G775LC':(398,58),'G775LE':(389,54),
}
tplMcsCtrl='''\ tplMcsCtrl='''\
################################################################### ###################################################################
@@ -169,7 +176,7 @@ smarActMCSCreateController("{port}", "asyn{port}", {num_ax}, 0.1, 1.0)
''' '''
tplMcsAxis='''\ tplMcsAxis='''\
smarActMCSCreateAxis({port}, {axis}, {chan}) smarActMCSCreateAxis({PORT}, {ADDR}, {ADDR})
''' '''
mcsSubsHdr='''\ mcsSubsHdr='''\
@@ -179,7 +186,6 @@ file asyn.template {{{{P={prefix}, PORT=asyn{port}}}}}
file $(smarActMot_DIR)/db/MCS_axis.template file $(smarActMot_DIR)/db/MCS_axis.template
{{ {{
pattern pattern
{{PORT ,S ,M ,ADDR,DESC ,DIR,VBAS,VMAX,DHLM,DLLM,EGU,SENSOR ,UDSENS,RTRY}}
''' '''
tplPwrBrkCtrl='''\ tplPwrBrkCtrl='''\
@@ -259,6 +265,17 @@ file PPMACMotor.template
pattern pattern
''' '''
# tpl_asyn='''\
#record(asyn,"$(P):$(R=asyn)")
#{
# field(DTYP,"asynRecordDevice")
# field(PORT,"$(PORT)")
# field(ADDR,"0")
# field(OMAX,"100")
# field(IMAX,"100")
#}
#'''
def __init__(self): def __init__(self):
os.makedirs('gen/ioc/',exist_ok=True) os.makedirs('gen/ioc/',exist_ok=True)
@@ -374,16 +391,23 @@ file PPMACMotor.template
tplAxis=Generate.tplMcsAxis tplAxis=Generate.tplMcsAxis
#tplAxSR=Generate.tplMcsAxisSaveRestore #tplAxSR=Generate.tplMcsAxisSaveRestore
subsHdr=Generate.mcsSubsHdr subsHdr=Generate.mcsSubsHdr
lutSens=Generate.lutSensMcs lutPSENS=Generate.lutPSENS
os.makedirs('gen/ioc/cfg/',exist_ok=True) os.makedirs('gen/ioc/cfg/',exist_ok=True)
for ioc,v in Generate.iocSmarAct.items(): for ioc,v in Generate.iocSmarAct.items():
# fh_ss startup script # fh_ss startup script
# fh_sb substitution # fh_sb substitution
# fh_sr save restore # fh_sr save restore
fmt=' '+v['fmt']
motLst=v['motLst'] hdr=v['motLst'][0]
if len(v['motLst'])>1:
motLst=v['motLst'][1:]
else:
motLst=tuple()
param= {k: v[k] for k in {'port','host','prefix','loc'}} param= {k: v[k] for k in {'port','host','prefix','loc'}}
ioc_host,ioc_port=Generate.yamlParam[ioc][:2] try:
ioc_host,ioc_port=Generate.yamlParam[ioc][:2]
except KeyError as e:
_log.warning(repr(e)+': skipped');continue
param['ioc']=ioc param['ioc']=ioc
param['ioc_host']=ioc_host param['ioc_host']=ioc_host
param['ioc_port']=ioc_port param['ioc_port']=ioc_port
@@ -403,17 +427,24 @@ file PPMACMotor.template
#fh_sr=open(fn,'w') #fh_sr=open(fn,'w')
fh_ss.write(tplCtrl.format(**param)) fh_ss.write(tplCtrl.format(**param))
fh_sb.write(subsHdr.format(**param)) fh_sb.write(subsHdr.format(**param))
port=param['port'] h=hdr+('PORT','S','VELO','RTRY')
prefix=param['prefix'] motPar=dict(zip(h, h))
for d, m, a, hlm, llm, dir,egu,sens in motLst: fh_sb.write(fmt.format(**motPar))
sens=lutSens[sens] for motPar in motLst:
param={'PORT':port,'S':prefix,'M':m,'ADDR':a,'DESC':'"'+d+'"', motPar=dict(zip(hdr, motPar))
'DIR':dir,'VBAS':0,'VMAX':2,'DHLM':hlm,'DLLM':llm,'EGU':egu,'SENSOR':sens,'UDSENS':0,'RTRY':1} try:
fh_sb.write(' {{{PORT:10},{S:16},{M:10},{ADDR:4},{DESC:27},{DIR:3},{VBAS:4},{VMAX:4},{DHLM:4},{DLLM:4},{EGU:3},{SENSOR:7},{UDSENS:5}{RTRY:5}}}\n'.format(**param)) motPar['PTYP']=lutPSENS[motPar['PTYP']][1] #idx0 is for MCS1
fh_ss.write(tplAxis.format(port=port,axis=a,chan=a)) except KeyError as e:
#fh_sr.write(tplAxSR.format(prefix=prefix,m=m)) if motPar['PTYP']!=0:
_log.info(f'{motPar["PTYP"]} not in lookup table')
motPar['PORT']=v['port']
motPar['S']=v['prefix']
motPar['VELO']=2
motPar['RTRY']=1
fh_sb.write(fmt.format(**motPar))
fh_ss.write(tplAxis.format(**motPar))
#fh_sr.write(tplAxSR.format(**motPar))
fh_sb.write('}\n\n') fh_sb.write('}\n\n')
fh_ss.close() fh_ss.close()
fh_sb.close() fh_sb.close()