source: FOIAVistA/trunk/r/ENGINEERING-EN/ENARGO.m@ 1801

Last change on this file since 1801 was 628, checked in by George Lilly, 15 years ago

initial load of FOIAVistA 6/30/08 version

File size: 5.5 KB
Line 
1ENARGO ;(WIRMFO)/JED,SAB-MOVE ARCHIVE GLOBAL TO STORAGE MEDIA ;4.29.97
2 ;;7.0;ENGINEERING;**40**;Aug 17, 1993
3 Q
4A ; Archive global to media
5 ; called by ENAR1
6 ; input
7 ; ENGBL - global subscript in ^ENAR to be archived (e.g. 6919.1)
8 ; ENTIME - date/time of archive session (internal format)
9 ; ENERR - error message text (should be 0 for no error)
10 ; output
11 ; ENERR - error message text or 0 when no error
12 D DT^DICRW
13 ;
14 S ENHFSM="W",ENHFSIO="" D ARDEV I ENERR'=0 G OUT
15 I IOT="MT" D MTSETUP I ENERR'=0 G CLOUT
16 I IOT="MT" D MTCHECK I ENERR'=0 G CLOUT
17 I IOT="MT" X ENWPROT I Y D G A
18 . D CLOSE
19 . W $C(7),!!,"But your tape is write protected!!" D MSG
20 ;
21 U IO(0) W !,"Beginning output"
22 ; determine header info
23 S ENHD(1)=$$FMTE^XLFDT(ENTIME)
24 S ENHD(2)=$P(^ENAR(ENGBL,0),"^",1)_", ID# "_$P(^(-1),",",3)_", "_$P(^(0),"^",3)_" RECORDS SAVED"
25 S ENHD(3)="^ENAR("_ENGBL_",-1)"
26 S ENHD(4)=@ENHD(3)
27 ; write data to archive device
28 U IO S ENSTART=$P($H,",",2)
29 ; - write header info
30 W ENHD(1) W:IOT'="MT" ! W ENHD(2) W:IOT'="MT" !
31 ; - write nodes and content of nodes
32 S ENX="^ENAR("_ENGBL_")",ENC=0
33 F S ENX=$Q(@ENX) Q:ENX="" Q:$QS(ENX,1)'=ENGBL D
34 . W ENX W:IOT'="MT" ! W @ENX W:IOT'="MT" !
35 . S ENC=ENC+1 I '(ENC#100) U IO(0) W "." U IO
36 ; - write footer info
37 W "**EOF**" W:IOT'="MT" ! W "**EOF**" W:IOT'="MT" !
38 U IO(0)
39 W !,"Elapsed time: ",$J($P($H,",",2)-ENSTART/60,6,2)," minutes.",!
40 ;
41 S DIR(0)="Y",DIR("A")="Archive complete, care to verify",DIR("B")="YES"
42 S DIR("?",1)="This process reads archived records and compares them to"
43 S DIR("?",2)="the source global."
44 S DIR("?",3)=" "
45 S DIR("?")="Enter YES or No"
46 D ^DIR K DIR
47 I 'Y S ENERR="VERIFY DECLINED" K ^ENAR(ENGBL,"LOCK") G CLOUT
48 ;
49 S DIR(0)="SB^F:FULL;H:HEADER-ONLY"
50 S DIR("A")="Select type of verify to perform",DIR("B")="FULL"
51 S DIR("?",3)="FULL - Every record is read from the archive media and"
52 S DIR("?",4)=" compared to the source global."
53 S DIR("?",1)="HEADER-ONLY - The header data (4 lines) is read from the"
54 S DIR("?",2)=" archive media and compared to expected values."
55 S DIR("?",5)=" "
56 S DIR("?")="Enter H or F"
57 D ^DIR K DIR I $D(DIRUT) S ENERR="USER VERIFY ABORT" G CLOUT
58 S ENVT=Y
59 ;
60VRF ; Verify
61 ; rewind (or close and reopen) device
62 W !,"Please wait while I rewind (or reopen) the archive device."
63 S Y=$S("^MT^HFS^SDP^"[(U_IOT_U):$$REWIND^%ZIS(IO,IOT,IOPAR),1:0)
64 I 'Y D CLOSE S IOP=ENION,ENHFSM="R" D ARDEV G:ENERR'=0 OUT
65 I IOT="MT" D MTCHECK I ENERR'=0 G CLOUT
66 ;
67 S ENREDO=0,ENSTART=$P($H,",",2)
68 D VHDR G:ENREDO VRF I ENERR'=0 G CLOUT
69 I ENVT="F" D VREC G:ENREDO VRF I ENERR'=0 G CLOUT
70 ;
71 D CLOSE
72 W !,"Elapsed time: ",$J($P($H,",",2)-ENSTART/60,6,2)," minutes."
73 K ^ENAR(ENGBL,"LOCK")
74 G OUT
75 ;
76VHDR ; verify header
77 U IO(0) W !!,"Verifying Header..."
78 U IO R ENX(1):15,ENX(2):15,ENX(3):15,ENX(4):15
79 U IO(0)
80 F ENI=1:1:4 Q:ENX(ENI)'=ENHD(ENI)
81 I ENX(ENI)'=ENHD(ENI) D
82 . W $C(7),!!,"Expected: ",ENHD(ENI),!,"Found: ",ENX(ENI)
83 . S DIR(0)="Y",DIR("A")="Try again",DIR("B")="YES"
84 . D ^DIR K DIR I Y S ENREDO=1 Q
85 . S ENERR="BAD HEADER VERIFY"
86 I ENX(ENI)=ENHD(ENI) W "Header OK"
87 Q
88 ;
89VREC ; verify records
90 U IO(0) W !,"Continuing with full verify"
91 S (ENC,ENC("VERR"))=0
92 U IO
93 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
94 . U IO(0)
95 . S ENC("VERR")=ENC("VERR")+1
96 . W $C(7),!,"WARNING: ",ENX,!,"Expected: ",@ENX,!,"Found: ",ENX(1)
97 . I ENC("VERR")'>5 W !!,"continuing"
98 . U IO
99 U IO(0)
100 I ENC("VERR")>5 D
101 . W $C(7),!,"Sorry, the verify doesn't look good"
102 . S DIR(0)="Y",DIR("A")="Try again",DIR("B")="YES"
103 . D ^DIR K DIR I Y S ENREDO=1 Q
104 . S ENERR="BAD VERIFY"
105 Q
106 ;
107CLOUT ; Close archive device and exit
108 D CLOSE
109OUT ; Exit
110 K ENBOT,ENC,ENEOT,ENHD,ENHFSIO,ENHFSM,ENI,ENION,ENMTERR
111 K ENONLINE,ENR,ENREDO,ENREW,ENSTART,ENVT,ENWPROT,ENX
112 K DIROUT,DIRUT,DTOUT,DUOUT,X,Y
113 Q
114 ;
115MSG W !,"Press <RETURN> to continue" R ENR:DTIME S:'$T ENR="^" Q
116 ;
117ARDEV ; Select and open archival device
118 ; called from ENARGO, ENARGR
119 ; input
120 ; ENHFSM - host file access mode ('W'rite-only or 'R'ead-only)
121 ; ENERR - error message text (should be 0 for no error)
122 ; IOP - (optional) name of device to use
123 ; ENHFSIO - (optional) name of host file to open
124 ; output
125 ; ENERR - 0 or error message text
126 ; ENION - ION of selected device
127 ; ENHFSIO - name of host file opened (only defined when IOT="HFS")
128 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",!
129 S %ZIS("A")="ARCHIVAL DEVICE: ",%ZIS("B")="",%ZIS("HFSMODE")=ENHFSM
130 I $G(ENHFSIO)]"" S %ZIS("HFSNAME")=ENHFSIO
131 S %ZIS("S")="I ""^VTRM^TRM^""'[(U_$G(^(""TYPE""))_U)"
132 D ^%ZIS I POP S ENERR="ARCHIVAL DEVICE NOT SELECTED" Q
133 S ENION=ION
134 S ENHFSIO=$S(IOT="HFS":IO,1:"")
135 Q
136 ;
137CLOSE ; Close archival device
138 ; called from ENARGO, ENARGR
139 D ^%ZISC
140 Q
141 ;
142MTSETUP ; Mag Tape Variables Setup
143 ; called from ENARGO, ENARGR
144 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
145 X ^%ZOSF("MAGTAPE") S ENREW=%MT("REW") K %MT
146 S ENEOT=^%ZOSF("EOT"),ENBOT=^%ZOSF("MTBOT")
147 S ENMTERR=^%ZOSF("MTERR"),ENONLINE=^%ZOSF("MTONLINE")
148 S ENWPROT=^%ZOSF("MTWPROT")
149 Q
150 ;
151MTCHECK ; Mag Tape Check
152 ; called from ENARGO, ENARGR
153 ; Checks if Mag Tape is online and rewind if at BOT
154 U IO X ENONLINE G:Y MTC1
155 U IO(0) W !,"Tape off-line, please make ready" D MSG
156 I ENR="^" S ENERR="USER INTERUPT @TAPE STATUS" Q
157 G MTCHECK
158MTC1 U IO X ENBOT Q:Y
159 U IO(0) W !,"Rewinding tape" U IO W @ENREW
160 Q
161 ;ENARGO
Note: See TracBrowser for help on using the repository browser.