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

allow coincell to have multiple mulitplexer channels to allow the system to do 4wire mesurment

parent 89793685
No related branches found
No related tags found
No related merge requests found
......@@ -2,22 +2,38 @@
#include <chrono>
#include <thread>
CoinCell::CoinCell(Heaters* heatersIn, Multiplexers* multiplexersIn, int heaterIdIn, int multiplexerChIn):
heaters(heatersIn), multiplexers(multiplexersIn), heaterId(heaterIdIn), multiplexerCh(multiplexerChIn)
CoinCell::CoinCell(Heaters* heatersIn, Multiplexers* multiplexersIn, int heaterIdIn, const std::vector<int> multiplexerChsIn):
heaters(heatersIn), multiplexers(multiplexersIn), heaterId(heaterIdIn), multiplexerChs(multiplexerChsIn)
{
}
bool CoinCell::connectExclusive()
{
bool ret = multiplexers->setChExlusive(multiplexerCh, true);
bool ret = multiplexers->disconnectAll();
if(!ret)
return ret;
for(int id : multiplexerChs)
{
ret = multiplexers->setCh(id, true);
if(!ret)
return ret;
}
std::this_thread::sleep_for(std::chrono::milliseconds(250));
return ret;
}
bool CoinCell::dissconnect()
{
bool ret = multiplexers->setCh(multiplexerCh, false);
bool ret = true;
for(int id : multiplexerChs)
{
ret = multiplexers->setCh(id, false);
if(!ret)
return ret;
}
return ret;
}
......@@ -52,7 +68,13 @@ bool CoinCell::getTemperature(float& temperature)
bool CoinCell::setConnected(bool connected)
{
bool ret = multiplexers->setCh(multiplexerCh, connected);
bool ret = true;
for(int id : multiplexerChs)
{
ret = multiplexers->setCh(id, connected);
if(!ret)
return ret;
}
std::this_thread::sleep_for(std::chrono::milliseconds(250));
return ret;
}
......
......@@ -13,7 +13,7 @@ class CoinCell
{
private:
int heaterId;
int multiplexerCh;
std::vector<int> multiplexerChs;
Heaters* heaters;
Multiplexers* multiplexers;
double lastKnownCap = -1;
......@@ -24,7 +24,7 @@ private:
public:
CoinCell(Heaters* heaters, Multiplexers* multiplexers, int heaterId, int multiplexerCh);
CoinCell(Heaters* heaters, Multiplexers* multiplexers, int heaterId, const std::vector<int> multiplexerChs);
bool connectExclusive();
bool dissconnect();
......
......@@ -146,27 +146,28 @@ bool listSerialPorts()
std::vector<std::unique_ptr<CoinCell>> asign_coincells(std::vector<uint16_t> cellids, Heaters* heaters, Multiplexers* multiplexers)
{
CoinCell cell(heaters, multiplexers, 0, {3});
std::vector<std::unique_ptr<CoinCell>> coinCells;
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 0, 3));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 1, 2));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 2, 1));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 3, 0));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 4, 8));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 5, 7));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 6, 5));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 7, 4));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 8, 12));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 9, 11));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 10, 10));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 11, 9));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 12, 17));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 13, 16));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 14, 15));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 15, 14));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 16, 21));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 17, 20));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 18, 19));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 19, 18));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 0, std::vector<int>({3})));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 1, std::vector<int>({2})));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 2, std::vector<int>({1})));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 3, std::vector<int>({0})));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 4, std::vector<int>({8})));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 5, std::vector<int>({7})));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 6, std::vector<int>({5})));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 7, std::vector<int>({4})));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 8, std::vector<int>({12})));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 9, std::vector<int>({11})));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 10, std::vector<int>({10})));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 11, std::vector<int>({9})));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 12, std::vector<int>({17})));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 13, std::vector<int>({16})));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 14, std::vector<int>({15})));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 15, std::vector<int>({14})));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 16, std::vector<int>({21})));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 17, std::vector<int>({20})));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 18, std::vector<int>({19})));
coinCells.push_back(std::make_unique<CoinCell>(heaters, multiplexers, 19, std::vector<int>({18})));
if(!cellids.empty())
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment