#
# Property of ABB Vasteras/Sweden. All rights reserved.
# Copyright 1999.
#
# Install.cmd script for 4.0 /PE 000628
#
# Install questions
#    var 1  = Option loop
#    var 2  = Option loop
#    var 3  = irb variant
#    var 4  = trafo type
#    var 5  = Tp language
#    var 6  = 0 
#    var 7  = TP font (0=ISO-Latin,1=Katakan)
#    var 9  = Query mode
#    var 10 = temp use.
#
sysbsu_config -timeout 300
mc_config_memory
mkdir -path "SYSTEM"
mkdir -path "SYSTEM/INFO"
memsize -pgm 6200000 -cfg 1550000 -tx 550000 -uwm 70000 -console 20000
eiosetup -cross 200 -unit 41 -driv 50 -phy 1200 -log 1200 -symb 1400 -pf 1200 -subscr 512 -bus 10
init

setstr -strvar $ANSWER -value "BootBase"
selectmedia -strvar $ANSWER -boot

config -version 4 -revision 0
# Early elog start
task -slotname elogts -slotid 1 -pri 90 -vwopt 0x1c -stcks 5000 -entp elog_main -auto
task  -slotname elog_all -pri 120 -vwopt 0x1c -stcks 5000 -entp elog_all -auto
synchronize -level task
go -level task
invoke -entry root_elog_new

invoke -entry IoMgrInit -errlabel ERROR
# VC IOC SKIP
ifvc -label VC_IOC_SKIP
loadComputer -path $ROOTPATH/bin/ioc0 -single 0
invoke -entry IoMgrRemoteInit -errlabel ERROR
delay -time 5000
creat -name /ioc0/tpu1:/tpu1: -pmode 0
#VC_IOC_SKIP

invoke -entry delay_init -errlabel ERROR
task -slotname delay_high -entp delay_ts -pri 60 -vwopt 0x1c -stcks 8000 -nosync -auto
task -slotname delay_medium -entp delay_ts -pri 78 -vwopt 0x1c -stcks 8000 -nosync -auto
task -slotname delay_low -entp delay_ts -pri 140 -vwopt 0x1c -stcks 8000 -nosync -auto
invoke -entry eiomsg_init -arg 100 -nomode -errlabel ERROR

init -resource sio
init -resource eio
init -resource motion
init -resource proc
init -resource cab
init -resource tp

# Teachpendant setup for VC or RW
ifvc -label VC_TPU_SKIP
teachpendant -device "/tpu1:" -type 0 -font B -keyclick 50 -idletime 120 \
-commtimeout 2000 -moverate 100 -idlerate 500
goto -label INSTALL_START
#VC_TPU_SKIP
teachpendant -device wintpu -type 0 -font B -keyclick 50 -idletime 120 \
-commtimeout 2000 -moverate 100 -idlerate 500
#INSTALL_START

echo -text "Installation start ..."
setvar -var 9 -value 10
setvar -var 6 -value 0
setvar -var 10 -value 0
setstr -strvar $TEMP1 -value "NoQuery"
getkey -id $TEMP1 -var 10 -strvar $TEMP2 -errlabel NEXT
setvar -var 9 -value 10
goto -label QUERY
#NEXT
echo -text "Select installation mode:"
echo -text ""
echo -text "Silent = No queries "
echo -text "EasyQuery = Mode + Lang + InstallOpt"
echo -text "   Mode = Std or Service mode"
echo -text "   Lang = Language query"
echo -text "   InstallOpt = Keep/remove options"
echo -text "Query  = Query all"
query -text "Silent        EasyQuery         Query" -var 9 -fk_text -timeout 10
if -var 9 -value 10 -label QUERY
if -var 9 -value 50 -label QUERY
setvar -var 9 -value 30
#QUERY

task -slotname cabts -slotid 17 -pri 100 -vwopt 0x1c -stcks 45000 \
-entp cabts_main -auto

ifvc -label VC_SYSDMP_SKIP
task -slotname sysdmpts -slotid 79 -pri 150 -vwopt 0x1c -stcks 7000 \
-entp sysdmpts -auto
#VC_SYSDMP_SKIP

