#
# Property of ABB Vasteras/Sweden. All rights reserved.
# Copyright 1999.
#
# Startup.cmd script for 4.0 /PE 000518
#
silent
#log_console -on
sysbsu_config -timeout 300
mc_config_memory
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
svcsetup
init
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 gtime_init
invoke -entry rtc_init
invoke -entry IoMgrInit -errlabel ERROR

# VC IOC SKIP #1
ifvc -label VC_IOC_SKIP1
loadComputer -path $ROOTPATH/bin/ioc0 -single 0
invoke -entry IoMgrRemoteInit -errlabel ERROR
invoke -entry ftpdNewStart
wait

fileexist -path opt_l3.cmd -label LOAD_CMD
goto -label NEXT_STEP
#LOAD_CMD
include -path opt_l3.cmd
#NEXT_STEP

#VC_IOC_SKIP1

invoke -entry timer_init -errlabel ERROR
invoke -entry delay_init -errlabel ERROR
invoke -entry appif_init -errlabel ERROR

# VC COMMAND DEVICE SKIP
ifvc -label CMD_DEV_SKIP
invoke -entry cmddev_init -errlabel ERROR
#CMD_DEV_SKIP

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_mbus -entp delay_ts -pri 96 -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
iomgrinstall -entry fpdm -name /fpdm
iomgrinstall -entry simFBC -name /simfbc
iomgrinstall -entry swFBC -name /swfbc
creat -name /simfbc/simfbc1: -pmode 0
creat -name /fpdm/sim1:/simfbc1: -pmode 0
creat -name /swfbc/swfbc1: -pmode 0
creat -name /fpdm/sw1:/swfbc1: -pmode 0

# VC IOC SKIP #2
ifvc -label VC_IOC_SKIP2
invoke -entry watchdog_create -strarg "/pci0" -nomode
creat -name /ioc0/BASE1:/BASE1: -pmode 0
creat -name /ioc0/READBASE1:/READBASE1: -pmode 0
creat -name /ioc0/elog0/elog -pmode 0
invoke -entry root_elog_remote
creat -name /ioc0/tpu1:/tpu1: -pmode 0
#VC_IOC_SKIP2

invoke -entry read_init -errlabel ERROR

fileexist -path opt_l0.cmd -label LOAD_CMD
goto -label NEXT_STEP
#LOAD_CMD
include -path opt_l0.cmd
#NEXT_STEP

invoke -entry root_eio_init
init -resource sio
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 TASK_START
#VC_TPU_SKIP
teachpendant -device wintpu -type 0 -font B -keyclick 50 -idletime 120 \
-commtimeout 2000 -moverate 100 -idlerate 500
#TASK_START
# task definitions: 

task -path $(SEARCH)$(HPBIN)/alarmts  \
-slotname alarmts -slotid 16 -pri 80 -vwopt 0x1c -stcks 5000 \
-entp alarmts -auto

synchronize -level task
delay -time 500
go -level task

task -path $(SEARCH)$(HPBIN)/cabsupts  \
-slotname cabsupts -slotid 62 -pri 130 -vwopt 0x1c -stcks 5000 \
-entp cabsup_main

task -path $(SEARCH)$(HPBIN)/pstopts \
-slotname pstopts -pri 30 -vwopt 0x1c -stcks 2500 \
-entp pstopts_main -auto -nosync

task -slotname eiots -slotid 54 -pri 70 -vwopt 0x1c -stcks 10000 \
-entp eiots -auto

task -slotname eioadmts -slotid 55 -pri 74 -vwopt 0x1c -stcks 10000 \
-entp eioadmts -auto

# VC IOC SKIP #3
ifvc -label VC_IOC_SKIP3
creat -name /ioc0/ioc0sio1/tyCo1: -pmode 0
creat -name /ioc0/ioc0sio2/tyCo2: -pmode 0
creat -name /ioc0/ioc0dnsio1/dnsio1: -pmode 0
invoke -entry SioX86HwInit
#VC_IOC_SKIP3
iomgrinstall -entry UserSio -name /usersio
creat -name /usersio/SIO -pmode 0

