42 tgDataObserver::tgDataObserver(std::string filePrefix) :
45 m_filePrefix(filePrefix)
66 int fileTimeSize = 64;
67 char fileTime [fileTimeSize];
70 currentTime = localtime(&rawtime);
71 strftime(fileTime, fileTimeSize,
"%m%d%Y_%H%M%S.txt", currentTime);
72 m_fileName = m_filePrefix + fileTime;
73 std::cout << m_fileName << std::endl;
75 if (m_dataLogger != NULL)
86 tgOutput.open(m_fileName.c_str());
97 tgOutput <<
"Time" <<
",";
99 for (std::size_t i = 0; i < children.size(); i++)
104 std::stringstream name;
106 if(tgCast::cast<tgModel, tgLinearString>(children[i]) != 0)
108 name << children[i]->getTags() <<
" " << stringNum;
109 tgOutput << name.str() <<
"_RL" <<
","
110 << name.str() <<
"_AL" <<
","
111 << name.str() <<
"_Ten" <<
",";
114 else if(tgCast::cast<tgModel, tgRod>(children[i]) != 0)
116 name << children[i]->getTags() <<
" " << rodNum;
117 tgOutput << name.str() <<
"_X" <<
","
118 << name.str() <<
"_Y" <<
","
119 << name.str() <<
"_Z" <<
","
120 << name.str() <<
"_mass" <<
",";
126 tgOutput << std::endl;
139 tgOutput.open(m_fileName.c_str(), std::ios::app);
140 tgOutput << m_totalTime <<
",";
145 tgOutput.open(m_fileName.c_str(), std::ios::app);
146 tgOutput << std::endl;
Contains the definition of interface class tgDataLogger.
Convenience function for combining strings with ints, mostly for naming structures.
Utility class for class casting and filtering collections by type.
virtual void onVisit(const tgModelVisitor &r) const
Contains the definition of class tgModel. $Id$.
Contains the definition of class tgLinearString.
Definition of tgObserver class.
virtual void onStep(tgModel &model, double dt)
virtual void onSetup(tgModel &model)
Contains the definition of class tgRod $Id$.
virtual ~tgDataObserver()
std::vector< tgModel * > getDescendants() const