;+
; NAME:
;       EIS_HDR__DISPLAY
;
; PURPOSE:
;       EIS_HDR__DISPLAY is a method of the class EIS_HDR. It is used
;       to display the contents of an eis_hdr object as text.
;
; CATEGORY:
;       Hansteen/Wikstol Data analysis SW
;
; CALLING SEQUENCE:
;       eis_hdr-> display, textdump. eis_hdr is an object of class
;       EIS_HDR, textdump is the output.
;
; INPUTS:
;
;
; KEYWORD PARAMETERS:
;
; OUTPUTS:
;       Textdump: A string containing the values of all the parameters
;       of the header object and a description of it.
;
; CALLS:
;
; COMMON BLOCKS:
;
;
; PROCEDURE:
;       EIS_HDR__DISPLAY reads all the instance data of an EIS_HDR
;       object, and stores it as strings in a string array together
;       with a description of the data. All strings are then finallly
;       joined in one long string (textdump) with CR at the rigth
;       places. The variable 'textdump is the output from the method,
;       and the header can then be displayed as text by printing
;       'textdump'.
;
; RESTRICTIONS:
;
;
; MODIFICATION HISTORY:
;       XX-Mar-2001: Oivind Wikstol.
;       01-Oct-2001: Oivind Wikstol. Added documentation.
;        4-Jul-2008: A. Gardini.     Added init keyword.
;-
pro eis_hdr::display,textdump,init=init
  if n_elements(init) eq 1 then return
