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
|
/**
* @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 dltsystemviewerplugin.cpp
* For further information see http://www.covesa.global/.
* @licence end@
*/
#include <QtGui>
#include "dltsystemviewerplugin.h"
#define PROC_STAT_NODE_1 1
#define PROC_STAT_NODE_UNDEFINE -1
DltSystemViewerPlugin::DltSystemViewerPlugin()
{
form = NULL;
counterMessages = 0;
counterNonVerboseMessages = 0;
counterVerboseMessages = 0;
lastValueUser = 0;
lastValueNice = 0;
lastValueKernel = 0;
lastTimeStamp = 0;
dltFile = NULL;
}
DltSystemViewerPlugin::~DltSystemViewerPlugin()
{
}
QString DltSystemViewerPlugin::name()
{
return QString("DLT System Viewer Plugin");
}
QString DltSystemViewerPlugin::pluginVersion(){
return DLT_SYSTEM_VIEWER_PLUGIN_VERSION;
}
QString DltSystemViewerPlugin::pluginInterfaceVersion(){
return PLUGIN_INTERFACE_VERSION;
}
QString DltSystemViewerPlugin::description()
{
return QString();
}
QString DltSystemViewerPlugin::error()
{
return QString();
}
bool DltSystemViewerPlugin::loadConfig(QString /* filename */)
{
return true;
}
bool DltSystemViewerPlugin::saveConfig(QString /* filename */)
{
return true;
}
QStringList DltSystemViewerPlugin::infoConfig()
{
return QStringList();
}
QWidget* DltSystemViewerPlugin::initViewer()
{
form = new DltSystemViewer::Form();
return form;
}
void DltSystemViewerPlugin::selectedIdxMsg(int , QDltMsg &) {
//empty. Implemented because derived plugin interface functions are virtual.
}
void DltSystemViewerPlugin::selectedIdxMsgDecoded(int , QDltMsg &){
//empty. Implemented because derived plugin interface functions are virtual.
}
void DltSystemViewerPlugin::initFileStart(QDltFile *file){
dltFile = file;
counterMessages = dltFile->size();
form->deleteAllProccesses();
}
void DltSystemViewerPlugin::initMsg(int index, QDltMsg &msg){
updateProcesses(index, msg);
}
void DltSystemViewerPlugin::initMsgDecoded(int , QDltMsg &){
//empty. Implemented because derived plugin interface functions are virtual.
}
void DltSystemViewerPlugin::initFileFinish(){
}
void DltSystemViewerPlugin::updateFileStart(){
}
void DltSystemViewerPlugin::updateMsg(int index, QDltMsg &msg){
if(!dltFile)
return;
updateProcesses(index, msg);
counterMessages = dltFile->size();
}
void DltSystemViewerPlugin::updateMsgDecoded(int , QDltMsg &){
//empty. Implemented because derived plugin interface functions are virtual.
}
void DltSystemViewerPlugin::updateFileFinish(){
}
void DltSystemViewerPlugin::updateProcesses(int , QDltMsg &msg)
{
QStringList datalist;
QDltArgument arg;
int pid,seq;
if(!dltFile)
return;
if(msg.getMode() == QDltMsg::DltModeVerbose)
{
counterVerboseMessages++;
}
if(msg.getMode() == QDltMsg::DltModeNonVerbose)
{
counterNonVerboseMessages++;
}
if(msg.getApid()=="SYS" && msg.getCtid()=="PROC") {
msg.getArgument(0,arg);
pid = arg.toString().toInt();
msg.getArgument(1,arg);
if(arg.toString()=="stat") {
msg.getArgument(2,arg);
form->addProcesses(pid,arg.toString(),msg);
}
}
if(msg.getApid()=="SYS" && msg.getCtid()=="STAT") {
msg.getArgument(0,arg);
seq = arg.toString().toInt();
if( seq == PROC_STAT_NODE_1 || seq == PROC_STAT_NODE_UNDEFINE ) {
msg.getArgument(1,arg);
datalist = arg.toString().split(" ");
form->setUser(QString("%1").arg(((datalist.at(2).toInt())-lastValueUser)*10000/(msg.getTimestamp()-lastTimeStamp)));
form->setNice(QString("%1").arg(((datalist.at(3).toInt())-lastValueNice)*10000/(msg.getTimestamp()-lastTimeStamp)));
form->setSystem(QString("%1").arg(((datalist.at(4).toInt())-lastValueKernel)*10000/(msg.getTimestamp()-lastTimeStamp)));
lastValueUser = datalist.at(2).toInt();
lastValueNice = datalist.at(3).toInt();;
lastValueKernel = datalist.at(4).toInt();;
lastTimeStamp = msg.getTimestamp();
}
}
}
#ifndef QT5
Q_EXPORT_PLUGIN2(dltsystemviewerplugin, DltSystemViewerPlugin);
#endif
|