Skip to content

Commit

Permalink
altiwx.workdir
Browse files Browse the repository at this point in the history
  • Loading branch information
OK9UWU committed Jan 28, 2023
1 parent 0ab6d85 commit b36363d
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
15 changes: 10 additions & 5 deletions src/processing/pass_processing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
#include "processing_script.h"

// Generate output filename / path
std::string generateFilepath(SatellitePass &satellitePass, SatelliteConfig &satelliteConfig, DownlinkConfig &downlinkConfig, TLE &tle)
//std::string generateFilepath(SatellitePass &satellitePass, SatelliteConfig &satelliteConfig, DownlinkConfig &downlinkConfig, TLE &tle)
std::pair<std::string, std::string> generateFilepath(SatellitePass &satellitePass, SatelliteConfig &satelliteConfig, DownlinkConfig &downlinkConfig, TLE &tle)
{
std::tm *timeReadable = gmtime(&satellitePass.aos);

Expand All @@ -25,12 +26,14 @@ std::string generateFilepath(SatellitePass &satellitePass, SatelliteConfig &sate

std::filesystem::create_directories(workdDir);

return workdDir + "/" + utc_timestamp;
//return workdDir + "/" + utc_timestamp;
return std::make_pair(workdDir + "/" + utc_timestamp, workdDir);
}

struct ToProcess
{
std::string filename;
std::string workdir;
std::string filePath;
std::string script;
DownlinkConfig downlink;
Expand All @@ -57,13 +60,15 @@ void processSatellitePass(SatellitePass satPass, std::shared_ptr<DeviceDSP> dsp,
logger->debug("Adding recorder for " + downlinkConfig.name + " downlink on " + std::to_string(downlinkConfig.frequency) + " Hz");

// Generate filename / path, store them and setup recorder
std::string filename = generateFilepath(satPass, satellite_config, downlinkConfig, tle);
std::pair<std::string, std::string> pgenFilepath = generateFilepath(satPass, satellite_config, downlinkConfig, tle);
std::string filename = pgenFilepath.first;
std::string workdir = pgenFilepath.second;
std::string filepath = filename + "." + downlinkConfig.output_extension;
logger->debug("Using file path " + filepath);

std::shared_ptr<DownlinkRecorder> recorder = std::make_shared<DownlinkRecorder>(dsp, downlinkConfig, satellite_config, tle, filepath);
downlink_recorders.push_back(recorder);
filePaths.push_back({filename, filepath, downlinkConfig.post_processing_script, downlinkConfig, downlinkConfig.bandwidth});
filePaths.push_back({filename, workdir, filepath, downlinkConfig.post_processing_script, downlinkConfig, downlinkConfig.bandwidth});
}

// Start recording all downlinks
Expand Down Expand Up @@ -104,7 +109,7 @@ void processSatellitePass(SatellitePass satPass, std::shared_ptr<DeviceDSP> dsp,
continue;
}

ProcessingScript currentProcessor(satPass, satellite_config, fileToProcess.downlink, tle, fileToProcess.filePath, fileToProcess.filename, scriptFullPath);
ProcessingScript currentProcessor(satPass, satellite_config, fileToProcess.downlink, tle, fileToProcess.filePath, fileToProcess.filename, fileToProcess.workdir, scriptFullPath);
currentProcessor.process();
}
}
4 changes: 4 additions & 0 deletions src/processing/processing_script.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@ ProcessingScript::ProcessingScript(SatellitePass satellite_pass,
TLE tle,
std::string input_file,
std::string filename,
std::string workdir,
std::string script) : d_satellite_pass(satellite_pass),
d_satellite_config(satelliteConfig),
d_downlink_config(downlinkConfig),
d_input_file(input_file),
d_filename(filename),
d_workdir(workdir),
d_script(script),
d_tle(tle)
{
Expand All @@ -42,6 +44,7 @@ void ProcessingScript::process()
// Set python variables;
altiWxModule.attr("input_file") = pybind11::cast(d_input_file);
altiWxModule.attr("filename") = pybind11::cast(d_filename);
altiWxModule.attr("workdir") = pybind11::cast(d_workdir);
altiWxModule.attr("satellite_name") = pybind11::cast(d_tle.object_name);
altiWxModule.attr("downlink_name") = pybind11::cast(d_downlink_config.name);
altiWxModule.attr("samplerate") = pybind11::cast(d_downlink_config.bandwidth);
Expand Down Expand Up @@ -102,6 +105,7 @@ PYBIND11_EMBEDDED_MODULE(altiwx, m)
// Variables
m.attr("input_file") = "";
m.attr("filename") = "";
m.attr("workdir") = "";
m.attr("satellite_name") = "";
m.attr("samplerate") = 0;
m.attr("southbound") = 0;
Expand Down
3 changes: 2 additions & 1 deletion src/processing/processing_script.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@ class ProcessingScript
DownlinkConfig d_downlink_config;
std::string d_input_file;
std::string d_filename;
std::string d_workdir;
std::string d_script;
std::string script_content;
TLE d_tle;

public:
ProcessingScript(SatellitePass satellite_pass, SatelliteConfig satelliteConfig, DownlinkConfig downlinkConfig, TLE tle, std::string input_file, std::string filename, std::string script);
ProcessingScript(SatellitePass satellite_pass, SatelliteConfig satelliteConfig, DownlinkConfig downlinkConfig, TLE tle, std::string input_file, std::string filename, std::string workdir, std::string script);
void process();
};

0 comments on commit b36363d

Please sign in to comment.