35 from .
import commeffectevent_pb2
41 self.
_event = commeffectevent_pb2.CommEffectEvent()
44 commeffect = self.
_event.commEffects.add()
46 commeffect.nemId = nemId
48 for (name,value)
in list(kwargs.items()):
51 if (isinstance(value,int)
or \
52 isinstance(value,float))
and \
54 commeffect.latencySeconds = value
56 raise ValueError(
"latency must be a positive numeric")
58 elif name ==
'jitter':
59 if (isinstance(value,int)
or \
60 isinstance(value,float))
and \
62 commeffect.jitterSeconds = value
64 raise ValueError(
"jitter must be a positive numeric")
67 if (isinstance(value,int)
or \
68 isinstance(value,float))
and \
70 commeffect.probabilityLoss = value
72 raise ValueError(
"loss must be numeric")
74 elif name ==
'duplicate':
75 if (isinstance(value,int)
or \
76 isinstance(value,float))
and \
78 commeffect.probabilityDuplicate = value
80 raise ValueError(
"duplicate must be a positive numeric")
82 elif name ==
'unicast':
83 if (isinstance(value,int)
or isinstance(value,int))
and \
85 commeffect.unicastBitRatebps = value
87 raise ValueError(
"unicast must be a positive integer")
89 elif name ==
'broadcast':
90 if (isinstance(value,int)
or isinstance(value,int))
and \
92 commeffect.broadcastBitRatebps = value
94 raise ValueError(
"broadcast must be a positive integer")
97 raise KeyError(
"unknown parameter: %s" % name)
101 return self.
_event.SerializeToString()
104 self.
_event.ParseFromString(data)
107 for commeffect
in self.
_event.commEffects:
108 kwargs = {
'latency': commeffect.latencySeconds,
109 'jitter' : commeffect.jitterSeconds,
110 'loss' : commeffect.probabilityLoss,
111 'duplicate' : commeffect.probabilityDuplicate,
112 'unicast' : commeffect.unicastBitRatebps,
113 'broadcast' : commeffect.broadcastBitRatebps}
115 yield (commeffect.nemId,kwargs)
def append(self, nemId, kwargs)