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 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342
|
/**
* @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);
/* Show DLTv2 Details */
text = QString("<html><body>");
if(msg.getVersionNumber()==2)
{
text += QString("<h4>Base Header</h4>");
text += QString("With Session Id: %1<br>").arg(msg.getWithSessionId());
text += QString("With App Context Id: %1<br>").arg(msg.getWithAppContextId());
text += QString("With Ecu Id: %1<br>").arg(msg.getWithEcuId());
text += QString("With Message Info: %1<br>").arg(msg.getWithHFMessageInfo());
text += QString("With Number Of Arguments: %1<br>").arg(msg.getWithHFNumberOfArguments());
text += QString("With Timestamp: %1<br>").arg(msg.getWithHFTimestamp());
text += QString("With Message Id: %1<br>").arg(msg.getWithHFMessageId());
if(msg.getContentInformation()==0)
{
text += QString("Content Information: verbose<br>");
}
else if(msg.getContentInformation()==1)
{
text += QString("Content Information: none verbose<br>");
}
else if(msg.getContentInformation()==2)
{
text += QString("Content Information: control<br>");
}
else
{
text += QString("Content Information: unknown value 3<br>");
}
text += QString("With Segementation: %1<br>").arg(msg.getWithSegementation());
text += QString("With PrivacyLevel: %1<br>").arg(msg.getWithPrivacyLevel());
text += QString("With Tags: %1<br>").arg(msg.getWithTags());
text += QString("With Source File Name and Line Number: %1<br>").arg(msg.getWithSourceFileNameLineNumber());
text += QString("Message Counter: %1<br>").arg(msg.getMessageCounter());
text += QString("Message Info: %1<br>").arg(msg.getTypeString());
text += QString("Message Type: %1<br>").arg(msg.getSubtypeString());
if(msg.getWithHFNumberOfArguments())
{
text += QString("Number Of Arguments: %1<br>").arg(msg.getNumberOfArguments());
}
if(msg.getWithHFTimestamp())
{
text += QString("Timestamp Nanoseconds: %1<br>").arg(msg.getTimestampNanoseconds());
text += QString("Timestamp Seconds: %1<br>").arg(msg.getTimestampSeconds());
}
if(msg.getWithHFMessageId())
{
text += QString("Message Id: %1<br>").arg(msg.getMessageId());
}
text += QString("<h4>Extension Header</h4>");
if(msg.getWithEcuId())
{
text += QString("ECU Id: %1<br>").arg(msg.getEcuid());
}
if(msg.getWithAppContextId())
{
text += QString("App Id: %1<br>").arg(msg.getApid());
text += QString("Ctx Id: %1<br>").arg(msg.getCtid());
}
if(msg.getWithSessionId())
{
text += QString("Session Id: %1<br>").arg(msg.getSessionid());
}
if(msg.getWithSourceFileNameLineNumber())
{
text += QString("Source File Name: %1<br>").arg(msg.getSourceFileName());
text += QString("Line Number: %1<br>").arg(msg.getLineNumber());
}
if(msg.getWithTags())
{
text += QString("Tags: %1<br>").arg(msg.getTags().join(','));
}
if(msg.getWithPrivacyLevel())
{
text += QString("Privacy Level: %1<br>").arg(msg.getPrivacyLevel());
}
if(msg.getWithSegementation())
{
if(msg.getSegmentationFrameType()==0)
{
text += QString("Segmentation Frame Type: First Frame<br>");
text += QString("Segmentation Total Length: %1<br>").arg(msg.getSegmentationTotalLength());
}
else if(msg.getSegmentationFrameType()==1)
{
text += QString("Segmentation Frame Type: Consecutive Frame<br>");
text += QString("Segmentation Consecutive Frame: %1<br>").arg(msg.getSegmentationConsecutiveFrame());
}
else if(msg.getSegmentationFrameType()==2)
{
text += QString("Segmentation Frame Type: Las tFrame<br>");
}
else if(msg.getSegmentationFrameType()==3)
{
text += QString("Segmentation Frame Type: Abort Frame<br>");
text += QString("Segmentation Abort Reason: %1<br>").arg(msg.getSegmentationAbortReason());
}
else
{
text += QString("Segmentation Frame Type: Unknown value %1<br>").arg(msg.getSegmentationFrameType());
}
}
text += QString("<h4>Payload</h4>");
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>");
}
else
{
text += "No DLTv2 message!";
}
text += QString("</body></html>");
form->setTextBrowserDltV2(text);
/* get binary payload */
QByteArray bytes_header = msg.getHeader();
QByteArray bytes_payload = msg.getPayload();
/* Show Ascii output */
form->setTextBrowserAscii(QDlt::toAsciiTable(bytes_header,false,false,true,8,64)+QDlt::toAsciiTable(bytes_payload,false,false,true,8,64));
/* Show Binary output */
form->setTextBrowserBinary(QDlt::toAsciiTable(bytes_header,true,true,false)+QDlt::toAsciiTable(bytes_payload,true,true,false));
/* Show Mixed output */
form->setTextBrowserMixed(QDlt::toAsciiTable(bytes_header,true,true,true)+QDlt::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;
}
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
Q_EXPORT_PLUGIN2(dltviewerplugin, DltViewerPlugin);
#endif
|