tabmaroc.cpp 3.76 KB
Newer Older
Alexander Steffens's avatar
Alexander Steffens committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128
#include <QDebug>
#include <QCloseEvent>
#include <QSettings>

#include "tabmaroc.h"
#include "maroc_def.h"
#include "maroc.h"
#include "messages.h"





TabMaroc::TabMaroc(QWidget *parent, int DeviceNo, QObject *part, int MarocNo, tabclkrst *clkrst) :
    QWidget(parent)
{
    _Init               = true;
    _DeviceNo           = DeviceNo;
    _QMaroc             = (QMaroc *)part;
    _ConcentratorAvail  = MarocNo;
    _ClkRst             = clkrst;


    if (_ConcentratorAvail>=0) {
        connect(this,      SIGNAL(OMLockTabs(int)), parent,    SLOT(IMLockTabs(int)));
        connect(this,      SIGNAL(OMUnlockTabs()),  parent,    SLOT(IMUnlockTabs()));
    }

    if (_ConcentratorAvail>=0)
            qDebug(qPrintable(QString("+------- Maroc (%1) ------+").arg(MarocNo)));
    else    qDebug("+------- Maroc -----------+");
    qDebug("Creating Tab...");

    _TopLayout          = new QGridLayout(this);
    setLayout(_TopLayout);

    _MTab               = new QTabWidget(this);
    _MTab->setTabPosition(QTabWidget::West);

    _TopLayout->addWidget(_MTab,0,0);

    qDebug("@ adding Info Tab...");
    _MTInfo = new mtInfo(this,_QMaroc);
    _MTab->addTab(_MTInfo,"Info");

    qDebug("@ adding Trigger Tab...");
    _MTTrigger = new mtTrigger(this,_QMaroc);
    _MTab->addTab(_MTTrigger,"Trigger");

    qDebug("@ adding Setup Tab...");
    _MTSetup = new mtSetup(this,_QMaroc);
    _MTab->addTab(_MTSetup,"Setup");

    qDebug("@ adding DAQ Tab...");
    _MTDaq = new mtDaq(this,_QMaroc);
    _MTab->addTab(_MTDaq,"DAQ");

    connect(this,      SIGNAL(OSetValue(int,int,QVariant)),     _QMaroc,    SLOT(ISetValue(int,int,QVariant)));
    connect(this,      SIGNAL(OGetValue(int,int)),              _QMaroc,    SLOT(IGetValue(int,int)));
    connect(_QMaroc,   SIGNAL(OSubSetValue(int,int,QVariant)),  this,       SLOT(ISubSetValue(int,int,QVariant)));

    connect(_MTab,     SIGNAL(currentChanged(int)),             this,       SLOT(TabChanged(int)));

    int LastTab = _QMaroc->IGetValue(mM_LastTab,0).toInt();
    if ((LastTab>=0)&&(LastTab<_MTab->count()))
        _MTab->setCurrentIndex(LastTab);

//    qDebug("+--------- Maroc ---<<<---+");
    _Init = false;
}



TabMaroc::~TabMaroc()
{
}

void TabMaroc::ILockTabs(int tab){
    _MTab->setTabEnabled(tab, false);
    if (_ConcentratorAvail>=0)
        emit OMLockTabs(_ConcentratorAvail);
}

void TabMaroc::IUnlockTabs() {
    if (_ConcentratorAvail>=0) emit OMUnlockTabs();
    for (int i=0; i<_MTab->count(); i++) {
        _MTab->setTabEnabled(i, true);
    }
}



void TabMaroc::TabChanged(int index)
{
    if (_Init) return;
    emit OSetValue(mM_LastTab,0,index);
}




void TabMaroc::ISubSetValue(int id, int idx, QVariant val)
{
    Q_UNUSED(idx);
    Q_UNUSED(id);
    Q_UNUSED(val);
    switch (id)
    {
        case mM_SetTab:         _MTab->setCurrentIndex(val.toInt()); break;

/*
//        case mM_BoardId:        ui->tlBoardID->setText("0x"+QString::number(val.toInt(),16)); break;
//        case mM_BoardRev:       ui->tlBoardRev->setText("0x"+QString::number(val.toInt(),16)); break;
//        case mM_FirmwareId:     ui->tlFirmwareID->setText("0x"+QString::number(val.toInt(),16)); break;
//        case mM_FirmwareRev:    ui->tlFirmwareRev->setText("0x"+QString::number(val.toInt(),16)); break;

        case mM_Serial:         if (val.toInt()==SERIAL_UNKNOWN)
                                        ui->tlSerialNo->setText("No Serial");
                                else    ui->tlSerialNo->setText("0x"+QString::number(val.toInt(),16));
                                break;
*/
//        default:                qWarning(qPrintable(QString("TabMaroc: ISetValue ID %1  out of range !").arg(id)));  break;
    }
}