Ejemplo n.º 1
0
void DBCSignalEditor::bitfieldClicked(int x, int y)
{
    int bit = (x) + (y * 8);
    if (currentSignal == NULL) return;
    currentSignal->startBit = bit;
    fillSignalForm(currentSignal);
}
Ejemplo n.º 2
0
void DBCSignalEditor::clickSignalList(int row)
{
    //qDebug() << ui->signalsList->item(row)->text();

    DBC_SIGNAL *thisSig = (row<0) ? NULL : dbcMessage->sigHandler->findSignalByName(ui->signalsList->item(row)->text());
    currentSignal = thisSig;
    fillSignalForm(thisSig);
    fillValueTable(thisSig);
}
Ejemplo n.º 3
0
void DBCSignalEditor::clickSignalList(int row)
{
    if (row < 0) return;
    //qDebug() << ui->signalsList->item(row)->text();
    DBC_SIGNAL *thisSig = dbcHandler->findSignalByName(dbcMessage, ui->signalsList->item(row)->text());
    if (thisSig == NULL) return;
    currentSignal = thisSig;
    fillSignalForm(thisSig);
    fillValueTable(thisSig);

}
Ejemplo n.º 4
0
void DBCSignalEditor::showEvent(QShowEvent* event)
{
    QDialog::showEvent(event);

    refreshSignalsList();
    currentSignal = NULL;
    if (dbcMessage->msgSignals.count() > 0)
    {        
        currentSignal = &dbcMessage->msgSignals[0];
        fillSignalForm(currentSignal);
        fillValueTable(currentSignal);
    }
}
Ejemplo n.º 5
0
void DBCSignalEditor::bitfieldClicked(int x, int y)
{
    int bit = (7 - x) + (y * 8);
    if (currentSignal == NULL) return;
    currentSignal->startBit = bit;
    if (currentSignal->valType == SP_FLOAT)
    {
        if (currentSignal->startBit > 31) currentSignal->startBit = 39;
    }

    if (currentSignal->valType == DP_FLOAT)
        currentSignal->startBit = 7;
    fillSignalForm(currentSignal);
}
Ejemplo n.º 6
0
void DBCSignalEditor::deleteCurrentSignal()
{
    int currIdx = ui->signalsList->currentRow();
    if (currIdx > -1)
    {
        delete(ui->signalsList->item(currIdx));
        dbcMessage->msgSignals.removeAt(currIdx);
        currentSignal = NULL;
        currIdx = ui->signalsList->currentRow();
        if (currIdx > -1) currentSignal = &dbcMessage->msgSignals[currIdx];
        fillSignalForm(currentSignal);
        fillValueTable(currentSignal);
    }
}
Ejemplo n.º 7
0
DBCSignalEditor::DBCSignalEditor(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DBCSignalEditor)
{
    ui->setupUi(this);

    readSettings();

    qsrand(QDateTime::currentMSecsSinceEpoch());

    dbcHandler = DBCHandler::getReference();
    dbcMessage = NULL;
    currentSignal = NULL;

    QStringList headers2;
    headers2 << "Value" << "Text";
    ui->valuesTable->setColumnCount(2);
    ui->valuesTable->setColumnWidth(0, 200);
    ui->valuesTable->setColumnWidth(1, 440);
    ui->valuesTable->setHorizontalHeaderLabels(headers2);
    ui->valuesTable->horizontalHeader()->setStretchLastSection(true);

    ui->comboType->addItem("UNSIGNED INTEGER");
    ui->comboType->addItem("SIGNED INTEGER");
    ui->comboType->addItem("SINGLE PRECISION");
    ui->comboType->addItem("DOUBLE PRECISION");
    ui->comboType->addItem("STRING");

    connect(ui->signalsList, SIGNAL(currentRowChanged(int)), this, SLOT(clickSignalList(int)));
    connect(ui->bitfield, SIGNAL(gridClicked(int,int)), this, SLOT(bitfieldClicked(int,int)));
    connect(ui->signalsList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onCustomMenuSignals(QPoint)));
    ui->signalsList->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(ui->valuesTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onCustomMenuValues(QPoint)));
    ui->valuesTable->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(ui->valuesTable, SIGNAL(cellChanged(int,int)), this, SLOT(onValuesCellChanged(int,int)));

    //now with 100% more lambda expressions just to make it interesting (and shorter, and easier...)
    connect(ui->cbIntelFormat, &QCheckBox::toggled,
            [=]()
            {
                if (currentSignal == NULL) return;
                currentSignal->intelByteOrder = ui->cbIntelFormat->isChecked();
                if (currentSignal->valType == SP_FLOAT || currentSignal->valType == DP_FLOAT)
                    currentSignal->intelByteOrder = false;
                fillSignalForm(currentSignal);
            });

    connect(ui->comboReceiver, &QComboBox::currentTextChanged,
            [=]()
            {
                if (currentSignal == NULL) return;
                currentSignal->receiver = dbcFile->findNodeByName(ui->comboReceiver->currentText());
            });
    connect(ui->comboType, &QComboBox::currentTextChanged,
            [=]()
            {
                if (currentSignal == NULL) return;
                switch (ui->comboType->currentIndex())
                {
                case 0:
                    currentSignal->valType = UNSIGNED_INT;
                    break;
                case 1:
                    currentSignal->valType = SIGNED_INT;
                    break;
                case 2:
                    currentSignal->valType = SP_FLOAT;
                    currentSignal->intelByteOrder = false;
                    if (currentSignal->startBit > 39) currentSignal->startBit = 39;
                    currentSignal->signalSize = 32;
                    break;
                case 3:
                    currentSignal->valType = DP_FLOAT;
                    currentSignal->intelByteOrder = false;
                    currentSignal->startBit = 7; //has to be!
                    currentSignal->signalSize = 64;
                    break;
                case 4:
                    currentSignal->valType = STRING;
                    break;                    
                }
                fillSignalForm(currentSignal);
            });
    connect(ui->txtBias, &QLineEdit::editingFinished,
            [=]()
            {
                if (currentSignal == NULL) return;
                double temp;
                bool result;
                temp = ui->txtBias->text().toDouble(&result);
                if (result) currentSignal->bias = temp;
            });

    connect(ui->txtMaxVal, &QLineEdit::editingFinished,
            [=]()
            {
                if (currentSignal == NULL) return;
                double temp;
                bool result;
                temp = ui->txtMaxVal->text().toDouble(&result);
                if (result) currentSignal->max = temp;
            });

    connect(ui->txtMinVal, &QLineEdit::editingFinished,
            [=]()
            {
                if (currentSignal == NULL) return;
                double temp;
                bool result;
                temp = ui->txtMinVal->text().toDouble(&result);
                if (result) currentSignal->min = temp;
            });
    connect(ui->txtScale, &QLineEdit::editingFinished,
            [=]()
            {
                if (currentSignal == NULL) return;
                double temp;
                bool result;
                temp = ui->txtScale->text().toDouble(&result);
                if (result) currentSignal->factor = temp;
            });
    connect(ui->txtComment, &QLineEdit::editingFinished,
            [=]()
            {
                if (currentSignal == NULL) return;
                currentSignal->comment = ui->txtComment->text().simplified().replace(' ', '_');
            });

    connect(ui->txtUnitName, &QLineEdit::editingFinished,
            [=]()
            {
                if (currentSignal == NULL) return;
                currentSignal->unitName = ui->txtUnitName->text().simplified().replace(' ', '_');
            });
    connect(ui->txtBitLength, &QLineEdit::textChanged,
            [=]()
            {
                if (currentSignal == NULL) return;
                int temp;
                temp = Utility::ParseStringToNum(ui->txtBitLength->text());
                if (temp < 0) return;
                if (temp > 63) return;
                if (currentSignal->valType != SP_FLOAT && currentSignal->valType != DP_FLOAT)
                    currentSignal->signalSize = temp;
                fillSignalForm(currentSignal);
            });
    connect(ui->txtName, &QLineEdit::editingFinished,
            [=]()
            {
                if (currentSignal == NULL) return;
                QString tempNameStr = ui->txtName->text().simplified().replace(' ', '_');
                if (tempNameStr.length() > 0) currentSignal->name = tempNameStr;
                //need to update the list too.
                ui->signalsList->currentItem()->setText(currentSignal->name);
            });

    connect(ui->txtMultiplexValue, &QLineEdit::editingFinished,
            [=]()
            {
                if (currentSignal == NULL) return;
                int temp;
                temp = Utility::ParseStringToNum(ui->txtMultiplexValue->text());
                //TODO: could look up the multiplexor and ensure that the value is within a range that the multiplexor could return
                currentSignal->multiplexValue = temp;
            });
    connect(ui->rbMultiplexed, &QRadioButton::toggled,
            [=](bool state)
            {
                if (state && currentSignal) //signal is now set as a multiplexed signal
                {
                    currentSignal->isMultiplexed = true;
                    currentSignal->isMultiplexor = false;
                    //if the set multiplexor for the message was this signal then clear it
                    if (dbcMessage->multiplexorSignal == currentSignal) dbcMessage->multiplexorSignal = NULL;
                }
            });

    connect(ui->rbMultiplexor, &QRadioButton::toggled,
            [=](bool state)
            {
                if (state && currentSignal) //signal is now set as a multiplexed signal
                {
                    //don't allow this signal to be a multiplexor if there is already one for this message.
                    //if (dbcMessage->multiplexorSignal != currentSignal && dbcMessage->multiplexorSignal != NULL) return; //I spoke too soon above...
                    currentSignal->isMultiplexed = false;
                    currentSignal->isMultiplexor = true;
                    //we just set that this is the multiplexor so update the message to show that as well.
                    dbcMessage->multiplexorSignal = currentSignal;
                }
            });

    connect(ui->rbNotMulti, &QRadioButton::toggled,
            [=](bool state)
            {
                if (state && currentSignal) //signal is now set as a multiplexed signal
                {
                    currentSignal->isMultiplexed = false;
                    currentSignal->isMultiplexor = false;
                    if (dbcMessage->multiplexorSignal == currentSignal) dbcMessage->multiplexorSignal = NULL;
                }
            });

    installEventFilter(this);
}
Ejemplo n.º 8
0
DBCSignalEditor::DBCSignalEditor(DBCHandler *handler, QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DBCSignalEditor)
{
    ui->setupUi(this);

    readSettings();

    qsrand(QDateTime::currentMSecsSinceEpoch());

    dbcHandler = handler;
    dbcMessage = NULL;
    currentSignal = NULL;

    QStringList headers2;
    headers2 << "Value" << "Text";
    ui->valuesTable->setColumnCount(2);
    ui->valuesTable->setColumnWidth(0, 200);
    ui->valuesTable->setColumnWidth(1, 440);
    ui->valuesTable->setHorizontalHeaderLabels(headers2);
    ui->valuesTable->horizontalHeader()->setStretchLastSection(true);

    ui->comboType->addItem("UNSIGNED INTEGER");
    ui->comboType->addItem("SIGNED INTEGER");
    ui->comboType->addItem("SINGLE PRECISION");
    ui->comboType->addItem("DOUBLE PRECISION");
    ui->comboType->addItem("STRING");

    for (int x = 0; x < dbcHandler->dbc_nodes.count(); x++)
    {
        ui->comboReceiver->addItem(dbcHandler->dbc_nodes[x].name);
    }

    connect(ui->signalsList, SIGNAL(currentRowChanged(int)), this, SLOT(clickSignalList(int)));
    connect(ui->bitfield, SIGNAL(gridClicked(int,int)), this, SLOT(bitfieldClicked(int,int)));
    connect(ui->signalsList, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onCustomMenuSignals(QPoint)));
    ui->signalsList->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(ui->valuesTable, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onCustomMenuValues(QPoint)));
    ui->valuesTable->setContextMenuPolicy(Qt::CustomContextMenu);
    connect(ui->valuesTable, SIGNAL(cellChanged(int,int)), this, SLOT(onValuesCellChanged(int,int)));

    //now with 100% more lambda expressions just to make it interesting (and shorter, and easier...)
    connect(ui->cbIntelFormat, &QCheckBox::toggled,
            [=]()
            {
                if (currentSignal == NULL) return;
                currentSignal->intelByteOrder = ui->cbIntelFormat->isChecked();
                fillSignalForm(currentSignal);
            });

    connect(ui->comboReceiver, &QComboBox::currentTextChanged,
            [=]()
            {
                if (currentSignal == NULL) return;
                currentSignal->receiver = dbcHandler->findNodeByName(ui->comboReceiver->currentText());
            });
    connect(ui->comboType, &QComboBox::currentTextChanged,
            [=]()
            {
                if (currentSignal == NULL) return;
                switch (ui->comboType->currentIndex())
                {
                case 0:
                    currentSignal->valType = UNSIGNED_INT;
                    break;
                case 1:
                    currentSignal->valType = SIGNED_INT;
                    break;
                case 2:
                    currentSignal->valType = SP_FLOAT;
                    break;
                case 3:
                    currentSignal->valType = DP_FLOAT;
                    break;
                case 4:
                    currentSignal->valType = STRING;
                    break;
                }
            });
    connect(ui->txtBias, &QLineEdit::editingFinished,
            [=]()
            {
                if (currentSignal == NULL) return;
                double temp;
                bool result;
                temp = ui->txtBias->text().toDouble(&result);
                if (result) currentSignal->bias = temp;
            });

    connect(ui->txtMaxVal, &QLineEdit::editingFinished,
            [=]()
            {
                if (currentSignal == NULL) return;
                double temp;
                bool result;
                temp = ui->txtMaxVal->text().toDouble(&result);
                if (result) currentSignal->max = temp;
            });

    connect(ui->txtMinVal, &QLineEdit::editingFinished,
            [=]()
            {
                if (currentSignal == NULL) return;
                double temp;
                bool result;
                temp = ui->txtMinVal->text().toDouble(&result);
                if (result) currentSignal->min = temp;
            });
    connect(ui->txtScale, &QLineEdit::editingFinished,
            [=]()
            {
                if (currentSignal == NULL) return;
                double temp;
                bool result;
                temp = ui->txtScale->text().toDouble(&result);
                if (result) currentSignal->factor = temp;
            });
    connect(ui->txtComment, &QLineEdit::editingFinished,
            [=]()
            {
                if (currentSignal == NULL) return;
                currentSignal->comment = ui->txtComment->text();
            });

    connect(ui->txtUnitName, &QLineEdit::editingFinished,
            [=]()
            {
                if (currentSignal == NULL) return;
                currentSignal->unitName = ui->txtUnitName->text();
            });
    connect(ui->txtBitLength, &QLineEdit::editingFinished,
            [=]()
            {
                if (currentSignal == NULL) return;
                int temp;
                temp = Utility::ParseStringToNum(ui->txtBitLength->text());
                if (temp < 0) return;
                if (temp > 63) return;
                currentSignal->signalSize = temp;
                fillSignalForm(currentSignal);
            });
    connect(ui->txtName, &QLineEdit::editingFinished,
            [=]()
            {
                if (currentSignal == NULL) return;
                currentSignal->name = ui->txtName->text();
                //need to update the list too.
                ui->signalsList->currentItem()->setText(currentSignal->name);
            });
}