Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Graph float signals #783

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions dbc/dbc_classes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ bool DBC_SIGNAL::processAsDouble(const CANFrame &frame, double &outValue)
//that the bytes that make up the integer are instead treated as having made up
//a 32 bit single precision float. That's evil incarnate but it is very fast and small
//in terms of new code.
result = Utility::processIntegerSignal(frame.payload(), startBit, 32, false, false);
result = Utility::processIntegerSignal(frame.payload(), startBit, 32, intelByteOrder, false);
endResult = (*((float *)(&result)) * factor) + bias;
}
else //double precision float
Expand All @@ -312,7 +312,7 @@ bool DBC_SIGNAL::processAsDouble(const CANFrame &frame, double &outValue)
}
//like the above, this is rotten and evil and wrong in so many ways. Force
//calculation of a 64 bit integer and then cast it into a double.
result = Utility::processIntegerSignal(frame.payload(), startBit, 64, false, false);
result = Utility::processIntegerSignal(frame.payload(), startBit, 64, intelByteOrder, false);
endResult = (*((double *)(&result)) * factor) + bias;
}
cachedValue = endResult;
Expand Down
56 changes: 30 additions & 26 deletions re/graphingwindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1241,34 +1241,40 @@ void GraphingWindow::appendToGraph(GraphParams &params, CANFrame &frame, QVector
if (params.strideSoFar >= params.stride)
{
params.strideSoFar = 0;
int64_t tempVal; //64 bit temp value.
tempVal = Utility::processIntegerSignal(frame.payload(), params.startBit, params.numBits, params.intelFormat, params.isSigned); //& params.mask;
DBC_SIGNAL * sig = params.associatedSignal;
double xVal, yVal;

if (sig == NULL) {
return;
}
if (!sig->processAsDouble(frame, yVal)) {
return;
}
params.y.append(yVal);
y.append(yVal);

if (Utility::timeStyle == TS_SECONDS)
{
xVal = ((double)(frame.timeStamp().microSeconds()) / 1000000.0 - params.xbias);
}
else if (Utility::timeStyle == TS_CLOCK)
{
QDateTime dt = QDateTime::fromMSecsSinceEpoch((frame.timeStamp().microSeconds() / 1000) - params.xbias);
xVal = (dt.time().second() + dt.time().minute() * 60 + dt.time().hour() * 3600);
xVal = (dt.time().msec()/1000.0 + dt.time().second() + dt.time().minute() * 60 + dt.time().hour() * 3600);
}
else
{
xVal = (frame.timeStamp().microSeconds() - params.xbias);
}
yVal = (tempVal * params.scale) + params.bias;
params.x.append(xVal);
params.y.append(yVal);
x.append(xVal);
y.append(yVal);

//now see if we've got to do anything with the brackets and labels for value table stuff
QString tempStr;
if (params.associatedSignal)
{

bool isValid = params.associatedSignal->getValueString(tempVal, tempStr);
bool isValid = params.associatedSignal->getValueString(yVal, tempStr);
if (isValid)
{
//we have a graph with associated signal and we could interpret it. So, see what we need to do
Expand All @@ -1287,7 +1293,7 @@ void GraphingWindow::appendToGraph(GraphParams &params, CANFrame &frame, QVector
}
else //wasn't the same so complete the previous span and start a new one.
{
params.prevValTable = tempVal;
params.prevValTable = yVal;
params.prevValLocation = QPointF(xVal, yVal);
params.prevValStr = tempStr;

Expand Down Expand Up @@ -1315,7 +1321,6 @@ void GraphingWindow::appendToGraph(GraphParams &params, CANFrame &frame, QVector

void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
{
int64_t tempVal; //64 bit temp value.
double yminval=10000000.0, ymaxval = -1000000.0;
double xminval=10000000000.0, xmaxval = -10000000000.0;
GraphParams *refParam = &params;
Expand Down Expand Up @@ -1368,20 +1373,19 @@ void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
for (int j = 0; j < numEntries; j++)
{
int k = j * params.stride;
if (params.associatedSignal)
if (!params.associatedSignal) {
continue;
}
//skip all the rest of the stuff in this loop and don't add this to the graph if this signal isn't in this frame
if (!params.associatedSignal->isSignalInMessage(frameCache[k]))
{
//skip all the rest of the stuff in this loop and don't add this to the graph if this signal isn't in this frame
if (!params.associatedSignal->isSignalInMessage(frameCache[k]))
{
qDebug() << "Signal was not in this frame";
continue;
}
else qDebug() << "Signal in the frame!";
qDebug() << "Signal was not in this frame";
continue;
}
if (!params.associatedSignal->processAsDouble(frameCache[k], y)) {
continue;
}
tempVal = Utility::processIntegerSignal(frameCache[k].payload(), sBit, bits, intelFormat, isSigned); //& params.mask;
//qDebug() << tempVal;
y = (tempVal * params.scale) + params.bias;
params.y.append( y );
params.y.append(y);

if (Utility::timeStyle == TS_SECONDS)
{
Expand All @@ -1399,18 +1403,18 @@ void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)

params.x.append( x );

if (params.associatedSignal && numEntries > 1)
if (numEntries > 1)
{

bool isValid = params.associatedSignal->getValueString(tempVal, tempStr);
bool isValid = params.associatedSignal->getValueString(y, tempStr);
if (isValid)
{
if (params.prevValLocation == QPointF(0,0)) {
params.prevValLocation = QPointF(x, y);
params.prevValStr = tempStr;
params.prevValTable = 0;
}
if (tempVal != params.prevValTable)
if (y != params.prevValTable)
{
qDebug() << "New Value: " << tempStr;

Expand Down Expand Up @@ -1438,7 +1442,7 @@ void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
params.prevValStr = tempStr;
params.lastBracket = bracket;
}
params.prevValTable = tempVal;
params.prevValTable = y;
}
}

Expand All @@ -1464,7 +1468,7 @@ void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
valueText->setFont(QFont(font().family(), 10));
params.prevValLocation = QPointF(x, y);
params.prevValStr = tempStr;
params.prevValTable = tempVal;
params.prevValTable = y;
params.lastBracket = bracket;
}

Expand Down