void ShaftsDriveline4WD::Create(const rapidjson::Document& d) { // Read top-level data. assert(d.HasMember("Type")); assert(d.HasMember("Template")); assert(d.HasMember("Name")); SetName(d["Name"].GetString()); // Get shaft directions. assert(d.HasMember("Shaft Direction")); SetMotorBlockDirection(loadVector(d["Shaft Direction"]["Motor Block"])); SetAxleDirection(loadVector(d["Shaft Direction"]["Axle"])); // Read shaft inertias. assert(d.HasMember("Shaft Inertia")); m_driveshaft_inertia = d["Shaft Inertia"]["Driveshaft"].GetDouble(); m_frontshaft_inertia = d["Shaft Inertia"]["Front Driveshaft"].GetDouble(); m_rearshaft_inertia = d["Shaft Inertia"]["Rear Driveshaft"].GetDouble(); m_central_differentialbox_inertia = d["Shaft Inertia"]["Central Differential Box"].GetDouble(); m_front_differentialbox_inertia = d["Shaft Inertia"]["Front Differential Box"].GetDouble(); m_rear_differentialbox_inertia = d["Shaft Inertia"]["Rear Differential Box"].GetDouble(); // Read gear ratios. assert(d.HasMember("Gear Ratio")); m_front_conicalgear_ratio = d["Gear Ratio"]["Front Conical Gear"].GetDouble(); m_rear_conicalgear_ratio = d["Gear Ratio"]["Rear Conical Gear"].GetDouble(); m_central_differential_ratio = d["Gear Ratio"]["Central Differential"].GetDouble(); m_front_differential_ratio = d["Gear Ratio"]["Front Differential"].GetDouble(); m_rear_differential_ratio = d["Gear Ratio"]["Rear Differential"].GetDouble(); }
void ShaftsDriveline4WD::Create(const rapidjson::Document& d) { // Invoke base class method. ChPart::Create(d); // Get shaft directions. assert(d.HasMember("Shaft Direction")); SetMotorBlockDirection(LoadVectorJSON(d["Shaft Direction"]["Motor Block"])); SetAxleDirection(LoadVectorJSON(d["Shaft Direction"]["Axle"])); // Read shaft inertias. assert(d.HasMember("Shaft Inertia")); m_driveshaft_inertia = d["Shaft Inertia"]["Driveshaft"].GetDouble(); m_frontshaft_inertia = d["Shaft Inertia"]["Front Driveshaft"].GetDouble(); m_rearshaft_inertia = d["Shaft Inertia"]["Rear Driveshaft"].GetDouble(); m_central_differentialbox_inertia = d["Shaft Inertia"]["Central Differential Box"].GetDouble(); m_front_differentialbox_inertia = d["Shaft Inertia"]["Front Differential Box"].GetDouble(); m_rear_differentialbox_inertia = d["Shaft Inertia"]["Rear Differential Box"].GetDouble(); // Read gear ratios. assert(d.HasMember("Gear Ratio")); m_front_conicalgear_ratio = d["Gear Ratio"]["Front Conical Gear"].GetDouble(); m_rear_conicalgear_ratio = d["Gear Ratio"]["Rear Conical Gear"].GetDouble(); m_central_differential_ratio = d["Gear Ratio"]["Central Differential"].GetDouble(); m_front_differential_ratio = d["Gear Ratio"]["Front Differential"].GetDouble(); m_rear_differential_ratio = d["Gear Ratio"]["Rear Differential"].GetDouble(); m_axle_differential_locking_limit = 100; if (d.HasMember("Axle Differential Locking Limit")) { m_axle_differential_locking_limit = d["Axle Differential Locking Limit"].GetDouble(); } m_central_differential_locking_limit = 100; if (d.HasMember("Central Differential Locking Limit")) { m_central_differential_locking_limit = d["Central Differential Locking Limit"].GetDouble(); } }