From 024781f0070dada2b88eed4bb82bbd92f2d7041f Mon Sep 17 00:00:00 2001
From: Giacomo Strangolino <giacomo.strangolino@elettra.eu>
Date: Thu, 9 Sep 2021 14:30:29 +0200
Subject: [PATCH] ported to cumbia

---
 4uhv.pro        |  83 ++++++++++++++++++++-----
 src/4uhv.cpp    | 138 ++++++++++++++++++++++--------------------
 src/4uhv.h      |  19 +++++-
 src/4uhv.ui     |  13 ++--
 src/channel.cpp |  10 +--
 src/channel.h   |   8 ++-
 src/channel.ui  | 158 ++++++++++++++++++------------------------------
 src/main.cpp    |  72 +++++++++++++++-------
 8 files changed, 286 insertions(+), 215 deletions(-)

diff --git a/4uhv.pro b/4uhv.pro
index 071cb94..abd135a 100644
--- a/4uhv.pro
+++ b/4uhv.pro
@@ -1,17 +1,13 @@
-include (/usr/local/qtango/include/qtango6/qtango.pri)
+isEmpty(CUMBIA_ROOT) {
+    CUMBIA_ROOT=/usr/local/cumbia-libs
+}
+include($${CUMBIA_ROOT}/include/quapps/quapps.pri)
 
-TEMPLATE = app
-
-QT += 
-
-CONFIG +=
+# CONFIG += debug | release
 
 DEFINES += QT_NO_DEBUG_OUTPUT
 
-OBJECTS_DIR = obj
-
-# RESOURCES += 
-
+# RESOURCES +=
 
 SOURCES += src/main.cpp \
 		src/4uhv.cpp \
@@ -20,8 +16,67 @@ SOURCES += src/main.cpp \
 HEADERS += src/4uhv.h \
     src/channel.h
 
