!******************************************************************************!
! Test CONVERT BLUE2JSON of Platinum 1000/6000 pair file with custom mappings
! starter test
!
! NXM-3855 Support BLUE information being put in nested JSON text file
!
! Author:  Jeanette McCall
!******************************************************************************!
startmacro

  res expectedException ""

  set origPlatFullKeywords      "nxm.sys.test.testplat4plat2blue_cov.cdif"
  set fullPlat1000Assoc6000  "testplat1000assoc6000.cdif"
  set plat6000Assoc1000  "testplat6000assoc1000.cdif"
  res outjsonfile "blue2json_platinum_pair.txt"

  call createFilePair

  %convert_blue2json_platinum_pair fullPlat1000Assoc6000 outjsonfile

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
res expectedException
res emsg.data.message
  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
!******************************************************************************!
! Create Platinum 1000 / 6000 pair
!******************************************************************************!
procedure createFilePair


  ! Transform testplat4plat2blue_cov.cdif to 2.0 valid PLATINUM files
  file copy/f origPlatFullKeywords fullPlat1000Assoc6000
  file UNPROTECT fullPlat1000Assoc6000
  keyword fullPlat1000Assoc6000 set TOA_SIGMA 0.0 FOA_SIGMA 0.0
  keyword fullPlat1000Assoc6000 set AIR_TAIL_NUM "009" COLLECTOR MY_COLLECTOR
  keyword fullPlat1000Assoc6000 set XTAL_FREQ "Signal Generator" SIGNAL_ID SIG001
  keyword fullPlat1000Assoc6000 set POLORIZATION VERTICLE ANTENNA_DIA MY_ANTENNA_DIA
  keyword fullPlat1000Assoc6000 set IOVERSION 1.2.3 WRITER NXM WRITER_VERSION 4.1.3 APPLICATION "SigMF"
  keyword fullPlat1000Assoc6000 set ASSOC6000 "^plat6000Assoc1000"
  keyword fullPlat1000Assoc6000 set ver 2.0 /SCOPE=main ! setting VER needs to be last
  !status/key ^fullPlat1000Assoc6000

  ! Create 6000 Platinum to match
  file copy/f test6000.prm{BLUEVER=2.0} plat6000Assoc1000
  file UNPROTECT plat6000Assoc1000
  keyword plat6000Assoc1000 set ASSOC1000 "^fullPlat1000Assoc6000"
  keyword plat6000Assoc1000 set ver 2.0 /SCOPE=main ! setting VER needs to be last
  !status/key ^plat6000Assoc1000

return