*** empty log message ***

This commit is contained in:
Mark Mine 2002-03-23 00:30:52 +00:00
parent c9cbb60c2a
commit c91d322a3b
3 changed files with 94 additions and 65 deletions

View File

@ -21,8 +21,8 @@ class ClusterConfigItem:
class DisplayConnection: class DisplayConnection:
def __init__(self,qcm,serverName,port,msgHandler): def __init__(self,qcm,serverName,port,msgHandler):
self.msgHandler = msgHandler self.msgHandler = msgHandler
gameServerTimeoutMs = base.config.GetInt("game-server-timeout-ms", gameServerTimeoutMs = base.config.GetInt(
20000) "game-server-timeout-ms", 20000)
# A big old 20 second timeout. # A big old 20 second timeout.
self.tcpConn = qcm.openTCPClientConnection( self.tcpConn = qcm.openTCPClientConnection(
serverName, port, gameServerTimeoutMs) serverName, port, gameServerTimeoutMs)
@ -60,7 +60,9 @@ class DisplayConnection:
# the following should only be called by a synchronized cluster manger # the following should only be called by a synchronized cluster manger
def sendSwapNow(self): def sendSwapNow(self):
ClusterManager.notify.debug( ("dispaly connect send swap now, packet %d" % self.msgHandler.packetNumber)) ClusterManager.notify.debug(
"display connect send swap now, packet %d" %
self.msgHandler.packetNumber)
datagram = self.msgHandler.makeSwapNowDatagram() datagram = self.msgHandler.makeSwapNowDatagram()
self.cw.send(datagram, self.tcpConn) self.cw.send(datagram, self.tcpConn)
@ -68,27 +70,26 @@ class ClusterManager(DirectObject.DirectObject):
notify = DirectNotifyGlobal.directNotify.newCategory("ClusterClient") notify = DirectNotifyGlobal.directNotify.newCategory("ClusterClient")
MGR_NUM = 1000000 MGR_NUM = 1000000
def __init__(self, dispConfigs): def __init__(self, configList):
self.qcm=QueuedConnectionManager() self.qcm=QueuedConnectionManager()
self.dispList = [] self.serverList = []
self.msgHandler = MsgHandler(ClusterManager.MGR_NUM,self.notify) self.msgHandler = MsgHandler(ClusterManager.MGR_NUM,self.notify)
for dispConfig in dispConfigs: for serverConfig in configList:
thisDisp = DisplayConnection(self.qcm,dispConfig.serverName, server = DisplayConnection(self.qcm,serverConfig.serverName,
dispConfig.port,self.msgHandler) serverConfig.port,self.msgHandler)
if thisDisp == None: if server == None:
self.notify.error( ('Could not open %s on %s port %d' % self.notify.error( ('Could not open %s on %s port %d' %
(dispConfig.serverFunction, (serverConfig.serverFunction,
dispConfig.serverName, serverConfig.serverName,
dispConfig.port)) ) serverConfig.port)) )
else: else:
self.dispList.append(thisDisp) server.sendCamOffset(serverConfig.xyz,serverConfig.hpr)
self.dispList[len(self.dispList)-1].sendCamOffset( self.serverList.append(server)
dispConfig.xyz,dispConfig.hpr)
self.startMoveCamTask() self.startMoveCamTask()
def moveCamera(self, xyz, hpr): def moveCamera(self, xyz, hpr):
for disp in self.dispList: for server in self.serverList:
disp.sendMoveCam(xyz,hpr) server.sendMoveCam(xyz,hpr)
def startMoveCamTask(self): def startMoveCamTask(self):
task = Task.Task(self.moveCameraTask,49) task = Task.Task(self.moveCameraTask,49)
@ -104,8 +105,8 @@ class ClusterManager(DirectObject.DirectObject):
class ClusterManagerSync(ClusterManager): class ClusterManagerSync(ClusterManager):
def __init__(self, dispConfigs): def __init__(self, configList):
ClusterManager.__init__(self, dispConfigs) ClusterManager.__init__(self, configList)
#I probably don't need this #I probably don't need this
self.waitForSwap = 0 self.waitForSwap = 0
self.ready = 0 self.ready = 0
@ -120,20 +121,24 @@ class ClusterManagerSync(ClusterManager):
self.ready = 1 self.ready = 1
if self.waitForSwap: if self.waitForSwap:
self.waitForSwap=0 self.waitForSwap=0
self.notify.debug("START get swaps----------------------------------") self.notify.debug(
"START get swaps----------------------------------")
localClock = ClockObject() localClock = ClockObject()
t1 = localClock.getRealTime() t1 = localClock.getRealTime()
for disp in self.dispList: for server in self.serverList:
disp.getSwapReady() server.getSwapReady()
self.notify.debug("----------------START swap now--------------------") self.notify.debug(
"----------------START swap now--------------------")
t2 = localClock.getRealTime() t2 = localClock.getRealTime()
for disp in self.dispList: for server in self.serverList:
disp.sendSwapNow() server.sendSwapNow()
self.notify.debug("------------------------------START swap----------") self.notify.debug(
"------------------------------START swap----------")
t3 = localClock.getRealTime() t3 = localClock.getRealTime()
base.win.swap() base.win.swap()
t4 = localClock.getRealTime() t4 = localClock.getRealTime()
self.notify.debug("------------------------------------------END swap") self.notify.debug(
"------------------------------------------END swap")
self.notify.debug( ("times=%f %f %f %f" % (t1,t2,t3,t4)) ) self.notify.debug( ("times=%f %f %f %f" % (t1,t2,t3,t4)) )
self.notify.debug( ("deltas=%f %f %f" % (t2-t1,t3-t2,t4-t3)) ) self.notify.debug( ("deltas=%f %f %f" % (t2-t1,t3-t2,t4-t3)) )
return Task.cont return Task.cont

