diff --git a/main.cxx b/main.cxx index 680c18fd18d422d517460ae78c73b191c78635bd..88c617cb66b72f26f8595a50d4c5b4a2a436ce69 100644 --- a/main.cxx +++ b/main.cxx @@ -1,6 +1,10 @@ +#include <fstream> #include <iostream> +#include <iomanip> +#include <string> + #include <vector> -#include <fstream> + #include <productiondatabaseclient.h> #include <boost/program_options.hpp> @@ -20,11 +24,10 @@ int main(int argc, char* argv[]) { ProductionDatabaseClient *proddb = new ProductionDatabaseClient(); - if (debug) cout << "Intitializing apdBatchSetter with version " << proddb->getVersion() << " of the database access libraries." << endl << endl; - readArguments(argc, argv); - if (debug) cout << "Trying to set Batch number " << batchNo << "for ADPs from serial file " << fileName << endl; + if (debug) cout << "Intitialized apdBatchSetter with version " << proddb->getVersion() << " of the database access libraries." << endl << endl + << "Now trying to set Batch number " << batchNo << " for ADPs from serial file " << fileName << endl; vector<string> apdSerials; int nAPDs = 0; @@ -55,7 +58,9 @@ int main(int argc, char* argv[]) proddb->assignBatchNumberToAPDs(apdSerials,batchNo,irradiatedAPDs); - cout << "\nSuccessfully assigned Batch " << batchNo << " to APDs from serial file " << fileName << "!\n\nThank you for using apdBatchSetter :)" << endl << endl; + cout << "\nSuccessfully assigned Batch " << batchNo << " to APDs from serial file " << fileName; + if (irradiatedAPDs) cout << " (after irradiation)"; + cout << "!\n\nThank you for using apdBatchSetter :)" << endl << endl; return (-apdSerials.empty()); } @@ -92,6 +97,7 @@ void readArguments(int m_argc, char* m_argv[]) { string temp = ""; cout << "Have these APDs been irradiated? (yes / no)" << endl; cin >> temp; + cout << endl; if (temp == "yes" || temp == "y") { irradiatedAPDs = true; } @@ -109,11 +115,21 @@ void readArguments(int m_argc, char* m_argv[]) { cout << "Which Batch do these APDs belong to?" << endl; try { cin >> batchNo; + cout << endl; } catch (...) { batchNo = 0; } if (batchNo <= 0) { cerr << "Invalid batch number!" << endl; + exit(-1); + } + if (batchNo < 1000 && irradiatedAPDs) { + cerr << "Batches with irradiated APDs should have batch numbers greater than 10000!" << endl; + exit(-1); + } + if (batchNo >= 1000 && !irradiatedAPDs) { + cerr<< "Batches with batch numbers greather than 10000 have been irradiated!" << endl; + exit(-1); } } if (vm.count("fileName")) {