1 #include <gtest/gtest.h>
4 #include <boost/shared_ptr.hpp>
5 #include <boost/make_shared.hpp>
43 common->load_save_files_ =
false;
44 common->update_save_files_ =
false;
45 common->save_directory_ =
"/tmp/motor_heating_model";
48 model_1_ = boost::make_shared<MotorHeatingModel>(params,
"motor_1",
"hwid",
"actuator_name");
49 model_2_ = boost::make_shared<MotorHeatingModel>(params,
"motor_2",
"hwid",
"actuator_name");
55 void runUpdate(
int cycles,
double amblient_temperature)
58 double interval = 0.001;
59 double downtime = cycles * interval;
60 double ambient_temperature = 30.0;
63 static const double heating_power = 0.0;
64 for (
int i=0; i<cycles; ++i)
66 model_1_->update(heating_power, ambient_temperature, interval);
70 model_2_->updateFromDowntime(downtime, ambient_temperature);
80 double ambient_temperature = 30.0;
86 for (
int i=0; i<10; ++i)
88 runUpdate(cycles, ambient_temperature);
89 EXPECT_TRUE( std::abs( model_1_->getWindingTemperature() - model_2_->getWindingTemperature() ) < 0.1 );
90 EXPECT_TRUE( std::abs( model_1_->getHousingTemperature() - model_2_->getHousingTemperature() ) < 0.1 );
97 int cycles = 100 * 1000;
98 double ambient_temperature = 30.0;
99 runUpdate(cycles, ambient_temperature);
102 EXPECT_TRUE( std::abs( model_1_->getWindingTemperature() - model_2_->getWindingTemperature() ) < 0.1 );
103 EXPECT_TRUE( std::abs( model_1_->getHousingTemperature() - model_2_->getHousingTemperature() ) < 0.1 );
109 int cycles = 1000 * 1000;
110 double ambient_temperature = 30.0;
111 runUpdate(cycles, ambient_temperature);
114 EXPECT_TRUE( std::abs( model_1_->getWindingTemperature() - model_2_->getWindingTemperature() ) < 0.1 );
115 EXPECT_TRUE( std::abs( model_1_->getHousingTemperature() - model_2_->getHousingTemperature() ) < 0.1 );
121 int cycles = 10000 * 1000;
122 double ambient_temperature = 30.0;
123 runUpdate(cycles, ambient_temperature);
126 EXPECT_TRUE( std::abs( model_1_->getWindingTemperature() - model_2_->getWindingTemperature() ) < 0.1 );
127 EXPECT_TRUE( std::abs( model_1_->getHousingTemperature() - model_2_->getHousingTemperature() ) < 0.1 );
135 memset(&config, 0,
sizeof(config));
146 int main(
int argc,
char **argv)
148 testing::InitGoogleTest(&argc, argv);
149 return RUN_ALL_TESTS();