migrate smaract to community driver, update ui-files
This commit is contained in:
190
generate.py
190
generate.py
@@ -17,33 +17,98 @@ from __future__ import print_function
|
||||
import logging, sys, os, json
|
||||
import string
|
||||
|
||||
host2param={
|
||||
#HOST runScript
|
||||
'SAR-CPPM-EXPMX1': ('require ESB_MX\nrunScript $(ESB_MX_DIR)/add_EXPMX1.cmd "P=SAR-EXPMX,PORT=PPMAC1"',),
|
||||
'SAR-CPPM-EXPMX2': ('require ESB_MX\nrunScript $(ESB_MX_DIR)/add_EXPMX2.cmd "P=SAR-EXPMX,PORT=PPMAC1"',),
|
||||
'SAR-CPPM-EXPMX3': ('require ESB_MX\nrunScript $(ESB_MX_DIR)/add_EXPMX3.cmd "P=SAR-EXPMX,PORT=PPMAC1"',),
|
||||
}
|
||||
class Generate:
|
||||
yamlParam={
|
||||
# ioc : ( host , port , ver , arch , osys , osys_id ,
|
||||
# 'SAR-CSSU-EXPMX1' : ('SAR-CSSU-EXPMX1' , 50001 , '3.14.12' , 'moxa42-armv6l' , 'moxa42-armv6l' , 'moxa42-armv6l' , ) ,
|
||||
'SAR-CPPM-EXPMX1' : ('SAR-CPPM-EXPMX1' , 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-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' , ) ,
|
||||
}
|
||||
|
||||
mxSmarAct={
|
||||
'port':'MCS',
|
||||
'host':'129.129.244.32',
|
||||
'prefix':'SARES30-SMX',
|
||||
'motLst':(
|
||||
# description , PV name , axis , hlm , llm , dir , sens ,
|
||||
('COLLI:TX' , 'MCS1' , 0 , 12 , -10 , 1 , 'S' ) ,
|
||||
('COLLI:TY' , 'MCS2' , 1 , 12 , -10 , 1 , 'S' ) ,
|
||||
('Motor3' , 'MCS3' , 2 , 10 , -10 , 0 , 'S' ) ,
|
||||
('POSTTUBE:TX1' , 'MCS4' , 3 , 10 , -10 , 0 , 'S' ) ,
|
||||
('POSTTUBE:TX2' , 'MCS5' , 4 , 10 , -10 , 0 , 'S' ) ,
|
||||
('POSTTUBE:TY1' , 'MCS6' , 5 , 15 , -20 , 0 , 'S' ) ,
|
||||
('POSTTUBE:TY2' , 'MCS7' , 6 , 15 , -20 , 0 , 'S' ) ,
|
||||
('POSTTUBE:TZ' , 'MCS8' , 7 , 10 , -10 , 1 , 'S' ) ,
|
||||
('Motor9' , 'MCS9' , 8 , 10 , -10 , 0 , 'S' ) ,
|
||||
('SLITS:X1' , 'MCS10' , 9 , 10 , -10 , 1 , 'S' ) ,
|
||||
('SLITS:X2' , 'MCS11' , 10 , 10 , -10 , 1 , 'S' ) ,
|
||||
('SLITS:Y1' , 'MCS12' , 11 , 10 , -10 , 1 , 'S' ) ,
|
||||
('SLITS:Y2' , 'MCS13' , 12 , 10 , -10 , 1 , 'S' ) ,
|
||||
('XEYE:TX' , 'MCS14' , 13 , 10 , -10 , 0 , 'S' ) ,
|
||||
('XEYE:TY' , 'MCS15' , 14 , 10 , -10 , 0 , 'S' ) ,
|
||||
),
|
||||
}
|
||||
|
||||
pb_host2param={
|
||||
# HOST runScript
|
||||
'SAR-CPPM-EXPMX1':('','require ESB_MX\nrunScript $(ESB_MX_DIR)/add_EXPMX1.cmd "P=SAR-EXPMX,PORT=PPMAC1"',),
|
||||
'SAR-CPPM-EXPMX2':('','require ESB_MX\nrunScript $(ESB_MX_DIR)/add_EXPMX2.cmd "P=SAR-EXPMX,PORT=PPMAC1"',),
|
||||
'SAR-CPPM-EXPMX3':('','require ESB_MX\nrunScript $(ESB_MX_DIR)/add_EXPMX3.cmd "P=SAR-EXPMX,PORT=PPMAC1"',),
|
||||
'SAR-CPPM-EXPMX4':('','require ESB_MX\nrunScript $(ESB_MX_DIR)/add_EXPMX4.cmd "P=SAR-EXPMX,PORT=PPMAC1"',),
|
||||
}
|
||||
|
||||
|
||||
tplYaml='''\
|
||||
cpu_architecture: {os}
|
||||
os: {os}
|
||||
os_id: {os}
|
||||
epics_version: 7.0.7
|
||||
tplYaml='''\
|
||||
ioc_host: {host}
|
||||
ioc_port: {port}
|
||||
epics_version: {ver}
|
||||
cpu_architecture: {arch}
|
||||
os: {osys}
|
||||
os_id: {osys_id}
|
||||
'''
|
||||
|
||||
##################################################################
|
||||
# DO NOT EDIT: Generated with epics_ioc_modules/OATT/generate.py
|
||||
# This is the IOC on "{host}" port {port}:
|
||||
##################################################################
|
||||
tplScriptPowerBrickIOC='''\
|
||||
#####################################
|
||||
lutSensMcs={'S':0, 'SR':1, 'SP':2, 'SC':3, 'SR20':4, 'M':5, 'SD':6, 'SR2':7, 'MD':8, 'SC500':9, 'User Def':10,
|
||||
'None':11, 'LC':12, 'L':13}
|
||||
|
||||
tplMcsCtrl='''\
|
||||
epicsEnvSet("ENGINEER", "T. Zamofing (zamofing_t)")
|
||||
epicsEnvSet("LOCATION", "0.Z553.58")
|
||||
|
||||
#load module
|
||||
# motorSmarAct community driver
|
||||
# smarActMot PSI templates and other files
|
||||
require motorSmarAct zamofing_t
|
||||
#require motorSmarAct
|
||||
require smarActMot
|
||||
# -------------
|
||||
drvAsynIPPortConfigure("asyn{port}", "{host}:5000", 0, 0, 0)
|
||||
# PORT, MCS_PORT, number of axes, active poll period (sec), idle poll period (sec)
|
||||
smarActMCSCreateController("{port}", "asyn{port}", {num_ax}, 0.1, 1.0)
|
||||
'''
|
||||
|
||||
tplMcsAxis='''\
|
||||
smarActMCSCreateAxis({port}, {axis}, {chan})
|
||||
'''
|
||||
|
||||
mcs_subs_hdr='''\
|
||||
file asyn.template {{{{P={prefix}, PORT=asyn{port}}}}}
|
||||
|
||||
##### MCS
|
||||
file $(smarActMot_DIR)/db/MCS_axis.template
|
||||
{{
|
||||
pattern
|
||||
{{PORT ,S ,M ,ADDR,DESC ,DIR,VBAS,VMAX,DHLM,DLLM,EGU,SENSOR ,UDSENS,RTRY}}
|
||||
'''
|
||||
|
||||
tplScriptPowerBrickIOC='''\
|
||||
##########################################
|
||||
# DO NOT EDIT: Generated with generate.py
|
||||
# This is the IOC on host {host}
|
||||
##########################################
|
||||
# PPMAC responsible: Thierry Zamofing
|
||||
#####################################
|
||||
##########################################
|
||||
{req}
|
||||
|
||||
############################################
|
||||
@@ -62,7 +127,7 @@ powerPmacCreateController("PPMAC1", 200, 1000)
|
||||
{devConf}
|
||||
'''
|
||||
|
||||
tplEVR='''\
|
||||
tplEVR='''\
|
||||
####### initialise EVR ##############################
|
||||
# https://git.psi.ch/epics_driver_modules/mrfioc2
|
||||
require mrfioc2
|
||||
@@ -74,42 +139,43 @@ require mrfioc2_regDev
|
||||
runScript $(mrfioc2_regDev_DIR)/mrfioc2_regDev_pulseID_RX.cmd, "DEVICE=EVR0,SYS=SAR-EXPMX"
|
||||
'''
|
||||
|
||||
|
||||
class CPPM:
|
||||
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
def genIOC(self):
|
||||
print('### genIOC ###')
|
||||
tpl=tplScriptPowerBrickIOC
|
||||
|
||||
os.makedirs('gen/ioc/',exist_ok=True)
|
||||
#os.makedirs('gen/db/',exist_ok=True)
|
||||
|
||||
def genYAML(self):
|
||||
|
||||
for ioc,p in self.yamlParam.items():
|
||||
param=dict(zip(('host','port','ver','arch','osys','osys_id',),p))
|
||||
fn=f'gen/ioc/{ioc}_parameters.yaml'
|
||||
print('generate '+fn+' ...')
|
||||
fh=open(fn,'w')
|
||||
fh.write(self.tplYaml.format(**param))
|
||||
fh.close()
|
||||
print('done.')
|
||||
|
||||
def genIOC(self):
|
||||
print('### genIOC ###')
|
||||
tplIOC=Generate.tplScriptPowerBrickIOC
|
||||
yamlParam=Generate.yamlParam
|
||||
pb_h2p=Generate.pb_host2param
|
||||
tplEVR=Generate.tplEVR
|
||||
fh=open('gen/ioc/Makefile','w')
|
||||
fh.write('include /ioc/tools/ioc.makefile\n')
|
||||
fh.close()
|
||||
|
||||
port=50001
|
||||
osys='eldk42-ppc4xxFP'
|
||||
|
||||
for host,v in host2param.items():
|
||||
devConf,=v
|
||||
req=''
|
||||
|
||||
for host in yamlParam.keys():
|
||||
if not host in pb_h2p:
|
||||
assert(host=='SARES30-CPCL-MCSSMX')
|
||||
self.genSmarActIOC(host)
|
||||
continue
|
||||
req,devConf=pb_h2p[host]
|
||||
fn='gen/ioc/{host}_startup.script'.format(host=host)
|
||||
print('generate '+fn+'...')
|
||||
print('generate '+fn+' ...')
|
||||
fh=open(fn,'w')
|
||||
fh.write(tpl.format(host=host,port=port,req=req,devConf=devConf))
|
||||
fh.write(tplIOC.format(host=host,req=req,devConf=devConf))
|
||||
if host=='SAR-CPPM-EXPMX1':
|
||||
fh.write(tplEVR)
|
||||
fh.close()
|
||||
fn='gen/ioc/{host}_parameters.yaml'.format(host=host)
|
||||
print('generate '+fn+'...')
|
||||
fh=open(fn,'w')
|
||||
fh.write(tplYaml.format(os=osys,host=host,port=port))
|
||||
fh.close()
|
||||
print('done.')
|
||||
|
||||
def genLauncher(self):
|
||||
@@ -125,6 +191,36 @@ class CPPM:
|
||||
#'''.format(dev=dev))
|
||||
# fh.close()
|
||||
|
||||
def genSmarActIOC(self,ioc):
|
||||
tplCtrl=Generate.tplMcsCtrl
|
||||
tplAxis=Generate.tplMcsAxis
|
||||
motLst=Generate.mxSmarAct['motLst']
|
||||
subs=Generate.mcs_subs_hdr
|
||||
host=Generate.mxSmarAct['host']
|
||||
prefix=Generate.mxSmarAct['prefix']
|
||||
port=Generate.mxSmarAct['port']
|
||||
lutSens=Generate.lutSensMcs
|
||||
num_ax=len(motLst)
|
||||
fn=f'gen/ioc/{ioc}_startup.script'
|
||||
print('generate '+fn+' ...')
|
||||
with open(fn,'w') as fh_ss:
|
||||
fh_ss.write(tplCtrl.format(host=host,port=port,num_ax=num_ax))
|
||||
|
||||
fn_subs=f'gen/ioc/{ioc}_gen.subs' # with a name _* the .subs file is recognize by the 'ioc install' tool
|
||||
print('generate '+fn_subs+'...')
|
||||
with open(fn_subs,'w') as fh:
|
||||
fh.write(subs.format(port=port,prefix=prefix))
|
||||
for d, m, a, hlm, llm, dir,sens in motLst:
|
||||
sens=lutSens[sens]
|
||||
param={'PORT':port,'S':prefix,'M':m,'ADDR':a,'DESC':'"'+d+'"',
|
||||
'DIR':dir,'VBAS':0,'VMAX':2,'DHLM':hlm,'DLLM':llm,'EGU':'mm','SENSOR':sens,'UDSENS':0,'RTRY':1}
|
||||
fh.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))
|
||||
fh_ss.write(tplAxis.format(port=port,axis=a,chan=a))
|
||||
fh.write('}\n\n')
|
||||
|
||||
|
||||
|
||||
|
||||
if __name__=='__main__':
|
||||
def parse_args():
|
||||
import argparse
|
||||
@@ -138,10 +234,12 @@ if __name__=='__main__':
|
||||
args = parser.parse_args()
|
||||
#print(args)
|
||||
|
||||
obj=CPPM()
|
||||
obj=Generate()
|
||||
if args.mode&0x1:
|
||||
obj.genIOC()
|
||||
obj.genYAML()
|
||||
if args.mode&0x2:
|
||||
obj.genIOC()
|
||||
if args.mode&0x4:
|
||||
obj.genLauncher()
|
||||
|
||||
parse_args()
|
||||
|
||||
Reference in New Issue
Block a user