Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
O
ogs-feliks
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
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
Service Desk
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
Feliks Kiszkurno
ogs-feliks
Commits
60306176
Commit
60306176
authored
12 years ago
by
Tom Fischer
Browse files
Options
Downloads
Patches
Plain Diff
Changed SensorData::addTimeSeries() and used logog logging within class SensorData.
parent
6456e087
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
GeoLib/SensorData.cpp
+25
-19
25 additions, 19 deletions
GeoLib/SensorData.cpp
GeoLib/SensorData.h
+1
-1
1 addition, 1 deletion
GeoLib/SensorData.h
with
26 additions
and
20 deletions
GeoLib/SensorData.cpp
+
25
−
19
View file @
60306176
...
@@ -10,12 +10,16 @@
...
@@ -10,12 +10,16 @@
* Created on 2012-08-01 by Karsten Rink
* Created on 2012-08-01 by Karsten Rink
*/
*/
#include
<cstdlib>
#include
<fstream>
// ThirdParty/logog
#include
"logog/include/logog.hpp"
#include
"SensorData.h"
#include
"SensorData.h"
#include
"StringTools.h"
#include
"StringTools.h"
#include
"DateTools.h"
#include
"DateTools.h"
#include
<cstdlib>
#include
<fstream>
SensorData
::
SensorData
(
const
std
::
string
&
file_name
)
SensorData
::
SensorData
(
const
std
::
string
&
file_name
)
...
@@ -30,7 +34,7 @@ SensorData::SensorData(std::vector<size_t> time_steps)
...
@@ -30,7 +34,7 @@ SensorData::SensorData(std::vector<size_t> time_steps)
for
(
size_t
i
=
1
;
i
<
time_steps
.
size
();
i
++
)
for
(
size_t
i
=
1
;
i
<
time_steps
.
size
();
i
++
)
{
{
if
(
time_steps
[
i
-
1
]
>=
time_steps
[
i
])
if
(
time_steps
[
i
-
1
]
>=
time_steps
[
i
])
std
::
cout
<<
"Error in SensorData() - Time series has no order!"
<<
std
::
endl
;
ERR
(
"Error in SensorData() - Time series has no order!"
)
;
}
}
}
}
...
@@ -51,19 +55,21 @@ void SensorData::addTimeSeries( const std::string &data_name, std::vector<float>
...
@@ -51,19 +55,21 @@ void SensorData::addTimeSeries( const std::string &data_name, std::vector<float>
void
SensorData
::
addTimeSeries
(
SensorDataType
::
type
data_name
,
std
::
vector
<
float
>
*
data
,
const
std
::
string
&
data_unit_string
)
void
SensorData
::
addTimeSeries
(
SensorDataType
::
type
data_name
,
std
::
vector
<
float
>
*
data
,
const
std
::
string
&
data_unit_string
)
{
{
if
(
_step_size
>
0
)
if
(
_step_size
>
0
)
{
{
if
(((
_end
-
_start
)
/
_step_size
)
!=
data
->
size
())
{
if
(((
_end
-
_start
)
/
_step_size
)
!=
data
->
size
())
WARN
(
"Warning in SensorData::addTimeSeries() - Lengths of time series does not match number of time steps."
);
std
::
cout
<<
"Warning in SensorData::addTimeSeries() - Lengths of time series does not match number of time steps."
<<
std
::
endl
;
return
;
}
}
else
if
(
data
->
size
()
!=
_time_steps
.
size
())
}
else
{
std
::
cout
<<
"Warning in SensorData::addTimeSeries() - Lengths of time series does not match number of time steps."
<<
std
::
endl
;
if
(
data
->
size
()
!=
_time_steps
.
size
())
{
else
WARN
(
"Warning in SensorData::addTimeSeries() - Lengths of time series does not match number of time steps."
);
{
return
;
_vec_names
.
push_back
(
data_name
);
}
_data_vecs
.
push_back
(
data
);
_data_unit_string
.
push_back
(
data_unit_string
);
}
}
_vec_names
.
push_back
(
data_name
);
_data_vecs
.
push_back
(
data
);
_data_unit_string
.
push_back
(
data_unit_string
);
}
}
const
std
::
vector
<
float
>*
SensorData
::
getTimeSeries
(
SensorDataType
::
type
time_series_name
)
const
const
std
::
vector
<
float
>*
SensorData
::
getTimeSeries
(
SensorDataType
::
type
time_series_name
)
const
...
@@ -73,18 +79,18 @@ const std::vector<float>* SensorData::getTimeSeries(SensorDataType::type time_se
...
@@ -73,18 +79,18 @@ const std::vector<float>* SensorData::getTimeSeries(SensorDataType::type time_se
if
(
time_series_name
==
_vec_names
[
i
])
if
(
time_series_name
==
_vec_names
[
i
])
return
_data_vecs
[
i
];
return
_data_vecs
[
i
];
}
}
std
::
cout
<<
"Error in SensorData::getTimeSeries() - Time series
\"
"
<<
time_series_name
<<
"
\"
not found."
<<
std
::
endl
;
ERR
(
"Error in SensorData::getTimeSeries() - Time series
\"
%d
\"
not found."
,
time_series_name
)
;
return
NULL
;
return
NULL
;
}
}
const
std
::
string
SensorData
::
getDataUnit
(
SensorDataType
::
type
time_series_name
)
const
std
::
string
SensorData
::
getDataUnit
(
SensorDataType
::
type
time_series_name
)
const
{
{
for
(
size_t
i
=
0
;
i
<
_vec_names
.
size
();
i
++
)
for
(
size_t
i
=
0
;
i
<
_vec_names
.
size
();
i
++
)
{
{
if
(
time_series_name
==
_vec_names
[
i
])
if
(
time_series_name
==
_vec_names
[
i
])
return
_data_unit_string
[
i
];
return
_data_unit_string
[
i
];
}
}
std
::
cout
<<
"Error in SensorData::getDataUnit() - Time series
\"
"
<<
time_series_name
<<
"
\"
not found."
<<
std
::
endl
;
ERR
(
"Error in SensorData::getDataUnit() - Time series
\"
%d
\"
not found."
,
time_series_name
)
;
return
""
;
return
""
;
}
}
...
@@ -94,7 +100,7 @@ int SensorData::readDataFromFile(const std::string &file_name)
...
@@ -94,7 +100,7 @@ int SensorData::readDataFromFile(const std::string &file_name)
if
(
!
in
.
is_open
())
if
(
!
in
.
is_open
())
{
{
std
::
cout
<<
"SensorData::readDataFromFile() - Could not open file
...
\n
"
;
INFO
(
"SensorData::readDataFromFile() - Could not open file
%s."
,
file_name
.
c_str
())
;
return
0
;
return
0
;
}
}
...
...
This diff is collapsed.
Click to expand it.
GeoLib/SensorData.h
+
1
−
1
View file @
60306176
...
@@ -110,7 +110,7 @@ public:
...
@@ -110,7 +110,7 @@ public:
TimeStepType
::
type
getTimeUnit
()
const
{
return
_time_unit
;
};
TimeStepType
::
type
getTimeUnit
()
const
{
return
_time_unit
;
};
/// Returns the data unit of the given time series
/// Returns the data unit of the given time series
const
std
::
string
getDataUnit
(
SensorDataType
::
type
t
)
const
;
std
::
string
getDataUnit
(
SensorDataType
::
type
t
)
const
;
/// Converts Sensor Data Types to Strings
/// Converts Sensor Data Types to Strings
static
std
::
string
convertSensorDataType2String
(
SensorDataType
::
type
t
);
static
std
::
string
convertSensorDataType2String
(
SensorDataType
::
type
t
);
...
...
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