!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! test_plot_layer1d_openfile - test opening a new pipe with qualifiers
! @author J Bauer
! @bug 2115
! @version $Id: test_plot_layer1d_openfile.mm,v 1.4 2010/10/05 15:30:09 ntn Exp $
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
startmacro/msgid=main/theme=gear2

    pipe on
      set fs 512
      set sr 1e5
      panel/setup/controls=gc/wmsgid=main ! special handling of window messages

      waveform/rt _wave1{ps=32k} shape=sin form=cf elem=inf amp=32e3 freq=sr/10 delta=1/sr
      waveform/rt _wave2{ps=32k} shape=cos form=cf elem=inf amp=32e3 freq=sr/20 delta=1/sr
      waveform/rt _wave3{ps=32k} shape=cos form=cf elem=inf amp=32e3 freq=sr/40 delta=1/sr

      plot/id=plot1/fs=8k _wave1{FS=^fs} type=line

      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" "Should see a line plot of a pipe. Click the buttons and the plot should change." 10 5 /title
      gcontrol/nc=1 button swapFile "FILE TO PLOT" "PIPE 1,PIPE 2,PIPE 3" 1

    pipe off

endmacro

procedure processMessage m:msg

  if msg.name EQS "MAIN" then
    if msg.data EQS "EXIT" then
      pipe stop
    else
      assert/text="^reg.main.name: user indicated" msg.data eqs "PASS"
      pipe stop
    endif

  elseif msg.name EQS "SWAPFILE" then
    if msg.data EQS "PIPE 1" then
      set myfile _wave1
    elseif msg.data EQS "PIPE 2" then
      set myfile _wave2
    else
      set myfile _wave3
    endif
    message func=send id=plot1 info=-1 name="OPENFILE" DATA=^{myfile}{fs=^fs}

  endif

return
