Commit ae0acde0 authored by Georg Martin Reinke's avatar Georg Martin Reinke
Browse files

VillasInterface: close shmem object in destructor

parent 8042a16f
......@@ -18,12 +18,6 @@ void DPsim::villasExample()
VillasInterface *villas = new VillasInterface("/villas1");
villas->registerVoltageSource(evs, 0);
std::cout << "The contents of circElements0 are:";
for (std::vector<BaseComponent*>::iterator it = comps.begin(); it != comps.end(); ++it) {
std::cout << "Added " << (*it)->getName() << std::endl;
}
std::cout << '\n';
// Set up simulation
Real timeStep = 0.01;
Simulation newSim(comps, 2.0*M_PI*50.0, timeStep, 0.1, log);
......@@ -37,8 +31,11 @@ void DPsim::villasExample()
updateProgressBar(newSim.getTime(), newSim.getFinalTime());
}
std::cout << "Simulation finished." << std::endl;
villas->shutdown();
log.WriteLogToFile("output.log");
rlog.WriteLogToFile("rvector.log");
llog.WriteLogToFile("lvector.log");
for (auto comp : comps) {
delete comp;
}
delete villas;
}
......@@ -11,5 +11,6 @@ namespace DPsim {
class ExternalInterface {
public:
virtual void readValues() = 0;
virtual ~ExternalInterface() {};
};
}
......@@ -17,6 +17,10 @@ VillasInterface::VillasInterface(const char* name) {
}
}
VillasInterface::~VillasInterface() {
shmem_shared_close(mShmem, mBase);
}
void VillasInterface::registerVoltageSource(ExternalVoltageSource *evs, int num) {
mExtComponents[num] = evs;
}
......@@ -43,8 +47,3 @@ void VillasInterface::readValues() {
sample_put(sample);
}
}
// TODO put this in destructor
void VillasInterface::shutdown() {
shmem_shared_close(mShmem, mBase);
}
......@@ -19,8 +19,8 @@ namespace DPsim {
std::unordered_map<int, BaseComponent*> mExtComponents;
public:
VillasInterface(const char* name);
~VillasInterface();
void registerVoltageSource(ExternalVoltageSource* evs, int num);
virtual void readValues();
void shutdown();
};
};
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment