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)
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;
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;
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;
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();
double winding_thermal_time_constant_
Thermal time constant of motor winding : in seconds.
TEST(MotorHeatingModelParametersEepromConfig, SelfConsistantCRC)
TEST_F(UpdateFromDowntimeTest, DowntimeUpdate10Seconds)
bool verifyCRC(void) const
MotorHeatingModelParameters casterMotorHeatingModelParams()
boost::shared_ptr< MotorHeatingModel > model_2_
double winding_to_housing_thermal_resistance_
Thermal resistance between motor winding and motor housing : in C/Watt.
void runUpdate(int cycles, double amblient_temperature)
double housing_thermal_time_constant_
Thermal time constant of motor housing : in seconds.
int main(int argc, char **argv)
double max_winding_temperature_
temperature limit of motor windings : in Celcius
boost::shared_ptr< MotorHeatingModel > model_1_
double housing_to_ambient_thermal_resistance_
Thermal resistance between motor housing and ambient : in C/Watt.