Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto eol=lf
174 changes: 87 additions & 87 deletions gs/backend/sun/ephemeris_parser.py
Original file line number Diff line number Diff line change
@@ -1,87 +1,87 @@
# Parser for tests and will be used as the basis for the parser on the OBC
# Test harness for test_ephemeris.py
from __future__ import annotations
import dataclasses
import struct
# Standard library imports
from typing import BinaryIO
# Local application imports
from . import ephemeris
from .ephemeris import DataPoint
@dataclasses.dataclass
class Header:
"""
Data class to store the header information
"""
start_time: float
step_size: float
num_data_points: int
def parse_header(file: str) -> Header:
"""
Tests the header file to ensure that the data was read correctly
:param file: The file to read from
"""
with open(file, "rb") as f:
f.seek(0)
# Read 2 double values
start_time = get_single_data_point(f, False)
step_size = get_single_data_point(f, False)
# Read 1 uint value
num_data_points = int(struct.unpack(ephemeris.DATA_UINT, f.read(ephemeris.SIZE_OF_INT))[0])
return Header(start_time, step_size, num_data_points)
def get_single_data_point(file: BinaryIO, is_float: bool = True) -> float:
"""
Tests the output file to ensure that the data was written correctly
:param is_float: If true, then will parse as float, otherwise will parse as double
:param file: The file to read from
"""
if is_float:
read_type = ephemeris.DATA_FLOAT
read_size = ephemeris.SIZE_OF_FLOAT
else:
read_type = ephemeris.DATA_DOUBLE
read_size = ephemeris.SIZE_OF_DOUBLE
# Read and parse 1 float/double value
byte_str = file.read(read_size)
float_val = struct.unpack(read_type, byte_str)[0]
return float(float_val)
def parse_file(file: str) -> list[DataPoint]:
"""
Tests the output file to ensure that the data was written correctly
:param file: The file to read from
"""
output = []
header = parse_header(file)
with open(file, "rb") as f:
f.seek(ephemeris.SIZE_OF_HEADER)
# Read and calculate the data points
for i in range(header.num_data_points):
jd = header.start_time + (i * header.step_size)
data_point = DataPoint(
jd,
get_single_data_point(f),
get_single_data_point(f),
get_single_data_point(f),
)
output.append(data_point)
return output
# Parser for tests and will be used as the basis for the parser on the OBC
# Test harness for test_ephemeris.py
from __future__ import annotations

import dataclasses
import struct

# Standard library imports
from typing import BinaryIO

# Local application imports
from . import ephemeris
from .ephemeris import DataPoint


@dataclasses.dataclass
class Header:
"""
Data class to store the header information
"""

start_time: float
step_size: float
num_data_points: int


def parse_header(file: str) -> Header:
"""
Tests the header file to ensure that the data was read correctly

:param file: The file to read from
"""
with open(file, "rb") as f:
f.seek(0)
# Read 2 double values
start_time = get_single_data_point(f, False)
step_size = get_single_data_point(f, False)

# Read 1 uint value
num_data_points = int(struct.unpack(ephemeris.DATA_UINT, f.read(ephemeris.SIZE_OF_INT))[0])
return Header(start_time, step_size, num_data_points)


def get_single_data_point(file: BinaryIO, is_float: bool = True) -> float:
"""
Tests the output file to ensure that the data was written correctly

:param is_float: If true, then will parse as float, otherwise will parse as double
:param file: The file to read from
"""
if is_float:
read_type = ephemeris.DATA_FLOAT
read_size = ephemeris.SIZE_OF_FLOAT
else:
read_type = ephemeris.DATA_DOUBLE
read_size = ephemeris.SIZE_OF_DOUBLE

# Read and parse 1 float/double value
byte_str = file.read(read_size)
float_val = struct.unpack(read_type, byte_str)[0]
return float(float_val)


def parse_file(file: str) -> list[DataPoint]:
"""
Tests the output file to ensure that the data was written correctly

:param file: The file to read from
"""
output = []
header = parse_header(file)

with open(file, "rb") as f:
f.seek(ephemeris.SIZE_OF_HEADER)

# Read and calculate the data points
for i in range(header.num_data_points):
jd = header.start_time + (i * header.step_size)
data_point = DataPoint(
jd,
get_single_data_point(f),
get_single_data_point(f),
get_single_data_point(f),
)
output.append(data_point)

