| 1 |
// |
| 2 |
// TEMPLATE.cc -- standalone program to call the TEMPLATEEXE program. |
| 3 |
// by Emiliano Mocchiutti |
| 4 |
// |
| 5 |
// Version 2.00 (2006/01/13) |
| 6 |
// |
| 7 |
// Changelog: |
| 8 |
// |
| 9 |
// 1.00 - 2.00 : use ROOT class to connect to the DB. No more FORCE and framework input variables (assume "ROOT" and FORCE=1). |
| 10 |
// |
| 11 |
// 0.00 - 1.00 : working. |
| 12 |
// |
| 13 |
#include <iostream> |
| 14 |
#include <TSQLServer.h> |
| 15 |
#include <TString.h> |
| 16 |
// |
| 17 |
extern short int ACEXE(int, TSQLServer *); |
| 18 |
// |
| 19 |
// the "info" subroutines is created by the makefile during the compilation and contains infos about the compiling environment |
| 20 |
// it is added at the end of this file during compilation |
| 21 |
// |
| 22 |
extern void info(); |
| 23 |
// |
| 24 |
using namespace std; |
| 25 |
// |
| 26 |
int main(int numinp, char *inps[]){ |
| 27 |
int error = 0; |
| 28 |
int run = 0; |
| 29 |
TSQLServer *dbc = 0; |
| 30 |
if ( numinp > 1 ){ |
| 31 |
if ( !strcmp(inps[1],"--version") ){ |
| 32 |
info(); |
| 33 |
return(0); |
| 34 |
}; |
| 35 |
if ( !strcmp(inps[1],"-h") || !strcmp(inps[1],"--help") ){ |
| 36 |
printf("\nUsage:\n\n ACL2 run_id \n"); |
| 37 |
printf("\n - run_id : ID number of the run to be processed \n"); |
| 38 |
printf("\nExample: \n\nACL2 1085 \n\n"); |
| 39 |
return(0); |
| 40 |
}; |
| 41 |
}; |
| 42 |
if ( numinp == 1 ){ |
| 43 |
printf("\n Welcome to the AC LEVEL2 flight software! \n"); |
| 44 |
// |
| 45 |
char input[256]; |
| 46 |
// |
| 47 |
printf("\n\n Enter ID of the run to be processed: \n "); |
| 48 |
cin.getline(input,256); |
| 49 |
run = atoi(input); |
| 50 |
// |
| 51 |
} else { |
| 52 |
printf("\n Welcome to the AC LEVEL2 flight software! \n"); |
| 53 |
run = atoi(inps[1]); |
| 54 |
}; |
| 55 |
// |
| 56 |
// |
| 57 |
// |
| 58 |
printf("\nConnecting to database... \n"); |
| 59 |
// |
| 60 |
dbc = TSQLServer::Connect("mysql://localhost/pamela_test","anonymous",""); |
| 61 |
bool connect = dbc->IsConnected(); |
| 62 |
// |
| 63 |
if( !connect ) { |
| 64 |
printf("Problems connecting to the DB (check username and passwd), exiting...\n\n"); |
| 65 |
return(2); |
| 66 |
}; |
| 67 |
printf("...connected! \n\n"); |
| 68 |
// |
| 69 |
error = ACEXE(run,dbc); |
| 70 |
// |
| 71 |
// |
| 72 |
// |
| 73 |
printf("\nClose the connection to the database... \n"); |
| 74 |
dbc->Close(); |
| 75 |
printf("...connection terminated!\n\n"); |
| 76 |
// |
| 77 |
return(error); |
| 78 |
} |