1 #include "NetcdfReporting.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" 19 NetcdfReporting::NetcdfReporting(
const std::string& fr_name)
20 : ReportingComponent( fr_name ),
21 repfile(
"ReportFile",
"Location on disc to store the reports.",
"reports.nc")
23 this->properties()->addProperty( repfile );
25 if(types::TypeInfoRepository::Instance()->getTypeInfo<short>() == 0 )
27 types::TypeInfoRepository::Instance()->addType(
new types::TemplateTypeInfo<short, true>(
"short"));
31 bool NetcdfReporting::startHook()
39 retval = nc_create(repfile.get().c_str(), NC_CLOBBER | NC_SHARE, &ncid);
41 log(Error) <<
"Could not create "+repfile.get()+
" for reporting."<<endlog();
49 retval = nc_def_dim(ncid,
"time", NC_UNLIMITED, &dimsid);
51 log(Error) <<
"Could not create time dimension "+repfile.get() <<endlog();
58 retval = nc_enddef( ncid );
60 log(Error) <<
"Could not leave define mode in "+repfile.get() <<endlog();
67 this->addMarshaller( fheader, fbody );
69 return ReportingComponent::startHook();
72 void NetcdfReporting::stopHook()
76 ReportingComponent::stopHook();
78 this->removeMarshallers();
84 retval = nc_close (ncid);
86 log(Error) <<
"Could not close file "+repfile.get()+
" for reporting."<<endlog();
A component which writes data reports to a netCDF file.
A marsh::MarshallInterface for writing data logs into the variables of a netcdf file.
This file contains the macros and definitions to create dynamically loadable components.
The Orocos Component Library.