#CONFIG_LOAD
# system defined config files
echo -text "Installing system config files"
config -filename  $BOOTPATH/sys.cfg -domain SYS -internal
config -filename $BOOTPATH/eiobase.cfg -domain EIO -internal
setvar -var 10 -value 0
getkey -id "SkipStdPanel" -var 10 -strvar $ANSWER -errlabel STD_PANEL
goto -label CONFIG_NEXT
#STD_PANEL
config -filename $BOOTPATH/eio509.cfg -domain EIO -internal
#CONFIG_NEXT
#------------------------------------------------------------------
if -var 9 -value 50 -label USER_QUERY
if -var 9 -value 30 -label USER_QUERY
setvar -var 10 -value 0
getkey -id "MocParMmc" -var 10 -strvar $ANSWER -errlabel STD_MOCPAR
goto -label ADVANCE_MOCPAR
#USER_QUERY
echo -text "Select Service/Standard motion param:"
query -text "Stand                          Service" -var 10 -fk_text
if -var 10 -value 50 -label ADVANCE_MOCPAR
#STD_MOCPAR
config -filename  $BOOTPATH/moc_mmc.cfg -domain MOC -internal
goto -label CONFIG_NEXT
#ADVANCE_MOCPAR
config -filename  $BOOTPATH/moc_mmcs.cfg -domain MOC -internal
#CONFIG_NEXT
config -filename  $BOOTPATH/sys_mmc.cfg -domain SYS -internal
config -filename  $BOOTPATH/com_mmc.cfg -domain SIO -internal
config -filename  $BOOTPATH/eio_mmc.cfg -domain MMC -internal
config -filename  $BOOTPATH/mmc_350.cfg -domain MMC -internal
config -filename  $BOOTPATH/mmc_351.cfg -domain MMC -internal
config -filename  $BOOTPATH/mmc_352.cfg -domain MMC -internal
config -filename  $BOOTPATH/mmc_378.cfg -domain MMC -internal

config -filename  $BOOTPATH/pgmbtn.cfg -domain MMC  -internal
config -filename  $BOOTPATH/rlmset.cfg -domain MMC  -internal
config -filename  $BOOTPATH/rlmove.cfg -domain MMC -internal
config -filename  $BOOTPATH/rlmsys.cfg -domain MMC -internal
config -filename  $BOOTPATH/rlexe.cfg -domain MMC -internal
config -filename  $BOOTPATH/rlcom.cfg -domain MMC -internal
config -filename  $BOOTPATH/rlio.cfg -domain MMC -internal
config -filename  $BOOTPATH/rltrap.cfg -domain MMC -internal
config -filename  $BOOTPATH/rlmmec.cfg -domain MMC -internal
config -filename  $BOOTPATH/rlsys.cfg -domain MMC -internal
config -filename  $BOOTPATH/rlload.cfg -domain MMC -internal
config -filename  $BOOTPATH/rlmsrc.cfg -domain MMC -internal
config -filename  $BOOTPATH/rltrig.cfg -domain MMC -internal
config -filename  $BOOTPATH/rlpid.cfg -domain MMC -internal
config -filename  $BOOTPATH/rlsmod.cfg -domain MMC -internal
config -filename  $BOOTPATH/rlfsta.cfg -domain MMC -internal
config -filename  $BOOTPATH/rlraps.cfg -domain MMC -internal
config -filename  $BOOTPATH/rlmath.cfg -domain MMC -internal
config -filename  $BOOTPATH/rlsset.cfg -domain MMC -internal
config -filename  $BOOTPATH/rlstr.cfg -domain MMC -internal
config -filename  $BOOTPATH/rlcure.cfg -domain MMC -internal
config -filename  $BOOTPATH/rlwz.cfg -domain MMC -internal
config -filename  $BOOTPATH/rltool.cfg -domain MMC -internal
config -filename  $BOOTPATH/rlsym.cfg -domain MMC -internal
config -filename  $BOOTPATH/rlbit.cfg -domain MMC -internal
config -filename  $BOOTPATH/rlcal.cfg -domain MMC -internal
config -filename  $BOOTPATH/rlcnv.cfg -domain MMC -internal

