5#include "slot-output-stats.h"
8#include <ns3/rng-seed-manager.h>
21 m_tableName = tableName;
25 ret = m_db->SpinExec(
"CREATE TABLE IF NOT EXISTS " + tableName +
26 "(Frame INTEGER NOT NULL, "
27 "SubFrame INTEGER NOT NULL,"
28 "Slot INTEGER NOT NULL,"
29 "BwpId INTEGER NOT NULL,"
30 "CellId INTEGER NOT NULL,"
31 "ScheduledUe INTEGER NOT NULL,"
32 "UsedReg INTEGER NOT NULL,"
33 "UsedSym INTEGER NOT NULL,"
34 "AvailableRb INTEGER NOT NULL,"
35 "AvailableSym INTEGER NOT NULL,"
36 "Seed INTEGER NOT NULL,"
37 "Run INTEGER NOT NULL);");
40 SlotOutputStats::DeleteWhere(m_db,
41 RngSeedManager::GetSeed(),
42 RngSeedManager::GetRun(),
52 uint32_t availableSym,
58 c.scheduledUe = scheduledUe;
61 c.availableRb = availableRb;
62 c.availableSym = availableSym;
66 m_slotCache.emplace_back(c);
69 if (m_slotCache.size() *
sizeof(SlotCache) > 1000000)
82SlotOutputStats::DeleteWhere(SQLiteOutput* p, uint32_t seed, uint32_t run,
const std::string& table)
86 ret = p->SpinPrepare(&stmt,
"DELETE FROM \"" + table +
"\" WHERE SEED = ? AND RUN = ?;");
87 NS_ABORT_IF(ret ==
false);
88 ret = p->Bind(stmt, 1, seed);
89 NS_ABORT_IF(ret ==
false);
90 ret = p->Bind(stmt, 2, run);
92 ret = p->SpinExec(stmt);
93 NS_ABORT_IF(ret ==
false);
97SlotOutputStats::WriteCache()
99 bool ret = m_db->SpinExec(
"BEGIN TRANSACTION;");
100 for (
const auto& v : m_slotCache)
104 m_db->SpinPrepare(&stmt,
105 "INSERT INTO " + m_tableName +
" VALUES (?,?,?,?,?,?,?,?,?,?,?,?);");
107 ret = m_db->Bind(stmt, 1, v.sfnSf.GetFrame());
109 ret = m_db->Bind(stmt, 2, v.sfnSf.GetSubframe());
111 ret = m_db->Bind(stmt, 3, v.sfnSf.GetSlot());
113 ret = m_db->Bind(stmt, 4, v.bwpId);
115 ret = m_db->Bind(stmt, 5, v.cellId);
117 ret = m_db->Bind(stmt, 6, v.scheduledUe);
119 ret = m_db->Bind(stmt, 7, v.usedReg);
121 ret = m_db->Bind(stmt, 8, v.usedSym);
123 ret = m_db->Bind(stmt, 9, v.availableRb);
125 ret = m_db->Bind(stmt, 10, v.availableSym);
127 ret = m_db->Bind(stmt, 11, RngSeedManager::GetSeed());
129 ret = m_db->Bind(stmt, 12,
static_cast<uint32_t
>(RngSeedManager::GetRun()));
132 ret = m_db->SpinExec(stmt);
136 ret = m_db->SpinExec(
"END TRANSACTION;");
SlotOutputStats()
Constructor.
void EmptyCache()
Force the cache write to disk, emptying the cache itself.
void SaveSlotStats(const SfnSf &sfnSf, uint32_t scheduledUe, uint32_t usedReg, uint32_t usedSym, uint32_t availableRb, uint32_t availableSym, uint16_t bwpId, uint16_t cellId)
Save the slot statistics.
void SetDb(SQLiteOutput *db, const std::string &tableName="slotStats")
Install the output database.