Skip to content
Snippets Groups Projects
Commit 89d5e0dd authored by Jan Reher's avatar Jan Reher
Browse files

Minor changes

parent d3a5a1de
No related branches found
No related tags found
No related merge requests found
#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")) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment