Skip to content

Commit c7be665

Browse files
committed
[reassembler] time: try to mark slots
1 parent 019fb46 commit c7be665

File tree

1 file changed

+54
-6
lines changed

1 file changed

+54
-6
lines changed

iridiumtk/reassembler/time.py

Lines changed: 54 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,51 @@
44
import sys
55
import re
66
from util import dt
7+
import numpy as np
78

89
from .base import *
910
from ..config import config, outfile
1011

12+
early_frame = 3
13+
14+
conv_start = None
15+
16+
17+
def lbfc_str(ts, start=0):
18+
"""Convert milliseconds into L-Band frame counter"""
19+
global conv_start
20+
21+
if start != 0:
22+
conv_start = start
23+
24+
if conv_start is None:
25+
return " "
26+
27+
ts = ts - conv_start
28+
lbfc_c = int((ts)//90)
29+
lbfc_o = ts-lbfc_c*90
30+
31+
# guard + simplex + guard + 4* uplink + 4* downlink
32+
# 1 + 20.32 + 1.24 + 4 * (8.28 + 0.22) + 0.02 + 4 * (8.28 + 0.1) - 0.1
33+
34+
# moved the first guard from the begining to the end
35+
slots = (20.32+1.24,
36+
8.28+0.22, 8.28+0.22, 8.28+0.22, 8.28+0.22+0.02,
37+
8.28+0.1, 8.28+0.1, 8.28+0.1, 8.28+1 + early_frame, )
38+
39+
sname = ("S", "U1", "U2", "U3", "U4", "D1", "D2", "D3", "D4", )
40+
41+
st = 0
42+
for i, t in enumerate(slots):
43+
if lbfc_o < st + t - early_frame: # allow slots to start slightly early
44+
if len(sname[i]) == 1:
45+
slot = f"{sname[i]}{round(lbfc_o - st):+03d}"
46+
else:
47+
slot = f"{sname[i]}{round(lbfc_o - st):+2d}"
48+
break
49+
st += t
50+
return f"{lbfc_c:03d}{lbfc_o:+03.0f}#{slot}"
51+
1152

1253
class ReassembleTIME(Reassemble):
1354
toff = None
@@ -17,17 +58,24 @@ def __init__(self):
1758

1859
def filter(self, line):
1960
q = super().filter(line)
20-
if q is None: return None
61+
if q is None:
62+
print("-", line, end="")
63+
return None
2164
return q
2265

2366
def process(self, q):
2467
q.enrich(channelize=True)
25-
if self.toff is None:
68+
if self.toff is None and q.typ in ("IRA:", "ITL:", "INP:", "IMS:", "MSG:"):
2669
self.toff = q.mstime
27-
strtime = dt.epoch(q.time).isoformat(timespec='centiseconds')
28-
lbfc_c = (q.mstime-self.toff+45)//90
29-
lbfc_o = q.mstime-self.toff-lbfc_c*90
30-
return [f"{strtime} {lbfc_c%48:02.0f}#{lbfc_o:+07.3f} {q.typ} {q.freq_print} {q.confidence:3d}% {q.level:6.2f} {q.symbols} {q.uldl} {q.data}"]
70+
q.uxtime = np.datetime64(int(q.starttime), 's')
71+
q.uxtime += np.timedelta64(q.nstime, 'ns')
72+
strtime = str(q.uxtime)[:-2]
73+
if False:
74+
lbfc_c = (q.mstime-self.toff+45)//90
75+
lbfc_o = q.mstime-self.toff-lbfc_c*90
76+
return [f"{strtime} {lbfc_c%48:02.0f}#{lbfc_o:+07.3f} {q.typ} {q.freq_print} {q.confidence:3d}% {q.level:6.2f} {q.symbols} {q.uldl} {q.data}"]
77+
lbs = lbfc_str(q.mstime, self.toff)
78+
return [f"{strtime} {lbs} {q.typ} {q.freq_print} {q.confidence:3d}% {q.level:6.2f} {q.symbols} {q.uldl} {q.data}"]
3179

3280
def consume(self, q):
3381
print(q, end="", file=outfile)

0 commit comments

Comments
 (0)