-FORMS    = src/4uhv.ui \
-    src/channel.ui
+# cuuimake runs uic
+#	FORMS    = src/4uhv.ui \
+#	    src/channel.ui
+#	
+
+# but we need to include ui_xxxx.h file amongst the headers
+# in order to be recompiled when it changes
+#
+HEADERS += \
+	ui_4uhv.h \
+	ui_channel.h
+
+# - ui: where to find cuuimake ui_*.h files
+#   since FORMS is not used
+# - src: where to find headers included by
+#   ui_*.h (e.g. for custom widget promoted
+#   from the Qt designer)
+#
+INCLUDEPATH += ui src
+
+TARGET = FourUHV-gui
+
+!wasm-emscripten {
+    TARGET   = bin/$${TARGET}
+} else {
+    TARGET = wasm/$${TARGET}
+}
+
+#
+# make install works if INSTALL_DIR is given to qmake
+#
+!isEmpty(INSTALL_DIR) {
+    wasm-emscripten {
+        inst.files = wasm/*
+    } else {
+        inst.files = $${TARGET}
+    }
+    inst.path = $${INSTALL_DIR}
+    INSTALLS += inst
+    message("-")
+    message("INSTALLATION")
+    message("       execute `make install` to install '$PROJECT_NAME$' under $${INSTALL_DIR} ")
+    message("-")
+} else {
+    message("-")
+    message("INSTALLATION")
+    message("       call qmake INSTALL_DIR=/usr/local/bin to install $PROJECT_NAME$ later with `make install` ")
+    message("-")
+}
+
+# unix:LIBS += -L. -lmylib
+
+# unix:INCLUDEPATH +=  . ../../src
+
+message("-")
+message("NOTE")
+message("You need to run cuuimake in order to build the project")
+message("-")
+message("        cuuimake --show-config to see cuuimake configuration options")
+message("        cuuimake --configure to configure cuuimake")
+message("        cuuimake -jN to execute cuuimake and then make -jN")
+message("        cuuimake --make to run cuuimake and then make")
+message("-")
 
-TARGET   = bin/FourUHV-gui
-QMAKE_POST_LINK = $(STRIP) $(TARGET)
diff --git a/src/4uhv.cpp b/src/4uhv.cpp
index 5b1c567..cc472fc 100644
--- a/src/4uhv.cpp
+++ b/src/4uhv.cpp
@@ -1,87 +1,95 @@
 #include "4uhv.h"
+// cumbia
+#include <cumbiapool.h>
+#include <cuserviceprovider.h>
+#include <cumacros.h>
+#include <quapps.h>
+// cumbia
+
 #include "ui_4uhv.h"
 #include "channel.h"
 #include <tango.h>
 #include <QMessageBox>
 #include <QGridLayout>
-#include <TPushButton>
+// #include <TPushButton>
+#include <qubutton.h>//	TPushButton is mapped to QuButton	//	 ## added by qumbiaprojectwizard
 #include <QGroupBox>
 #include <QtDebug>
+#include <quwatcher.h>
 
-FourUHV::FourUHV(QWidget *parent) :
-    QWidget(parent),
-    ui(new Ui::FourUHV)
-{
-    ui->setupUi(this);
-    if(qApp->arguments().size() > 1) {
-        QString device = qApp->arguments().at(1);
-        QStringList parts;
-        std::vector<std::string> list;
-        Tango::Database *db = new Tango::Database();
-        Tango::DbData db_data;
-        db_data.push_back(Tango::DbDatum("power_supply"));
-        try{
-            db->get_property("vacuum", db_data);
-            db_data[0] >> list;
-            for(size_t i = 0; i < list.size(); i++)
-            {
-                parts = QString::fromStdString(list.at(i)).split(":");
-                if(parts.size() >= 3 && device == parts.first()) {
-                    for(int ch = 1; ch < parts.size(); ch++)
-                        if(parts[ch].compare("none", Qt::CaseInsensitive) != 0)
-                            m_chSensorMap[ch] = parts[ch];
-               }
-            }
-        }
-        catch(Tango::DevFailed& e)
-        {
-            perr("4uhv: error getting power_supply property from \"vacuum\" object");
-            QMessageBox::critical(this, "Error getting property from database",
-                                  "4uhv: error getting power_supply property from \"vacuum\" object");
-        }
-    }
-    int r = 0, c = 0;
-    QGridLayout *glo = new QGridLayout(ui->contentsWidget);
-    foreach(int ch, m_chSensorMap.keys()) {
-        Channel *channel = new Channel(ui->contentsWidget);
-        channel->findChild<QLabel*>("lChannel")->setText(QString("Channel %1 - %2")
-                                                         .arg(ch).arg(m_chSensorMap[ch].section('/', -1, -1)));
-        foreach(QWidget *w, channel->findChildren<QWidget *>()) {
-            if(w->metaObject()->indexOfProperty("source") > -1)
-                w->setProperty("source",  QString(w->property("point").toString()).arg(ch));
-            if(w->metaObject()->indexOfProperty("targets") > -1)
-                w->setProperty("targets", QString(w->property("point").toString()).arg(ch));
-        }
-        //////////////////////////////////////////////////////////////
-        //
-        // hide Threshold settings for now
-        channel->findChild<QGroupBox *>("gbHighTh")->setHidden(true);
-        channel->findChild<QGroupBox *>("gbLowTh")->setHidden(true);
-        //
-        ///////////////////////////////////////////////////////////////
-        glo->addWidget(channel, r, c % 2, 1, 1);
-        if(c == 1) {
-            c = 0; r++;
-        }
-        else
-            c++;
+FourUHV::FourUHV(CumbiaPool *cumbia_pool, QWidget *parent) :
+    QWidget(parent) {
 
+    // cumbia
+    CuModuleLoader mloader(cumbia_pool, &m_ctrl_factory_pool, &m_log_impl);
+    cu_pool = cumbia_pool;
+    ui = new Ui::FourUHV;
+    ui->setupUi(this, cu_pool, m_ctrl_factory_pool);
 
-        foreach(QGroupBox *gb, channel->findChild<QTabWidget *>()->widget(1)->findChildren<QGroupBox *>())
-            connect(gb->findChild<TPushButton *>(), SIGNAL(clicked()), this, SLOT(applyThresholdClicked()));
+    // mloader.modules() to get the list of loaded modules
+    // cumbia
+    if(qApp->arguments().size() > 1) {
+        m_dev = qApp->arguments().at(1);
+        Qu1TWatcher *spw = new Qu1TWatcher(this, cu_pool, m_ctrl_factory_pool);
+        connect(spw, SIGNAL(newData(const CuData&)), this, SLOT(onPsListReady(const CuData& )));
+        spw->setSource("tango://#vacuum#power_supply");
     }
-
 }
 
-FourUHV::~FourUHV()
-{
+FourUHV::~FourUHV() {
     delete ui;
 }
 
 void FourUHV::applyThresholdClicked()
 {
-    QString onam = sender()->objectName();
-    if(sender()->objectName().startsWith("tpbApplyThHigh"))
+    const QString& onam = sender()->objectName();
+    if(onam.startsWith("tpbApplyThHigh"))
         findChild<QGroupBox *>("");
 }
 
+void FourUHV::onPsListReady(const CuData &da) {
+    if(da.B("err")) {
+    }
+    else {
+        std::vector<std::string> list = da["value"].toStringVector();
+        for(size_t i = 0; i < list.size(); i++) {
+            QStringList parts = QString::fromStdString(list.at(i)).split(":");
+            if(parts.size() >= 3 && m_dev == parts.first()) {
+                for(int ch = 1; ch < parts.size(); ch++)
+                    if(parts[ch].compare("none", Qt::CaseInsensitive) != 0)
+                        m_chSensorMap[ch] = parts[ch];
+            }
+        }
+
+        int r = 0, c = 0;
+        QGridLayout *glo = new QGridLayout(ui->contentsWidget);
+        foreach(int ch, m_chSensorMap.keys()) {
+            Channel *channel = new Channel(ui->contentsWidget, cu_pool, m_ctrl_factory_pool);
+            channel->findChild<QLabel*>("lChannel")->setText(QString("Channel %1 - %2")
+                                                             .arg(ch).arg(m_chSensorMap[ch].section('/', -1, -1)));
+            foreach(QWidget *w, channel->findChildren<QWidget *>()) {
+                if(w->metaObject()->indexOfProperty("source") > -1) {
+                    const QString& s = w->property("point").toString();
+                    if(s.contains("%1")) w->setProperty("source",  QString(s).arg(ch));
+                }
+                if(w->metaObject()->indexOfProperty("target") > -1) {
+                    const QString& t = w->property("point").toString();
+                    if(t.contains("%1"))  w->setProperty("target", QString(t).arg(ch));
+                }
+            }
+            channel->findChild<QGroupBox *>("gbHighTh")->setHidden(true);
+            channel->findChild<QGroupBox *>("gbLowTh")->setHidden(true);
+            glo->addWidget(channel, r, c % 2, 1, 1);
+            if(c == 1) {
+                c = 0; r++;
+            }
+            else
+                c++;
+
+            foreach(QGroupBox *gb, channel->findChild<QTabWidget *>()->widget(1)->findChildren<QGroupBox *>())
+                connect(gb->findChild<QuButton *>(), SIGNAL(clicked()), this, SLOT(applyThresholdClicked()));
+        }
+    }
+}
+
+
diff --git a/src/4uhv.h b/src/4uhv.h
index 61de8bd..e3dbf8b 100644
--- a/src/4uhv.h
+++ b/src/4uhv.h
@@ -1,6 +1,13 @@
 #ifndef FourUHV_H
 #define FourUHV_H
 
+// cumbia
+#include <qulogimpl.h>
+#include <cucontrolsfactorypool.h>
+class CumbiaPool;
+class CuData;
+// cumbia
+
 #include <QWidget>
 #include <QMap>
 
@@ -13,7 +20,7 @@ class FourUHV : public QWidget
     Q_OBJECT
 
 public:
-    explicit FourUHV(QWidget *parent = 0);
+    explicit FourUHV(CumbiaPool *cu_p, QWidget *parent = 0);
     ~FourUHV();
 
 private:
@@ -23,6 +30,16 @@ private:
 
 private slots:
     void applyThresholdClicked();
+    void onPsListReady(const CuData& da);
+
+private:
+// cumbia
+    CumbiaPool *cu_pool;
+    QuLogImpl m_log_impl;
+    CuControlsFactoryPool m_ctrl_factory_pool;
+    // cumbia
+    QString m_dev;
 };
 
 #endif // FourUHV_H
+
diff --git a/src/4uhv.ui b/src/4uhv.ui
index 8e11cef..5006e43 100644
--- a/src/4uhv.ui
+++ b/src/4uhv.ui
@@ -49,14 +49,14 @@
     </widget>
    </item>
    <item row="2" column="0">
-    <widget class="TLabel" name="tLabel_11">
+    <widget class="QuLabel" name="tLabel_11">
      <property name="source">
       <string>$1/state</string>
      </property>
     </widget>
    </item>
    <item row="2" column="1">
-    <widget class="TLabel" name="tLabel_12">
+    <widget class="QuLabel" name="tLabel_12">
      <property name="source">
       <string>$1/status</string>
      </property>
@@ -67,14 +67,9 @@
  <layoutdefault spacing="6" margin="11"/>
  <customwidgets>
   <customwidget>
-   <class>TLabel</class>
-   <extends>ELabel</extends>
-   <header>TLabel</header>
-  </customwidget>
-  <customwidget>
-   <class>ELabel</class>
+   <class>QuLabel</class>
    <extends>QLabel</extends>
-   <header>elabel.h</header>
+   <header>qulabel.h</header>
   </customwidget>
  </customwidgets>
  <resources/>
diff --git a/src/channel.cpp b/src/channel.cpp
index 742dfe4..5dd4385 100644
--- a/src/channel.cpp
+++ b/src/channel.cpp
@@ -1,14 +1,14 @@
 #include "channel.h"
 #include "ui_channel.h"
 
-Channel::Channel(QWidget *parent) :
-    QWidget(parent),
-    ui(new Ui::Channel)
-{
-    ui->setupUi(this);
+Channel::Channel(QWidget *parent, CumbiaPool *cu_p, const CuControlsFactoryPool &fp) :
+    QWidget(parent) {
+    ui = new Ui::Channel;
+    ui->setupUi(this, cu_p, fp);
 }
 
 Channel::~Channel()
 {
     delete ui;
 }
+
diff --git a/src/channel.h b/src/channel.h
index 2602fde..a514aff 100644
--- a/src/channel.h
+++ b/src/channel.h
@@ -2,6 +2,9 @@
 #define CHANNEL_H
 
 #include <QWidget>
+#include <cucontrolsfactorypool.h>
+
+class CumbiaPool;
 
 namespace Ui {
 class Channel;
@@ -12,11 +15,14 @@ class Channel : public QWidget
     Q_OBJECT
 
 public:
-    explicit Channel(QWidget *parent = 0);
+    explicit Channel(QWidget *parent, CumbiaPool *cu_p, const CuControlsFactoryPool& fp);
     ~Channel();
 
 private:
     Ui::Channel *ui;
+    CumbiaPool *cu_pool;
+    CuControlsFactoryPool m_ctrl_fpool;
 };
 
 #endif // CHANNEL_H
+
diff --git a/src/channel.ui b/src/channel.ui
index 3ff94e4..8a94cc3 100644
--- a/src/channel.ui
+++ b/src/channel.ui
@@ -7,7 +7,7 @@
     <x>0</x>
     <y>0</y>
     <width>375</width>
-    <height>411</height>
+    <height>416</height>
    </rect>
   </property>
   <property name="windowTitle">
@@ -41,7 +41,7 @@
       </attribute>
       <layout class="QGridLayout" name="gridLayout_4">
        <item row="4" column="0" colspan="2">
-        <widget class="TTable" name="tTable">
+        <widget class="QuTable" name="tTable">
          <property name="numRows">
           <number>5</number>
          </property>
@@ -82,7 +82,7 @@
         </widget>
        </item>
        <item row="3" column="1">
-        <widget class="TPushButton" name="tPushButton_2">
+        <widget class="QuButton" name="tPushButton_2">
          <property name="text">
           <string>Off</string>
          </property>
@@ -95,7 +95,7 @@
         </widget>
        </item>
        <item row="3" column="0">
-        <widget class="TPushButton" name="tPushButton">
+        <widget class="QuButton" name="tPushButton">
          <property name="text">
           <string>On</string>
          </property>
@@ -118,10 +118,7 @@
         </widget>
        </item>
        <item row="2" column="1">
-        <widget class="TLabel" name="tLabel_3">
-         <property name="source">
-          <string/>
-         </property>
+        <widget class="QuLabel" name="tLabel_3">
          <property name="point" stdset="0">
           <string>$1/Current%1</string>
          </property>
@@ -138,17 +135,14 @@
         </widget>
        </item>
        <item row="1" column="1">
-        <widget class="TLabel" name="tLabel_2">
-         <property name="source">
-          <string/>
-         </property>
+        <widget class="QuLabel" name="tLabel_2">
          <property name="point" stdset="0">
           <string>$1/Pressure%1</string>
          </property>
         </widget>
        </item>
        <item row="0" column="1">
-        <widget class="TLabel" name="tLabel">
+        <widget class="QuLabel" name="tLabel">
          <property name="point" stdset="0">
           <string>$1/Voltage%1</string>
          </property>
@@ -161,21 +155,8 @@
        <string>Expert</string>
       </attribute>
       <layout class="QGridLayout" name="gridLayout_5">
-       <item row="5" column="0">
-        <spacer name="spacer">
-         <property name="orientation">
-          <enum>Qt::Vertical</enum>
-         </property>
-         <property name="sizeHint" stdset="0">
-          <size>
-           <width>20</width>
-           <height>65</height>
-          </size>
-         </property>
-        </spacer>
-       </item>
        <item row="3" column="2">
-        <widget class="TPushButton" name="tPushButton_7">
+        <widget class="QuButton" name="tPushButton_7">
          <property name="text">
           <string>Step</string>
          </property>
@@ -184,18 +165,28 @@
          </property>
         </widget>
        </item>
-       <item row="3" column="1">
-        <widget class="TPushButton" name="tPushButton_6">
+       <item row="2" column="1">
+        <widget class="QuButton" name="tPushButton_4">
          <property name="text">
-          <string>Fix</string>
+          <string>Fix5000</string>
          </property>
          <property name="point" stdset="0">
-          <string>$1/Fixed%1(true)</string>
+          <string>$1/VTarget%1(5)</string>
+         </property>
+        </widget>
+       </item>
+       <item row="4" column="2">
+        <widget class="QuButton" name="tPushButton_9">
+         <property name="text">
+          <string>Start</string>
+         </property>
+         <property name="point" stdset="0">
+          <string>$1/Protect%1(false)</string>
          </property>
         </widget>
        </item>
        <item row="2" column="2">
-        <widget class="TPushButton" name="tPushButton_5">
+        <widget class="QuButton" name="tPushButton_5">
          <property name="text">
           <string>Fix7000</string>
          </property>
@@ -204,13 +195,13 @@
          </property>
         </widget>
        </item>
-       <item row="2" column="0">
-        <widget class="TPushButton" name="tPushButton_3">
+       <item row="4" column="1">
+        <widget class="QuButton" name="tPushButton_8">
          <property name="text">
-          <string>Fix3000</string>
+          <string>Protect</string>
          </property>
          <property name="point" stdset="0">
-          <string>$1/VTarget%1(3)</string>
+          <string>$1/Protect%1(true)</string>
          </property>
         </widget>
        </item>
@@ -237,55 +228,28 @@
            </widget>
           </item>
           <item row="0" column="1">
-           <widget class="TLabel" name="tLabel_8">
-            <property name="source">
-             <string/>
-            </property>
-           </widget>
+           <widget class="QuLabel" name="tLabel_8"/>
           </item>
           <item row="1" column="0">
-           <widget class="TLineEdit" name="LowThr1"/>
+           <widget class="QuLineEdit" name="LowThr1"/>
           </item>
           <item row="1" column="1">
-           <widget class="TPushButton" name="tpbApplyLow">
+           <widget class="QuButton" name="tpbApplyLow">
             <property name="text">
              <string>Apply</string>
             </property>
-            <property name="targets">
-             <string>;</string>
-            </property>
            </widget>
           </item>
          </layout>
         </widget>
        </item>
-       <item row="2" column="1">
-        <widget class="TPushButton" name="tPushButton_4">
-         <property name="text">
-          <string>Fix5000</string>
-         </property>
-         <property name="point" stdset="0">
-          <string>$1/VTarget%1(5)</string>
-         </property>
-        </widget>
-       </item>
-       <item row="4" column="2">
-        <widget class="TPushButton" name="tPushButton_9">
-         <property name="text">
-          <string>Start</string>
-         </property>
-         <property name="point" stdset="0">
-          <string>$1/Protect%1(false)</string>
-         </property>
-        </widget>
-       </item>
-       <item row="4" column="1">
-        <widget class="TPushButton" name="tPushButton_8">
+       <item row="3" column="1">
+        <widget class="QuButton" name="tPushButton_6">
          <property name="text">
-          <string>Protect</string>
+          <string>Fix</string>
          </property>
          <property name="point" stdset="0">
-          <string>$1/Protect%1(true)</string>
+          <string>$1/Fixed%1(true)</string>
          </property>
         </widget>
        </item>
@@ -312,24 +276,17 @@
            </widget>
           </item>
           <item row="0" column="1">
-           <widget class="TLabel" name="tLabel_7">
-            <property name="source">
-             <string/>
-            </property>
-           </widget>
+           <widget class="QuLabel" name="tLabel_7"/>
           </item>
           <item row="1" column="0">
-           <widget class="TLineEdit" name="HighThr1"/>
+           <widget class="QuLineEdit" name="HighThr1"/>
           </item>
           <item row="1" column="1">
-           <widget class="TPushButton" name="tpbApplyHigh">
+           <widget class="QuButton" name="tpbApplyHigh">
             <property name="text">
              <string>Apply</string>
             </property>
-            <property name="targets">
-             <string/>
-            </property>
-            <property name="confirmNeeded">
+            <property name="confirmNeeded" stdset="0">
              <bool>true</bool>
             </property>
            </widget>
@@ -337,6 +294,16 @@
          </layout>
         </widget>
        </item>
+       <item row="2" column="0">
+        <widget class="QuButton" name="tPushButton_3">
+         <property name="text">
+          <string>Fix3000</string>
+         </property>
+         <property name="point" stdset="0">
+          <string>$1/VTarget%1(3)</string>
+         </property>
+        </widget>
+       </item>
       </layout>
      </widget>
     </widget>
@@ -345,35 +312,30 @@
  </widget>
  <customwidgets>
   <customwidget>
-   <class>TLabel</class>
-   <extends>ELabel</extends>
-   <header>TLabel</header>
+   <class>QuLabel</class>
+   <extends>QLabel</extends>
+   <header>qulabel.h</header>
   </customwidget>
   <customwidget>
-   <class>TTable</class>
+   <class>QuTable</class>
    <extends>EFlag</extends>
-   <header>TTable</header>
+   <header>qutable.h</header>
   </customwidget>
   <customwidget>
-   <class>TLineEdit</class>
-   <extends>QLineEdit</extends>
-   <header>TLineEdit</header>
-  </customwidget>
-  <customwidget>
-   <class>TPushButton</class>
+   <class>QuButton</class>
    <extends>QPushButton</extends>
-   <header>TPushButton</header>
-  </customwidget>
-  <customwidget>
-   <class>ELabel</class>
-   <extends>QLabel</extends>
-   <header>elabel.h</header>
+   <header>qubutton.h</header>
   </customwidget>
   <customwidget>
    <class>EFlag</class>
    <extends>QWidget</extends>
    <header>eflag.h</header>
   </customwidget>
+  <customwidget>
+   <class>QuLineEdit</class>
+   <extends>QLineEdit</extends>
+   <header>qulineedit.h</header>
+  </customwidget>
  </customwidgets>
  <resources/>
  <connections/>
diff --git a/src/main.cpp b/src/main.cpp
index 280071c..9b84a43 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -1,9 +1,18 @@
 #include "4uhv.h"
-#include <TApplication>
-#include <tutil.h>
+// #include <TApplication>
+// cumbia
+#include <cumbiapool.h>
+#include <cuthreadfactoryimpl.h>
+#include <qthreadseventbridgefactory.h>
+// cumbia
+
+#include <quapplication.h>//	TApplication is mapped into QuApplication. DBus connection is provided by the cumbia dbus plugin	//	 ## added by qumbiaprojectwizard
+// #include <tutil.h>
+// no cumbia include replacement found for tutil.h
 #include <X11/Xlib.h>
 #include <QX11Info>
-#include <elettracolors.h>
+// #include <elettracolors.h>
+// no cumbia include replacement found for elettracolors.h
 
 #define CVSVERSION "$Name:  $"
 
@@ -11,31 +20,50 @@
 int main(int argc, char *argv[])
 {
 
-    TApplication a( argc, argv );
-    a.setOrganizationName("-");
-    a.setApplicationName("-");
+//     TApplication qu_app( argc, argv );
+    QuApplication qu_app( argc, argv );//	TApplication is mapped into QuApplication. DBus connection is provided by cumbia dbus plugin	//	 ## added by qumbiaprojectwizard
+    qu_app.setOrganizationName("-");
+    qu_app.setApplicationName("-");
     QString version(CVSVERSION);
-    a.setApplicationVersion(version);
-    a.setProperty("author", "Giacomo");
-    a.setProperty("mail", "giacomo.strangolino@elettra.eu");
-    a.setProperty("phone", "0403758073");
-    a.setProperty("office", "T2Pt025");
-    a.setProperty("hwReferent", "-"); /* name of the referent that provides the device server */
+    qu_app.setApplicationVersion(version);
+    qu_app.setProperty("author", "Giacomo");
+    qu_app.setProperty("mail", "giacomo.strangolino@elettra.eu");
+    qu_app.setProperty("phone", "0403758073");
+    qu_app.setProperty("office", "T2Pt025");
+    qu_app.setProperty("hwReferent", "-"); /* name of the referent that provides the device server */
     
-    TUtil::instance()->setLoggingTarget(argv[0]);
+//     TUtil::instance()->setLoggingTarget(argv[0]);
+//	QTango TUtil:: class is not present in cumbia	//	 ## added by qumbiaprojectwizard
+
+    CumbiaPool *cu_p = new CumbiaPool();
+
 
 
-    FourUHV w;
-    if(w.property("epalette").isValid())
-    	a.setPalette(EPalette(w.property("epalette").toString()));
-    if (a.arguments().size() > 1)
-        w.setWindowTitle(a.arguments()[1].split('/').last());
-    w.show();
 
-    /* register to window manager */
+    FourUHV *w = new FourUHV(cu_p, 0);
+//     if(w->property("epalette").isValid())
+//	EPalette is not currently available in cumbia	//	 ## added by qumbiaprojectwizard
+//     	qu_app.setPalette(EPalette(w->property("epalette").toString()));
+//	EPalette is not currently available in cumbia	//	 ## added by qumbiaprojectwizard
+    if (qu_app.arguments().size() > 1)
+        w->setWindowTitle(qu_app.arguments()[1].split('/').last());
+    w->show();
+
     Display *disp = QX11Info::display();
-    Window root_win = (Window) w.winId();
+    Window root_win = (Window) w->winId();
     XSetCommand(disp, root_win, argv, argc);
 
-    return a.exec();
+// exec application loop
+    int ret = qu_app.exec();
+    // delete resources and return
+    delete w;
+
+    for(std::string n : cu_p->names())
+        if(cu_p->get(n))
+            delete cu_p->get(n);
+
+    return ret;
+
+
 }
+
-- 
GitLab