Newer
Older
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
function print_the_help {
echo "USAGE: make_scpi_ioc -n NAME "
echo " OPTIONS: "
echo " -n,--name NAME IOC name (must begin with letter)"
exit
}
function yes_or_no {
while true; do
read -p "$* [y/n]: " yn
case $yn in
[Yy]*) return 0 ;;
[Nn]*) echo "No entered" ; return 1 ;;
esac
done
}
NAME=
#if [[ $# -eq 0 ]] ; then
# print_the_help
# exit
#fi
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
-h|--help)
shift # past argument
print_the_help
;;
-n|--name)
NAME="$2"
shift # past argument
shift # past value
;;
#-a|--all)
# LOG_ALL_PLOTS=1
# shift # past argument
# #shift # past value
# ;;
#-o|--online-only)
# ONLINE_ONLY=1
# shift # past argument
# #shift # past value
# ;;
*) # unknown option
#POSITIONAL+=("$1") # save it in an array for later
echo "unknown option $1"
print_the_help
shift # past argument
;;
esac
done
set -- "${POSITIONAL[@]}" # restore positional parameters
if [[ -z "${NAME}" ]] ; then
echo "Error: ioc NAME must be supplied"
print_the_help
exit
fi
if [ -d "${NAME}" ]
then
echo "Directory ${NAME} exists."
echo "Error: cannot overrite ${NAME}"
else
echo "Making directory ${NAME}"
mkdir "${NAME}"
fi
cd "${NAME}"
makeSupport.pl -t streamSCPI ${NAME}
rm -r configure
makeBaseApp.pl -t ioc ${NAME}
makeBaseApp.pl -i -t ioc ${NAME}
sed -i '29iCALC = /opt/epics/synApps/support/calc' configure/RELEASE
sed -i '29iSTREAM = /opt/epics/synApps/support/stream' configure/RELEASE
sed -i '29iASYN = /opt/epics/synApps/support/asyn' configure/RELEASE
# fix the install ...
sed -i '6d' ${NAME}Sup/Makefile
sed -i "6iDB_INSTALLS += \$\(TOP\)/${NAME}Sup/dev${NAME}.db" ${NAME}Sup/Makefile
sed -i "17i${NAME}_DBD += drvVxi11.dbd" ${NAME}App/src/Makefile
sed -i "17i${NAME}_DBD += calc.dbd" ${NAME}App/src/Makefile
sed -i "17i${NAME}_DBD += stream.dbd" ${NAME}App/src/Makefile
#sed -i "17i${NAME}_DBD += stream.dbd" ${NAME}App/src/Makefile
sed -i "39i${NAME}_LIBS += stream asyn calc" ${NAME}App/src/Makefile
cat << EOF > iocBoot/ioc${NAME}/st.cmd
#!../../bin/linux-x86_64/${NAME}
#- You may have to change ${NAME} to something else
#- everywhere it appears in this file
< envPaths
epicsEnvSet ("STREAM_PROTOCOL_PATH", ".:\$(TOP)/db:../protocols")
# Allow PV name prefixes and serial port name to be set from the environment
epicsEnvSet "R" "\$(R=test)"
#epicsEnvSet "TTY" "\$(TTY=/dev/tty.PL2303-000013FA)"
cd "\${TOP}"
## Register all support components
dbLoadDatabase "dbd/${NAME}.dbd"
${NAME}_registerRecordDeviceDriver pdbbase
vxi11Configure ("L0","10.10.241.61",1,1000,"inst0",0)
# If vxi11 isn't fully supported just use TCP:
#drvAsynIPPortConfigure ("L0", "10.10.241.78:9221")
# Serial port config
#drvAsynSerialPortConfigure ("L0","/dev/ttyUSB2")
#asynSetOption ("L0", 0, "baud", "9600")
#asynSetOption ("L0", 0, "bits", "8")
#asynSetOption ("L0", 0, "parity", "none")
#asynSetOption ("L0", 0, "stop", "1")
#asynSetOption ("L0", 0, "clocal", "Y")
#asynSetOption ("L0", 0, "crtscts", "N")
#asynSetTraceMask("L0", 0, 6)
#asynSetTraceIOMask("L0", 0, 6)
#dbLoadRecords("db/dev${NAME}.db","P=\$(P),R=\$(R),PORT=L0,A=0")
cd "\${TOP}/iocBoot/\${IOC}"
iocInit
## Start any sequence programs
#seq sncxxx,"user=you"
EOF