Skip to content

Commit

Permalink
now writes files the app is happy with
Browse files Browse the repository at this point in the history
  • Loading branch information
ckuethe committed Jun 16, 2024
1 parent 59243e0 commit 1e02f68
Showing 1 changed file with 6 additions and 12 deletions.
18 changes: 6 additions & 12 deletions src/rcfiles.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,15 @@

from binascii import hexlify, unhexlify
from datetime import datetime, timedelta
from json import dumps as jdumps
from re import sub as re_sub
from struct import pack as struct_pack
from struct import unpack as struct_unpack
from typing import Any, Dict, List, Optional

import xmltodict

from rctypes import (
EnergyCalibration,
SpecData,
SpectrogramPoint,
SpectrumLayer,
TrackPoint,
)
from rcutils import DateTime2FileTime, FileTime2DateTime, UnixTime2FileTime
from rctypes import EnergyCalibration, SpectrogramPoint, SpectrumLayer, TrackPoint
from rcutils import DateTime2FileTime, FileTime2DateTime

_datestr: str = "%Y-%m-%d %H:%M:%S"

Expand Down Expand Up @@ -85,7 +78,8 @@ def _format_trackpoint(self, tp: TrackPoint):
def write_file(self, filename: str) -> None:
with open(filename, "wt") as ofd:
print("Track: " + "\t".join([self.name, self.serialnumber, self.comment, self.flags]), file=ofd)
print("\t".join(self._columns), file=ofd)
# Patch column names in output file.
print("\t".join(["Timestamp", "Time"] + self._columns[1:]), file=ofd)
for p in self.points:
print(self._format_trackpoint(p), file=ofd)

Expand All @@ -108,11 +102,11 @@ def load_file(self, filename: str) -> None:
fields = line.split("\t")
if len(fields) != nf + 1:
raise ValueError(f"Incorrect number of values on line {n+1}")
fields[1] = FileTime2DateTime(fields[0]) # filetime is higher resolution than datetime
fields[1] = FileTime2DateTime(fields[0]) # filetime is higher resolution than YYYY-mm-dd HH:MM:SS
for i in range(2, 7):
fields[i] = float(fields[i])
pass
fields[-1] = fields[-1].strip()
fields[-1] = fields[-1].rstrip("\n")
self.points.append(TrackPoint(*fields[1:]))

def add_point(
Expand Down

0 comments on commit 1e02f68

Please sign in to comment.