Merge branch 'master' of github.com:collin80/SavvyCAN

This commit is contained in:
Collin Kidder
2017-08-25 12:54:19 -04:00
4 changed files with 57 additions and 13 deletions
+2
View File
@@ -169,12 +169,14 @@ void UDS_HANDLER::gotISOTPFrame(ISOTP_MESSAGE msg)
}
else return;
udsMsg.data = msg.data.mid(2, -1); //don't copy error byte nor service byte
udsMsg.len -= 2; //and remove those bytes from the length reported too.
}
else
{
udsMsg.isErrorReply = false;
if (msg.data.length() > 1) udsMsg.subFunc = msg.data.at(1);
udsMsg.data = msg.data.mid(1, -1); //don't copy service byte
udsMsg.len -= 1; //and remove service byte from length too.
}
}
else return;
+46 -12
View File
@@ -71,6 +71,7 @@ GraphingWindow::GraphingWindow(const QVector<CANFrame> *frames, QWidget *parent)
ui->graphingView->setOpenGl(true); //purdy and fast drawing courtesy of your video card - pretty everyone has 3D accel these days
needScaleSetup = true;
followGraphEnd = false;
}
GraphingWindow::~GraphingWindow()
@@ -164,6 +165,22 @@ void GraphingWindow::updatedFrames(int numFrames)
{
graphParams[j].ref->setData(graphParams[j].x, graphParams[j].y);
}
if (followGraphEnd)
{
//find the current X span and maintain that span but move the end of it over to match the new end
//of the actual graph. This causes the view to move with the data to always show the end
QCPRange range = ui->graphingView->xAxis->range();
double size = range.size();
bool foundRange;
QCPRange keyRange = ui->graphingView->graph()->getKeyRange(foundRange);
if (foundRange)
{
double end, start;
end = keyRange.upper;
start = end - size;
ui->graphingView->xAxis->setRange(start, end);
}
}
ui->graphingView->replot();
}
}
@@ -503,6 +520,11 @@ void GraphingWindow::removeAllGraphs()
}
}
void GraphingWindow::toggleFollowMode()
{
followGraphEnd = !followGraphEnd;
}
void GraphingWindow::contextMenuRequest(QPoint pos)
{
QMenu *menu = new QMenu(this);
@@ -522,6 +544,9 @@ void GraphingWindow::contextMenuRequest(QPoint pos)
menu->addAction(tr("Save graph definitions to file"), this, SLOT(saveDefinitions()));
menu->addAction(tr("Load graph definitions from file"), this, SLOT(loadDefinitions()));
menu->addAction(tr("Save spreadsheet of data"), this, SLOT(saveSpreadsheet()));
QAction *act = menu->addAction(tr("Follow end of graph"), this, SLOT(toggleFollowMode()));
act->setCheckable(true);
act->setChecked(followGraphEnd);
menu->addAction(tr("Add new graph"), this, SLOT(addNewGraph()));
if (ui->graphingView->selectedGraphs().size() > 0)
{
@@ -963,17 +988,25 @@ void GraphingWindow::addNewGraph()
void GraphingWindow::appendToGraph(GraphParams &params, CANFrame &frame)
{
int64_t tempVal; //64 bit temp value.
tempVal = Utility::processIntegerSignal(frame.data, params.startBit, params.numBits, params.intelFormat, params.isSigned); //& params.mask;
if (secondsMode)
params.strideSoFar++;
if (params.strideSoFar >= params.stride)
{
params.x.append((double)(frame.timestamp) / 1000000.0 - params.xbias);
params.strideSoFar = 0;
int64_t tempVal; //64 bit temp value.
tempVal = Utility::processIntegerSignal(frame.data, params.startBit, params.numBits, params.intelFormat, params.isSigned); //& params.mask;
double xVal, yVal;
if (secondsMode)
{
xVal = ((double)(frame.timestamp) / 1000000.0 - params.xbias);
}
else
{
xVal = (frame.timestamp - params.xbias);
}
yVal = (tempVal * params.scale) + params.bias;
params.x.append(xVal);
params.y.append(yVal);
}
else
{
params.x.append(frame.timestamp - params.xbias);
}
params.y.append((tempVal * params.scale) + params.bias);
}
void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
@@ -1013,15 +1046,16 @@ void GraphingWindow::createGraph(GraphParams &params, bool createGraphParam)
for (int j = 0; j < numEntries; j++)
{
tempVal = Utility::processIntegerSignal(frameCache[j * params.stride].data, sBit, bits, intelFormat, isSigned); //& params.mask;
int k = j * params.stride;
tempVal = Utility::processIntegerSignal(frameCache[k].data, sBit, bits, intelFormat, isSigned); //& params.mask;
//qDebug() << tempVal;
if (secondsMode)
{
params.x[j] = (double)(frameCache[j].timestamp) / 1000000.0;
params.x[j] = (double)(frameCache[k].timestamp) / 1000000.0;
}
else
{
params.x[j] = frameCache[j].timestamp;
params.x[j] = frameCache[k].timestamp;
}
params.y[j] = (tempVal * params.scale) + params.bias;
if (params.y[j] < yminval) yminval = params.y[j];
+3
View File
@@ -22,6 +22,7 @@ public:
float bias;
float scale;
int stride;
int strideSoFar;
QColor color;
QCPGraph *ref;
QString graphName;
@@ -56,6 +57,7 @@ private slots:
void saveSpreadsheet();
void saveDefinitions();
void loadDefinitions();
void toggleFollowMode();
void addNewGraph();
void createGraph(GraphParams &params, bool createGraphParam = true);
void appendToGraph(GraphParams &params, CANFrame &frame);
@@ -79,6 +81,7 @@ private:
QCPSelectionDecorator *selDecorator;
bool needScaleSetup; //do we need to set x,y graphing extents?
bool secondsMode;
bool followGraphEnd;
void showParamsDialog(int idx);
void closeEvent(QCloseEvent *event);
+6 -1
View File
@@ -49,6 +49,8 @@ void ScriptContainer::compileScript()
//Find out which callbacks the script has created.
setupFunction = scriptEngine.globalObject().property("setup");
canHelper->setRxCallback(scriptEngine.globalObject().property("gotCANFrame"));
isoHelper->setRxCallback(scriptEngine.globalObject().property("gotISOTPMessage"));
udsHelper->setRxCallback(scriptEngine.globalObject().property("gotUDSMessage"));
tickFunction = scriptEngine.globalObject().property("tick");
@@ -245,6 +247,7 @@ void ISOTPScriptHelper::setRxCallback(QJSValue cb)
void ISOTPScriptHelper::newISOMessage(ISOTP_MESSAGE msg)
{
qDebug() << "isotpScriptHelper got a ISOTP message";
if (!gotFrameFunction.isCallable()) return; //nothing to do if we can't even call the function
//qDebug() << "Got frame in script interface";
@@ -318,6 +321,8 @@ void UDSScriptHelper::setRxCallback(QJSValue cb)
void UDSScriptHelper::newUDSMessage(UDS_MESSAGE msg)
{
//qDebug() << "udsScriptHelper got a UDS message";
qDebug() << "UDS script helper. Meg data len: " << msg.len;
if (!gotFrameFunction.isCallable()) return; //nothing to do if we can't even call the function
//qDebug() << "Got frame in script interface";
@@ -325,7 +330,7 @@ void UDSScriptHelper::newUDSMessage(UDS_MESSAGE msg)
args << msg.bus << msg.ID << msg.service << msg.subFunc << msg.len;
QJSValue dataBytes = scriptEngine->newArray(msg.len);
for (unsigned int j = 0; j < msg.len; j++) dataBytes.setProperty(j, QJSValue(msg.data[j]));
for (unsigned int j = 0; j < msg.data.length(); j++) dataBytes.setProperty(j, QJSValue(msg.data[j]));
args.append(dataBytes);
gotFrameFunction.call(args);
}