function thm_part_get_config_mask, config_word, is_esa, apid
compile_opt idl2, hidden
if config_word eq '1234'xu || config_word eq '5678'xu then begin
config = '0000'xu
endif else if config_word eq '9abc'xu then begin
config = keyword_set(apid) && apid eq '45b'xu ? 'ffff'xu:'0000'xu
endif else if config_word eq 'def0'xu then begin
config = keyword_set(apid) && apid eq '45e'xu ? 'ffff'xu:'0000'xu
endif else if is_esa then begin
config = config_word and '0F0F'xu
endif else begin
config = config_word and '0F0E'xu
endelse
return, ishft(config and '0F00'xu, -4) + (config and '000F'xu)
end
function thm_part_get_config_esawind, apid, cw
compile_opt idl2, hidden
f = 0b
switch apid of
'454'xu:
'455'xu:
'456'xu: begin
if cw eq '0302'xu || $
cw eq '0402'xu || $
cw eq '0702'xu || $
cw eq '0a02'xu || $
cw eq '0b02'xu then begin
f = 1
end
break
end
'457'xu:
'458'xu:
'459'xu: begin
if cw eq '0102'xu || $
cw eq '0202'xu || $
cw eq '0112'xu || $
cw eq '0212'xu then begin
f = 1
end
break
end
else:
endswitch
return, f
end
function thm_part_get_config_sstspins, cw, burst=burst, reduced=reduced, full=full
compile_opt idl2, hidden
nspins = [1, 4, 8, 32, 64, 128, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1]
msb = ishft(cw,-12) and '0F'xu
lsb = ishft(cw,-4) and '0F'xu
if keyword_set(burst) then return, 1
if keyword_set(reduced) then return, nspins[msb]
if keyword_set(full) then return, nspins[lsb]
return, 0
end
pro thm_part_get_config_setvalue, u, _extra=_extra
compile_opt idl2, hidden
u.valid = 1b
struct_assign, _extra, u, /nozero
end
pro thm_part_get_config_454, u
compile_opt idl2, hidden
u.is_esa = 1b
u.esa_solarwind_flag = thm_part_get_config_esawind(u.apid, u.config_word)
config = thm_part_get_config_mask(u.config_word, u.is_esa)
case config of
'00'xu:thm_part_get_config_setvalue, u, $
angle_mode=0, angle_bins=88, energy_bins=32, nspins=3, sweep_mode=0
'11'xu:thm_part_get_config_setvalue, u, $
angle_mode=1, angle_bins=88, energy_bins=32, nspins=128, sweep_mode=1
'21'xu:thm_part_get_config_setvalue, u, $
angle_mode=1, angle_bins=88, energy_bins=32, nspins=32, sweep_mode=1
'32'xu:thm_part_get_config_setvalue, u, $
angle_mode=2, angle_bins=176, energy_bins=16, nspins=128, sweep_mode=2
'42'xu:thm_part_get_config_setvalue, u, $
angle_mode=2, angle_bins=176, energy_bins=16, nspins=32, sweep_mode=2
'13'xu:thm_part_get_config_setvalue, u, $
angle_mode=1, angle_bins=88, energy_bins=32, nspins=128, sweep_mode=3
'53'xu:thm_part_get_config_setvalue, u, $
angle_mode=1, angle_bins=88, energy_bins=32, nspins=32, sweep_mode=3
'61'xu:thm_part_get_config_setvalue, u, $
angle_mode=1, angle_bins=88, energy_bins=32, nspins=32, sweep_mode=1
'72'xu:thm_part_get_config_setvalue, u, $
angle_mode=2, angle_bins=176, energy_bins=16, nspins=32, sweep_mode=2
else:
endcase
end
pro thm_part_get_config_455, u
compile_opt idl2, hidden
u.is_esa = 1b
u.esa_solarwind_flag = thm_part_get_config_esawind(u.apid, u.config_word)
config = thm_part_get_config_mask(u.config_word, u.is_esa)
case config of
'00'xu:thm_part_get_config_setvalue, u, $
angle_mode=0, angle_bins=6, energy_bins=16, nspins=3, sweep_mode=0
'11'xu:thm_part_get_config_setvalue, u, $
angle_mode=1, angle_bins=1, energy_bins=32, nspins=1, sweep_mode=1
'21'xu:thm_part_get_config_setvalue, u, $
angle_mode=2, angle_bins=50, energy_bins=24, nspins=1, sweep_mode=2
'32'xu:thm_part_get_config_setvalue, u, $
angle_mode=3, angle_bins=1, energy_bins=16, nspins=1, sweep_mode=3
'42'xu:thm_part_get_config_setvalue, u, $
angle_mode=5, angle_bins=72, energy_bins=16, nspins=1, sweep_mode=3
'13'xu:thm_part_get_config_setvalue, u, $
angle_mode=1, angle_bins=1, energy_bins=32, nspins=1, sweep_mode=4
'53'xu:thm_part_get_config_setvalue, u, $
angle_mode=4, angle_bins=50, energy_bins=24, nspins=1, sweep_mode=5
'61'xu:thm_part_get_config_setvalue, u, $
angle_mode=6, angle_bins=6, energy_bins=32, nspins=1, sweep_mode=1
'72'xu:thm_part_get_config_setvalue, u, $
angle_mode=7, angle_bins=6, energy_bins=16, nspins=1, sweep_mode=3
else:
endcase
end
pro thm_part_get_config_456, u
compile_opt idl2, hidden
u.is_esa = 1b
u.esa_solarwind_flag = thm_part_get_config_esawind(u.apid, u.config_word)
config = thm_part_get_config_mask(u.config_word, u.is_esa)
case config of
'00'xu:thm_part_get_config_setvalue, u, $
angle_mode=0, angle_bins=88, energy_bins=32, nspins=1, sweep_mode=0
'11'xu:thm_part_get_config_setvalue, u, $
angle_mode=1, angle_bins=88, energy_bins=32, nspins=1, sweep_mode=1
'21'xu:thm_part_get_config_setvalue, u, $
angle_mode=1, angle_bins=88, energy_bins=32, nspins=1, sweep_mode=1
'32'xu:thm_part_get_config_setvalue, u, $
angle_mode=2, angle_bins=176, energy_bins=16, nspins=1, sweep_mode=2
'42'xu:thm_part_get_config_setvalue, u, $
angle_mode=2, angle_bins=176, energy_bins=16, nspins=1, sweep_mode=2
'13'xu:thm_part_get_config_setvalue, u, $
angle_mode=1, angle_bins=88, energy_bins=32, nspins=1, sweep_mode=3
'53'xu:thm_part_get_config_setvalue, u, $
angle_mode=1, angle_bins=88, energy_bins=32, nspins=1, sweep_mode=3
'61'xu:thm_part_get_config_setvalue, u, $
angle_mode=1, angle_bins=88, energy_bins=32, nspins=1, sweep_mode=1
'72'xu:thm_part_get_config_setvalue, u, $
angle_mode=2, angle_bins=176, energy_bins=16, nspins=1, sweep_mode=2
else:
endcase
end
pro thm_part_get_config_457, u
compile_opt idl2, hidden
u.is_esa = 1b
u.esa_solarwind_flag = thm_part_get_config_esawind(u.apid, u.config_word)
config = thm_part_get_config_mask(u.config_word, u.is_esa)
case config of
'00'xu:thm_part_get_config_setvalue, u, $
angle_mode=0, angle_bins=88, energy_bins=32, nspins=3, sweep_mode=0
'11'xu:thm_part_get_config_setvalue, u, $
angle_mode=0, angle_bins=88, energy_bins=32, nspins=128, sweep_mode=1
'21'xu:thm_part_get_config_setvalue, u, $
angle_mode=0, angle_bins=88, energy_bins=32, nspins=32, sweep_mode=1
'31'xu:thm_part_get_config_setvalue, u, $
angle_mode=1, angle_bins=88, energy_bins=15, nspins=1, sweep_mode=3
'12'xu:thm_part_get_config_setvalue, u, $
angle_mode=0, angle_bins=88, energy_bins=32, nspins=128, sweep_mode=2
'22'xu:thm_part_get_config_setvalue, u, $
angle_mode=0, angle_bins=88, energy_bins=32, nspins=32, sweep_mode=2
'14'xu:thm_part_get_config_setvalue, u, $
angle_mode=0, angle_bins=88, energy_bins=32, nspins=128, sweep_mode=4
'24'xu:thm_part_get_config_setvalue, u, $
angle_mode=0, angle_bins=88, energy_bins=32, nspins=32, sweep_mode=4
'34'xu:thm_part_get_config_setvalue, u, $
angle_mode=0, angle_bins=88, energy_bins=15, nspins=1, sweep_mode=5
else:
endcase
end
pro thm_part_get_config_458, u
compile_opt idl2, hidden
u.is_esa = 1b
u.esa_solarwind_flag = thm_part_get_config_esawind(u.apid, u.config_word)
config = thm_part_get_config_mask(u.config_word, u.is_esa)
case config of
'00'xu:thm_part_get_config_setvalue, u, $
angle_mode=0, angle_bins=6, energy_bins=16, nspins=3, sweep_mode=0
'11'xu:thm_part_get_config_setvalue, u, $
angle_mode=1, angle_bins=1, energy_bins=32, nspins=1, sweep_mode=1
'21'xu:thm_part_get_config_setvalue, u, $
angle_mode=2, angle_bins=6, energy_bins=32, nspins=1, sweep_mode=1
'31'xu:thm_part_get_config_setvalue, u, $
angle_mode=1, angle_bins=32, energy_bins=32, nspins=1, sweep_mode=1
'12'xu:thm_part_get_config_setvalue, u, $
angle_mode=1, angle_bins=1, energy_bins=32, nspins=1, sweep_mode=2
'22'xu:thm_part_get_config_setvalue, u, $
angle_mode=2, angle_bins=6, energy_bins=32, nspins=1, sweep_mode=2
'14'xu:thm_part_get_config_setvalue, u, $
angle_mode=1, angle_bins=1, energy_bins=32, nspins=1, sweep_mode=3
'24'xu:thm_part_get_config_setvalue, u, $
angle_mode=2, angle_bins=6, energy_bins=32, nspins=1, sweep_mode=3
'34'xu:thm_part_get_config_setvalue, u, $
angle_mode=1, angle_bins=1, energy_bins=32, nspins=1, sweep_mode=3
else:
endcase
end
pro thm_part_get_config_459, u
compile_opt idl2, hidden
u.is_esa = 1b
u.esa_solarwind_flag = thm_part_get_config_esawind(u.apid, u.config_word)
config = thm_part_get_config_mask(u.config_word, u.is_esa)
case config of
'00'xu:thm_part_get_config_setvalue, u, $
angle_mode=0, angle_bins=88, energy_bins=32, nspins=1, sweep_mode=0
'11'xu:thm_part_get_config_setvalue, u, $
angle_mode=0, angle_bins=88, energy_bins=32, nspins=1, sweep_mode=1
'21'xu:thm_part_get_config_setvalue, u, $
angle_mode=0, angle_bins=88, energy_bins=32, nspins=1, sweep_mode=1
'31'xu:thm_part_get_config_setvalue, u, $
angle_mode=0, angle_bins=88, energy_bins=32, nspins=1, sweep_mode=1
'12'xu:thm_part_get_config_setvalue, u, $
angle_mode=0, angle_bins=88, energy_bins=32, nspins=1, sweep_mode=2
'22'xu:thm_part_get_config_setvalue, u, $
angle_mode=0, angle_bins=88, energy_bins=32, nspins=1, sweep_mode=2
'14'xu:thm_part_get_config_setvalue, u, $
angle_mode=0, angle_bins=88, energy_bins=32, nspins=1, sweep_mode=3
'24'xu:thm_part_get_config_setvalue, u, $
angle_mode=0, angle_bins=88, energy_bins=32, nspins=1, sweep_mode=3
'34'xu:thm_part_get_config_setvalue, u, $
angle_mode=0, angle_bins=88, energy_bins=32, nspins=1, sweep_mode=3
else:
endcase
end
pro thm_part_get_config_45A, u
compile_opt idl2, hidden
u.is_sst = 1b
u.nspins = thm_part_get_config_sstspins(u.config_word, /full)
config = thm_part_get_config_mask(u.config_word, u.is_esa)
case config of
'00'xu:thm_part_get_config_setvalue, u, $
angle_bins=64, energy_bins=16
'10'xu:thm_part_get_config_setvalue, u, $
angle_bins=128, energy_bins=16
'20'xu:thm_part_get_config_setvalue, u, $
angle_bins=64, energy_bins=16
'30'xu:thm_part_get_config_setvalue, u, $
angle_bins=32, energy_bins=16
'40'xu:thm_part_get_config_setvalue, u, $
angle_bins=32, energy_bins=16
else:
endcase
end
pro thm_part_get_config_45B, u
compile_opt idl2, hidden
u.is_sst = 1b
u.nspins = thm_part_get_config_sstspins(u.config_word, /reduced)
config = thm_part_get_config_mask(u.config_word, u.is_esa, u.apid)
case config of
'00'xu:thm_part_get_config_setvalue, u, $
angle_bins=6, energy_bins=16
'10'xu:thm_part_get_config_setvalue, u, $
angle_bins=6, energy_bins=16
'20'xu:thm_part_get_config_setvalue, u, $
angle_bins=1, energy_bins=16
'30'xu:thm_part_get_config_setvalue, u, $
angle_bins=1, energy_bins=16
'40'xu:thm_part_get_config_setvalue, u, $
angle_bins=6, energy_bins=16
else:
endcase
end
pro thm_part_get_config_45C, u
compile_opt idl2, hidden
u.is_sst = 1b
u.nspins = thm_part_get_config_sstspins(u.config_word, /burst)
config = thm_part_get_config_mask(u.config_word, u.is_esa)
switch config of
'00'xu:
'10'xu:
'20'xu:
'30'xu:
'40'xu:thm_part_get_config_setvalue, u, $
angle_bins=64, energy_bins=16
else:
endswitch
end
pro thm_part_get_config_45D, u
compile_opt idl2, hidden
u.is_sst = 1b
u.nspins = thm_part_get_config_sstspins(u.config_word, /full)
config = thm_part_get_config_mask(u.config_word, u.is_esa)
case config of
'00'xu:thm_part_get_config_setvalue, u, $
angle_bins=64, energy_bins=16
'10'xu:thm_part_get_config_setvalue, u, $
angle_bins=128, energy_bins=16
'20'xu:thm_part_get_config_setvalue, u, $
angle_bins=64, energy_bins=16
'30'xu:thm_part_get_config_setvalue, u, $
angle_bins=32, energy_bins=16
'40'xu:thm_part_get_config_setvalue, u, $
angle_bins=32, energy_bins=16
'50'xu:thm_part_get_config_setvalue, u, $
angle_bins=64, energy_bins=16
else:
endcase
end
pro thm_part_get_config_45E, u
compile_opt idl2, hidden
u.is_sst = 1b
u.nspins = thm_part_get_config_sstspins(u.config_word, /reduced)
config = thm_part_get_config_mask(u.config_word, u.is_esa, u.apid)
case config of
'00'xu:thm_part_get_config_setvalue, u, $
angle_bins=6, energy_bins=16
'10'xu:thm_part_get_config_setvalue, u, $
angle_bins=6, energy_bins=16
'20'xu:thm_part_get_config_setvalue, u, $
angle_bins=1, energy_bins=16
'30'xu:thm_part_get_config_setvalue, u, $
angle_bins=1, energy_bins=16
'40'xu:thm_part_get_config_setvalue, u, $
angle_bins=6, energy_bins=16
'50'xu:thm_part_get_config_setvalue, u, $
angle_bins=6, energy_bins=16
else:
endcase
end
pro thm_part_get_config_45F, u
compile_opt idl2, hidden
u.is_sst = 1b
u.nspins = thm_part_get_config_sstspins(u.config_word, /burst)
config = thm_part_get_config_mask(u.config_word, u.is_esa)
switch config of
'00'xu:
'10'xu:
'20'xu:
'30'xu:
'40'xu:
'50'xu:thm_part_get_config_setvalue, u, $
angle_bins=64, energy_bins=16
else:
endswitch
end
function thm_part_get_config, apid0, config_word0, config_word1
compile_opt idl2, hidden
if total( size(/type, apid0) eq [1,2,3,12,13] ) lt 1 then begin
dprint, dlevel=1, 'Must specify APID as byte or int ( e.g. ''45A''xu )'
return, -1
endif
if total( size(/type, config_word0) eq [1,2,3,12,14] ) lt 1 then begin
dprint, dlevel=1, 'Must specify CONFIG_WORD as byte or int. ( e.g. ''9abc''xu )'
return, -1
endif
if n_params() eq 3 then begin
if total( size(/type, config_word1) eq [1,2,3,12,14] ) lt 1 then begin
dprint, dlevel=1, 'Must specify CONFIG_WORD as byte or int. ( e.g. ''9abc''xu )'
return, -1
endif
endif
apid = uint(apid0)
if n_params() eq 3 then begin
config_word = uint([config_word0,config_word1])
endif else begin
config_word = uint(config_word0)
endelse
if n_elements(config_word) eq 2 then begin
config_word = ishft(config_word[0],8) or config_word[1]
endif else if n_elements(config_word) gt 1 then begin
dprint, dlevel=1, 'Too many elements in config word. See usage'
return, -1
endif
u = { $
apid: apid, $
config_word: config_word, $
is_esa: 0b, $
is_sst: 0b, $
valid: 0b, $
nspins: 0L, $
angle_bins: -1L, $
energy_bins: -1L, $
sweep_mode: 0L, $
angle_mode: 0L, $
esa_solarwind_flag: 0b $
}
case apid of
'454'xu: thm_part_get_config_454, u
'455'xu: thm_part_get_config_455, u
'456'xu: thm_part_get_config_456, u
'457'xu: thm_part_get_config_457, u
'458'xu: thm_part_get_config_458, u
'459'xu: thm_part_get_config_459, u
'45A'xu: thm_part_get_config_45A, u
'45B'xu: thm_part_get_config_45B, u
'45C'xu: thm_part_get_config_45C, u
'45D'xu: thm_part_get_config_45D, u
'45E'xu: thm_part_get_config_45E, u
'45F'xu: thm_part_get_config_45F, u
else: begin
dprint, dlevel=1, 'Uknown apid: ' + string(apid, format='(z)')
end
endcase
return, u
end