RecordTools.hpp
1 #pragma once
2 
3 #include <State/Address.hpp>
4 
5 #include <Device/Address/AddressSettings.hpp>
6 #include <Device/Node/DeviceNode.hpp>
7 
8 #include <Process/TimeValue.hpp>
9 
10 #include <Scenario/Commands/Scenario/Displacement/MoveNewEvent.hpp>
11 
12 #include <Recording/Commands/Record.hpp>
13 
14 #include <score/command/Dispatchers/MacroCommandDispatcher.hpp>
15 #include <score/tools/std/HashMap.hpp>
16 
17 #include <chrono>
18 #include <memory>
19 #include <vector>
20 
21 namespace RedoStrategy
22 {
23 struct Quiet;
24 }
25 namespace Explorer
26 {
27 class DeviceExplorerModel;
28 }
29 namespace Scenario
30 {
31 class ProcessModel;
32 class IntervalModel;
33 class EventModel;
34 struct Point;
35 }
36 
37 namespace std
38 {
39 // MOVEME
40 template <>
41 struct hash<Device::FullAddressSettings>
42 {
43  std::size_t operator()(const Device::FullAddressSettings& k) const
44  {
45  return std::hash<State::Address>{}(k.address);
46  }
47 };
48 }
49 
50 namespace Recording
51 {
52 struct RecordContext;
59 using RecordListening = std::vector<std::vector<Device::Node*>>;
60 using RecordCommandDispatcher = GenericMacroCommandDispatcher<
62 
63 struct Box
64 {
65  Scenario::IntervalModel& interval;
66  // In the first slot.
67 
69  Id<Scenario::EventModel> endEvent;
70 };
71 /*
72 // Only the selected addresses
73 RecordListening GetAddressesToRecord(
74  Explorer::DeviceExplorerModel& m_explorer);
75 */
76 // The selected addresses and all their children
77 RecordListening GetAddressesToRecordRecursive(Explorer::DeviceExplorerModel& explorer);
78 
79 Box CreateBox(RecordContext&);
80 
81 inline double GetTimeDifferenceInDouble(std::chrono::steady_clock::time_point start)
82 {
83  using namespace std::chrono;
84  return duration_cast<microseconds>(steady_clock::now() - start).count() / 1000.;
85 }
86 inline TimeVal GetTimeDifference(std::chrono::steady_clock::time_point start)
87 {
88  using namespace std::chrono;
89  return TimeVal::fromMsecs(GetTimeDifferenceInDouble(start));
90 }
91 
97 constexpr int ReasonableUpdateInterval(int numberOfCurves)
98 {
99  return numberOfCurves < 10 ? 8
100  : numberOfCurves < 50 ? 16
101  : numberOfCurves < 100 ? 100
102  : numberOfCurves < 1000 ? 1000
103  : 5000;
104 }
105 }
Definition: DeviceExplorerModel.hpp:67
The MacroCommandDispatcher class.
Definition: MacroCommandDispatcher.hpp:18
Definition: Record.hpp:11
Definition: MoveNewEvent.hpp:34
Definition: IntervalModel.hpp:50
The id_base_t class.
Definition: Identifier.hpp:57
Manipulation of Devices from Qt.
Definition: AddressSettings.cpp:14
Main plug-in of score.
Definition: score-plugin-dataflow/Dataflow/PortItem.hpp:14
Definition: AddressSettings.hpp:62
Definition: RecordTools.hpp:64
Definition: RecordProviderFactory.hpp:39
Definition: SendStrategy.hpp:42
Definition: SendStrategy.hpp:23
Definition: TimeValue.hpp:21
Definition: Address.hpp:187