style: remove TC4VAF2DataDecoder code
This commit is contained in:
@@ -70,9 +70,6 @@ class DataDecodeFormat(Generic[T], metaclass=abc.ABCMeta):
|
||||
if expr == RawDataDecoder.NAME:
|
||||
return RawDataDecoder.INSTANCE
|
||||
|
||||
elif expr == TC4VAF2DataDecoder.NAME:
|
||||
return TC4VAF2DataDecoder()
|
||||
|
||||
elif expr == TDC4VAF2DataDecoder.NAME:
|
||||
return TDC4VAF2DataDecoder()
|
||||
|
||||
@@ -316,90 +313,6 @@ class RecDataDecoder(DataDecodeFormat[RecordingData], metaclass=abc.ABCMeta):
|
||||
def decode(self, data: bytes) -> Optional[RecordingData]:
|
||||
pass
|
||||
|
||||
|
||||
class TC4VAF2DataDecoder(RecDataDecoder):
|
||||
"""
|
||||
::
|
||||
|
||||
| | 1 | 2 | 3 |
|
||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2
|
||||
-----------------------------------------------------------------
|
||||
| header | length |
|
||||
| timestamp |
|
||||
| data [0] | data[1] |
|
||||
| ............................ | data[N] |
|
||||
|
||||
*data*
|
||||
|
||||
::
|
||||
|
||||
| | 1 |
|
||||
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6
|
||||
---------------------------------
|
||||
|channel| value | F |
|
||||
|
||||
"""
|
||||
|
||||
NAME = 'TC4VAF2'
|
||||
|
||||
__slots__ = ('_prev_data',)
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self._prev_data: Optional[bytes] = None
|
||||
|
||||
@property
|
||||
def name(self) -> str:
|
||||
return self.NAME
|
||||
|
||||
def decode(self, data: bytes) -> Optional[RecordingData]:
|
||||
if len(data) < 6:
|
||||
return None
|
||||
|
||||
# hex_line(data)
|
||||
|
||||
data_length = int(data[1])
|
||||
|
||||
if data_length == 0:
|
||||
return None
|
||||
|
||||
time_stamp: float = struct.unpack('<I', data[2:6])[0] # unit: 1/32ms
|
||||
|
||||
time_stamp, delta, ret_get_time_stamp = self.get_time_stamp(time_stamp)
|
||||
|
||||
if time_stamp is None:
|
||||
return None
|
||||
|
||||
if time_stamp == 0:
|
||||
self._prev_data = data
|
||||
return None
|
||||
|
||||
prev_data = self._prev_data
|
||||
self._prev_data = data
|
||||
assert prev_data is not None
|
||||
|
||||
time_stamp /= 32 # unit: ms
|
||||
data_length = int(prev_data[1])
|
||||
sample_rate = 1000 * ((data_length - 4) / 2) / delta
|
||||
|
||||
ret = RecordingData(self.device, int(time_stamp), int(sample_rate))
|
||||
|
||||
for i in range(6, data_length + 2, 2):
|
||||
d1 = data[i]
|
||||
d2 = data[i + 1]
|
||||
|
||||
channel = (d1 & 0xF0) >> 4
|
||||
value = ((d1 & 0x0F) << 6) | ((d2 & 0xFC) >> 2)
|
||||
flag = d2 & 0b0011
|
||||
|
||||
if flag == 0:
|
||||
ret.append_data(channel, value - 512)
|
||||
else:
|
||||
ret.append_data(channel, None)
|
||||
|
||||
return ret
|
||||
|
||||
|
||||
class TDC4VAF2DataDecoder(RecDataDecoder):
|
||||
"""
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ cli options
|
||||
sin : sine save (default)
|
||||
ramp : ramp
|
||||
(Elite, Neulive serial)
|
||||
TC4VAF2 Elite_Legacy
|
||||
Elite_Legacy
|
||||
TDC4VAF2 Elite Neulive
|
||||
(NeuliveSTI serial)
|
||||
NeuliveSTI NeuliveSTI1.0
|
||||
@@ -317,7 +317,6 @@ class RampGenerator(Generator):
|
||||
|
||||
class DeviceGenerator(Generator):
|
||||
SUPPORT = {
|
||||
'TC4VAF2': ('Elite_Legacy', '0.0.0'),
|
||||
'Elite_Legacy': ('Elite_Legacy', '0.0.0'),
|
||||
'TDC4VAF2': ('Elite', '0.1.0'),
|
||||
'Elite': ('Elite', '0.1.0'),
|
||||
@@ -645,7 +644,7 @@ class GeneratorOptions(CliOptions):
|
||||
sin : sine save (default)
|
||||
ramp : ramp
|
||||
(Elite, Neulive serial)
|
||||
TC4VAF2 Elite_Legacy
|
||||
Elite_Legacy
|
||||
TDC4VAF2 Elite Neulive
|
||||
(NeuliveSTI serial)
|
||||
NeuliveSTI NeuliveSTI1.0
|
||||
|
||||
Reference in New Issue
Block a user