00001 // Transmission.h - a gearbox for the drivetrain. 00002 // 00003 // Copyright (C) 2001--2004 Sam Varner 00004 // 00005 // This file is part of Vamos Automotive Simulator. 00006 // 00007 // This program is free software; you can redistribute it and/or modify 00008 // it under the terms of the GNU General Public License as published by 00009 // the Free Software Foundation; either version 2 of the License, or 00010 // (at your option) any later version. 00011 // 00012 // This program is distributed in the hope that it will be useful, 00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00015 // GNU General Public License for more details. 00016 // 00017 // You should have received a copy of the GNU General Public License 00018 // along with this program; if not, write to the Free Software 00019 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00020 00021 #ifndef _TRANSMISSION_H_ 00022 #define _TRANSMISSION_H_ 00023 00024 #include <map> 00025 00026 namespace Vamos_Body 00027 { 00028 //* A gearbox for the drivetrain. 00029 class Transmission 00030 { 00031 // A map of gears to gear ratios. Neutral has a key of 0. 00032 // Reverse gears have negative keys. 00033 std::map <int, double> m_gear_ratios; 00034 00035 // The number of consecutive forward gears. Any non-consecutive 00036 // gears are inaccessible. 00037 int m_forward_gears; 00038 00039 // The number of consecutive reverse gears. Any non-consecutive 00040 // gears are inaccessible. 00041 int m_reverse_gears; 00042 00043 // The current gear. 00044 int m_gear; 00045 00046 // The rotational speed at the clutch side of the transmission. 00047 double m_clutch_speed; 00048 00049 public: 00050 //** Constructors 00051 00052 // Let the program calulate equally-spaced 00053 Transmission (int forward_gears, double first_ratio, double last_ratio); 00054 00055 Transmission (); 00056 00057 // Shift to a particular gear. 00058 void shift (int gear); 00059 00060 // Set the gear ratio for GEAR. RATIO is (driveshaft speed) / 00061 // (engine speed). Forward gears have positive ratios, usually > 00062 // 1.0. Neutral has a rato of 0.0, unless you change it. 00063 void gear_ratio (int gear, double ratio); 00064 00065 // Return the torque on the driveshaft due to friction at the 00066 // clutch. 00067 double torque (double drag); 00068 00069 // Return the current gear. 00070 int gear () const { return m_gear; } 00071 00072 // Return the number of consecutive forward gears. 00073 int forward_gears () const { return m_forward_gears; } 00074 00075 // Return the number of consecutive reverse gears. 00076 int reverse_gears () const { return m_reverse_gears; } 00077 00078 // Tell the transmission what the rotational speed of the 00079 // driveshaft is. 00080 void set_driveshaft_speed (double speed); 00081 00082 // Return the rotational speed at the clutch side of the 00083 // transmission. 00084 double clutch_speed () const { return m_clutch_speed; } 00085 00086 void set_clutchspeed(double ncs) {m_clutch_speed = ncs;} 00087 }; 00088 } 00089 00090 #endif // not _TRANSMISSION_H_
1.4.6