config -filename  $BOOTPATH/rlbasic.cfg -domain SYS -internal
config -filename  $BOOTPATH/rldbg.cfg -domain SYS -internal

config -filename  $BOOTPATH/hip.cfg -domain MMC -internal
config -filename  $BOOTPATH/hiref.cfg -domain MMC -internal
config -filename  $BOOTPATH/hifi.cfg -domain MMC -internal
config -filename  $BOOTPATH/datatype.cfg -domain MMC -internal
config -filename  $BOOTPATH/hia.cfg -domain MMC
config -filename  $BOOTPATH/hic.cfg -domain MMC
config -filename  $BOOTPATH/hij.cfg -domain MMC
config -filename  $BOOTPATH/mmc.cfg -domain MMC
config -filename  $BOOTPATH/wm.cfg -domain MMC
config -filename  $BOOTPATH/his.cfg -domain MMC
# Site dependent default config files
config -filename  $BOOTPATH/usrsys.cfg -domain SYS
setvar -var 10 -value 0
getkey -id "SkipStdPanel" -var 10 -strvar $ANSWER -errlabel STD_PANEL
config -filename  $BOOTPATH/pntmmc.cfg -domain MMC
goto -label CONFIG_NEXT
#STD_PANEL
config -filename  $BOOTPATH/usrmmc.cfg -domain MMC
#CONFIG_NEXT
config -filename  $BOOTPATH/com_int.cfg -domain SIO -internal
config -filename  $BOOTPATH/com_ext.cfg -domain SIO

new -resource proc

#
#RAPID instruction texts
#
echo -text "Installing RAPID"
text -filename  $BOOTPATH/pgmbtn.eng -package 0

text -filename  $BOOTPATH/rlmset.eng -package 0
text -filename  $BOOTPATH/rlmove.eng -package 0
text -filename  $BOOTPATH/rlmsys.eng -package 0
text -filename  $BOOTPATH/rlexe.eng -package 0
text -filename  $BOOTPATH/rlcom.eng -package 0
text -filename  $BOOTPATH/rlio.eng -package 0
text -filename  $BOOTPATH/rltrap.eng -package 0
text -filename  $BOOTPATH/rlmmec.eng -package 0
text -filename  $BOOTPATH/rlsys.eng -package 0
text -filename  $BOOTPATH/rlload.eng -package 0
text -filename  $BOOTPATH/rlcure.eng -package 0
text -filename  $BOOTPATH/rlmsrc.eng -package 0
text -filename  $BOOTPATH/rltrig.eng -package 0
text -filename  $BOOTPATH/rlfsta.eng -package 0
text -filename  $BOOTPATH/rlraps.eng -package 0
text -filename  $BOOTPATH/rlmath.eng -package 0
text -filename  $BOOTPATH/rlsset.eng -package 0
text -filename  $BOOTPATH/rlstr.eng -package 0
text -filename  $BOOTPATH/rlwz.eng -package 0
text -filename  $BOOTPATH/rltool.eng -package 0
text -filename  $BOOTPATH/rlsym.eng -package 0
text -filename  $BOOTPATH/rlbit.eng -package 0
text -filename  $BOOTPATH/rlcal.eng -package 0
text -filename  $BOOTPATH/rlcnv.eng -package 0
text -filename  $BOOTPATH/rldbg.eng -package 0                       


synchronize -level task
go -level task

echo -text "Installing system files"

fileexist -path opt_l0.cmd -label CLEANUP_0
goto -label NEXT_STEP
#CLEANUP_0
delete -path opt_l0.cmd
#NEXT_STEP
fileexist -path option.cmd -label CLEANUP_1
goto -label NEXT_STEP
#CLEANUP_1
delete -path option.cmd
#NEXT_STEP
fileexist -path opt_l2.cmd -label CLEANUP_2
goto -label NEXT_STEP
#CLEANUP_2
delete -path opt_l2.cmd
#NEXT_STEP

