Commit e94c919b authored by Claudio Scafuri's avatar Claudio Scafuri 💬
Browse files

Reader

parent 268dd8e8
#0 Temperature Fault
#1 DC Under-Voltage
#2 Input Over-Current
#3 Over-Power
#4 Earth Leakage
#5 Earth Fuse
#6 Regulation Fault
#7 AUX2 Fault (check!!)
#8 DCCT Fault
#9 DC-Fuse
#10 Crowbar
#11 Quench
#12 Parallel link fault
#13 Output Over-Current
#14 Output Over-Voltage
#15 Reserved
#16 External Interlock #1
#17 External Interlock #2
#18 External Interlock #3
#19 External Interlock #4
#20 Dissipative Unit Over-Temperature
#21 Dissipative Unit Error
#22 Reserved
#23 Reserved
#24 Units in parallel have different fw version
#25 Units in parallel have different models
#26 Units in parallel have different ratings
#27 Reserved
#28 Reserved
#29 Reserved
#30 Reserved
#31 Reserved
bitmask: 0;1;2;3;4;5;6;7;8;9;10;11;12;13;14;16;17;18;19;20;21;24;25;26
truestrings: Overtemperature;DC-Link Under Voltage;Overcurrent;Overpower; Earth Leakage;Earth Fuse;Regulation Fault;AUX2 Fault;DCCT Error;DC Fuse;Crowbar;Quench;Parallel link fault;Output Overcurrent;Output Overvoltage;
Interlock #1; Interlock #2; Interlock #3; Interlock #4;Diss. Unit over Temp/Power; Diss. Unit not OK; Wrong version;diff. models; Wrong ratings
......@@ -4,23 +4,26 @@ isEmpty(CUMBIA_ROOT) {
include($${CUMBIA_ROOT}/include/quapps/quapps.pri)
# CONFIG += debug | release
DEFINES += QT_NO_DEBUG_OUTPUT
CONFIG += release
#DEFINES += QT_NO_DEBUG_OUTPUT
# RESOURCES +=
SOURCES += src/main.cpp \
src/ngps.cpp
src/ngps.cpp \
src/dialogstack.cpp \
src/moduleslistener.cpp
HEADERS += src/ngps.h
HEADERS += src/ngps.h \
src/dialogstack.h \
src/moduleslistener.h
# cuuimake runs uic
# FORMS = src/ngps.ui
# FORMS = src/ngps.ui src/dialogstack.ui
# but we need to include ui_xxxx.h file amongst the headers
# in order to be recompiled when it changes
#
HEADERS += \
ui/ui_ngps.h
HEADERS += ui/ui_ngps.h ui/ui_dialogstack.h
# - ui: where to find cuuimake ui_*.h files
# since FORMS is not used
......
#include "dialogstack.h"
#include "ui_dialogstack.h"
// cumbia
#include <cumbiapool.h>
#include <cumbiatango.h>
#include <cucontrolsfactorypool.h>
#include <cutcontrolsreader.h>
#include <cutcontrolswriter.h>
#include <cutango-world.h>
#include <cuthreadfactoryimpl.h>
#include <cuserviceprovider.h>
#include <qthreadseventbridgefactory.h>
#include <cumacros.h>
#include <cumbiapool.h>
#include <cuserviceprovider.h>
#include <cumacros.h>
#include <quapps.h>
#include <cutreader.h>
// cumbia
DialogStack::DialogStack(CumbiaTango* cuta,CumbiaPool *cumbia_pool, CuControlsFactoryPool& m_ctrl_factory_pool, QWidget *parent) :
QDialog(parent)
{
// cumbia
//user interface
ui = new Ui::DialogStack();
ui->setupUi(this, cumbia_pool, m_ctrl_factory_pool);
setWindowTitle("Modules $1");
mylistener = new ModulesListener(); //TODO register widgets at build or later?
mylistener->registerModulesWidgets(ui->quTable_module1, ui->quTable_module2, ui->quTable_module3, ui->quTable_module4);
treader = new CuTControlsReader(cuta, mylistener);
CuData conf("refresh_mode", CuTReader::PolledRefresh);
conf["period"] = 3000; // millistreader->setOptions(conf);
treader->setOptions(conf);
treader->setSource("$1/modulesFault");
QString sname=treader->source();
sname = sname.remove("\/modulesFault");
setWindowTitle("Modules of " + sname);
// cumbia
}
DialogStack::~DialogStack()
{
delete mylistener;
delete treader;
delete ui;
}
void DialogStack::changeEvent(QEvent *e)
{
QDialog::changeEvent(e);
switch (e->type()) {
case QEvent::LanguageChange:
ui->retranslateUi(this);
break;
default:
break;
}
}
void DialogStack::closeEvent(QCloseEvent* e){
treader->unsetSource();
}
void DialogStack::showEvent(QShowEvent* e){
treader->setSource("$1/modulesFault");
}
#ifndef DialogStack_H
#define DialogStack_H
#include <QDialog>
#include "moduleslistener.h"
// cumbia
#include <qulogimpl.h>
#include <cucontrolsfactorypool.h>
#include <cutcontrolsreader.h>
#include <cudatalistener.h>
class CumbiaPool;
// cumbia
namespace Ui{
class DialogStack;
}
class DialogStack : public QDialog
{
Q_OBJECT
public:
explicit DialogStack(CumbiaTango* cuta,CumbiaPool *cumbia_pool, CuControlsFactoryPool& m_ctrl_factory_pool, QWidget *parent=0);
~DialogStack();
protected:
void changeEvent(QEvent *e);
CuTControlsReader* treader;
ModulesListener *mylistener;
void closeEvent(QCloseEvent* e);
void showEvent(QShowEvent* e);
private:
Ui::DialogStack *ui;
};
#endif // DialogStack_H
This diff is collapsed.
#include "moduleslistener.h"
//cumbia
#include <cumbiapool.h>
#include <cumbiatango.h>
#include <cucontrolsfactorypool.h>
#include <cutcontrolsreader.h>
#include <cutcontrolswriter.h>
#include <cutango-world.h>
#include <cuthreadfactoryimpl.h>
#include <cuserviceprovider.h>
#include <qthreadseventbridgefactory.h>
#include <cumacros.h>
#include <cumbiapool.h>
#include <cuserviceprovider.h>
#include <cumacros.h>
#include <quapps.h>
#include <cutreader.h>
ModulesListener::ModulesListener():dim_x(0),dim_y(0),first_run(true)
{
module1=nullptr;
module2=nullptr;
module3=nullptr;
module3=nullptr;
}
void ModulesListener::onUpdate(const CuData& data)
{
const CuVariant v = data.value("value");
CuMatrix<Tango::DevBoolean> bm = v.toMatrix<Tango::DevBoolean>();
const std::vector<bool> bv = bm.data();
if(first_run){
//data.print();
dim_x = bm.nrows();
dim_y = bm.ncols();
m1data.clear();
m2data.clear();
m3data.clear();
m4data.clear();
//std::cout << "dim_x=" << dim_x << " dim_y=" << dim_y << " size=" << bv.size() << std::endl;
first_run = false;
}
// spread out the received data for the 4 QuTable Widgtes
unsigned int col=0; //here col in the module numebr
unsigned int row=0; //here row is the place in the module column
m1data.clear();
for (row=0; row < dim_x; row++){ //column 0 m1
m1data << bv[index(row,col)];
}
if(module1){
module1->setValue(m1data,true);
}
col = 1;
m2data.clear();
for (row=0; row < dim_x; row++){ //column 0 m1
m2data << bv[index(row,col)];
}
if(module2){
module2->setValue(m2data,true);
}
col = 2;
m3data.clear();
for (row=0; row < dim_x; row++){ //column 0 m1
m3data << bv[index(row,col)];
}
if(module3){
module3->setValue(m3data,true);
}
col = 3;
m4data.clear();
for (row=0; row < dim_x; row++){ //column 0 m1
m4data << bv[index(row,col)];
}
if(module4){
module4->setValue(m4data,true);
}
}
unsigned int ModulesListener::index(const unsigned int x, const unsigned int y)
{
return (y * dim_x + x);
}
void ModulesListener::registerModulesWidgets(QuTable* m1, QuTable* m2, QuTable* m3, QuTable* m4)
{
module1 = m1;
module2 = m2;
module3 = m3;
module4 = m4;
}
#ifndef MODULESLISTENER_H
#define MODULESLISTENER_H
#include <cudatalistener.h>
#include "qutable.h"
class ModulesListener : public CuDataListener
{
public:
ModulesListener();
void onUpdate(const CuData& data);
void registerModulesWidgets(QuTable*,QuTable*,QuTable*,QuTable*);
protected:
unsigned int dim_x;
unsigned int dim_y;
bool first_run;
//TODO: support variable number of modules, 1 to 8
QuTable* module1;
QuTable* module2;
QuTable* module3;
QuTable* module4;
QList<QVariant> m1data;
QList<QVariant> m2data;
QList<QVariant> m3data;
QList<QVariant> m4data;
unsigned int index(const unsigned int x, const unsigned int y);
};
#endif // MODULESLISTENER_H
#include "ngps.h"
#include "ui_ngps.h"
#include "dialogstack.h"
// cumbia
#include <cumbiapool.h>
#include <cumbiatango.h>
#include <cucontrolsfactorypool.h>
#include <cutcontrolsreader.h>
#include <cutcontrolswriter.h>
#include <cutango-world.h>
#include <cuthreadfactoryimpl.h>
#include <cuserviceprovider.h>
#include <qthreadseventbridgefactory.h>
#include <cumacros.h>
#include <cumbiapool.h>
#include <cuserviceprovider.h>
#include <cumacros.h>
#include <quapps.h>
#include <cutreader.h>
// cumbia
Ngps::Ngps(CumbiaPool *cumbia_pool, QWidget *parent) :
QWidget(parent)
QWidget(parent)
{
// cumbia
CuModuleLoader mloader(cumbia_pool, &m_ctrl_factory_pool, &m_log_impl);
cu_pool = cumbia_pool;
ui = new Ui::Ngps;
ui->setupUi(this, cu_pool, m_ctrl_factory_pool);
// mloader.modules() to get the list of loaded modules
// cumbia
dlogstack = nullptr;
// cumbia
CuModuleLoader mloader(cumbia_pool, &m_ctrl_factory_pool, &m_log_impl);
cu_pool = cumbia_pool;
cuta = new CumbiaTango(new CuThreadFactoryImpl(), new QThreadsEventBridgeFactory());
cu_pool->registerCumbiaImpl("tango", cuta);
m_ctrl_factory_pool.registerImpl("tango", CuTReaderFactory());
m_ctrl_factory_pool.registerImpl("tango", CuTWriterFactory());
CuTangoWorld tw;
m_ctrl_factory_pool.setSrcPatterns("tango", tw.srcPatterns());
cu_pool->setSrcPatterns("tango", tw.srcPatterns());
ui = new Ui::Ngps;
ui->setupUi(this, cu_pool, m_ctrl_factory_pool);
connect(ui->pushButtonModules, SIGNAL(clicked()), this , SLOT(show_dialogstack()));
// mloader.modules() to get the list of loaded modules
// cumbia
}
void Ngps::show_dialogstack(){
if (dlogstack == nullptr){
dlogstack = new DialogStack(cuta, cu_pool, m_ctrl_factory_pool, this);
dlogstack->show();
}
dlogstack->show();
}
Ngps::~Ngps()
{
delete ui;
if(dlogstack) delete dlogstack;
delete ui;
}
......@@ -2,10 +2,13 @@
#define Ngps_H
#include <QWidget>
#include "dialogstack.h"
// cumbia
#include <qulogimpl.h>
#include <cucontrolsfactorypool.h>
//#include <cutcontrolsreader.h>
#include <cudatalistener.h>
#include <cutcontrolsreader.h>
class CumbiaPool;
// cumbia
......@@ -21,14 +24,18 @@ public:
explicit Ngps(CumbiaPool *cu_p, QWidget *parent = 0);
~Ngps();
private:
Ui::Ngps *ui;
// cumbia
CumbiaPool *cu_pool;
QuLogImpl m_log_impl;
CuControlsFactoryPool m_ctrl_factory_pool;
CumbiaTango* cuta;
// cumbia
DialogStack *dlogstack;
private slots:
void show_dialogstack();
};
#endif // Ngps_H
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment