Skip to content

Commit c30899f

Browse files
committed
Cassini RPWS_LOW_RATE_FULL_MFR0 loader almost done
Signed-off-by: Alexis Jeandet <[email protected]>
1 parent 8224825 commit c30899f

File tree

8 files changed

+210
-1
lines changed

8 files changed

+210
-1
lines changed

meson.build

+3
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ space_ouija_doc_extra_files = files(
5757
)
5858

5959
subdir('space_ouija')
60+
if get_option('with_tests')
61+
subdir('tests')
62+
endif
6063

6164
c_compiler = meson.get_compiler('c')
6265
cpp_compiler = meson.get_compiler('cpp')

space_ouija/meson.build

+9-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,15 @@ conf_data.set_quoted('SPACE_OUIJA_VERSION', meson.project_version())
1717
configure_file(output : 'space_ouija_config.h',
1818
configuration : conf_data)
1919

20-
space_ouija_headers = files()
20+
space_ouija_headers = files(
21+
'ouija_boards/cassini/rpws.hpp',
22+
'ouija_boards/cassini/RPWS_LOW_RATE_FULL_MFR0.hpp',
23+
)
24+
25+
space_ouija_dep = declare_dependency(
26+
include_directories : include_directories('.'),
27+
dependencies : [cpp_utils, fmt_dep]
28+
)
2129

