Selaa lähdekoodia

*** empty log message ***

Mark Mine 24 vuotta sitten
vanhempi
sitoutus
c91d322a3b

+ 32 - 27
direct/src/cluster/ClusterClient.py

@@ -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",
-                                                 20000)
+        gameServerTimeoutMs = base.config.GetInt(
+            "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:
-            thisDisp = DisplayConnection(self.qcm,dispConfig.serverName,
-                                         dispConfig.port,self.msgHandler)
-            if thisDisp == None:
+        for serverConfig in configList:
+            server = DisplayConnection(self.qcm,serverConfig.serverName,
+                                         serverConfig.port,self.msgHandler)
+            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,
-                                     dispConfig.serverName,
-                                     dispConfig.port)) )
+                                    (serverConfig.serverFunction,
+                                     serverConfig.serverName,
+                                     serverConfig.port)) )
             else:
             else:
-                self.dispList.append(thisDisp)
-                self.dispList[len(self.dispList)-1].sendCamOffset(
-                    dispConfig.xyz,dispConfig.hpr)
+                server.sendCamOffset(serverConfig.xyz,serverConfig.hpr)
+                self.serverList.append(server)
         self.startMoveCamTask()
         self.startMoveCamTask()
 
 
     def moveCamera(self, xyz, hpr):
     def moveCamera(self, xyz, hpr):
-        for disp in self.dispList:
-            disp.sendMoveCam(xyz,hpr)
+        for server in self.serverList:
+            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):
-        ClusterManager.__init__(self, dispConfigs)
+    def __init__(self, configList):
+        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:
-                disp.getSwapReady()
-            self.notify.debug("----------------START swap now--------------------")
+            for server in self.serverList:
+                server.getSwapReady()
+            self.notify.debug(
+                "----------------START swap now--------------------")
             t2 = localClock.getRealTime()
             t2 = localClock.getRealTime()
-            for disp in self.dispList:
-                disp.sendSwapNow()
-            self.notify.debug("------------------------------START swap----------")
+            for server in self.serverList:
+                server.sendSwapNow()
+            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

+ 58 - 37
direct/src/cluster/ClusterConfig.py

@@ -7,46 +7,67 @@ 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)] ],
-                 'single': [ [Vec3(0,0,0),Vec3(0,0,0)] ]}
+# Specify offset from client for each server's camera group
+# 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():
-    # setup camera offsets based on chanconfig
-    # This should ideally be independent of chan-config.  In other
-    # words, there might be some other configuration for clustering,
-    # from which the number and offset of the servers' cameras are set.
-    chanConfig = base.config.GetString('chan-config', 'single')
-    
-    if base.config.GetBool('display-client'):
-        if not ClientConfigs.has_key(chanConfig):
-            base.notify.warning('Display Client flag set, but %s is not a display client configuration.' % chanConfig)
-            return None
-        thisClientConfig = ClientConfigs[chanConfig]
-        displayConfigs = []
-        for i in range(len(thisClientConfig)):
-            configString = 'display%d' % i
-            serverString = base.config.GetString(configString, '')
-            if serverString == '':
-                base.notify.warning('%s should be defined in Configrc to use %s as display client.' % [configString,chanConfig])
-                base.notify.warning('%s will not be used.' % configString)
-            else:
-                serverInfo = string.split(serverString)
-                if len(serverInfo) > 1:
-                    port = int(serverInfo[1])
-                else:
-                    port = CLUSTER_PORT
-                displayConfigs.append(ClusterConfigItem(configString,
-                    serverInfo[0], thisClientConfig[i][0], thisClientConfig[i][1],port))
-                
-        synced = base.config.GetBool('sync-display',0)
-        if synced:
-            base.win.setSync(1)
-            return ClusterManagerSync(displayConfigs)
+def createClusterManager():
+    # setup camera offsets based on cluster-config
+    clusterConfig = base.config.GetString('cluster-config', 'single-server')
+    # No cluster config specified!
+    if not ClientConfigs.has_key(clusterConfig):
+        base.notify.warning(
+            'display-client flag set, but %s cluster-config is undefined.' %
+            clusterConfig)
+        return None
+    # Get display config for each server in the cluster
+    displayConfigs = []
+    configData = ClientConfigs[clusterConfig]
+    numConfigs = len(configData)
+    for i in range(numConfigs):
+        serverConfigName = 'display%d' % i
+        serverString = base.config.GetString(serverConfigName, '')
+        if serverString == '':
+            base.notify.warning(
+                '%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)
+            serverName = serverInfo[0]
+            if len(serverInfo) > 1:
+                port = int(serverInfo[1])
+            else:
+                # Use default port
+                port = CLUSTER_PORT
+            displayConfigs.append(ClusterConfigItem(
+                serverConfigName,
+                serverName,
+                # 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:
+        base.win.setSync(1)
+        return ClusterManagerSync(displayConfigs)
+    else:
             return ClusterManager(displayConfigs)
             return ClusterManager(displayConfigs)
     
     
 
 

+ 4 - 1
direct/src/directtools/DirectSession.py

@@ -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()