# File: fl_fd_close.src
#
# This control file closes the MDI front door.
# The initial door status is checked, motor 2 is exercised,
# then motor 1 is used to close the door.
#

program "@(#) MODULE: fl_fd_close.src RELEASE: %R%.%L% CREATED: %G% %U%"
source "/mdisw/cfl/flight/src/fl_fd_close.src"
descr "fl_fd_close - Close MDI front door"

display "Executing procedure fl_fd_close."

if getdig(mkfdopn1) <> "        OPEN" then
  display "mkfdopn1 status is NOT correct - procedure halted"
  halt
end if

if getdig(mkfdopn2) <> "    NOT OPEN" then
  display "mkfdopn2 status is NOT correct - procedure halted"
  halt
end if

if getdig(msfdopn) <> "        OPEN" then
  display "msfdopn status is NOT correct - procedure halted"
  halt
end if

if getdig(mkfdmtr1) <> "  NOT CLOSED" then
  display "mkfdmtr1 status is NOT correct - procedure halted"
  halt
end if

if getdig(mkfdmtr2) <> "      CLOSED" then
  display "mkfdmtr2 status is NOT correct - procedure halted"
  halt
end if

if getdig(msfdcln) <> "  NOT CLOSED" then
  display "msfdcln status is NOT correct - procedure halted"
  halt
end if

tcblock mbfdrs                           ## reset door controller
tcblock mbpwfdon                         ## turn on 15V to door

wait time 60

if getdig(mkpwfd) <> "          ON" then
  display "Front door power is NOT on - procedure halted"
  halt
end if

ask !LS0 "Type <Enter> when ready to continue"

display "Open front door on motor 2"
tcblock mbfd2o                           ## open with motor 2

wait time 60                             ## wait for door to open

set !LI1 = getint(mkfdtime)              ## get move time
display "   open 2 time: %d" !LI1

if getdig(mkfdmove) <> "  NOT MOVING" then
  display "mkfdmove status is NOT correct - procedure halted"
  halt
end if

if getdig(mkfdopn2) <> "        OPEN" then
  display "mkfdopn2 status is NOT correct - procedure halted"
  halt
end if

if getdig(mkfdmtr2) <> "  NOT CLOSED" then
  display "mkfdmtr2 status is NOT correct - procedure halted"
  halt
end if

ask !LS0 "Type <Enter> when ready to continue"

display "Close front door on motor 2"
tcblock mbfd2c                           ## close with 2

wait time 60                             ## wait for door to close

set !LI1 = getint(mkfdtime)              ## get move time
display "   close 2 time: %d" !LI1

if getdig(mkfdmove) <> "  NOT MOVING" then
  display "mkfdmove status is NOT correct - procedure halted"
  halt
end if

if getdig(mkfdopn2) <> "    NOT OPEN" then
  display "mkfdopn2 status is NOT correct - procedure halted"
  halt
end if

if getdig(mkfdmtr2) <> "      CLOSED" then
  display "mkfdmtr2 status is NOT correct - procedure halted"
  halt
end if

ask !LS0 "Type <Enter> when ready to continue"

display "Close front door on motor 1"
tcblock mbfd1c                           ## close with motor 1

wait time 60                             ## wait for door to close

set !LI1 = getint(mkfdtime)              ## get move time
display "   close 1 time: %d" !LI1

if getdig(mkfdmove) <> "  NOT MOVING" then
  display "mkfdmove status is NOT correct - procedure halted"
  halt
end if

if getdig(mkfdopn1) <> "    NOT OPEN" then
  display "mkfdopn2 status is NOT correct - procedure halted"
  halt
end if

if getdig(mkfdmtr1) <> "      CLOSED" then
  display "mkfdmtr2 status is NOT correct - procedure halted"
  halt
end if

if getdig(msfdopn) <> "    NOT OPEN" then
  display "msfdopn status is NOT correct - procedure halted"
  halt
end if

if getdig(msfdcln) <> "      CLOSED" then
  display "msfdcln status is NOT correct - procedure halted"
  halt
end if

tcblock mbpwfdof                         ## turn off 15V to door

wait time 60

if getdig(mkpwfd) <> "         OFF" then
  display "Front door power is NOT off - procedure halted"
  halt
end if

display "Finished procedure fl_fd_close.                      "

return
