openETCS
case study for the European Train Control System developed for the authors dissertation
WrapperFunctions.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 C wrapper functions for the simulative PSM classes
23  */
24 
25 #ifndef __OETCS_DF_PS_SIM_WRAPPERFUNCTIONS_H__
26 #define __OETCS_DF_PS_SIM_WRAPPERFUNCTIONS_H__
27 
28 
29 #include <QtCore>
30 #include <QtDBus>
31 #include <QMutex>
32 #include "oETCS/DF/OdometerAdaptor.h"
33 #include "oETCS/DF/EmergencyBrakeAdaptor.h"
34 #include "oETCS/DF/ServiceBrakeAdaptor.h"
35 #include "oETCS/DF/BaliseDeviceInAdaptor.h"
36 #include "oETCS/DF/BaliseDeviceOutAdaptor.h"
37 #include "oETCS/DF/PS/SIM/DMIInterface.h"
38 #include "Simulation.h"
39 
40 
41 
42 
43 
44 /* public:
45  int dummy;*/
46 
47 
48 
49 #define __EVC_DBUS__ "tcp:host=192.168.56.1,port=2222"
50 
51 
52 
53 extern "C"
54 {
55 
56  /*!
57  * \brief global telegram for ETCS Application Level switchtes from 0 to 1
58  */
59  extern const int G_TELEGRAM_LEVEL_0_TO_1[];
60 
61 
62 
63  /*!
64  * \brief global size of global telegram for ETCS Application Level switchtes from 0 to 1
65  */
66  extern const int G_SIZE_TELEGRAM_LEVEL_0_TO_1;
67 
68 
69 
70  /*!
71  * \brief global telegram for ETCS Application Level switchtes from 0 to 1
72  */
73  extern const int G_TELEGRAM_LEVEL_STOP_IN_SR[];
74 
75 
76 
77  /*!
78  * \brief global size of global telegram for ETCS Application Level switchtes from 0 to 1
79  */
80  extern const int G_SIZE_TELEGRAM_STOP_IN_SR;
81 
82 
83 
84  /*!
85  * \brief thread function for the QCoreApplication instance
86  *
87  * \param[out] pInitialised pointer to boolean to the set initialisation status
88  */
89  static void QAppThread(bool * pInitialised);
90 
91 
92 
93  /*!
94  * \brief PSM D-Bus adaptor initialisations
95  */
96  void InitPSM();
97 
98 
99 
100  /*!
101  * \brief initialises the module global DMI proxy
102  *
103  * \return !=0, if the DMI proxy was initialised sucessfully
104  */
105  int InitDMI();
106 
107 
108 
109  /*!
110  * \brief gets the DMI input status
111  *
112  * \return !=0, if a any (new) input field was found
113  */
114  int DMIHasInput();
115 
116 
117 
118  /*!
119  * \brief gets a certain DMI output value
120  *
121  * \param[in] pName pointer to name of the output field
122  * \param[out] ppValue pointer of pointer to value of the output field, de- and allocated by this function
123  */
124  void GetDMIOutput(const char * const pName, char ** const ppValue);
125 
126 
127 
128  /*!
129  * \brief sets a boolean input value in the DMI
130  *
131  * \param[in] pInputName literal name of the input field
132  * \param[in] iValue input value
133  */
134  void SetDMIBooleanValue(const char * const pInputName, int iValue);
135 
136 
137 
138  /*!
139  * \brief sets an integer input value in the DMI
140  *
141  * \param[in] pInputName literal name of the input field
142  * \param[in] iValue input value
143  */
144  void SetDMIIntegerValue(const char * const pInputName, int iValue);
145 
146 
147 
148  /*!
149  * \brief sets a double input value in the DMI
150  *
151  * \param[in] pInputName literal name of the input field
152  * \param[in] iValue input value
153  */
154  void SetDMIDoubleValue(const char * const pInputName, double dValue);
155 
156 
157 
158  /*!
159  * \brief sets a string input value in the DMI
160  *
161  * \param[in] pInputName literal name of the input field
162  * \param[in] pValue input value (C-string)
163  */
164  void SetDMIStringValue(const char * const pInputName, const char * const pValue);
165 
166 
167 
168  /*!
169  * \brief sets a telegram as received for the PIM
170  *
171  * \param[in] pTelegram pointer to bytes of the telegram
172  * \param[in] iBits number bits included in the telegram
173  */
174  void SetNewInputTelegram(char * pTelegram, int iBits);
175 
176 
177 
178  /*!
179  * \brief sets a telegram as received for the PIM in a binary format
180  *
181  * \param[in] pTelegram pointer to bits of the telegram
182  * \param[in] iBits number bits included in the telegram
183  */
184  void SetNewInputTelegramBinary(const int * const pTelegram, int iBits);
185 
186 
187 
188  /*!
189  * \brief gets the type of the first DMI input
190  *
191  * \param[out] pDMIType pointer to the integer with the current DMI type value
192  */
193  void EvaluateDMIInputs(int * pDMIType);
194 
195 
196 
197  /*!
198  * \brief gets the current speed from the odometer object
199  *
200  * \return current speed [km/h]
201  */
202  double GetVelocity();
203 
204 
205 
206  /*!
207  * \brief sets the speed in the odomoeter object
208  *
209  * \param[in] dVelocity new speed in [km/h]
210  */
211  void SetVelocity(double dVelocity);
212 
213 
214 
215  /*!
216  * \brief (re)sets the position of the odometer object
217  *
218  * \param[in] dPosition new position in [m]
219  */
220  void ResetPosition(double dPosition);
221 
222 
223 
224  /*!
225  * \brief gets the current position from the odometer object
226  *
227  * \return current position [m]
228  */
229  double GetPosition();
230 
231 
232 
233  /*!
234  * \brief sets the activation intensity
235  *
236  * \param[in] bIntensity the new activation intensity in [%]
237  */
238  void SetServiceIntensity(double dIntensity);
239 
240 
241 
242  /*!
243  * \brief gets the activation intensity
244  *
245  * \return activation intensity of the service brake in [%]
246  */
247  double GetServiceIntensity();
248 
249 
250 
251  /*!
252  * \brief sets the virtual mass
253  *
254  * \param[in] dMass new mass in [kg]
255  */
256  void SetMass(double dMass);
257 
258 
259 
260  /*!
261  * \brief sets the virtual adhesion
262  *
263  * \param[in] dAdhesion new virtual adhesion factor (0...1)
264  */
265  void SetAdhesion(double dAdhesion);
266 
267 
268 
269  /*!
270  * \brief sets the activation state
271  *
272  * \param[in] iActivated the new activation flag (!=0: true)
273  */
274  void SetEmergencyActivation(int iActication);
275 
276 
277 
278  /*!
279  * \brief gets the activation state
280  *
281  * \return activation flag of the emergency brake (!=0: true)
282  */
284 
285 
286 
287 } // extern "C"
288 
289 
290 
291 
292 
293 #endif // __ OETCS_DF_PS_SIM_WRAPPERFUNCTIONS_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/.