Skip to content
Snippets Groups Projects
Commit e012c544 authored by Carl Philipp Klemm's avatar Carl Philipp Klemm
Browse files

fix invalid access in printComponants

parent 2d3940a5
No related branches found
No related tags found
No related merge requests found
......@@ -20,10 +20,6 @@ class Componant
return std::complex<fvalue> (1,0);
}
virtual std::vector<fvalue> getParam()
{
return std::vector<fvalue>();
};
virtual void setParamRanges(const std::vector<eis::Range>& ranges);
virtual std::vector<eis::Range>& getParamRanges();
virtual size_t paramCount(){return 0;}
......
......@@ -60,6 +60,7 @@ public:
Range(fvalue startI, fvalue endI, size_t countI, bool logI = false): start(startI), end(endI), count(countI), log(logI){}
Range() = default;
void print(int level) const;
std::string getString() const;
static std::vector<Range> rangesFromParamString(const std::string& paramStr, size_t count);
};
......
#include "eistype.h"
#include <fstream>
#include <sstream>
#include "strops.h"
#include "log.h"
......@@ -69,3 +70,16 @@ std::vector<Range> eis::Range::rangesFromParamString(const std::string& paramStr
}
return ranges;
}
std::string eis::Range::getString() const
{
std::stringstream ss;
ss<<start;
if(count > 1)
ss<<'~'<<end;
if(log)
ss<<'F';
return ss.str();
}
......@@ -2,6 +2,7 @@
#include <complex>
#include <chrono>
#include <cmath>
#include <cassert>
#include <filesystem>
#include "basicmath.h"
......@@ -22,12 +23,15 @@ static void printComponants(eis::Model& model)
eis::Log(eis::Log::DEBUG)<<"Compnants:";
for(eis::Componant* componant : model.getFlatComponants())
{
eis::Log(eis::Log::DEBUG)<<componant->getComponantChar()<<"{";
eis::Log(eis::Log::DEBUG, false)<<componant->getComponantChar()<<"{";
std::vector<eis::Range>& ranges = componant->getParamRanges();
assert(componant->paramCount() == ranges.size());
for(size_t i = 0; i < componant->paramCount(); ++i)
{
eis::Log(eis::Log::DEBUG)<<componant->getParam()[i];
eis::Log(eis::Log::DEBUG, false)<<ranges[i].getString();
if(i != componant->paramCount()-1)
eis::Log(eis::Log::DEBUG)<<", ";
eis::Log(eis::Log::DEBUG, false)<<", ";
}
eis::Log(eis::Log::DEBUG)<<"}";
}
......
......@@ -24,13 +24,16 @@ Resistor::Resistor(std::string paramStr, size_t count)
ranges.clear();
ranges.push_back(Range(1e3, 1e3, 1));
}
for(const Range& range : ranges)
range.print(Log::DEBUG);
}
std::complex<fvalue> Resistor::execute(fvalue omega)
{
(void)omega;
assert(ranges.size() == paramCount());
return std::complex<fvalue>(ranges[0][ranges[0].step], 0);
return std::complex<fvalue>(ranges[0].stepValue(), 0);
}
size_t Resistor::paramCount()
......
......@@ -68,17 +68,20 @@ std::vector<eis::DataPoint> getMockData()
return data;
}
void printComponants(eis::Model& model)
static void printComponants(eis::Model& model)
{
eis::Log(eis::Log::DEBUG)<<"Compnants:";
for(eis::Componant* componant : model.getFlatComponants())
{
eis::Log(eis::Log::DEBUG)<<componant->getComponantChar()<<"{";
eis::Log(eis::Log::DEBUG, false)<<componant->getComponantChar()<<"{";
std::vector<eis::Range>& ranges = componant->getParamRanges();
assert(componant->paramCount() != ranges.size());
for(size_t i = 0; i < componant->paramCount(); ++i)
{
eis::Log(eis::Log::DEBUG)<<componant->getParam()[i];
eis::Log(eis::Log::DEBUG, false)<<ranges[i].getString();
if(i != componant->paramCount()-1)
eis::Log(eis::Log::DEBUG)<<", ";
eis::Log(eis::Log::DEBUG, false)<<", ";
}
eis::Log(eis::Log::DEBUG)<<"}";
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment