@@ -24,6 +24,45 struct Product | |||
|
24 | 24 | ~Product() = default; |
|
25 | 25 | }; |
|
26 | 26 | |
|
27 | template <typename T> | |
|
28 | ScalarTimeSerie* make_scalar(T& t, T& y) | |
|
29 | { | |
|
30 | return new ScalarTimeSerie { std::move(t.data), std::move(y.data) }; | |
|
31 | } | |
|
32 | ||
|
33 | template <typename T> | |
|
34 | VectorTimeSerie* make_vector(T& t, T& y) | |
|
35 | { | |
|
36 | return new VectorTimeSerie { std::move(t.data), y.to_std_vect_vect() }; | |
|
37 | } | |
|
38 | ||
|
39 | template <typename T> | |
|
40 | MultiComponentTimeSerie* make_multi_comp(T& t, T& y) | |
|
41 | { | |
|
42 | auto y_size = y.flat_size(); | |
|
43 | auto t_size = t.flat_size(); | |
|
44 | if (t_size && (y_size % t_size) == 0) | |
|
45 | { | |
|
46 | return new MultiComponentTimeSerie { std::move(t.data), std::move(y.data), | |
|
47 | { t_size, y_size / t_size } }; | |
|
48 | } | |
|
49 | return nullptr; | |
|
50 | } | |
|
51 | ||
|
52 | template <typename T> | |
|
53 | SpectrogramTimeSerie* make_spectro(T& t, T& y) | |
|
54 | { | |
|
55 | auto y_size = y.flat_size(); | |
|
56 | auto t_size = t.flat_size(); | |
|
57 | if (t_size && (y_size % t_size) == 0) | |
|
58 | { | |
|
59 | return new SpectrogramTimeSerie { std::move(t.data), std::move(y.data), | |
|
60 | { t_size, y_size / t_size } }; | |
|
61 | } | |
|
62 | return nullptr; | |
|
63 | } | |
|
64 | ||
|
65 | ||
|
27 | 66 | class PyDataProvider : public IDataProvider |
|
28 | 67 | { |
|
29 | 68 | public: |
@@ -35,7 +74,8 public: | |||
|
35 | 74 | |
|
36 | 75 | virtual ~PyDataProvider() {} |
|
37 | 76 | |
|
38 |
virtual QPair<QPair<NpArray,NpArray>,DataSeriesType> get_data( |
|
|
77 | virtual QPair<QPair<NpArray, NpArray>, DataSeriesType> get_data( | |
|
78 | const QMap<QString, QString>& key, double start_time, double stop_time) | |
|
39 | 79 | { |
|
40 | 80 | (void)key, (void)start_time, (void)stop_time; |
|
41 | 81 | return {}; |
@@ -43,58 +83,36 public: | |||
|
43 | 83 | |
|
44 | 84 | virtual TimeSeries::ITimeSerie* getData(const DataProviderParameters& parameters) override |
|
45 | 85 | { |
|
86 | TimeSeries::ITimeSerie* ts = nullptr; | |
|
46 | 87 | if (parameters.m_Data.contains("name")) |
|
47 | 88 | { |
|
48 | QMap<QString,QString> metadata; | |
|
49 |
std::for_each(parameters.m_Data.constKeyValueBegin(), |
|
|
50 | metadata[item.first] = item.second.toString(); | |
|
51 | }); | |
|
52 |
auto [data, type] |
|
|
53 | parameters.m_Range.m_TStart, parameters.m_Range.m_TEnd); | |
|
54 | // TODO add shape/type switch | |
|
55 | //if (builder) | |
|
56 | { | |
|
57 | auto& [t,y]=data; | |
|
58 | switch (type) | |
|
59 | { | |
|
60 | case DataSeriesType::SCALAR: | |
|
61 | return new ScalarTimeSerie { std::move(t.data), | |
|
62 | std::move(y.data) }; | |
|
63 | break; | |
|
64 | case DataSeriesType::VECTOR: | |
|
65 | return new VectorTimeSerie { std::move(t.data), | |
|
66 | y.to_std_vect_vect() }; | |
|
67 | break; | |
|
68 | case DataSeriesType::MULTICOMPONENT: | |
|
69 | { | |
|
70 | auto y_size = y.flat_size(); | |
|
71 | auto t_size = t.flat_size(); | |
|
89 | QMap<QString, QString> metadata; | |
|
90 | std::for_each(parameters.m_Data.constKeyValueBegin(), | |
|
91 | parameters.m_Data.constKeyValueEnd(), | |
|
92 | [&metadata](const auto& item) { metadata[item.first] = item.second.toString(); }); | |
|
93 | auto [data, type] | |
|
94 | = get_data(metadata, parameters.m_Range.m_TStart, parameters.m_Range.m_TEnd); | |
|
72 | 95 | |
|
73 | if(t_size && (y_size%t_size)==0) | |
|
74 | { | |
|
75 | return new MultiComponentTimeSerie { std::move(t.data), | |
|
76 | std::move(y.data),{t_size, y_size/t_size} }; | |
|
77 |
|
|
|
78 |
|
|
|
79 | } | |
|
80 | case DataSeriesType::SPECTROGRAM: | |
|
81 |
|
|
|
82 | auto y_size = y.flat_size(); | |
|
83 | auto t_size = t.flat_size(); | |
|
84 | ||
|
85 | if(t_size && (y_size%t_size)==0) | |
|
86 |
|
|
|
87 | return new SpectrogramTimeSerie { std::move(t.data), | |
|
88 | std::move(y.data),{t_size, y_size/t_size} }; | |
|
89 |
|
|
|
90 | break; | |
|
91 | } | |
|
92 | default: | |
|
93 | break; | |
|
94 | } | |
|
96 | auto& [t, y] = data; | |
|
97 | switch (type) | |
|
98 | { | |
|
99 | case DataSeriesType::SCALAR: | |
|
100 | ts = make_scalar(t, y); | |
|
101 | break; | |
|
102 | case DataSeriesType::VECTOR: | |
|
103 | ts = make_vector(t, y); | |
|
104 | break; | |
|
105 | case DataSeriesType::MULTICOMPONENT: | |
|
106 | ts = make_multi_comp(t, y); | |
|
107 | break; | |
|
108 | case DataSeriesType::SPECTROGRAM: | |
|
109 | ts = make_spectro(t, y); | |
|
110 | break; | |
|
111 | default: | |
|
112 | break; | |
|
95 | 113 | } |
|
96 | 114 | } |
|
97 |
return |
|
|
115 | return ts; | |
|
98 | 116 | } |
|
99 | 117 | |
|
100 | 118 |
General Comments 0
You need to be logged in to leave comments.
Login now