1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208
|
/**
* @licence app begin@
* Copyright (C) 2011-2012 BMW AG
*
* This file is part of COVESA Project Dlt Viewer.
*
* Contributions are licensed to the COVESA Alliance under one or more
* Contribution License Agreements.
*
* \copyright
* This Source Code Form is subject to the terms of the
* Mozilla Public License, v. 2.0. If a copy of the MPL was not distributed with
* this file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* \file dltviewerplugin.cpp
* For further information see http://www.covesa.global/.
* @licence end@
*/
#include <QtGui>
#include "dltviewerplugin.h"
DltViewerPlugin::DltViewerPlugin() {
form = NULL;
dltFile = 0;
}
DltViewerPlugin::~DltViewerPlugin() {
}
QString DltViewerPlugin::name()
{
return plugin_name_displayed;
}
QString DltViewerPlugin::pluginVersion(){
return DLT_VIEWER_PLUGIN_VERSION;
}
QString DltViewerPlugin::pluginInterfaceVersion(){
return PLUGIN_INTERFACE_VERSION;
}
QString DltViewerPlugin::description() {
return QString();
}
QString DltViewerPlugin::error() {
return QString();
}
bool DltViewerPlugin::loadConfig(QString /*filename*/) {
return true;
}
bool DltViewerPlugin::saveConfig(QString /*filename*/) {
return true;
}
QStringList DltViewerPlugin::infoConfig() {
return QStringList();
}
QWidget* DltViewerPlugin::initViewer() {
form = new DltViewer::Form();
return form;
}
void DltViewerPlugin::selectedIdxMsgDecoded(int , QDltMsg &msg){
/* Show Decoded output */
form->setTextBrowserMessage(msg.toStringHeader()+"<br><br>"+stringToHtml(msg.toStringPayload()));
}
void DltViewerPlugin::selectedIdxMsg(int index, QDltMsg &msg) {
QString text;
QDltArgument argument;
//if(!dltFile)
// return;
/* Show Payload*/
form->setTextBrowserUncoded(msg.toStringHeader()+"<br><br>"+stringToHtml(msg.toStringPayload()));
/* Show details */
text = QString("<html><body>");
text += QString("<h3>Header</h3>");
text += QString("<table border=\"1\" cellspacing=\"0\" cellheader=\"0\">");
//qDebug() << text;
text += QString("<tr><th>Index</th><th>Time</th><th>Timestamp</th><th>Count</th><th>Ecuid</th><th>Apid</th><th>Ctid</th><th>SessionId</th>");
text += QString("<th>Type</th><th>Subtype</th><th>Mode</th><th>Endianness</th><th>#Args</th></tr>");
//text += QString("<tr><td>%1</td>").arg(dltFile->getMsgFilterPos(index));
text += QString("<tr><td>%1</td>").arg(index);
text += QString("<td>%1.%2</td>").arg(msg.getTimeString()).arg(msg.getMicroseconds(),6,10,QLatin1Char('0'));
text += QString("<td>%1.%2</td>").arg(msg.getTimestamp()/10000).arg(msg.getTimestamp()%10000,4,10,QLatin1Char('0'));
text += QString("<td>%1</td>").arg(msg.getMessageCounter());
text += QString("<td>%1</td>").arg(msg.getEcuid());
text += QString("<td>%1</td>").arg(msg.getApid());
text += QString("<td>%1</td>").arg(msg.getCtid());
text += QString("<td>%1</td>").arg(msg.getSessionid());
text += QString("<td>%1</td>").arg(msg.getTypeString());
text += QString("<td>%1</td>").arg(msg.getSubtypeString());
text += QString("<td>%1</td>").arg(msg.getModeString());
text += QString("<td>%1</td>").arg(msg.getEndiannessString());
text += QString("<td>%1</td>").arg(msg.getNumberOfArguments());
text += QString("</tr></table>");
if(msg.getType()==QDltMsg::DltTypeControl) {
text += QString("<h3>Control Message</h3>");
text += QString("<table border=\"1\" cellspacing=\"0\" cellheader=\"0\">");
text += QString("<tr><th>MessageId</th><th>CtrlServiceId</th><th>CtrlReturnType</th></tr>");
text += QString("<tr>");
text += QString("<td>%1</td>").arg(msg.getMessageId());
text += QString("<td>%1</td>").arg(msg.getCtrlServiceIdString());
text += QString("<td>%1</td>").arg(msg.getCtrlReturnTypeString());
text += QString("</tr></table>");
}
else {
text += QString("<h3>Payload</h3>");
text += QString("<table border=\"1\" cellspacing=\"0\" cellheader=\"0\">");
text += QString("<tr><th>Index</th><th>Offest</th><th>Size</th><th>TypeInfo</th><th>Name</th><th>Unit</th><th>Text</th><th>Binary</th></tr>");
for(int num=0;num<msg.getNumberOfArguments();num++) {
text += QString("<tr>");
if(msg.getArgument(num,argument)) {
text += QString("<td>%1</td>").arg(num+1);
text += QString("<td>%1</td>").arg(argument.getOffsetPayload());
text += QString("<td>%1</td>").arg(argument.getDataSize());
text += QString("<td>%1</td>").arg(argument.getTypeInfoString());
text += QString("<td>%1</td>").arg(argument.getName());
text += QString("<td>%1</td>").arg(argument.getUnit());
text += QString("<td>");
// Necessary to display < and > as characters in a HTML context.
// Otherwise < and > would be handled as HTML tags and not the complete payload would be displayed.
text += stringToHtml(argument.toString());
text += QString("</td>");
text += QString("<td>");
text += argument.toString(true); /* Binary output */
text += QString("</td>");
}
text += QString("</tr>");
}
text += QString("</table>");
}
text += QString("</body></html>");
form->setTextBrowserDetails(text);
/* get binary payload */
QByteArray bytes_header = msg.getHeader();
QByteArray bytes_payload = msg.getPayload();
/* Show Ascii output */
form->setTextBrowserAscii(msg.toAsciiTable(bytes_header,false,false,true,8,64)+msg.toAsciiTable(bytes_payload,false,false,true,8,64));
/* Show Binary output */
form->setTextBrowserBinary(msg.toAsciiTable(bytes_header,true,true,false)+msg.toAsciiTable(bytes_payload,true,true,false));
/* Show Mixed output */
form->setTextBrowserMixed(msg.toAsciiTable(bytes_header,true,true,true)+msg.toAsciiTable(bytes_payload,true,true,true));
}
void DltViewerPlugin::initFileStart(QDltFile *file)
{
dltFile = file;
qDebug() << "Activate plugin" << plugin_name_displayed << DLT_VIEWER_PLUGIN_VERSION;
}
void DltViewerPlugin::initMsg(int /*index*/, QDltMsg & /*msg*/){
}
void DltViewerPlugin::initMsgDecoded(int , QDltMsg &){
//empty. Implemented because derived plugin interface functions are virtual.
}
void DltViewerPlugin::initFileFinish(){
}
void DltViewerPlugin::updateFileStart(){
//empty. Implemented because derived plugin interface functions are virtual.
}
void DltViewerPlugin::updateMsg(int /*index*/, QDltMsg &/*msg*/){
}
void DltViewerPlugin::updateMsgDecoded(int , QDltMsg &){
//empty. Implemented because derived plugin interface functions are virtual.
}
void DltViewerPlugin::updateFileFinish(){
}
QString DltViewerPlugin::stringToHtml(QString str)
{
str = str.replace("<","<");
str = str.replace(">",">");
return str;
}
#ifndef QT5
Q_EXPORT_PLUGIN2(dltviewerplugin, DltViewerPlugin);
#endif
|