!******************************************************************************!
! Tests PLOT of Jeff's SJ, with both 1000 and 2000 files
!
! ALL these test should be run with both USENATIVE |Convert| (i.e. NONATIVE=FALSE or default)
! and USENATIVE | (i.e. NONATIVE=TRUE) to exercise both Native.c & Convert.java code
!
! Arguments: None
!
! @bug      NXM-3894  12-bit integer Midas Data Type needed
! @since    4.1.2
! @author:  Jeanette McCall
!******************************************************************************!
startmacro
  switch INTERACTIVE interAct GET DEF=TRUE  SDEF=TRUE  ! for normal interactive test(s)
  switch BASELINE    baseline GET DEF=FALSE SDEF=TRUE  ! for defects or more obscure test case(s)
  switch NONATIVE    nonative GET DEF=FALSE SDEF=TRUE  ! run with all Java

  res savedUseNative env.usenative
  if nonative then
    env set usenative |
  else
    env set usenative |IO|Math|Cast|Convert|Other|
  endif

  res t1000cj jeff1000cj.tmp
  res t2000cj jeff2000cj.tmp
  res t1000sifromsj jeffsifromsj.tmp

  if interAct then
    set instructions "Tests PLOT of Jeff's 12-bit SJ, both 1000 and 2000 files\n\n&
                      This needs to be run with and without the NONATIVE switch\n\n&
                      Curently NONATIVE = ^{nonative}"

    waveform t1000sj FORM="SJ" AMP=200 ELEM=512
    fft t1000sj t2000sj{FORM=SJ} NFFT=32

    pipe on
      panel/msgid=MAIN/setup/controls=gc
      gcontrol label macro "Test MACRO"
      gcontrol menu  main "Exit with Status =" "PASS,FAIL" TABLE={ItemColors={PASS="GREEN",FAIL="RED"}} /tleft

      gcontrol text  idtext "Instructions" instructions 24 12 /title

      plot/id=plot1000sj t1000sj
      plot/id=plot2000sj t2000sj

      list2/id=list1000sj t1000sj
      list2/id=list2000sj t2000sj

      shellgui/id=statusshell/attach
      info "status of 1000 SJ"
      status  t1000sj
      info "status of 2000 SJ"
      status  t2000sj
      info "DATALIST of 1000 SJ"
      datalist t1000sj /nc=16
    pipe off

    erase t1000sj t2000sj
  endif
  env set usenative savedUseNative
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
  else
    say "Unhandled message name: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif
return

!******************************************************************************!
! If an unexpected exception is caught, mark test as failed, unless it is expected
!******************************************************************************!
procedure processException m:emsg
  if expectedException REXISTS then
    assert/text="^reg.main.name: Expected ERROR starts with: ^{expectedException}" expectedException EQSS emsg.data.message
    remove expectedException
  else
    assert/text="^reg.main.name: Caught unexpected exception ^{emsg.data}" "FALSE" isTrue
    if "Trace" SUBS ENV.DEBUG then invoke ,, emsg.data.printStackTrace()
  endif
return
