-
Notifications
You must be signed in to change notification settings - Fork 45
Expand file tree
/
Copy pathITimeSyncService.hpp
More file actions
61 lines (49 loc) · 1.93 KB
/
ITimeSyncService.hpp
File metadata and controls
61 lines (49 loc) · 1.93 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// SPDX-FileCopyrightText: 2022 Vector Informatik GmbH
//
// SPDX-License-Identifier: MIT
#pragma once
#include <functional>
#include "OrchestrationDatatypes.hpp"
namespace SilKit {
namespace Services {
namespace Orchestration {
class ITimeSyncService
{
public:
using SimulationStepHandler = std::function<void(std::chrono::nanoseconds now, std::chrono::nanoseconds duration)>;
public:
virtual ~ITimeSyncService() = default;
public:
/*! \brief Set the task to be executed with each grant / tick
*
* Can be changed at runtime. Execution context depends on the run type.
*
* Throwing an error inside the handler will cause a call to
* ReportError().
*/
virtual void SetSimulationStepHandler(SimulationStepHandler task, std::chrono::nanoseconds initialStepSize) = 0;
/*! \brief Set the task to be executed with each grant / tick
*
* Can be changed at runtime. Execution context depends on the run type.
* Execution will perform one simulation step at a time.
* CompleteSimulationStep is required to signal completion of the simulation step.
*
* Throwing an error inside the handler will cause a call to
* ReportError().
*/
virtual void SetSimulationStepHandlerAsync(SimulationStepHandler task,
std::chrono::nanoseconds initialStepSize) = 0;
/*! \brief Signal that the current simulation task is finished and the next simulation step can be processed.
*
* This method should only be used after calling SetSimulationStepHandlerAsync.
* Otherwise, undefined runtime behavior will result.
*/
virtual void CompleteSimulationStep() = 0;
/*! \brief Get the current simulation time
*/
virtual auto Now() const -> std::chrono::nanoseconds = 0;
virtual void SetStepDuration(std::chrono::nanoseconds stepDuration) = 0;
};
} // namespace Orchestration
} // namespace Services
} // namespace SilKit