!******************************************************************************!
! Tests for files with a TimeLine that pages under Layer2D.
!
! Arguments: None
!
! Issue:   NXM-1175 PLOT: returns wrong time for Layer2D files
! Since:   NeXtMidas 2.5.3
! Author:  Neon Ngo
!******************************************************************************!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE

  ! Only allow interAct if PANEL command Exists - may be running in LIBNXM mode
  invoke panelExists reg.shell.M.dictionary.isDictionaryEntry(PANEL)

  set testfile test_timeline_paging_problem
  set nels 942*5000
  set startTimecode 2008:01:10::16:39:29.9999
  ! set timeDelta 0.0648
  set timeDelta 0.005

  ! Start Interactive test section to verify RESULTS output
  if interAct AND panelExists then
    ! create test file
    waveform OUT=^testfile FORM=SF ELEM=^nels SHAPE=white AMP=1 &
             FREQ=0.01 PHASE=0 START=0 DELTA=1
    headermod ^testfile XU=freq xs=4.548677098765432E8 XD=7.71604938271605 &
              FS=500 YU=time_s YS=0 YD=^timeDelta TIMECODE=^startTimecode

    set instr "Should see a plot of noise. Hover mouse over the top edge of the plot. &
           The readout on the axis for y=00:00:00 should show time as t=2008:01:10::16:39:30.000 &
           Slowly move the mouse vertically down the plot, the time displayed in 't=' should increase and &
           never decrease (hint: focus on the seconds and fractional seconds after the decimal in &
           the time string). It may be easier to verify this if you zoom near the top of the plot. "

    pipe on
      panel/msgid=MAIN/id=panel/setup/controls=gc
      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" "^instr" 30 20 /title

      plot ^testfile readout=+OnAxis|-OnTitle|+T|+DateString|-X|-DX|-DY|-View /ALL
    pipe off

    ! cleanup
    erase ^testfile
  endif
  ! End Interactive test section

endmacro

! Procedure for handling all messages
procedure processMessage m:msg
  if msg.name EQS "MAIN" then
    assert/text="^reg.main.name: TimeLine paging tests" "PASS" SUBS msg.data
    pipe stop
  else
    say "^reg.main.name: Unhandled messagename: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return
