Skip to content
Snippets Groups Projects
Select Git revision
  • 8d68cee028c7f2912aa5998cfda981f5a3ac3d48
  • master default
  • main protected
3 results

options.h

Blame
  • options.h 3.71 KiB
    #pragma once
    
    #include <cstdint>
    #include <string>
    #include <vector>
    #include <argp.h>
    #include <filesystem>
    
    #include "log.h"
    #include "tokenize.h"
    
    const char *argp_program_version = "kissExpiramentController-1.0";
    const char *argp_program_bug_address = "<carl@uvos.xyz>";
    static char doc[] = "Application that controls the kiss expirament";
    static char args_doc[] = "";
    
    static struct argp_option options[] =
    {
      {"verbose",     'v', 0,               0,  "Show debug messages" },
      {"quiet",       'q', 0,               0,  "only output data" },
      {"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" },
      {"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" },
      {"cellmask",    'c', "[LIST OF IDS]", 0,  "lists the coin cell units to be involved in the expirament" },
      {"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"},
      {"skip-start",  'z'  , 0,             0,  "skipps the startup sequence"},
      { 0 }
    };
    
    struct Config
    {
    	std::vector<uint16_t> multiplexerSerials = {1, 2, 3, 4};
    	std::vector<uint16_t> heaterSerials = {1, 2, 3, 4, 5};
    	std::string psuPort = "/dev/ttyUSB0";
    	std::filesystem::path biocontrolpath = "/home/philipp/programming/biocontrol/build/biocontrol.exe";
    	std::string bioip = "10.2.0.2";
    	std::vector<uint16_t> cells;
    	std::filesystem::path outdir = "./log";
    	std::filesystem::path stepfile = "/tmp/cchstep";
    	float psuVoltage = 10;
    	float psuCurrent = 5;
    
    	size_t globalStep = 0;
    	size_t subStep = 0;
    	bool skipstart = false;
    };
    
    static std::vector<uint16_t> parseList(const std::string& in)
    {
    	std::vector<std::string> tokens = tokenize(in, ',');
    	std::vector<uint16_t> list;
    	list.reserve(tokens.size());
    	for(const std::string& str : tokens)
    		list.push_back(std::stoul(str));
    
    	return list;
    }
    
    static error_t parse_opt (int key, char *arg, struct argp_state *state)
    {
    	Config *config = reinterpret_cast<Config*>(state->input);
    
    	try