source: pacpussensors/trunk/CanGateway/DbtRawCanReader.cpp@ 101

Last change on this file since 101 was 2, checked in by DHERBOMEZ Gérald, 11 years ago

correction of minor bugs (include and link). Build on Windows OK.

File size: 1.9 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 dispatchCanFrame(dataToDecode);
82 }
83
84 LOG_INFO("reading finished");
85
86 dbtFile_.close();
87
88}
Note: See TracBrowser for help on using the repository browser.