openETCS
case study for the European Train Control System developed for the authors dissertation
Simulation.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010-2012
3  Johannes Feuser <feuser@uni-bremen.de>
4  This file is part of the openETCS library.
5 
6  The openETCS library is free software: you can redistribute it and/or modify
7  it under the terms of the GNU General Public License as published by
8  the Free Software Foundation, either version 3 of the License, or
9  any later version.
10 
11  The openETCS library is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with the openETCS library. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 /*!
21  * \author Johannes Feuser <feuser@uni-bremen.de>
22  * \brief classes for simulative usage
23  */
24 
25 #ifndef __OETCS_DF_PS_SIM_SIMULATION_H__
26 #define __OETCS_DF_PS_SIM_SIMULATION_H__
27 
28 
29 #include <iostream>
30 
31 #include "../../Configuration.h"
32 #include "../AdaptorStubsMOC.h"
33 #include <mutex>
34 #include <thread>
35 #include <QBitArray>
36 
37 
38 namespace oETCS { namespace DF { namespace PS { namespace SIM { class CEmergencyBrake; } } } }
39 
40 
41 namespace oETCS {
42 
43 namespace DF {
44 
45 namespace PS {
46 
47 namespace SIM {
48 
49 
50 /*!
51  * \brief simulative odometer class
52  */
54 {
55  public:
56  /*!
57  * \brief default/general constructor
58  *
59  * \param[in] dInitialPosition optional initial position (default 0.0) in [m]
60  * \param[in] dInitialVelocity optional initial velocity (default 0.0) in [km/h]
61  */
62  explicit COdometer(const double & dInitialPosition = 0.0, const double & dInitialVelocity = 0.0) throw();
63 
64 
65 
66  /*!
67  * \brief destructor
68  */
69  virtual ~COdometer() throw();
70 
71 
72 
73  /*!
74  * \brief gets the current absolute position
75  *
76  * Calculates the position by integrating the current speed over the
77  * time difference from the last calculation time point m_LastCalculation.
78  *
79  * \return current absolute position in [m]
80  */
81  virtual double GetAbsolutePosition();
82 
83 
84 
85  /*!
86  * \brief gets the current velocity
87  *
88  * \return current velocity in [km/h]
89  */
90  virtual double GetVelocity();
91 
92 
93 
94  /*!
95  * \brief sets the current velocity
96  *
97  * Also calculates the position by integrating the old speed over the
98  * time difference from the last calculation time point m_LastCalculation.
99  *
100  * \param[in] dVelocity new velocity in [km/s]
101  */
102  void SetVelocity(const double& dVelocity) throw();
103 
104 
105 
106  /*!
107  * \brief resets the position
108  *
109  * Also resets the last calculation time to now.
110  *
111  * \param[in] dPosition optinal position in [m]
112  */
113  void ResetPosition(const double& dPosition = 0) throw();
114 
115 
116 
117 
118  private:
119  /*!
120  * \brief value of the current velocity in [km/h]
121  */
122  double m_dVelocity;
123 
124 
125 
126  /*!
127  * \brief current position in [m]
128  */
129  double m_dPosition;
130 
131 
132 
133  /*!
134  * \brief last calculation time point for the position
135  */
137 
138 
139 
140  /*!
141  * \brief muteable exclusion for internal states
142  */
143  ::std::recursive_mutex m_Mutex;
144 
145 
146 
147 
148 }; // class COdometer : public ::oETCS::DF::PS::COdometer
149 
150 
151 
152 /*!
153  * \brief simulative brake system class for a service brake
154  */
156 {
157  public:
158  /*!
159  * \brief general constructor
160  *
161  *
162  * \param[in] pOdometer pointer to the odometer device to be manipulated
163  * \param[in] pEmergencyBrake optional pointer to a emergency brake instance
164  * \param[in] dIntensity optional initial brake intensity in [%]
165  * \param[in] dMass optional initial train mass [kg]
166  * \param[in[ dAdsesion: optional initial adhesion factor (0...1)
167  */
168  explicit CServiceBrake(::oETCS::DF::PS::SIM::COdometer * const pOdometer, ::oETCS::DF::PS::SIM::CEmergencyBrake * const pEmergencyBrake = nullptr, const double & dIntensity = 0.0, const double & dMass = 10000, const double & dAdhesion = 1.0) throw();
169 
170 
171 
172  /*!
173  * \brief destructor
174  */
175  virtual ~CServiceBrake() throw();
176 
177 
178 
179  /*!
180  * \brief gets the activation intensity
181  *
182  * \return activation intensity of the service brake in [%]
183  */
184  virtual double GetIntensity();
185 
186 
187 
188  /*!
189  * \brief sets the activation intensity
190  *
191  * \param[in] bIntensity the new activation intensity in [%]
192  */
193  virtual void SetIntensity(const double& dIntensity);
194 
195 
196 
197  /*!
198  * \brief sets the virtual mass
199  *
200  * \param[in] dMass new mass in [kg]
201  */
202  void SetMass(const double& dMass) throw();
203 
204 
205 
206  /*!
207  * \brief sets the virtual adhesion
208  *
209  * \param[in] dAdhesion new virtual adhesion factor (0...1)
210  */
211  void SetAdhesion(const double& dAdhesion) throw();
212 
213 
214 
215 
216  private:
217  /*!
218  * \brief thread for setting the velocity depending on the brake intensity
219  */
220  void OdometerThread() throw();
221 
222 
223 
224  /*!
225  * \brief flag for the execution of the m_pPhysicalCalculation thread
226  */
228 
229 
230 
231  /*!
232  * \brief intesity of the applied service brake in [%]
233  */
234  double m_dIntensity;
235 
236 
237 
238  /*!
239  * \brief virtual mass in [kg] of the train used for braking curve calculation
240  */
241  double m_dMass;
242 
243 
244 
245  /*!
246  * \brief adhesion factor {0...1) of the train used for braking curve calculation
247  */
248  double m_dAdhesion;
249 
250 
251 
252  /*!
253  * \brief pointer to the odometer in which the velocity is modified
254  */
256 
257 
258 
259  /*!
260  * \brief optional pointer to a emegency brake taken into account for brake curve calculation
261  */
263 
264 
265 
266  /*!
267  * \brief pointer to the thread object for the physical model calculation manipulating m_pOdometer
268  */
269  ::std::thread* m_pPhysicalCalculation;
270 
271 
272 
273  /*!
274  * \brief muteable exclusion for internal states
275  */
276  ::std::recursive_mutex m_Mutex;
277 
278 
279 
280 
281 }; // class CServiceBrake : public ::oETCS::DF::PS::CServiceBrake
282 
283 
284 
285 /*!
286  * \brief simulative brake system class for a service brake
287  */
289 {
290  public:
291  /*!
292  * \brief default/general constructor
293  *
294  * \param[in] bActive optional initial emergency activation flag
295  */
296  explicit CEmergencyBrake(const bool & bActive = false) throw();
297 
298 
299 
300  /*!
301  * \brief destructor
302  */
303  virtual ~CEmergencyBrake() throw();
304 
305 
306 
307  /*!
308  * \brief gets the activation state
309  *
310  * \return activation flag of the emergency brake
311  */
312  virtual bool GetActivation();
313 
314 
315 
316  /*!
317  * \brief sets the activation state
318  *
319  * \param[in] bActivated the new activation flag
320  */
321  virtual void SetActivation(bool bActivated);
322 
323 
324 
325 
326  private:
327  /*!
328  * \brief activation flag of the emergency brake
329  */
330  bool m_bActive;
331 
332 
333 
334  /*!
335  * \brief muteable exclusion for internal states
336  */
337  ::std::recursive_mutex m_Mutex;
338 
339 
340 
341 
342 }; // class CEmergencyBrake : public ::oETCS::DF::PS::CEmergencyBrake
343 
344 
345 
346 /*!
347  * \brief simulative class for a balise out system
348  */
350 {
351  public:
352  /*!
353  * \brief default/general constructor
354  */
355  explicit CBaliseDeviceOut() throw();
356 
357 
358 
359  /*!
360  * \brief destructor
361  */
362  virtual ~CBaliseDeviceOut() throw();
363 
364 
365 
366  /*!
367  * \brief sends a telegram
368  *
369  * \param[in] Bits telegram to send as bits
370  */
371  virtual void SendTelegram(const ::QBitArray& Bits);
372 
373 
374 
375 
376  private:
377  /*!
378  * \brief muteable exclusion for internal states
379  */
380  ::std::recursive_mutex m_Mutex;
381 
382 
383 
384 
385 }; // class CBaliseDeviceOut : virtual public ::oETCS::DF::PS::CBaliseDeviceOut
386 
387 
388 
389 /*!
390  * \brief simulative class for a balise in system
391  */
393 {
394  public:
395  /*!
396  * \brief default/general constructor
397  */
398  explicit CBaliseDeviceIn() throw();
399 
400 
401 
402  /*!
403  * \brief destructor
404  */
405  virtual ~CBaliseDeviceIn() throw();
406 
407 
408 
409  /*!
410  * \brief sets a telegram as received
411  *
412  * Emits the NewTelegram(QBitArray) signal.
413  *
414  * \param[in] Bits raw bits of the telegram
415  */
416  void SetNewInputTelegram(const ::QBitArray& Bits) throw();
417 
418 
419 
420 
421  private:
422  /*!
423  * \brief muteable exclusion for internal states
424  */
425  ::std::recursive_mutex m_Mutex;
426 
427 
428 
429 
430 }; // class CBaliseDeviceIn : virtual public ::oETCS::DF::PS::CBaliseDeviceIn
431 
432 
433 
434 
435 
436 } // namespace oETCS::DF::PS::SIM
437 
438 } // namespace oETCS::DF::PS
439 
440 } // namespace oETCS::DF
441 
442 } // namespace oETCS
443 
444 #endif // __ OETCS_DF_PS_SIM_SIMULATION_H__

Copyright (C) 2010-2012 Johannes Feuser (feuser@uni-bremen.de)
The openETCS library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version.
The openETCS library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License along with the openETCS library. If not, see "http://www.gnu.org/licenses/.