;
  line=strarr(256)

  ; cr = carriage return
  case !version.os of
    'MacOS': cr=string(13b)
    'Win32': cr=string(13b)+string(10b)
    else: cr=string(10b)
  endcase

  line[0]=cr+'==================================================================='
  line[1]='Serial packet nr: ' + $
    strcompress(string(self-> getserial_packet_no(),format='(i10)'), /rem)
  line[2]='==================================================================='
  type=self->getdatatype()
  size=self->getpacket_size()
  pkt=self->getserial_packet_no()
  line[3]='Type: '+strcompress(string(type,format='("0x",z2)'), /rem) + $
          ' Size: '+strcompress(string(size,format='("0x",z6)'),  /rem) + $
          ' (' +strtrim(string(size), 1)+')'+$
          ' Pkt No: '+strcompress(string(pkt,format='("0x",z8)'), /rem) + $
          ' (' +strtrim(string(pkt),  1) +')'

  main_id=self->getmain_id()
  main_seq_flag=self->getmain_seq_flag()
  main_seq_count=self->getmain_seq_count()
  line[4]='Main ID: '+strcompress(string(main_id,format='("0x",z4)'), /rem) + $
          ' Main seq. flag: '+$
          strcompress(string(main_seq_flag,format='("0x",z)'), /rem) + $
          ' Main seq. count: '+ $
          strcompress(string(main_seq_count,format='("0x",z4)'), /rem) + $
          ' (' +strtrim(string(main_seq_count), 1) +')'

  nr_pack=self->getnr_of_packets()
  img_type=self->getimg_type()
  line[5]='No. of packets: '+ $
          strcompress(string(nr_pack,format='("0x",z2)'), /rem)+ $
          ' No. of image type: ' + $
          strtrim(string(img_type,format='(i1)'), 1)

  sub_id=self->getsub_id()
  sub_seq_flag=self->getsub_seq_flag()
  sub_seq_count=self->getsub_seq_count()
  line[6]='Sub ID: '+ strcompress(string(sub_id,format='("0x",z4)'), /rem)+ $
          ' Sub seq. flag: '+ $
          strcompress(string(sub_seq_flag,format='("0x",z)'), /rem) + $
          ' Sub seq. count: '+ $
          strcompress(string(sub_seq_count,format='("0x",z4)'), /rem) + $
          ' (' +strtrim(string(sub_seq_count),  1) +')'

  x_f=self->getx_f()
  y_f=self->gety_f()
  b_x=self->getb_x()
  b_y=self->getb_y()
  x_p=self->getx_p()
  y_p=self->gety_p()
  line[7]='Full image size (Xf): '+ $
           strcompress(string(x_f,format='("0x",z4)'), /rem) + $
          ' (' + strtrim(string(x_f,format='(i5)'), 1) + ')'+ $
          ' Full image size (Yf): '+ $
          strcompress(string(y_f,format='("0x",z4)'), /rem) + $
          ' (' + strtrim(string(y_f,format='(i5)'), 1) + ')'
   line[8] ='Base point (Xb): '+ $
            strcompress(string(b_x,format='("0x",z4)'), /rem) + $
          ' (' + strtrim(string(b_x,format='(i5)'), 1) + ')' + $
          ' Base point (Yb): '+ $
          strcompress(string(b_y,format='("0x",z4)'), /rem) + $
          ' (' + strtrim(string(b_y,format='(i5)'), 1) + ')'
   line[9] = 'Part image size (Xp): '+ $
             strcompress(string(x_p,format='("0x",z4)'), /rem) + $
          ' (' + strtrim(string(x_p,format='(i5)'), 1) + ')'+ $
          ' Part image size (Yp): '+ $
          strcompress(string(y_p,format='("0x",z4)'), /rem) + $
          ' (' + strtrim(string(y_p,format='(i5)'), 1) + ')'

  bit_compr_mode=self->getbit_compr_mode()
  img_compr_mode=self->getimg_compr_mode()
  huffman_ac=self->gethuffman_ac()
  huffman_dc=self->gethuffman_dc()
  quant_tab=self->getquant_tab()

  line[10]='Bit compression mode: '+ $
           strcompress(string(bit_compr_mode,format='("0x",z1)'), /rem) + $
          ' Image compression mode: ' + $
          strcompress(string(img_compr_mode,format='("0x",z1)'), /rem)

  line[11]='Huffman AC: ' + $
           strcompress(string(huffman_ac,format='("0x",z1)'), /rem) + $
          ' Huffman DC: ' + $
          strcompress(string(huffman_dc,format='("0x",z1)'), /rem) + $
          ' Quant. tab. no: ' + $
          strcompress(string(quant_tab,format='("0x",z1)'), /rem)

  exp_info=self->getexp_info()

  line[12]='TI_1: '+ $
           strcompress(string(exp_info.ti_1,format='("0x",z8)'), /rem)+ $
          ' (' + strtrim(string(exp_info.ti_1,format='(i10)'), 1) + ')'+$
           ' TI_2: '+ $
           strcompress(string(exp_info.ti_2,format='("0x",z8)'), /rem) + $
          ' (' + strtrim(string(exp_info.ti_2,format='(i10)'), 1) + ')'

  line[13]='MHC: '+ $
            strcompress(string(exp_info.exp_mhc,format='("0x",z8)'), /rem) + $
          ' (' + strtrim(string(exp_info.exp_mhc,format='(i10)'), 1) + ')'+$
           ' ICU duration: '+ $
           strcompress(string(exp_info.exp_dur,format='("0x",z4)'), /rem) + $
          ' (' + strtrim(string(exp_info.exp_dur,format='(i5)'), 1) + ')'

  line[14]='Seq. no: '+ $
           strcompress(string(exp_info.seq_nr,format='("0x",z2)'), /rem) + $
          ' (' + strtrim(string(exp_info.seq_nr,format='(i3)'), 1) + ')'+$
           ' Line list no: '+ $
           strcompress(string(exp_info.ll_nr,format='("0x",z2)'), /rem) + $
          ' (' + strtrim(string(exp_info.ll_nr,format='(i3)'), 1) + ')'

  line[15]='Seq. ID: '+ $
           strcompress(string(exp_info.seq_id,format='("0x",z4)'), /rem) + $
           ' Raster ID: '+ $
           strcompress(string(exp_info.rast_id,format='("0x",z4)'), /rem)

  line[16]='No of win: '+ strtrim(string(exp_info.nwin,format='(i2)'), 1) + $
           ')'+ ' CCD ro side: '+ $
           strcompress(string(exp_info.ccd_sides,format='("0x",z1)'), /rem) + $
           ' CCD X: '+ $
           strcompress(string(exp_info.ccd_length,format='("0x",z3)'), /rem) + $
          ' (' + strtrim(string(exp_info.ccd_length,format='(i4)'), 1) + ')'

  line[17]='XW(S): '+ $
           strcompress(string(exp_info.xws,format='("0x",z3)'), /rem) + $
          ' (' + strtrim(string(exp_info.xws,format='(i4)'), 1) + ')' + $
           'XW(L): '+ $
           strcompress(string(exp_info.xw,format='("0x",z3)'), /rem) + $
          ' (' + strtrim(string(exp_info.xw,format='(i4)'), 1) + ')' + $
           'YW(S): '+ $
           strcompress(string(exp_info.yws,format='("0x",z3)'), /rem) + $
          ' (' + strtrim(string(exp_info.yws,format='(i4)'), 1) + ')' + $
           'YW(L): '+ $
           strcompress(string(exp_info.yw,format='("0x",z3)'), /rem) + $
          ' (' +strtrim(string(exp_info.yw,format='(i4)'), 1) + ')'

  j=18
  nwin=25
  for i=0,nwin-1 do begin
    line[i+j]='Win no: ' + strtrim(string(i,format='(i2)'), 1) + $
              ' hdr: ' + $
          strcompress(string(exp_info.win_hdr(i),format='("0x",z3)'), /rem) + $
              ' X(S): ' + strtrim(string(exp_info.x_s(i),format='(i4)'), 1) + $
              ' X(L): ' + strtrim(string(exp_info.x_l(i),format='(i4)'), 1)
  endfor

  k=j+nwin-1
  line[k]='Coarse pos: '+ $
          strcompress(string(exp_info.cmirr_pos,format='("0x",z4)'), /rem) + $
          ' Fine pos: '+ $
          strcompress(string(exp_info.fmirr_pos,format='("0x",z4)'), /rem) + $
          ' Slit no: '+ $
          strcompress(string(exp_info.slit_nr,format='("0x",z4)'), /rem)

  line[k+1]='X_OCB: ' + strtrim(string(exp_info.x_ocb,format='(i3)'), 1) + $
            ' Y_OCB: ' + strtrim(string(exp_info.y_ocb,format='(i3)'), 1)

  line[k+2]='Nr. of rast. exp req: ' + strcompress(string(exp_info.nexp, $
             format='(i10)'), /rem) + $
            ' Rast. exp. counter: ' + strcompress(string(exp_info.nexpc, $
             format='(i10)'), /rem)

  line[k+3]='Nr. of rast. rep req: ' + strcompress(string(exp_info.nrepr, $
             format='(i4)'), /rem) + $
            ' Nr. of rast. rep perf: ' + strcompress(string(exp_info.nrepp, $
             format='(i4)'), /rem)
  
