startmacro a:host[localhost] l:port[8080] l:sport[9000]

local ctbl cent item 

res ctbl "icebox"
res cent "default"

res l:sport1 sport+1
res l:sport2 sport+2

xpipe/setup/controls on

xpipe off

endmacro

startcontrols

label initialentry
xcontrol/lab=lact menu item 0 "Macro;Launch,Start,Stop,Close,Status,Exit"
xcontrol/lab=lhost aprompt host host "Host: " 20
xcontrol/lab=lport/name="Port: " lval port port 
xcontrol/lab=ltbl aprompt ctbl ctbl "Table: " 20
xcontrol/lab=lent aprompt cent cent "Scene: " 20
xcontrol/lab=lfmt menu fmt 1 "Params;Set 1,Set 2,Set 3"
return

label lact
if item eq 1 then
  say "Launch"
  icenet set ^host:^port {ALLOC=LAUNCH} "HTTP"
elseif item eq 2 then
  say "Start"
  icenet set ^host:^port {ACTION=MONITOR} "HTTP"
elseif item eq 3 then
  say "Stop"
  icenet set ^host:^port {ACTION=STOP} "HTTP"
elseif item eq 4 then
  say "Close"
  icenet set ^host:^port {ALLOC=CLOSE} "HTTP"
elseif item eq 5 then
  say "Status"
  icenet get ^host:^port {ALLOC=,ACTION=} "HTTP"
  icenet get ^host:^sport1 {RATE=,FORMAT=,GAIN=} "HTTP"
elseif item eq 6 then
  stop
endif
return

label lhost
say "Set Server Host = ^host"
return

label lport
say "Set Server Port = ^port"
return

label ltbl
say "Tbl = ^ctbl"
return

label lent
say "Scene = ^cent"
icenet set ^host:^port {SCENE=^cent} "HTTP"
return

label lfmt
say "Format = ^fmt"
if fmt eq 1 then
  icenet set ^host:^sport1 {RATE=50,FORMAT=SI} "HTTP"
elseif fmt eq 2 then
  icenet set ^host:^sport1 {RATE=100,FORMAT=SB} "HTTP"
else
  icenet set ^host:^sport1 {RATE=25,FORMAT=CI} "HTTP"
endif
return

endcontrols
