!******************************************************************************!
! Test timeline pipe restarts
!
! Arguments: None
!
! @bug      NXM-3174 NeXtMidas 3.7.3 PipeResources.initTimecode() timeline broken with pipe restarts
!           NXM-3042 TimeLine Issues
! @since    3.8.0
! @author:  J. Czechowski
!
! TODO: This needs to be changed to an automated test case
!******************************************************************************!
startmacro
  calc L:nfft    1K
  calc D:dt      1e-6
  calc L:tll     32
  calc L:tlt     dt
  calc D:jitter  1
  res  quals     {TLL=^tll,TLT=^tlt}
  res  outFile   timeline373.tmp{AUX=HOME,FLAGS=+FLUSH}^quals
  res  startTime 2017:01:01:00:00:00
  
  pipe on
    waveform/rt _wave^quals FORM=SI SHAPE=SIN DELTA=^dt DURATION=30
    nxm.sys.test.addjitter IN=_wave^quals OUT=_waveTC^quals JITTER=^jitter
    fft/id=FFT/psd _waveTC^quals _psd^quals NFFT=nfft
    noop _wave outFile
    set this.timers    1
    set this.timer(0)  1
  pipe run
  pipe wait
  pipe off
  
  ! Need to automate this rather than printing to the screen
  status/k/t outfile
  
endmacro

procedure processMessage m:msg
  if msg.name eqs "TIMER" AND msg.info EQ 0 then
    calc L:nfft nfft 2 *
    
    if (nfft > 16K) then
      info "**************************************"
      info "Done"
      pipe stop
    endif
    
    info "**************************************"
    info "setting NFFT=^nfft"
    set reg.fft.nfft nfft
  else
    warn "Got unexpected message ^msg data=^msg.data"
  endif
return
