# File: ipwload.src
#
# Loads IP WCS. 
#
# Created by M.Levay from IPLOAD.  
#

program "@(#) MODULE: ipwload.src RELEASE: 2.3 CREATED: 04/19/94 13:51:56"
source "/mdisw/cfl/eof/src/ipwload.src"
descr "  ipwload - Loads IP WCS"

display "Executing procedure ipwload."
write  !GS9 "Executing procedure ipwload :"
write  !GS9 " %s" !DATE
writen !GS9 " %s" !TIME
writen !GS9 " "

#  Load WCS as Needed
menu !LS1 "Need to Load WCS?" "YES" "NO"

setstr !LS2 = "NOLOAD"
if !LS1 = "YES" then
  setstr !LS2 = "LOAD"
end if

load:
setstr !LS3 = "NOERR"
if !LS2 = "LOAD" then

  display "Loading WCS"
  writen !GS9 "Loading WCS"
  tcblock mbiplbic 0x36 6
  display "Waiting 1 minute for load to complete" to 30
  wait time 70
  if getraw(hk1[309]) <> 9 then
    setstr !LS3 = "ERR"
  end if
  if getraw(hk1[310]) <> 0 then
    setstr !LS3 = "ERR"
  end if
  if getraw(hk1[311]) <> 1 then
    setstr !LS3 = "ERR"
  end if
end if

if !LS3 = "NOERR" then
  goto loaddone
end if

display "**** ERROR LOADING WCS****"
beep
writen !GS9 "**** ERROR LOADING WCS****" 

menu !LS1 "Try Load again?" "YES" "NO"

setstr !LS2 = "NOLOAD"
if !LS1 = "YES" then
  setstr !LS2 = "LOAD"
end if

if !LS2 = "LOAD" then
  goto load
end if

ask !LS1 "WCS LOAD ERROR.  OPERATOR MUST SELECT ACTION AFTER HALT"

halt

loaddone:

#  Reset APU & DMA, then Run
tcblock mbipcmd 5
tcblock mbiprsap
tcblock mbiprun

wait mf 2
if getint(mkipstat) <> 0x48 then
  ask !LS1 "IP DID NOT GO TO RUN.... RESET IP, ABORT, AND RETRY"
  halt
end if

writen !GS9 " "
writen !GS9 "Finished procedure ipwload: %s" !TIME
writen !GS9 " "

return

