*Very* drastic changes to the graphing system. Now all graphs are done very much like DBC signals. Quite a bit has changed.
This commit compiles but the results are all funky. Just committing to give a good reference point during debugging. Don't use compiles from this revision. Wait young Jedi...
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#ifndef CONFIG
|
||||
#define CONFIG
|
||||
|
||||
#define VERSION 154
|
||||
#define VERSION 155
|
||||
|
||||
//try to keep this in sync.
|
||||
//SavvyCAN will complain if you connect a GVRET board with a revision
|
||||
|
||||
@@ -180,6 +180,7 @@ bool DBC_SIGNAL::processAsDouble(const CANFrame &frame, double &outValue)
|
||||
endResult = ((double)result * factor) + bias;
|
||||
result = (int64_t)endResult;
|
||||
}
|
||||
/*TODO: It should be noted that the below floating point has not even been tested. For shame! Test it!*/
|
||||
else if (valType == SP_FLOAT)
|
||||
{
|
||||
//The theory here is that we force the integer signal code to treat this as
|
||||
|
||||
+36
-339
@@ -685,22 +685,14 @@ void GraphingWindow::saveDefinitions()
|
||||
QList<GraphParams>::iterator iter;
|
||||
for (iter = graphParams.begin(); iter != graphParams.end(); ++iter)
|
||||
{
|
||||
outFile->write("X,");
|
||||
outFile->write(QString::number(iter->ID, 16).toUtf8());
|
||||
outFile->putChar(',');
|
||||
if (iter->isDBCSignal)
|
||||
{
|
||||
outFile->putChar('S');
|
||||
outFile->putChar(',');
|
||||
outFile->write(iter->signal.toUtf8());
|
||||
outFile->putChar(',');
|
||||
}
|
||||
else
|
||||
{
|
||||
outFile->write(QString::number(iter->mask, 16).toUtf8());
|
||||
outFile->putChar(',');
|
||||
outFile->write(QString::number(iter->startByte).toUtf8());
|
||||
outFile->write(QString::number(iter->startBit).toUtf8());
|
||||
outFile->putChar(',');
|
||||
outFile->write(QString::number(iter->endByte).toUtf8());
|
||||
outFile->write(QString::number(iter->numBits).toUtf8());
|
||||
outFile->putChar(',');
|
||||
if (iter->isSigned) outFile->putChar('Y');
|
||||
else outFile->putChar('N');
|
||||
@@ -711,7 +703,6 @@ void GraphingWindow::saveDefinitions()
|
||||
outFile->putChar(',');
|
||||
outFile->write(QString::number(iter->stride).toUtf8());
|
||||
outFile->putChar(',');
|
||||
}
|
||||
outFile->write(QString::number(iter->color.red()).toUtf8());
|
||||
outFile->putChar(',');
|
||||
outFile->write(QString::number(iter->color.green()).toUtf8());
|
||||
@@ -729,7 +720,6 @@ void GraphingWindow::loadDefinitions()
|
||||
{
|
||||
QString filename;
|
||||
QFileDialog dialog;
|
||||
bool dbcMissing = false;
|
||||
|
||||
QStringList filters;
|
||||
filters.append(QString(tr("Graph definition (*.gdf)")));
|
||||
@@ -755,66 +745,33 @@ void GraphingWindow::loadDefinitions()
|
||||
if (line.length() > 2)
|
||||
{
|
||||
GraphParams gp;
|
||||
QList<QByteArray> tokens = line.split(',');
|
||||
gp.isDBCSignal = false;
|
||||
|
||||
gp.ID = tokens[0].toInt(NULL, 16);
|
||||
if (tokens[1] == "S")
|
||||
QList<QByteArray> tokens = line.split(',');
|
||||
|
||||
if (tokens[0] == "X")
|
||||
{
|
||||
gp.isDBCSignal = true;
|
||||
//tokens[2] is the signal name. Need to use the message ID and this name to look it up
|
||||
DBC_MESSAGE *msg = dbcHandler->getFileByIdx(0)->messageHandler->findMsgByID(gp.ID);
|
||||
if (msg != NULL)
|
||||
{
|
||||
DBC_SIGNAL *sig = msg->sigHandler->findSignalByName(tokens[2]);
|
||||
if (sig == NULL) dbcMissing = true;
|
||||
gp.signal = tokens[2];
|
||||
}
|
||||
else
|
||||
{
|
||||
gp.signal = "";
|
||||
dbcMissing = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gp.mask = tokens[1].toULongLong(NULL, 16);
|
||||
qDebug() << gp.mask;
|
||||
gp.startByte = tokens[2].toInt();
|
||||
gp.endByte = tokens[3].toInt();
|
||||
if (tokens[4] == "Y") gp.isSigned = true;
|
||||
gp.ID = tokens[1].toInt(NULL, 16);
|
||||
gp.mask = tokens[2].toULongLong(NULL, 16);
|
||||
gp.startBit = tokens[3].toInt();
|
||||
gp.numBits = tokens[4].toInt();
|
||||
if (tokens[5] == "Y") gp.isSigned = true;
|
||||
else gp.isSigned = false;
|
||||
gp.bias = tokens[5].toFloat();
|
||||
gp.scale = tokens[6].toFloat();
|
||||
gp.stride = tokens[7].toInt();
|
||||
}
|
||||
if (!gp.isDBCSignal)
|
||||
{
|
||||
gp.color.setRed(tokens[8].toInt());
|
||||
gp.color.setGreen(tokens[9].toInt());
|
||||
gp.color.setBlue(tokens[10].toInt());
|
||||
if (tokens.length() > 11)
|
||||
gp.graphName = tokens[11];
|
||||
gp.bias = tokens[6].toFloat();
|
||||
gp.scale = tokens[7].toFloat();
|
||||
gp.stride = tokens[8].toInt();
|
||||
|
||||
gp.color.setRed(tokens[9].toInt());
|
||||
gp.color.setGreen(tokens[10].toInt());
|
||||
gp.color.setBlue(tokens[11].toInt());
|
||||
if (tokens.length() > 12)
|
||||
gp.graphName = tokens[12];
|
||||
else
|
||||
gp.graphName = QString();
|
||||
}
|
||||
else
|
||||
{
|
||||
gp.color.setRed(tokens[3].toInt());
|
||||
gp.color.setGreen(tokens[4].toInt());
|
||||
gp.color.setBlue(tokens[5].toInt());
|
||||
gp.graphName = tokens[6];
|
||||
}
|
||||
createGraph(gp, true);
|
||||
}
|
||||
}
|
||||
inFile->close();
|
||||
if (dbcMissing)
|
||||
{
|
||||
QMessageBox msg;
|
||||
msg.setText("One or more graphs could not be loaded\r\nbecause the signal could not be found.\r\nPerhaps you forgot to load\r\nthe DBC file?");
|
||||
msg.exec();
|
||||
}
|
||||
inFile->close();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -851,37 +808,7 @@ void GraphingWindow::addNewGraph()
|
||||
void GraphingWindow::appendToGraph(GraphParams ¶ms, CANFrame &frame)
|
||||
{
|
||||
int64_t tempVal; //64 bit temp value.
|
||||
if (params.isDBCSignal)
|
||||
{
|
||||
double tempValue;
|
||||
DBC_MESSAGE *msg = dbcHandler->getFileByIdx(0)->messageHandler->findMsgByID(params.ID);
|
||||
DBC_SIGNAL *sig = NULL;
|
||||
if (msg) sig = msg->sigHandler->findSignalByName(params.signal);
|
||||
if (sig == NULL) return;
|
||||
//if the given signal was found and successfully processed in this frame then add it to the graph
|
||||
if (sig->processAsDouble(frame, tempValue))
|
||||
{
|
||||
//qDebug() << "tempValue: " << tempValue;
|
||||
if (secondsMode)
|
||||
{
|
||||
params.x.append((double)(frame.timestamp) / 1000000.0 - params.xbias);
|
||||
}
|
||||
else
|
||||
{
|
||||
params.x.append(frame.timestamp - params.xbias);
|
||||
}
|
||||
params.y.append(tempValue);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (params.endByte == -1 || params.startByte == params.endByte)
|
||||
{
|
||||
tempVal = (frame.data[params.startByte] & params.mask);
|
||||
if (params.isSigned && tempVal > 127)
|
||||
{
|
||||
tempVal = tempVal - 256;
|
||||
}
|
||||
tempVal = Utility::processIntegerSignal(frame.data, params.startBit, params.numBits, params.intelFormat, params.isSigned) & params.mask;
|
||||
if (secondsMode)
|
||||
{
|
||||
params.x.append((double)(frame.timestamp) / 1000000.0 - params.xbias);
|
||||
@@ -891,93 +818,6 @@ void GraphingWindow::appendToGraph(GraphParams ¶ms, CANFrame &frame)
|
||||
params.x.append(frame.timestamp - params.xbias);
|
||||
}
|
||||
params.y.append((tempVal * params.scale) + params.bias);
|
||||
}
|
||||
else if (params.endByte > params.startByte) //big endian
|
||||
{
|
||||
float tempValue;
|
||||
int64_t tempValInt;
|
||||
int numBytes = (params.endByte - params.startByte) + 1;
|
||||
int64_t shiftRef = 1 << (numBytes * 8);
|
||||
uint64_t maskShifter;
|
||||
uint8_t tempByte;
|
||||
tempValInt = 0;
|
||||
int64_t expon = 1;
|
||||
maskShifter = params.mask;
|
||||
for (int c = 0; c < numBytes; c++)
|
||||
{
|
||||
tempByte = frame.data[params.endByte - c];
|
||||
tempByte &= maskShifter;
|
||||
tempValInt += (tempByte * expon);
|
||||
expon *= 256;
|
||||
maskShifter = maskShifter >> 8;
|
||||
}
|
||||
|
||||
tempValInt &= params.mask;
|
||||
|
||||
int64_t twocompPoint = params.mask;
|
||||
if (shiftRef < twocompPoint || twocompPoint == -1) twocompPoint = shiftRef;
|
||||
//qDebug() << "two comp point: " << twocompPoint;
|
||||
if (params.isSigned && tempValInt > ((twocompPoint / 2)))
|
||||
{
|
||||
tempValInt = tempValInt - twocompPoint;
|
||||
}
|
||||
|
||||
tempValue = (float)tempValInt;
|
||||
|
||||
if (secondsMode)
|
||||
{
|
||||
params.x.append((double)(frame.timestamp) / 1000000.0 - params.xbias);
|
||||
}
|
||||
else
|
||||
{
|
||||
params.x.append(frame.timestamp - params.xbias);
|
||||
}
|
||||
|
||||
params.y.append((tempValue * params.scale) + params.bias);
|
||||
}
|
||||
else //little endian
|
||||
{
|
||||
float tempValue;
|
||||
int64_t tempValInt;
|
||||
int numBytes = (params.startByte - params.endByte) + 1;
|
||||
int64_t shiftRef = 1 << (numBytes * 8);
|
||||
uint64_t maskShifter;
|
||||
uint8_t tempByte;
|
||||
tempValInt = 0;
|
||||
int64_t expon = 1;
|
||||
maskShifter = params.mask;
|
||||
for (int c = 0; c < numBytes; c++)
|
||||
{
|
||||
tempByte = frame.data[params.endByte + c];
|
||||
tempByte &= maskShifter;
|
||||
tempValInt += tempByte * expon;
|
||||
expon *= 256;
|
||||
maskShifter = maskShifter >> 8;
|
||||
}
|
||||
tempValInt &= params.mask;
|
||||
|
||||
int64_t twocompPoint = params.mask;
|
||||
if (shiftRef < twocompPoint || twocompPoint == -1) twocompPoint = shiftRef;
|
||||
//qDebug() << "two comp point: " << twocompPoint;
|
||||
if (params.isSigned && tempValInt > ((twocompPoint / 2)))
|
||||
{
|
||||
tempValInt = tempValInt - twocompPoint;
|
||||
}
|
||||
|
||||
tempValue = (float)tempValInt;
|
||||
|
||||
if (secondsMode)
|
||||
{
|
||||
params.x.append((double)(frame.timestamp) / 1000000.0 - params.xbias);
|
||||
}
|
||||
else
|
||||
{
|
||||
params.x.append(frame.timestamp - params.xbias);
|
||||
}
|
||||
|
||||
params.y.append((tempValue * params.scale) + params.bias);
|
||||
}
|
||||
}
|
||||
|
||||
params.ref->setData(params.x,params.y);
|
||||
}
|
||||
@@ -988,23 +828,15 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam)
|
||||
float yminval=10000000.0, ymaxval = -1000000.0;
|
||||
float xminval=10000000000.0, xmaxval = -10000000000.0;
|
||||
GraphParams *refParam = ¶ms;
|
||||
DBC_MESSAGE *msg = NULL;
|
||||
DBC_SIGNAL *sig = NULL;
|
||||
int sBit, bits;
|
||||
bool intelFormat, isSigned;
|
||||
|
||||
if (params.isDBCSignal)
|
||||
{
|
||||
msg = dbcHandler->getFileByIdx(0)->messageHandler->findMsgByID(params.ID);
|
||||
if (msg) sig = msg->sigHandler->findSignalByName(params.signal);
|
||||
if (sig == NULL) return;
|
||||
qDebug() << "New signal graph: " << params.signal <<" in ID:" << params.ID;
|
||||
}
|
||||
else
|
||||
{
|
||||
qDebug() << "New Graph ID: " << params.ID;
|
||||
qDebug() << "Start byte: " << params.startByte;
|
||||
qDebug() << "End Byte: " << params.endByte;
|
||||
qDebug() << "Start bit: " << params.startBit;
|
||||
qDebug() << "Data length: " << params.numBits;
|
||||
qDebug() << "Intel Mode: " << params.intelFormat;
|
||||
qDebug() << "Signed: " << params.isSigned;
|
||||
qDebug() << "Mask: " << params.mask;
|
||||
}
|
||||
|
||||
frameCache.clear();
|
||||
for (int i = 0; i < modelFrames->count(); i++)
|
||||
@@ -1020,49 +852,15 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam)
|
||||
params.x.fill(0, numEntries);
|
||||
params.y.fill(0, numEntries);
|
||||
|
||||
if (params.isDBCSignal)
|
||||
{
|
||||
double tempValue;
|
||||
int l = 0;
|
||||
for (int j = 0; j < numEntries; j++)
|
||||
{
|
||||
//if the given signal was found and successfully processed in this frame then add it to the graph
|
||||
if (sig->processAsDouble(frameCache[j], tempValue))
|
||||
{
|
||||
//qDebug() << "tempValue: " << tempValue;
|
||||
if (secondsMode)
|
||||
{
|
||||
params.x[l] = (double)(frameCache[j].timestamp) / 1000000.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
params.x[l] = frameCache[j].timestamp;
|
||||
}
|
||||
params.y[l] = tempValue;
|
||||
if (params.y[l] < yminval) yminval = params.y[l];
|
||||
if (params.y[l] > ymaxval) ymaxval = params.y[l];
|
||||
if (params.x[l] < xminval) xminval = params.x[l];
|
||||
if (params.x[l] > xmaxval) xmaxval = params.x[l];
|
||||
l++;
|
||||
}
|
||||
}
|
||||
params.x.resize(l);
|
||||
params.y.resize(l);
|
||||
params.x.squeeze();
|
||||
params.y.squeeze();
|
||||
}
|
||||
else
|
||||
{
|
||||
sBit = params.startBit;
|
||||
bits = params.numBits;
|
||||
intelFormat = params.intelFormat;
|
||||
isSigned = params.isSigned;
|
||||
|
||||
if (params.endByte == -1 || params.startByte == params.endByte)
|
||||
{
|
||||
for (int j = 0; j < numEntries; j++)
|
||||
{
|
||||
tempVal = (frameCache[j * params.stride].data[params.startByte] & params.mask);
|
||||
if (params.isSigned && tempVal > 127)
|
||||
{
|
||||
tempVal = tempVal - 256;
|
||||
}
|
||||
tempVal = Utility::processIntegerSignal(frameCache[j /** params.stride*/].data, sBit, bits, intelFormat, isSigned) & params.mask;
|
||||
//qDebug() << tempVal;
|
||||
if (secondsMode)
|
||||
{
|
||||
params.x[j] = (double)(frameCache[j].timestamp) / 1000000.0;
|
||||
@@ -1077,107 +875,6 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam)
|
||||
if (params.x[j] < xminval) xminval = params.x[j];
|
||||
if (params.x[j] > xmaxval) xmaxval = params.x[j];
|
||||
}
|
||||
}
|
||||
else if (params.endByte > params.startByte) //big endian
|
||||
{
|
||||
float tempValue;
|
||||
int64_t tempValInt;
|
||||
int numBytes = (params.endByte - params.startByte) + 1;
|
||||
int64_t shiftRef = (uint64_t)1 << (numBytes * 8);
|
||||
uint64_t maskShifter;
|
||||
uint8_t tempByte;
|
||||
for (int j = 0; j < numEntries; j++)
|
||||
{
|
||||
tempValInt = 0;
|
||||
int64_t expon = 1;
|
||||
maskShifter = params.mask;
|
||||
for (int c = 0; c < numBytes; c++)
|
||||
{
|
||||
tempByte = frameCache[j * params.stride].data[params.endByte - c];
|
||||
tempByte &= maskShifter;
|
||||
tempValInt += (tempByte * expon);
|
||||
expon *= 256;
|
||||
maskShifter = maskShifter >> 8;
|
||||
}
|
||||
|
||||
tempValInt &= params.mask;
|
||||
|
||||
int64_t twocompPoint = params.mask;
|
||||
if (shiftRef < twocompPoint || twocompPoint == -1) twocompPoint = shiftRef;
|
||||
//qDebug() << "two comp point: " << twocompPoint;
|
||||
if (params.isSigned && tempValInt > ((twocompPoint / 2)))
|
||||
{
|
||||
tempValInt = tempValInt - twocompPoint;
|
||||
}
|
||||
|
||||
tempValue = (float)tempValInt;
|
||||
|
||||
if (secondsMode)
|
||||
{
|
||||
params.x[j] = (double)(frameCache[j].timestamp) / 1000000.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
params.x[j] = frameCache[j].timestamp;
|
||||
}
|
||||
|
||||
params.y[j] = (tempValue * params.scale) + params.bias;
|
||||
if (params.y[j] < yminval) yminval = params.y[j];
|
||||
if (params.y[j] > ymaxval) ymaxval = params.y[j];
|
||||
if (params.x[j] < xminval) xminval = params.x[j];
|
||||
if (params.x[j] > xmaxval) xmaxval = params.x[j];
|
||||
}
|
||||
}
|
||||
else //little endian
|
||||
{
|
||||
float tempValue;
|
||||
int64_t tempValInt;
|
||||
int numBytes = (params.startByte - params.endByte) + 1;
|
||||
int64_t shiftRef = (uint64_t)1 << (numBytes * 8);
|
||||
uint64_t maskShifter;
|
||||
uint8_t tempByte;
|
||||
for (int j = 0; j < numEntries; j++)
|
||||
{
|
||||
tempValInt = 0;
|
||||
int64_t expon = 1;
|
||||
maskShifter = params.mask;
|
||||
for (int c = 0; c < numBytes; c++)
|
||||
{
|
||||
tempByte = frameCache[j * params.stride].data[params.endByte + c];
|
||||
tempByte &= maskShifter;
|
||||
tempValInt += tempByte * expon;
|
||||
expon *= 256;
|
||||
maskShifter = maskShifter >> 8;
|
||||
}
|
||||
tempValInt &= params.mask;
|
||||
|
||||
int64_t twocompPoint = params.mask;
|
||||
if (shiftRef < twocompPoint || twocompPoint == -1) twocompPoint = shiftRef;
|
||||
//qDebug() << "two comp point: " << twocompPoint;
|
||||
if (params.isSigned && tempValInt > ((twocompPoint / 2)))
|
||||
{
|
||||
tempValInt = tempValInt - twocompPoint;
|
||||
}
|
||||
|
||||
tempValue = (float)tempValInt;
|
||||
|
||||
if (secondsMode)
|
||||
{
|
||||
params.x[j] = (double)(frameCache[j].timestamp) / 1000000.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
params.x[j] = frameCache[j].timestamp;
|
||||
}
|
||||
|
||||
params.y[j] = (tempValue * params.scale) + params.bias;
|
||||
if (params.y[j] < yminval) yminval = params.y[j];
|
||||
if (params.y[j] > ymaxval) ymaxval = params.y[j];
|
||||
if (params.x[j] < xminval) xminval = params.x[j];
|
||||
if (params.x[j] > xmaxval) xmaxval = params.x[j];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
params.xbias = 0;
|
||||
|
||||
@@ -1193,8 +890,8 @@ void GraphingWindow::createGraph(GraphParams ¶ms, bool createGraphParam)
|
||||
|
||||
if (params.graphName == NULL || params.graphName.length() == 0)
|
||||
{
|
||||
params.graphName = QString("0x") + QString::number(params.ID, 16) + ":" + QString::number(params.startByte);
|
||||
if ((params.endByte != -1) && (params.endByte != params.startByte)) params.graphName += "-" + QString::number(params.endByte);
|
||||
params.graphName = QString("0x") + QString::number(params.ID, 16) + ":" + QString::number(params.startBit);
|
||||
params.graphName += "-" + QString::number(params.numBits);
|
||||
}
|
||||
ui->graphingView->graph()->setName(params.graphName);
|
||||
ui->graphingView->graph()->setProperty("id", params.ID);
|
||||
|
||||
+2
-3
@@ -15,7 +15,8 @@ class GraphParams
|
||||
{
|
||||
public:
|
||||
uint32_t ID;
|
||||
int startByte, endByte;
|
||||
int startBit, numBits;
|
||||
bool intelFormat;
|
||||
bool isSigned;
|
||||
uint64_t mask;
|
||||
float bias;
|
||||
@@ -24,8 +25,6 @@ public:
|
||||
QColor color;
|
||||
QCPGraph *ref;
|
||||
QString graphName;
|
||||
bool isDBCSignal; //is this graph actually a DBC signal? If so the below pointer should be filled out
|
||||
QString signal;
|
||||
//the below stuff is used for internal purposes only - code should be refactored so these can be private
|
||||
QVector<double> x, y;
|
||||
double xbias;
|
||||
|
||||
+88
-118
@@ -24,9 +24,13 @@ NewGraphDialog::NewGraphDialog(DBCHandler *handler, QWidget *parent) :
|
||||
ui->colorSwatch->setPalette(p);
|
||||
|
||||
connect(ui->cbMessages, SIGNAL(currentIndexChanged(int)), this, SLOT(loadSignals(int)));
|
||||
connect(ui->cbSignals, SIGNAL(currentIndexChanged(int)), this, SLOT(fillFormFromSignal(int)));
|
||||
connect(ui->rbSignalGraph, SIGNAL(toggled(bool)), this, SLOT(setSignalActive(bool)));
|
||||
connect(ui->rbStandardGraph, SIGNAL(toggled(bool)), this, SLOT(setStandardActive(bool)));
|
||||
connect(ui->gridData, SIGNAL(gridClicked(int,int)), this, SLOT(bitfieldClicked(int,int)));
|
||||
connect(ui->txtDataLen, SIGNAL(textChanged(QString)), this, SLOT(handleDataLenUpdate()));
|
||||
connect(ui->cbIntel, SIGNAL(toggled(bool)), this, SLOT(drawBitfield()));
|
||||
connect(ui->btnCopySignal, SIGNAL(clicked(bool)), this, SLOT(copySignalToParamsUI()));
|
||||
|
||||
startBit = 0;
|
||||
dataLen = 1;
|
||||
|
||||
loadMessages();
|
||||
}
|
||||
@@ -36,6 +40,12 @@ NewGraphDialog::~NewGraphDialog()
|
||||
delete ui;
|
||||
}
|
||||
|
||||
void NewGraphDialog::showEvent(QShowEvent* event)
|
||||
{
|
||||
QDialog::showEvent(event);
|
||||
loadMessages();
|
||||
}
|
||||
|
||||
void NewGraphDialog::addButtonClicked()
|
||||
{
|
||||
accept();
|
||||
@@ -59,91 +69,47 @@ void NewGraphDialog::clearParams()
|
||||
ui->txtScale->clear();
|
||||
ui->txtStride->clear();
|
||||
ui->txtName->clear();
|
||||
ui->txtData->clear();
|
||||
ui->rbStandardGraph->setChecked(true);
|
||||
setStandardActive(true);
|
||||
|
||||
}
|
||||
|
||||
void NewGraphDialog::setParams(GraphParams ¶ms)
|
||||
{
|
||||
if (params.isDBCSignal)
|
||||
{
|
||||
clearParams();
|
||||
setSignalActive(true);
|
||||
//loadMessages();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
setStandardActive(true);
|
||||
ui->txtBias->setText(QString::number(params.bias));
|
||||
ui->txtMask->setText(Utility::formatNumber(params.mask));
|
||||
ui->txtScale->setText(QString::number(params.scale));
|
||||
ui->txtStride->setText(QString::number(params.stride));
|
||||
ui->cbSigned->setChecked(params.isSigned);
|
||||
|
||||
if (params.endByte > -1)
|
||||
{
|
||||
ui->txtData->setText(QString::number(params.startByte) + "-" + QString::number(params.endByte));
|
||||
}
|
||||
else
|
||||
{
|
||||
ui->txtData->setText(QString::number(params.startByte));
|
||||
}
|
||||
}
|
||||
startBit = params.startBit;
|
||||
dataLen = params.numBits;
|
||||
|
||||
ui->txtID->setText(Utility::formatNumber(params.ID));
|
||||
ui->txtName->setText(params.graphName);
|
||||
QPalette p = ui->colorSwatch->palette();
|
||||
p.setColor(QPalette::Button, params.color);
|
||||
ui->colorSwatch->setPalette(p);
|
||||
|
||||
drawBitfield();
|
||||
}
|
||||
|
||||
void NewGraphDialog::getParams(GraphParams ¶ms)
|
||||
{
|
||||
params.isDBCSignal = ui->rbSignalGraph->isChecked();
|
||||
params.color = ui->colorSwatch->palette().button().color();
|
||||
params.graphName = ui->txtName->text();
|
||||
|
||||
if (params.isDBCSignal)
|
||||
{
|
||||
params.signal = ui->cbSignals->currentText();
|
||||
params.ID = Utility::ParseStringToNum(ui->txtID->text());
|
||||
params.bias = 0;
|
||||
params.isSigned = false;
|
||||
params.mask = 0;
|
||||
params.scale = 1;
|
||||
params.bias = 0;
|
||||
params.stride = 1;
|
||||
|
||||
}
|
||||
else {
|
||||
params.ID = Utility::ParseStringToNum(ui->txtID->text());
|
||||
params.bias = ui->txtBias->text().toFloat();
|
||||
params.isSigned = ui->cbSigned->isChecked();
|
||||
params.mask = Utility::ParseStringToNum(ui->txtMask->text());
|
||||
params.scale = ui->txtScale->text().toFloat();
|
||||
params.stride = Utility::ParseStringToNum(ui->txtStride->text());
|
||||
params.signal = "";
|
||||
|
||||
QStringList values = ui->txtData->text().split('-');
|
||||
params.startByte = -1;
|
||||
params.endByte = -1;
|
||||
if (values.count() > 0)
|
||||
{
|
||||
params.startByte = values[0].toInt();
|
||||
if (values.count() > 1)
|
||||
{
|
||||
params.endByte = values[1].toInt();
|
||||
}
|
||||
}
|
||||
params.startBit = startBit;
|
||||
params.numBits = dataLen;
|
||||
|
||||
//now catch stupidity and bring it to defaults
|
||||
if (params.mask == 0) params.mask = 0xFFFFFFFF;
|
||||
if (fabs(params.scale) < 0.00000001) params.scale = 1.0f;
|
||||
if (params.stride < 1) params.stride = 1;
|
||||
}
|
||||
}
|
||||
|
||||
void NewGraphDialog::loadMessages()
|
||||
@@ -174,73 +140,77 @@ void NewGraphDialog::loadSignals(int idx)
|
||||
}
|
||||
}
|
||||
|
||||
void NewGraphDialog::fillFormFromSignal(int idx)
|
||||
void NewGraphDialog::bitfieldClicked(int x,int y)
|
||||
{
|
||||
int bit = (y * 8 + (7-x));
|
||||
int res;
|
||||
|
||||
qDebug() << "Clicked bit: " << bit;
|
||||
startBit = bit;
|
||||
drawBitfield();
|
||||
}
|
||||
|
||||
void NewGraphDialog::drawBitfield()
|
||||
{
|
||||
int64_t bitField = 0;
|
||||
int endBit, sBit;
|
||||
|
||||
bitField |= 1ull << (startBit); //make the start bit a different color to set it apart
|
||||
ui->gridData->setReference((unsigned char *)&bitField, false);
|
||||
|
||||
if (ui->cbIntel->isChecked())
|
||||
{
|
||||
endBit = startBit + dataLen - 1;
|
||||
if (startBit < 0) startBit = 0;
|
||||
if (endBit > 63) endBit = 63;
|
||||
for (int y = startBit; y <= endBit; y++)
|
||||
{
|
||||
bitField |= 1ull << y;
|
||||
}
|
||||
}
|
||||
else //big endian / motorola format
|
||||
{
|
||||
//much more irritating than the intel version...
|
||||
int size = dataLen;
|
||||
sBit = startBit;
|
||||
while (size > 0)
|
||||
{
|
||||
bitField |= 1ull << sBit;
|
||||
size--;
|
||||
if ((sBit % 8) == 0) sBit += 15;
|
||||
else sBit--;
|
||||
if (sBit > 63) sBit = 63;
|
||||
}
|
||||
}
|
||||
|
||||
ui->gridData->updateData((unsigned char *)&bitField, true);
|
||||
}
|
||||
|
||||
void NewGraphDialog::handleDataLenUpdate()
|
||||
{
|
||||
dataLen = ui->txtDataLen->text().toInt();
|
||||
if (dataLen < 1) dataLen = 1;
|
||||
if (dataLen > 63) dataLen = 63;
|
||||
drawBitfield();
|
||||
}
|
||||
|
||||
void NewGraphDialog::copySignalToParamsUI()
|
||||
{
|
||||
Q_UNUSED(idx);
|
||||
GraphParams params;
|
||||
DBC_MESSAGE *msg = dbcHandler->getFileByIdx(0)->messageHandler->findMsgByName(ui->cbMessages->currentText());
|
||||
|
||||
if (msg == NULL) return;
|
||||
|
||||
if (!msg) return;
|
||||
DBC_SIGNAL *sig = msg->sigHandler->findSignalByName(ui->cbSignals->currentText());
|
||||
if (!sig) return;
|
||||
|
||||
if (sig == NULL) return;
|
||||
|
||||
params.graphName = sig->name;
|
||||
params.ID = msg->ID;
|
||||
//params.bias = sig->bias;
|
||||
//params.scale = sig->factor;
|
||||
//params.stride = 1;
|
||||
//params.mask = (1 << (sig->signalSize)) - 1;
|
||||
//if (sig->valType == SIGNED_INT) params.isSigned = true;
|
||||
//else params.isSigned = false;
|
||||
params.color = ui->colorSwatch->palette().color(QPalette::Button);
|
||||
/*
|
||||
if (sig->intelByteOrder)
|
||||
{
|
||||
//for this ordering the byte order is reserved and starting byte
|
||||
//will be the higher value
|
||||
params.endByte = sig->startBit / 8;
|
||||
params.startByte = (sig->startBit + sig->signalSize - 1) / 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
//for this ordering it goes in normal numerical order
|
||||
params.startByte = sig->startBit / 8;
|
||||
params.endByte = (sig->startBit + sig->signalSize - 1) / 8;
|
||||
}
|
||||
*/
|
||||
setParams(params);
|
||||
}
|
||||
|
||||
void NewGraphDialog::setSignalActive(bool state)
|
||||
{
|
||||
if (!state) return;
|
||||
ui->rbSignalGraph->setChecked(true);
|
||||
ui->rbStandardGraph->setChecked(false);
|
||||
ui->cbMessages->setEnabled(true);
|
||||
ui->cbSignals->setEnabled(true);
|
||||
ui->cbSigned->setEnabled(false);
|
||||
ui->txtBias->setEnabled(false);
|
||||
ui->txtData->setEnabled(false);
|
||||
ui->txtID->setEnabled(false);
|
||||
ui->txtMask->setEnabled(false);
|
||||
ui->txtScale->setEnabled(false);
|
||||
ui->txtStride->setEnabled(false);
|
||||
}
|
||||
|
||||
void NewGraphDialog::setStandardActive(bool state)
|
||||
{
|
||||
if (!state) return;
|
||||
ui->rbStandardGraph->setChecked(true);
|
||||
ui->rbSignalGraph->setChecked(false);
|
||||
ui->cbMessages->setEnabled(false);
|
||||
ui->cbSignals->setEnabled(false);
|
||||
ui->cbSigned->setEnabled(true);
|
||||
ui->txtBias->setEnabled(true);
|
||||
ui->txtData->setEnabled(true);
|
||||
ui->txtID->setEnabled(true);
|
||||
ui->txtMask->setEnabled(true);
|
||||
ui->txtScale->setEnabled(true);
|
||||
ui->txtStride->setEnabled(true);
|
||||
startBit = sig->startBit;
|
||||
ui->txtBias->setText(QString::number(sig->bias));
|
||||
ui->txtDataLen->setText(QString::number(sig->signalSize));
|
||||
ui->txtID->setText(Utility::formatNumber(msg->ID));
|
||||
ui->txtMask->setText("0xFFFFFFFF");
|
||||
ui->txtName->setText(sig->name);
|
||||
ui->txtScale->setText(QString::number(sig->factor));
|
||||
ui->txtStride->setText("1");
|
||||
ui->cbIntel->setChecked(sig->intelByteOrder);
|
||||
if (sig->valType == SIGNED_INT) ui->cbSigned->setChecked(true);
|
||||
else ui->cbSigned->setChecked(false);
|
||||
drawBitfield();
|
||||
}
|
||||
|
||||
+6
-3
@@ -16,6 +16,7 @@ class NewGraphDialog : public QDialog
|
||||
public:
|
||||
explicit NewGraphDialog(DBCHandler *handler, QWidget *parent = 0);
|
||||
~NewGraphDialog();
|
||||
void showEvent(QShowEvent*);
|
||||
void getParams(GraphParams &);
|
||||
void setParams(GraphParams &);
|
||||
void clearParams();
|
||||
@@ -25,13 +26,15 @@ private slots:
|
||||
void colorSwatchClick();
|
||||
void loadMessages();
|
||||
void loadSignals(int idx);
|
||||
void fillFormFromSignal(int idx);
|
||||
void setSignalActive(bool);
|
||||
void setStandardActive(bool);
|
||||
void bitfieldClicked(int,int);
|
||||
void handleDataLenUpdate();
|
||||
void drawBitfield();
|
||||
void copySignalToParamsUI();
|
||||
|
||||
private:
|
||||
Ui::NewGraphDialog *ui;
|
||||
DBCHandler *dbcHandler;
|
||||
int startBit, dataLen;
|
||||
};
|
||||
|
||||
#endif // NEWGRAPHDIALOG_H
|
||||
|
||||
+85
-44
@@ -6,8 +6,8 @@
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>492</width>
|
||||
<height>340</height>
|
||||
<width>681</width>
|
||||
<height>640</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
@@ -15,31 +15,7 @@
|
||||
</property>
|
||||
<layout class="QVBoxLayout" name="verticalLayout">
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout_2">
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbStandardGraph">
|
||||
<property name="text">
|
||||
<string>Standard Graph</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QRadioButton" name="rbSignalGraph">
|
||||
<property name="text">
|
||||
<string>DBC Signal Graph</string>
|
||||
</property>
|
||||
<property name="checked">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="1,1">
|
||||
<layout class="QHBoxLayout" name="horizontalLayout" stretch="3,2">
|
||||
<item>
|
||||
<layout class="QFormLayout" name="formLayout">
|
||||
<item row="1" column="0">
|
||||
@@ -55,28 +31,25 @@
|
||||
<item row="2" column="0">
|
||||
<widget class="QLabel" name="label_2">
|
||||
<property name="text">
|
||||
<string>Data:</string>
|
||||
<string>Start Bit:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="QLineEdit" name="txtData"/>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<item row="5" column="0">
|
||||
<widget class="QLabel" name="label_3">
|
||||
<property name="text">
|
||||
<string>Signed:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<item row="5" column="1">
|
||||
<widget class="QCheckBox" name="cbSigned">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<item row="6" column="0">
|
||||
<widget class="QLabel" name="label_4">
|
||||
<property name="frameShape">
|
||||
<enum>QFrame::NoFrame</enum>
|
||||
@@ -86,47 +59,47 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<item row="6" column="1">
|
||||
<widget class="QLineEdit" name="txtMask"/>
|
||||
</item>
|
||||
<item row="5" column="0">
|
||||
<item row="7" column="0">
|
||||
<widget class="QLabel" name="label_5">
|
||||
<property name="text">
|
||||
<string>Bias:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="5" column="1">
|
||||
<item row="7" column="1">
|
||||
<widget class="QLineEdit" name="txtBias"/>
|
||||
</item>
|
||||
<item row="6" column="0">
|
||||
<item row="8" column="0">
|
||||
<widget class="QLabel" name="label_6">
|
||||
<property name="text">
|
||||
<string>Scale</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="6" column="1">
|
||||
<item row="8" column="1">
|
||||
<widget class="QLineEdit" name="txtScale"/>
|
||||
</item>
|
||||
<item row="7" column="0">
|
||||
<item row="9" column="0">
|
||||
<widget class="QLabel" name="label_7">
|
||||
<property name="text">
|
||||
<string>Stride</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="7" column="1">
|
||||
<item row="9" column="1">
|
||||
<widget class="QLineEdit" name="txtStride"/>
|
||||
</item>
|
||||
<item row="8" column="0">
|
||||
<item row="10" column="0">
|
||||
<widget class="QLabel" name="label_8">
|
||||
<property name="text">
|
||||
<string>Color</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="8" column="1">
|
||||
<item row="10" column="1">
|
||||
<widget class="QPushButton" name="colorSwatch">
|
||||
<property name="autoFillBackground">
|
||||
<bool>true</bool>
|
||||
@@ -139,7 +112,7 @@
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="9" column="1">
|
||||
<item row="11" column="1">
|
||||
<widget class="QPushButton" name="btnAddGraph">
|
||||
<property name="text">
|
||||
<string>Add this graph</string>
|
||||
@@ -156,6 +129,46 @@
|
||||
<item row="0" column="1">
|
||||
<widget class="QLineEdit" name="txtName"/>
|
||||
</item>
|
||||
<item row="2" column="1">
|
||||
<widget class="CANDataGrid" name="gridData" native="true">
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>290</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="baseSize">
|
||||
<size>
|
||||
<width>150</width>
|
||||
<height>150</height>
|
||||
</size>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="0">
|
||||
<widget class="QLabel" name="label_13">
|
||||
<property name="text">
|
||||
<string>Intel Format</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="4" column="1">
|
||||
<widget class="QCheckBox" name="cbIntel">
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="0">
|
||||
<widget class="QLabel" name="label_14">
|
||||
<property name="text">
|
||||
<string>Data Len:</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item row="3" column="1">
|
||||
<widget class="QLineEdit" name="txtDataLen"/>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
<item>
|
||||
@@ -214,12 +227,40 @@
|
||||
<item>
|
||||
<widget class="QComboBox" name="cbSignals"/>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QPushButton" name="btnCopySignal">
|
||||
<property name="text">
|
||||
<string>Copy Signal Parameters</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<spacer name="verticalSpacer">
|
||||
<property name="orientation">
|
||||
<enum>Qt::Vertical</enum>
|
||||
</property>
|
||||
<property name="sizeHint" stdset="0">
|
||||
<size>
|
||||
<width>20</width>
|
||||
<height>40</height>
|
||||
</size>
|
||||
</property>
|
||||
</spacer>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>CANDataGrid</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>candatagrid.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
|
||||
Reference in New Issue
Block a user