Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikhail Polkovnikov committed Apr 9, 2014
1 parent 28231df commit d3ac4a3
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 29 deletions.
74 changes: 68 additions & 6 deletions mainwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)));
Expand Down Expand Up @@ -493,8 +494,10 @@ MainWindow::signalClockTimesChanged(int value)
Clock* clock = dynamic_cast<Clock*>(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();
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -844,6 +858,9 @@ MainWindow::signalNotifierActivated(int)
void
MainWindow::signalT2Changed(int value)
{
if (!ui->checkBoxTimingSettings->isChecked())
return;

if (!bIgnore) {
Pulse* pulse = dynamic_cast<Pulse*>(pTimingParams[0].signal);
pulse->length = value;
Expand All @@ -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<Pulse*>(pTimingParams[0].signal);
Pulse* pulse_next = dynamic_cast<Pulse*>(pTimingParams[1].signal);
Expand All @@ -867,6 +887,9 @@ MainWindow::signalT3Changed(int value)
void
MainWindow::signalT4Changed(int value)
{
if (!ui->checkBoxTimingSettings->isChecked())
return;

if (!bIgnore) {
Pulse* pulse = dynamic_cast<Pulse*>(pTimingParams[1].signal);
pulse->length = value;
Expand All @@ -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<Pulse*>(pTimingParams[1].signal);
Pulse* pulse_next = dynamic_cast<Pulse*>(pTimingParams[2].signal);
Expand All @@ -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<Pulse*>(pTimingParams[2].signal);
Pulse* pulse_next = dynamic_cast<Pulse*>(pTimingParams[3].signal);
Expand All @@ -902,6 +931,9 @@ MainWindow::signalT6Changed(int value)
void
MainWindow::signalT7Changed(int value)
{
if (!ui->checkBoxTimingSettings->isChecked())
return;

if (!bIgnore) {
Pulse* pulse = dynamic_cast<Pulse*>(pTimingParams[3].signal);
pulse->length = value;
Expand All @@ -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<Pulse*>(pTimingParams[3].signal);
Pulse* pulse_next = dynamic_cast<Pulse*>(pTimingParams[4].signal);
Expand All @@ -925,6 +960,9 @@ MainWindow::signalT8Changed(int value)
void
MainWindow::signalT9Changed(int value)
{
if (!ui->checkBoxTimingSettings->isChecked())
return;

if (!bIgnore) {
Pulse* pulse = dynamic_cast<Pulse*>(pTimingParams[4].signal);
pulse->length = value;
Expand All @@ -936,6 +974,9 @@ MainWindow::signalT9Changed(int value)
void
MainWindow::signalT10Changed(int value)
{
if (!ui->checkBoxTimingSettings->isChecked())
return;

if (!bIgnore) {
Pulse* pulse = dynamic_cast<Pulse*>(pTimingParams[4].signal);
Clock* clock_prev = dynamic_cast<Clock*>(pTimingParams[5].signal);
Expand All @@ -950,6 +991,9 @@ MainWindow::signalT10Changed(int value)
void
MainWindow::signalT11Changed(int value)
{
if (!ui->checkBoxTimingSettings->isChecked())
return;

if (!bIgnore) {
Clock* clock = dynamic_cast<Clock*>(pTimingParams[5].signal);
clock->pulse.offset = clock->pulse.offset + clock->pulse.length - value;
Expand All @@ -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<Clock*>(pTimingParams[5].signal);
Clock* clock_next = dynamic_cast<Clock*>(pTimingParams[7].signal);
Expand All @@ -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<Clock*>(pTimingParams[5].signal);
Clock* clock_next = dynamic_cast<Clock*>(pTimingParams[7].signal);
Expand All @@ -989,6 +1039,9 @@ MainWindow::signalT13Changed(int value)
void
MainWindow::signalT14Changed(int value)
{
if (!ui->checkBoxTimingSettings->isChecked())
return;

if (!bIgnore) {
Clock* clock = dynamic_cast<Clock*>(pTimingParams[7].signal);
clock->pulse.offset += clock->pulse.length - value;
Expand All @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class MainWindow : public QMainWindow {
private slots:
void signalCurrentItemChanged(QListWidgetItem*);
void signalCurrentRowChanged(int);
void signalTimingSettings(bool);

void signalLevelChanged();
void signalPulseOffsetChanged(int);
Expand Down
46 changes: 28 additions & 18 deletions mainwindow.ui
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
</sizepolicy>
</property>
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tabSignalsTest">
<property name="maximumSize">
Expand All @@ -57,18 +57,18 @@
<string>&quot;t&quot; Timings</string>
</attribute>
<layout class="QGridLayout" name="gridLayout_11">
<item row="0" column="0">
<item row="1" column="0">
<widget class="QToolBox" name="toolBoxSignalsTest">
<property name="currentIndex">
<number>2</number>
<number>0</number>
</property>
<widget class="QWidget" name="page2">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>256</width>
<height>384</height>
<height>339</height>
</rect>
</property>
<attribute name="label">
Expand Down Expand Up @@ -136,7 +136,7 @@
<x>0</x>
<y>0</y>
<width>256</width>
<height>384</height>
<height>339</height>
</rect>
</property>
<attribute name="label">
Expand Down Expand Up @@ -178,7 +178,7 @@
<x>0</x>
<y>0</y>
<width>256</width>
<height>384</height>
<height>339</height>
</rect>
</property>
<attribute name="label">
Expand Down Expand Up @@ -220,7 +220,7 @@
<x>0</x>
<y>0</y>
<width>256</width>
<height>384</height>
<height>339</height>
</rect>
</property>
<attribute name="label">
Expand Down Expand Up @@ -276,7 +276,7 @@
<x>0</x>
<y>0</y>
<width>256</width>
<height>384</height>
<height>339</height>
</rect>
</property>
<attribute name="label">
Expand Down Expand Up @@ -332,7 +332,7 @@
<x>0</x>
<y>0</y>
<width>256</width>
<height>384</height>
<height>339</height>
</rect>
</property>
<attribute name="label">
Expand Down Expand Up @@ -402,7 +402,7 @@
<x>0</x>
<y>0</y>
<width>256</width>
<height>384</height>
<height>339</height>
</rect>
</property>
<attribute name="label">
Expand Down Expand Up @@ -454,6 +454,13 @@
</widget>
</widget>
</item>
<item row="0" column="0">
<widget class="QCheckBox" name="checkBoxTimingSettings">
<property name="text">
<string>Enable timing settings</string>
</property>
</widget>
</item>
</layout>
</widget>
<widget class="QWidget" name="tabSignals">
Expand Down Expand Up @@ -891,8 +898,18 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string/>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QSlider" name="totalLengthHorizontalSlider">
<property name="enabled">
<bool>false</bool>
</property>
<property name="minimum">
<number>4096</number>
</property>
Expand All @@ -910,13 +927,6 @@
</property>
</widget>
</item>
<item row="0" column="1">
<widget class="QLabel" name="label">
<property name="text">
<string/>
</property>
</widget>
</item>
</layout>
</widget>
</item>
Expand Down Expand Up @@ -1131,7 +1141,7 @@
<x>0</x>
<y>0</y>
<width>944</width>
<height>22</height>
<height>25</height>
</rect>
</property>
</widget>
Expand Down
10 changes: 5 additions & 5 deletions plotter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit d3ac4a3

Please sign in to comment.