From a819eb04d1155a0efc964972cf2c46af79511040 Mon Sep 17 00:00:00 2001 From: Jan Reher <jreher@ep1.rub.de> Date: Fri, 15 Nov 2019 11:00:23 +0100 Subject: [PATCH] Made apdSetInfoGiessen.cpp file from copying and included it in CMakeLists.txt. Not working yet! --- CMakeLists.txt | 2 + apdSetInfoGiessen.cpp | 107 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 109 insertions(+) create mode 100644 apdSetInfoGiessen.cpp diff --git a/CMakeLists.txt b/CMakeLists.txt index bd1151d..3544503 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,7 @@ add_executable(setArrivalForIrradiation "apdsetarrivalforirradiation.cpp") add_executable(setSentForAnalysisAfterIrradiation "apdSetSentForAnalysisAfterIrradiation.cpp") add_executable(setIrradiationInfo "apdSetIrradiationInfo.cpp") add_executable(setAnnealingInfo "apdSetAnnealingInfo.cpp") +add_executable(setInfoGiessen "apdSetInfoGiessen.cpp") add_executable(apdBoxSetter "apdboxsetter.cpp") add_executable(getLocations "getlocations.cpp") add_executable(getBatch "getbatch.cpp") @@ -44,4 +45,5 @@ target_link_libraries(setArrivalForIrradiation proddbclient boost_program_option target_link_libraries(setSentForAnalysisAfterIrradiation proddbclient boost_program_options Qt5::Gui Qt5::Widgets) target_link_libraries(setIrradiationInfo proddbclient boost_program_options Qt5::Gui Qt5::Widgets) target_link_libraries(setAnnealingInfo proddbclient boost_program_options Qt5::Gui Qt5::Widgets) +target_link_libraries(setInfoGiessen proddbclient boost_program_options Qt5::Gui Qt5::Widgets) diff --git a/apdSetInfoGiessen.cpp b/apdSetInfoGiessen.cpp new file mode 100644 index 0000000..c0eb1d6 --- /dev/null +++ b/apdSetInfoGiessen.cpp @@ -0,0 +1,107 @@ +#include <fstream> +#include <iostream> +#include <iomanip> +#include <string> +#include <vector> + +#include <productiondatabaseclient.h> +#include <boost/program_options.hpp> +#include "toolbox.cpp" +#include "BulkDbAccess.h" + +#include "QtGui/QApplication" + +namespace po=boost::program_options; +using namespace std; +using namespace ProductionDatabase; + +static string fileName = "serials.dat"; +static string username = ""; +static string password = ""; + +static string arrivalDate = "1970-01-01"; +static string irradiationDate = "1970-01-01"; +static string annealingDate = "1970-01-01"; +static string sentBackDate = "1970-01-01"; + +static double irradiationDose = -1; +static double irradiationTemp = -300; + +static double annealingTemp = -300; +static double annealingTime = -1; + +static string change = ""; +static bool debug = false; + +void processArgumentsAndQueryMissing(int m_argc, char* m_argv[]) { + po::options_description desc("Available options"); + desc.add_options() + ("help", "produce help message") + ("fileName", po::value<string>(), "file name for serial numbers [serials.dat]") + ("user", po::value<string>(), "User name to connect to DB. Only used when combined with pass!") + ("pass", po::value<string>(), "Password to connect to DB. Only used when combined with user!") + ("day", po::value<short>(), "Day of arrival") + ("month", po::value<short>(), "Month of arrival") + ("year", po::value<short>(), "Year of arrival") + ("dose", po::value<double>(), "Irradiation dose to enter") + ("temp", po::value<double>(), "Temperature during irradiation") + ("debug", "emit additional messages for debugging purposes") + ; + + po::variables_map vm; + po::store(po::parse_command_line(m_argc, m_argv, desc), vm); + po::notify(vm); + + if (vm.count("help")) { + cout << desc << "\n"; + exit(0); + } + if (vm.count("fileName")) { + fileName = vm["fileName"].as<string>(); + cout << "Reading serials from " << fileName << endl; + } + if (vm.count("user")) { + username = vm["user"].as<string>(); + } + if (vm.count("pass")) { + password = vm["pass"].as<string>(); + } + + if (vm.count("debug")) { + debug = true; + } +} + +int main(int argc, char* argv[]) { + QApplication *_app = new QApplication(argc, argv); + + processArgumentsAndQueryMissing(argc, argv); + + vector<string> apdSerials; + + apdSerials = loadSerialsFromFileName(fileName); + + if ( apdSerials.size() == 0 ) { + cout << "No data to write! Exiting." << endl; + return 0; + } + cout << "Data will be written for " << apdSerials.size() << " APDs." << endl; + + ProductionDatabaseClient *_proddbclient = new ProductionDatabaseClient(); + + if (username == "" || password == "") _proddbclient->queryCredentials(); + else _proddbclient->setCredentials(username, password); + DatabaseClientResponse response = _proddbclient->checkConnectivityAndCredentials(); + if (response != Successful ) { + cerr << "Connection to database failed because of error: " << response << endl; + return response; + } + if (debug) cout << "Connection successful!" << endl; + + _proddbclient->storeApdIrradiationInfo(apdSerials,dose, temp, irradiationDay,irradiationMonth,irradiationYear); + + cout << "\nSuccessfully entered irradiation with " << dose << " Gy at " << temp << "degrees celsius on " << irradiationDay << "." << irradiationMonth << "." << irradiationYear << " to APDs from serial file " << fileName << "!\n\nThank you for using the ApdToolbox! :)" << endl << endl; + + _app->exit(0); + return (-apdSerials.empty()); +} -- GitLab