new -resource proc

reconfigure -resource eio

# New read task for FBC for VC
ifvc -label VC_SIMFBC
goto -label NO_VC_SIMFBC
#VC_SIMFBC
task -slotname SIM1 -entp read_ts -pri 76 -vwopt 0 -stcks 4000 -nosync -auto
readparam -devicename /sim1:/device -rmode 1 -buffersize 5000
#NO_VC_SIMFBC

invoke -entry safspvts_init
invoke -entry eio_start_supervision -nomode
synchronize -level io_system -timeout 60

# VC Simulated Panel Init
ifvc -label VC_SIM_PANEL
goto -label NO_SIM_PANEL
#VC_SIM_PANEL
invoke -entry simio_init -nomode
#NO_SIM_PANEL

reconfigure -resource sio

task -slotname safevtts  -slotid 20 -pri 20 -vwopt 0x1c -stcks 10000 \
-entp safevtts -auto

task -slotname sysevtts  -slotid 30 -pri 95 -vwopt 0x1c -stcks 5000 \
-entp sysevtts -auto

task -slotname safcycts  -slotid 29 -pri 80 -vwopt 0x1c -stcks 8000 \
-entp safcycts -auto

task -slotname safspvts -pri 190  -vwopt 0x1c -stcks 5000 \
-entp safspvts -auto -nosync

task -slotname ipolts -slotid 18 -pri 90 -vwopt 0x1c -stcks 50000 \
-entp ipolts_main -auto

# VC MOTION SKIP
ifvc -label VC_MOTION
goto -label RW_MOTION
#VC_MOTION
task -slotname servots -slotid 19 -pri 3 -vwopt 0x1c -stcks 60000 \
-entp servoqt -auto
goto -label RW_MOTION_SKIP

#RW_MOTION
task -slotname servots -slotid 19 -pri 3 -vwopt 0x1c -stcks 60000 \
-entp servots -auto -slots 2

task -slotname refmats -slotid 52 -pri 2 -vwopt 0x1c -stcks 20000 \
-entp refmats -auto

task -slotname dsp_flts -slotid 28 -pri 4 -vwopt 0x1c -stcks 5000 \
-entp dsp_flts_main -auto
#RW_MOTION_SKIP

task -slotname bcalcts -slotid 44 -pri 200 -vwopt 0x1c -stcks 30000 \
-entp bcalcts -auto

ifvc -label RW_MOTION_END
task -slotname logsrvts -slotid 51 -pri 100 -vwopt 0x1c -stcks 20000 \
-entp logsrvts -auto
#RW_MOTION_END

task -slotname peventts -slotid 21 -pri 70 -vwopt 0x1c -stcks 25000 \
-entp peventts -auto

task -slotname rloadts -slotid 45 -pri 105 -vwopt 0x1c -stcks 10000 \
-entp peventts -auto

task -slotname barts -slotid 78 -pri 135 -vwopt 0x1c -stcks 40000 \
-entp barts_main -auto

task -slotname rlcomts -slotid 27 -pri 100 -vwopt 0x1c -stcks 8000 \
-entp rlcomts_main -auto

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

task -slotname wmb -slotid 24 -pri 125 -vwopt 0x1c -stcks 3000 \
-entp wmb_main -auto

task -slotname wm -slotid 3 -pri 110 -vwopt 0x1c -stcks 10000 \
-entp wm_main -auto

task -slotname tpiRdts -pri 80 -vwopt 0x1c -stcks 10000 \
-entp tpiRd_ts -auto -nosync

task -slotname tpits -slotid 4 -pri 80 -vwopt 0x1c -stcks 10000 \
-entp tpi_ts -auto


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

# VC TPU INIT SKIP
ifvc -label VC_TPU_SKIP
task -slotname tpiupts -pri 80 -vwopt 0x1c -stcks 10000 \
-entp tpiup_ts -auto
#VC_TPU_SKIP

