!------------------------------------------------------------------------------!
! Tests for LIST command /POLL switch
! NOTE:  this is an interactive test and requires operator verification
!        in order to determine test success.
!
!   Author : J. Hallam
!   Version: $Id: test_list_poll.mm,v 1.5 2010/08/04 15:55:13 ntn Exp $
!
!------------------------------------------------------------------------------!
startmacro

switch INTERACTIVE interAct GET DEF=TRUE
switch BASELINE    baseline GET DEF=FALSE
if interAct then
  ! INPUT files used for tests
  waveform temp_list_poll elem=4k
  set pollTime 2

  timex now sod=sod
  pipe init

    panel/msgid=MAIN/controls=gc/setup

    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" "Initializing..." 24 5 /title
    gcontrol label pollList "POLL LIST" AlwaysOpen
    gcontrol PANEL listPanel "POLL LIST" 200 200
    gcontrol label options "OPTIONS" AlwaysOpen
    gcontrol/mon=sod/msg=f dval secondofday "Seconds-of-day" sod -1 1e9 /fmt="#.000"
    set gc.IDTEXT.value &
      "The lists should refresh from the file following the specified Poll Time. The current time &
       shown as a Seconds-of-day widget is provided to help determine when the lists are updated."
    gcontrol LVAL polltime "Poll Time" pollTime 1 10 1
    list/poll=^pollTime/id=idlist  temp_list_poll
    list/poll=^pollTime/id=listpanel temp_list_poll

    set reg.panel.timer(0) 1
  pipe off

  ! Erase temporary files
  erase/quiet/warn=no temp_list_poll

endif

endmacro

!------------------------------------------------------------------------------!
! Procedure for handling all messages
!
procedure processMessage m:msg
  if msg.fid EQS "IDLIST" then
    say "Got ^msg.name from ^msg.fid"

  elseif msg.name EQS "TIMER" then
    timex now sod=sod
    set FILE(temp_list_poll).data(0) ^sod

  elseif msg.name EQS "POLLTIME" then
    set reg.idlist.pollinterval    gc.POLLTIME.value
    set reg.listpanel.pollinterval gc.POLLTIME.value

  elseif msg.name EQS "MAIN" then
    assert/text="^reg.main.name: Interactive tests" msg.data eqss "PASS"
    pipe stop

  else
    say "^reg.main.name: Unhandled messagename: ^msg.name from fid: ^msg.fid data: ^msg.data"
  endif

return