line[k+4]='Nr. of seq. rep req: ' + strcompress(string(exp_info.nseqr, $
             format='(i3)'), /rem) + $
            ' Nr. of seq. rep perf: ' + strcompress(string(exp_info.nseqp, $
             format='(i3)'), /rem)

line[k+5] = 'Readout nodes: CCDA-R: ' + $
            strcompress(string(exp_info.ron_ccdar, $
            format = '(i1)'), /rem)+ ' CCDA-L: ' + $
            strcompress(string(exp_info.ron_ccdal, format = '(i1)'), /rem)+ $
            ' CCDB-R: ' + strcompress(string(exp_info.ron_ccdbr, $
             format = '(i1)'), /rem)+ ' CCDB-L: ' + $
            strcompress(string(exp_info.ron_ccdbl, format = '(i1)'), /rem)

line[k+6] = 'HSL status - CCDB-L: ' + strcompress(string(exp_info.hsl_ccdbl, $
            format = '(i1)'), /rem) + ' CCDB-R: ' + $
            strcompress(string(exp_info.hsl_ccdbr, format = '(i1)'), /rem) $
            + ' CCDA-L: ' + strcompress(string(exp_info.hsl_ccdal, $
            format = '(i1)'), /rem) + ' CCDA-R: '+ $
            strcompress(string(exp_info.hsl_ccdar, format = '(i1)'), /rem)

line[k+7] = 'HSL status - CCD Bank selected: ' + $
            strcompress(string(exp_info.hsl_ccdbank, format = '(i1)'), /rem) +$
            ' Link Error: ' + strcompress(string(exp_info.hsl_link_err, $
            format = '(i1)'), /rem) + ' EOF: ' + $
            strcompress(string(exp_info.hsl_eof, format = '(i1)'), /rem) + $
            ' Last: '+ strcompress(string(exp_info.hsl_last, $
            format = '("0x",z2)'), /rem)

