function mav_swea_hkp_pfdpu_decom,ccsds
data = ccsds.data
data2 = uint(data,0,n_elements(data)/2)
byteorder,data2,/swap_if_little_endian
imonitors = fix(data2[0:23])
fmonitors = float(imonitors)
subsec = data[0]*256 + data[1]
swia_struct1 = { $
time: ccsds.time, $
monitors:fmonitors, $
SWELVPST: fmonitors[0] * 1., $
SWEMCPHV: -0.152588 *fmonitors[1] , $
SWENRV : -0.000203 * fmonitors[2] , $
SWEAnalHV: -0.030518*fmonitors[3] , $
SWEDef1HV: -0.073360*fmonitors[4] , $
SWEDef2HV: -0.073360*fmonitors[5] , $
other_stuff: data[48:*], $
valid:1 }
return,swia_struct1
end
function mav_apid_swea_3D_decom,ccsds
data = mav_pfdpu_part_decompress_data(ccsds)
subsec = data[0]*256 + data[1]
ccode = ishft(data[3],6)
LUT = data[4]
ddata = reform( mav_log_decomp(data[6:*],ccode), 80, 16 )
swea_struct1 = { $
time: ccsds.time, $
ccode:ccode, $
data: ddata, $
valid:1 }
return,swea_struct1
end
function mav_apid_swea_xxxxx_decom,ccsds
data = mav_pfdpu_part_decompress_data(ccsds)
subsec = data[0]*256 + data[1]
swia_struct1 = { $
time: ccsds.time, $
data:data[6:*], $
valid:1 }
return,swia_struct1
end
function mav_apid_swea_spectra_decom,ccsds
data = mav_pfdpu_part_decompress_data(ccsds)
nsample = 64
size = nsample*16+6
if n_elements(data) ne size then begin
dprint,ccsds.apid,n_elements(ccsds.data),n_elements(data),format='(z02,i5,i5)'
data = data[0:size-1]
endif
subsec = data[0]*256 + data[1]
ccode = data[2]
ccode = ishft(data[2],6)
ddata = mav_log_decomp(data[6:*],ccode)
swia_struct1 = { $
time: ccsds.time, $
ccode:ccode, $
data:fltarr(nsample), $
valid:1 }
swia_structs = replicate(swia_struct1,16)
swia_structs.time += dindgen(16)*8.
swia_structs.data = reform(ddata,nsample,16)
return,swia_structs
end
pro mav_apid_swea_handler,ccsds,decom=decom,reset=reset
common mav_apid_swea_handler_com,manage,realtime,swea_hkp,a,b,d,e
if n_elements(reset) ne 0 then begin
manage = reset
swia_hkp =0
realtime=1
return
endif
if not keyword_set(manage) then return
if not keyword_set(ccsds) then return
Case ccsds.apid of
'28'x: mav_gse_structure_append ,dummy_ptrs, realtime=realtime, tname='swea_hkp',(swea_hkp=mav_swea_hkp_pfdpu_decom(ccsds))
'A0'x: begin
swea_3d = mav_apid_swea_3d_decom(ccsds)
s1 = total(swea_3d.data,1)
mav_gse_structure_append ,dummy_ptrs, realtime=realtime, tname='swea_3D_sum1',{time:swea_3d.time,data:s1}
s2 = total(swea_3d.data,2)
mav_gse_structure_append ,dummy_ptrs, realtime=realtime, tname='swea_3D_sum2',{time:swea_3d.time,data:s2}
end
'A1'x: begin
swea_3d = mav_apid_swea_3d_decom(ccsds)
s1 = total(swea_3d.data,1)
mav_gse_structure_append ,dummy_ptrs, realtime=realtime, tname='swea_archive_3D_sum1',{time:swea_3d.time,data:s1}
s2 = total(swea_3d.data,2)
mav_gse_structure_append ,dummy_ptrs, realtime=realtime, tname='swea_archive_3D_sum2',{time:swea_3d.time,data:s2}
end
'A2'x: mav_gse_structure_append ,dummy_ptrs, realtime=realtime, tname='swea_PAD',(swea_a2=mav_apid_swea_xxxxx_decom(ccsds))
'a4'x: begin
swea_spec=mav_apid_swea_spectra_decom(ccsds)
mav_gse_structure_append ,dummy_ptrs, realtime=realtime, tname='swea_spec',swea_spec
end
else: return
endcase
decom = 1
end