| [1e781ba] | 1 | import struct
|
|---|
| 2 | import numpy as np
|
|---|
| 3 |
|
|---|
| 4 |
|
|---|
| 5 | class AmmosIFDataHeader():
|
|---|
| 6 |
|
|---|
| 7 | @classmethod
|
|---|
| 8 | def from_bytes(cls, bytes):
|
|---|
| 9 | elements = struct.unpack('<IIQIIIQIIIIi', bytes)
|
|---|
| 10 | block_count = elements[0]
|
|---|
| 11 | block_length = int(elements[1])*4
|
|---|
| 12 | timestamp = np.datetime64(int(elements[2])*1000, 'ns')
|
|---|
| 13 | status = elements[3]
|
|---|
| 14 | source_id = elements[4]
|
|---|
| 15 | source_state = elements[5]
|
|---|
| 16 | frequency = elements[6]
|
|---|
| 17 | bandwidth = elements[7]
|
|---|
| 18 | sample_rate = elements[8]
|
|---|
| 19 | interpolation = elements[9]
|
|---|
| 20 | decimation = elements[10]
|
|---|
| 21 | voltage_ref = elements[11]
|
|---|
| 22 |
|
|---|
| 23 | return AmmosIFDataHeader(block_count, block_length, timestamp, status, source_id,
|
|---|
| 24 | source_state, frequency, bandwidth, sample_rate,
|
|---|
| 25 | interpolation, decimation, voltage_ref)
|
|---|
| 26 |
|
|---|
| 27 | def __init__(self, block_count, block_length, timestamp, status, source_id, source_state, frequency,
|
|---|
| 28 | bandwidth, sample_rate, interpolation, decimation, voltage_ref):
|
|---|
| 29 | self.block_count = block_count
|
|---|
| 30 | self.block_length = block_length
|
|---|
| 31 | self.timestamp = timestamp
|
|---|
| 32 | self.status = status
|
|---|
| 33 | self.source_id = source_id
|
|---|
| 34 | self.source_state = source_state
|
|---|
| 35 | self.frequency = frequency
|
|---|
| 36 | self.bandwidth = bandwidth
|
|---|
| 37 | self.sample_rate = sample_rate
|
|---|
| 38 | self.interpolation = interpolation
|
|---|
| 39 | self.decimation = decimation
|
|---|
| 40 | self.voltage_ref = voltage_ref
|
|---|
| 41 |
|
|---|
| 42 | def header_size(self):
|
|---|
| 43 | return 56
|
|---|
| 44 |
|
|---|
| 45 | def __str_(self):
|
|---|
| 46 | output = ("\nGlobal frame body data header\n" +
|
|---|
| 47 | "-----------------------------\n" +
|
|---|
| 48 | "Block count:" + str(self.block_count) + "\n" +
|
|---|
| 49 | "Block length:" + str(self.block_length) + "\n" +
|
|---|
| 50 | "Time stamp:" + str(self.timestamp) + "\n" +
|
|---|
| 51 | "Frequency:" + str(self.frequency) + "\n" +
|
|---|
| 52 | "Bandwidth:" + str(self.bandwidth) + "\n" +
|
|---|
| 53 | "Sample rate:" + str(self.sample_rate) + "\n")
|
|---|
| 54 | return output
|
|---|