From d3ac4a3dff10ba16467095a59a2e0d9806e85e29 Mon Sep 17 00:00:00 2001 From: Mikhail Polkovnikov Date: Wed, 9 Apr 2014 18:13:01 +0400 Subject: [PATCH] test --- mainwindow.cpp | 74 ++++++++++++++++++++++++++++++++++++++++++++++---- mainwindow.h | 1 + mainwindow.ui | 46 +++++++++++++++++++------------ plotter.cpp | 10 +++---- 4 files changed, 102 insertions(+), 29 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 5ef519e..daed17b 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -97,6 +97,7 @@ MainWindow::MainWindow(QWidget* parent) connect( ui->fullStartPushButton, SIGNAL(clicked()), this, SLOT(signalFullStartButtonClicked())); + connect( ui->checkBoxTimingSettings, SIGNAL(toggled(bool)), this, SLOT(signalTimingSettings(bool))); connect( ui->t2SpinBox, SIGNAL(valueChanged(int)), this, SLOT(signalT2Changed(int))); connect( ui->t3SpinBox, SIGNAL(valueChanged(int)), this, SLOT(signalT3Changed(int))); connect( ui->t4SpinBox, SIGNAL(valueChanged(int)), this, SLOT(signalT4Changed(int))); @@ -493,8 +494,10 @@ MainWindow::signalClockTimesChanged(int value) Clock* clock = dynamic_cast(pTimingParams[currentChart].signal); clock->times = value; - for ( unsigned int i = 2; i < 15; ++i) { - setTn(i); + if (ui->checkBoxTimingSettings->isChecked()) { + for ( unsigned int i = 2; i < 15; ++i) { + setTn(i); + } } changeSignalsOffsets(); formAll(); @@ -556,6 +559,13 @@ MainWindow::formByteArray() void MainWindow::signalConnectButtonClicked() { + quint8 *buf = formByteArray(); + for ( unsigned int i = 0; i < Signal::total_length; ++i) + std::cout << (quint16)buf[i] << " "; + std::cout << std::endl; + + delete [] buf; + #ifdef Q_OS_LINUX fd = ::open( "/dev/viking", O_RDWR); #elif defined(Q_OS_WIN32) @@ -626,8 +636,11 @@ MainWindow::signalApplyButtonClicked() ++i; } - for ( int i = 2; i < 15; ++i) - setTn(i); + if (ui->checkBoxTimingSettings->isChecked()) { + for ( unsigned int i = 2; i < 15; ++i) { + setTn(i); + } + } changeSignalsOffsets(); formAll(); @@ -768,6 +781,7 @@ MainWindow::signalWriteButtonClicked() ::memset( buffer, 0, BUFFER_SIZE); buffer[0] = 'D'; ::memcpy( buffer + HEADER_SIZE, buf + i * BUFFER_DATA, BUFFER_DATA); + #ifdef Q_OS_LINUX result = file.write( buffer, BUFFER_SIZE); if (result != BUFFER_SIZE) { @@ -844,6 +858,9 @@ MainWindow::signalNotifierActivated(int) void MainWindow::signalT2Changed(int value) { + if (!ui->checkBoxTimingSettings->isChecked()) + return; + if (!bIgnore) { Pulse* pulse = dynamic_cast(pTimingParams[0].signal); pulse->length = value; @@ -855,6 +872,9 @@ MainWindow::signalT2Changed(int value) void MainWindow::signalT3Changed(int value) { + if (!ui->checkBoxTimingSettings->isChecked()) + return; + if (!bIgnore) { Pulse* pulse_prev = dynamic_cast(pTimingParams[0].signal); Pulse* pulse_next = dynamic_cast(pTimingParams[1].signal); @@ -867,6 +887,9 @@ MainWindow::signalT3Changed(int value) void MainWindow::signalT4Changed(int value) { + if (!ui->checkBoxTimingSettings->isChecked()) + return; + if (!bIgnore) { Pulse* pulse = dynamic_cast(pTimingParams[1].signal); pulse->length = value; @@ -878,6 +901,9 @@ MainWindow::signalT4Changed(int value) void MainWindow::signalT5Changed(int value) { + if (!ui->checkBoxTimingSettings->isChecked()) + return; + if (!bIgnore) { Pulse* pulse_prev = dynamic_cast(pTimingParams[1].signal); Pulse* pulse_next = dynamic_cast(pTimingParams[2].signal); @@ -890,6 +916,9 @@ MainWindow::signalT5Changed(int value) void MainWindow::signalT6Changed(int value) { + if (!ui->checkBoxTimingSettings->isChecked()) + return; + if (!bIgnore) { Pulse* pulse_prev = dynamic_cast(pTimingParams[2].signal); Pulse* pulse_next = dynamic_cast(pTimingParams[3].signal); @@ -902,6 +931,9 @@ MainWindow::signalT6Changed(int value) void MainWindow::signalT7Changed(int value) { + if (!ui->checkBoxTimingSettings->isChecked()) + return; + if (!bIgnore) { Pulse* pulse = dynamic_cast(pTimingParams[3].signal); pulse->length = value; @@ -913,6 +945,9 @@ MainWindow::signalT7Changed(int value) void MainWindow::signalT8Changed(int value) { + if (!ui->checkBoxTimingSettings->isChecked()) + return; + if (!bIgnore) { Pulse* pulse_prev = dynamic_cast(pTimingParams[3].signal); Pulse* pulse_next = dynamic_cast(pTimingParams[4].signal); @@ -925,6 +960,9 @@ MainWindow::signalT8Changed(int value) void MainWindow::signalT9Changed(int value) { + if (!ui->checkBoxTimingSettings->isChecked()) + return; + if (!bIgnore) { Pulse* pulse = dynamic_cast(pTimingParams[4].signal); pulse->length = value; @@ -936,6 +974,9 @@ MainWindow::signalT9Changed(int value) void MainWindow::signalT10Changed(int value) { + if (!ui->checkBoxTimingSettings->isChecked()) + return; + if (!bIgnore) { Pulse* pulse = dynamic_cast(pTimingParams[4].signal); Clock* clock_prev = dynamic_cast(pTimingParams[5].signal); @@ -950,6 +991,9 @@ MainWindow::signalT10Changed(int value) void MainWindow::signalT11Changed(int value) { + if (!ui->checkBoxTimingSettings->isChecked()) + return; + if (!bIgnore) { Clock* clock = dynamic_cast(pTimingParams[5].signal); clock->pulse.offset = clock->pulse.offset + clock->pulse.length - value; @@ -963,6 +1007,9 @@ MainWindow::signalT11Changed(int value) void MainWindow::signalT12Changed(int value) { + if (!ui->checkBoxTimingSettings->isChecked()) + return; + if (!bIgnore) { Clock* clock_prev = dynamic_cast(pTimingParams[5].signal); Clock* clock_next = dynamic_cast(pTimingParams[7].signal); @@ -977,6 +1024,9 @@ MainWindow::signalT12Changed(int value) void MainWindow::signalT13Changed(int value) { + if (!ui->checkBoxTimingSettings->isChecked()) + return; + if (!bIgnore) { Clock* clock_prev = dynamic_cast(pTimingParams[5].signal); Clock* clock_next = dynamic_cast(pTimingParams[7].signal); @@ -989,6 +1039,9 @@ MainWindow::signalT13Changed(int value) void MainWindow::signalT14Changed(int value) { + if (!ui->checkBoxTimingSettings->isChecked()) + return; + if (!bIgnore) { Clock* clock = dynamic_cast(pTimingParams[7].signal); clock->pulse.offset += clock->pulse.length - value; @@ -1001,14 +1054,23 @@ MainWindow::signalT14Changed(int value) void MainWindow::signalFullStartButtonClicked() { - signalWriteLengthButtonClicked(); - ::usleep(1000000); signalResetButtonClicked(); ::usleep(1000000); signalWriteButtonClicked(); signalStartButtonClicked(); } +void +MainWindow::signalTimingSettings(bool state) +{ + if (state) { + for ( unsigned int i = 2; i < 15; ++i) { + setTn(i); + } + changeSignalsOffsets(); + } +} + void MainWindow::setTn(unsigned int n) { diff --git a/mainwindow.h b/mainwindow.h index b23be85..8e203bd 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -49,6 +49,7 @@ class MainWindow : public QMainWindow { private slots: void signalCurrentItemChanged(QListWidgetItem*); void signalCurrentRowChanged(int); + void signalTimingSettings(bool); void signalLevelChanged(); void signalPulseOffsetChanged(int); diff --git a/mainwindow.ui b/mainwindow.ui index b771072..8f14fa8 100644 --- a/mainwindow.ui +++ b/mainwindow.ui @@ -44,7 +44,7 @@ - 1 + 0 @@ -57,10 +57,10 @@ "t" Timings - + - 2 + 0 @@ -68,7 +68,7 @@ 0 0 256 - 384 + 339 @@ -136,7 +136,7 @@ 0 0 256 - 384 + 339 @@ -178,7 +178,7 @@ 0 0 256 - 384 + 339 @@ -220,7 +220,7 @@ 0 0 256 - 384 + 339 @@ -276,7 +276,7 @@ 0 0 256 - 384 + 339 @@ -332,7 +332,7 @@ 0 0 256 - 384 + 339 @@ -402,7 +402,7 @@ 0 0 256 - 384 + 339 @@ -454,6 +454,13 @@ + + + + Enable timing settings + + + @@ -891,8 +898,18 @@ + + + + + + + + + false + 4096 @@ -910,13 +927,6 @@ - - - - - - - @@ -1131,7 +1141,7 @@ 0 0 944 - 22 + 25 diff --git a/plotter.cpp b/plotter.cpp index f6216e1..07001e6 100644 --- a/plotter.cpp +++ b/plotter.cpp @@ -245,13 +245,13 @@ void Plotter::drawGrid(QPainter *painter) return; PlotSettings settings = zoomStack[curZoom]; -#ifdef Q_OS_WIN32 +//#ifdef Q_OS_WIN32 QPen quiteDark = palette().dark().color(); QPen light = palette().dark().color().darker(); -#else - QPen quiteDark = palette().dark().color().darker(); - QPen light = palette().dark().color().light(); -#endif +//#else +// QPen quiteDark = palette().dark().color().darker(); +// QPen light = palette().dark().color().light(); +//#endif quiteDark.setStyle(Qt::DashDotLine); light.setStyle(Qt::DashDotLine);