synchronize -level task
delay -time 500
go -level task

task -path $(SEARCH)$($(HPBIN))/rhaltts \
-slotname rhaltts -pri 30 -vwopt 0x1c -stcks 2500 \
-entp rhaltts_main -auto -nosync


#PNT new -entry purge_sync
#PNT delay -time 5000

# RAP Startup
task -slotname rapsynts -pri 125 -vwopt 0x1c -stcks 28000 \
-entp rapsynts_main -auto

task -slotname rapdatts -pri 125 -vwopt 0x1c -stcks 15000 \
-entp rapdatts_main -auto

task -slotname rapts -pri 130 -vwopt 0x1c -stcks 35000 \
-entp rapts -auto

task -slotname rapts1 -pri 50 -vwopt 0x1c -stcks 10000 \
-entp rapts1 -auto

fileexist -path option.cmd -label LOAD_CMD
goto -label NEXT_STEP
#LOAD_CMD
include -path option.cmd
#NEXT_STEP

new -resource motion
delay -time 1500
connect_dependings -object SYS_STORED_OBJ_CAB -instance 0 -man 0 -ipm 0 -servo 0 -ipol 0 

# syncronization (setsync) to be used with network systems only
# setsync
if -var 52 -value 1 -label SYNCROB
goto -label NOSYNC
#SYNCROB
# syncronization (setsync) to be used with network systems only
setsync
#NOSYNC

#task -slotname reiots -slotid 38 -pri 80 -vwopt 0x1c -stcks 5000 \
#-entp reiots -auto 

new -resource cab

ifvc -label VC_SYSDMP_CFG_SKIP
sysdmp_config
#VC_SYSDMP_CFG_SKIP

task -slotname spoolts -slotid 34 -pri 140 -vwopt 0x1c -stcks 3000 \
-entp spool_main -auto

task -slotname him -slotid 7 -pri 120 -vwopt 0x1c -stcks 10000 \
-entp him_main -auto

task -slotname hix -slotid 31 -pri 120 -vwopt 0x1c -stcks 5000 \
-entp hix_main  -auto

task -slotname hio -slotid 5 -pri 120 -vwopt 0x1c -stcks 10000 \
-entp hio_main -auto

task -slotname hic -slotid 11 -pri 120 -vwopt 0x1c -stcks 15000 \
-entp hic_main -auto

task -slotname hij -slotid 8 -pri 120 -vwopt 0x1c -stcks 30000 \
-entp hij_main -auto

task -slotname hpjts -slotid 22 -pri 99 -vwopt 0x1c -stcks 30000 \
-entp hpj_main -auto

task -slotname hif -slotid 14 -pri 120 -vwopt 0x1c -stcks 50000 \
-entp hif_main  -auto

task -slotname his -slotid 12 -pri 120 -vwopt 0x1c -stcks 10000 \
-entp his_main  -auto

task -slotname hiats -slotid 6 -pri 120 -vwopt 0x1c -stcks 50000 \
-entp hia_main  -auto

task -slotname hip -slotid 13 -pri 120 -vwopt 0x1c -stcks 10000 \
-entp hip_main -auto

# Init of S4api for VC
ifvc -label S4API_INIT
goto -label NO_S4API_INIT
#S4API_INIT
task -slotname s4apits -slotid 10 -pri 40 -vwopt 0x1c -stcks 20000 \
-entp s4api_main  -auto -slots 3
#NO_S4API_INIT

fileexist -path opt_l2.cmd -label LOAD_CMD
goto -label NEXT_STEP
#LOAD_CMD
include -path opt_l2.cmd
#NEXT_STEP
if -var 7 -value 1 -label KATAKAN2
goto -label NOKATAKAN
#KATAKAN2
delay -time 1000
loadfont -path katakan.tpu
#NOKATAKAN
synchronize -level task
elogact
go -level task
tpkey_on
systemrun
new -resource tp
new -resource sermeas
taskset -pri 95 -slotname tNetTask
#pool_mem_show

