# Copyright (c) 2001, Stanford University
# All rights reserved
#
# See the file LICENSE.txt for information on redistributing this software.

import sys
sys.path.append( '../server' )
from mothership import *

if len(sys.argv) > 3 or len(sys.argv) < 2:
	print 'Usage: %s <demo> [spu]' % sys.argv[0] 
	sys.exit(-1)

CR_BIN_DIR = r'c:\work\cr\bin\WIN_NT'
demo = sys.argv[1]

if len(sys.argv) == 3:
	clientspuname = sys.argv[2]
else:
	clientspuname = 'pack'

server_spu = SPU( 'render' )
client_spu = SPU( clientspuname )

server_spu.Conf( 'window_geometry', 100, 100, 500, 500 )

server_node = CRNetworkNode( )
server_node.AddSPU( server_spu )

if (clientspuname == 'tilesort' ):
	server_node.AddTile( 0, 0, 500, 500 )

client_node = CRApplicationNode( )
client_node.AddSPU( client_spu )
client_spu.AddServer( server_node, 'tcpip' )

client_node.SetApplication( '%s/%s' % (CR_BIN_DIR, demo) )
client_node.StartDir( CR_BIN_DIR )

cr = CR()
cr.MTU( 16*1024 );
cr.AddNode( client_node )
cr.AddNode( server_node )
cr.Go()
