#!/bin/bash

#dir=BOS_11Mar20
#config=122Am0pInt
#rdg=(1415	1416	1417	1418	1419	1420	1421	1422	1423	1424	1429	1430	1431	1432	1433	1434	1435	1436	1437	1439	1440)
#sp=(3	5	7	401	402	403	404	405	406	407	1153	1163	1173	1183	1193	1203	1213	1223	1233	1162	1152)

#dir=BOS_12Mar20
#config=122DLm0p2068
#rdg=(1442	1446	1447	1448	1449	1450	1451	1452	1453	1454	1455	1456)
#sp=(7	1153	1163	1173	1183	1193	1203	1213	1223	1233	1162	1152)

#dir=BOS_12Mar20b
#config=122DLm5p2069
#rdg=(1457	1459	1460	1461	1462	1463	1464	1465	1466	1467	1468	1469)
#sp=(7	1153	1163	1173	1183	1193	1203	1213	1223	1233	1162	1152)

#dir=BOS_13Mar20
#config=122DLm5p2079
#rdg=(1471	1474	1475	1476	1477	1478	1479	1480	1481	1482	1483	1484)
#sp=(7	1153	1163	1173	1183	1193	1203	1213	1223	1233	1162	1152)

#dir=BOS_13Mar20b
#config=122DLm5p2068
#rdg=(1485	1486	1487	1488	1489	1490	1491	1492	1493	1494	1495	1496)
#sp=(7	1153	1163	1173	1183	1193	1203	1213	1223	1233	1162	1152)

dir=BOS_17Mar20
config=122Am5pInt
rdg=(1498	1501	1502	1503	1504	1505	1506	1507	1508	1509	1510	1511	1512)
sp=(7	1153	1163	1173	1183	1193	1203	1213	1223	1233	1162	1152	1152)

#dir=BOS_17Mar20b
#config=122DSm5p2069
#rdg=(1513	1514	1515	1516	1517	1518	1519	1520	1521	1522	1523	1524)
#sp=(7	1153	1163	1173	1183	1193	1203	1213	1223	1223	1233	1152)

###########################################

unzip -o ${config}_BOS.zip 

for (( i=0; i<${#rdg[@]}; i++ ))
 do
   ed BOSx.lay << EOF
1,\$s/config/${config}/
1,\$s/rdg/${rdg[$i]}/
1,\$s/setpoint/${sp[$i]}/
w tmp.lay
q
EOF
   ed BOSx.mcr << EOF
1,\$s/config/${config}/
1,\$s/setpoint/${sp[$i]}/
w tmp.mcr
q
EOF
   open -g -W -n '/Applications/Tecplot 360 EX 2017 R2/Tecplot 360 EX 2017 R2.app' --args tmp.mcr > /dev/null
 done
rm *.dat
