*** empty log message ***

This commit is contained in:
Jesse Schell 2000-11-01 18:35:26 +00:00
parent ae77863a93
commit a85771f39d
6 changed files with 32 additions and 23 deletions

View File

@ -51,20 +51,20 @@ class ClientDistClass:
def updateField(self, do, di):
# Get the update field id
fieldId = di.getArg(ST_uint8)
fieldId = di.getArg(STUint16)
# look up the CDU
assert(self.number2CDU.has_key(fieldId))
cdu = self.number2CDU[fieldId]
# Let the cdu finish the job
cdu.updateField(cdc, do, di)
cdu.updateField(self, do, di)
return None
def sendUpdate(self, do, fieldName, args):
def sendUpdate(self, cr, do, fieldName, args):
# Look up the cdu
assert(self.name2CDU.has_key(fieldName))
cdu = self.name2CDU[fieldName]
# Let the cdu finish the job
cdu.sendUpdate(do, args)
cdu.sendUpdate(cr, do, args)

View File

@ -3,6 +3,8 @@
import DirectNotifyGlobal
import Avatar
import DistributedToon
import Datagram
from MsgTypes import *
class ClientDistUpdate:
notify = DirectNotifyGlobal.directNotify.newCategory("ClientDistUpdate")
@ -28,7 +30,7 @@ class ClientDistUpdate:
componentField = dcFieldMolecular.getAtomic(i)
for j in range(0, componentField.getNumElements()):
self.types.append(componentField.getElementType(j))
self.types.append(componentField.getElementDivisor(j))
self.divisors.append(componentField.getElementDivisor(j))
else:
ClientDistUpdate.notify.error("field is neither atom nor molecule")
return None
@ -57,17 +59,17 @@ class ClientDistUpdate:
numElems = len(args)
assert (numElems == len(self.types))
for i in range(0, numElems):
datagram.addArg(args[i], self.types[i])
datagram.putArg(args[i], self.types[i])
def sendUpdate(self, do, args):
datagram = Datagram()
def sendUpdate(self, cr, do, args):
datagram = Datagram.Datagram()
# Add message type
datagram.addUint16(ALL_OBJECT_UPDATE_FIELD)
datagram.addUint16(CLIENT_OBJECT_UPDATE_FIELD)
# Add the DO id
datagram.addUint32(do.doId)
# Add the field id
datagram.addUint8(self.number)
datagram.addUint16(self.number)
# Add the arguments
self.addArgs(datagram, args)
# send the datagram
cr.send(datagram)

View File

@ -106,7 +106,7 @@ class ClientRepository(DirectObject.DirectObject):
distObj.updateRequiredFields(cdc, di)
else:
# Construct a new one
distObj = constructor()
distObj = constructor(self)
# Assign it an Id
distObj.doId = doId
# Update the required fields
@ -119,10 +119,10 @@ class ClientRepository(DirectObject.DirectObject):
def handleUpdateField(self, di):
# Get the DO Id
doId = di.getArg(ST_uint32)
doId = di.getArg(STUint32)
# Find the DO
assert(self.doId2do.has_key(doId))
do = self.doId2do(doId)
do = self.doId2do[doId]
# Find the cdc
assert(self.doId2cdc.has_key(doId))
cdc = self.doId2cdc[doId]
@ -136,5 +136,8 @@ class ClientRepository(DirectObject.DirectObject):
assert(self.doId2cdc.has_key(doId))
cdc = self.doId2cdc[doId]
# Let the cdc finish the job
cdc.sendUpdate(do, fieldName, args)
cdc.sendUpdate(self, do, fieldName, args)
def send(self, datagram):
self.cw.send(datagram, self.tcpConn)
return None

View File

@ -6,11 +6,12 @@ import Actor
class DistributedActor(DistributedNode.DistributedNode, Actor.Actor):
"""Distributed Actor class:"""
def __init__(self):
def __init__(self, cr):
try:
self.DistributedActor_initialized
except:
self.DistributedActor_initialized = 1
DistributedNode.DistributedNode.__init__(self, cr)
return None

View File

@ -6,11 +6,12 @@ import DistributedObject
class DistributedNode(DistributedObject.DistributedObject, NodePath.NodePath):
"""Distributed Node class:"""
def __init__(self):
def __init__(self, cr):
try:
self.DistributedNode_initialized
except:
self.DistributedNode_initialized = 1
DistributedObject.DistributedObject.__init__(self, cr)
return None
def generateInit(self, di):
@ -22,10 +23,10 @@ class DistributedNode(DistributedObject.DistributedObject, NodePath.NodePath):
def d_setHpr(self, h, p, r):
self.sendUpdate("setHpr", [h, p, r])
def d_setPosHpr(self):
def d_broadcastPosHpr(self):
self.d_setPos_Hpr(self.getX(), self.getY(), self.getZ(),
self.getH(), self.getP(), self.getR())
self.d_setPosHpr(self.getX(), self.getY(), self.getZ(),
self.getH(), self.getP(), self.getR())
def d_setPosHpr(self, x, y, z, h, p, r):
self.sendUpdate("setPosHpr", [x, y, z, h, p, r])

View File

@ -1,14 +1,16 @@
"""DistributedObject module: contains the DistributedObject class"""
from PandaObject import *
from ToonBaseGlobal import *
class DistributedObject(PandaObject):
"""Distributed Object class:"""
def __init__(self):
def __init__(self, cr):
try:
self.DistributedObject_initialized
except:
self.DistributedObject_initialized = 1
self.cr = cr
return None
def getDoId(self):
@ -22,7 +24,7 @@ class DistributedObject(PandaObject):
i.updateField(cdc, self, di)
def sendUpdate(self, fieldName, args):
cr.sendupdate(self, fieldName, args)
self.cr.sendUpdate(self, fieldName, args)
def taskName(self, taskString):
return (taskString + "-" + str(self.getDoId))