!******************************************************************************!
! Readout includes radius when plotting real vs imagingary
!
! Arguments: None
!
! @issue    NXM-4065 MPlot should include radius on real vs imag readouts
! @since    NeXtMidas 4.1.4
! @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)

  lookandfeel gear4
  call setDatDir

  if ^{env.NMROOT} EQS "classpath:" then
    res psk_file "psk_iq{AUX=RAM}"
    file copy ^{datDir}.psk_iq_t1000.prm psk_file
    file unprotect psk_file
  else
    res psk_file "^{datDir}.psk_iq_t1000.prm"
  endif

  if interAct then
    set instructions "Real versus Imaginary Plot of 8PSK Signal\n\n&
                     1) Should see 8 symbol positions,\n   &
                        with a 'ball' or 'cloud' of points at each\n\n&
                     2) When hovering over the plot, you should see\n   &
                        an onAxis readout with radius 'r=', where\n   &
                        the center of each ball is about r=1 (+-0.05)."

    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

      ! file with phase modulation -> psd, file with phase modulation -> demod
      noop/rt/wrap/id=psk psk_file _pskwave{ps=32k}
      plot/id=plotiq _pskwave{LAYER={Type="Point"}} cm=RvI /READOUT=+OnAxis
    pipe off

  endif
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

!******************************************************************************!
! 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
