48 m_fileNamePrefix(fileNamePrefix),
49 m_timeInterval(timeInterval)
55 throw std::invalid_argument(
"File name cannot be the empty string. Please pass in a path to a file that can be opened.");
59 throw std::invalid_argument(
"Time interval must be nonnegative. Negative time intervals do not make sense.");
69 std::string home = std::getenv(
"HOME");
89 throw std::invalid_argument(
"Cannot create a tgDataLogger2 without a path to the log file! Please use the constructor that takes a string.");
121 int fileTimeSize = 64;
122 char fileTime [fileTimeSize];
125 currentTime = localtime(&rawtime);
126 strftime(fileTime, fileTimeSize,
"%m%d%Y_%H%M%S", currentTime);
131 std::cout <<
"tgDataLogger2 will be saving data to the file: " << std::endl
137 throw std::runtime_error(
"Log file could not be opened. Usually, this is because the directory you specified does not exist. Check for spelling errors.");
141 tgOutput <<
"tgDataLogger2 started logging at time " << fileTime <<
", with "
143 <<
" senseable objects." << std::endl;
153 for (std::size_t i=0; i <
m_sensors.size(); i++) {
155 std::vector<std::string> headings =
m_sensors[i]->getSensorDataHeadings();
157 for (std::size_t j=0; j < headings.size(); j++) {
160 tgOutput << i <<
"_" << headings[j] <<
",";
200 throw std::invalid_argument(
"dt is not positive");
215 for (
size_t i=0; i <
m_sensors.size(); i++) {
217 std::vector<std::string> sensordata =
m_sensors[i]->getSensorData();
219 for (std::size_t j=0; j < sensordata.size(); j++) {
243 std::ostringstream os;
245 <<
"This tgDataManager is a tgDataLogger2. " << std::endl;
Constains definition of abstract class tgSensor, which defines the methods that a sensor must impleme...
std::vector< tgSensor * > m_sensors
std::ostream & operator<<(std::ostream &os, const tgModel &obj)
Contains the definition of class tgDataLogger2.
virtual std::string toString() const
std::string m_fileNamePrefix
std::vector< tgSenseable * > m_senseables
virtual std::string toString() const
virtual void step(double dt)