ros_realtime_tests /oneshot_timer_tests/src/ArgumentParser.cpp

Language C++ Lines 74
MD5 Hash ac5e87c6c7ef2c848338bb294d815835
Repository https://gitlab.com/F34140r/ros_realtime_tests.git View Raw File
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/**
* Copyright (C) 2014, BMW Car IT GmbH
* Author: Jonas Sticha (Jonas.Sticha@bmw-carit.de)
*
* This software is licensed under BSD 3-clause License
* (see http://spdx.org/licenses/BSD-3-Clause).
**/

#include "Config.h"
#include "ArgumentParser.h"

ArgumentParser::ArgumentParser()
{
}

bool ArgumentParser::parseArgs(int argc, char* argv[])
{
	Config* config = Config::getConfig();
	config->loops = 1000;
	config->timeout_us = 1000;
	config->testnodeRT = false;
	bool error = false;
	for(int i = 1; i < argc; i++)
	{
		std::string arg(argv[i]);
		if(arg.compare("-s") == 0)
		{
			std::string val(argv[i+1]);
			if(val.compare("0") == 0)
			{
				config->testnodeRT = false;
			} else if(val.compare("RR") == 0)
			{
				config->testnodeRT = true;
				config->fifoScheduling = false;
			} else if(val.compare("FIFO") == 0)
			{
				config->testnodeRT = true;
				config->fifoScheduling = true;
			} else {
				error = true;
				continue;
			}
			i++;
		} else if(arg.compare("-r") == 0)
		{
			config->loops = atoi(argv[i+1]);
			i++;
		} else if(arg.compare("-t") == 0)
		{
			config->timeout_us = atoi(argv[i+1]);
			i++;
		} else if(arg.compare("-p") == 0)
		{
			config->namePrefix = std::string(argv[i+1]);
			i++;
		} else if(arg.compare("-b") == 0)
		{
			config->busyMode = atoi(argv[i+1]);
			i++;
		}
	}
	return !error;
}

std::string ArgumentParser::getUsage()
{
	return "Args: [-t <timeout(microseconds)>] [-r <repetitions>] [-s <0/RR/FIFO>] [-p <file/name_prefix>] [-b <(busy_mode)0/1>]";
}

ArgumentParser::~ArgumentParser()
{
}
Back to Top