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

allow the masking of heaters

parent 4acf4f8e
No related branches found
No related tags found
No related merge requests found
#include <coincellhell/coincellhell.h>
#include <coincellhell/usbcommands.h>
#include <cstdint>
#include <ctime>
#include <memory>
#include <thread>
......@@ -9,7 +10,7 @@
Heaters::Heaters(const std::vector<uint16_t> serials,
std::function<void(int device, uint16_t serial, int code)> deviceFailCbIn,
std::function<void(int heater, int device)> heaterFailCbIn):
std::function<void(int heater, int device)> heaterFailCbIn, const std::set<uint16_t>& maskedSerials):
deviceFailCb(deviceFailCbIn), heaterFailCb(heaterFailCbIn)
{
Log(Log::INFO)<<"inializeing "<<serials.size()<<" coincellhell devices with "<<serials.size()*HEATERS_PER_DEVICE<<" heaters";
......@@ -22,6 +23,15 @@ deviceFailCb(deviceFailCbIn), heaterFailCb(heaterFailCbIn)
{
devices[i].mutex = std::make_unique<std::mutex>();
int ret = coincellhell_connect(&devices[i].device, serials[i]);
if(maskedSerials.contains(serials[i]))
{
if(ret != 0)
Log(Log::WARN)<<"Could not connect to masked heater device with the serial "<<serials[i];
devices[i].bad = true;
continue;
}
if(ret != 0)
{
throw startup_failure("Unable to connect to coincellhell with serial " + std::to_string(serials[i]));
......
......@@ -6,6 +6,7 @@
#include <functional>
#include <mutex>
#include <memory>
#include <set>
#include "log.h"
......@@ -51,7 +52,7 @@ public:
Heaters(const std::vector<uint16_t> serials,
std::function<void(int device, uint16_t serial, int code)> deviceFailCb,
std::function<void(int heater, int device)> heaterFailCb);
std::function<void(int heater, int device)> heaterFailCb, const std::set<uint16_t>& maskedHeaters = {});
bool wait(int timeout = -1);
bool allReady();
std::vector<bool> getBadDevices();
......
......@@ -221,7 +221,7 @@ int main(int argc, char** argv)
Log(Log::INFO)<<"Aquireing heaters and multiplexers";
Heaters heaters(config.heaterSerials,
[&psu](int device, uint16_t serial, int code){devicefailed(psu, device, serial, code);},
&heaterfailed);
&heaterfailed, config.maskedHeaters);
Multiplexers multiplexers(config.multiplexerSerials);
std::vector<std::unique_ptr<CoinCell>> coinCells = asign_coincells(config.cells, &heaters, &multiplexers);
......
......@@ -5,6 +5,7 @@
#include <vector>
#include <argp.h>
#include <filesystem>
#include <set>
#include "log.h"
#include "tokenize.h"
......@@ -21,6 +22,7 @@ static struct argp_option options[] =
{"out", 'o', "[DIRECTORY]", 0, "Directory where to save the output mesurements" },
{"muliplexers", 'm', "[SERIALS]", 0, "List the serial numbers of the involved multiplexers" },
{"heaters", 'r', "[SERIALS]", 0, "set the serial numbers of the involved coincellhells" },
{"heater-mask" ,'x', "[SERIALS]", 0, "disable the actual driveing of the given heaters" },
{"psuport", 'p', "[PORT]", 0, "sets the serial port where the psu is connected" },
{"biocontrol", 'b', "[PATH]", 0, "sets the path where the biocontrol application is stored" },
{"bioip", 'i', "[IPADDR]", 0, "the ip address of the biologic device" },
......@@ -28,8 +30,8 @@ static struct argp_option options[] =
{"voltage", 'u', "[VOLTAGE]", 0, "sets the voltage at wich to operate the heaters" },
{"current", 'l', "[CURRENT]", 0, "sets the current limit at wich to operate the heaters"},
{"step", 's', "[STEP NUMBER]", 0, "sets the global setp at wich to start the expirament"},
{"sub-step", 'k', "[STEP NUMBER]", 0, "sets the subset of the expirament"},
{"stepfile", 'f', "[PATH]", 0, "sets the subset of the expirament"},
{"sub-step", 'k', "[STEP NUMBER]", 0, "sets the subsep of the expirament"},
{"stepfile", 'f', "[PATH]", 0, "if set this file is used to save the step and substep"},
{"skip-start", 'z' , 0, 0, "skipps the startup sequence"},
{"watchdog", 'w' , 0, 0, "enable mcu watchdogs"},
{ 0 }
......@@ -39,6 +41,7 @@ struct Config
{
std::vector<uint16_t> multiplexerSerials = {1, 2, 3, 4, 5};
std::vector<uint16_t> heaterSerials = {1, 2, 3, 4, 5, 6};
std::set<uint16_t> maskedHeaters;
std::string psuPort = "/dev/ttyUSB0";
std::filesystem::path biocontrolpath = "/home/philipp/programming/biocontrol/build/biocontrol.exe";
std::string bioip = "10.2.0.2";
......@@ -85,6 +88,12 @@ static error_t parse_opt (int key, char *arg, struct argp_state *state)
case 'r':
config->heaterSerials = parseList(arg);
break;
case 'x':
{
std::vector<uint16_t> list = parseList(arg);
config->maskedHeaters.insert(list.begin(), list.end());
break;
}
case 'p':
config->psuPort = arg;
break;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment