mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-26 01:51:40 +00:00
generate packing for python messages (#1535)
Generate packet serialization in Python, too.
This commit is contained in:
@@ -21,14 +21,31 @@
|
||||
###############################################################################
|
||||
|
||||
from ..targeting import *
|
||||
from ..packet import Packet
|
||||
|
||||
|
||||
class PhotonPipelineMetadataSerde:
|
||||
|
||||
# Message definition md5sum. See photon_packet.adoc for details
|
||||
MESSAGE_VERSION = "ac0a45f686457856fb30af77699ea356"
|
||||
MESSAGE_FORMAT = "int64 sequenceID;int64 captureTimestampMicros;int64 publishTimestampMicros;int64 timeSinceLastPong;"
|
||||
|
||||
@staticmethod
|
||||
def pack(value: "PhotonPipelineMetadata") -> "Packet":
|
||||
ret = Packet()
|
||||
|
||||
# sequenceID is of intrinsic type int64
|
||||
ret.encodeLong(value.sequenceID)
|
||||
|
||||
# captureTimestampMicros is of intrinsic type int64
|
||||
ret.encodeLong(value.captureTimestampMicros)
|
||||
|
||||
# publishTimestampMicros is of intrinsic type int64
|
||||
ret.encodeLong(value.publishTimestampMicros)
|
||||
|
||||
# timeSinceLastPong is of intrinsic type int64
|
||||
ret.encodeLong(value.timeSinceLastPong)
|
||||
return ret
|
||||
|
||||
@staticmethod
|
||||
def unpack(packet: "Packet") -> "PhotonPipelineMetadata":
|
||||
ret = PhotonPipelineMetadata()
|
||||
|
||||
Reference in New Issue
Block a user