From 4bf34af328583ce5902d1c1b8c5e20223ccd9155 2021-07-13 14:30:12 From: Alexis Jeandet Date: 2021-07-13 14:30:12 Subject: [PATCH] Few fixes to build on CentOS 7 and adds simple example of virtual product Signed-off-by: Alexis Jeandet --- diff --git a/app/PySide2-bindings/meson.build b/app/PySide2-bindings/meson.build index 42333ab..20ea284 100644 --- a/app/PySide2-bindings/meson.build +++ b/app/PySide2-bindings/meson.build @@ -17,6 +17,11 @@ shiboken2_build_flags = run_command(python3, 'shiboken-helper.py', '--includes', shiboken2_link_flags = run_command(python3, 'shiboken-helper.py', '--libs', modules_arg).stdout().strip('\n').split(' ') shiboken2_typesystem = run_command(python3, 'shiboken-helper.py', '--typesystem').stdout().strip('\n') +message('shiboken2_build_flags = @0@'.format(shiboken2_build_flags)) +message('shiboken2_link_flags = @0@'.format(shiboken2_link_flags)) +message('shiboken2_typesystem = @0@'.format(shiboken2_typesystem)) + + sciqlop_bindings_incs = shiboken2_build_flags + [ '-I'+meson.current_source_dir()+'/../../gui/include', '-I'+meson.current_source_dir()+'/../../core/include', diff --git a/app/PySide2-bindings/plugins/Demo-virtual-product.py b/app/PySide2-bindings/plugins/Demo-virtual-product.py new file mode 100644 index 0000000..9ce7553 --- /dev/null +++ b/app/PySide2-bindings/plugins/Demo-virtual-product.py @@ -0,0 +1,38 @@ +import traceback +from SciQLopBindings import PyDataProvider, Product, VectorTimeSerie, ScalarTimeSerie, DataSeriesType +import numpy as np +from spwc.cache import _cache +from spwc.common.datetime_range import DateTimeRange +from datetime import datetime, timedelta, timezone +from spwc.common.variable import SpwcVariable +from spwc.amda import AMDA + +amda = AMDA() + + +def vp_make_scalar(var=None): + if var is None: + return (((np.array([]), np.array([])), np.array([])), DataSeriesType.SCALAR) + else: + return (((var.time, np.array([])), var.data), DataSeriesType.SCALAR) + +class DemoVP(PyDataProvider): + def __init__(self): + super().__init__() + self.register_products([Product("/VP/thb_fgm_gse_mod",[],{"type":"scalar"})]) + + def get_data(self,metadata,start,stop): + try: + tstart = datetime.fromtimestamp(start, tz=timezone.utc) + tend = datetime.fromtimestamp(stop, tz=timezone.utc) + thb_bs = amda.get_parameter(start_time=tstart, stop_time=tend, parameter_id='thb_bs', method="REST") + thb_bs.data = np.sqrt((thb_bs.data*thb_bs.data).sum(axis=1)) + return vp_make_scalar(thb_bs) + except Exception as e: + print(traceback.format_exc()) + print(f"Error in {__file__} ",str(e)) + return (((np.array([]), np.array([])), np.array([])), ts_type) + + +t=DemoVP() + diff --git a/app/PySide2-bindings/plugins/meson.build b/app/PySide2-bindings/plugins/meson.build index e1c8dd6..193c773 100644 --- a/app/PySide2-bindings/plugins/meson.build +++ b/app/PySide2-bindings/plugins/meson.build @@ -1,3 +1,4 @@ configure_file(input:'TestPlugin.py', output:'TestPlugin.py', copy:true) configure_file(input:'SPWC-Amda.py', output:'SPWC-Amda.py', copy:true) +configure_file(input:'Demo-virtual-product.py', output:'Demo-virtual-product.py', copy:true) diff --git a/app/PySide2-bindings/shiboken-helper.py b/app/PySide2-bindings/shiboken-helper.py old mode 100755 new mode 100644 index d191a7b..d4da821 --- a/app/PySide2-bindings/shiboken-helper.py +++ b/app/PySide2-bindings/shiboken-helper.py @@ -29,14 +29,14 @@ if shiboken2.__file__ and shiboken2_generator.__file__ and PySide2.__file__: PySide2_inc = first_existing_path([PySide2.__path__[0]+'/include','/usr/include/PySide2']) PySide2_typesys = first_existing_path([PySide2.__path__[0]+'/typesystems','/usr/share/PySide2/typesystems']) PySide2_includes = first_existing_path([PySide2.__path__[0]+'/include','/usr/include/PySide2']) - shiboken2_includes = first_existing_path([shiboken2.__path__[0]+'/include','/usr/include/shiboken2']) + shiboken2_includes = first_existing_path([shiboken2.__path__[0]+'/include',shiboken2_generator.__path__[0]+'/include','/usr/include/shiboken2']) if args.typesystem: print(PySide2_typesys) modules = args.modules.split(',') if args.libs: - main_lib = (glob(shiboken2.__path__[0]+'/libshiboken2'+importlib.machinery.EXTENSION_SUFFIXES[0])+glob("/usr/lib64/"+'/libshiboken2'+importlib.machinery.EXTENSION_SUFFIXES[0]))[0] - main_lib += " "+(glob(PySide2.__path__[0]+'/libpyside2'+importlib.machinery.EXTENSION_SUFFIXES[0])+glob("/usr/lib64/"+'/libpyside2'+importlib.machinery.EXTENSION_SUFFIXES[0]))[0] + main_lib = (glob(shiboken2.__path__[0]+'/libshiboken2'+importlib.machinery.EXTENSION_SUFFIXES[0]+'*')+glob("/usr/lib64/"+'/libshiboken2'+importlib.machinery.EXTENSION_SUFFIXES[0]+'*'))[0] + main_lib += " "+(glob(PySide2.__path__[0]+'/libpyside2'+importlib.machinery.EXTENSION_SUFFIXES[0]+'*')+glob("/usr/lib64/"+'/libpyside2'+importlib.machinery.EXTENSION_SUFFIXES[0]+'*'))[0] modules_libs = [importlib.import_module(f'PySide2.{module}').__file__ for module in modules] print(" ".join([main_lib]+ modules_libs)) if args.includes: