Main Page
Related Pages
Namespaces
Classes
Files
File List
File Members
reporting
NetcdfReporting.cpp
Go to the documentation of this file.
1
#include "
NetcdfReporting.hpp
"
2
#include <
rtt/RTT.hpp
>
3
#include <
rtt/Logger.hpp
>
4
#include <rtt/types/Types.hpp>
5
#include <
rtt/types/TemplateTypeInfo.hpp
>
6
#include "
NetcdfMarshaller.hpp
"
7
#include "
NetcdfHeaderMarshaller.hpp
"
8
9
#include "
ocl/Component.hpp
"
10
ORO_CREATE_COMPONENT
(
OCL::NetcdfReporting
)
11
12
#include <netcdf.h>
13
14
namespace
OCL
15
{
16
using namespace
RTT
;
17
using namespace
std
;
18
19
NetcdfReporting::NetcdfReporting
(
const
std::string& fr_name)
20
:
ReportingComponent
( fr_name ),
21
repfile(
"ReportFile"
,
"Location on disc to store the reports."
,
"reports.nc"
)
22
{
23
this->
properties
()->
addProperty
(
repfile
);
24
25
if
(types::TypeInfoRepository::Instance()->getTypeInfo<short>() == 0 )
26
{
27
types::TypeInfoRepository::Instance()->addType(
new
types::TemplateTypeInfo<short, true>
(
"short"
));
28
}
29
}
30
31
bool
NetcdfReporting::startHook
()
32
{
33
int
retval;
34
39
retval = nc_create(
repfile
.
get
().c_str(), NC_CLOBBER | NC_SHARE, &
ncid
);
40
if
( retval ) {
41
log(
Error
) <<
"Could not create "
+
repfile
.
get
()+
" for reporting."
<<endlog();
42
return
false
;
43
}
44
49
retval = nc_def_dim(
ncid
,
"time"
, NC_UNLIMITED, &
dimsid
);
50
if
( retval ) {
51
log(
Error
) <<
"Could not create time dimension "
+
repfile
.
get
() <<endlog();
52
return
false
;
53
}
54
58
retval = nc_enddef(
ncid
);
59
if
( retval ) {
60
log(
Error
) <<
"Could not leave define mode in "
+
repfile
.
get
() <<endlog();
61
return
false
;
62
}
63
64
fheader
=
new
RTT::NetcdfHeaderMarshaller
(
ncid
,
dimsid
);
65
fbody
=
new
RTT::NetcdfMarshaller
(
ncid
);
66
67
this->
addMarshaller
(
fheader
,
fbody
);
68
69
return
ReportingComponent::startHook
();
70
}
71
72
void
NetcdfReporting::stopHook
()
73
{
74
int
retval;
75
76
ReportingComponent::stopHook
();
77
78
this->
removeMarshallers
();
79
83
if
(
ncid
)
84
retval = nc_close (
ncid
);
85
if
( retval )
86
log(
Error
) <<
"Could not close file "
+
repfile
.
get
()+
" for reporting."
<<endlog();
87
}
88
89
}
OCL::NetcdfReporting
Definition:
NetcdfReporting.hpp:13
OCL::NetcdfReporting::stopHook
void stopHook()
Definition:
NetcdfReporting.cpp:72
RTT::Property::get
DataSourceType get() const
OCL::NetcdfReporting::fheader
RTT::marsh::MarshallInterface * fheader
Definition:
NetcdfReporting.hpp:32
NetcdfReporting.hpp
RTT::NetcdfMarshaller
Definition:
NetcdfMarshaller.hpp:20
OCL::ReportingComponent::addMarshaller
bool addMarshaller(RTT::marsh::MarshallInterface *headerM, RTT::marsh::MarshallInterface *bodyM)
Definition:
ReportingComponent.cpp:222
RTT::types::TemplateTypeInfo
OCL::NetcdfReporting::dimsid
int dimsid
Definition:
NetcdfReporting.hpp:30
OCL::ReportingComponent::startHook
virtual bool startHook()
Definition:
ReportingComponent.cpp:547
OCL::NetcdfReporting::ncid
int ncid
Definition:
NetcdfReporting.hpp:26
OCL::NetcdfReporting::NetcdfReporting
NetcdfReporting(const std::string &fr_name)
Definition:
NetcdfReporting.cpp:19
RTT::NetcdfHeaderMarshaller
Definition:
NetcdfHeaderMarshaller.hpp:20
std
OCL::NetcdfReporting::fbody
RTT::marsh::MarshallInterface * fbody
Definition:
NetcdfReporting.hpp:33
Logger.hpp
OCL::NetcdfReporting::repfile
RTT::Property< std::string > repfile
Definition:
NetcdfReporting.hpp:21
Component.hpp
RTT::PropertyBag::addProperty
Property< T > & addProperty(const std::string &name, T &attr)
OCL::ReportingComponent::removeMarshallers
bool removeMarshallers()
Definition:
ReportingComponent.cpp:237
OCL::ReportingComponent::stopHook
virtual void stopHook()
Definition:
ReportingComponent.cpp:698
OCL
Definition:
deployer-funcs.cpp:68
TemplateTypeInfo.hpp
Error
Error
OCL::ReportingComponent
A Component for periodically reporting Component Port contents to a human readable text format...
Definition:
ReportingComponent.hpp:81
RTT::TaskContext::properties
PropertyBag * properties()
NetcdfHeaderMarshaller.hpp
RTT
RTT.hpp
NetcdfMarshaller.hpp
OCL::NetcdfReporting::startHook
bool startHook()
Definition:
NetcdfReporting.cpp:31
ORO_CREATE_COMPONENT
ORO_CREATE_COMPONENT(OCL::logging::Log4cxxAppender)
ocl
Author(s): OCL Development Team
autogenerated on Mon Mar 23 2020 04:47:19