/* voltlogger_analyzer Copyright (C) 2015 Dmitry Yu Okunev 0x8E30679C This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #define _GNU_SOURCE #include "configuration.h" #include "macros.h" #include /* getline() */ #include /* atof() */ #include /* getopt() */ #include #include #include "error.h" #include "analyzer.h" enum functype { FT_SIN }; typedef enum functype functype_t; static char *const functypes[] = { [FT_SIN] = "sin", NULL }; int main(int argc, char *argv[]) { functype_t functype = FT_SIN; char realtime = 0; float frequency = 50; double errorthreshold = 1; int concurrency = 1; char *checkpointpath = NULL; FILE *input = stdin; int channelsNum = 1; int channelId = 0; // Initializing output subsystem { int output_method = OM_STDERR; int output_quiet = 0; int output_verbosity = 9; int output_debuglevel = 9; error_init(&output_method, &output_quiet, &output_verbosity, &output_debuglevel); } // Parsing arguments char c; while ((c = getopt (argc, argv, "ri:f:F:c:C:e:N:n:")) != -1) { char *arg; arg = optarg; switch (c) { case 'f': { char *value; functype = getsubopt(&arg, functypes, &value); break; } case 'F': frequency = atof(optarg); break; case 'r': realtime = 1; break; case 'c': concurrency = atoi(optarg); break; case 'C': checkpointpath = arg; break; case 'i': assert ((input = fopen(arg, "r")) != NULL); break; case 'e': errorthreshold = atof(optarg); break; case 'N': channelsNum = atoi(optarg); break; case 'n': channelId = atoi(optarg); break; default: abort (); } } assert (channelsNum > 0); assert (channelId < channelsNum); switch (functype) { case FT_SIN: vl_analyze_sin(input, stdout, channelsNum, channelId, checkpointpath, concurrency, frequency, errorthreshold, realtime); break; default: fprintf(stderr, "Unknown approximation function\n"); abort (); } return 0; }