copy -from $BOOTPATH/instopt.cmd -to instopt.cmd
copy -from $BOOTPATH/katakan.tpu -to katakan.tpu
copy -from $BOOTPATH/startup.cmd -to startup.cmd
copy -from $BOOTPATH/user.sys -to user.sys
copy -from $BOOTPATH/base_mt.sys -to base_mt.sys

setstr -strvar $ANSWER -value "LanguageSub"
selectmedia -strvar $ANSWER -label NEXT_STEP
echo -text "Old key file install TP text"

setstr -strvar $ANSWER -value "Language"
selectmedia -strvar $ANSWER -label NEXT_STEP
echo -text "Error install TP text"
goto -label ERROR
#NEXT_STEP

setvar -var 10 -value 0
getkey -id "SkipIrb" -var 10 -strvar $ANSWER -errlabel IRB
echo -text "Skip install Irb"
goto -label CONFIG_NEXT
#IRB
setstr -strvar $ANSWER -value "Irb"
selectmedia -strvar $ANSWER -label CONFIG_NEXT
echo -text "Error install Irb"
goto -label ERROR
#CONFIG_NEXT

setvar -var 1 -value 0
setvar -var 2 -value 30
loop -path "instopt.cmd" -var 2
delete -path instopt.cmd

setstr -strvar $ANSWER -value "ExtOpt"
selectmedia -strvar $ANSWER -option
#NEXT_STEP


setvar -var 10 -value 0
getkey -id "ExtCfg" -var 10 -strvar $CFGPATH -errlabel SYSPAR_DEF
goto -label SYSPAR
#SYSPAR_DEF
setstr -strvar $CFGPATH -value "syspar" 
#SYSPAR

fileexist -path $CFGPATH/moc.cfg -label ERASE_MOC
goto -label NEXT_ERASE_STEP
#ERASE_MOC
echo -text "Replacing domain MOC"
config -erase -domain MOC
config -filename $CFGPATH/moc.cfg -domain MOC

#NEXT_ERASE_STEP
fileexist -path $CFGPATH/eio.cfg -label ERASE_EIO
goto -label NEXT_ERASE_STEP
#ERASE_EIO
echo -text "Replacing domain EIO"
config -erase -domain EIO
config -filename $CFGPATH/eio.cfg  -domain EIO

#NEXT_ERASE_STEP
fileexist -path $CFGPATH/sio.cfg -label ERASE_SIO
goto -label NEXT_ERASE_STEP
#ERASE_SIO
echo -text "Replacing domain SIO"
config -erase -domain SIO
config -filename $CFGPATH/sio.cfg  -domain SIO

#NEXT_ERASE_STEP
fileexist -path $CFGPATH/mmc.cfg -label ERASE_MMC
goto -label NEXT_ERASE_STEP
#ERASE_MMC
echo -text "Replacing domain MMC"
config -erase -domain MMC
config -filename $CFGPATH/mmc.cfg  -domain MMC

#NEXT_ERASE_STEP
fileexist -path $CFGPATH/proc.cfg -label ERASE_PROC
goto -label NEXT_ERASE_STEP
#ERASE_PROC
echo -text "Replacing domain PROC"
config -erase -domain PROC
config -filename $CFGPATH/proc.cfg -domain PROC

#NEXT_ERASE_STEP
fileexist -path $CFGPATH/sys.cfg -label ERASE_SYS
goto -label NEXT_ERASE_STEP
#ERASE_SYS
echo -text "Replacing domain SYS"
config -erase -domain SYS
config -filename $CFGPATH/sys.cfg -domain SYS

#NEXT_ERASE_STEP
fileexist -path $CFGPATH/calib.cfg -label ADD_MOC
goto -label NEXT_ERASE_STEP
#ADD_MOC
echo -text "Load calib file"
config -replace -filename $CFGPATH/calib.cfg -domain MOC
#NEXT_ERASE_STEP
#NEXT_STEP

echo -text "Installing RAPID instruction sets"
new -resource cab
restart
delay -time 6000
# Make System Warmstart (use Startup.cmd)
# A VC will continue to execute the script after restart
goto -label NO_ERROR
#ERROR
echo -text "Error during installation !"
echo -text "Please retry to install the system."
#NO_ERROR
