|
1 | 1 | """Classes to convert between measurement specific protobuf types and containers.""" |
2 | 2 |
|
3 | 3 | import collections.abc |
4 | | -import datetime as dt |
5 | 4 | from typing import Type, Union |
6 | 5 |
|
7 | 6 | import hightime as ht |
|
22 | 21 | ExtendedPropertyDictionary, |
23 | 22 | ExtendedPropertyValue, |
24 | 23 | NoneScaleMode, |
25 | | - SampleIntervalMode, |
26 | 24 | Timing, |
27 | 25 | ) |
28 | 26 | from typing_extensions import TypeAlias |
@@ -107,21 +105,19 @@ def to_python_value(self, protobuf_message: DoubleAnalogWaveform) -> AnalogWavef |
107 | 105 | # Timestamp |
108 | 106 | pt_converter = PrecisionTimestampConverter() |
109 | 107 | bin_datetime = pt_converter.to_python_value(protobuf_message.t0) |
110 | | - timestamp = convert_datetime(dt.datetime, bin_datetime) |
| 108 | + # TODO: We shouldn't need to convert to dt.datetime here. |
| 109 | + # I'm only doing this to avoid a mypy error. This needs to be fixed. |
| 110 | + timestamp = bin_datetime._to_datetime_datetime() |
111 | 111 |
|
112 | 112 | # Sample Interval |
113 | 113 | if not protobuf_message.dt: |
114 | | - sample_interval_mode = SampleIntervalMode.NONE |
115 | | - sample_interval = None |
| 114 | + timing = Timing.create_with_no_interval(timestamp=timestamp) |
116 | 115 | else: |
117 | | - sample_interval_mode = SampleIntervalMode.REGULAR |
118 | 116 | sample_interval = ht.timedelta(seconds=protobuf_message.dt) |
119 | | - |
120 | | - timing = Timing( |
121 | | - sample_interval_mode=sample_interval_mode, |
122 | | - timestamp=timestamp, |
123 | | - sample_interval=sample_interval, |
124 | | - ) |
| 117 | + timing = Timing.create_with_regular_interval( |
| 118 | + sample_interval=sample_interval, |
| 119 | + timestamp=timestamp, |
| 120 | + ) |
125 | 121 |
|
126 | 122 | extended_properties = {} |
127 | 123 | for key, value in protobuf_message.attributes.items(): |
|
0 commit comments