22 #include "MACollectedData.hpp" 24 #include <MCBinaryData.hpp> 25 #include <MCDataContainer.hpp> 29 const std::string& variable_map) :
32 MC::DataContainerSPtr Container =
DataStorage->CreateContainer(
"UserData");
48 MC::DataContainerSPtr Container =
DataStorage->GetContainer(
"UserData");
50 return *
reinterpret_cast<int*
>(Container->GetData(
"CollectionID")->DataPtr);
56 MC::DataContainerSPtr Container =
DataStorage->GetContainer(
"UserData");
58 return *
reinterpret_cast<int*
>(Container->GetData(
"SessionID")->DataPtr);
64 if (data_name.empty())
67 MC::DataContainerSPtr Container =
DataStorage->GetContainer(
"UserData");
75 MC::DataContainerSPtr Container =
DataStorage->GetContainer(
"UserData");
78 if (DataItem && MCGetClassName<MCBinaryData>() == DataItem->TypeName)
82 *BinaryData = *
reinterpret_cast<MCBinaryData*
>(DataItem->DataPtr);
103 MC::StringList ContainerNames =
DataStorage->GetContainerNames();
105 for (
unsigned int i = 0; i < ContainerNames.size(); ++i)
107 MC_LOG(
"%s: %d items", ContainerNames[i].c_str(),
108 DataStorage->GetContainer(ContainerNames[i])->GetAllData().size());
115 MC::DataContainerSPtr Container =
DataStorage->GetContainer(
"UserData");
117 return *
reinterpret_cast<std::string*
>(Container->GetData(
"RobotStateVariableMap")->DataPtr);
123 if (name ==
"UserData")
125 MC_WARNING(
"UserData container cannot store collected data.");
128 MC::DataContainerSPtr DataContainer =
DataStorage->GetContainer(name);
130 if (!DataContainer.get())
132 DataContainer =
DataStorage->CreateContainer(name);
141 MC::DataContainerSPtr DataContainer =
DataStorage->GetContainer(type_name);
143 if (!DataContainer.get())
145 MC_WARNING(
"Data type is not collected (%s)\n", type_name.c_str());
146 return MA::BinaryDataPtrList();
148 MA::BinaryDataPtrList CollectedData;
149 const MC::DataItemBasePtrList& DataItems = DataContainer->GetAllData();
151 for (
auto& item : DataItems)
153 if (item->TypeName ==
"MCBinaryData")
155 CollectedData.push_back(reinterpret_cast<MCBinaryData*>(item->DataPtr));
158 return CollectedData;
177 return CollectedData;
MA::BinaryDataPtrList GetAllDataByTypeName(const std::string &type_name)
Get all data by type name.
Collected data with portable storage functions.
A helper class to fill the type info to the base structure.
std::string GetName() const
Get name.
void MakeCompact()
Compress the collected data if it has not been done.
#define MC_WARNING(...)
Warning macro.
Data container item base structure to store basic type info.
int GetCollectionID()
Get collection ID.
std::string MCToStr(const T value, bool hex_manipulator=false)
Convert an other type to string with std::stringstream.
static MCDataStorage * Decode(const MCBinaryData &data, bool portable=false)
Load the data storage from binary form.
void PrintSummary()
Print summary of the collected data.
MCBinaryData * GetCustomData(const std::string &data_name)
Get custom data.
static MACollectedData * Decode(const MCBinaryData &data)
Decode from binary data.
bool IsCompact() const
Check if the collected data is compressed.
MCBinaryData * Encode() const
Encode into binary data.
const std::string & GetRobotStateVariableMap() const
Get robot state variable map.
Data storage with file support.
void AddNewData(const std::string &name, int cycle_id, const MCBinaryData &data)
Add new data to the current cycle container.
boost::scoped_ptr< MCDataStorage > DataStorage
Data storage of all collected data.
MACollectedData(const int session_id, const std::string &name, const int id, const std::string &variable_map)
Class constructor.
int GetSessionID()
Get session ID.
#define MC_LOG(...)
Debug macro.
void SetCustomData(const std::string &data_name, const MCBinaryData &data_value)
Add custom data.