7 #include <sys/resource.h>
13 : mSaleaeDirectory(filename,true)
15 std::filesystem::path csvpath(filename);
16 mDir = csvpath.parent_path();
17 std::filesystem::create_directory(mDir);
23 std::unordered_map<int,SaleaeDirectoryFileIndex> fileIndexes;
24 for (
auto it = mDataFiles.begin(); it != mDataFiles.end(); ++it)
27 fileIndexes.insert(std::make_pair(it->first,sof->
fileIndex()));
43 std::filesystem::path path;
45 bool updateDirectory =
false;
51 auto it = mDataFiles.find(fileIndex);
52 if (it != mDataFiles.end())
63 getrlimit(RLIMIT_NOFILE, &rlim);
66 unsigned int required = fileIndex + 256;
67 if (rlim.rlim_max < required)
return nullptr;
68 if (rlim.rlim_cur < required)
70 rlim.rlim_cur = required;
71 setrlimit(RLIMIT_NOFILE, &rlim);
74 std::ostringstream fname;
75 fname <<
"digital_" << fileIndex <<
".bin";
76 path = mDir / fname.str();
78 updateDirectory =
true;
87 mDataFiles.insert(std::make_pair(fileIndex,sof));
The SaleaeDirectoryFileIndex class represents a single SALEAE data file. The class comprises the inde...
int get_datafile_index(const std::string &nam, uint32_t id) const
Get waveform datafile index for net identified by name and id.
void add_or_replace_net(SaleaeDirectoryNetEntry &sdne)
Add net entry if not yet existing, replace existing entry otherwise.
int get_next_available_index() const
Getter for next available file index ('digital_XXX.bin' with lowest number XXX not in use)
void update_file_indexes(std::unordered_map< int, SaleaeDirectoryFileIndex > &fileIndexes)
Update file index information (like number of transitions, end time ...) after writing SALEAE files.
std::string get_datafile_path(int index) const
Get full path to waveform data file.
The SaleaeDirectoryNetEntry class represents a regular waveform for a single simulated net....
void addIndex(const SaleaeDirectoryFileIndex &sdfe)
Add index for binary file to net entry instance.
The SaleaeDirectoryStoreRequest class is useful to bundle requests for updating SALEAE directory....
void close()
Update header on disk and close file.
SaleaeDirectoryFileIndex fileIndex() const
File index summary for saleae directory.
SaleaeWriter(const std::string &filename)
void add_directory_entry(int inx, const std::string &name, uint32_t id)
Adds directory entry for net/waveform with binary file index inx.
~SaleaeWriter()
Destructor closes all open binary files updating their file header. It also updates SALEAE directory.
SaleaeOutputFile * add_or_replace_waveform(const std::string &name, uint32_t id)
Create new empty output file. Will delete existing binary file if directory links already a data file...
bool save(std::filesystem::path file_path, GateLibrary *gate_lib, bool overwrite=false)