PyTestAmdaWrapper.cpp
126 lines
| 4.9 KiB
| text/x-c
|
CppLexer
r1339 | /*------------------------------------------------------------------------------ | |||
-- This file is a part of the SciQLOP Software | ||||
-- Copyright (C) 2018, Plasma Physics Laboratory - CNRS | ||||
-- | ||||
-- This program is free software; you can redistribute it and/or modify | ||||
-- it under the terms of the GNU General Public License as published by | ||||
-- the Free Software Foundation; either version 2 of the License, or | ||||
-- (at your option) any later version. | ||||
-- | ||||
-- This program is distributed in the hope that it will be useful, | ||||
-- but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
-- GNU General Public License for more details. | ||||
-- | ||||
-- You should have received a copy of the GNU General Public License | ||||
-- along with this program; if not, write to the Free Software | ||||
-- Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | ||||
-------------------------------------------------------------------------------*/ | ||||
/*-- Author : Alexis Jeandet | ||||
-- Mail : alexis.jeandet@member.fsf.org | ||||
----------------------------------------------------------------------------*/ | ||||
#include <string> | ||||
#include <sstream> | ||||
#include <memory> | ||||
#include <pybind11/pybind11.h> | ||||
#include <pybind11/operators.h> | ||||
#include <pybind11/embed.h> | ||||
r1340 | #include <pybind11/numpy.h> | |||
#include <pybind11/chrono.h> | ||||
r1339 | ||||
#include <SqpApplication.h> | ||||
r1348 | #include <Variable/VariableController2.h> | |||
r1339 | #include <Time/TimeController.h> | |||
r1347 | #include <Data/DateTimeRange.h> | |||
r1339 | #include <Data/DataSeriesType.h> | |||
#include <Common/DateUtils.h> | ||||
#include <Variable/Variable.h> | ||||
#include <Data/ScalarSeries.h> | ||||
r1340 | #include <Data/VectorSeries.h> | |||
r1339 | ||||
#include <AmdaProvider.h> | ||||
#include <AmdaResultParser.h> | ||||
r1341 | //#include <QDate> | |||
//#include <QTime> | ||||
//#include <QUuid> | ||||
//#include <QString> | ||||
r1339 | #include <QFile> | |||
r1341 | #include <pywrappers_common.h> | |||
#include <CoreWrappers.h> | ||||
r1340 | ||||
r1346 | #include "PyTestAmdaWrapper.h" | |||
r1339 | ||||
r1341 | using namespace std::chrono; | |||
r1339 | ||||
r1340 | ||||
r1339 | PYBIND11_MODULE(pytestamda, m){ | |||
r1341 | ||||
r1340 | int argc = 0; | |||
char ** argv=nullptr; | ||||
SqpApplication::setOrganizationName("LPP"); | ||||
SqpApplication::setOrganizationDomain("lpp.fr"); | ||||
SqpApplication::setApplicationName("SciQLop"); | ||||
static SqpApplication app(argc, argv); | ||||
r1341 | auto qtmod = py::module::import("sciqlopqt"); | |||
auto sciqlopmod = py::module::import("pysciqlopcore"); | ||||
r1339 | ||||
r1341 | m.doc() = "hello"; | |||
r1339 | ||||
r1348 | // py::class_<VariableController>(m, "VariableController") | |||
// .def_static("createVariable",[](const QString &name, | ||||
// std::shared_ptr<IDataProvider> provider, const DateTimeRange& range){ | ||||
// return sqpApp->variableController().createVariable(name, {{"dataType", "vector"}, {"xml:id", "c1_b"}}, provider, range); | ||||
// }) | ||||
// .def_static("hasPendingDownloads", | ||||
// [](){return sqpApp->variableController().hasPendingDownloads();} | ||||
// ) | ||||
// .def_static("addSynchronizationGroup", | ||||
// [](QUuid uuid){sqpApp->variableController().onAddSynchronizationGroupId(uuid);} | ||||
// ) | ||||
// .def_static("removeSynchronizationGroup", | ||||
// [](QUuid uuid){sqpApp->variableController().onRemoveSynchronizationGroupId(uuid);} | ||||
// ) | ||||
// .def_static("synchronizeVar", | ||||
// [](std::shared_ptr<Variable> variable, QUuid uuid){sqpApp->variableController().onAddSynchronized(variable, uuid);} | ||||
// ) | ||||
// .def_static("deSynchronizeVar", | ||||
// [](std::shared_ptr<Variable> variable, QUuid uuid){sqpApp->variableController().desynchronize(variable, uuid);} | ||||
// ) | ||||
// .def_static("deleteVariable", | ||||
// [](std::shared_ptr<Variable> variable){ | ||||
// sqpApp->variableController().deleteVariable(variable);} | ||||
// ) | ||||
// .def_static("update_range",[](std::shared_ptr<Variable> variable, const DateTimeRange &range, bool synchronise){ | ||||
// sqpApp->variableController().onRequestDataLoading({variable}, range, synchronise); | ||||
// }) | ||||
// .def_static("wait_for_downloads",[](){ | ||||
// while (sqpApp->variableController().hasPendingDownloads()) { | ||||
// usleep(100); | ||||
// } | ||||
// }); | ||||
r1339 | ||||
r1340 | py::class_<TimeController>(m,"TimeController") | |||
r1346 | .def_static("setTime", [](DateTimeRange range){sqpApp->timeController().setDateTimeRange(range);}); | |||
r1340 | ||||
r1341 | ||||
auto amda_provider = std::make_shared<AmdaProvider>(); | ||||
m.def("amda_provider",[amda_provider](){return amda_provider;}, py::return_value_policy::copy); | ||||
r1340 | ||||
py::class_<AmdaProvider, std::shared_ptr<AmdaProvider>, IDataProvider>(m, "AmdaProvider"); | ||||
r1339 | ||||
r1351 | // py::class_<AmdaResultParser>(m, "AmdaResultParser") | |||
// .def_static("readTxt", AmdaResultParser::readTxt) | ||||
// .def("readScalarTxt", [](const QString& path){ | ||||
// return std::dynamic_pointer_cast<ScalarSeries>(AmdaResultParser::readTxt(path, DataSeriesType::SCALAR)); | ||||
// }, py::return_value_policy::copy); | ||||
r1339 | ||||
} | ||||