!******************************************************************************!
! Test overlapping multiple type 100 time-based plot
!
! Arguments: None
!
! Note1: The standard Window (X,Y) position should be set to (25,25) in the .mmp
!        configuration file.
!
! @bug      2419
! @author:  J Bauer
!******************************************************************************!
startmacro

  call setDatDir

  timex now yis=init
  calc init2 init 1 +
  noop ^{datDir}.sinewave.prm(0:~10) ram:first
  head first tc=init xs=0
  noop ^{datDir}.sinewave.prm(~1:~11) ram:second
  head second tc=init2 xs=0
  
  set defaultInstructions "You should see two plots, each of two files.\n\n&
                           The bottom plot should show the two plots overlaid on top of each other precisely.\n\n&
                           Press true or false to toggle Time Align on the top plot. When true, &
                           the two plots should be identical."
  
  pipe on
  
    panel/msgid=MAIN/setup/controls=gc
		
		gcontrol label mainLabel "Main"
      gcontrol menu main "Exit with Status = " "PASS,FAIL" /tleft
      set gc.main.itemColors {PASS=GREEN,FAIL=RED}
      
    gcontrol text idtext "Instructions" "^defaultInstructions" 40 14 /title
    
    plot/id=plot1 first|second readout="+onAxis|+DateString"

    plot/id=plot2 first|second readout="+onAxis|+DateString" /timealign   ! /timealign switch added in 3.1.2
  
  
    gcontrol button myButt "Align Plots By Base Time" "true,false" ""
  
  pipe off

endmacro

!******************************************************************************!
! Main process message for this macro. Should be right after the 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.name eqs "MYBUTT" then
    set reg.plot1.timeAlign msg.data
    invoke ,, reg.plot1.refresh()
  endif
  
return

!******************************************************************************!
! Set the dat directory
!******************************************************************************!
procedure setDatDir
  invoke nxmMajor env.nmversion.subString(0,1)
  invoke major java.lang.Integer.valueOf(nxmMajor)
  if major GE 4 then
    invoke s:datDir           nxm.sys.test.DatLocator.getDatDirLocation()
    invoke s:datDirSlash      nxm.sys.test.DatLocator.getDatDirSlashLocation()
    invoke z:sysDatFull       nxm.sys.test.DatLocator.sysDatFull()
    invoke z:sysTestDatExists nxm.sys.test.DatLocator.sysTestDatExists()
  else
    set s:datDir           "nxm.sys.dat"
    set s:datDirSlash      "nxm/sys/dat"
    set z:sysDatFull       true
    set z:sysTestDatExists false
  endif
return
