! Test the resetting of values for a thinned type 2000 pipe
!
! Author:  J Bauer
! Version: $Id: test_thin_reset.mm,v 1.3 2013/03/08 21:53:03 jwb Exp $
!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE

  if interAct then
    set instructions "You should see a piped 2d file. The file has been THIN'd. &
      Change the values of the FRAME START, STOP, or INCREMENT and push &
      the corresponding button to apply the change. After a RESTART, the &
      plot should change appearance based on the re-THIN of the frames. &
      NOTE: THE PLOT WILL ONLY RESTART IF YOU USE EITHER THE 'FEND' BUTTON OR 'ALL'."


    set format sf
    set sr 1e4
    set over 0
    set sfreq sr/10
    set amp 1e4

    pipe init
      panel/msgid=MAIN/setup/controls=gc

      waveform/id=wave/throttle=real _wave format 10e10 cos freq=sfreq amp=amp delta=1/sr
      fft/dbf _wave _waveb{form=sf} nfft=1k over=over
      thin/id=thinned _waveb _thinned fstart=95 fend=115 finc=1
      plot/id=idplot/msgid=MAIN/READOUT=Show|OnAxis _thinned /lpb=16

      gcontrol label  macro   "MACRO"
      gcontrol menu main "Exit with Status = " "PASS,FAIL" /tleft
      set gc.main.itemColors {PASS=GREEN,FAIL=RED}
      gcontrol text idtext "Instructions" "^instructions" 24 14 /title

      gcontrol label  plot  "RESET VALS"
      gcontrol prompt   pfstart "FSTART" 90
      gcontrol prompt   pfend  "FEND"    110
      gcontrol prompt   pfinc  "FINC"    2

      gcontrol button reset "APPLY RESET" "FSTART,FEND,FINC,ALL"


    pipe off
  endif
endmacro

!******************************************************************************!
procedure processMessage m:msg

  if msg.name eqs "MAIN" then
    assert/text="^reg.main.name: User indicated tests" msg.data eqss "PASS"
    pipe stop
  elseif msg.data eqs "FSTART" then
    set reg.thinned.fstart ^gc.pfstart.value
  elseif msg.data eqs "FEND" then
    set reg.thinned.fend ^gc.pfend.value
  elseif msg.data eqs "FINC" then
    set reg.thinned.finc ^gc.pfinc.value
  elseif msg.data eqs "ALL"
    set reg.thinned.fvals {FSTART=^gc.pfstart.value,FEND=^gc.pfend.value,FINC=^gc.pfinc.value}
  else
    !say "Unhandled message name=^msg.name info=^msg.info fid=^msg.fid data=^msg.data"
  endif

return
