source: pacpussensors/trunk/PacpusSocket/StringGenerator.cpp@ 126

Last change on this file since 126 was 126, checked in by DHERBOMEZ Gérald, 8 years ago

StringGenerator component added to test PacpusUDPSocket
XML file to test provided

File size: 3.1 KB
Line 
1/*********************************************************************
2// created: 2016/05/13
3// filename: StringGenerator.cpp
4//
5// author: Gerald Dherbomez
6// Copyright Heudiasyc UMR UTC/CNRS 7253
7//
8// version: $Id: $
9//
10// purpose: A component that generates a string
11//
12*********************************************************************/
13
14#include "StringGenerator.h"
15
16using namespace pacpus;
17
18
19DECLARE_STATIC_LOGGER("pacpusensors.StringGenerator");
20
21
22//////////////////////////////////////////////////////////////////////////
23// Construct the factory
24//////////////////////////////////////////////////////////////////////////
25static ComponentFactory <StringGenerator> sFactory("StringGenerator");
26
27
28//////////////////////////////////////////////////////////////////////////
29// Constructeur
30//////////////////////////////////////////////////////////////////////////
31StringGenerator::StringGenerator(QString name)
32 : ComponentBase(name)
33{
34}
35
36
37//////////////////////////////////////////////////////////////////////////
38// Destructor
39//////////////////////////////////////////////////////////////////////////
40StringGenerator::~StringGenerator()
41{
42}
43
44
45////////////////////////////////////////////////////////////////////////////////
46// AddOutputs
47////////////////////////////////////////////////////////////////////////////////
48void StringGenerator::addOutputs()
49{
50 addOutput<QString, StringGenerator>("string");
51}
52
53
54////////////////////////////////////////////////////////////////////////////////
55// AddInputs
56////////////////////////////////////////////////////////////////////////////////
57void StringGenerator::addInputs()
58{
59}
60
61
62//////////////////////////////////////////////////////////////////////////
63// Called by the ComponentManager to pass the XML parameters to the
64// component
65//////////////////////////////////////////////////////////////////////////
66ComponentBase::COMPONENT_CONFIGURATION StringGenerator::configureComponent(XmlComponentConfig config)
67{
68
69 return ComponentBase::CONFIGURED_OK;
70}
71
72
73//////////////////////////////////////////////////////////////////////////
74// Called by the ComponentManager to start the component
75//////////////////////////////////////////////////////////////////////////
76void StringGenerator::startActivity()
77{
78 stringOutput_ = getTypedOutput<QString, StringGenerator>("string");
79
80 QTimer *timer_ = new QTimer(this);
81
82 connect(timer_, SIGNAL(timeout()), this, SLOT(sendData()));
83
84 timer_->start(1000);
85
86}
87
88
89//////////////////////////////////////////////////////////////////////////
90// Called by the ComponentManager to stop the component
91//////////////////////////////////////////////////////////////////////////
92void StringGenerator::stopActivity()
93{
94
95
96}
97
98//////////////////////////////////////////////////////////////////////////
99// Send data at the output
100//////////////////////////////////////////////////////////////////////////
101void StringGenerator::sendData()
102{
103
104 LOG_INFO("TIMEOUT EXPIRED");
105
106 if (stringOutput_ && stringOutput_->hasConnection())
107 stringOutput_->send(QString("Test"));
108
109}
110
Note: See TracBrowser for help on using the repository browser.