View File

@ -7,42 +7,63 @@ import string
# For mono-modelcave-pipe0, I decided to set the offsets in the # For mono-modelcave-pipe0, I decided to set the offsets in the
# actual configuration for the display. # actual configuration for the display.
ClientConfigs = {'mono-modelcave-pipe0': [ [Vec3(0,0,0),Vec3(0,0,0)] ], # Specify offset from client for each server's camera group
'single': [ [Vec3(0,0,0),Vec3(0,0,0)] ]} # Note: If server chan-config consists of multiple display regions
# each display region can have an additional offset as specified in
# DirectCamConfig.py
ClientConfigs = {'mono-modelcave-pipe0': [ [Vec3(0),Vec3(0)] ],
'single-server': [ [Vec3(0),Vec3(0)] ],
'two-server' : [ [Vec3(0),Vec3(-60,0,0)],
[Vec3(0),Vec3(60,0,0)]
],
'cavetest' : [ [Vec3(0), Vec3(0)],
[Vec3(0), Vec3(0)],
[Vec3(0), Vec3(0)],
[Vec3(0), Vec3(0)]
],
}
# The following is a fake configuration to show an example with two servers.
# 'two-server' : [ [Vec3(0,0,0),Vec3(-60,0,0)],
# [Vec3(0,0,0),Vec3(60,0,0) ] ]
def createCluster(): def createClusterManager():
# setup camera offsets based on chanconfig # setup camera offsets based on cluster-config
# This should ideally be independent of chan-config. In other clusterConfig = base.config.GetString('cluster-config', 'single-server')
# words, there might be some other configuration for clustering, # No cluster config specified!
# from which the number and offset of the servers' cameras are set. if not ClientConfigs.has_key(clusterConfig):
chanConfig = base.config.GetString('chan-config', 'single') base.notify.warning(
'display-client flag set, but %s cluster-config is undefined.' %
if base.config.GetBool('display-client'): clusterConfig)
if not ClientConfigs.has_key(chanConfig):
base.notify.warning('Display Client flag set, but %s is not a display client configuration.' % chanConfig)
return None return None
thisClientConfig = ClientConfigs[chanConfig] # Get display config for each server in the cluster
displayConfigs = [] displayConfigs = []
for i in range(len(thisClientConfig)): configData = ClientConfigs[clusterConfig]
configString = 'display%d' % i numConfigs = len(configData)
serverString = base.config.GetString(configString, '') for i in range(numConfigs):
serverConfigName = 'display%d' % i
serverString = base.config.GetString(serverConfigName, '')
if serverString == '': if serverString == '':
base.notify.warning('%s should be defined in Configrc to use %s as display client.' % [configString,chanConfig]) base.notify.warning(
base.notify.warning('%s will not be used.' % configString) '%s undefined in Configrc: expected by %s display client.' %
(serverConfigName,clusterConfig))
base.notify.warning('%s will not be used.' % serverConfigName)
else: else:
serverInfo = string.split(serverString) serverInfo = string.split(serverString)
serverName = serverInfo[0]
if len(serverInfo) > 1: if len(serverInfo) > 1:
port = int(serverInfo[1]) port = int(serverInfo[1])
else: else:
# Use default port
port = CLUSTER_PORT port = CLUSTER_PORT
displayConfigs.append(ClusterConfigItem(configString, displayConfigs.append(ClusterConfigItem(
serverInfo[0], thisClientConfig[i][0], thisClientConfig[i][1],port)) serverConfigName,
serverName,
synced = base.config.GetBool('sync-display',0) # Pos Offset
configData[i][0],
# Hpr Offset
configData[i][1],
port))
# Create Cluster Managers (opening connections to servers)
# Are the servers going to be synced?
synced = base.config.GetBool('sync-display', 0)
if synced: if synced:
base.win.setSync(1) base.win.setSync(1)
return ClusterManagerSync(displayConfigs) return ClusterManagerSync(displayConfigs)

View File

@ -35,7 +35,10 @@ class DirectSession(PandaObject):
"models/fonts/Comic", "models/fonts/Comic",
priority = 100) priority = 100)
self.iAmAClient = base.config.GetBool("display-client",0) self.iAmAClient = base.config.GetBool("display-client",0)
self.clusterManager = createCluster() if self.iAmAClient:
self.clusterManager = createClusterManager()
else:
self.clusterManager = None
self.iAmAServer = base.config.GetBool("display-server",0) self.iAmAServer = base.config.GetBool("display-server",0)
self.fEnabled = 0 self.fEnabled = 0
self.drList = DisplayRegionList() self.drList = DisplayRegionList()