generate packing for python messages (#1535)

Generate packet serialization in Python, too.
This commit is contained in:
Lucien Morey
2024-11-10 05:08:45 +11:00
committed by GitHub
parent 1d8d934a8a
commit 14fcc5d485
11 changed files with 263 additions and 7 deletions

View File

@@ -21,14 +21,32 @@
###############################################################################
from ..targeting import *
from ..packet import Packet
class PnpResultSerde:
# Message definition md5sum. See photon_packet.adoc for details
MESSAGE_VERSION = "ae4d655c0a3104d88df4f5db144c1e86"
MESSAGE_FORMAT = "Transform3d best;Transform3d alt;float64 bestReprojErr;float64 altReprojErr;float64 ambiguity;"
@staticmethod
def pack(value: "PnpResult") -> "Packet":
ret = Packet()
ret.encodeTransform(value.best)
ret.encodeTransform(value.alt)
# bestReprojErr is of intrinsic type float64
ret.encodeDouble(value.bestReprojErr)
# altReprojErr is of intrinsic type float64
ret.encodeDouble(value.altReprojErr)
# ambiguity is of intrinsic type float64
ret.encodeDouble(value.ambiguity)
return ret
@staticmethod
def unpack(packet: "Packet") -> "PnpResult":
ret = PnpResult()