##// END OF EJS Templates
Merge pull request 235 from SCIQLOP-Initialisation develop...
leroux -
r632:6ca459f3421e merge
parent child
Show More
@@ -0,0 +1,39
1
2 app_moc_headers = [
3 'include/MainWindow.h'
4 ]
5
6 app_ui_files = [
7 'ui/MainWindow.ui'
8 ]
9
10 app_qresources = ['resources/qlopapp.qrc']
11
12 app_moc_files = qt5.preprocess(moc_headers : app_moc_headers,
13 ui_files : app_ui_files,
14 qresources : app_qresources)
15
16 app_sources = [
17 'src/Main.cpp',
18 'src/MainWindow.cpp'
19 ]
20
21 app_inc = include_directories(['include'])
22
23 if host_machine.system()=='windows' or build_machine.system()=='windows'
24 winmod = import('windows')
25 rc = winmod.compile_resources('resources/qlopapp.rc')
26 else
27 rc = []
28 endif
29
30 sciqlop_app = executable('sciqlop',
31 app_sources,
32 app_moc_files,
33 rc,
34 link_with : [sciqlop_core, sciqlop_gui],
35 include_directories : [gui_inc, core_inc, app_inc],
36 dependencies : [qt5core, qt5printsupport, qt5gui, qt5widgets, qt5network],
37 install : true
38 )
39
@@ -0,0 +1,1
1 IDI_ICON1 ICON DISCARDABLE "sciqlop.ico"
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -0,0 +1,22
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3 <plist version="1.0">
4 <dict>
5 <key>NSPrincipalClass</key>
6 <string>NSApplication</string>
7 <key>CFBundleIconFile</key>
8 <string>sciqlopLOGO.icns</string>
9 <key>CFBundlePackageType</key>
10 <string>APPL</string>
11 <key>CFBundleGetInfoString</key>
12 <string>Created by Qt/QMake</string>
13 <key>CFBundleSignature</key>
14 <string>????</string>
15 <key>CFBundleExecutable</key>
16 <string>SciQLOP</string>
17 <key>CFBundleIdentifier</key>
18 <string>com.lpp.SciQLOP</string>
19 <key>NOTE</key>
20 <string>This file was generated by Qt/QMake.</string>
21 </dict>
22 </plist>
@@ -0,0 +1,8
1 #!/bin/bash
2
3 mkdir build
4 meson --prefix=/tmp/SciQLOP.app --bindir=Contents/MacOS build
5 cd build
6 ninja
7 ninja install
8
@@ -0,0 +1,11
1 #!/bin/bash
2
3 mkdir -p ${MESON_INSTALL_PREFIX}/Contents/Frameworks
4 mv ${MESON_INSTALL_PREFIX}/lib/*plugin* ${MESON_INSTALL_PREFIX}/Contents/MacOS
5 macdeployqt ${MESON_INSTALL_PREFIX} -verbose=3
6 install_name_tool -change @rpath/QtCore.framework/Versions/5/QtCore @executable_path/../Frameworks/QtCore.framework/Versions/5/QtCore /tmp/SciQLOP.app/Contents/MacOS/sciqlop
7 install_name_tool -change @rpath/QtPrintSupport.framework/Versions/5/QtPrintSupport @executable_path/../Frameworks/QtPrintSupport.framework/Versions/5/QtPrintSupport /tmp/SciQLOP.app/Contents/MacOS/sciqlop
8 install_name_tool -change @rpath/QtGui.framework/Versions/5/QtGui @executable_path/../Frameworks/QtGui.framework/Versions/5/QtGui /tmp/SciQLOP.app/Contents/MacOS/sciqlop
9 install_name_tool -change @rpath/QtWidgets.framework/Versions/5/QtWidgets @executable_path/../Frameworks/QtWidgets.framework/Versions/5/QtWidgets /tmp/SciQLOP.app/Contents/MacOS/sciqlop
10 install_name_tool -change @rpath/QtNetwork.framework/Versions/5/QtNetwork @executable_path/../Frameworks/QtNetwork.framework/Versions/5/QtNetwork /tmp/SciQLOP.app/Contents/MacOS/sciqlop
11
1 NO CONTENT: new file 100644, binary diff hidden
NO CONTENT: new file 100644, binary diff hidden
@@ -0,0 +1,8
1 #!/bin/bash
2
3 mkdir build
4 meson --prefix=/tmp/SciQLOP --cross-file build_cfg/windows/cross_fedora_win64.txt build
5 cd build
6 ninja
7 ninja install
8
@@ -0,0 +1,18
1 [binaries]
2 c = 'x86_64-w64-mingw32-gcc'
3 cpp = 'x86_64-w64-mingw32-g++'
4 ar = 'x86_64-w64-mingw32-ar'
5 strip = 'x86_64-w64-mingw32-strip'
6 qmake = 'mingw64-qmake-qt5'
7 qmake-qt5 = 'mingw64-qmake-qt5'
8 moc-qt5 = '/usr/x86_64-w64-mingw32/bin/qt5/moc'
9 windres = 'x86_64-w64-mingw32-windres'
10 pkgconfig = 'mingw64-pkg-config'
11 exe_wrapper = 'wine' # A command used to run generated executables.
12
13 [host_machine]
14 system = 'windows'
15 cpu_family = 'x86'
16 cpu = 'x86_64'
17 endian = 'little'
18
@@ -0,0 +1,26
1 #!/bin/bash
2
3 mkdir -p ${MESON_INSTALL_PREFIX}/plugins
4 mv ${MESON_INSTALL_PREFIX}/bin/*plugin*.dll ${MESON_INSTALL_PREFIX}/plugins/
5 mv ${MESON_INSTALL_PREFIX}/lib64/*.dll ${MESON_INSTALL_PREFIX}/
6 mv ${MESON_INSTALL_PREFIX}/bin/* ${MESON_INSTALL_PREFIX}/
7
8 cp /usr/x86_64-w64-mingw32/sys-root/mingw/lib/qt5/plugins/platforms/qwindows.dll ${MESON_INSTALL_PREFIX}/
9 cp /usr/x86_64-w64-mingw32/sys-root/mingw/lib/qt5/plugins/imageformats/*.dll ${MESON_INSTALL_PREFIX}/
10
11 peldd ${MESON_INSTALL_PREFIX}/sciqlop.exe -a -w libsciqlopcore.dll -w libsciqlopgui.dll -w dwmapi.dll -w UxTheme.dll -w CRYPT32.dll -w DNSAPI.dll -w IPHLPAPI.DLL -w comdlg32.dll -w WINSPOOL.DRV -w IMM32.dll | xargs cp -t ${MESON_INSTALL_PREFIX}/ || true
12 peldd ${MESON_INSTALL_PREFIX}/libsciqlopcore.dll -a -w libsciqlopgui.dll -w dwmapi.dll -w UxTheme.dll -w CRYPT32.dll -w DNSAPI.dll -w IPHLPAPI.DLL -w comdlg32.dll -w WINSPOOL.DRV -w IMM32.dll | xargs cp -t ${MESON_INSTALL_PREFIX}/ || true
13 peldd ${MESON_INSTALL_PREFIX}/libsciqlopgui.dll -a -w libsciqlopcore.dll -w dwmapi.dll -w UxTheme.dll -w CRYPT32.dll -w DNSAPI.dll -w IPHLPAPI.DLL -w comdlg32.dll -w WINSPOOL.DRV -w IMM32.dll | xargs cp -t ${MESON_INSTALL_PREFIX}/ || true
14 peldd ${MESON_INSTALL_PREFIX}/qwindows.dll -a -w libsciqlopcore.dll -w dwmapi.dll -w UxTheme.dll -w CRYPT32.dll -w DNSAPI.dll -w IPHLPAPI.DLL -w comdlg32.dll -w WINSPOOL.DRV -w IMM32.dll | xargs cp -t ${MESON_INSTALL_PREFIX}/ || true
15
16 peldd ${MESON_INSTALL_PREFIX}/qjp2.dll -a -w libsciqlopcore.dll -w dwmapi.dll -w UxTheme.dll -w CRYPT32.dll -w DNSAPI.dll -w IPHLPAPI.DLL -w comdlg32.dll -w WINSPOOL.DRV -w IMM32.dll | xargs cp -t ${MESON_INSTALL_PREFIX}/ || true
17 peldd ${MESON_INSTALL_PREFIX}/qjpeg.dll -a -w libsciqlopcore.dll -w dwmapi.dll -w UxTheme.dll -w CRYPT32.dll -w DNSAPI.dll -w IPHLPAPI.DLL -w comdlg32.dll -w WINSPOOL.DRV -w IMM32.dll | xargs cp -t ${MESON_INSTALL_PREFIX}/ || true
18 peldd ${MESON_INSTALL_PREFIX}/qsvg.dll -a -w libsciqlopcore.dll -w dwmapi.dll -w UxTheme.dll -w CRYPT32.dll -w DNSAPI.dll -w IPHLPAPI.DLL -w comdlg32.dll -w WINSPOOL.DRV -w IMM32.dll | xargs cp -t ${MESON_INSTALL_PREFIX}/ || true
19 peldd ${MESON_INSTALL_PREFIX}/qtiff.dll -a -w libsciqlopcore.dll -w dwmapi.dll -w UxTheme.dll -w CRYPT32.dll -w DNSAPI.dll -w IPHLPAPI.DLL -w comdlg32.dll -w WINSPOOL.DRV -w IMM32.dll | xargs cp -t ${MESON_INSTALL_PREFIX}/ || true
20 peldd ${MESON_INSTALL_PREFIX}/qwebp.dll -a -w libsciqlopcore.dll -w dwmapi.dll -w UxTheme.dll -w CRYPT32.dll -w DNSAPI.dll -w IPHLPAPI.DLL -w comdlg32.dll -w WINSPOOL.DRV -w IMM32.dll | xargs cp -t ${MESON_INSTALL_PREFIX}/ || true
21 peldd ${MESON_INSTALL_PREFIX}/plugins/libamdaplugin.dll -a -w libsciqlopgui.dll -w libsciqlopcore.dll -w dwmapi.dll -w UxTheme.dll -w CRYPT32.dll -w DNSAPI.dll -w IPHLPAPI.DLL -w comdlg32.dll -w WINSPOOL.DRV -w IMM32.dll | xargs cp -t ${MESON_INSTALL_PREFIX}/ || true
22 peldd ${MESON_INSTALL_PREFIX}/plugins/libmockplugin.dll -a -w libsciqlopgui.dll -w libsciqlopcore.dll -w dwmapi.dll -w UxTheme.dll -w CRYPT32.dll -w DNSAPI.dll -w IPHLPAPI.DLL -w comdlg32.dll -w WINSPOOL.DRV -w IMM32.dll | xargs cp -t ${MESON_INSTALL_PREFIX}/ || true
23
24 rm ${MESON_INSTALL_PREFIX}/bin/*plugin*.dll
25
26 rm -r ${MESON_INSTALL_PREFIX}/bin ${MESON_INSTALL_PREFIX}/lib64
@@ -0,0 +1,28
1 #ifndef SCIQLOP_VARIABLEREQUEST_H
2 #define SCIQLOP_VARIABLEREQUEST_H
3
4 #include <QObject>
5
6 #include <QUuid>
7
8 #include <Common/MetaTypes.h>
9 #include <Data/IDataSeries.h>
10 #include <Data/SqpRange.h>
11
12 #include <memory>
13
14 /**
15 * @brief The VariableRequest struct holds the information of an acquisition request
16 */
17 struct VariableRequest {
18 VariableRequest() { m_CanUpdate = false; }
19
20 SqpRange m_RangeRequested;
21 SqpRange m_CacheRangeRequested;
22 std::shared_ptr<IDataSeries> m_DataSeries;
23 bool m_CanUpdate;
24 };
25
26 SCIQLOP_REGISTER_META_TYPE(VARIABLEREQUEST_REGISTRY, VariableRequest)
27
28 #endif // SCIQLOP_VARIABLEREQUEST_H
@@ -0,0 +1,55
1
2 core_moc_headers = [
3 'include/Data/IDataProvider.h',
4 'include/DataSource/DataSourceController.h',
5 'include/DataSource/DataSourceItemAction.h',
6 'include/Network/NetworkController.h',
7 'include/Time/TimeController.h',
8 'include/Variable/Variable.h',
9 'include/Variable/VariableCacheController.h',
10 'include/Variable/VariableController.h',
11 'include/Variable/VariableAcquisitionWorker.h',
12 'include/Variable/VariableCacheStrategy.h',
13 'include/Variable/VariableSynchronizationGroup.h',
14 'include/Variable/VariableModel.h',
15 'include/Visualization/VisualizationController.h'
16 ]
17
18
19 core_moc_files = qt5.preprocess(moc_headers : core_moc_headers)
20
21 core_sources = [
22 'src/Common/DateUtils.cpp',
23 'src/Data/ScalarSeries.cpp',
24 'src/Data/DataSeriesIterator.cpp',
25 'src/Data/VectorSeries.cpp',
26 'src/DataSource/DataSourceController.cpp',
27 'src/DataSource/DataSourceItem.cpp',
28 'src/DataSource/DataSourceItemAction.cpp',
29 'src/Network/NetworkController.cpp',
30 'src/Plugin/PluginManager.cpp',
31 'src/Settings/SqpSettingsDefs.cpp',
32 'src/Time/TimeController.cpp',
33 'src/Variable/Variable.cpp',
34 'src/Variable/VariableCacheController.cpp',
35 'src/Variable/VariableController.cpp',
36 'src/Variable/VariableAcquisitionWorker.cpp',
37 'src/Variable/VariableCacheStrategy.cpp',
38 'src/Variable/VariableSynchronizationGroup.cpp',
39 'src/Variable/VariableModel.cpp',
40 'src/Visualization/VisualizationController.cpp'
41 ]
42
43 core_inc = include_directories(['include', '../plugin/include'])
44
45 sciqlop_core = library('sciqlopcore',
46 core_sources,
47 core_moc_files,
48 cpp_args : '-DCORE_LIB',
49 include_directories : core_inc,
50 dependencies : [qt5core, qt5widgets, qt5network],
51 install : true
52 )
53
54 subdir('tests')
55
@@ -0,0 +1,20
1
2
3 tests = [
4 [['Data/TestDataSeries.cpp'],['test_data'],['DataSeries test']],
5 [['Data/TestOneDimArrayData.cpp'],['test_1d'],['One Dim Array test']],
6 [['Data/TestTwoDimArrayData.cpp'],['test_2d'],['Two Dim Array test']],
7 [['DataSource/TestDataSourceController.cpp'],['test_data_source'],['DataSourceController test']],
8 [['Variable/TestVariableCacheController.cpp'],['test_variable_cache'],['VariableCacheController test']],
9 [['Variable/TestVariable.cpp'],['test_variable'],['Variable test']]
10 ]
11
12 foreach unit_test : tests
13 test_moc_files = qt5.preprocess(moc_sources : unit_test[0])
14 test_exe = executable(unit_test[1],unit_test[0] , test_moc_files,
15 link_with : sciqlop_core,
16 include_directories : core_inc,
17 dependencies : [qt5core, qt5widgets, qt5network,qt5test])
18 test(unit_test[2], test_exe)
19 endforeach
20
@@ -0,0 +1,72
1
2 gui_moc_headers = [
3 'include/DataSource/DataSourceWidget.h',
4 'include/Settings/SqpSettingsDialog.h',
5 'include/Settings/SqpSettingsGeneralWidget.h',
6 'include/SidePane/SqpSidePane.h',
7 'include/SqpApplication.h',
8 'include/TimeWidget/TimeWidget.h',
9 'include/Variable/VariableInspectorWidget.h',
10 'include/Visualization/qcustomplot.h',
11 'include/Visualization/VisualizationGraphWidget.h',
12 'include/Visualization/VisualizationTabWidget.h',
13 'include/Visualization/VisualizationWidget.h',
14 'include/Visualization/VisualizationZoneWidget.h'
15 ]
16
17 gui_ui_files = [
18 'ui/DataSource/DataSourceWidget.ui',
19 'ui/Settings/SqpSettingsDialog.ui',
20 'ui/Settings/SqpSettingsGeneralWidget.ui',
21 'ui/SidePane/SqpSidePane.ui',
22 'ui/TimeWidget/TimeWidget.ui',
23 'ui/Variable/VariableInspectorWidget.ui',
24 'ui/Variable/VariableMenuHeaderWidget.ui',
25 'ui/Visualization/VisualizationGraphWidget.ui',
26 'ui/Visualization/VisualizationTabWidget.ui',
27 'ui/Visualization/VisualizationWidget.ui',
28 'ui/Visualization/VisualizationZoneWidget.ui'
29 ]
30
31 gui_qresources = ['resources/sqpguiresources.qrc']
32
33 gui_moc_files = qt5.preprocess(moc_headers : gui_moc_headers,
34 ui_files : gui_ui_files,
35 qresources : gui_qresources)
36
37 gui_sources = [
38 'src/SqpApplication.cpp',
39 'src/Common/ColorUtils.cpp',
40 'src/DataSource/DataSourceTreeWidgetItem.cpp',
41 'src/DataSource/DataSourceTreeWidgetHelper.cpp',
42 'src/DataSource/DataSourceWidget.cpp',
43 'src/Settings/SqpSettingsDialog.cpp',
44 'src/Settings/SqpSettingsGeneralWidget.cpp',
45 'src/SidePane/SqpSidePane.cpp',
46 'src/TimeWidget/TimeWidget.cpp',
47 'src/Variable/VariableInspectorWidget.cpp',
48 'src/Variable/VariableMenuHeaderWidget.cpp',
49 'src/Visualization/VisualizationGraphHelper.cpp',
50 'src/Visualization/VisualizationGraphRenderingDelegate.cpp',
51 'src/Visualization/VisualizationGraphWidget.cpp',
52 'src/Visualization/VisualizationTabWidget.cpp',
53 'src/Visualization/VisualizationWidget.cpp',
54 'src/Visualization/VisualizationZoneWidget.cpp',
55 'src/Visualization/qcustomplot.cpp',
56 'src/Visualization/operations/GenerateVariableMenuOperation.cpp',
57 'src/Visualization/operations/MenuBuilder.cpp',
58 'src/Visualization/operations/RemoveVariableOperation.cpp',
59 'src/Visualization/operations/RescaleAxeOperation.cpp'
60 ]
61
62 gui_inc = include_directories(['include'])
63
64 sciqlop_gui = library('sciqlopgui',
65 gui_sources,
66 gui_moc_files,
67 link_with : sciqlop_core,
68 include_directories : [gui_inc, core_inc],
69 dependencies : [qt5core, qt5printsupport, qt5gui, qt5widgets, qt5network],
70 install : true
71 )
72
@@ -0,0 +1,36
1 project('SciQLOP', 'cpp',default_options : ['cpp_std=c++14'])
2
3 qt5 = import('qt5')
4 qt5core = dependency('qt5', modules : 'Core')
5 qt5widgets = dependency('qt5', modules : 'Widgets')
6 qt5gui = dependency('qt5', modules : 'Gui')
7 qt5svg = dependency('qt5', modules : 'Svg')
8 qt5xml = dependency('qt5', modules : 'Xml')
9 qt5network = dependency('qt5', modules : 'Network')
10 qt5printsupport = dependency('qt5', modules : 'PrintSupport')
11 qt5test = dependency('qt5', modules : 'Test')
12
13 moc = find_program('moc','moc-qt5')
14
15 subdir('core')
16 subdir('gui')
17 subdir('app')
18 subdir('plugins')
19
20 if build_machine.system()=='darwin'
21 install_data('build_cfg/mac/sciqlopLOGO.icns', install_dir : 'Contents/Resources')
22 install_data('build_cfg/mac/Info.plist', install_dir : 'Contents')
23 meson.add_install_script('build_cfg/mac/install_script.sh')
24 elif host_machine.system()=='windows'
25 meson.add_install_script('build_cfg/windows/install_script.sh')
26 endif
27
28 cppcheck = find_program('cppcheck', required : false)
29
30 if cppcheck.found()
31 run_target('cppcheck',
32 command : [cppcheck, '--enable=all',
33 '--project=' + join_paths(meson.build_root(), 'compile_commands.json')],
34 build_by_default : true
35 )
36 endif
@@ -0,0 +1,61
1
2 amdaplugin_moc_headers = [
3 'include/AmdaPlugin.h'
4 ]
5
6 amdaplugin_sources = [
7 'src/AmdaDefs.cpp',
8 'src/AmdaParser.cpp',
9 'src/AmdaPlugin.cpp',
10 'src/AmdaProvider.cpp',
11 'src/AmdaResultParser.cpp'
12 ]
13
14 amdaplugin_ui_files = []
15 amdaplugin_resources_files = [
16 'resources/amdaresources.qrc'
17 ]
18
19 amdaplugin_inc = include_directories(['include', '../../plugin/include'])
20
21 gen = generator(moc,
22 output : 'moc_@BASENAME@.cpp',
23 arguments : ['@INPUT@',
24 '-DPLUGIN_JSON_FILE_PATH="'+meson.source_root()+'/plugins/amda/resources/amda.json"',
25 '-I', meson.current_source_dir()+'/include',
26 '-I', meson.current_source_dir()+'/../../plugin/include',
27 '-o', '@OUTPUT@'])
28
29 amdaplugin_moc_plugin_files = gen.process(amdaplugin_moc_headers)
30
31 amdaplugin_moc_files = qt5.preprocess(
32 ui_files : amdaplugin_ui_files,
33 qresources : amdaplugin_resources_files)
34
35 sciqlop_amdaplugin = library('amdaplugin',
36 amdaplugin_sources,
37 amdaplugin_moc_files,
38 amdaplugin_moc_plugin_files,
39 cpp_args : '-DAMDA_LIB',
40 link_with : [sciqlop_core, sciqlop_gui],
41 include_directories : [amdaplugin_inc, core_inc, gui_inc],
42 dependencies : [qt5core, qt5gui, qt5widgets, qt5network],
43 install : true
44 )
45
46
47 tests = [
48 [['tests/TestAmdaParser.cpp'],['test_amda_parser'],['AMDA parser test']],
49 [['tests/TestAmdaResultParser.cpp'],['test_amda_result_parser'],['AMDA result parser test']],
50 [['tests/TestAmdaAcquisition.cpp'],['test_amda_acquisition'],['AMDA Acquisition test']]
51 ]
52
53 foreach unit_test : tests
54 test_moc_files = qt5.preprocess(moc_sources : unit_test[0])
55 test_exe = executable(unit_test[1],unit_test[0] , test_moc_files,
56 link_with : [sciqlop_core, sciqlop_amdaplugin, sciqlop_gui],
57 include_directories : [core_inc, amdaplugin_inc, gui_inc],
58 cpp_args : ['-DAMDA_TESTS_RESOURCES_DIR="'+meson.current_source_dir()+'/tests-resources"'],
59 dependencies : [qt5core, qt5widgets, qt5network,qt5test])
60 test(unit_test[2], test_exe,timeout: 3 * 60)
61 endforeach
@@ -0,0 +1,2
1 subdir('mockplugin')
2 subdir('amda')
@@ -0,0 +1,33
1
2 mockplugin_moc_headers = [
3 'include/MockPlugin.h'
4 ]
5
6 mockplugin_sources = [
7 'src/CosinusProvider.cpp',
8 'src/MockPlugin.cpp'
9 ]
10
11 mockplugin_inc = include_directories(['include', '../../plugin/include'])
12
13
14 gen = generator(moc,
15 output : 'moc_@BASENAME@.cpp',
16 arguments : ['@INPUT@',
17 '-DPLUGIN_JSON_FILE_PATH="'+meson.source_root()+'/plugins/mockplugin/resources/mockplugin.json"',
18 '-I', meson.current_source_dir()+'/include',
19 '-I', meson.current_source_dir()+'/../../plugin/include',
20 '-o', '@OUTPUT@'])
21
22 mockplugin_moc_files = gen.process(mockplugin_moc_headers)
23
24 sciqlop_mockplugin = library('mockplugin',
25 mockplugin_sources,
26 mockplugin_moc_files,
27 cpp_args : '-DMOCKPLUGIN_LIB',
28 link_with : [sciqlop_core, sciqlop_gui],
29 include_directories : [mockplugin_inc, core_inc, gui_inc],
30 dependencies : [qt5core, qt5gui, qt5widgets, qt5network],
31 install : true
32 )
33
@@ -14,16 +14,16
14 #include <memory>
14 #include <memory>
15
15
16 /**
16 /**
17 * @brief The AcquisitionRequest struct holds the information of an acquisition request
17 * @brief The AcquisitionRequest struct holds the information of an variable request
18 */
18 */
19 struct AcquisitionRequest {
19 struct AcquisitionRequest {
20 AcquisitionRequest()
20 AcquisitionRequest()
21 {
21 {
22
23 m_AcqIdentifier = QUuid::createUuid();
22 m_AcqIdentifier = QUuid::createUuid();
24 m_Size = 0;
23 m_Size = 0;
25 }
24 }
26
25
26 QUuid m_VarRequestId;
27 QUuid m_AcqIdentifier;
27 QUuid m_AcqIdentifier;
28 QUuid m_vIdentifier;
28 QUuid m_vIdentifier;
29 DataProviderParameters m_DataProviderParameters;
29 DataProviderParameters m_DataProviderParameters;
@@ -28,9 +28,9 public:
28 explicit VariableAcquisitionWorker(QObject *parent = 0);
28 explicit VariableAcquisitionWorker(QObject *parent = 0);
29 virtual ~VariableAcquisitionWorker();
29 virtual ~VariableAcquisitionWorker();
30
30
31 void pushVariableRequest(QUuid vIdentifier, SqpRange rangeRequested,
31 QUuid pushVariableRequest(QUuid varRequestId, QUuid vIdentifier, SqpRange rangeRequested,
32 SqpRange cacheRangeRequested, DataProviderParameters parameters,
32 SqpRange cacheRangeRequested, DataProviderParameters parameters,
33 std::shared_ptr<IDataProvider> provider);
33 std::shared_ptr<IDataProvider> provider);
34
34
35 void abortProgressRequested(QUuid vIdentifier);
35 void abortProgressRequested(QUuid vIdentifier);
36
36
@@ -29,8 +29,8 class SCIQLOP_CORE_EXPORT VariableCacheStrategy : public QObject {
29 public:
29 public:
30 explicit VariableCacheStrategy(QObject *parent = 0);
30 explicit VariableCacheStrategy(QObject *parent = 0);
31
31
32 std::pair<SqpRange, SqpRange> computeCacheRange(const SqpRange &vRange,
32 std::pair<SqpRange, SqpRange> computeStrategyRanges(const SqpRange &vRange,
33 const SqpRange &rangeRequested);
33 const SqpRange &rangeRequested);
34
34
35 private:
35 private:
36 class VariableCacheStrategyPrivate;
36 class VariableCacheStrategyPrivate;
@@ -8,6 +8,7
8
8
9 #include <QLoggingCategory>
9 #include <QLoggingCategory>
10 #include <QObject>
10 #include <QObject>
11 #include <QUuid>
11
12
12 #include <Common/spimpl.h>
13 #include <Common/spimpl.h>
13
14
@@ -46,16 +46,19 VariableAcquisitionWorker::~VariableAcquisitionWorker()
46 }
46 }
47
47
48
48
49 void VariableAcquisitionWorker::pushVariableRequest(QUuid vIdentifier, SqpRange rangeRequested,
49 QUuid VariableAcquisitionWorker::pushVariableRequest(QUuid varRequestId, QUuid vIdentifier,
50 SqpRange cacheRangeRequested,
50 SqpRange rangeRequested,
51 DataProviderParameters parameters,
51 SqpRange cacheRangeRequested,
52 std::shared_ptr<IDataProvider> provider)
52 DataProviderParameters parameters,
53 std::shared_ptr<IDataProvider> provider)
53 {
54 {
54 qCInfo(LOG_VariableAcquisitionWorker())
55 qCDebug(LOG_VariableAcquisitionWorker())
55 << tr("TORM VariableAcquisitionWorker::pushVariableRequest ") << cacheRangeRequested;
56 << tr("TORM VariableAcquisitionWorker::pushVariableRequest ") << cacheRangeRequested;
57 auto varRequestIdCanceled = QUuid();
56
58
57 // Request creation
59 // Request creation
58 auto acqRequest = AcquisitionRequest{};
60 auto acqRequest = AcquisitionRequest{};
61 acqRequest.m_VarRequestId = varRequestId;
59 acqRequest.m_vIdentifier = vIdentifier;
62 acqRequest.m_vIdentifier = vIdentifier;
60 acqRequest.m_DataProviderParameters = parameters;
63 acqRequest.m_DataProviderParameters = parameters;
61 acqRequest.m_RangeRequested = rangeRequested;
64 acqRequest.m_RangeRequested = rangeRequested;
@@ -63,6 +66,7 void VariableAcquisitionWorker::pushVariableRequest(QUuid vIdentifier, SqpRange
63 acqRequest.m_Size = parameters.m_Times.size();
66 acqRequest.m_Size = parameters.m_Times.size();
64 acqRequest.m_Provider = provider;
67 acqRequest.m_Provider = provider;
65
68
69
66 // Register request
70 // Register request
67 impl->lockWrite();
71 impl->lockWrite();
68 impl->m_AcqIdentifierToAcqRequestMap.insert(
72 impl->m_AcqIdentifierToAcqRequestMap.insert(
@@ -71,6 +75,13 void VariableAcquisitionWorker::pushVariableRequest(QUuid vIdentifier, SqpRange
71 auto it = impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.find(vIdentifier);
75 auto it = impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.find(vIdentifier);
72 if (it != impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.cend()) {
76 if (it != impl->m_VIdentifierToCurrrentAcqIdNextIdPairMap.cend()) {
73 // A current request already exists, we can replace the next one
77 // A current request already exists, we can replace the next one
78 auto nextAcqId = it->second.second;
79 auto acqIdentifierToAcqRequestMapIt = impl->m_AcqIdentifierToAcqRequestMap.find(nextAcqId);
80 if (acqIdentifierToAcqRequestMapIt != impl->m_AcqIdentifierToAcqRequestMap.cend()) {
81 auto request = acqIdentifierToAcqRequestMapIt->second;
82 varRequestIdCanceled = request.m_VarRequestId;
83 }
84
74 it->second.second = acqRequest.m_AcqIdentifier;
85 it->second.second = acqRequest.m_AcqIdentifier;
75 impl->unlock();
86 impl->unlock();
76 }
87 }
@@ -83,6 +94,8 void VariableAcquisitionWorker::pushVariableRequest(QUuid vIdentifier, SqpRange
83 QMetaObject::invokeMethod(this, "onExecuteRequest", Qt::QueuedConnection,
94 QMetaObject::invokeMethod(this, "onExecuteRequest", Qt::QueuedConnection,
84 Q_ARG(QUuid, acqRequest.m_AcqIdentifier));
95 Q_ARG(QUuid, acqRequest.m_AcqIdentifier));
85 }
96 }
97
98 return varRequestIdCanceled;
86 }
99 }
87
100
88 void VariableAcquisitionWorker::abortProgressRequested(QUuid vIdentifier)
101 void VariableAcquisitionWorker::abortProgressRequested(QUuid vIdentifier)
@@ -173,7 +186,7 void VariableAcquisitionWorker::onVariableDataAcquired(QUuid acqIdentifier,
173
186
174 void VariableAcquisitionWorker::onExecuteRequest(QUuid acqIdentifier)
187 void VariableAcquisitionWorker::onExecuteRequest(QUuid acqIdentifier)
175 {
188 {
176 qCInfo(LOG_VariableAcquisitionWorker()) << tr("onExecuteRequest") << QThread::currentThread();
189 qCDebug(LOG_VariableAcquisitionWorker()) << tr("onExecuteRequest") << QThread::currentThread();
177 impl->lockRead();
190 impl->lockRead();
178 auto it = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier);
191 auto it = impl->m_AcqIdentifierToAcqRequestMap.find(acqIdentifier);
179 if (it != impl->m_AcqIdentifierToAcqRequestMap.cend()) {
192 if (it != impl->m_AcqIdentifierToAcqRequestMap.cend()) {
@@ -20,7 +20,7 VariableCacheStrategy::VariableCacheStrategy(QObject *parent)
20 }
20 }
21
21
22 std::pair<SqpRange, SqpRange>
22 std::pair<SqpRange, SqpRange>
23 VariableCacheStrategy::computeCacheRange(const SqpRange &vRange, const SqpRange &rangeRequested)
23 VariableCacheStrategy::computeStrategyRanges(const SqpRange &vRange, const SqpRange &rangeRequested)
24 {
24 {
25
25
26 auto varRanges = std::pair<SqpRange, SqpRange>{};
26 auto varRanges = std::pair<SqpRange, SqpRange>{};
@@ -1,6 +1,5
1 #include <Variable/Variable.h>
1 #include <Variable/Variable.h>
2 #include <Variable/VariableAcquisitionWorker.h>
2 #include <Variable/VariableAcquisitionWorker.h>
3 #include <Variable/VariableCacheController.h>
4 #include <Variable/VariableCacheStrategy.h>
3 #include <Variable/VariableCacheStrategy.h>
5 #include <Variable/VariableController.h>
4 #include <Variable/VariableController.h>
6 #include <Variable/VariableModel.h>
5 #include <Variable/VariableModel.h>
@@ -9,6 +8,7
9 #include <Data/DataProviderParameters.h>
8 #include <Data/DataProviderParameters.h>
10 #include <Data/IDataProvider.h>
9 #include <Data/IDataProvider.h>
11 #include <Data/IDataSeries.h>
10 #include <Data/IDataSeries.h>
11 #include <Data/VariableRequest.h>
12 #include <Time/TimeController.h>
12 #include <Time/TimeController.h>
13
13
14 #include <QMutex>
14 #include <QMutex>
@@ -16,6 +16,7
16 #include <QUuid>
16 #include <QUuid>
17 #include <QtCore/QItemSelectionModel>
17 #include <QtCore/QItemSelectionModel>
18
18
19 #include <deque>
19 #include <set>
20 #include <set>
20 #include <unordered_map>
21 #include <unordered_map>
21
22
@@ -78,7 +79,6 struct VariableController::VariableControllerPrivate {
78 : m_WorkingMutex{},
79 : m_WorkingMutex{},
79 m_VariableModel{new VariableModel{parent}},
80 m_VariableModel{new VariableModel{parent}},
80 m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}},
81 m_VariableSelectionModel{new QItemSelectionModel{m_VariableModel, parent}},
81 m_VariableCacheController{std::make_unique<VariableCacheController>()},
82 m_VariableCacheStrategy{std::make_unique<VariableCacheStrategy>()},
82 m_VariableCacheStrategy{std::make_unique<VariableCacheStrategy>()},
83 m_VariableAcquisitionWorker{std::make_unique<VariableAcquisitionWorker>()},
83 m_VariableAcquisitionWorker{std::make_unique<VariableAcquisitionWorker>()},
84 q{parent}
84 q{parent}
@@ -97,7 +97,8 struct VariableController::VariableControllerPrivate {
97 }
97 }
98
98
99
99
100 void processRequest(std::shared_ptr<Variable> var, const SqpRange &rangeRequested);
100 void processRequest(std::shared_ptr<Variable> var, const SqpRange &rangeRequested,
101 QUuid varRequestId);
101
102
102 QVector<SqpRange> provideNotInCacheDateTimeList(std::shared_ptr<Variable> variable,
103 QVector<SqpRange> provideNotInCacheDateTimeList(std::shared_ptr<Variable> variable,
103 const SqpRange &dateTime);
104 const SqpRange &dateTime);
@@ -108,6 +109,11 struct VariableController::VariableControllerPrivate {
108
109
109 void registerProvider(std::shared_ptr<IDataProvider> provider);
110 void registerProvider(std::shared_ptr<IDataProvider> provider);
110
111
112 void storeVariableRequest(QUuid varId, QUuid varRequestId, const VariableRequest &varRequest);
113 QUuid acceptVariableRequest(QUuid varId, std::shared_ptr<IDataSeries> dataSeries);
114 void updateVariableRequest(QUuid varRequestId);
115 void cancelVariableRequest(QUuid varRequestId);
116
111 QMutex m_WorkingMutex;
117 QMutex m_WorkingMutex;
112 /// Variable model. The VariableController has the ownership
118 /// Variable model. The VariableController has the ownership
113 VariableModel *m_VariableModel;
119 VariableModel *m_VariableModel;
@@ -115,7 +121,6 struct VariableController::VariableControllerPrivate {
115
121
116
122
117 TimeController *m_TimeController{nullptr};
123 TimeController *m_TimeController{nullptr};
118 std::unique_ptr<VariableCacheController> m_VariableCacheController;
119 std::unique_ptr<VariableCacheStrategy> m_VariableCacheStrategy;
124 std::unique_ptr<VariableCacheStrategy> m_VariableCacheStrategy;
120 std::unique_ptr<VariableAcquisitionWorker> m_VariableAcquisitionWorker;
125 std::unique_ptr<VariableAcquisitionWorker> m_VariableAcquisitionWorker;
121 QThread m_VariableAcquisitionWorkerThread;
126 QThread m_VariableAcquisitionWorkerThread;
@@ -128,6 +133,10 struct VariableController::VariableControllerPrivate {
128 std::map<QUuid, QUuid> m_VariableIdGroupIdMap;
133 std::map<QUuid, QUuid> m_VariableIdGroupIdMap;
129 std::set<std::shared_ptr<IDataProvider> > m_ProviderSet;
134 std::set<std::shared_ptr<IDataProvider> > m_ProviderSet;
130
135
136 std::map<QUuid, std::map<QUuid, VariableRequest> > m_VarRequestIdToVarIdVarRequestMap;
137
138 std::map<QUuid, std::deque<QUuid> > m_VarIdToVarRequestIdQueueMap;
139
131
140
132 VariableController *q;
141 VariableController *q;
133 };
142 };
@@ -199,8 +208,6 void VariableController::deleteVariable(std::shared_ptr<Variable> variable) noex
199 << tr("Number of providers deleted for variable %1: %2")
208 << tr("Number of providers deleted for variable %1: %2")
200 .arg(variable->name(), QString::number(nbProvidersDeleted));
209 .arg(variable->name(), QString::number(nbProvidersDeleted));
201
210
202 // Clears cache
203 impl->m_VariableCacheController->clear(variable);
204
211
205 // Deletes from model
212 // Deletes from model
206 impl->m_VariableModel->deleteVariable(variable);
213 impl->m_VariableModel->deleteVariable(variable);
@@ -241,7 +248,10 VariableController::createVariable(const QString &name, const QVariantHash &meta
241 impl->m_VariableToIdentifierMap[newVariable] = identifier;
248 impl->m_VariableToIdentifierMap[newVariable] = identifier;
242
249
243
250
244 impl->processRequest(newVariable, range);
251 auto varRequestId = QUuid::createUuid();
252 qCInfo(LOG_VariableController()) << "processRequest for" << name << varRequestId;
253 impl->processRequest(newVariable, range, varRequestId);
254 impl->updateVariableRequest(varRequestId);
245
255
246 return newVariable;
256 return newVariable;
247 }
257 }
@@ -249,41 +259,32 VariableController::createVariable(const QString &name, const QVariantHash &meta
249
259
250 void VariableController::onDateTimeOnSelection(const SqpRange &dateTime)
260 void VariableController::onDateTimeOnSelection(const SqpRange &dateTime)
251 {
261 {
252 // TODO check synchronisation
262 // TODO check synchronisation and Rescale
253 qCDebug(LOG_VariableController()) << "VariableController::onDateTimeOnSelection"
263 qCDebug(LOG_VariableController()) << "VariableController::onDateTimeOnSelection"
254 << QThread::currentThread()->objectName();
264 << QThread::currentThread()->objectName();
255 auto selectedRows = impl->m_VariableSelectionModel->selectedRows();
265 auto selectedRows = impl->m_VariableSelectionModel->selectedRows();
266 auto varRequestId = QUuid::createUuid();
256
267
257 for (const auto &selectedRow : qAsConst(selectedRows)) {
268 for (const auto &selectedRow : qAsConst(selectedRows)) {
258 if (auto selectedVariable = impl->m_VariableModel->variable(selectedRow.row())) {
269 if (auto selectedVariable = impl->m_VariableModel->variable(selectedRow.row())) {
259 selectedVariable->setRange(dateTime);
270 selectedVariable->setRange(dateTime);
260 impl->processRequest(selectedVariable, dateTime);
271 impl->processRequest(selectedVariable, dateTime, varRequestId);
261
272
262 // notify that rescale operation has to be done
273 // notify that rescale operation has to be done
263 emit rangeChanged(selectedVariable, dateTime);
274 emit rangeChanged(selectedVariable, dateTime);
264 }
275 }
265 }
276 }
277 impl->updateVariableRequest(varRequestId);
266 }
278 }
267
279
268 void VariableController::onDataProvided(QUuid vIdentifier, const SqpRange &rangeRequested,
280 void VariableController::onDataProvided(QUuid vIdentifier, const SqpRange &rangeRequested,
269 const SqpRange &cacheRangeRequested,
281 const SqpRange &cacheRangeRequested,
270 QVector<AcquisitionDataPacket> dataAcquired)
282 QVector<AcquisitionDataPacket> dataAcquired)
271 {
283 {
272 if (auto var = impl->findVariable(vIdentifier)) {
284 auto retrievedDataSeries = impl->retrieveDataSeries(dataAcquired);
273 var->setRange(rangeRequested);
285 auto varRequestId = impl->acceptVariableRequest(vIdentifier, retrievedDataSeries);
274 var->setCacheRange(cacheRangeRequested);
286 if (!varRequestId.isNull()) {
275 qCDebug(LOG_VariableController()) << tr("1: onDataProvided") << rangeRequested;
287 impl->updateVariableRequest(varRequestId);
276 qCDebug(LOG_VariableController()) << tr("2: onDataProvided") << cacheRangeRequested;
277
278 auto retrievedDataSeries = impl->retrieveDataSeries(dataAcquired);
279 qCDebug(LOG_VariableController()) << tr("3: onDataProvided")
280 << retrievedDataSeries->range();
281 var->mergeDataSeries(retrievedDataSeries);
282 qCDebug(LOG_VariableController()) << tr("4: onDataProvided");
283 emit var->updated();
284 }
285 else {
286 qCCritical(LOG_VariableController()) << tr("Impossible to provide data to a null variable");
287 }
288 }
288 }
289 }
289
290
@@ -363,22 +364,25 void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable>
363 {
364 {
364 // NOTE: oldRange isn't really necessary since oldRange == variable->range().
365 // NOTE: oldRange isn't really necessary since oldRange == variable->range().
365
366
366 qCDebug(LOG_VariableController()) << "VariableController::onRequestDataLoading"
367 << QThread::currentThread()->objectName();
368 // we want to load data of the variable for the dateTime.
367 // we want to load data of the variable for the dateTime.
369 // First we check if the cache contains some of them.
368 // First we check if the cache contains some of them.
370 // For the other, we ask the provider to give them.
369 // For the other, we ask the provider to give them.
371
370
371 auto varRequestId = QUuid::createUuid();
372 qCInfo(LOG_VariableController()) << "VariableController::onRequestDataLoading"
373 << QThread::currentThread()->objectName() << varRequestId;
374
372 for (const auto &var : variables) {
375 for (const auto &var : variables) {
373 qCDebug(LOG_VariableController()) << "processRequest for" << var->name();
376 qCDebug(LOG_VariableController()) << "processRequest for" << var->name() << varRequestId;
374 impl->processRequest(var, range);
377 impl->processRequest(var, range, varRequestId);
375 }
378 }
376
379
377 if (synchronise) {
380 if (synchronise) {
378 // Get the group ids
381 // Get the group ids
379 qCDebug(LOG_VariableController())
382 qCDebug(LOG_VariableController())
380 << "TORM VariableController::onRequestDataLoading for synchro var ENABLE";
383 << "TORM VariableController::onRequestDataLoading for synchro var ENABLE";
381 auto groupIds = std::set<QUuid>();
384 auto groupIds = std::set<QUuid>{};
385 auto groupIdToOldRangeMap = std::map<QUuid, SqpRange>{};
382 for (const auto &var : variables) {
386 for (const auto &var : variables) {
383 auto varToVarIdIt = impl->m_VariableToIdentifierMap.find(var);
387 auto varToVarIdIt = impl->m_VariableToIdentifierMap.find(var);
384 if (varToVarIdIt != impl->m_VariableToIdentifierMap.cend()) {
388 if (varToVarIdIt != impl->m_VariableToIdentifierMap.cend()) {
@@ -386,6 +390,7 void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable>
386 auto varIdToGroupIdIt = impl->m_VariableIdGroupIdMap.find(vId);
390 auto varIdToGroupIdIt = impl->m_VariableIdGroupIdMap.find(vId);
387 if (varIdToGroupIdIt != impl->m_VariableIdGroupIdMap.cend()) {
391 if (varIdToGroupIdIt != impl->m_VariableIdGroupIdMap.cend()) {
388 auto gId = varIdToGroupIdIt->second;
392 auto gId = varIdToGroupIdIt->second;
393 groupIdToOldRangeMap.insert(std::make_pair(gId, var->range()));
389 if (groupIds.find(gId) == groupIds.cend()) {
394 if (groupIds.find(gId) == groupIds.cend()) {
390 qCDebug(LOG_VariableController()) << "Synchro detect group " << gId;
395 qCDebug(LOG_VariableController()) << "Synchro detect group " << gId;
391 groupIds.insert(gId);
396 groupIds.insert(gId);
@@ -407,9 +412,10 void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable>
407 if (var != nullptr) {
412 if (var != nullptr) {
408 qCDebug(LOG_VariableController()) << "processRequest synchro for"
413 qCDebug(LOG_VariableController()) << "processRequest synchro for"
409 << var->name();
414 << var->name();
410 auto vSyncRangeRequested
415 auto vSyncRangeRequested = computeSynchroRangeRequested(
411 = computeSynchroRangeRequested(var->range(), range, oldRange);
416 var->range(), range, groupIdToOldRangeMap.at(gId));
412 impl->processRequest(var, vSyncRangeRequested);
417 qCDebug(LOG_VariableController()) << "synchro RR" << vSyncRangeRequested;
418 impl->processRequest(var, vSyncRangeRequested, varRequestId);
413 }
419 }
414 else {
420 else {
415 qCCritical(LOG_VariableController())
421 qCCritical(LOG_VariableController())
@@ -420,6 +426,8 void VariableController::onRequestDataLoading(QVector<std::shared_ptr<Variable>
420 }
426 }
421 }
427 }
422 }
428 }
429
430 impl->updateVariableRequest(varRequestId);
423 }
431 }
424
432
425
433
@@ -463,22 +471,43 AcquisitionZoomType VariableController::getZoomType(const SqpRange &range, const
463 }
471 }
464
472
465 void VariableController::VariableControllerPrivate::processRequest(std::shared_ptr<Variable> var,
473 void VariableController::VariableControllerPrivate::processRequest(std::shared_ptr<Variable> var,
466 const SqpRange &rangeRequested)
474 const SqpRange &rangeRequested,
475 QUuid varRequestId)
467 {
476 {
468
477
469 auto varRangesRequested
478 // TODO: protect at
470 = m_VariableCacheStrategy->computeCacheRange(var->range(), rangeRequested);
479 auto varRequest = VariableRequest{};
471 auto notInCacheRangeList = var->provideNotInCacheRangeList(varRangesRequested.second);
480 auto varId = m_VariableToIdentifierMap.at(var);
472 auto inCacheRangeList = var->provideInCacheRangeList(varRangesRequested.second);
481
482 auto varStrategyRangesRequested
483 = m_VariableCacheStrategy->computeStrategyRanges(var->range(), rangeRequested);
484 auto notInCacheRangeList = var->provideNotInCacheRangeList(varStrategyRangesRequested.second);
485 auto inCacheRangeList = var->provideInCacheRangeList(varStrategyRangesRequested.second);
473
486
474 if (!notInCacheRangeList.empty()) {
487 if (!notInCacheRangeList.empty()) {
475 auto identifier = m_VariableToIdentifierMap.at(var);
488 varRequest.m_RangeRequested = varStrategyRangesRequested.first;
489 varRequest.m_CacheRangeRequested = varStrategyRangesRequested.second;
490 qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM processRequest RR ") << rangeRequested;
491 qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM processRequest R ")
492 << varStrategyRangesRequested.first;
493 qCDebug(LOG_VariableAcquisitionWorker()) << tr("TORM processRequest CR ")
494 << varStrategyRangesRequested.second;
495 // store VarRequest
496 storeVariableRequest(varId, varRequestId, varRequest);
497
476 auto varProvider = m_VariableToProviderMap.at(var);
498 auto varProvider = m_VariableToProviderMap.at(var);
477 if (varProvider != nullptr) {
499 if (varProvider != nullptr) {
478 m_VariableAcquisitionWorker->pushVariableRequest(
500 auto varRequestIdCanceled = m_VariableAcquisitionWorker->pushVariableRequest(
479 identifier, varRangesRequested.first, varRangesRequested.second,
501 varRequestId, varId, varStrategyRangesRequested.first,
502 varStrategyRangesRequested.second,
480 DataProviderParameters{std::move(notInCacheRangeList), var->metadata()},
503 DataProviderParameters{std::move(notInCacheRangeList), var->metadata()},
481 varProvider);
504 varProvider);
505
506 if (!varRequestIdCanceled.isNull()) {
507 qCInfo(LOG_VariableAcquisitionWorker()) << tr("varRequestIdCanceled: ")
508 << varRequestIdCanceled;
509 cancelVariableRequest(varRequestIdCanceled);
510 }
482 }
511 }
483 else {
512 else {
484 qCCritical(LOG_VariableController())
513 qCCritical(LOG_VariableController())
@@ -490,10 +519,13 void VariableController::VariableControllerPrivate::processRequest(std::shared_p
490 }
519 }
491 }
520 }
492 else {
521 else {
493 var->setRange(rangeRequested);
522
494 var->setCacheRange(varRangesRequested.second);
523 varRequest.m_RangeRequested = varStrategyRangesRequested.first;
495 var->setDataSeries(var->dataSeries()->subDataSeries(varRangesRequested.second));
524 varRequest.m_CacheRangeRequested = varStrategyRangesRequested.second;
496 emit var->updated();
525 // store VarRequest
526 storeVariableRequest(varId, varRequestId, varRequest);
527 acceptVariableRequest(varId,
528 var->dataSeries()->subDataSeries(varStrategyRangesRequested.second));
497 }
529 }
498 }
530 }
499
531
@@ -550,3 +582,157 void VariableController::VariableControllerPrivate::registerProvider(
550 qCDebug(LOG_VariableController()) << tr("Cannot register provider, it already exists ");
582 qCDebug(LOG_VariableController()) << tr("Cannot register provider, it already exists ");
551 }
583 }
552 }
584 }
585
586 void VariableController::VariableControllerPrivate::storeVariableRequest(
587 QUuid varId, QUuid varRequestId, const VariableRequest &varRequest)
588 {
589 // First request for the variable. we can create an entry for it
590 auto varIdToVarRequestIdQueueMapIt = m_VarIdToVarRequestIdQueueMap.find(varId);
591 if (varIdToVarRequestIdQueueMapIt == m_VarIdToVarRequestIdQueueMap.cend()) {
592 auto varRequestIdQueue = std::deque<QUuid>{};
593 qCDebug(LOG_VariableController()) << tr("Store REQUEST in QUEUE");
594 varRequestIdQueue.push_back(varRequestId);
595 m_VarIdToVarRequestIdQueueMap.insert(std::make_pair(varId, std::move(varRequestIdQueue)));
596 }
597 else {
598 qCDebug(LOG_VariableController()) << tr("Store REQUEST in EXISTING QUEUE");
599 auto &varRequestIdQueue = varIdToVarRequestIdQueueMapIt->second;
600 varRequestIdQueue.push_back(varRequestId);
601 }
602
603 auto varRequestIdToVarIdVarRequestMapIt = m_VarRequestIdToVarIdVarRequestMap.find(varRequestId);
604 if (varRequestIdToVarIdVarRequestMapIt == m_VarRequestIdToVarIdVarRequestMap.cend()) {
605 auto varIdToVarRequestMap = std::map<QUuid, VariableRequest>{};
606 varIdToVarRequestMap.insert(std::make_pair(varId, varRequest));
607 qCDebug(LOG_VariableController()) << tr("Store REQUESTID in MAP");
608 m_VarRequestIdToVarIdVarRequestMap.insert(
609 std::make_pair(varRequestId, std::move(varIdToVarRequestMap)));
610 }
611 else {
612 auto &varIdToVarRequestMap = varRequestIdToVarIdVarRequestMapIt->second;
613 qCDebug(LOG_VariableController()) << tr("Store REQUESTID in EXISTING MAP");
614 varIdToVarRequestMap.insert(std::make_pair(varId, varRequest));
615 }
616 }
617
618 QUuid VariableController::VariableControllerPrivate::acceptVariableRequest(
619 QUuid varId, std::shared_ptr<IDataSeries> dataSeries)
620 {
621 QUuid varRequestId;
622 auto varIdToVarRequestIdQueueMapIt = m_VarIdToVarRequestIdQueueMap.find(varId);
623 if (varIdToVarRequestIdQueueMapIt != m_VarIdToVarRequestIdQueueMap.cend()) {
624 auto &varRequestIdQueue = varIdToVarRequestIdQueueMapIt->second;
625 varRequestId = varRequestIdQueue.front();
626 auto varRequestIdToVarIdVarRequestMapIt
627 = m_VarRequestIdToVarIdVarRequestMap.find(varRequestId);
628 if (varRequestIdToVarIdVarRequestMapIt != m_VarRequestIdToVarIdVarRequestMap.cend()) {
629 auto &varIdToVarRequestMap = varRequestIdToVarIdVarRequestMapIt->second;
630 auto varIdToVarRequestMapIt = varIdToVarRequestMap.find(varId);
631 if (varIdToVarRequestMapIt != varIdToVarRequestMap.cend()) {
632 qCDebug(LOG_VariableController()) << tr("acceptVariableRequest");
633 auto &varRequest = varIdToVarRequestMapIt->second;
634 varRequest.m_DataSeries = dataSeries;
635 varRequest.m_CanUpdate = true;
636 }
637 else {
638 qCDebug(LOG_VariableController())
639 << tr("Impossible to acceptVariableRequest of a unknown variable id attached "
640 "to a variableRequestId")
641 << varRequestId << varId;
642 }
643 }
644 else {
645 qCCritical(LOG_VariableController())
646 << tr("Impossible to acceptVariableRequest of a unknown variableRequestId")
647 << varRequestId;
648 }
649
650 qCDebug(LOG_VariableController()) << tr("1: erase REQUEST in QUEUE ?")
651 << varRequestIdQueue.size();
652 varRequestIdQueue.pop_front();
653 qCDebug(LOG_VariableController()) << tr("2: erase REQUEST in QUEUE ?")
654 << varRequestIdQueue.size();
655 if (varRequestIdQueue.empty()) {
656 m_VarIdToVarRequestIdQueueMap.erase(varId);
657 }
658 }
659 else {
660 qCCritical(LOG_VariableController())
661 << tr("Impossible to acceptVariableRequest of a unknown variable id") << varId;
662 }
663
664 return varRequestId;
665 }
666
667 void VariableController::VariableControllerPrivate::updateVariableRequest(QUuid varRequestId)
668 {
669
670 auto varRequestIdToVarIdVarRequestMapIt = m_VarRequestIdToVarIdVarRequestMap.find(varRequestId);
671 if (varRequestIdToVarIdVarRequestMapIt != m_VarRequestIdToVarIdVarRequestMap.cend()) {
672 bool processVariableUpdate = true;
673 auto &varIdToVarRequestMap = varRequestIdToVarIdVarRequestMapIt->second;
674 for (auto varIdToVarRequestMapIt = varIdToVarRequestMap.cbegin();
675 (varIdToVarRequestMapIt != varIdToVarRequestMap.cend()) && processVariableUpdate;
676 ++varIdToVarRequestMapIt) {
677 processVariableUpdate &= varIdToVarRequestMapIt->second.m_CanUpdate;
678 qCDebug(LOG_VariableController()) << tr("updateVariableRequest")
679 << processVariableUpdate;
680 }
681
682 if (processVariableUpdate) {
683 for (auto varIdToVarRequestMapIt = varIdToVarRequestMap.cbegin();
684 varIdToVarRequestMapIt != varIdToVarRequestMap.cend(); ++varIdToVarRequestMapIt) {
685 if (auto var = findVariable(varIdToVarRequestMapIt->first)) {
686 auto &varRequest = varIdToVarRequestMapIt->second;
687 var->setRange(varRequest.m_RangeRequested);
688 var->setCacheRange(varRequest.m_CacheRangeRequested);
689 qCDebug(LOG_VariableController()) << tr("1: onDataProvided")
690 << varRequest.m_RangeRequested;
691 qCDebug(LOG_VariableController()) << tr("2: onDataProvided")
692 << varRequest.m_CacheRangeRequested;
693 var->mergeDataSeries(varRequest.m_DataSeries);
694 qCDebug(LOG_VariableController()) << tr("3: onDataProvided")
695 << varRequest.m_DataSeries->range();
696 qCDebug(LOG_VariableController()) << tr("4: onDataProvided");
697 emit var->updated();
698 }
699 else {
700 qCCritical(LOG_VariableController())
701 << tr("Impossible to update data to a null variable");
702 }
703 }
704
705 // cleaning varRequestId
706 qCDebug(LOG_VariableController()) << tr("0: erase REQUEST in MAP ?")
707 << m_VarRequestIdToVarIdVarRequestMap.size();
708 m_VarRequestIdToVarIdVarRequestMap.erase(varRequestId);
709 qCDebug(LOG_VariableController()) << tr("1: erase REQUEST in MAP ?")
710 << m_VarRequestIdToVarIdVarRequestMap.size();
711 }
712 }
713 else {
714 qCCritical(LOG_VariableController())
715 << tr("Cannot updateVariableRequest for a unknow varRequestId") << varRequestId;
716 }
717 }
718
719 void VariableController::VariableControllerPrivate::cancelVariableRequest(QUuid varRequestId)
720 {
721 // cleaning varRequestId
722 m_VarRequestIdToVarIdVarRequestMap.erase(varRequestId);
723
724 for (auto varIdToVarRequestIdQueueMapIt = m_VarIdToVarRequestIdQueueMap.begin();
725 varIdToVarRequestIdQueueMapIt != m_VarIdToVarRequestIdQueueMap.end();) {
726 auto &varRequestIdQueue = varIdToVarRequestIdQueueMapIt->second;
727 varRequestIdQueue.erase(
728 std::remove(varRequestIdQueue.begin(), varRequestIdQueue.end(), varRequestId),
729 varRequestIdQueue.end());
730 if (varRequestIdQueue.empty()) {
731 varIdToVarRequestIdQueueMapIt
732 = m_VarIdToVarRequestIdQueueMap.erase(varIdToVarRequestIdQueueMapIt);
733 }
734 else {
735 ++varIdToVarRequestIdQueueMapIt;
736 }
737 }
738 }
@@ -9,9 +9,9
9 #include <Variable/Variable.h>
9 #include <Variable/Variable.h>
10 #include <Variable/VariableController.h>
10 #include <Variable/VariableController.h>
11
11
12 #include <cmath>
13 #include <QUuid>
12 #include <QUuid>
14 #include <SqpApplication.h>
13 #include <SqpApplication.h>
14 #include <cmath>
15
15
16 Q_LOGGING_CATEGORY(LOG_VisualizationZoneWidget, "VisualizationZoneWidget")
16 Q_LOGGING_CATEGORY(LOG_VisualizationZoneWidget, "VisualizationZoneWidget")
17
17
@@ -100,49 +100,49 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<V
100 auto deltaRight = oldGraphRange.m_TEnd - graphRange.m_TEnd;
100 auto deltaRight = oldGraphRange.m_TEnd - graphRange.m_TEnd;
101 graphChildRange.m_TStart += deltaLeft;
101 graphChildRange.m_TStart += deltaLeft;
102 graphChildRange.m_TEnd -= deltaRight;
102 graphChildRange.m_TEnd -= deltaRight;
103 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: ZoomIn");
103 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: ZoomIn");
104 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: deltaLeft")
104 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: deltaLeft")
105 << deltaLeft;
105 << deltaLeft;
106 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: deltaRight")
106 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: deltaRight")
107 << deltaRight;
107 << deltaRight;
108 qCCritical(LOG_VisualizationZoneWidget())
108 qCDebug(LOG_VisualizationZoneWidget())
109 << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart;
109 << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart;
110
110
111 break;
111 break;
112 }
112 }
113
113
114 case AcquisitionZoomType::ZoomOut: {
114 case AcquisitionZoomType::ZoomOut: {
115 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: ZoomOut");
115 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: ZoomOut");
116 auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart;
116 auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart;
117 auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd;
117 auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd;
118 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: deltaLeft")
118 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: deltaLeft")
119 << deltaLeft;
119 << deltaLeft;
120 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: deltaRight")
120 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: deltaRight")
121 << deltaRight;
121 << deltaRight;
122 qCCritical(LOG_VisualizationZoneWidget())
122 qCDebug(LOG_VisualizationZoneWidget())
123 << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart;
123 << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart;
124 graphChildRange.m_TStart -= deltaLeft;
124 graphChildRange.m_TStart -= deltaLeft;
125 graphChildRange.m_TEnd += deltaRight;
125 graphChildRange.m_TEnd += deltaRight;
126 break;
126 break;
127 }
127 }
128 case AcquisitionZoomType::PanRight: {
128 case AcquisitionZoomType::PanRight: {
129 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: PanRight");
129 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: PanRight");
130 auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd;
130 auto deltaRight = graphRange.m_TEnd - oldGraphRange.m_TEnd;
131 graphChildRange.m_TStart += deltaRight;
131 graphChildRange.m_TStart += deltaRight;
132 graphChildRange.m_TEnd += deltaRight;
132 graphChildRange.m_TEnd += deltaRight;
133 qCCritical(LOG_VisualizationZoneWidget())
133 qCDebug(LOG_VisualizationZoneWidget())
134 << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart;
134 << tr("TORM: dt") << graphRange.m_TEnd - graphRange.m_TStart;
135 break;
135 break;
136 }
136 }
137 case AcquisitionZoomType::PanLeft: {
137 case AcquisitionZoomType::PanLeft: {
138 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: PanLeft");
138 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: PanLeft");
139 auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart;
139 auto deltaLeft = oldGraphRange.m_TStart - graphRange.m_TStart;
140 graphChildRange.m_TStart -= deltaLeft;
140 graphChildRange.m_TStart -= deltaLeft;
141 graphChildRange.m_TEnd -= deltaLeft;
141 graphChildRange.m_TEnd -= deltaLeft;
142 break;
142 break;
143 }
143 }
144 case AcquisitionZoomType::Unknown: {
144 case AcquisitionZoomType::Unknown: {
145 qCCritical(LOG_VisualizationZoneWidget())
145 qCDebug(LOG_VisualizationZoneWidget())
146 << tr("Impossible to synchronize: zoom type unknown");
146 << tr("Impossible to synchronize: zoom type unknown");
147 break;
147 break;
148 }
148 }
@@ -153,11 +153,11 VisualizationGraphWidget *VisualizationZoneWidget::createGraph(std::shared_ptr<V
153 break;
153 break;
154 }
154 }
155 graphChild->enableAcquisition(false);
155 graphChild->enableAcquisition(false);
156 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: Range before: ")
156 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: Range before: ")
157 << graphChild->graphRange();
157 << graphChild->graphRange();
158 qCCritical(LOG_VisualizationZoneWidget()) << tr("TORM: Range after : ")
158 qCDebug(LOG_VisualizationZoneWidget()) << tr("TORM: Range after : ")
159 << graphChildRange;
159 << graphChildRange;
160 qCCritical(LOG_VisualizationZoneWidget())
160 qCDebug(LOG_VisualizationZoneWidget())
161 << tr("TORM: child dt") << graphChildRange.m_TEnd - graphChildRange.m_TStart;
161 << tr("TORM: child dt") << graphChildRange.m_TEnd - graphChildRange.m_TStart;
162 graphChild->setGraphRange(graphChildRange);
162 graphChild->setGraphRange(graphChildRange);
163 graphChild->enableAcquisition(true);
163 graphChild->enableAcquisition(true);
@@ -11,12 +11,16
11
11
12 Q_DECLARE_LOGGING_CATEGORY(LOG_AmdaPlugin)
12 Q_DECLARE_LOGGING_CATEGORY(LOG_AmdaPlugin)
13
13
14 #ifndef PLUGIN_JSON_FILE_PATH
15 #define PLUGIN_JSON_FILE_PATH "amda.json"
16 #endif
17
14 class DataSourceItem;
18 class DataSourceItem;
15
19
16 class SCIQLOP_AMDA_EXPORT AmdaPlugin : public QObject, public IPlugin {
20 class SCIQLOP_AMDA_EXPORT AmdaPlugin : public QObject, public IPlugin {
17 Q_OBJECT
21 Q_OBJECT
18 Q_INTERFACES(IPlugin)
22 Q_INTERFACES(IPlugin)
19 Q_PLUGIN_METADATA(IID "sciqlop.plugin.IPlugin" FILE "amda.json")
23 Q_PLUGIN_METADATA(IID "sciqlop.plugin.IPlugin" FILE PLUGIN_JSON_FILE_PATH)
20 public:
24 public:
21 /// @sa IPlugin::initialize()
25 /// @sa IPlugin::initialize()
22 void initialize() override;
26 void initialize() override;
@@ -76,8 +76,8 void AmdaProvider::requestDataLoading(QUuid acqIdentifier, const DataProviderPar
76 for (const auto &dateTime : qAsConst(times)) {
76 for (const auto &dateTime : qAsConst(times)) {
77 this->retrieveData(acqIdentifier, dateTime, data);
77 this->retrieveData(acqIdentifier, dateTime, data);
78
78
79 // TORM
79 // TORM when AMDA will support quick asynchrone request
80 // QThread::msleep(200);
80 QThread::msleep(1000);
81 }
81 }
82 }
82 }
83
83
@@ -130,8 +130,8 void TestAmdaAcquisition::testAcquisition()
130 QTimer::singleShot(timeToWaitMs, &loop, &QEventLoop::quit);
130 QTimer::singleShot(timeToWaitMs, &loop, &QEventLoop::quit);
131 loop.exec();
131 loop.exec();
132
132
133 qDebug() << count << "RANGE " << var->range();
133 qInfo() << count << "RANGE " << var->range();
134 qDebug() << count << "CACHERANGE" << var->cacheRange();
134 qInfo() << count << "CACHERANGE" << var->cacheRange();
135
135
136 QCOMPARE(var->range().m_TStart, nextSqpR.m_TStart);
136 QCOMPARE(var->range().m_TStart, nextSqpR.m_TStart);
137 QCOMPARE(var->range().m_TEnd, nextSqpR.m_TEnd);
137 QCOMPARE(var->range().m_TEnd, nextSqpR.m_TEnd);
@@ -144,7 +144,7 void TestAmdaAcquisition::testAcquisition()
144 // 2 : pan (jump) left for one hour
144 // 2 : pan (jump) left for one hour
145 auto nextVarRS = QDateTime{QDate{2012, 01, 02}, QTime{2, 1, 0, 0}};
145 auto nextVarRS = QDateTime{QDate{2012, 01, 02}, QTime{2, 1, 0, 0}};
146 auto nextVarRE = QDateTime{QDate{2012, 01, 02}, QTime{2, 2, 0, 0}};
146 auto nextVarRE = QDateTime{QDate{2012, 01, 02}, QTime{2, 2, 0, 0}};
147 // requestDataLoading(nextVarRS, nextVarRE);
147 requestDataLoading(nextVarRS, nextVarRE);
148
148
149
149
150 // 3 : pan (jump) right for one hour
150 // 3 : pan (jump) right for one hour
@@ -9,6 +9,10
9
9
10 #include <memory>
10 #include <memory>
11
11
12 #ifndef PLUGIN_JSON_FILE_PATH
13 #define PLUGIN_JSON_FILE_PATH "mockplugin.json"
14 #endif
15
12 Q_DECLARE_LOGGING_CATEGORY(LOG_MockPlugin)
16 Q_DECLARE_LOGGING_CATEGORY(LOG_MockPlugin)
13
17
14 class DataSourceItem;
18 class DataSourceItem;
@@ -16,7 +20,7 class DataSourceItem;
16 class SCIQLOP_MOCKPLUGIN_EXPORT MockPlugin : public QObject, public IPlugin {
20 class SCIQLOP_MOCKPLUGIN_EXPORT MockPlugin : public QObject, public IPlugin {
17 Q_OBJECT
21 Q_OBJECT
18 Q_INTERFACES(IPlugin)
22 Q_INTERFACES(IPlugin)
19 Q_PLUGIN_METADATA(IID "sciqlop.plugin.IPlugin" FILE "mockplugin.json")
23 Q_PLUGIN_METADATA(IID "sciqlop.plugin.IPlugin" FILE PLUGIN_JSON_FILE_PATH)
20 public:
24 public:
21 /// @sa IPlugin::initialize()
25 /// @sa IPlugin::initialize()
22 void initialize() override;
26 void initialize() override;
General Comments 0
You need to be logged in to leave comments. Login now