示例#1
0
 def serialize(self):
     stream = samples_pb2.sample_stream()
     stream.timestamp = self.timestamp
     stream.session_id = self.session_id.bytes
     stream.machine_id = str(bytearray(self.machine_id))
     stream.channel = self.channel
     stream.samples.extend(self.samples)
     
     return stream.SerializeToString()
示例#2
0
 def deserialize(serialized):
     stream = samples_pb2.sample_stream()
     stream.ParseFromString(serialized)
     # text_format.Merge(serialized, stream)
     
     b = Block()
     b.timestamp = stream.timestamp
     b.channel = stream.channel
     b.samples = stream.samples
     
     return b