Home   Package List   Routine Alphabetical List   Global Alphabetical List   FileMan Files List   FileMan Sub-Files List   Package Component Lists   Package-Namespace Mapping  
Routine: ENARGO

ENARGO.m

Go to the documentation of this file.
  1. ENARGO ;(WIRMFO)/JED,SAB-MOVE ARCHIVE GLOBAL TO STORAGE MEDIA ;4.29.97
  1. ;;7.0;ENGINEERING;**40**;Aug 17, 1993
  1. Q
  1. A ; Archive global to media
  1. ; called by ENAR1
  1. ; input
  1. ; ENGBL - global subscript in ^ENAR to be archived (e.g. 6919.1)
  1. ; ENTIME - date/time of archive session (internal format)
  1. ; ENERR - error message text (should be 0 for no error)
  1. ; output
  1. ; ENERR - error message text or 0 when no error
  1. D DT^DICRW
  1. ;
  1. S ENHFSM="W",ENHFSIO="" D ARDEV I ENERR'=0 G OUT
  1. I IOT="MT" D MTSETUP I ENERR'=0 G CLOUT
  1. I IOT="MT" D MTCHECK I ENERR'=0 G CLOUT
  1. I IOT="MT" X ENWPROT I Y D G A
  1. . D CLOSE
  1. . W $C(7),!!,"But your tape is write protected!!" D MSG
  1. ;
  1. U IO(0) W !,"Beginning output"
  1. ; determine header info
  1. S ENHD(1)=$$FMTE^XLFDT(ENTIME)
  1. S ENHD(2)=$P(^ENAR(ENGBL,0),"^",1)_", ID# "_$P(^(-1),",",3)_", "_$P(^(0),"^",3)_" RECORDS SAVED"
  1. S ENHD(3)="^ENAR("_ENGBL_",-1)"
  1. S ENHD(4)=@ENHD(3)
  1. ; write data to archive device
  1. U IO S ENSTART=$P($H,",",2)
  1. ; - write header info
  1. W ENHD(1) W:IOT'="MT" ! W ENHD(2) W:IOT'="MT" !
  1. ; - write nodes and content of nodes
  1. S ENX="^ENAR("_ENGBL_")",ENC=0
  1. F S ENX=$Q(@ENX) Q:ENX="" Q:$QS(ENX,1)'=ENGBL D
  1. . W ENX W:IOT'="MT" ! W @ENX W:IOT'="MT" !
  1. . S ENC=ENC+1 I '(ENC#100) U IO(0) W "." U IO
  1. ; - write footer info
  1. W "**EOF**" W:IOT'="MT" ! W "**EOF**" W:IOT'="MT" !
  1. U IO(0)
  1. W !,"Elapsed time: ",$J($P($H,",",2)-ENSTART/60,6,2)," minutes.",!
  1. ;
  1. S DIR(0)="Y",DIR("A")="Archive complete, care to verify",DIR("B")="YES"
  1. S DIR("?",1)="This process reads archived records and compares them to"
  1. S DIR("?",2)="the source global."
  1. S DIR("?",3)=" "
  1. S DIR("?")="Enter YES or No"
  1. D ^DIR K DIR
  1. I 'Y S ENERR="VERIFY DECLINED" K ^ENAR(ENGBL,"LOCK") G CLOUT
  1. ;
  1. S DIR(0)="SB^F:FULL;H:HEADER-ONLY"
  1. S DIR("A")="Select type of verify to perform",DIR("B")="FULL"
  1. S DIR("?",3)="FULL - Every record is read from the archive media and"
  1. S DIR("?",4)=" compared to the source global."
  1. S DIR("?",1)="HEADER-ONLY - The header data (4 lines) is read from the"
  1. S DIR("?",2)=" archive media and compared to expected values."
  1. S DIR("?",5)=" "
  1. S DIR("?")="Enter H or F"
  1. D ^DIR K DIR I $D(DIRUT) S ENERR="USER VERIFY ABORT" G CLOUT
  1. S ENVT=Y
  1. ;
  1. VRF ; Verify
  1. ; rewind (or close and reopen) device
  1. W !,"Please wait while I rewind (or reopen) the archive device."
  1. S Y=$S("^MT^HFS^SDP^"[(U_IOT_U):$$REWIND^%ZIS(IO,IOT,IOPAR),1:0)
  1. I 'Y D CLOSE S IOP=ENION,ENHFSM="R" D ARDEV G:ENERR'=0 OUT
  1. I IOT="MT" D MTCHECK I ENERR'=0 G CLOUT
  1. ;
  1. S ENREDO=0,ENSTART=$P($H,",",2)
  1. D VHDR G:ENREDO VRF I ENERR'=0 G CLOUT
  1. I ENVT="F" D VREC G:ENREDO VRF I ENERR'=0 G CLOUT
  1. ;
  1. D CLOSE
  1. W !,"Elapsed time: ",$J($P($H,",",2)-ENSTART/60,6,2)," minutes."
  1. K ^ENAR(ENGBL,"LOCK")
  1. G OUT
  1. ;
  1. VHDR ; verify header
  1. U IO(0) W !!,"Verifying Header..."
  1. U IO R ENX(1):15,ENX(2):15,ENX(3):15,ENX(4):15
  1. U IO(0)
  1. F ENI=1:1:4 Q:ENX(ENI)'=ENHD(ENI)
  1. I ENX(ENI)'=ENHD(ENI) D
  1. . W $C(7),!!,"Expected: ",ENHD(ENI),!,"Found: ",ENX(ENI)
  1. . S DIR(0)="Y",DIR("A")="Try again",DIR("B")="YES"
  1. . D ^DIR K DIR I Y S ENREDO=1 Q
  1. . S ENERR="BAD HEADER VERIFY"
  1. I ENX(ENI)=ENHD(ENI) W "Header OK"
  1. Q
  1. ;
  1. VREC ; verify records
  1. U IO(0) W !,"Continuing with full verify"
  1. S (ENC,ENC("VERR"))=0
  1. U IO
  1. F R ENX:15,ENX(1):15 Q:ENX="**EOF**" D:ENX(1)'=@ENX Q:ENC("VERR")>5 S ENC=ENC+1 I '(ENC#100) U IO(0) W "." U IO
  1. . U IO(0)
  1. . S ENC("VERR")=ENC("VERR")+1
  1. . W $C(7),!,"WARNING: ",ENX,!,"Expected: ",@ENX,!,"Found: ",ENX(1)
  1. . I ENC("VERR")'>5 W !!,"continuing"
  1. . U IO
  1. U IO(0)
  1. I ENC("VERR")>5 D
  1. . W $C(7),!,"Sorry, the verify doesn't look good"
  1. . S DIR(0)="Y",DIR("A")="Try again",DIR("B")="YES"
  1. . D ^DIR K DIR I Y S ENREDO=1 Q
  1. . S ENERR="BAD VERIFY"
  1. Q
  1. ;
  1. CLOUT ; Close archive device and exit
  1. D CLOSE
  1. OUT ; Exit
  1. K ENBOT,ENC,ENEOT,ENHD,ENHFSIO,ENHFSM,ENI,ENION,ENMTERR
  1. K ENONLINE,ENR,ENREDO,ENREW,ENSTART,ENVT,ENWPROT,ENX
  1. K DIROUT,DIRUT,DTOUT,DUOUT,X,Y
  1. Q
  1. ;
  1. MSG W !,"Press <RETURN> to continue" R ENR:DTIME S:'$T ENR="^" Q
  1. ;
  1. ARDEV ; Select and open archival device
  1. ; called from ENARGO, ENARGR
  1. ; input
  1. ; ENHFSM - host file access mode ('W'rite-only or 'R'ead-only)
  1. ; ENERR - error message text (should be 0 for no error)
  1. ; IOP - (optional) name of device to use
  1. ; ENHFSIO - (optional) name of host file to open
  1. ; output
  1. ; ENERR - 0 or error message text
  1. ; ENION - ION of selected device
  1. ; ENHFSIO - name of host file opened (only defined when IOT="HFS")
  1. I '$D(IOP) W $C(7),!!,"If using tape, please load ",$S(ENHFSM="W":"WRITE ENABLED ",ENHFSM="R":"WRITE PROTECTED ",1:""),"tape and bring on-line now",!
  1. S %ZIS("A")="ARCHIVAL DEVICE: ",%ZIS("B")="",%ZIS("HFSMODE")=ENHFSM
  1. I $G(ENHFSIO)]"" S %ZIS("HFSNAME")=ENHFSIO
  1. S %ZIS("S")="I ""^VTRM^TRM^""'[(U_$G(^(""TYPE""))_U)"
  1. D ^%ZIS I POP S ENERR="ARCHIVAL DEVICE NOT SELECTED" Q
  1. S ENION=ION
  1. S ENHFSIO=$S(IOT="HFS":IO,1:"")
  1. Q
  1. ;
  1. CLOSE ; Close archival device
  1. ; called from ENARGO, ENARGR
  1. D ^%ZISC
  1. Q
  1. ;
  1. MTSETUP ; Mag Tape Variables Setup
  1. ; called from ENARGO, ENARGR
  1. I '$D(^%ZOSF("MAGTAPE"))!('$D(^("EOT")))!('$D(^("MTBOT")))!('$D(^("MTERR")))!('$D(^("MTONLINE")))!('$D(^("MTWPROT"))) S ENERR="YOUR %ZOSF GLOBAL NODES FOR MAGTAPE ARE NOT SET UP. CANNOT PROCEED." Q
  1. X ^%ZOSF("MAGTAPE") S ENREW=%MT("REW") K %MT
  1. S ENEOT=^%ZOSF("EOT"),ENBOT=^%ZOSF("MTBOT")
  1. S ENMTERR=^%ZOSF("MTERR"),ENONLINE=^%ZOSF("MTONLINE")
  1. S ENWPROT=^%ZOSF("MTWPROT")
  1. Q
  1. ;
  1. MTCHECK ; Mag Tape Check
  1. ; called from ENARGO, ENARGR
  1. ; Checks if Mag Tape is online and rewind if at BOT
  1. U IO X ENONLINE G:Y MTC1
  1. U IO(0) W !,"Tape off-line, please make ready" D MSG
  1. I ENR="^" S ENERR="USER INTERUPT @TAPE STATUS" Q
  1. G MTCHECK
  1. MTC1 U IO X ENBOT Q:Y
  1. U IO(0) W !,"Rewinding tape" U IO W @ENREW
  1. Q
  1. ;ENARGO