line[k+8] = 'XRT Flare trigger status: ' + $
            strcompress(string(exp_info.xrt_fltr_st, format = '(i1)'), /rem) +$
            ' EIS AEC status: ' + strcompress(string(exp_info.eis_aec_st, $
            format = '(i1)'), /rem)
line[k+9] = 'EIS event trigger status: ' + $
            strcompress(string(exp_info.eis_evtr_st, format = '(i1)'), /rem)$
            +' EIS flare trigger status: '+ $
            strcompress(string(exp_info.eis_fltr_st, format = '(i1)'), /rem)

line[k+10] = 'XRT Flare Flag Received: ' + $
            strcompress(string(exp_info.xrt_flfl, format = '(i3)'), /rem) $
            +' XRT Flare X: '+ $
            strcompress(string(exp_info.xrt_fl_x, format = '(i3)'), /rem) $
            +' XRT Flare Y: ' + $
            strcompress(string(exp_info.xrt_fl_y, format = '(i3)'), /rem)

line[k+11] = 'AEC high energy pixel count: ' + $
            strcompress(string(exp_info.aec_npix_h, $
            format = '("0x",z8)'), /rem) + ' AEC low energy pixel count: ' + $
            strcompress(string(exp_info.aec_npix_l, $
            format = '("0x",z8)'), /rem)

line[k+12] = 'EIS translation of XRT flare X - Sign: ' + $
             strcompress(string(exp_info.eis_x_sign, format = '(i1)'), /rem)+$
             ' Coordinate: ' + strcompress(string(exp_info.eis_xrt_fl_x, $
             format = '("0x", z4)'), /rem)+'(' + $ 
             strcompress(string(exp_info.eis_xrt_fl_x, $
             format = '(i5)'), /rem) +')'

line[k+13] = 'EIS translation of XRT flare Y - Sign: ' + $
             strcompress(string(exp_info.eis_y_sign, format = '(i1)'), /rem)+$
             ' Coordinate: ' + strcompress(string(exp_info.eis_xrt_fl_y, $
             format = '("0x", z4)'), /rem)+'(' + $ 
             strcompress(string(exp_info.eis_xrt_fl_y, $
             format = '(i5)'), /rem) +')'

line[k+14] = 'MHC fine mirror strain gauge: ' + $
             strcompress(string(exp_info.mhc_fmirr_sg, $
             format = '("0x",z4)'), /rem)

line[k+15] = 'EIS flare trigger X: ' + $
             strcompress(string(exp_info.eis_fltr_x, $
             format = '("0x", z4)'), /rem)+'(' + $ 
             strcompress(string(exp_info.eis_fltr_x, $
             format = '(i5)'), /rem) +')' + ' EIS flare trigger Y: ' + $
             strcompress(string(exp_info.eis_fltr_y, $
             format = '("0x", z4)'), /rem)+'(' + $ 
             strcompress(string(exp_info.eis_fltr_y, $
             format = '(i5)'), /rem) +')'

line[k+16] = 'EIS event trigger X: ' + $
             strcompress(string(exp_info.eis_evtr_x, $
             format = '("0x", z4)'), /rem)+'(' + $ 
             strcompress(string(exp_info.eis_evtr_x, $
             format = '(i5)'), /rem) +')' + ' EIS event trigger Y: ' + $
             strcompress(string(exp_info.eis_evtr_y, $
             format = '("0x", z4)'), /rem)+'(' + $ 
             strcompress(string(exp_info.eis_evtr_y, $
             format = '(i5)'), /rem) +')'

line[k+17] = 'Anti Solar Rot Comp. Stat. - Direction: ' + $
             strcompress(string(exp_info.asrc_dir, format = '(i1)'), /rem) + $
             ' Nr of steps: ' + strcompress(string(exp_info.asrc_nr, $
             format = '(i3)'), /rem) + ' Skip: ' + $
            strcompress(string(exp_info.asrc_skip, format = '(i3)'), /rem)

line[k+18] = 'Nr of exp. pr. raster pos.: ' + $
             strcompress(string(exp_info.exp_prp, format = '(i3)'), /rem) + $
             ' FMIR step size: ' + strcompress(string(exp_info.fmir_step, $
             format = '(i5)'), /rem)

  textdump=strjoin(line[0:k+18],cr)
end
