Linux GNU 11.4.0 Code Coverage Report


Directory: ./
Coverage: low: ≥ 0% medium: ≥ 75.0% high: ≥ 90.0%
Coverage Exec / Excl / Total
Lines: 65.0% 13 / 0 / 20
Functions: 66.7% 4 / 0 / 6
Branches: 25.0% 1 / 0 / 4

OMCompiler/SimulationRuntime/cpp/Core/Solver/SimulationMonitor.cpp
Line Branch Exec Source
1 /*
2 * This file belongs to the OpenModelica Run-Time System
3 *
4 * Copyright (c) 1998-2026, Open Source Modelica Consortium (OSMC), c/o Linköpings
5 * universitet, Department of Computer and Information Science, SE-58183 Linköping, Sweden. All rights
6 * reserved.
7 *
8 * THIS PROGRAM IS PROVIDED UNDER THE TERMS OF THE BSD NEW LICENSE OR THE
9 * AGPL VERSION 3 LICENSE OR THE OSMC PUBLIC LICENSE (OSMC-PL) VERSION 1.8. ANY
10 * USE, REPRODUCTION OR DISTRIBUTION OF THIS PROGRAM CONSTITUTES RECIPIENT'S
11 * ACCEPTANCE OF THE BSD NEW LICENSE OR THE OSMC PUBLIC LICENSE OR THE AGPL
12 * VERSION 3, ACCORDING TO RECIPIENTS CHOICE.
13 *
14 * The OpenModelica software and the OSMC (Open Source Modelica Consortium) Public License
15 * (OSMC-PL) are obtained from OSMC, either from the above address, from the URLs:
16 * http://www.openmodelica.org or https://github.com/OpenModelica/ or
17 * http://www.ida.liu.se/projects/OpenModelica, and in the OpenModelica distribution. GNU
18 * AGPL version 3 is obtained from: https://www.gnu.org/licenses/licenses.html#GPL. The BSD NEW
19 * License is obtained from: http://www.opensource.org/licenses/BSD-3-Clause.
20 *
21 * This program is distributed WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, EXCEPT AS EXPRESSLY
23 * SET FORTH IN THE BY RECIPIENT SELECTED SUBSIDIARY LICENSE CONDITIONS OF
24 * OSMC-PL.
25 *
26 */
27
28 /** @addtogroup coreSolver
29 *
30 * @{
31 */
32 #include <Core/ModelicaDefine.h>
33 #include <Core/Modelica.h>
34 #include <Core/Solver/FactoryExport.h>
35 #include <Core/Solver/SimulationMonitor.h>
36 /*_time_out(0)
37 ,*/
38 40 SimulationMonitor::SimulationMonitor()
39 :_time_out(0)
40 40 ,_interrupt(false)
41 {
42 40 }
43
44 40 SimulationMonitor::~SimulationMonitor()
45 {
46 40 }
47
48 40 void SimulationMonitor::initialize()
49 {
50 #ifdef USE_CHRONO
51 40 _t_s = high_resolution_clock::now();
52 40 _interrupt = false;
53 #else
54 throw ModelicaSimulationError(SOLVER,"simulation time out is only supported for c++11");
55 #endif
56 40 }
57
58 ✗ void SimulationMonitor::setTimeOut(unsigned int time_out)
59 {
60 #ifdef USE_CHRONO
61 ✗ _time_out = seconds(time_out);
62 #else
63 throw ModelicaSimulationError(SOLVER,"simulation time out is only supported for c++11");
64 #endif
65 ✗ }
66 ✗ void SimulationMonitor::stop()
67 {
68 ✗ _interrupt =true;
69 ✗ }
70 340419 void SimulationMonitor::checkTimeout()
71 {
72 #ifdef USE_CHRONO
73 340419 high_resolution_clock::time_point t1 = high_resolution_clock::now();
74 seconds elapsed = duration_cast<std::chrono::seconds>(t1 - _t_s);
75
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 340419 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
340419 if ((_time_out > seconds(0)) && (elapsed >= _time_out))
76 {
77 ✗ _interrupt =true;
78 }
79 #else
80 throw ModelicaSimulationError(SOLVER,"simulation time out is only supported for c++11");
81 #endif
82
83 340419 }
84 /** @} */ // end of coreSolver
85