!******************************************************************************!
! Test with extreme value changes to verify DataFile.read 12-bit SJ Data Type
!
! 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 t1000sj jeff1000sj.tmp
  res t1000slfromsj jeffslfromsj.tmp

  if interAct then
    set instructions "CJ And SJ square waves should 'match' as &
                      the square wave transitions from one extreme value &
                      to the other.\n\n&
                      This needs to be run with and without the NONATIVE switch\n\n&
                      Curently NONATIVE = ^{nonative}"

    waveform t1000cj FORM="CJ" AMP=0x4321 ELEM=12 SHAPE=Square DELTA=16
    waveform t1000sj FORM="SJ" AMP=0x4321 ELEM=12 SHAPE=Square DELTA=16

    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 14 /title

      plot/id=plot1000cj t1000cj
      plot/id=plot1000sj t1000sj

      list2/id=list1000cj t1000cj
      list2/id=list1000sj t1000sj

      shellgui/id=statusshell/attach
      INFO "status of 1000 SJ"
      status  t1000sj
      INFO "status of 1000 CJ"
      status  t1000cj

    pipe off

    erase t1000cj t1000sj
  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