2230
_space_ouija = python3.extension_module('_space_ouija', 'space_ouija.cpp',
2331
dependencies: [cpp_utils, fmt_dep, pybind11_dep, python3.dependency()],
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
/*------------------------------------------------------------------------------
2+
-- The MIT License (MIT)
3+
--
4+
-- Copyright © 2025, Laboratory of Plasma Physics- CNRS
5+
--
6+
-- Permission is hereby granted, free of charge, to any person obtaining a copy
7+
-- of this software and associated documentation files (the “Software”), to deal
8+
-- in the Software without restriction, including without limitation the rights
9+
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10+
-- of the Software, and to permit persons to whom the Software is furnished to do
11+
-- so, subject to the following conditions:
12+
--
13+
-- The above copyright notice and this permission notice shall be included in all
14+
-- copies or substantial portions of the Software.
15+
--
16+
-- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
17+
-- INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
18+
-- PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19+
-- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20+
-- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21+
-- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
-------------------------------------------------------------------------------*/
23+
/*-- Author : Alexis Jeandet
24+
25+
----------------------------------------------------------------------------*/
26+
#include "rpws.hpp"
27+
#include <cpp_utils/reflexion/reflection.hpp>
28+
#include <cpp_utils/serde/serde.hpp>
29+
30+
namespace ouija_boards::cassini::rpws
31+
{
32+
33+
struct TIME_TABLE
34+
{
35+
using endianness = cpp_utils::endianness::big_endian_t;
36+
RPWS_SCLK_SCET sclk_scet;
37+
uint32_t spare;
38+
cpp_utils::serde::static_array<float, 224> TIME_OFFSET;
39+
};
40+
// static_assert(cpp_utils::reflexion::composite_size<TIME_TABLE>() == 912);
41+
42+
struct FREQUENCY_TABLE
43+
{
44+
using endianness = cpp_utils::endianness::big_endian_t;
45+
RPWS_SCLK_SCET sclk_scet;
46+
uint32_t spare;
47+
cpp_utils::serde::static_array<float, 224> FREQUENCY;
48+
};
49+
// static_assert(cpp_utils::reflexion::composite_size<FREQUENCY_TABLE>() == 912);
50+
51+
struct LRFC_DATA_QUALITY
52+
{
53+
using endianness = cpp_utils::endianness::big_endian_t;
54+
uint32_t value;
55+
/*inline bool VALID_DATA_FLAG() { return value & 0x1; }
56+
inline bool HFR_SOUNDER_ACTIVE() { return value & 0x2; }
57+
inline bool LP_RAW_SWEEP_ACTIVE() { return value & 0x4; }
58+
inline bool GROUND_PRODUCED_DATA() { return value & 0x8; }
59+
inline uint8_t SENSOR_NUMBER() { return (value & 0xF000'0000) >> 4; }*/
60+
};
61+
62+
struct SPECTRAL_DENSITY_TABLE
63+
{
64+
using endianness = cpp_utils::endianness::big_endian_t;
65+
RPWS_SCLK_SCET sclk_scet;
66+
LRFC_DATA_QUALITY data_quality;
67+
cpp_utils::serde::static_array<float, 224> DENSITY;
68+
};
69+
// static_assert(cpp_utils::reflexion::composite_size<SPECTRAL_DENSITY_TABLE>() == 912);
70+
71+
struct RPWS_LOW_RATE_FULL_MFR0
72+
{
73+
using endianness = cpp_utils::endianness::big_endian_t;
74+
LRFULL_TABLE<sizeof(TIME_TABLE)> lrfull_table;
75+
TIME_TABLE time_table;
76+
FREQUENCY_TABLE frequency_table;
77+
cpp_utils::serde::dynamic_array<0, SPECTRAL_DENSITY_TABLE> spectral_density_table;
78+
inline std::size_t field_size(
79+
const cpp_utils::serde::dynamic_array<0, SPECTRAL_DENSITY_TABLE>&) const
80+
{
81+
return lrfull_table.RECORDS - 3;
82+
}
83+
};
84+
}
+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/*------------------------------------------------------------------------------
2+
-- The MIT License (MIT)
3+
--
4+
-- Copyright © 2025, Laboratory of Plasma Physics- CNRS
5+
--
6+
-- Permission is hereby granted, free of charge, to any person obtaining a copy
7+
-- of this software and associated documentation files (the “Software”), to deal
8+
-- in the Software without restriction, including without limitation the rights
9+
-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
10+
-- of the Software, and to permit persons to whom the Software is furnished to do
11+
-- so, subject to the following conditions:
12+
--
13+
-- The above copyright notice and this permission notice shall be included in all
14+
-- copies or substantial portions of the Software.
15+
--
16+
-- THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
17+
-- INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
18+
-- PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
19+
-- HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
20+
-- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21+
-- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22+
-------------------------------------------------------------------------------*/
23+
/*-- Author : Alexis Jeandet
24+
25+
----------------------------------------------------------------------------*/
26+
#include <cpp_utils/endianness/endianness.hpp>
27+
#include <cpp_utils/reflexion/reflection.hpp>
28+
#include <cpp_utils/serde/special_fields.hpp>
29+
#include <cstdint>
30+
31+
namespace ouija_boards::cassini::rpws
32+
{
33+
34+
template <std::size_t record_size>
35+
struct LRFULL_TABLE
36+
{
37+
using endianness = cpp_utils::endianness::big_endian_t;
38+
cpp_utils::serde::static_array<char,8> FILE_ID;
39+
uint32_t RECORD_LENGTH;
40+
uint32_t RECORDS;
41+
uint32_t RECEIVER_TYPE;
42+
uint32_t unused;
43+
cpp_utils::serde::static_array<char,24> MINI_PACKET_HEADER;
44+
cpp_utils::serde::static_array<char,16> SCET;
45+
cpp_utils::serde::static_array<char,16> SCLK;
46+
cpp_utils::serde::static_array<char,record_size - 80> extra_space;
47+
};
48+
49+
struct RPWS_SCLK
50+
{
51+
using endianness = cpp_utils::endianness::big_endian_t;
52+
uint32_t SCLK_SECOND;
53+
uint8_t SCLK_PARTITION;
54+
uint8_t SCLK_FINE;
55+
};
56+
57+
static_assert(cpp_utils::reflexion::composite_size<RPWS_SCLK>() == 6);
58+
59+
struct RPWS_SCET
60+
{
61+
using endianness = cpp_utils::endianness::big_endian_t;
62+
uint16_t SCET_DAY;
63+
uint32_t SCET_MILLISECOND;
64+
};
65+
static_assert(cpp_utils::reflexion::composite_size<RPWS_SCET>() == 6);
66+
67+
68+
struct RPWS_SCLK_SCET
69+
{
70+
using endianness = cpp_utils::endianness::big_endian_t;
71+
RPWS_SCLK sclk;
72+
RPWS_SCET scet;
73+
};
74+
static_assert(cpp_utils::reflexion::composite_size<RPWS_SCLK_SCET>() == 12);
75+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#define CATCH_CONFIG_MAIN // This tells Catch to provide a main() - only do this in one cpp file
2+
#include <array>
3+
#include <catch2/catch_test_macros.hpp>
4+
#include <cpp_utils.hpp>
5+
#include <string>
6+
#include <filesystem>
7+
8+
#include <ouija_boards/cassini/RPWS_LOW_RATE_FULL_MFR0.hpp>
9+
#include <cpp_utils/io/memory_mapped_file.hpp>
10+
11+
using namespace ouija_boards::cassini::rpws;
12+
TEST_CASE("RPWS_LOW_RATE_FULL_MFR0", "[simple structures]")
13+
{
14+
cpp_utils::io::memory_mapped_file file(std::filesystem::path(RESOURCES_DIR) / "T2002292_MFR0.DAT");
15+
auto s = cpp_utils::serde::deserialize<RPWS_LOW_RATE_FULL_MFR0>(file.view(0));
16+
REQUIRE(s.lrfull_table.RECORD_LENGTH == 912);
17+
REQUIRE(s.lrfull_table.RECORDS == 8);
18+
}
19+
20+

tests/meson.build

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
catch2_dep = dependency('catch2-with-main', version:'>3.0.0', required : true)
2+
3+
resources_dir = meson.current_source_dir() + '/resources'
4+
5+
tests = [
6+
{
7+
'name':'Cassini_RPWS_LOW_RATE_FULL_MFR0',
8+
'sources': ['Cassini/test_RPWS_LOW_RATE_FULL_MFR0.cpp'],
9+
'deps': [space_ouija_dep, catch2_dep]
10+
},
11+
]
12+
13+
foreach unit_test : tests
14+
test_exe = executable(unit_test['name'],unit_test['sources'],
15+
dependencies : unit_test['deps'],
16+
cpp_args : ['-DRESOURCES_DIR="@0@"'.format(resources_dir)]
17+
)
18+
test('Test-' + unit_test['name'], test_exe, args:['-o','@0@_out.xml'.format(unit_test['name']), '-r', 'xml'])
19+
endforeach

tests/resources/T2002278_HFR4.DAT

11 KB
Binary file not shown.

tests/resources/T2002292_MFR0.DAT

7.13 KB
Binary file not shown.

0 commit comments

Comments
 (0)