return output
Empty file removed libs/cserialport/bindings/tmp.ts
Empty file.
2 changes: 1 addition & 1 deletion libs/cserialport/include/CSerialPort/SerialPort.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* @file SerialPort.h
* @author itas109 (itas109@qq.com) \n\n
* Blog : https://blog.csdn.net/itas109 \n
Expand Down
2 changes: 1 addition & 1 deletion libs/cserialport/include/CSerialPort/SerialPortBase.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* @file SerialPortBase.h
* @author itas109 (itas109@qq.com) \n\n
* Blog : https://blog.csdn.net/itas109 \n
Expand Down
2 changes: 1 addition & 1 deletion libs/cserialport/include/CSerialPort/SerialPortInfo.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* @file SerialPortInfo.h
* @author itas109 (itas109@qq.com) \n\n
* Blog : https://blog.csdn.net/itas109 \n
Expand Down
2 changes: 1 addition & 1 deletion libs/cserialport/include/CSerialPort/SerialPortInfoBase.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* @file SerialPortInfoBase.h
* @author itas109 (itas109@qq.com) \n\n
* Blog : https://blog.csdn.net/itas109 \n
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* @file SerialPortInfoUnixBase.h
* @author itas109 (itas109@qq.com) \n\n
* Blog : https://blog.csdn.net/itas109 \n
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* @file SerialPortInfoWinBase.h
* @author itas109 (itas109@qq.com) \n\n
* Blog : https://blog.csdn.net/itas109 \n
Expand Down
2 changes: 1 addition & 1 deletion libs/cserialport/include/CSerialPort/SerialPortListener.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* @file SerialPortListener.h
* @author itas109 (itas109@qq.com) \n\n
* Blog : https://blog.csdn.net/itas109 \n
Expand Down
2 changes: 1 addition & 1 deletion libs/cserialport/include/CSerialPort/SerialPortUnixBase.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* @file SerialPortUnixBase.h
* @author itas109 (itas109@qq.com) \n\n
* Blog : https://blog.csdn.net/itas109 \n
Expand Down
2 changes: 1 addition & 1 deletion libs/cserialport/include/CSerialPort/SerialPortWinBase.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* @file SerialPortWinBase.h
* @author itas109 (itas109@qq.com) \n\n
* Blog : https://blog.csdn.net/itas109 \n
Expand Down
2 changes: 1 addition & 1 deletion libs/cserialport/include/CSerialPort/SerialPort_global.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* @file SerialPort_global.h
* @author itas109 (itas109@qq.com) \n\n
* Blog : https://blog.csdn.net/itas109 \n
Expand Down
2 changes: 1 addition & 1 deletion libs/cserialport/include/CSerialPort/SerialPort_version.h
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* \file SerialPort_global.h
* \author itas109 \n\n
* Blog : https://blog.csdn.net/itas109 \n
Expand Down
2 changes: 1 addition & 1 deletion libs/cserialport/include/CSerialPort/ibuffer.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* @file ibuffer.hpp
* @author itas109 (itas109@qq.com) \n\n
* Blog : https://blog.csdn.net/itas109 \n
Expand Down
2 changes: 1 addition & 1 deletion libs/cserialport/include/CSerialPort/ithread.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* @file ithread.hpp
* @author itas109 (itas109@qq.com) \n\n
* Blog : https://blog.csdn.net/itas109 \n
Expand Down
2 changes: 1 addition & 1 deletion libs/cserialport/include/CSerialPort/itimer.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* @file itimer.hpp
* @author itas109 (itas109@qq.com) \n\n
* Blog : https://blog.csdn.net/itas109 \n
Expand Down
2 changes: 1 addition & 1 deletion libs/cserialport/include/CSerialPort/iutils.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/**
/**
* @file iutils.hpp
* @author itas109 (itas109@qq.com) \n\n
* Blog : https://blog.csdn.net/itas109 \n
Expand Down
2 changes: 1 addition & 1 deletion libs/cserialport/source/SerialPort.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <iostream>
#include <iostream>

#include "CSerialPort/SerialPort.h"
#include "CSerialPort/SerialPort_version.h"
Expand Down
2 changes: 1 addition & 1 deletion libs/cserialport/source/SerialPortBase.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "CSerialPort/SerialPortBase.h"
#include "CSerialPort/SerialPortBase.h"
#include "CSerialPort/ithread.hpp"
#include "CSerialPort/itimer.hpp"

Expand Down
2 changes: 1 addition & 1 deletion libs/cserialport/source/SerialPortInfo.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "CSerialPort/SerialPortInfo.h"
#include "CSerialPort/SerialPortInfo.h"
#include "CSerialPort/SerialPort_global.h"

#ifdef I_OS_WIN
Expand Down
2 changes: 1 addition & 1 deletion libs/cserialport/source/SerialPortInfoBase.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "CSerialPort/SerialPortInfoBase.h"
#include "CSerialPort/SerialPortInfoBase.h"

CSerialPortInfoBase::CSerialPortInfoBase() {}

Expand Down
2 changes: 1 addition & 1 deletion libs/cserialport/source/SerialPortInfoUnixBase.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "CSerialPort/SerialPortInfoUnixBase.h"
#include "CSerialPort/SerialPortInfoUnixBase.h"
#include "CSerialPort/SerialPort_global.h"
#include "CSerialPort/iutils.hpp"

Expand Down
2 changes: 1 addition & 1 deletion libs/cserialport/source/SerialPortInfoWinBase.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <Windows.h>
#include <Windows.h>
#include <initguid.h> // GUID
#include <Setupapi.h> // SetupDiGetClassDevs Setup*
#include <tchar.h> // _T
Expand Down
2 changes: 1 addition & 1 deletion libs/cserialport/source/SerialPortUnixBase.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include <unistd.h> // usleep
#include <unistd.h> // usleep

#include "CSerialPort/SerialPortUnixBase.h"
#include "CSerialPort/SerialPortListener.h"
Expand Down
2 changes: 1 addition & 1 deletion libs/cserialport/source/SerialPortWinBase.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#include "CSerialPort/SerialPortWinBase.h"
#include "CSerialPort/SerialPortWinBase.h"
#include "CSerialPort/SerialPortListener.h"
#include "CSerialPort/iutils.hpp"
#include "CSerialPort/ithread.hpp"
Expand Down
Loading
Loading