|
|
|
@ -26,8 +26,15 @@ inline std::ostream& operator<< (std::ostream &out, const app_options &opts) {
|
|
|
|
|
return out << "Options: { " |
|
|
|
|
<< "config-file: " << opts.config_file << ", " |
|
|
|
|
<< "initial-pin-state: " << opts.initial_pin_state << " }"; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline std::ostream& operator<< (std::ostream &out, const std::ifstream &input) { |
|
|
|
|
std::string line; |
|
|
|
|
while (std::getline(const_cast<std::ifstream &>(input), line).good()) { |
|
|
|
|
out << line << std::endl; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return out; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
int main(int argc, char** argv) { |
|
|
|
@ -36,13 +43,21 @@ int main(int argc, char** argv) {
|
|
|
|
|
el::Loggers::addFlag(el::LoggingFlag::ColoredTerminalOutput); |
|
|
|
|
|
|
|
|
|
app_options opts = parse_opts(argc, argv); |
|
|
|
|
LOG(INFO) << opts; |
|
|
|
|
|
|
|
|
|
if(opts.config_file.empty()) { |
|
|
|
|
LOG(WARNING) << "Config file is not set! So we use hardcoded configuration:" << std::endl |
|
|
|
|
<< schedule.str(); |
|
|
|
|
} else { |
|
|
|
|
std::ifstream input{opts.config_file}; |
|
|
|
|
LOG(INFO) << "Config file:" << std::endl << input; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
LOG(INFO) << opts; |
|
|
|
|
TaskManager manager{schedule, digitalWrite}; |
|
|
|
|
std::ifstream input{opts.config_file}; |
|
|
|
|
std::istream &stream =
|
|
|
|
|
!opts.config_file.empty() && input.is_open() ?
|
|
|
|
|
static_cast<std::istream&>(input) : static_cast<std::istream&>(schedule); |
|
|
|
|
TaskManager manager{stream, digitalWrite}; |
|
|
|
|
|
|
|
|
|
wiringPiSetup (); |
|
|
|
|
pinMode (PIN, OUTPUT); |
|
|
|
|