Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
scdaq
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
scouting-demonstrator
scdaq
Commits
6995fe89
Commit
6995fe89
authored
2 years ago
by
Emilio Meschi
Committed by
Thomas Owen James
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
remove all file actions and rationalize passing of arguments
parent
9a1ad056
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/OutputByOrbit.cc
+4
-75
4 additions, 75 deletions
src/OutputByOrbit.cc
with
4 additions
and
75 deletions
src/OutputByOrbit.cc
+
4
−
75
View file @
6995fe89
...
@@ -7,60 +7,22 @@
...
@@ -7,60 +7,22 @@
#include
<string>
#include
<string>
#include
<system_error>
#include
<system_error>
#include
"config.h"
#include
"controls.h"
#include
"log.h"
#include
"log.h"
#include
"slice.h"
#include
"slice.h"
#include
"tools.h"
#include
"tools.h"
/* Defines the journal file. Note: Filename prefix is added making the final
OutputByOrbitStream
::
OutputByOrbitStream
(
ctrl
&
c
,
config
&
conf_
)
* filename */
static
const
std
::
string
journal_file
{
"index.journal"
};
/* Defined where are the files stored before they are moved to the final
* destination */
static
const
std
::
string
working_dir
{
"in_progress"
};
static
void
create_output_directory
(
std
::
string
&
output_directory
)
{
struct
stat
sb
;
/* check if path exists and is a directory */
if
(
stat
(
output_directory
.
c_str
(),
&
sb
)
==
0
)
{
if
(
S_ISDIR
(
sb
.
st_mode
))
{
// output directory already exists
return
;
}
std
::
string
err
=
"ERROR The output directory path '"
+
output_directory
+
"' exists, but the path is not a directory!"
;
LOG
(
ERROR
)
<<
err
;
throw
std
::
runtime_error
(
err
);
}
if
(
!
tools
::
filesystem
::
create_directories
(
output_directory
))
{
std
::
string
err
=
tools
::
strerror
(
"ERROR when creating the output directory '"
+
output_directory
+
"'"
);
LOG
(
ERROR
)
<<
err
;
throw
std
::
runtime_error
(
err
);
}
LOG
(
TRACE
)
<<
"Created output directory: "
<<
output_directory
<<
"'."
;
}
OutputByOrbitStream
::
OutputByOrbitStream
(
const
std
::
string
output_filename_base
,
const
std
::
string
output_filename_prefix
,
ctrl
&
c
,
config
&
conf_
)
:
tbb
::
filter
(
serial_in_order
),
:
tbb
::
filter
(
serial_in_order
),
my_output_filename_base
(
output_filename_base
),
my_output_filename_prefix
(
output_filename_prefix
),
totcounts
(
0
),
totcounts
(
0
),
current_file_size
(
0
),
current_file_size
(
0
),
file_count
(
-
1
),
file_count
(
-
1
),
control
(
c
),
control
(
c
),
current_run_number
(
0
),
current_run_number
(
0
),
conf
(
conf_
),
conf
(
conf_
),
fixedOrbitsPerFile
(
bool
(
conf
.
getNOrbitsPerFile
())),
output_file_handler_
(
conf
.
getOutputFilenameBase
(),
conf
.
getOutputFilenamePrefix
())
{
outFile
()
{
LOG
(
TRACE
)
<<
"Created output filter at "
<<
static_cast
<
void
*>
(
this
);
LOG
(
TRACE
)
<<
"Created output filter at "
<<
static_cast
<
void
*>
(
this
);
// Create the ouput directory
std
::
string
output_directory
=
my_output_filename_base
+
"/"
+
working_dir
;
create_output_directory
(
output_directory
);
}
}
void
*
OutputByOrbitStream
::
OutputFixedOrbits
(
Slice
&
out
)
{
void
*
OutputByOrbitStream
::
OutputFixedOrbits
(
Slice
&
out
)
{
...
@@ -107,18 +69,6 @@ void *OutputByOrbitStream::operator()(void *item) {
...
@@ -107,18 +69,6 @@ void *OutputByOrbitStream::operator()(void *item) {
return
NULL
;
return
NULL
;
}
}
/*
* Create a properly formatted file name
* TODO: Change to C++
*/
static
std
::
string
format_run_file_stem
(
std
::
string
&
filename_prefix
,
uint32_t
run_number
,
int32_t
file_count
)
{
char
run_order_stem
[
PATH_MAX
];
snprintf
(
run_order_stem
,
sizeof
(
run_order_stem
),
"%s_%06d_%06d.dat"
,
filename_prefix
.
c_str
(),
run_number
,
file_count
);
return
std
::
string
(
run_order_stem
);
}
void
OutputByOrbitStream
::
close_and_move_file
()
// Used for fixedNorbits per
void
OutputByOrbitStream
::
close_and_move_file
()
// Used for fixedNorbits per
// file option
// file option
{
{
...
@@ -137,24 +87,3 @@ void OutputByOrbitStream::close_and_move_file() // Used for fixedNorbits per
...
@@ -137,24 +87,3 @@ void OutputByOrbitStream::close_and_move_file() // Used for fixedNorbits per
}
}
current_run_number
=
control
.
run_number
;
current_run_number
=
control
.
run_number
;
}
}
void
OutputByOrbitStream
::
open_file
(
uint32_t
index_
)
// Used for fixedNorbits per file option
{
// Create a new file
std
::
string
output_directory
=
my_output_filename_base
+
"/"
+
working_dir
;
create_output_directory
(
output_directory
);
std
::
string
current_filename_a
=
output_directory
+
"/"
+
format_run_file_stem
(
my_output_filename_prefix
,
current_run_number
,
index_
);
std
::
string
filename
=
output_directory
+
"/"
+
format_run_file_stem
(
my_output_filename_prefix
,
control
.
run_number
,
index_
);
LOG
(
INFO
)
<<
"opening file with index "
<<
index_
;
outFile
.
setFile
(
fopen
(
filename
.
c_str
(),
"w"
));
outFile
.
setIndex
(
index_
);
if
(
outFile
.
getFile
()
==
NULL
)
{
std
::
string
err
=
tools
::
strerror
(
"ERROR when creating file '"
+
current_filename_a
+
"'"
);
LOG
(
ERROR
)
<<
err
;
throw
std
::
runtime_error
(
err
);
}
}
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