MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
{
    CurvesPlotWidget *curvesPlotWidget = new CurvesPlotWidget();
    CpuPlot *cpuPlot = new CpuPlot();
    OscilloscopeWidget *oscilloscopeWidget = new OscilloscopeWidget();
    SamplingThread *samplingThread = new SamplingThread();
    samplingThread->setFrequency(oscilloscopeWidget->frequency());
    samplingThread->setAmplitude(oscilloscopeWidget->amplitude());
    samplingThread->setInterval(oscilloscopeWidget->signalInterval());
    connect(oscilloscopeWidget, SIGNAL(frequencyChanged(double)),
        samplingThread, SLOT(setFrequency(double)));
    connect(oscilloscopeWidget, SIGNAL(amplitudeChanged(double)),
        samplingThread, SLOT(setAmplitude(double)));
    connect(oscilloscopeWidget, SIGNAL(signalIntervalChanged(double)),
        samplingThread, SLOT(setInterval(double)));
    samplingThread->start();
    oscilloscopeWidget->start();
    QWidget *cockpitGrid = new CockpitGrid();

    WidgetContainerOverview *wc = new WidgetContainerOverview();
    wc->addWidget(curvesPlotWidget);
    wc->addWidget(cpuPlot);
    wc->addWidget(oscilloscopeWidget);
    wc->addWidget(cockpitGrid);
    wc->addWidget(new CpuPlot());
    //wc->addWidget(new CurvesPlotWidget());


    this->setCentralWidget(wc);
    this->setWindowFlags(Qt::FramelessWindowHint);
}
Esempio n. 2
0
int main (int argc, char *argv[])
{
    SamplingThread samplingThread;
    QApplication a(argc, argv);
    MainWindow w;

    w.show();
    samplingThread.start();


    return a.exec();
}
void MainWindow::on_startButton_clicked()
{

    /* Variable Declarations */
    int BoardNum = 0;
    int ULStat = 0;
    int LowChan = 0;
    int HighChan = 2;
    int Gain = BIP10VOLTS;
    short Status = RUNNING;
    long CurCount;
    long CurIndex;
    long Rate = 100;
    Count = (HighChan+1)*1000;
    channels = HighChan-LowChan+1;
    unsigned Options;
    float revision = (float)CURRENTREVNUM;
    BOOL HighResAD = FALSE;
    int ADRes;
    SamplingThread  samplingThread;
    samplingThread.setInterval( 0.1 );

   /* Declare Revision level of the Universal Library */
    ULStat = cbDeclareRevision(&revision);

    /* Initiate error handling
        Parameters:
            PRINTALL :all warnings and errors encountered will be printed
            DONTSTOP :program will continue even if error occurs.
                     Note that STOPALL and STOPFATAL are only effective in
                     Windows applications, not Console applications.
   */
    cbErrHandling (PRINTALL, DONTSTOP);

    /* Get the resolution of A/D */
    cbGetConfig(BOARDINFO, BoardNum, 0, BIADRES, &ADRes);

    /* check If the resolution of A/D is higher than 16 bit.
       If it is, then the A/D is high resolution. */
    if(ADRes > 16)
        HighResAD = TRUE;

    /*  set aside memory to hold data */
    if(HighResAD)
    {
        MemHandle = cbWinBufAlloc32(Count);
        ADData32 = (DWORD*) MemHandle;
    }
    else
    {
        MemHandle = cbWinBufAlloc(Count);
        ADData = (WORD*) MemHandle;
    }

    /* Make sure it is a valid pointer */
    if (!MemHandle)
        exit(1); /* out of memory */
    /* set up the display screen */
    /* Demonstration of cbAInScan() */
    /* Data are being collected in the BACKGROUND, CONTINUOUSLY */

    /* Collect the values with cbAInScan() in BACKGROUND mode, CONTINUOUSLY
        Parameters:
             BoardNum    :the number used by CB.CFG to describe this board
             LowChan     :low channel of the scan
             HighChan    :high channel of the scan
             Count       :the total number of A/D samples to collect
             Rate        :sample rate in samples per second
             Gain        :the gain for the board
             ADData[]    :the array for the collected data values
             Options     :data collection options */
    Options = CONVERTDATA + BACKGROUND + CONTINUOUS;
    ULStat = cbAInScan (BoardNum, LowChan, HighChan, Count, &Rate, Gain, MemHandle, Options);

    samplingThread.start();
    d_plot->start();

    /* Your program could be doing something useful here while data are collected */

    /* During the BACKGROUND operation, check the status */
    //float EngUnits;
    //QwtSystemClock checktimer;
    //checktimer.start();
    //StoredLocation=0;
    //float v;
    while (Status==RUNNING)
    {
        qApp->processEvents();
//        // Check the status of the current background operation
//        /*Parameters:
//            BoardNum  :the number used by CB.CFG to describe this board
//            Status    :current status of the operation (IDLE or RUNNING)
//            CurCount  :current number of samples collected
//            CurIndex  :index to the last data value transferred
//            FunctionType: A/D operation (AIFUNCTIOM)*/
//        ULStat = cbGetStatus (BoardNum, &Status, &CurCount, &CurIndex,AIFUNCTION);

//        if (CurIndex==StoredLocation+1)
//        {
//            double elapsed=checktimer.elapsed();
//            elapsed=elapsed/1000;
//            int ENG = cbToEngUnits(BoardNum,BIP5VOLTS,ADData[CurIndex],&v);
//            double v_double=(double)v;
//            const QPointF s(elapsed, 1.0);
//            SignalData::instance().append( s );
//            StoredLocation=CurIndex;
//            //printf("IIndex:%d\n",CurIndex);
//            checktimer.restart();
//        }
//            //printf("OIndex:%d",CurIndex);
////        // check the current status of the background operation */

        if ((Status == RUNNING) && CurCount > 0)
        {

//          int ENG = cbToEngUnits(BoardNum,BIP5VOLTS,ADData[CurIndex],&EngUnits);
//          double v_double=static_cast<double>(EngUnits);
//            printf ("  Value: %d  ",v_double);
//            emit dataValueChanged(*EngUnits);

        }
    }




    /* Data collection terminated */

    /* The BACKGROUND operation must be explicitly stopped
        Parameters:
             BoardNum    :the number used by CB.CFG to describe this board
             FunctionType: A/D operation (AIFUNCTIOM)*/

}