{
CoreApplication a(argc, argv, help, false);
a.setStreamPrefix("%t: ");
GeopsyCoreEngine gp;
new FFTW;
Leds leds;
QString titanPath, stationName, timeReference;
double signalDuration=300.0;
int watchInterval=60;
QString server;
quint16 port=18000;
int i, j=1;
for(i=1; i<argc; i++) {
QByteArray arg=argv[i];
if(arg[0]=='-') {
if(arg=="-s") {
CoreApplication::checkOptionArg(i, argc, argv);
titanPath=argv[i];
} else if(arg=="-n") {
CoreApplication::checkOptionArg(i, argc, argv);
stationName=argv[i];
} else if(arg=="-server") {
CoreApplication::checkOptionArg(i, argc, argv);
server=argv[i];
} else if(arg=="-port") {
CoreApplication::checkOptionArg(i, argc, argv);
port=atoi(argv[i]);
} else if(arg=="-d") {
CoreApplication::checkOptionArg(i, argc, argv);
signalDuration=atof(argv[i]);
} else if(arg=="-tref") {
CoreApplication::checkOptionArg(i, argc, argv);
timeReference=argv[i];
} else if(arg=="-m") {
CoreApplication::checkOptionArg(i, argc, argv);
watchInterval=atoi(argv[i]);
} else if(arg=="--") {
for(i++; i<argc; i++) {
argv[j++]=argv[i];
}
break;
} else {
App::stream() << tr("error: bad option %s, see -help").arg(argv[i]) << endl;
Leds::timer(0, 100, 100);
return 2;
}
} else {
argv[j++]=argv[i];
}
}
if(j < argc) {
argv[j]=0;
argc=j;
}
if(argc==2) {
QString str="%t - ";
str+=argv[1];
str+=": ";
a.setStreamPrefix(str);
} else if(argc>2) {
App::stream() << tr("error: multiple plugin names specified for kephren_plugin") << endl;
for(i=1; i<argc; i++) {
App::stream() << QString(" ")+argv[i] << endl;
}
Leds::timer(0, 100, 100);
return 2;
} else {
App::stream() << tr("error: no plugin name specified for kephren_plugin") << endl;
Leds::timer(0, 100, 100);
return 2;
}
signal(SIGTERM, interrupted);
signal(SIGINT, interrupted);
signal(SIGSEGV, crashed);
signal(SIGABRT, crashed);
if(server.isEmpty()) {
App::stream() << tr("error: server address no specified or empty (option '-server')") << endl;
Leds::timer(0, 100, 100);
return 2;
}
if(stationName.isEmpty()) {
App::stream() << tr("error: station name no specified or empty (option '-n')") << endl;
Leds::timer(0, 100, 100);
return 2;
}
ConformProcess proc;
proc.setStationName(stationName);
if(!timeReference.isEmpty()) {
QDateTime t=QDateTime::fromString(timeReference, "yyyy-MM-dd");
if(t.isValid()) {
proc.setTimeReference(t);
} else {
App::stream() << tr("error: invalid time reference (option '-tref')\n") << endl;
Leds::timer(0, 100, 100);
return 2;
}
}
proc.start(server, port);
int appReturn=a.exec();
return appReturn;
}