Alexander Afanasyev | 7dbdcaf | 2011-12-13 21:40:37 -0800 | [diff] [blame] | 1 | /* -*- Mode:C++; c-file-style:"gnu"; indent-tabs-mode:nil; -*- */ |
| 2 | /* |
| 3 | * Copyright (c) 2006, 2007 INRIA |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify |
| 6 | * it under the terms of the GNU General Public License version 2 as |
| 7 | * published by the Free Software Foundation; |
| 8 | * |
| 9 | * This program is distributed in the hope that it will be useful, |
| 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 12 | * GNU General Public License for more details. |
| 13 | * |
| 14 | * You should have received a copy of the GNU General Public License |
| 15 | * along with this program; if not, write to the Free Software |
| 16 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 17 | * |
| 18 | * Author: |
| 19 | */ |
| 20 | #ifndef SPRING_MOBILITY_MODEL_H |
| 21 | #define SPRING_MOBILITY_MODEL_H |
| 22 | |
| 23 | #include "ns3/mobility-model.h" |
| 24 | #include "ns3/nstime.h" |
| 25 | #include "ns3/event-id.h" |
| 26 | |
| 27 | namespace ns3 { |
| 28 | |
| 29 | /** |
| 30 | * \ingroup mobility |
| 31 | * |
| 32 | * \brief |
| 33 | */ |
| 34 | class SpringMobilityModel : public MobilityModel |
| 35 | { |
| 36 | public: |
| 37 | static TypeId GetTypeId (void); |
| 38 | |
| 39 | /** |
| 40 | * Create a position located at coordinates (0,0,0) with velocity (0,0,0) |
| 41 | */ |
| 42 | SpringMobilityModel (); |
| 43 | virtual ~SpringMobilityModel (); |
| 44 | |
| 45 | /** |
| 46 | * \brief Attach node by a spring |
| 47 | * \param node MobilityModel layer of the attaching node |
| 48 | */ |
| 49 | void |
| 50 | AddSpring (Ptr<MobilityModel> node); |
| 51 | |
| 52 | private: |
| 53 | // from Object |
| 54 | virtual void |
| 55 | DoStart (); |
| 56 | |
| 57 | // from MobilityModel |
| 58 | virtual Vector |
| 59 | DoGetPosition (void) const; |
| 60 | |
| 61 | virtual void |
| 62 | DoSetPosition (const Vector &position); |
| 63 | |
| 64 | virtual Vector |
| 65 | DoGetVelocity (void) const; |
| 66 | |
| 67 | // Updating positions |
| 68 | void |
| 69 | Update (void) const; |
| 70 | |
Alexander Afanasyev | 5beb35a | 2011-12-21 16:45:13 -0800 | [diff] [blame] | 71 | static void |
| 72 | UpdateAll (); |
| 73 | |
Alexander Afanasyev | 7dbdcaf | 2011-12-13 21:40:37 -0800 | [diff] [blame] | 74 | private: |
Alexander Afanasyev | 5beb35a | 2011-12-21 16:45:13 -0800 | [diff] [blame] | 75 | static double m_epsilon; |
Alexander Afanasyev | 7dbdcaf | 2011-12-13 21:40:37 -0800 | [diff] [blame] | 76 | |
| 77 | double m_nodeMass; |
| 78 | double m_nodeCharge; |
| 79 | double m_springNormalLength; |
| 80 | double m_springConstant; |
| 81 | double m_dampingFactor; |
| 82 | |
| 83 | static double m_totalKineticEnergy; |
Alexander Afanasyev | 5beb35a | 2011-12-21 16:45:13 -0800 | [diff] [blame] | 84 | static bool m_stable; |
| 85 | static EventId m_updateEvent; |
Alexander Afanasyev | 7dbdcaf | 2011-12-13 21:40:37 -0800 | [diff] [blame] | 86 | |
| 87 | mutable Vector m_position; |
| 88 | mutable Vector m_velocity; |
Alexander Afanasyev | 7dbdcaf | 2011-12-13 21:40:37 -0800 | [diff] [blame] | 89 | mutable Time m_lastTime; |
| 90 | |
Alexander Afanasyev | 7dbdcaf | 2011-12-13 21:40:37 -0800 | [diff] [blame] | 91 | std::list<Ptr<MobilityModel> > m_springs; |
| 92 | }; |
| 93 | |
| 94 | } // namespace ns3 |
| 95 | |
| 96 | #endif // SPRING_MOBILITY_MODEL_H |