diff --git a/heater.cpp b/heater.cpp index b45468870568a6bbc7248b879d9b873cb2500c60..9c13353109ce5f8f41ae0753f7c83cc6cb918aa2 100644 --- a/heater.cpp +++ b/heater.cpp @@ -1,5 +1,6 @@ #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])); diff --git a/heaters.h b/heaters.h index d254f548222ae2cd7a783b252820c60ae0316887..a7bd8043564c081730be2222322bcfbed816a3b2 100644 --- a/heaters.h +++ b/heaters.h @@ -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(); diff --git a/main.cpp b/main.cpp index a1a4612e02fd879f487378c81f4d27e80d68f402..0621651bfb6676d99b9180596eec5407fe838059 100644 --- a/main.cpp +++ b/main.cpp @@ -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); diff --git a/options.h b/options.h index b08b4a004bd1fbd4fbab42c3d5fbeccd12b6ab90..5f65cf7e42363197ba25d5c08e97d0eb2d10e37d 100644 --- a/options.h +++ b/options.h @@ -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,10 +30,10 @@ 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"}, + {"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;