Init final simulator source

This commit is contained in:
Loic Guegan 2019-04-12 13:52:06 +02:00
parent 23e8f7f688
commit 9272834371
7 changed files with 302 additions and 0 deletions

View file

@ -0,0 +1,51 @@
#include "modules.hpp"
void setupEnergy(Cell cell){
NodeContainer nodes(cell.first.first,cell.first.second);
NetDeviceContainer nodesNetDev(cell.second.first,cell.second.second);
// Install energy source
BasicEnergySourceHelper edgeBasicSourceHelper;
edgeBasicSourceHelper.Set ("BasicEnergySourceInitialEnergyJ", DoubleValue (2.9009));
edgeBasicSourceHelper.Set ("BasicEnergySupplyVoltageV", DoubleValue (3.3));
EnergySourceContainer apEdgeNodesSources = edgeBasicSourceHelper.Install (cell.first.first);
EnergySourceContainer wifiEdgeNodesSources = edgeBasicSourceHelper.Install (cell.first.second);
// Install device energy model
WifiRadioEnergyModelHelper radioEnergyHelper;
radioEnergyHelper.Set ("TxCurrentA", DoubleValue (0.38));
radioEnergyHelper.Set ("RxCurrentA", DoubleValue (0.313));
radioEnergyHelper.Set ("IdleCurrentA", DoubleValue (0.273));
DeviceEnergyModelContainer edgeApDeviceModels = radioEnergyHelper.Install (cell.second.first, apEdgeNodesSources);
DeviceEnergyModelContainer edgeDeviceModels = radioEnergyHelper.Install (cell.second.second, wifiEdgeNodesSources);
// Trace
DeviceEnergyModelContainer energyModels(edgeApDeviceModels, edgeDeviceModels);
DeviceEnergyModelContainer::Iterator it=energyModels.Begin();
int i=0;
while(it!=energyModels.End()){
(*it)->TraceConnect ("TotalEnergyConsumption", std::to_string(i),MakeCallback (&EnergyUpdated));
it++;
i++;
}
// Ptr<BasicEnergySource> basicSourcePtr0 = DynamicCast<BasicEnergySource> (wifiEdgeNodesSources.Get (0));
// //basicSourcePtr0->TraceConnectWithoutContext ("RemainingEnergy", MakeCallback (&RemainingEnergy));
// //device energy model
// Ptr<DeviceEnergyModel> basicRadioModelPtr0 =
// basicSourcePtr0->FindDeviceEnergyModels ("ns3::WifiRadioEnergyModel").Get (0);
// NS_ASSERT (basicRadioModelPtr0 != NULL);
// basicRadioModelPtr0->TraceConnectWithoutContext ("TotalEnergyConsumption", MakeCallback (&TotalEnergy));
}