Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
A
Apd Toolbox
Manage
Activity
Members
Labels
Plan
Issues
1
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Jan Reher
Apd Toolbox
Commits
3aac9e99
Commit
3aac9e99
authored
4 years ago
by
Jan Reher
Browse files
Options
Downloads
Patches
Plain Diff
Creation of unit Creator files as copy from BoxSetter
parent
92a06f27
No related branches found
Branches containing commit
No related tags found
2 merge requests
!4
Many proven updates being brought into stable branch.
,
!3
Commented in the lines in apdUnitCreator.cpp that do the actual database
Pipeline
#1592
failed with stages
in 2 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
CMakeLists.txt
+2
-0
2 additions, 0 deletions
CMakeLists.txt
apdUnitCreator.cpp
+138
-0
138 additions, 0 deletions
apdUnitCreator.cpp
with
140 additions
and
0 deletions
CMakeLists.txt
+
2
−
0
View file @
3aac9e99
...
...
@@ -26,6 +26,7 @@ add_executable(getU100 "getu100.cxx")
add_executable
(
makeSerialList
"makeseriallist.cxx"
)
add_executable
(
makeGridList
"makeGridList.cxx"
)
add_executable
(
getIrradiationDose
"getirradiationstatus.cxx"
)
add_executable
(
apdUnitCreator
"apdUnitCreator.cpp"
)
add_executable
(
testXmlStructure
"testxmlstructure.cxx"
)
...
...
@@ -35,6 +36,7 @@ target_link_libraries(proddbaccess Qt5::Network Qt5::Core Qt5::Xml)
target_link_libraries
(
apdBatchSetter proddbaccess proddbclient boost_program_options
)
target_link_libraries
(
apdBoxSetter proddbaccess proddbclient boost_program_options
)
target_link_libraries
(
apdUnavailableSetter proddbaccess proddbclient boost_program_options
)
target_link_libraries
(
apdUnitCreator
)
target_link_libraries
(
getLocations proddbaccess boost_program_options
)
target_link_libraries
(
getBatch proddbaccess boost_program_options
)
target_link_libraries
(
getIrradiationDose proddbaccess boost_program_options
)
...
...
This diff is collapsed.
Click to expand it.
apdUnitCreator.cpp
0 → 100644
+
138
−
0
View file @
3aac9e99
#include
<fstream>
#include
<iostream>
#include
<iomanip>
#include
<string>
#include
<vector>
#include
<productiondatabaseclient.h>
#include
<boost/program_options.hpp>
using
namespace
std
;
using
namespace
ProductionDatabase
;
namespace
po
=
boost
::
program_options
;
static
string
fileName
=
"serials.dat"
;
static
int
boxNo
=
0
;
static
bool
debug
=
false
;
static
string
username
=
""
;
static
string
password
=
""
;
static
vector
<
string
>
apdSerials
;
static
std
::
vector
<
int
>
boxes
;
static
std
::
vector
<
int
>
positions
;
void
processArgumentsAndQueryMissing
(
int
m_argc
,
char
*
m_argv
[]);
void
loadSerialsFromFileName
(
string
m_fileName
,
bool
m_debug
=
false
);
int
main
(
int
argc
,
char
*
argv
[])
{
ProductionDatabaseClient
*
proddb
=
new
ProductionDatabaseClient
();
processArgumentsAndQueryMissing
(
argc
,
argv
);
if
(
debug
)
cout
<<
"Intitialized apdBoxSetter with version "
<<
proddb
->
getVersion
()
<<
" of the database access libraries."
<<
endl
<<
endl
<<
"Now trying to set Batch number "
<<
boxNo
<<
" for ADPs from serial file "
<<
fileName
<<
endl
;
loadSerialsFromFileName
(
fileName
);
if
(
username
==
""
||
password
==
""
)
proddb
->
queryCredentials
();
else
proddb
->
setCredentials
(
username
,
password
);
DatabaseClientResponse
response
=
proddb
->
checkConnectivityAndCredentials
();
if
(
response
!=
Successful
)
{
cerr
<<
"Connection to database failed because of error: "
<<
response
<<
endl
;
return
response
;
}
if
(
debug
)
cout
<<
"Connection successful!"
<<
endl
;
proddb
->
storeApdBoxNumber
(
apdSerials
,
boxes
,
positions
);
cout
<<
"
\n
Box "
<<
boxNo
<<
" was successfully assigned to APDs from serial file "
<<
fileName
<<
". At least I hope so. In any case, something happened for "
<<
apdSerials
.
size
()
<<
" APDs."
<<
"
\n
Thank you for using apdBoxSetter! :)"
<<
endl
<<
endl
;
return
(
-
apdSerials
.
empty
());
}
void
processArgumentsAndQueryMissing
(
int
m_argc
,
char
*
m_argv
[])
{
po
::
options_description
desc
(
"Available options"
);
desc
.
add_options
()
(
"help"
,
"produce help message"
)
(
"type"
,
po
::
value
<
string
>
(),
"(required) type of APDs [new, irr]"
)
(
"box"
,
po
::
value
<
int
>
(),
"(required) box number to be assigned"
)
(
"fileName"
,
po
::
value
<
string
>
(),
"file name or serial numbers [serials.dat]"
)
(
"debug"
,
"emit additional messages for debugging purposes"
)
(
"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!"
)
;
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
(
"box"
))
{
boxNo
=
int
(
vm
[
"box"
].
as
<
int
>
());
}
else
{
cout
<<
"Which box should these APDs be assigned to?"
<<
endl
;
try
{
cin
>>
boxNo
;
cout
<<
endl
;
}
catch
(...)
{
boxNo
=
0
;
}
if
(
boxNo
<=
0
)
{
cerr
<<
"Invalid batch number!"
<<
endl
;
exit
(
-
1
);
}
}
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
;
}
}
void
loadSerialsFromFileName
(
string
m_fileName
,
bool
m_debug
)
{
ifstream
in
(
m_fileName
.
c_str
());
if
(
!
in
.
good
())
{
cerr
<<
"Could not load serials. Does the input file exist?"
<<
endl
;
exit
(
0
);
}
apdSerials
.
clear
();
positions
.
clear
();
boxes
.
clear
();
int
pos
=
1
;
string
line
=
""
;
while
(
in
.
good
())
{
getline
(
in
,
line
);
if
(
line
.
length
()
==
0
||
!
isdigit
(
line
[
0
]))
{
pos
++
;
continue
;
}
apdSerials
.
push_back
(
line
);
boxes
.
push_back
(
boxNo
);
positions
.
push_back
(
pos
++
);
if
(
m_debug
)
cout
<<
"Found serial: "
<<
line
<<
endl
;
}
if
(
apdSerials
.
size
()
!=
positions
.
size
()
||
apdSerials
.
size
()
!=
boxes
.
size
())
{
cerr
<<
"ERROR: Array sizes don't match!"
<<
endl
;
apdSerials
.
clear
();
boxes
.
clear
();
positions
.
clear
();
return
;
}
cerr
<<
"Found "
<<
apdSerials
.
size
()
<<
" APDs"
<<
endl
;
return
;
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment