@@ 973-1000 (lines=28) @@ | ||
970 | self.ServerPicoseconds = None |
|
971 | self._freeze = True |
|
972 | ||
973 | def to_binary(self): |
|
974 | packet = [] |
|
975 | if self.Value: |
|
976 | self.Encoding |= (1 << 0) |
|
977 | if self.StatusCode: |
|
978 | self.Encoding |= (1 << 1) |
|
979 | if self.SourceTimestamp: |
|
980 | self.Encoding |= (1 << 2) |
|
981 | if self.ServerTimestamp: |
|
982 | self.Encoding |= (1 << 3) |
|
983 | if self.SourcePicoseconds: |
|
984 | self.Encoding |= (1 << 4) |
|
985 | if self.ServerPicoseconds: |
|
986 | self.Encoding |= (1 << 5) |
|
987 | packet.append(uabin.Primitives.UInt8.pack(self.Encoding)) |
|
988 | if self.Value: |
|
989 | packet.append(self.Value.to_binary()) |
|
990 | if self.StatusCode: |
|
991 | packet.append(self.StatusCode.to_binary()) |
|
992 | if self.SourceTimestamp: |
|
993 | packet.append(uabin.Primitives.DateTime.pack(self.SourceTimestamp)) # self.SourceTimestamp.to_binary()) |
|
994 | if self.ServerTimestamp: |
|
995 | packet.append(uabin.Primitives.DateTime.pack(self.ServerTimestamp)) # self.ServerTimestamp.to_binary()) |
|
996 | if self.SourcePicoseconds: |
|
997 | packet.append(uabin.Primitives.UInt16.pack(self.SourcePicoseconds)) |
|
998 | if self.ServerPicoseconds: |
|
999 | packet.append(uabin.Primitives.UInt16.pack(self.ServerPicoseconds)) |
|
1000 | return b''.join(packet) |
|
1001 | ||
1002 | @staticmethod |
|
1003 | def from_binary(data): |
@@ 1016-1037 (lines=22) @@ | ||
1013 | self.ServerPicoseconds = 0 |
|
1014 | self._freeze = True |
|
1015 | ||
1016 | def to_binary(self): |
|
1017 | packet = [] |
|
1018 | if self.Value: self.Encoding |= (1 << 0) |
|
1019 | if self.StatusCode: self.Encoding |= (1 << 1) |
|
1020 | if self.SourceTimestamp: self.Encoding |= (1 << 2) |
|
1021 | if self.SourcePicoseconds: self.Encoding |= (1 << 3) |
|
1022 | if self.ServerTimestamp: self.Encoding |= (1 << 4) |
|
1023 | if self.ServerPicoseconds: self.Encoding |= (1 << 5) |
|
1024 | packet.append(uabin.Primitives.UInt8.pack(self.Encoding)) |
|
1025 | if self.Value: |
|
1026 | packet.append(self.Value.to_binary()) |
|
1027 | if self.StatusCode: |
|
1028 | packet.append(self.StatusCode.to_binary()) |
|
1029 | if self.SourceTimestamp: |
|
1030 | packet.append(uabin.Primitives.DateTime.pack(self.SourceTimestamp)) |
|
1031 | if self.SourcePicoseconds: |
|
1032 | packet.append(uabin.Primitives.UInt16.pack(self.SourcePicoseconds)) |
|
1033 | if self.ServerTimestamp: |
|
1034 | packet.append(uabin.Primitives.DateTime.pack(self.ServerTimestamp)) |
|
1035 | if self.ServerPicoseconds: |
|
1036 | packet.append(uabin.Primitives.UInt16.pack(self.ServerPicoseconds)) |
|
1037 | return b''.join(packet) |
|
1038 | ||
1039 | @staticmethod |
|
1040 | def from_binary(data): |