pro plot_svm,svmhk1,svmhk2 
; 
;     svmhk2 = array of all monitors from SVHK2 TLM stream generated by DACS 
; 
; @(#)plot_svm.pro	1.1 01/23/98 :LASCO IDL LIBRARY
;
; offset the beginning of HK before HK information begins 
; 
offset=6 
; 
!y.title = 'Volt' 
!p.multi=[0,3,3,0,0] 
 
getcputime,svmhk2,firstday,time2,cdstime=utc2
kdate,firstday,id,im,iy 
getcputime,svmhk1,firstday,time1 ,cdstime=utc1
;
;  reject packets where the time is negative or points to more
;  than 4 days away
;
w = where(time2 gt 0 and time2 lt 100)
time2=time2(w)
svmhk2=svmhk2(*,w)
w = where(time1 gt 0 and time2 lt 100)
time1=time1(w)
svmhk1=svmhk1(*,w)

 
!x.title = 'Time (Hours) Starting Date:  '+ utc2str(utc1(0))
 
v = fix(svmhk2(offset+17,*))           ;Byte offset 17 
v = v * 17.39/255 
utplot,utc2,v,title='+15V (N)',yrange=[14,16] 
if (max(v) lt 1) then $ 
utstring,utc2(fix(n_elements(utc2)*.5)),15,'NA', charsize=0.9 
 
v = fix(svmhk2(offset+16,*))           ;Byte offset 16 
v = v * 6.375/255 
utplot,utc2,v,title='+5V (N)',yrange=[4,6] 
if (max(v) lt 1) then $ 
utstring,utc2(fix(n_elements(utc2)*.5)),5,'NA', charsize=0.9 
 
v = fix(svmhk2(offset+18,*))           ;Byte offset 18 
v = v * 17.39/255 - 17.39 
utplot,utc2,v,title='-15V (N)',yrange=[-16,-14] 
;utplot,time2,v,title='-15V (N)',yrange=[0,255] 
if (max(v) gt -1) then $ 
utstring,utc2(fix(n_elements(utc2)*.5)),-15,'NA', charsize=0.9 
 
v = fix(svmhk2(offset+7,*))           ;Byte offset 7 
v = v * 17.39/255 
utplot,utc2,v,title='+15V (R)',yrange=[14,16] 
if (max(v) lt 1) then $ 
utstring,utc2(fix(n_elements(utc2)*.5)),15,'NA', charsize=0.9 
 
v = fix(svmhk2(offset+6,*))           ;Byte offset 6 
v = v * 6.375/255 
utplot,utc2,v,title='+5V (R)',yrange=[4,6] 
if (max(v) lt 1) then $ 
utstring,utc2(fix(n_elements(utc2)*.5)),5,'NA', charsize=0.9 
 
v = fix(svmhk2(offset+8,*))           ;Byte offset 8 
v = v * 17.39/255 - 17.39 
utplot,utc2,v,title='-15V (R)',yrange=[-14,-16] 
if (max(v) gt -1) then $ 
utstring,utc2(fix(n_elements(utc2)*.5)),-15,'NA', charsize=0.9 
 
!y.title = 'Amp' 
v = fix(svmhk1(offset+113,*))            ;Byte offset 113 
v = ((v-1)*7.155/254+.02806)>0 
utplot,utc1,v,title='A Current',yrange=[0,4] 
if (max(v) lt 0.3) then $ 
utstring,utc1(fix(n_elements(utc1)*.5)),2,'NA', charsize=0.9 
 
v = fix(svmhk1(offset+155,*))            ;Byte offset 155 
v = ((v-1)*7.155/254+.02806)>0 
utplot,utc1,v,title='B Current',yrange=[0,4] 
if (max(v) lt 0.3) then $ 
utstring,utc1(fix(n_elements(utc1)*.5)),2,'NA', charsize=0.9 
 
!y.title = '' 
 
;vcvan = ( not tmpoint(svmhk2,offset+21,'0080'xl)) and 1 ;Byte offset 43 
;vcvar = ( not tmpoint(svmhk2,offset+20,'8000'xl)) and 1 ;Byte offset 40 
;vcvbn = ( not tmpoint(svmhk2,offset+21,'0040'xl)) and 1 ;Byte offset 43 
;vcvbr = ( not tmpoint(svmhk2,offset+20,'4000'xl)) and 1 ;Byte offset 40 
;vlcla = tmpoint(svmhk1,offset+47,'0002'xl)                      ;Byte offset 95 
;vlclb = tmpoint(svmhk1,offset+68,'0002'xl)                      ;Byte offset 137 
vcvan = ( not fix(svmhk2(offset+43,*) and 128)/128) and 1 ;Byte offset 43 
vcvar = ( not fix(svmhk2(offset+40,*) and 128)/128) and 1 ;Byte offset 40 
vcvbn = ( not fix(svmhk2(offset+43,*) and 64)/64)   and 1 ;Byte offset 43 
vcvbr = ( not fix(svmhk2(offset+40,*) and 64)/64)   and 1 ;Byte offset 40 
vlcla = (fix(svmhk1(offset+95,*)) and 2)/2                 ;Byte offset 95 
vlclb = (fix(svmhk1(offset+137,*)) and 2)/2                ;Byte offset 137 
plot,time2,vcvan+21,title='S/C Relay Status',yrange=[0,25],  $ 
      ytickformat='svmrelayst',yticks=11,ytickv=[1,2,5,6,9,10,13,14,17,18,21,22] 
oplot,time2,vcvar+17 
oplot,time1,vlcla+13 
oplot,time2,vcvbn+9 
oplot,time2,vcvbr+5 
oplot,time1,vlclb+1 
xyouts , time2 (fix(n_elements( time2 )*.3)),23,'CV A (N)', /data, charsize=0.7 
xyouts , time2 (fix(n_elements( time2 )*.3)),19,'CV A (R)', /data, charsize=0.7 
xyouts , time1 (fix(n_elements( time1 )*.35)),15,'LCL A', /data, charsize=0.7 
xyouts , time2 (fix(n_elements( time2 )*.3)),11,'CV B (N)', /data, charsize=0.7 
xyouts , time2 (fix(n_elements( time2 )*.3)),7,'CV B (R)', /data, charsize=0.7 
xyouts , time1 (fix(n_elements( time1 )*.35)),3,'LCL B', /data, charsize=0.7 
 
!p.multi = 0 
!x.title = '' 
empty 
return 
end 
