1 """autogenerated by genpy from network_monitor_udp/LinktestResult.msg. Do not edit."""
2 import sys
3 python3 = True if sys.hexversion > 0x03000000 else False
4 import genpy
5 import struct
6
7
9 _md5sum = "cde18aa0ddbb2c88ca3e62eb27f8aa3f"
10 _type = "network_monitor_udp/LinktestResult"
11 _has_header = False
12 _full_text = """# ====== DO NOT MODIFY! AUTOGENERATED FROM AN ACTION DEFINITION ======
13 # Result definition
14 float32 latency
15 float32 loss
16 float32 bandwidth
17 float32[] latency_histogram
18
19 """
20 __slots__ = ['latency','loss','bandwidth','latency_histogram']
21 _slot_types = ['float32','float32','float32','float32[]']
22
24 """
25 Constructor. Any message fields that are implicitly/explicitly
26 set to None will be assigned a default value. The recommend
27 use is keyword arguments as this is more robust to future message
28 changes. You cannot mix in-order arguments and keyword arguments.
29
30 The available fields are:
31 latency,loss,bandwidth,latency_histogram
32
33 :param args: complete set of field values, in .msg order
34 :param kwds: use keyword arguments corresponding to message field names
35 to set specific fields.
36 """
37 if args or kwds:
38 super(LinktestResult, self).__init__(*args, **kwds)
39
40 if self.latency is None:
41 self.latency = 0.
42 if self.loss is None:
43 self.loss = 0.
44 if self.bandwidth is None:
45 self.bandwidth = 0.
46 if self.latency_histogram is None:
47 self.latency_histogram = []
48 else:
49 self.latency = 0.
50 self.loss = 0.
51 self.bandwidth = 0.
52 self.latency_histogram = []
53
55 """
56 internal API method
57 """
58 return self._slot_types
59
61 """
62 serialize message into buffer
63 :param buff: buffer, ``StringIO``
64 """
65 try:
66 _x = self
67 buff.write(_struct_3f.pack(_x.latency, _x.loss, _x.bandwidth))
68 length = len(self.latency_histogram)
69 buff.write(_struct_I.pack(length))
70 pattern = '<%sf'%length
71 buff.write(struct.pack(pattern, *self.latency_histogram))
72 except struct.error as se: self._check_types(se)
73 except TypeError as te: self._check_types(te)
74
76 """
77 unpack serialized message in str into this message instance
78 :param str: byte array of serialized message, ``str``
79 """
80 try:
81 end = 0
82 _x = self
83 start = end
84 end += 12
85 (_x.latency, _x.loss, _x.bandwidth,) = _struct_3f.unpack(str[start:end])
86 start = end
87 end += 4
88 (length,) = _struct_I.unpack(str[start:end])
89 pattern = '<%sf'%length
90 start = end
91 end += struct.calcsize(pattern)
92 self.latency_histogram = struct.unpack(pattern, str[start:end])
93 return self
94 except struct.error as e:
95 raise genpy.DeserializationError(e)
96
97
99 """
100 serialize message with numpy array types into buffer
101 :param buff: buffer, ``StringIO``
102 :param numpy: numpy python module
103 """
104 try:
105 _x = self
106 buff.write(_struct_3f.pack(_x.latency, _x.loss, _x.bandwidth))
107 length = len(self.latency_histogram)
108 buff.write(_struct_I.pack(length))
109 pattern = '<%sf'%length
110 buff.write(self.latency_histogram.tostring())
111 except struct.error as se: self._check_types(se)
112 except TypeError as te: self._check_types(te)
113
115 """
116 unpack serialized message in str into this message instance using numpy for array types
117 :param str: byte array of serialized message, ``str``
118 :param numpy: numpy python module
119 """
120 try:
121 end = 0
122 _x = self
123 start = end
124 end += 12
125 (_x.latency, _x.loss, _x.bandwidth,) = _struct_3f.unpack(str[start:end])
126 start = end
127 end += 4
128 (length,) = _struct_I.unpack(str[start:end])
129 pattern = '<%sf'%length
130 start = end
131 end += struct.calcsize(pattern)
132 self.latency_histogram = numpy.frombuffer(str[start:end], dtype=numpy.float32, count=length)
133 return self
134 except struct.error as e:
135 raise genpy.DeserializationError(e)
136
137 _struct_I = genpy.struct_I
138 _struct_3f = struct.Struct("<3f")
139