source: pacpussensors/trunk/CanGateway/DbtRawCanReader.cpp

Last change on this file was 106, checked in by DHERBOMEZ Gérald, 9 years ago

add verbose display in decoder can

File size: 2.0 KB
Line 
1/*********************************************************************
2// created: 2011/04/26
3// filename: DbtRawCanReader.cpp
4//
5// author: Gerald Dherbomez
6// Copyright Heudiasyc UMR UTC/CNRS 7253
7//
8// version: $Id: DbtRawCanReader.cpp 1182 2012-07-05 16:42:32Z kurdejma $
9//
10// purpose:
11*********************************************************************/
12
13
14#include "Pacpus/kernel/ComponentFactory.h"
15#include "Pacpus/kernel/DbiteFileTypes.h"
16#include "Pacpus/kernel/Log.h"
17
18#include "Pacpus/kernel/road_time.h"
19
20using namespace pacpus;
21using namespace std;
22
23#include "DbtRawCanReader.h"
24
25DECLARE_STATIC_LOGGER("pacpus.base.DbtRawCanReader");
26
27/// Component factory for DbtRawCanReader
28static ComponentFactory<DbtRawCanReader> sFactory("DbtRawCanReader");
29
30/// Constructor
31DbtRawCanReader::DbtRawCanReader(QString name)
32 : ComponentBase(name)
33{
34}
35
36/// Destructor
37DbtRawCanReader::~DbtRawCanReader()
38{
39}
40
41/// Configures the component
42ComponentBase::COMPONENT_CONFIGURATION DbtRawCanReader::configureComponent(XmlComponentConfig config)
43{
44 dbtFileName_ = config.getProperty("dbt");
45
46 return ComponentBase::CONFIGURED_OK;
47}
48
49/// Starts the component
50void DbtRawCanReader::startActivity()
51{
52 start();
53}
54
55/// Stops the component
56void DbtRawCanReader::stopActivity()
57{
58
59}
60
61void DbtRawCanReader::run()
62{
63 road_time_t time;
64 road_timerange_t tr;
65 CanFrame dbtData;
66 TimestampedCanFrame dataToDecode;
67
68 // create the DBT file
69 dbtFile_.open(dbtFileName_.toStdString(), ReadMode);
70
71 LOG_INFO("DBT file opened for reading");
72
73 for (;;)
74 {
75 if ( !dbtFile_.readRecord(time, tr, reinterpret_cast<char *>(&dbtData) ) )
76 break;
77 dataToDecode.frame = dbtData;
78 dataToDecode.time = time;
79 dataToDecode.timerange = tr;
80
81 if (isOutputVerbose()) displayData(dataToDecode.frame.data, dataToDecode.frame.dlc, dataToDecode.frame.id);
82
83 dispatchCanFrame(dataToDecode);
84 }
85
86 LOG_INFO("reading finished");
87
88 dbtFile_.close();
89
90}
Note: See TracBrowser for help on using the repository browser.