openETCS
case study for the European Train Control System developed for the authors dissertation
UnitTesting.cpp
Go to the documentation of this file.
1 /*
2  Copyright (C) 2010-2011
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 unit testing module
23  */
24 
25 #include "UnitTesting.h"
26 #include "../DF/FunctionBlocks.h"
27 #include "../DF/Condition.h"
28 #include "../DF/Storage.h"
29 #include "../DF/ControlFlow.h"
30 #include "../../DSM/GOPPRRTransformer.h"
31 #include "../../GOPPRR/ConstraintChecker.h"
32 #include "../GEN/CPPGenerator.h"
33 
34 
35 // register all test suites
42 
43 namespace oETCS {
44 
45 namespace UT {
46 
47 
49 :m_pAnd(0),
50  m_pOr(0),
51  m_pEVCCondition(0),
52  m_pCondition(0),
53  m_pLevelCondition(0),
54  m_pComBlockIn(0),
55  m_pComBlockOut(0),
56  m_pXor(0),
57  m_pNot(0),
58  m_pSum(0),
59  m_pSubstraction(0),
60  m_pDivision(0),
61  m_pMultiplication(0),
62  m_pDoubleEqual(0),
63  m_pIntEqual(0),
64  m_pStringEqual(0),
65  m_pDoubleEqualOrGreater(0),
66  m_pDoubleGreater(0),
67  m_pIntGreater(0),
68  m_pDoubleArrayAccessor(0),
69  m_pBoolGate(0),
70  m_pBrakingToTargetSpeed(0),
71  m_pCeelingSpeedControl(0),
72  m_pStringGate(0),
73  m_pDoubleGate(0),
74  m_pBoolSwitch(0),
75  m_pDoubleSwitch(0),
76  m_pStringSwitch(0),
77  m_pEnteredTrigger(0),
78  m_pStorage(0),
79  m_pBitStorage(0),
80  m_bBoolInput(false),
81  m_bBoolInput2(false),
82  m_bBoolInput3(false),
83  m_bBoolInput4(false),
84  m_dDoubleInput(0),
85  m_DoubleArrayInput(::std::vector< double >(0)),
86  m_iIntInput(0),
87  m_StringInput("")
88 {
89  // Bouml preserved body begin 0007B802
90  // empty constructor
91  // Bouml preserved body end 0007B802
92 
93 } // CFunctionBlock::CFunctionBlock() throw()
94 
95 
96 
97 
98 void CFunctionBlock::setUp() throw(::std::bad_alloc)
99 {
100  // Bouml preserved body begin 0007B882
101  ::oETCS::DF::CVariable* pVariable(0);
102  ::oETCS::DF::CVariable* pHeader(0);
103  ::oETCS::DF::CPacket* pPacket(0);
104  ::oETCS::DF::CTelegram* pTelegram(0);
105  ::oETCS::DF::CBaliseDeviceIn* pBaliseIn(0);
106  ::oETCS::DF::CBaliseDeviceOut* pBaliseOut(0);
107  ::oETCS::DF::CFlow< bool >* pBoolFlow(0);
108  ::oETCS::DF::CFlow< double >* pDoubleFlow(0);
109  ::oETCS::DF::CFlow< ::std::vector< double > >* pDoubleArrayFlow(0);
111  ::oETCS::DF::CFlow< ::std::string >* pStringFlow(0);
112 
113 
114 
115  // create storage object, flows and language objects first, because of dependencies
116  m_pStorage = new ::oETCS::DF::CStorage(&m_StateMachine);
117  pBoolFlow = new ::oETCS::DF::CFlow< bool >(&m_bBoolInput, &m_StateMachine);
118  pDoubleFlow = new ::oETCS::DF::CFlow< double >(&m_dDoubleInput, &m_StateMachine);
119  pDoubleArrayFlow = new ::oETCS::DF::CFlow< ::std::vector< double> >(&m_DoubleArrayInput, &m_StateMachine);
120  pIntFlow = new ::oETCS::DF::CFlow< signed int >(&m_iIntInput, &m_StateMachine);
121  pStringFlow = new ::oETCS::DF::CFlow< ::std::string >(&m_StringInput, &m_StateMachine);
122  m_pStorage->m_BoolValue.push_back(pBoolFlow);
123  m_pStorage->m_DoubleValue.push_back(pDoubleFlow);
124  m_pStorage->m_DoubleArrayValue.push_back(pDoubleArrayFlow);
125  m_pStorage->m_IntValue.push_back(pIntFlow);
126  m_pStorage->m_StringValue.push_back(pStringFlow);
127 
128  m_pBitStorage = new ::oETCS::DF::CStorage(&m_StateMachine);
129  m_pStorage->m_BitValue.push_back(new ::oETCS::DF::CBitFlow(m_pBitStorage, &m_StateMachine));
130  pVariable = new ::oETCS::DF::CVariable(&m_StateMachine, 1, ::oETCS::DF::CVariable::DOUBLE, 32);
131  pVariable->m_BitValues.push_back(new ::oETCS::DF::CBitFlow(m_pStorage, &m_StateMachine));
132  pHeader = new ::oETCS::DF::CVariable(&m_StateMachine, 2, ::oETCS::DF::CVariable::INTEGER, 16);
133  pPacket = new ::oETCS::DF::CPacket(&m_StateMachine, 5, ::std::vector< ::oETCS::DF::CVariable* >(1, pVariable));
134  pTelegram = new ::oETCS::DF::CTelegram(&m_StateMachine,::std::vector< ::oETCS::DF::CVariable* >(1, pHeader), ::std::vector< ::oETCS::DF::CPacket* >(1, pPacket));
135  pBaliseIn = new ::oETCS::DF::CBaliseDeviceIn(::std::vector< ::oETCS::DF::CTelegram* >(1, pTelegram));
136  pBaliseOut = new ::oETCS::DF::CBaliseDeviceOut(::std::vector< ::oETCS::DF::CTelegram* >(1, pTelegram));
137 
138 
139  // create all high level function block test objects and their flows
140  m_pAnd = new ::oETCS::DF::CAnd(&m_StateMachine);
141  m_pAnd->m_Result.push_back(new ::oETCS::DF::CFlow< bool >(&m_bBoolInput, &m_StateMachine));
142  m_pOr = new ::oETCS::DF::COr(&m_StateMachine);
143  m_pOr->m_Result.push_back(new ::oETCS::DF::CFlow< bool >(&m_bBoolInput, &m_StateMachine));
144  m_pEVCCondition = new ::oETCS::DF::CEVCCondition(&m_StateMachine);
145  m_pCondition = new ::oETCS::DF::CCondition(&m_StateMachine);
146  m_pLevelCondition = new ::oETCS::DF::CLevelCondition(&m_StateMachine, "TEST");
147  m_pComBlockIn = new ::oETCS::DF::CComBlockIn(&m_StateMachine, ::std::vector< ::oETCS::DF::CBaliseDeviceIn* >(1, pBaliseIn));
148  m_pComBlockOut = new ::oETCS::DF::CComBlockOut(&m_StateMachine, ::std::vector< ::oETCS::DF::CBaliseDeviceOut* >(1, pBaliseOut));
149  m_pXor = new ::oETCS::DF::CXor(&m_StateMachine);
150  m_pXor->m_Result.push_back(new ::oETCS::DF::CFlow< bool >(&m_bBoolInput, &m_StateMachine));
151  m_pNot = new ::oETCS::DF::CNot(&m_StateMachine);
152  m_pNot->m_Result.push_back(new ::oETCS::DF::CFlow< bool >(&m_bBoolInput, &m_StateMachine));
153  m_pSum = new ::oETCS::DF::CSum(&m_StateMachine);
154  m_pSum->m_Sum.push_back(new ::oETCS::DF::CFlow< double >(&m_dDoubleInput, &m_StateMachine));
155  m_pSubstraction = new ::oETCS::DF::CSubstraction(&m_StateMachine);
156  m_pSubstraction->m_Difference.push_back(new ::oETCS::DF::CFlow< double >(&m_dDoubleInput, &m_StateMachine));
157  m_pDivision = new ::oETCS::DF::CDivision(&m_StateMachine);
158  m_pDivision->m_Quotient.push_back(new ::oETCS::DF::CFlow< double >(&m_dDoubleInput, &m_StateMachine));
159  m_pMultiplication = new ::oETCS::DF::CMultiplication(&m_StateMachine);
160  m_pMultiplication->m_Product.push_back(new ::oETCS::DF::CFlow< double >(&m_dDoubleInput, &m_StateMachine));
161  m_pDoubleEqual = new ::oETCS::DF::CDoubleEqual(&m_StateMachine);
162  m_pDoubleEqual->m_Equal.push_back(new ::oETCS::DF::CFlow< bool >(&m_bBoolInput, &m_StateMachine));
163  m_pIntEqual = new ::oETCS::DF::CIntEqual(&m_StateMachine);
164  m_pIntEqual->m_Equal.push_back(new ::oETCS::DF::CFlow< bool >(&m_bBoolInput, &m_StateMachine));
165  m_pStringEqual = new ::oETCS::DF::CStringEqual(&m_StateMachine);
166  m_pStringEqual->m_Equal.push_back(new ::oETCS::DF::CFlow< bool >(&m_bBoolInput, &m_StateMachine));
167  m_pDoubleEqualOrGreater = new ::oETCS::DF::CDoubleEqualOrGreater(&m_StateMachine);
168  m_pDoubleEqualOrGreater->m_EqualOrGreater.push_back(new ::oETCS::DF::CFlow< bool >(&m_bBoolInput, &m_StateMachine));
169  m_pDoubleGreater = new ::oETCS::DF::CDoubleGreater(&m_StateMachine);
170  m_pDoubleGreater->m_Greater.push_back(new ::oETCS::DF::CFlow< bool >(&m_bBoolInput, &m_StateMachine));
171  m_pIntGreater = new ::oETCS::DF::CIntGreater(&m_StateMachine);
172  m_pIntGreater->m_Greater.push_back(new ::oETCS::DF::CFlow< bool >(&m_bBoolInput, &m_StateMachine));
173  m_pDoubleArrayAccessor = new ::oETCS::DF::CDoubleArrayAccessor(&m_StateMachine);
174  m_pDoubleArrayAccessor->m_Value.push_back(new ::oETCS::DF::CFlow< double >(&m_dDoubleInput, &m_StateMachine));
175  m_pBoolGate = new ::oETCS::DF::CBoolGate(&m_StateMachine);
176  m_pBoolGate->m_GateOutput.push_back(new ::oETCS::DF::CFlow< bool >(&m_bBoolInput, &m_StateMachine));
177  m_pBrakingToTargetSpeed = new ::oETCS::DF::CBrakingToTargetSpeed(&m_StateMachine);
178  m_pBrakingToTargetSpeed->m_EmergencyBrakeValue.push_back(new ::oETCS::DF::CFlow< bool >(&m_bBoolInput, &m_StateMachine));
179  m_pBrakingToTargetSpeed->m_ServiceBrakeValue.push_back(new ::oETCS::DF::CFlow< double >(&m_dDoubleInput, &m_StateMachine));
180  m_pBrakingToTargetSpeed->m_EmergencyBrakeApplied.push_back(new ::oETCS::DF::CFlow< bool >(&m_bBoolInput2, &m_StateMachine));
181  m_pBrakingToTargetSpeed->m_ServiceBrakeApplied.push_back(new ::oETCS::DF::CFlow< bool >(&m_bBoolInput3, &m_StateMachine));
182  m_pBrakingToTargetSpeed->m_SpeedWarning.push_back(new ::oETCS::DF::CFlow< bool >(&m_bBoolInput4, &m_StateMachine));
183  m_pBrakingToTargetSpeed->m_ServiceBrakeValue.push_back(new ::oETCS::DF::CFlow< double >(&m_dDoubleInput, &m_StateMachine));
184  m_pCeelingSpeedControl = new ::oETCS::DF::CCeelingSpeedControl(&m_StateMachine);
185  m_pCeelingSpeedControl->m_EmergencyBrakeValue.push_back(new ::oETCS::DF::CFlow< bool >(&m_bBoolInput, &m_StateMachine));
186  m_pCeelingSpeedControl->m_EmergencyBrakeApplied.push_back(new ::oETCS::DF::CFlow< bool >(&m_bBoolInput2, &m_StateMachine));
187  m_pCeelingSpeedControl->m_ServiceBrakeApplied.push_back(new ::oETCS::DF::CFlow< bool >(&m_bBoolInput3, &m_StateMachine));
188  m_pCeelingSpeedControl->m_SpeedWarning.push_back(new ::oETCS::DF::CFlow< bool >(&m_bBoolInput4, &m_StateMachine));
189  m_pCeelingSpeedControl->m_ServiceBrakeValue.push_back(new ::oETCS::DF::CFlow< double >(&m_dDoubleInput, &m_StateMachine));
190  m_pStringGate = new ::oETCS::DF::CStringGate(&m_StateMachine);
191  m_pStringGate->m_GateOutput.push_back(new ::oETCS::DF::CFlow< ::std::string >(&m_StringInput, &m_StateMachine));
192  m_pDoubleGate = new ::oETCS::DF::CDoubleGate(&m_StateMachine);
193  m_pDoubleGate->m_GateOutput.push_back(new ::oETCS::DF::CFlow< double >(&m_dDoubleInput, &m_StateMachine));
194  m_pBoolSwitch = new ::oETCS::DF::CBoolSwitch(&m_StateMachine);
195  m_pBoolSwitch->m_SwitchOutput.push_back(new ::oETCS::DF::CFlow< bool >(&m_bBoolInput, &m_StateMachine));
196  m_pDoubleSwitch = new ::oETCS::DF::CDoubleSwitch(&m_StateMachine);
197  m_pDoubleSwitch->m_SwitchOutput.push_back(new ::oETCS::DF::CFlow< double >(&m_dDoubleInput, &m_StateMachine));
198  m_pStringSwitch = new ::oETCS::DF::CStringSwitch(&m_StateMachine);
199  m_pStringSwitch->m_SwitchOutput.push_back(new ::oETCS::DF::CFlow< ::std::string >(&m_StringInput, &m_StateMachine));
200  m_pEnteredTrigger = new ::oETCS::DF::CEnteredTrigger(&m_StateMachine);
201  m_pEnteredTrigger->m_Entered.push_back(new ::oETCS::DF::CFlow< bool >(&m_bBoolInput, &m_StateMachine));
202  // Bouml preserved body end 0007B882
203 
204 } // void CFunctionBlock::setUp() throw(::std::bad_alloc)
205 
206 
207 
208 
210 {
211  // Bouml preserved body begin 0007B902
212  // all function block objects are deleted by destructor of m_StateMachine
213  // Bouml preserved body end 0007B902
214 
215 } // void CFunctionBlock::tearDown() throw()
216 
217 
218 
219 
220 void CFunctionBlock::TestAnd() throw(::std::exception)
221 {
222  // Bouml preserved body begin 0007EC82
223  // reset boolean input of fixture
224  m_bBoolInput = false;
225 
226  // set inputs of CAnd object
227  m_pAnd->m_bInput1 = true;
228  m_pAnd->m_bInput2 = true;
229 
230  // calculate result
231  m_pAnd->Calculate();
232 
233  // assert result
234  CPPUNIT_ASSERT_MESSAGE("boolean and operation failed", m_bBoolInput() == true);
235 
236  // reset inputs of CAnd object
237  m_pAnd->m_bInput1 = false;
238  m_pAnd->m_bInput2 = true;
239 
240  // calculate result
241  m_pAnd->Calculate();
242 
243  // assert result
244  CPPUNIT_ASSERT_MESSAGE("boolean and operation failed", m_bBoolInput() == false);
245 
246  // reset boolean input of fixture
247  m_bBoolInput = true;
248 
249  // set inputs of CAnd object
250  m_pAnd->m_bInput1 = true;
251  m_pAnd->m_bInput2 = false;
252 
253  // calculate result
254  m_pAnd->Calculate();
255 
256  // assert result
257  CPPUNIT_ASSERT_MESSAGE("boolean and operation failed", m_bBoolInput() == false);
258 
259  // reset boolean input of fixture
260  m_bBoolInput = true;
261 
262  // set inputs of CAnd object
263  m_pAnd->m_bInput1 = false;
264  m_pAnd->m_bInput2 = false;
265 
266  // calculate result
267  m_pAnd->Calculate();
268 
269  // assert result
270  CPPUNIT_ASSERT_MESSAGE("boolean and operation failed", m_bBoolInput() == false);
271  // Bouml preserved body end 0007EC82
272 
273 } // void CFunctionBlock::TestAnd() throw(::std::exception)
274 
275 
276 
277 
278 void CFunctionBlock::TestOr() throw(::std::exception)
279 {
280  // Bouml preserved body begin 0007ED02
281  // reset boolean input of fixture
282  m_bBoolInput = false;
283 
284  // set inputs of COr object
285  m_pOr->m_bInput1 = true;
286  m_pOr->m_bInput2 = true;
287 
288  // calculate result
289  m_pOr->Calculate();
290 
291  // assert result
292  CPPUNIT_ASSERT_MESSAGE("boolean or operation failed", m_bBoolInput() == true);
293 
294  // reset boolean input of fixture
295  m_bBoolInput = false;
296 
297  // reset inputs of COr object
298  m_pOr->m_bInput1 = false;
299  m_pOr->m_bInput2 = true;
300 
301  // calculate result
302  m_pOr->Calculate();
303 
304  // assert result
305  CPPUNIT_ASSERT_MESSAGE("boolean or operation failed", m_bBoolInput() == true);
306 
307  // reset boolean input of fixture
308  m_bBoolInput = false;
309 
310  // set inputs of COr object
311  m_pOr->m_bInput1 = true;
312  m_pOr->m_bInput2 = false;
313 
314  // calculate result
315  m_pOr->Calculate();
316 
317  // assert result
318  CPPUNIT_ASSERT_MESSAGE("boolean or operation failed", m_bBoolInput() == true);
319 
320  // reset boolean input of fixture
321  m_bBoolInput = true;
322 
323  // set inputs of COr object
324  m_pOr->m_bInput1 = false;
325  m_pOr->m_bInput2 = false;
326 
327  // calculate result
328  m_pOr->Calculate();
329 
330  // assert result
331  CPPUNIT_ASSERT_MESSAGE("boolean or operation failed", m_bBoolInput() == false);
332  // Bouml preserved body end 0007ED02
333 
334 } // void CFunctionBlock::TestOr() throw(::std::exception)
335 
336 
337 
338 
339 void CFunctionBlock::TestXor() throw(::std::exception)
340 {
341  // Bouml preserved body begin 0007ED82
342  // reset boolean input of fixture
343  m_bBoolInput = true;
344 
345  // set inputs of CXor object
346  m_pXor->m_bInput1 = true;
347  m_pXor->m_bInput2 = true;
348 
349  // calculate result
350  m_pXor->Calculate();
351 
352  // assert result
353  CPPUNIT_ASSERT_MESSAGE("boolean exclusive or operation failed", m_bBoolInput() == false);
354 
355  // reset boolean input of fixture
356  m_bBoolInput = false;
357 
358  // reset inputs of CXor object
359  m_pXor->m_bInput1 = false;
360  m_pXor->m_bInput2 = true;
361 
362  // calculate result
363  m_pXor->Calculate();
364 
365  // assert result
366  CPPUNIT_ASSERT_MESSAGE("boolean exclusive or operation failed", m_bBoolInput() == true);
367 
368  // reset boolean input of fixture
369  m_bBoolInput = false;
370 
371  // set inputs of CXor object
372  m_pXor->m_bInput1 = true;
373  m_pXor->m_bInput2 = false;
374 
375  // calculate result
376  m_pXor->Calculate();
377 
378  // assert result
379  CPPUNIT_ASSERT_MESSAGE("boolean exclusive or operation failed", m_bBoolInput() == true);
380 
381  // reset boolean input of fixture
382  m_bBoolInput = true;
383 
384  // set inputs of CXor object
385  m_pXor->m_bInput1 = false;
386  m_pXor->m_bInput2 = false;
387 
388  // calculate result
389  m_pXor->Calculate();
390 
391  // assert result
392  CPPUNIT_ASSERT_MESSAGE("boolean exclusive or operation failed", m_bBoolInput() == false);
393  // Bouml preserved body end 0007ED82
394 
395 } // void CFunctionBlock::TestXor() throw(::std::exception)
396 
397 
398 
399 
400 void CFunctionBlock::TestNot() throw(::std::exception)
401 {
402  // Bouml preserved body begin 00080702
403  // reset boolean input of fixture
404  m_bBoolInput = true;
405 
406  // set inputs of CNot object
407  m_pNot->m_bInput = true;
408 
409  // calculate result
410  m_pNot->Calculate();
411 
412  // assert result
413  CPPUNIT_ASSERT_MESSAGE("boolean not operation failed", m_bBoolInput() == false);
414 
415  // reset boolean input of fixture
416  m_bBoolInput = false;
417 
418  // set inputs of CNot object
419  m_pNot->m_bInput = false;
420 
421  // calculate result
422  m_pNot->Calculate();
423 
424  // assert result
425  CPPUNIT_ASSERT_MESSAGE("boolean not operation failed", m_bBoolInput() == true);
426  // Bouml preserved body end 00080702
427 
428 } // void CFunctionBlock::TestNot() throw(::std::exception)
429 
430 
431 
432 
433 void CFunctionBlock::TestSum() throw(::std::exception)
434 {
435  // Bouml preserved body begin 00080782
436  const double ADDEND1(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
437  const double ADDEND2(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
438  const double ADDEND3(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
439 
440 
441 
442  // set inputs of CSum
443  m_pSum->m_dAddend1 = ADDEND1;
444  m_pSum->m_dAddend2 = ADDEND2;
445  m_pSum->m_dAddend3 = ADDEND3;
446 
447  // calculate the result
448  m_pSum->Calculate();
449 
450  // assert result
451  CPPUNIT_ASSERT_MESSAGE("addition of three double values failed", m_dDoubleInput() == (ADDEND1 + ADDEND2 + ADDEND3));
452  // Bouml preserved body end 00080782
453 
454 } // void CFunctionBlock::TestSum() throw(::std::exception)
455 
456 
457 
458 
459 void CFunctionBlock::TestSubstraction() throw(::std::exception)
460 {
461  // Bouml preserved body begin 00080802
462  const double MINUEND(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
463  const double SUBTRAHEND(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
464 
465 
466 
467  // set inputs of CSubstraction
468  m_pSubstraction->m_dMinuend = MINUEND;
469  m_pSubstraction->m_dSubtrahend = SUBTRAHEND;
470 
471  // calculate the result
473 
474  // assert result
475  CPPUNIT_ASSERT_MESSAGE("subtraction of double values failed", m_dDoubleInput() == (MINUEND - SUBTRAHEND));
476  // Bouml preserved body end 00080802
477 
478 } // void CFunctionBlock::TestSubstraction() throw(::std::exception)
479 
480 
481 
482 
483 void CFunctionBlock::TestDivision() throw(::std::exception)
484 {
485  // Bouml preserved body begin 00080882
486  const double DIVIDEND(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
487  const double DIVISOR(200.0 * double(rand()) / double(RAND_MAX) + 0.1);
488  const double RESULT(DIVIDEND / DIVISOR);
489 
490 
491 
492  // set inputs of CDivision
493  m_pDivision->m_dDividend = DIVIDEND;
494  m_pDivision->m_dDivisor = DIVISOR;
495 
496  // calculate the result
498 
499  // assert result
500  CPPUNIT_ASSERT_MESSAGE("division of double values failed", m_dDoubleInput() == RESULT);
501  // Bouml preserved body end 00080882
502 
503 } // void CFunctionBlock::TestDivision() throw(::std::exception)
504 
505 
506 
507 
508 void CFunctionBlock::TestMultiplication() throw(::std::exception)
509 {
510  // Bouml preserved body begin 00080902
511  const double MULTIPLICATOR1(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
512  const double MULTIPLICATOR2(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
513  const double MULTIPLICATOR3(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
514  const double RESULT(MULTIPLICATOR1 * MULTIPLICATOR2 * MULTIPLICATOR3);
515 
516 
517 
518  // set inputs of CMultiplication
519  m_pMultiplication->m_dMultiplicator1 = MULTIPLICATOR1;
520  m_pMultiplication->m_dMultiplicator2 = MULTIPLICATOR2;
521  m_pMultiplication->m_dMultiplicator3 = MULTIPLICATOR3;
522 
523  // calculate the result
525 
526  // assert result
527  CPPUNIT_ASSERT_MESSAGE("multiplication of three double factors failed", abs(m_dDoubleInput() - RESULT) < 0.00001 );
528  // Bouml preserved body end 00080902
529 
530 } // void CFunctionBlock::TestMultiplication() throw(::std::exception)
531 
532 
533 
534 
535 void CFunctionBlock::TestDoubleEqual() throw(::std::exception)
536 {
537  // Bouml preserved body begin 00080982
538  const double VALUE1(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
539  const double VALUE2(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
540 
541 
542 
543  // set inputs of CDoubleEqual
544  m_pDoubleEqual->m_dInput1 = VALUE1;
545  m_pDoubleEqual->m_dInput2 = VALUE2;
546 
547  // calculate the result
549 
550  // assert result
551  CPPUNIT_ASSERT_MESSAGE("double equal computation failed", m_bBoolInput() == false);
552 
553  // set inputs of CDoubleEqual
554  m_pDoubleEqual->m_dInput1 = VALUE1;
555  m_pDoubleEqual->m_dInput2 = VALUE1;
556 
557  // calculate the result
559 
560  // assert result
561  CPPUNIT_ASSERT_MESSAGE("double equal computation failed", m_bBoolInput() == true);
562  // Bouml preserved body end 00080982
563 
564 } // void CFunctionBlock::TestDoubleEqual() throw(::std::exception)
565 
566 
567 
568 
569 void CFunctionBlock::TestIntEqual() throw(::std::exception)
570 {
571  // Bouml preserved body begin 00080A02
572  const int VALUE1(rand());
573  const int VALUE2(rand());
574 
575 
576 
577  // set inputs of CIntEqual
578  m_pIntEqual->m_iInput1 = VALUE1;
579  m_pIntEqual->m_iInput2 = VALUE2;
580 
581  // calculate the result
583 
584  // assert result
585  CPPUNIT_ASSERT_MESSAGE("integer equal computation failed", m_bBoolInput() == false);
586 
587  // set inputs of CDoubleEqual
588  m_pIntEqual->m_iInput1 = VALUE1;
589  m_pIntEqual->m_iInput2 = VALUE1;
590 
591  // calculate the result
593 
594  // assert result
595  CPPUNIT_ASSERT_MESSAGE("integer equal computation failed", m_bBoolInput() == true);
596  // Bouml preserved body end 00080A02
597 
598 } // void CFunctionBlock::TestIntEqual() throw(::std::exception)
599 
600 
601 
602 
603 void CFunctionBlock::TestStringEqual() throw(::std::exception)
604 {
605  // Bouml preserved body begin 00080A82
606  unsigned int x(0);
607  ::std::string Value1;
608  ::std::string Value2;
609 
610 
611 
612  // create random string
613  for (x = 0; x < 20; x++)
614  {
615  // add random char to strings
616  Value1 += char(double(rand()) / double(RAND_MAX) * 94.0 + 32.0);
617  Value2 += char(double(rand()) / double(RAND_MAX) * 94.0 + 32.0);
618 
619  } // for (x = 0; x < 20; x++)
620 
621  // reset boolean input
622  m_bBoolInput = true;
623 
624  // set input of CStringEqual
625  m_pStringEqual->m_Input1 = Value1;
626  m_pStringEqual->m_Input2 = Value2;
627 
628  // calculate the result
630 
631  // assert result
632  CPPUNIT_ASSERT_MESSAGE("string equal computation failed", m_bBoolInput() == false);
633 
634  // reset boolean input
635  m_bBoolInput = false;
636 
637  // set input of CStringEqual
638  m_pStringEqual->m_Input1 = Value1;
639  m_pStringEqual->m_Input2 = Value1;
640 
641  // calculate the result
643 
644  // assert result
645  CPPUNIT_ASSERT_MESSAGE("string equal computation failed", m_bBoolInput() == true);
646  // Bouml preserved body end 00080A82
647 
648 } // void CFunctionBlock::TestStringEqual() throw(::std::exception)
649 
650 
651 
652 
653 void CFunctionBlock::TestDoubleEqualOrGreater() throw(::std::exception)
654 {
655  // Bouml preserved body begin 00082402
656  const double VALUE1(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
657  const double VALUE2(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
658 
659 
660 
661  // set inputs of CDoubleEqualOrGreater
664 
665  // calculate the result
667 
668  // assert result
669  CPPUNIT_ASSERT_MESSAGE("double equal or greater (>=) computation failed", m_bBoolInput() == (VALUE1 >= VALUE2));
670 
671  // set inputs of CDoubleEqualOrGreater
674 
675  // calculate the result
677 
678  // assert result
679  CPPUNIT_ASSERT_MESSAGE("double equal or greater (>=) computation failed", m_bBoolInput() == (VALUE1 <= VALUE2));
680 
681  // set inputs of CDoubleEqualOrGreater
684 
685  // calculate the result
687 
688  // assert result
689  CPPUNIT_ASSERT_MESSAGE("double equal or greater (>=) computation failed", m_bBoolInput() == true);
690  // Bouml preserved body end 00082402
691 
692 } // void CFunctionBlock::TestDoubleEqualOrGreater() throw(::std::exception)
693 
694 
695 
696 
697 void CFunctionBlock::TestDoubleGreater() throw(::std::exception)
698 {
699  // Bouml preserved body begin 00082482
700  const double VALUE1(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
701  const double VALUE2(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
702 
703 
704 
705  // set inputs of CDoublGreater
706  m_pDoubleGreater->m_dInput1 = VALUE1;
707  m_pDoubleGreater->m_dInput2 = VALUE2;
708 
709  // calculate the result
711 
712  // assert result
713  CPPUNIT_ASSERT_MESSAGE("double greater computation failed", m_bBoolInput() == (VALUE1 > VALUE2));
714 
715  // set inputs of CDoublGreater
716  m_pDoubleGreater->m_dInput1 = VALUE2;
717  m_pDoubleGreater->m_dInput2 = VALUE1;
718 
719  // calculate the result
721 
722  // assert result
723  CPPUNIT_ASSERT_MESSAGE("double greater computation failed", m_bBoolInput() == (VALUE1 < VALUE2));
724  // Bouml preserved body end 00082482
725 
726 } // void CFunctionBlock::TestDoubleGreater() throw(::std::exception)
727 
728 
729 
730 
731 void CFunctionBlock::TestIntGreater() throw(::std::exception)
732 {
733  // Bouml preserved body begin 00082502
734  const int VALUE1(rand());
735  const int VALUE2(rand());
736 
737 
738 
739  // set inputs of CDoubleEqualOrGreater
740  m_pIntGreater->m_iInput1 = VALUE1;
741  m_pIntGreater->m_iInput2 = VALUE2;
742 
743  // calculate the result
745 
746  // assert result
747  CPPUNIT_ASSERT_MESSAGE("integer greater computation failed", m_bBoolInput() == (VALUE1 > VALUE2));
748 
749  // set inputs of CDoubleEqualOrGreater
750  m_pIntGreater->m_iInput1 = VALUE2;
751  m_pIntGreater->m_iInput2 = VALUE1;
752 
753  // calculate the result
755 
756  // assert result
757  CPPUNIT_ASSERT_MESSAGE("integer greater computation failed", m_bBoolInput() == (VALUE1 < VALUE2));
758  // Bouml preserved body end 00082502
759 
760 } // void CFunctionBlock::TestIntGreater() throw(::std::exception)
761 
762 
763 
764 
765 void CFunctionBlock::TestDoubleArrayAccessor() throw(::std::exception)
766 {
767  // Bouml preserved body begin 00082582
768  const double VALUE1(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
769  const double VALUE2(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
770  const double VALUE3(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
771  ::std::vector< double> DoubleArray(3);
772 
773 
774 
775  // initialise double array with values
776  DoubleArray[0] = VALUE1;
777  DoubleArray[1] = VALUE2;
778  DoubleArray[2] = VALUE3;
779 
780  // set inputs of CDoublArrayAccessor
781  m_pDoubleArrayAccessor->m_Array = DoubleArray;
783 
784  // calculate the result
786 
787  // assert result
788  CPPUNIT_ASSERT_MESSAGE("accessing of first element failed", m_dDoubleInput() == VALUE1);
789 
790  // set inputs of CDoublArrayAccessor
792 
793  // calculate the result
795 
796  // assert result
797  CPPUNIT_ASSERT_MESSAGE("accessing of second element failed", m_dDoubleInput() == VALUE2);
798 
799  // set inputs of CDoublArrayAccessor
801 
802  // calculate the result
804 
805  // assert result
806  CPPUNIT_ASSERT_MESSAGE("accessing of third/last element failed", m_dDoubleInput() == VALUE3);
807  // Bouml preserved body end 00082582
808 
809 } // void CFunctionBlock::TestDoubleArrayAccessor() throw(::std::exception)
810 
811 
812 
813 
814 void CFunctionBlock::TestBoolGate() throw(::std::exception)
815 {
816  // Bouml preserved body begin 00082602
817  // reset boolean input of fixture
818  m_bBoolInput = false;
819 
820  // set inputs of CBoolGate object
821  m_pBoolGate->m_bGateInput = true;
822  m_pBoolGate->m_bOpen = false;
823 
824  // calculate result
826 
827  // assert result
828  CPPUNIT_ASSERT_MESSAGE("closing of boolean gate failed", m_bBoolInput() == false);
829 
830  // set inputs of CBoolGate object
831  m_pBoolGate->m_bOpen = true;
832 
833  // calculate result
835 
836  // assert result
837  CPPUNIT_ASSERT_MESSAGE("opening of boolean gate failed", m_bBoolInput() == true);
838  // Bouml preserved body end 00082602
839 
840 } // void CFunctionBlock::TestBoolGate() throw(::std::exception)
841 
842 
843 
844 
845 void CFunctionBlock::TestBrakingToTargetSpeed() throw(::std::exception)
846 {
847  // Bouml preserved body begin 00082682
848  const double PERMITTED_VELOCITY(100.0);
849  const double VELOCITY(PERMITTED_VELOCITY * 0.90);
850  const double VELOCITY_SOFT(PERMITTED_VELOCITY * 1.025);
851  const double VELOCITY_HARD(PERMITTED_VELOCITY * 1.10);
852  const double VELOCITY_EMERGENCY(PERMITTED_VELOCITY * 2.0);
853  const double ADHESION_FACTOR(1.0);
854  const double ABSOLUTE_DISTANCE(1000.0);
855  const double ABSOLUTE_DISTANCE_TO_PERMITTED(ABSOLUTE_DISTANCE + 500.0);
856 
857 
858 
859  // set inputs for permitted velocity
861  m_pBrakingToTargetSpeed->m_dDistanceOfPermittedVelocity = ABSOLUTE_DISTANCE_TO_PERMITTED;
863  m_pBrakingToTargetSpeed->m_dPermittedVelocity = PERMITTED_VELOCITY;
864  m_pBrakingToTargetSpeed->m_dAdhesionFactor = ADHESION_FACTOR;
865 
866  // calculate outputs
868 
869  // assert results
870  CPPUNIT_ASSERT_MESSAGE("calculation of service brake intensity for permitted speed failed", m_dDoubleInput() == 0.0);
871  CPPUNIT_ASSERT_MESSAGE("calculation of emergency brake activation for permitted speed failed", m_bBoolInput() == false);
872  CPPUNIT_ASSERT_MESSAGE("calculation of emergency brake activation flag for permitted speed failed", m_bBoolInput2() == false);
873  CPPUNIT_ASSERT_MESSAGE("calculation of service brake activation flag soft permitted speed failed", m_bBoolInput3() == false);
874  CPPUNIT_ASSERT_MESSAGE("calculation of speed warning flag for permitted speed failed", m_bBoolInput4() == false);
875 
876 
877  // set inputs for velocity in soft limit
879  m_pBrakingToTargetSpeed->m_dDistanceOfPermittedVelocity = ABSOLUTE_DISTANCE_TO_PERMITTED;
881  m_pBrakingToTargetSpeed->m_dPermittedVelocity = PERMITTED_VELOCITY;
882  m_pBrakingToTargetSpeed->m_dAdhesionFactor = ADHESION_FACTOR;
883 
884  // calculate outputs
886 
887  // assert results
888  CPPUNIT_ASSERT_MESSAGE("calculation of service brake intensity for permitted speed failed", m_dDoubleInput() == 0.0);
889  CPPUNIT_ASSERT_MESSAGE("calculation of emergency brake activation for permitted speed failed", m_bBoolInput() == false);
890  CPPUNIT_ASSERT_MESSAGE("calculation of emergency brake activation flag for soft permitted speed failed", m_bBoolInput2() == false);
891  CPPUNIT_ASSERT_MESSAGE("calculation of service brake activation flag soft permitted speed failed", m_bBoolInput3() == false);
892  CPPUNIT_ASSERT_MESSAGE("calculation of speed warning flag for permitted speed failed", m_bBoolInput4() == true);
893 
894 
895  // set inputs for velocity over hard limit
897  m_pBrakingToTargetSpeed->m_dDistanceOfPermittedVelocity = ABSOLUTE_DISTANCE_TO_PERMITTED;
899  m_pBrakingToTargetSpeed->m_dPermittedVelocity = PERMITTED_VELOCITY;
900  m_pBrakingToTargetSpeed->m_dAdhesionFactor = ADHESION_FACTOR;
901 
902  // calculate outputs
904 
905  // assert results
906  CPPUNIT_ASSERT_MESSAGE("calculation of service brake intensity for speed over hard limit failed", m_dDoubleInput() >= 1.0 && m_dDoubleInput() <= 100.0);
907  CPPUNIT_ASSERT_MESSAGE("calculation of emergency brake activation for speed over hard limit failed", m_bBoolInput() == false);
908  CPPUNIT_ASSERT_MESSAGE("calculation of emergency brake activation flag for speed over hard limit failed", m_bBoolInput2() == false);
909  CPPUNIT_ASSERT_MESSAGE("calculation of service brake activation flag for speed over hard limit failed", m_bBoolInput3() == true);
910  CPPUNIT_ASSERT_MESSAGE("calculation of speed warning flag for speed over hard limit failed", m_bBoolInput4() == true);
911 
912 
913  // set inputs for velocity over physical/emergency limit
915  m_pBrakingToTargetSpeed->m_dDistanceOfPermittedVelocity = ABSOLUTE_DISTANCE_TO_PERMITTED;
916  m_pBrakingToTargetSpeed->m_dCurrentVelocity = VELOCITY_EMERGENCY;
917  m_pBrakingToTargetSpeed->m_dPermittedVelocity = PERMITTED_VELOCITY;
918  m_pBrakingToTargetSpeed->m_dAdhesionFactor = ADHESION_FACTOR;
919 
920  // calculate outputs
922 
923  // assert results
924  CPPUNIT_ASSERT_MESSAGE("calculation of service brake intensity for speed over emergency limit failed", m_dDoubleInput() == 100.0);
925  CPPUNIT_ASSERT_MESSAGE("calculation of emergency brake activation for speed over emergency limit failed", m_bBoolInput() == true);
926  CPPUNIT_ASSERT_MESSAGE("calculation of emergency brake activation flag for speed over emergency limit failed", m_bBoolInput2() == true);
927  CPPUNIT_ASSERT_MESSAGE("calculation of service brake activation flag for speed over emergency limit failed", m_bBoolInput3() == true);
928  CPPUNIT_ASSERT_MESSAGE("calculation of speed warning flag for speed over emergency limit failed", m_bBoolInput4() == true);
929  // Bouml preserved body end 00082682
930 
931 } // void CFunctionBlock::TestBrakingToTargetSpeed() throw(::std::exception)
932 
933 
934 
935 
936 void CFunctionBlock::TestCeelingSpeedControl() throw(::std::exception)
937 {
938  // Bouml preserved body begin 000BCD02
939  const double PERMITTED_VELOCITY(100.0);
940  const double VELOCITY(PERMITTED_VELOCITY * 0.90);
941  const double VELOCITY_SOFT(PERMITTED_VELOCITY * 1.025);
942  const double VELOCITY_HARD(PERMITTED_VELOCITY * 1.10);
943  const double VELOCITY_EMERGENCY(PERMITTED_VELOCITY * 2.10);
944  const double ADHESION_FACTOR(1.0);
945  const double ABSOLUTE_DISTANCE(1000.0);
946 
947 
948  // set inputs for permitted velocity
950  m_pCeelingSpeedControl->m_dAdhesionFactor = ADHESION_FACTOR;
951  m_pCeelingSpeedControl->m_dPermittedVelocity = PERMITTED_VELOCITY;
953 
954  // calculate outputs
956 
957  // assert results
958  CPPUNIT_ASSERT_MESSAGE("calculation of service brake intensity for permitted speed failed", m_dDoubleInput() == 0.0);
959  CPPUNIT_ASSERT_MESSAGE("calculation of emergency brake activation for permitted speed failed", m_bBoolInput() == false);
960  CPPUNIT_ASSERT_MESSAGE("calculation of emergency brake activation flag for permitted speed failed", m_bBoolInput2() == false);
961  CPPUNIT_ASSERT_MESSAGE("calculation of service brake activation flag soft permitted speed failed", m_bBoolInput3() == false);
962  CPPUNIT_ASSERT_MESSAGE("calculation of speed warning flag for permitted speed failed", m_bBoolInput4() == false);
963 
964 
965  // set inputs for velocity in soft limit
967  m_pCeelingSpeedControl->m_dAdhesionFactor = ADHESION_FACTOR;
968  m_pCeelingSpeedControl->m_dPermittedVelocity = PERMITTED_VELOCITY;
970 
971  // calculate outputs
973 
974  // assert results
975  CPPUNIT_ASSERT_MESSAGE("calculation of service brake intensity for soft permitted speed failed", m_dDoubleInput() == 0.0);
976  CPPUNIT_ASSERT_MESSAGE("calculation of emergency brake activation for soft permitted speed failed", m_bBoolInput() == false);
977  CPPUNIT_ASSERT_MESSAGE("calculation of emergency brake activation flag for soft permitted speed failed", m_bBoolInput2() == false);
978  CPPUNIT_ASSERT_MESSAGE("calculation of service brake activation flag for soft permitted speed failed", m_bBoolInput3() == false);
979  CPPUNIT_ASSERT_MESSAGE("calculation of speed warning flag for soft permitted speed failed", m_bBoolInput4() == true);
980 
981  // set inputs for velocity over hard limit
983  m_pCeelingSpeedControl->m_dAdhesionFactor = ADHESION_FACTOR;
984  m_pCeelingSpeedControl->m_dPermittedVelocity = PERMITTED_VELOCITY;
986 
987  // calculate outputs
989 
990  // assert results
991  CPPUNIT_ASSERT_MESSAGE("calculation of service brake intensity for speed over hard limit failed", m_dDoubleInput() >= 1.0 && m_dDoubleInput() <= 100.0);
992  CPPUNIT_ASSERT_MESSAGE("calculation of emergency brake activation for speed over hard limit failed", m_bBoolInput() == false);
993  CPPUNIT_ASSERT_MESSAGE("calculation of emergency brake activation flag for speed over hard limit failed", m_bBoolInput2() == false);
994  CPPUNIT_ASSERT_MESSAGE("calculation of service brake activation flag for speed over hard limit failed", m_bBoolInput3() == true);
995  CPPUNIT_ASSERT_MESSAGE("calculation of speed warning flag for speed over hard limit failed", m_bBoolInput4() == true);
996 
997  // set inputs for velocity over physical/emergency limit
999  m_pCeelingSpeedControl->m_dAdhesionFactor = ADHESION_FACTOR;
1000  m_pCeelingSpeedControl->m_dPermittedVelocity = PERMITTED_VELOCITY;
1001  m_pCeelingSpeedControl->m_dCurrentVelocity = VELOCITY_EMERGENCY;
1002 
1003  // calculate outputs
1005 
1006  // assert results
1007  CPPUNIT_ASSERT_MESSAGE("calculation of service brake intensity for speed over emergency limit failed", m_dDoubleInput() == 100.0);
1008  CPPUNIT_ASSERT_MESSAGE("calculation of emergency brake activation for speed over emergency limit failed", m_bBoolInput() == true);
1009  CPPUNIT_ASSERT_MESSAGE("calculation of emergency brake activation flag for speed over emergency limit failed", m_bBoolInput2() == true);
1010  CPPUNIT_ASSERT_MESSAGE("calculation of service brake activation flag for speed over emergency limit failed", m_bBoolInput3() == true);
1011  CPPUNIT_ASSERT_MESSAGE("calculation of speed warning flag for speed over emergency limit failed", m_bBoolInput4() == true);
1012  // Bouml preserved body end 000BCD02
1013 
1014 } // void CFunctionBlock::TestCeelingSpeedControl() throw(::std::exception)
1015 
1016 
1017 
1018 
1019 void CFunctionBlock::TestStringGate() throw(::std::exception)
1020 {
1021  // Bouml preserved body begin 00082702
1022  unsigned int x(0);
1023  ::std::string Value1;
1024 
1025 
1026 
1027  // create random string
1028  for (x = 0; x < 20; x++)
1029  {
1030  // add random char to string
1031  Value1 += char(double(rand()) / double(RAND_MAX) * 94.0 + 32.0);
1032 
1033  } // for (x = 0; x < 20; x++)
1034 
1035  // reset string input of fixture
1036  m_StringInput().clear();
1037 
1038  // set inputs of CStringGate object
1039  m_pStringGate->m_GateInput = Value1;
1040  m_pStringGate->m_bOpen = false;
1041 
1042  // calculate result
1044 
1045  // assert result
1046  CPPUNIT_ASSERT_MESSAGE("closing of string gate failed", m_StringInput().empty());
1047 
1048  // set inputs of CStringGate object
1049  m_pStringGate->m_bOpen = true;
1050 
1051  // calculate result
1053 
1054  // assert result
1055  CPPUNIT_ASSERT_MESSAGE("opening of string gate failed", m_StringInput() == Value1);
1056  // Bouml preserved body end 00082702
1057 
1058 } // void CFunctionBlock::TestStringGate() throw(::std::exception)
1059 
1060 
1061 
1062 
1063 void CFunctionBlock::TestDoubleGate() throw(::std::exception)
1064 {
1065  // Bouml preserved body begin 00082782
1066  const double VALUE1(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
1067  const double VALUE2(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
1068 
1069 
1070 
1071  // reset double input of fixture
1072  m_dDoubleInput = VALUE2;
1073 
1074  // set inputs of CDoubleGate object
1075  m_pDoubleGate->m_dGateInput = VALUE1;
1076  m_pDoubleGate->m_bOpen = false;
1077 
1078  // calculate result
1080 
1081  // assert result
1082  CPPUNIT_ASSERT_MESSAGE("closing of double gate failed", m_dDoubleInput() == VALUE2);
1083 
1084  // set inputs of CDoubleGate object
1085  m_pDoubleGate->m_bOpen = true;
1086 
1087  // calculate result
1089 
1090  // assert result
1091  CPPUNIT_ASSERT_MESSAGE("opening of double gate failed", m_dDoubleInput() == VALUE1);
1092  // Bouml preserved body end 00082782
1093 
1094 } // void CFunctionBlock::TestDoubleGate() throw(::std::exception)
1095 
1096 
1097 
1098 
1099 void CFunctionBlock::TestBoolSwitch() throw(::std::exception)
1100 {
1101  // Bouml preserved body begin 00082802
1102  // reset boolean input of fixture
1103  m_bBoolInput = false;
1104 
1105  // set inputs of CBoolSwitch object
1106  m_pBoolSwitch->m_bInput1 = true;
1107  m_pBoolSwitch->m_bInput2 = false;
1108  m_pBoolSwitch->m_bUseInput1 = true;
1109 
1110  // calculate result
1112 
1113  // assert result
1114  CPPUNIT_ASSERT_MESSAGE("activating boolean switch failed", m_bBoolInput() == true);
1115 
1116  // set inputs of CBoolSwitch object
1117  m_pBoolSwitch->m_bUseInput1 = false;
1118 
1119  // calculate result
1121 
1122  // assert result
1123  CPPUNIT_ASSERT_MESSAGE("deactivating boolean switch failed", m_bBoolInput() == false);
1124  // Bouml preserved body end 00082802
1125 
1126 } // void CFunctionBlock::TestBoolSwitch() throw(::std::exception)
1127 
1128 
1129 
1130 
1131 void CFunctionBlock::TestDoubleSwitch() throw(::std::exception)
1132 {
1133  // Bouml preserved body begin 00082882
1134  const double VALUE1(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
1135  const double VALUE2(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
1136  const double VALUE3(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
1137 
1138 
1139 
1140  // reset double input of fixture
1141  m_dDoubleInput = VALUE3;
1142 
1143  // set inputs of CDoubleSwitch object
1144  m_pDoubleSwitch->m_dInput1 = VALUE1;
1145  m_pDoubleSwitch->m_dInput2 = VALUE2;
1146  m_pDoubleSwitch->m_bUseInput1 = true;
1147 
1148  // calculate result
1150 
1151  // assert result
1152  CPPUNIT_ASSERT_MESSAGE("activating double switch failed", m_dDoubleInput() == VALUE1);
1153 
1154  // set inputs of CDoubleSwitch object
1155  m_pDoubleSwitch->m_bUseInput1 = false;
1156 
1157  // calculate result
1159 
1160  // assert result
1161  CPPUNIT_ASSERT_MESSAGE("deactivating double switch failed", m_dDoubleInput() == VALUE2);
1162  // Bouml preserved body end 00082882
1163 
1164 } // void CFunctionBlock::TestDoubleSwitch() throw(::std::exception)
1165 
1166 
1167 
1168 
1169 void CFunctionBlock::TestStringSwitch() throw(::std::exception)
1170 {
1171  // Bouml preserved body begin 00082902
1172  unsigned int x(0);
1173  ::std::string Value1;
1174  ::std::string Value2;
1175 
1176 
1177 
1178  // create random string
1179  for (x = 0; x < 20; x++)
1180  {
1181  // add random char to strings
1182  Value1 += char(double(rand()) / double(RAND_MAX) * 94.0 + 32.0);
1183  Value2 += char(double(rand()) / double(RAND_MAX) * 94.0 + 32.0);
1184 
1185  } // for (x = 0; x < 20; x++)
1186 
1187  // reset string input of fixture
1188  m_StringInput().clear();
1189 
1190  // set inputs of CStringSwitch object
1191  m_pStringSwitch->m_Input1 = Value1;
1192  m_pStringSwitch->m_Input2 = Value2;
1193  m_pStringSwitch->m_bUseInput1 = true;
1194 
1195  // calculate result
1197 
1198  // assert result
1199  CPPUNIT_ASSERT_MESSAGE("activating string switch failed", m_StringInput() == Value1);
1200 
1201  // set inputs of CDoubleCStringSwitchSwitch object
1202  m_pStringSwitch->m_bUseInput1 = false;
1203 
1204  // calculate result
1206 
1207  // assert result
1208  CPPUNIT_ASSERT_MESSAGE("deactivating string switch failed", m_StringInput() == Value2);
1209  // Bouml preserved body end 00082902
1210 
1211 } // void CFunctionBlock::TestStringSwitch() throw(::std::exception)
1212 
1213 
1214 
1215 
1216 void CFunctionBlock::TestEnteredTrigger() throw(::std::exception)
1217 {
1218  // Bouml preserved body begin 00082982
1219  // reset boolean input of fixture
1220  m_bBoolInput = true;
1221 
1222  // set inputs of CEnteredTrigger object
1224 
1225  // calculate result
1227 
1228  // assert result
1229  CPPUNIT_ASSERT_MESSAGE("setting of entered trigger failed", m_bBoolInput() == false);
1230 
1231  // set inputs of CEnteredTrigger object
1233 
1234  // calculate result
1236 
1237  // assert result
1238  CPPUNIT_ASSERT_MESSAGE("setting of entered trigger failed", m_bBoolInput() == true);
1239  // Bouml preserved body end 00082982
1240 
1241 } // void CFunctionBlock::TestEnteredTrigger() throw(::std::exception)
1242 
1243 
1244 
1245 
1246 void CFunctionBlock::TestStorage() throw(::std::exception)
1247 {
1248  // Bouml preserved body begin 00082A02
1249  const double VALUE1(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
1250  const double VALUE2(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
1251  const double VALUE3(200.0 * double(rand()) / double(RAND_MAX) - 100.0);
1252  const int VALUE4(rand() - RAND_MAX / 2);
1253  const ::std::string VALUE5("3.14");
1254  ::std::stringstream Stream;
1255  ::std::vector< double > Array(2);
1256 
1257 
1258 
1259  // set input of CStorage
1260  m_pStorage->m_dDoubleInput = VALUE1;
1261 
1262  // calculate results
1263  m_pStorage->Calculate();
1264 
1265  // stream value
1266  Stream.str(::std::string());
1267  Stream << VALUE1;
1268 
1269  // assert results
1270  CPPUNIT_ASSERT_MESSAGE("copying of double failed", m_dDoubleInput() == VALUE1);
1271  CPPUNIT_ASSERT_MESSAGE("double conversion to double array failed", m_DoubleArrayInput().size() == 1);
1272  CPPUNIT_ASSERT_MESSAGE("double conversion to double array failed", m_DoubleArrayInput()[0] == VALUE1);
1273  CPPUNIT_ASSERT_MESSAGE("double conversion to integer failed", m_iIntInput() == int(VALUE1));
1274  CPPUNIT_ASSERT_MESSAGE("double conversion to string failed", m_StringInput() == Stream.str());
1275  CPPUNIT_ASSERT_MESSAGE("double conversion to boolean failed", m_bBoolInput() == bool(VALUE1));
1276  CPPUNIT_ASSERT_MESSAGE("bit copy of double failed", m_pBitStorage->m_dDoubleInput() == VALUE1);
1277 
1278 
1279  // create array
1280  Array[0] = VALUE2;
1281  Array[1] = VALUE3;
1282 
1283  // set input of CStorage
1284  m_pStorage->m_DoubleArrayInput = Array;
1285 
1286  // calculate results
1287  m_pStorage->Calculate();
1288 
1289  // stream value
1290  Stream.str(::std::string());
1291  Stream << VALUE2;
1292 
1293  // assert results
1294  CPPUNIT_ASSERT_MESSAGE("double array conversion to double failed", m_dDoubleInput() == VALUE2);
1295  CPPUNIT_ASSERT_MESSAGE("copying of double array failed",m_DoubleArrayInput().size() == 2);
1296  CPPUNIT_ASSERT_MESSAGE("copying of double array failed",m_DoubleArrayInput()[0] == VALUE2);
1297  CPPUNIT_ASSERT_MESSAGE("copying of double array failed",m_DoubleArrayInput()[1] == VALUE3);
1298  CPPUNIT_ASSERT_MESSAGE("double array conversion to integer failed",m_iIntInput() == int(VALUE2));
1299  CPPUNIT_ASSERT_MESSAGE("double array conversion to string failed",m_StringInput() == Stream.str());
1300  CPPUNIT_ASSERT_MESSAGE("copying of double array failed",m_DoubleArrayInput() == Array);
1301  CPPUNIT_ASSERT_MESSAGE("double array conversion to boolean failed", m_bBoolInput() == bool(VALUE2));
1302  CPPUNIT_ASSERT_MESSAGE("bit copy of double array failed", m_pBitStorage->m_DoubleArrayInput() == Array);
1303 
1304 
1305  // set input of CStorage
1306  m_pStorage->m_iIntInput = VALUE4;
1307 
1308  // calculate results
1309  m_pStorage->Calculate();
1310 
1311  // stream value
1312  Stream.str(::std::string());
1313  Stream << VALUE4;
1314 
1315  // assert results
1316  CPPUNIT_ASSERT_MESSAGE("integer conversion to double failed", m_dDoubleInput() == double(VALUE4));
1317  CPPUNIT_ASSERT_MESSAGE("integer conversion to double array failed", m_DoubleArrayInput().size() == 1);
1318  CPPUNIT_ASSERT_MESSAGE("integer conversion to double array failed", m_DoubleArrayInput()[0] == double(VALUE4));
1319  CPPUNIT_ASSERT_MESSAGE("copying of integer failed", m_iIntInput() == VALUE4);
1320  CPPUNIT_ASSERT_MESSAGE("integer conversion to string failed", m_StringInput() == Stream.str());
1321  CPPUNIT_ASSERT_MESSAGE("integer conversion to boolean failed", m_bBoolInput() == bool(VALUE4));
1322  CPPUNIT_ASSERT_MESSAGE("bit copy of integer failed", m_pBitStorage->m_iIntInput() == VALUE4);
1323 
1324 
1325  // set input of CStorage
1326  m_pStorage->m_bBoolInput = true;
1327 
1328  // calculate results
1329  m_pStorage->Calculate();
1330 
1331  // assert results
1332  CPPUNIT_ASSERT_MESSAGE("boolean conversion to double failed", m_dDoubleInput() == 1.0);
1333  CPPUNIT_ASSERT_MESSAGE("boolean conversion to double array failed", m_DoubleArrayInput().size() == 1);
1334  CPPUNIT_ASSERT_MESSAGE("boolean conversion to double array failed", m_DoubleArrayInput()[0] == 1.0);
1335  CPPUNIT_ASSERT_MESSAGE("boolean conversion to integer failed", m_iIntInput() == 1);
1336  CPPUNIT_ASSERT_MESSAGE("boolean conversion to string failed", m_StringInput() == "true");
1337  CPPUNIT_ASSERT_MESSAGE("copying of boolean failed", m_bBoolInput() == true);
1338  CPPUNIT_ASSERT_MESSAGE("bit copy of boolean failed", m_pBitStorage->m_bBoolInput() == true);
1339 
1340 
1341  // set input of CStorage
1342  m_pStorage->m_bBoolInput = false;
1343 
1344  // calculate results
1345  m_pStorage->Calculate();
1346 
1347  // assert results
1348  CPPUNIT_ASSERT_MESSAGE("boolean conversion to double failed", m_dDoubleInput() == 0.0);
1349  CPPUNIT_ASSERT_MESSAGE("boolean conversion to double array failed", m_DoubleArrayInput().size() == 1);
1350  CPPUNIT_ASSERT_MESSAGE("boolean conversion to double array failed", m_DoubleArrayInput()[0] == 0.0);
1351  CPPUNIT_ASSERT_MESSAGE("boolean conversion to integer failed", m_iIntInput() == 0);
1352  CPPUNIT_ASSERT_MESSAGE("boolean conversion to string failed", m_StringInput() == "false");
1353  CPPUNIT_ASSERT_MESSAGE("copying of boolean failed", m_bBoolInput() == false);
1354  CPPUNIT_ASSERT_MESSAGE("bit copy of boolean failed", m_pBitStorage->m_bBoolInput() == false);
1355 
1356 
1357  // set input of CStorage
1358  m_pStorage->m_StringInput = VALUE5;
1359 
1360  // calculate results
1361  m_pStorage->Calculate();
1362 
1363  // assert results
1364  CPPUNIT_ASSERT_MESSAGE("string conversion to double failed", m_dDoubleInput() == 3.14);
1365  CPPUNIT_ASSERT_MESSAGE("string conversion to double array failed", m_DoubleArrayInput().size() == 1);
1366  CPPUNIT_ASSERT_MESSAGE("string conversion to double array failed", m_DoubleArrayInput()[0] == 3.14);
1367  CPPUNIT_ASSERT_MESSAGE("string conversion to integer failed", m_iIntInput() == 3);
1368  CPPUNIT_ASSERT_MESSAGE("string conversion to boolean failed", m_bBoolInput() == true);
1369  CPPUNIT_ASSERT_MESSAGE("copying of string failed", m_StringInput() == VALUE5);
1370  CPPUNIT_ASSERT_MESSAGE("bit copy of string failed", m_pBitStorage->m_StringInput() == VALUE5);
1371  // Bouml preserved body end 00082A02
1372 
1373 } // void CFunctionBlock::TestStorage() throw(::std::exception)
1374 
1375 
1376 
1377 
1379 :m_pTelegram(0)
1380 {
1381  // Bouml preserved body begin 00084702
1382  // empty constructor
1383  // Bouml preserved body end 00084702
1384 
1385 } // CLanguage::CLanguage() throw()
1386 
1387 
1388 
1389 
1390 void CLanguage::setUp() throw(::std::bad_alloc)
1391 {
1392  // Bouml preserved body begin 00084602
1393  // create storages
1409 
1410  // create all substructures and connections/flows
1411  ::oETCS::DF::CStorage* pStorage1(new ::oETCS::DF::CStorage(&m_StateMachine));
1412  pStorage1->m_BoolValue.push_back(new ::oETCS::DF::CFlow< bool >(m_BoolInput["Storage1"], &m_StateMachine));
1413  pStorage1->m_DoubleValue.push_back(new ::oETCS::DF::CFlow< double >(m_DoubleInput["Storage1"], &m_StateMachine));
1414  pStorage1->m_DoubleArrayValue.push_back(new ::oETCS::DF::CFlow< ::std::vector< double > >(m_DoubleArrayInput["Storage1"], &m_StateMachine));
1415  pStorage1->m_IntValue.push_back(new ::oETCS::DF::CFlow< signed int >(m_IntInput["Storage1"], &m_StateMachine));
1416  pStorage1->m_StringValue.push_back(new ::oETCS::DF::CFlow< ::std::string >(m_StringInput["Storage1"], &m_StateMachine));
1417  ::oETCS::DF::CStorage* pStorage2(new ::oETCS::DF::CStorage(&m_StateMachine));
1418  pStorage2->m_BoolValue.push_back(new ::oETCS::DF::CFlow< bool >(m_BoolInput["Storage2"], &m_StateMachine));
1419  pStorage2->m_DoubleValue.push_back(new ::oETCS::DF::CFlow< double >(m_DoubleInput["Storage2"], &m_StateMachine));
1420  pStorage2->m_DoubleArrayValue.push_back(new ::oETCS::DF::CFlow< ::std::vector< double > >(m_DoubleArrayInput["Storage2"], &m_StateMachine));
1421  pStorage2->m_IntValue.push_back(new ::oETCS::DF::CFlow< signed int >(m_IntInput["Storage2"], &m_StateMachine));
1422  pStorage2->m_StringValue.push_back(new ::oETCS::DF::CFlow< ::std::string >(m_StringInput["Storage2"], &m_StateMachine));
1423  ::oETCS::DF::CStorage* pStorage3(new ::oETCS::DF::CStorage(&m_StateMachine));
1424  pStorage3->m_BoolValue.push_back(new ::oETCS::DF::CFlow< bool >(m_BoolInput["Storage3"], &m_StateMachine));
1425  pStorage3->m_DoubleValue.push_back(new ::oETCS::DF::CFlow< double >(m_DoubleInput["Storage3"], &m_StateMachine));
1426  pStorage3->m_DoubleArrayValue.push_back(new ::oETCS::DF::CFlow< ::std::vector< double > >(m_DoubleArrayInput["Storage3"], &m_StateMachine));
1427  pStorage3->m_IntValue.push_back(new ::oETCS::DF::CFlow< signed int >(m_IntInput["Storage3"], &m_StateMachine));
1428  pStorage3->m_StringValue.push_back(new ::oETCS::DF::CFlow< ::std::string >(m_StringInput["Storage3"], &m_StateMachine));
1429  ::oETCS::DF::CVariable* pVariable0(new ::oETCS::DF::CVariable(&m_StateMachine, 1, ::oETCS::DF::CVariable::INTEGER, 8)); // packet ID
1430  ::oETCS::DF::CVariable* pVariable1(new ::oETCS::DF::CVariable(&m_StateMachine, 1, ::oETCS::DF::CVariable::STRING, 96));
1431  pVariable1->m_BitValues.push_back(new ::oETCS::DF::CBitFlow(pStorage1, &m_StateMachine));
1432  ::oETCS::DF::CVariable* pVariable2(new ::oETCS::DF::CVariable(&m_StateMachine, 1, ::oETCS::DF::CVariable::INTEGER, 16));
1433  pVariable2->m_BitValues.push_back(new ::oETCS::DF::CBitFlow(pStorage2, &m_StateMachine));
1434  ::oETCS::DF::CVariable* pVariable3(new ::oETCS::DF::CVariable(&m_StateMachine, 1, ::oETCS::DF::CVariable::INTEGER, 8));
1435  pVariable3->m_ScaledVariables.push_back(pVariable2);
1436  ::oETCS::DF::CVariable* pVariable4(new ::oETCS::DF::CVariable(&m_StateMachine, 1, ::oETCS::DF::CVariable::INTEGER, 8)); // packet ID
1437  ::oETCS::DF::CVariable* pVariable5(new ::oETCS::DF::CVariable(&m_StateMachine, 1, ::oETCS::DF::CVariable::KILO_METERS_PER_HOUR, 32));
1438  pVariable5->m_BitValues.push_back(new ::oETCS::DF::CBitFlow(pStorage3, &m_StateMachine));
1439  ::oETCS::DF::CVariable* pVariable6(new ::oETCS::DF::CVariable(&m_StateMachine, 1, ::oETCS::DF::CVariable::INTEGER, 8));
1440  pVariable6->m_IteratedVariables.push_back(pVariable5);
1441 
1442  ::std::vector< ::oETCS::DF::CVariable* > Variables1(3);
1443  ::std::vector< ::oETCS::DF::CVariable* > Variables2(3);
1444  Variables1[0] = pVariable0;
1445  Variables1[1] = pVariable3;
1446  Variables1[2] = pVariable2;
1447  Variables2[0] = pVariable4;
1448  Variables2[1] = pVariable6;
1449  Variables2[2] = pVariable5;
1450 
1451  ::oETCS::DF::CPacket* pPacket1(new ::oETCS::DF::CPacket(&m_StateMachine, 1, Variables1));
1452  ::oETCS::DF::CPacket* pPacket2(new ::oETCS::DF::CPacket(&m_StateMachine, 2, Variables2));
1453 
1454  ::std::vector< ::oETCS::DF::CPacket* > Packets(2);
1455  Packets[0] = pPacket1;
1456  Packets[1] = pPacket2;
1457 
1458 
1459  // finally create test telegram with all packets and variables
1460  m_pTelegram = new ::oETCS::DF::CTelegram(&m_StateMachine, ::std::vector< ::oETCS::DF::CVariable* >(1, pVariable1), Packets);
1461  // Bouml preserved body end 00084602
1462 
1463 } // void CLanguage::setUp() throw(::std::bad_alloc)
1464 
1465 
1466 
1467 
1468 void CLanguage::tearDown() throw()
1469 {
1470  // Bouml preserved body begin 00084682
1471  // nothing to delete explicitly
1472  // Bouml preserved body end 00084682
1473 
1474 } // void CLanguage::tearDown() throw()
1475 
1476 
1477 
1478 
1479 void CLanguage::TestTelegram() throw(::std::exception)
1480 {
1481  // Bouml preserved body begin 00087B82
1482  unsigned int x(0);
1483  unsigned int y(0);
1484  //const char pString[] = {'H','e','l','l','o',' ','W','o','r','l','d','!'};
1485  const unsigned char* pByte(0);
1486  const unsigned char c8ID1(1);
1487  const unsigned char c8ID2(2);
1488  const int i8Scalor(3);
1489  const int i16Value(11);
1490  const int i8Iterator(2);
1491  const int i32Iterated1(234);
1492  const int i32Iterated2(567);
1493  unsigned long lOffset(0);
1494  const ::std::string STRING("Hello World!");
1495  const unsigned long BIT_LENGTH((STRING.size() * 8) + 8 + 8 + 8 + 16 + 8 + (32 * 2));
1496  ::std::vector< bool > Bits(BIT_LENGTH, 0);
1497  const int SCALED_VALUE(i8Scalor * i16Value);
1498  const double ITERATED1(i32Iterated1 / 3.6);
1499  const double ITERATED2(i32Iterated2 / 3.6);
1500 
1501 
1502 
1503  // copy bytes of string into vector
1504  for (x = 0; x < STRING.size(); x++)
1505  {
1506  // initialise byte pointer
1507  pByte = reinterpret_cast< const unsigned char* >(&STRING[x]);
1508 
1509 
1510  // copy all bits of current byte
1511  for (y = 0; y < 8; y++)
1512  {
1513  // copy current bit
1514  Bits[(x * 8) + y] = ((1 << (7 - y)) & (*pByte));
1515 
1516  } // for (y = 0; y < 8; y++)
1517 
1518  } // for (x = 0; x < STRING.size(); x++)
1519 
1520  // set bit offset
1521  lOffset += STRING.size() * 8;
1522 
1523  // initialise byte pointer
1524  pByte = reinterpret_cast< const unsigned char* >(&c8ID1);
1525 
1526  // copy all bytes of current byte
1527  for (y = 0; y < 8; y++)
1528  {
1529  // copy current bit
1530  Bits[lOffset + y] = ((1 << (7 - y)) & (*pByte));
1531 
1532  } // for (y = 0; y < 8; y++)
1533 
1534  // set bit offset
1535  lOffset += 8;
1536 
1537  // initialise byte pointer
1538  pByte = reinterpret_cast< const unsigned char* >(&i8Scalor);
1539 
1540  // copy all bytes of current byte
1541  for (y = 0; y < 8; y++)
1542  {
1543  // copy current bit
1544  Bits[lOffset + y] = ((1 << (7 - y)) & (*pByte));
1545 
1546  } // for (y = 0; y < 8; y++)
1547 
1548  // set bit offset
1549  lOffset += 8;
1550 
1551  // initialise byte pointer
1552  pByte = reinterpret_cast< const unsigned char* >(&i16Value) + 1;
1553 
1554  // copy bytes of value into vector
1555  for (x = 0; x < 2; x++)
1556  {
1557  // copy all bits of current byte
1558  for (y = 0; y < 8; y++)
1559  {
1560  // copy current bit
1561  Bits[(x * 8) + y + lOffset] = ((1 << (7 - y)) & (*pByte));
1562 
1563  } // for (y = 0; y < 8; y++)
1564 
1565  // increase byte pointer
1566  pByte--;
1567 
1568  } // for (x = 0; x < 2; x++)
1569 
1570  // set bit offset
1571  lOffset += 16;
1572 
1573  // initialise byte pointer
1574  pByte = reinterpret_cast< const unsigned char* >(&c8ID2);
1575 
1576  // copy all bytes of current byte
1577  for (y = 0; y < 8; y++)
1578  {
1579  // copy current bit
1580  Bits[lOffset + y] = ((1 << (7 - y)) & (*pByte));
1581 
1582  } // for (y = 0; y < 8; y++)
1583 
1584  // set bit offset
1585  lOffset += 8;
1586 
1587  // initialise byte pointer
1588  pByte = reinterpret_cast< const unsigned char* >(&i8Iterator);
1589 
1590  // copy all bytes of current byte
1591  for (y = 0; y < 8; y++)
1592  {
1593  // copy current bit
1594  Bits[lOffset + y] = ((1 << (7 - y)) & (*pByte));
1595 
1596  } // for (y = 0; y < 8; y++)
1597 
1598  // set bit offset
1599  lOffset += 8;
1600 
1601  // initialise byte pointer
1602  pByte = reinterpret_cast< const unsigned char* >(&i32Iterated1) + 3;
1603 
1604  // copy bytes of iterated into vector
1605  for (x = 0; x < 4; x++)
1606  {
1607  // copy all bits of current byte
1608  for (y = 0; y < 8; y++)
1609  {
1610  // copy current bit
1611  Bits[(x * 8) + y + lOffset] = ((1 << (7 - y)) & (*pByte));
1612 
1613  } // for (y = 0; y < 8; y++)
1614 
1615  // increase byte pointer
1616  pByte--;
1617 
1618  } // for (x = 0; x < 4; x++)
1619 
1620  // set bit offset
1621  lOffset += 32;
1622 
1623  // initialise byte pointer
1624  pByte = reinterpret_cast< const unsigned char* >(&i32Iterated2) + 3;
1625 
1626  // copy bytes of iterated into vector
1627  for (x = 0; x < 4; x++)
1628  {
1629  // copy all bits of current byte
1630  for (y = 0; y < 8; y++)
1631  {
1632  // copy current bit
1633  Bits[(x * 8) + y + lOffset] = ((1 << (7 - y)) & (*pByte));
1634 
1635  } // for (y = 0; y < 8; y++)
1636 
1637  // increase byte pointer
1638  pByte--;
1639 
1640  } // for (x = 0; x < 4; x++)
1641 
1642  // set bit offset
1643  lOffset += 32;
1644 
1645 
1646  // check test preconditon for bit vector
1647  CPPUNIT_ASSERT_MESSAGE("test precondition bit vector length not correct", lOffset == BIT_LENGTH);
1648 
1649  // send bit vector to telegram
1650  (*m_pTelegram) << Bits;
1651 
1652  // check string output of first storage
1653  CPPUNIT_ASSERT_MESSAGE("string message not corrected dispatched", (*m_StringInput["Storage1"])() == STRING);
1654 
1655  // check integer output of second storage
1656  CPPUNIT_ASSERT_MESSAGE("scaling not correct applied", (*m_IntInput["Storage2"])() == SCALED_VALUE);
1657 
1658  // check double array output of third storage
1659  CPPUNIT_ASSERT_MESSAGE("size of double array not correct", (*m_DoubleArrayInput["Storage3"])().size() == (unsigned)i8Iterator);
1660  CPPUNIT_ASSERT_MESSAGE("first iterated value of array false", (*m_DoubleArrayInput["Storage3"])()[0] == ITERATED1);
1661  CPPUNIT_ASSERT_MESSAGE("first iterated value of array false", (*m_DoubleArrayInput["Storage3"])()[1] == ITERATED2);
1662  // Bouml preserved body end 00087B82
1663 
1664 } // void CLanguage::TestTelegram() throw(::std::exception)
1665 
1666 
1667 
1668 
1670 :m_pStateMachine(0)
1671 {
1672  // Bouml preserved body begin 00089502
1673  // empty constructor
1674  // Bouml preserved body end 00089502
1675 
1676 } // CEVCStateMachine::CEVCStateMachine() throw()
1677 
1678 
1679 
1680 
1681 void CEVCStateMachine::setUp() throw(::std::bad_alloc)
1682 {
1683  // Bouml preserved body begin 00089582
1684  ::oETCS::DF::CEVCCondition* pFrom1To2(0);
1685  ::oETCS::DF::CEVCCondition* pFrom2To3(0);
1686  ::oETCS::DF::CStorage* pPermanentTrue(0);
1687  ::std::vector< ::oETCS::DF::CAbstractFlow* > PermanentTrueOutputs;
1688  ::oETCS::DF::CLevelCondition* pFromSTMToFFN(0);
1689  ::oETCS::DF::CDMISubject* pDMI(0);
1690  ::std::vector< ::oETCS::DF::CFunctionBlock* > Flow1STMFBs(0);
1691  ::std::vector< ::oETCS::DF::CFunctionBlock* > Flow2STMFBs(0);
1692  ::std::vector< ::oETCS::DF::CFunctionBlock* > Flow3FFNFBs(0);
1693  ::std::vector< ::oETCS::DF::CAbstractFlow* > Connections1STM(0);
1694  ::std::vector< ::oETCS::DF::CAbstractFlow* > Connections2STM(0);
1695  ::std::vector< ::oETCS::DF::CAbstractFlow* > Connections3FFN(0);
1696  ::oETCS::DF::CEVCState* pState1(0);
1697  ::oETCS::DF::CEVCState* pState2(0);
1698  ::oETCS::DF::CEVCState* pState3(0);
1699 
1700 
1701 
1702  // create EVC state machine object
1704 
1705 
1706  // create function blocks for data flows, including EVC conditions
1707  pFrom1To2 = new ::oETCS::DF::CEVCCondition(m_pStateMachine);
1708  pFrom2To3 = new ::oETCS::DF::CEVCCondition(m_pStateMachine);
1709  pFromSTMToFFN = new ::oETCS::DF::CLevelCondition(m_pStateMachine, "FFN");
1710 
1711  pPermanentTrue = new ::oETCS::DF::CStorage(m_pStateMachine);
1712  pPermanentTrue->m_BoolValue.push_back(new ::oETCS::DF::CFlow< bool >(&pFrom1To2->m_bGuard, m_pStateMachine));
1713  pPermanentTrue->m_BoolValue.push_back(new ::oETCS::DF::CFlow< bool >(&pFrom2To3->m_bGuard, m_pStateMachine));
1714  pPermanentTrue->m_BoolValue.push_back(new ::oETCS::DF::CFlow< bool >(&pFromSTMToFFN->m_bLevelSwitch, m_pStateMachine));
1715  pPermanentTrue->m_bBoolInput = true;
1716 
1717 
1718  // create three EVC states
1722 
1723 
1724  // create three data flows for EVC states
1725  Flow1STMFBs.push_back(pPermanentTrue);
1726  Flow1STMFBs.push_back(pFrom1To2);
1727  Connections1STM.push_back(pPermanentTrue->m_BoolValue[0]);
1728  new ::oETCS::DF::CDataFlow(pState1, "STM", Flow1STMFBs, Connections1STM, pDMI);
1729  Flow2STMFBs.push_back(pPermanentTrue);
1730  Flow2STMFBs.push_back(pFrom2To3);
1731  Flow2STMFBs.push_back(pFromSTMToFFN);
1732  Connections2STM.push_back(pPermanentTrue->m_BoolValue[1]);
1733  Connections2STM.push_back(pPermanentTrue->m_BoolValue[2]);
1734  new ::oETCS::DF::CDataFlow(pState2, "STM", Flow2STMFBs, Connections2STM, pDMI);
1735  new ::oETCS::DF::CDataFlow(pState3, "FFN", Flow3FFNFBs, Connections3FFN, pDMI);
1736 
1737 
1738  // create EVC transitions between states
1739  new ::oETCS::DF::CEVCTransition(pFrom1To2, pState1, pState2, 0);
1740  new ::oETCS::DF::CEVCTransition(pFrom2To3, pState2, pState3, 1);
1741  // Bouml preserved body end 00089582
1742 
1743 } // void CEVCStateMachine::setUp() throw(::std::bad_alloc)
1744 
1745 
1746 
1747 
1749 {
1750  // Bouml preserved body begin 00089602
1751  // delete EVC state machine
1752  delete m_pStateMachine;
1753  // Bouml preserved body end 00089602
1754 
1755 } // void CEVCStateMachine::tearDown() throw()
1756 
1757 
1758 
1759 
1760 void CEVCStateMachine::TestEVCState() throw(::std::exception)
1761 {
1762  // Bouml preserved body begin 00089682
1763  decltype (m_pStateMachine->GetStates()) States(m_pStateMachine->GetStates());
1764  const ::std::chrono::duration< long long, ::std::micro > SLEEP_TIME(10 * __DATA_FLOW_SAMPLE_TIME__);
1765 
1766 
1767  // start EVC state machine
1768  m_pStateMachine->Start(States[0], "STM");
1769 
1770  // put thread to sleep to wait for execution of state machine
1771  ::std::this_thread::sleep_for(SLEEP_TIME);
1772 
1773  // check current state and application level
1774  CPPUNIT_ASSERT_MESSAGE("target state not reached", m_pStateMachine->GetActiveState() == States[2]);
1775  CPPUNIT_ASSERT_MESSAGE("target application level not reached", m_pStateMachine->m_CurrentApplicationLevel == "FFN");
1776 
1777  // finally stop state machine
1778  m_pStateMachine->Stop();
1779  // Bouml preserved body end 00089682
1780 
1781 } // void CEVCStateMachine::TestEVCState() throw(::std::exception)
1782 
1783 
1784 
1785 
1787 :m_bBoolInput(false),
1788  m_StringInput(""),
1789  m_pStateMachine(0),
1790  m_pControlFlow(0)
1791 {
1792  // Bouml preserved body begin 00091B82
1793  // empty constructor
1794  // Bouml preserved body end 00091B82
1795 
1796 } // CControlFlow::CControlFlow() throw()
1797 
1798 
1799 
1800 
1801 void CControlFlow::setUp() throw(::std::bad_alloc)
1802 {
1803  // Bouml preserved body begin 00091C02
1804  ::oETCS::DF::CStorage* pPermanentTrue(0);
1805  ::oETCS::DF::CStorage* pPermanentFalse(0);
1806  ::oETCS::DF::CDMISubject* pDMI(0);
1807  ::std::vector< ::oETCS::DF::CFunctionBlock* > State1FunctionBlocks(0);
1808  ::std::vector< ::oETCS::DF::CFunctionBlock* > State2FunctionBlocks(0);
1809  ::std::vector< ::oETCS::DF::CFunctionBlock* > State3FunctionBlocks(0);
1810  ::std::vector< ::oETCS::DF::CFunctionBlock* > DataFlowFunctionBlocks(0);
1811  ::std::vector< ::oETCS::DF::CAbstractFlow* > FlowsState1(0);
1812  ::std::vector< ::oETCS::DF::CAbstractFlow* > FlowsState2(0);
1813  ::std::vector< ::oETCS::DF::CAbstractFlow* > FlowsState3(0);
1814  ::std::vector< ::oETCS::DF::CAbstractFlow* > Flows(0);
1815  ::oETCS::DF::CEVCState* pEVCState1(0);
1816  ::oETCS::DF::CControlFlow* pControlFlow(0);
1820  ::oETCS::DF::CCondition* pFrom1To2(0);
1821  ::oETCS::DF::CCondition* pFrom2To3(0);
1822 
1823 
1824 
1825 
1826  // create EVC state machine object
1827  m_pStateMachine = new ::oETCS::DF::CEVCStateMachine;
1828 
1829 
1830  // create EVC state
1832 
1833 
1834  // create control flow
1836  pControlFlow->m_IsRunning.push_back(new ::oETCS::DF::CFlow< bool >(&m_bBoolInput, m_pStateMachine));
1837  pControlFlow->m_ActiveStateName.push_back(new ::oETCS::DF::CFlow< ::std::string >(&m_StringInput, m_pStateMachine));
1838 
1839 
1840  // create function blocks for data flow
1841  pFrom1To2 = new ::oETCS::DF::CCondition(m_pStateMachine);
1842  pFrom2To3 = new ::oETCS::DF::CCondition(m_pStateMachine);
1843  pPermanentTrue = new ::oETCS::DF::CStorage(m_pStateMachine);
1844  pPermanentTrue->m_BoolValue.push_back(new ::oETCS::DF::CFlow< bool >(&pFrom1To2->m_bGuard, m_pStateMachine));
1845  pPermanentTrue->m_BoolValue.push_back(new ::oETCS::DF::CFlow< bool >(&pFrom2To3->m_bGuard, m_pStateMachine));
1846  pPermanentTrue->m_BoolValue.push_back(new ::oETCS::DF::CFlow< bool >(&pControlFlow->m_bStart, m_pStateMachine));
1847  pPermanentTrue->m_bBoolInput = true;
1848  pPermanentFalse = new ::oETCS::DF::CStorage(m_pStateMachine);
1849  pPermanentFalse->m_BoolValue.push_back(new ::oETCS::DF::CFlow< bool >(&pPermanentTrue->m_bBoolInput, m_pStateMachine));
1850  pPermanentFalse->m_bBoolInput = false;
1851  pControlFlow->m_IsRunning.push_back(new ::oETCS::DF::CFlow< bool >(&pPermanentTrue->m_bBoolInput, m_pStateMachine));
1852 
1853 
1854  // create states
1855  State1FunctionBlocks.push_back(pPermanentTrue);
1856  State1FunctionBlocks.push_back(pFrom1To2);
1857  FlowsState1.push_back(pPermanentTrue->m_BoolValue[0]);
1858  pState1 = new ::oETCS::DF::CControlFlow::CState(pControlFlow, "STATE 1", State1FunctionBlocks, FlowsState1, false, true);
1859  State2FunctionBlocks.push_back(pPermanentTrue);
1860  State2FunctionBlocks.push_back(pFrom2To3);
1861  FlowsState2.push_back(pPermanentTrue->m_BoolValue[1]);
1862  pState2 = new ::oETCS::DF::CControlFlow::CState(pControlFlow, "STATE 2", State2FunctionBlocks, FlowsState2);
1863  State3FunctionBlocks.push_back(pPermanentFalse);
1864  State3FunctionBlocks.push_back(pPermanentTrue);
1865  FlowsState3.push_back(pPermanentFalse->m_BoolValue[0]);
1866  pState3 = new ::oETCS::DF::CControlFlow::CState(pControlFlow, "FINAL STATE", State3FunctionBlocks, FlowsState3, true);
1867 
1868 
1869  // create state transitions
1870  new ::oETCS::DF::CTransition(pEVCState1, pFrom1To2, pState1, pState2, 0);
1871  new ::oETCS::DF::CTransition(pEVCState1, pFrom2To3, pState2, pState3, 0);
1872 
1873 
1874  // create data flow
1875  DataFlowFunctionBlocks.push_back(pPermanentTrue);
1876  DataFlowFunctionBlocks.push_back(pControlFlow);
1877  Flows.push_back(pPermanentTrue->m_BoolValue[2]);
1878  Flows.push_back(pControlFlow->m_ActiveStateName[0]);
1879  new ::oETCS::DF::CEVCStateMachine::CEVCState::CDataFlow(pEVCState1, "IGNORE", DataFlowFunctionBlocks, Flows, pDMI);
1880  // Bouml preserved body end 00091C02
1881 
1882 } // void CControlFlow::setUp() throw(::std::bad_alloc)
1883 
1884 
1885 
1886 
1887 void CControlFlow::tearDown() throw()
1888 {
1889  // Bouml preserved body begin 00091C82
1890  // delete EVC state machine
1891  delete m_pStateMachine;
1892  // Bouml preserved body end 00091C82
1893 
1894 } // void CControlFlow::tearDown() throw()
1895 
1896 
1897 
1898 
1899 void CControlFlow::TestState() throw(::std::exception)
1900 {
1901  // Bouml preserved body begin 00091D02
1902  decltype (m_pStateMachine->GetStates()) States(m_pStateMachine->GetStates());
1903  const ::std::chrono::duration< long long, ::std::micro > SLEEP_TIME(10 * __DATA_FLOW_SAMPLE_TIME__);
1904 
1905 
1906 
1907  // check, number of available states in EVC state machine
1908  CPPUNIT_ASSERT_MESSAGE("no states available in EVC state machine", States.size() > 0);
1909 
1910  // start state machine
1911  m_pStateMachine->Start(States[0], "IGNORE");
1912 
1913  // put thread to sleep to wait for execution of state machine
1914  ::std::this_thread::sleep_for(SLEEP_TIME);
1915 
1916  // check string input for final state name
1917  CPPUNIT_ASSERT_MESSAGE("string input of last state name not correct", m_StringInput() == "FINAL STATE");
1918 
1919  // check boolean input for running control flow
1920  CPPUNIT_ASSERT_MESSAGE("boolean input for running control flow not correct", m_bBoolInput() == false);
1921 
1922  // finally stop state machine
1923  m_pStateMachine->Stop();
1924  // Bouml preserved body end 00091D02
1925 
1926 } // void CControlFlow::TestState() throw(::std::exception)
1927 
1928 
1929 
1930 
1931 void CGOPPRRTransformer::setUp() throw(::std::bad_alloc)
1932 {
1933  // Bouml preserved body begin 00043A82
1934  // create test objects
1935  this->m_pSyntaxLexer = new ::DSM::CGOPPRRTransformer();
1936  this->m_pChecker = new ::GOPPRR::CConstraintChecker;
1937  // Bouml preserved body end 00043A82
1938 
1939 } // void CGOPPRRTransformer::setUp() throw(::std::bad_alloc)
1940 
1941 
1942 
1943 
1945 {
1946  // Bouml preserved body begin 00043B02
1947  // delete test objects
1948  delete this->m_pSyntaxLexer;
1949  delete this->m_pChecker;
1950  // Bouml preserved body end 00043B02
1951 
1952 } // void CGOPPRRTransformer::tearDown() throw()
1953 
1954 
1955 
1956 
1957 void CGOPPRRTransformer::TestCreateSyntax() throw(::std::exception)
1958 {
1959  // Bouml preserved body begin 00043B82
1960  ::GOPPRR::CProject* pProject(0);
1961  ::GOPPRR::CGraph* pRootGraph(0);
1962  ::DSM::CGOPPRRSyntaxTree* pSyntaxTree(0);
1963 
1964 
1965  // execute CreateSyntax() on test object
1966  m_pSyntaxLexer->CreateSyntaxFromFile("openETCS.xml", pRootGraph);
1967 
1968  // get project from lexer
1969  pSyntaxTree = m_pSyntaxLexer->GetGOPRRTree();
1970 
1971  // assert tree pointer
1972  CPPUNIT_ASSERT(pSyntaxTree != 0);
1973 
1974  // get pointer to project from tree
1975  pProject = pSyntaxTree->GetProject();
1976 
1977  // assert project pointer
1978  CPPUNIT_ASSERT_MESSAGE("no project object created", pProject != 0);
1979 
1980  // assert, if a root graph was created
1981  CPPUNIT_ASSERT_MESSAGE("no root graph created", pRootGraph != 0);
1982 
1983  // assert of identity of root graph
1984  CPPUNIT_ASSERT_MESSAGE("root graph not identical", &(pProject->m_GraphSet[ pRootGraph->m_OID ]) == pRootGraph);
1985 
1986  // call generated function from MetaEdit+ to execute all asserts
1987  ::MetaEdit::ExecuteAll(pProject);
1988  // Bouml preserved body end 00043B82
1989 
1990 } // void CGOPPRRTransformer::TestCreateSyntax() throw(::std::exception)
1991 
1992 
1993 
1994 
1995 void CGOPPRRTransformer::TestStaticSemantics() throw(::std::exception)
1996 {
1997  // Bouml preserved body begin 00103002
1998  ::GOPPRR::CProject* pProject(0);
1999  ::GOPPRR::CGraph* pRootGraph(0);
2000  ::DSM::CGOPPRRSyntaxTree* pSyntaxTree(0);
2001 
2002 
2003  // execute CreateSyntax() on test object
2004  m_pSyntaxLexer->CreateSyntaxFromFile("openETCS.xml", pRootGraph);
2005 
2006  // get project from lexer
2007  pSyntaxTree = m_pSyntaxLexer->GetGOPRRTree();
2008 
2009  // assert tree pointer
2010  CPPUNIT_ASSERT(pSyntaxTree != 0);
2011 
2012  // get pointer to project from tree
2013  pProject = pSyntaxTree->GetProject();
2014 
2015  // assert project pointer
2016  CPPUNIT_ASSERT_MESSAGE("no project object created", pProject != 0);
2017 
2018  // assert, if a root graph was created
2019  CPPUNIT_ASSERT_MESSAGE("no root graph created", pRootGraph != 0);
2020 
2021  // implement constraint checking
2022  CPPUNIT_ASSERT_MESSAGE("static semantics violated", m_pChecker->Check(pProject, "", nullptr));
2023  // Bouml preserved body end 00103002
2024 
2025 } // void CGOPPRRTransformer::TestStaticSemantics() throw(::std::exception)
2026 
2027 
2028 
2029 
2030 void CGenerator::setUp() throw(::std::bad_alloc)
2031 {
2032  // Bouml preserved body begin 000E9082
2033  // create test objects
2034  m_pCPPGenerator = new ::oETCS::GEN::CCPPGenerator;
2035  // Bouml preserved body end 000E9082
2036 
2037 } // void CGenerator::setUp() throw(::std::bad_alloc)
2038 
2039 
2040 
2041 
2042 void CGenerator::tearDown() throw()
2043 {
2044  // Bouml preserved body begin 000E9102
2045  // delete test objects
2046  delete this->m_pCPPGenerator;
2047  // Bouml preserved body end 000E9102
2048 
2049 } // void CGenerator::tearDown() throw()
2050 
2051 
2052 
2053 
2054 void CGenerator::TestGenerateCpp() throw(::std::exception)
2055 {
2056  // Bouml preserved body begin 000E9182
2057  ::GOPPRR::CGraph* pRootGraph(nullptr);
2058  ::GOPPRR::CProject* pProject(nullptr);
2059  ::DSM::CGOPPRRTransformer Transformer;
2060  ::DSM::CSyntaxTree* pTree(nullptr);
2061  ::std::stringstream GeneratedCpp;
2062  ::std::regex InstanceRegex;
2063  ::std::smatch Results;
2064  ::std::string Expression;
2065  ::std::string Cpp;
2066  const ::std::regex FB_TYPE_REGEX("(AND)|(OR)|(XOR)|(NOT)|(Sum)|(Subtraction)|(Division)"
2067  "|(Multiplication)|(DoubleEqual)|(IntEqual)|(StringEqual)"
2068  "|(DoubleEqualOrGreater)|(DoubleGreater)|(IntGreater)"
2069  "|(DoubleArrayAccessor)|(VariableStorage)|(Odometer)"
2070  "|(ServiceBrake)|(EmergencyBrake)|(BrakingToTargetSpeed)"
2071  "|(CeelingSpeedControl)|(CommunicationReader)|(CommunicationSender)"
2072  "|(BoolGate)|(DoubleGate)|(StringGate)|(BoolSwitch)|(DoubleSwitch)"
2073  "|(StringSwitch)|(ModeGuard)|(ApplicationLevelType)|(DMIOutput)"
2074  "|(DMIInput)|(EnteredTrigger)|(EmbeddedStateMachine)|(StateGuard)");
2075  const ::std::regex DATAFLOW_TYPE_REGEX("DataFlow");
2076  const ::std::regex EVC_STATE_TYPE_REGEX("Mode");
2077  const ::std::regex VARIABLE_TYPE_REGEX("VariableInstance");
2078  const ::std::regex PACKET_TYPE_REGEX("Packet");
2079  const ::std::regex TELEGRAM_TYPE_REGEX("Telegram");
2080  const ::std::regex BALISEREADER_TYPE_REGEX("BaliseReader");
2081  const ::std::regex BALISESENDER_TYPE_REGEX("BaliseSender");
2082  decltype (pProject->m_ObjectSet.begin()) o;
2083  decltype (pProject->m_RelationshipSet.begin()) r;
2084  bool bFound(false);
2085 
2086 
2087 
2088  // create transformer object
2089 
2090  // generate C++ source from XML
2091  Transformer.CreateSyntaxFromFile("openETCS.xml", pRootGraph);
2092 
2093  // get syntax tree from transformer
2094  pTree = Transformer.GetTree();
2095 
2096  // get project from tree
2097  pProject = static_cast< ::DSM::CGOPPRRSyntaxTree* >(pTree)->GetProject();
2098 
2099  // generate C++ source into string stream
2100  m_pCPPGenerator->Generate(pTree, GeneratedCpp);
2101 
2102  // get string from stringstream
2103  Cpp = GeneratedCpp.str();
2104 
2105 
2106  // process all objects in project
2107  for (o = pProject->m_ObjectSet.begin(); o != pProject->m_ObjectSet.end(); o++)
2108  {
2109  // check type of current object
2110  if (::std::regex_match(o->second.m_Type, FB_TYPE_REGEX))
2111  {
2112  // create regular expression for current FB instance
2113  Expression = ".*\n::oETCS::DF::C.+ +FBO_" + o->second.m_OID + "\\(&EVC\\);.*";
2114 
2115  // create a regular expression type from string expression
2116  InstanceRegex = ::std::regex(Expression);
2117 
2118  // search stream for instance declaration
2119  bFound = ::std::regex_match(Cpp, Results, InstanceRegex);
2120 
2121  // assert existence of current object
2122  CPPUNIT_ASSERT_MESSAGE("function block object declaration not found, OID: " + o->second.m_OID, bFound == true);
2123 
2124  // assert existence of multiple object instances
2125  CPPUNIT_ASSERT_MESSAGE("function block object declaration found multiple times, OID: " + o->second.m_OID, Results.size() == 1);
2126 
2127  } // if (::std::regex_match(o->second.m_Type, FB_TYPE_REGEX))
2128  else if (::std::regex_match(o->second.m_Type, EVC_STATE_TYPE_REGEX))
2129  {
2130  // create regular expression for current mode instance
2131  Expression = ".*\n::oETCS::DF::CEVCState +EVCState_" + o->second.m_OID + "\\(&EVC\\);.*";
2132 
2133  // create a regular expression type from string expression
2134  InstanceRegex = ::std::regex(Expression);
2135 
2136  // search stream for instance declaration
2137  bFound = ::std::regex_match(Cpp, Results, InstanceRegex);
2138 
2139  // assert existence of current object
2140  CPPUNIT_ASSERT_MESSAGE("EVC mode object declaration not found, OID: " + o->second.m_OID, bFound == true);
2141 
2142  // assert existence of multiple object instances
2143  CPPUNIT_ASSERT_MESSAGE("EVC mode object declaration found multiple times, OID: " + o->second.m_OID, Results.size() == 1);
2144 
2145  } // else if (::std::regex_match(o->second.m_Type, EVC_STATE_TYPE_REGEX))
2146  else if (::std::regex_match(o->second.m_Type, VARIABLE_TYPE_REGEX))
2147  {
2148  // create regular expression for current mode instance
2149  Expression = ".*\n::oETCS::DF::CVariable +VAR_" + o->second.m_OID + "\\(&EVC,.+\\);.*";
2150 
2151  // create a regular expression type from string expression
2152  InstanceRegex = ::std::regex(Expression);
2153 
2154  // search stream for instance declaration
2155  bFound = ::std::regex_match(Cpp, Results, InstanceRegex);
2156 
2157  // assert existence of current object
2158  CPPUNIT_ASSERT_MESSAGE("language variable object declaration not found, OID: " + o->second.m_OID, bFound == true);
2159 
2160  // assert existence of multiple object instances
2161  CPPUNIT_ASSERT_MESSAGE("language variable object declaration found multiple times, OID: " + o->second.m_OID, Results.size() == 1);
2162 
2163  } // else if (::std::regex_match(o->second.m_Type, VARIABLE_TYPE_REGEX))
2164  else if (::std::regex_match(o->second.m_Type, PACKET_TYPE_REGEX))
2165  {
2166  // create regular expression for current mode instance
2167  Expression = ".*\n::oETCS::DF::CPacket +PACK_" + o->second.m_OID + "\\(&EVC,.+\\);.*";
2168 
2169  // create a regular expression type from string expression
2170  InstanceRegex = ::std::regex(Expression);
2171 
2172  // search stream for instance declaration
2173  bFound = ::std::regex_match(Cpp, Results, InstanceRegex);
2174 
2175  // assert existence of current object
2176  CPPUNIT_ASSERT_MESSAGE("language packet object declaration not found, OID: " + o->second.m_OID, bFound == true);
2177 
2178  // assert existence of multiple object instances
2179  CPPUNIT_ASSERT_MESSAGE("language packet object declaration found multiple times, OID: " + o->second.m_OID, Results.size() == 1);
2180 
2181  } // else if (::std::regex_match(o->second.m_Type, PACKET_TYPE_REGEX))
2182  else if (::std::regex_match(o->second.m_Type, TELEGRAM_TYPE_REGEX))
2183  {
2184  // create regular expression for current mode instance
2185  Expression = ".*\n::oETCS::DF::CTelegram +TEL_" + o->second.m_OID + "_._.+\\(&EVC,.+\\);.*";
2186 
2187  // create a regular expression type from string expression
2188  InstanceRegex = ::std::regex(Expression);
2189 
2190  // search stream for instance declaration
2191  bFound = ::std::regex_match(Cpp, Results, InstanceRegex);
2192 
2193  // assert existence of current object
2194  CPPUNIT_ASSERT_MESSAGE("language telegram object declaration not found, OID: " + o->second.m_OID, bFound == true);
2195 
2196  // assert existence of multiple object instances
2197  CPPUNIT_ASSERT_MESSAGE("language telegram object declaration found multiple times, OID: " + o->second.m_OID, Results.size() == 1);
2198 
2199  } // else if (::std::regex_match(o->second.m_Type, TELEGRAM_TYPE_REGEX))
2200  else if (::std::regex_match(o->second.m_Type, BALISEREADER_TYPE_REGEX))
2201  {
2202  // create regular expression for current mode instance
2203  Expression = ".*\n::oETCS::DF::CBaliseDeviceIn +BALIN_" + o->second.m_OID + "_._.+\\(.+\\);.*";
2204 
2205  // create a regular expression type from string expression
2206  InstanceRegex = ::std::regex(Expression, ::std::regex_constants::extended);
2207 
2208  // search stream for instance declaration
2209  bFound = ::std::regex_match(Cpp, Results, InstanceRegex);
2210 
2211  // assert existence of current object
2212  CPPUNIT_ASSERT_MESSAGE("balise reader object declaration not found, OID: " + o->second.m_OID, bFound == true);
2213 
2214  } // else if (::std::regex_match(o->second.m_Type, BALISEREADER_TYPE_REGEX))
2215  else if (::std::regex_match(o->second.m_Type, BALISESENDER_TYPE_REGEX))
2216  {
2217  // create regular expression for current mode instance
2218  Expression = ".*\n::oETCS::DF::CBaliseDeviceIn +BALOUT_" + o->second.m_OID + "_._.+\\(.+\\);.*";
2219 
2220  // create a regular expression type from string expression
2221  InstanceRegex = ::std::regex(Expression, ::std::regex_constants::extended);
2222 
2223  // search stream for instance declaration
2224  bFound = ::std::regex_match(Cpp, Results, InstanceRegex);
2225 
2226  // assert existence of current object
2227  CPPUNIT_ASSERT_MESSAGE("balise sender object declaration not found, OID: " + o->second.m_OID, bFound == true);
2228 
2229  } // else if (::std::regex_match(o->second.m_Type, BALISESENDER_TYPE_REGEX))
2230 
2231  } // for (o = pProject->m_ObjectSet.begin(); o != pProject->m_ObjectSet.end(); o++)
2232 
2233 
2234 // WARNING: data flow chekcing currently disabled due to problem with telegram flows in commnunication reader ander sender graphs
2235 // // process all relationships in project
2236 // for (r = pProject->m_RelationshipSet.begin(); r != pProject->m_RelationshipSet.end(); r++)
2237 // {
2238 // // check type of current relationship
2239 // if (::std::regex_match(r->second.m_Type, DATAFLOW_TYPE_REGEX))
2240 // {
2241 // // create regular expression for current mode instance
2242 // Expression = ".*\n::oETCS::DF::(CBitFlow|CFlow< .+ >) +FLOW_" + r->second.m_OID + "\\(.+\\);.*";
2243 //
2244 // // create a regular expression type from string expression
2245 // InstanceRegex = ::std::regex(Expression, ::std::regex_constants::extended);
2246 //
2247 // // search stream for instance declaration
2248 // bFound = ::std::regex_match(Cpp, Results, InstanceRegex);
2249 //
2250 // // assert existence of current object
2251 // CPPUNIT_ASSERT_MESSAGE("flow object (from relationship) declaration not found, OID: " + r->second.m_OID, bFound == true);
2252 //
2253 // } // if (::std::regex_match(r->second.m_Type, DATAFLOW_TYPE_REGEX))
2254 //
2255 // } // for (r = pProject->m_RelationshipSet.begin(); r != pProject->m_RelationshipSet.end(); r++)
2256 
2257  // Bouml preserved body end 000E9182
2258 
2259 } // void CGenerator::TestGenerateCpp() throw(::std::exception)
2260 
2261 
2262 
2263 
2264 
2265 
2266 } // namespace oETCS::UT
2267 
2268 } // namespace oETCS

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/.