source: flair-src/trunk/lib/FlairCore/src/SendData.cpp@ 437

Last change on this file since 437 was 437, checked in by Sanahuja Guillaume, 5 months ago

prepare for graphs buffering

File size: 3.7 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5// created: 2012/03/07
6// filename: SendData.cpp
7//
8// author: Guillaume Sanahuja
9// Copyright Heudiasyc UMR UTC/CNRS 7253
10//
11// version: $Id: $
12//
13// purpose: Abstract class for sending datas to ground station
14//
15//
16/*********************************************************************/
17
18#include "SendData.h"
19#include "SendData_impl.h"
20#include "Layout.h"
21#include "LayoutPosition.h"
22#include "FrameworkManager.h"
23#include "FrameworkManager_impl.h"
24
25using namespace std;
26using namespace flair::core;
27
28namespace flair {
29namespace gui {
30
31SendData::SendData(const LayoutPosition *position, string name, string type,
32 uint16_t default_periodms, bool default_enabled, uint16_t default_nb_buffering)
33 : Widget(position->getLayout(), name, type) {
34 pimpl_ = new SendData_impl();
35
36 pimpl_->send_size = 0;
37
38 // default refesh rate: (ms)
39 pimpl_->send_period = default_periodms;
40 pimpl_->is_enabled = default_enabled;
41 pimpl_->nb_buffering = default_nb_buffering;
42
43 SetVolatileXmlProp("row", position->Row());
44 SetVolatileXmlProp("col", position->Col());
45 GetPersistentXmlProp("period", pimpl_->send_period);
46 SetPersistentXmlProp("period", pimpl_->send_period);
47 GetPersistentXmlProp("enabled", pimpl_->is_enabled);
48 SetPersistentXmlProp("enabled", pimpl_->is_enabled);
49 GetPersistentXmlProp("nb_buf", pimpl_->nb_buffering);
50 SetPersistentXmlProp("nb_buf", pimpl_->nb_buffering);
51
52 delete position;
53
54 if (getUiCom() != NULL) {
55 // register SendData for sending to ground station
56 getUiCom()->AddSendData(this);
57 // resume if necessary
58 getUiCom()->UpdateSendData(this);
59 }
60}
61
62SendData::~SendData() {
63 if (getUiCom() != NULL) {
64 // unregister SendData for sending to ground station
65 getUiCom()->RemoveSendData(this);
66 }
67
68 delete pimpl_;
69}
70
71void SendData::XmlEvent(void) {
72 uint16_t send_period,nb_buffering;
73 bool is_enabled;
74 bool something_changed = false;
75
76 if (GetPersistentXmlProp("period", send_period) && GetPersistentXmlProp("enabled", is_enabled) && GetPersistentXmlProp("nb_buf", nb_buffering)) {
77 if (send_period != SendPeriod())
78 something_changed = true;
79 if (is_enabled != IsEnabled())
80 something_changed = true;
81 }
82
83 if (GetPersistentXmlProp("nb_buf", nb_buffering)) {
84 if (nb_buffering != NbBuffering())
85 something_changed = true;
86 }
87
88 if (something_changed) {
89 getFrameworkManager()->BlockCom();
90
91 SetSendPeriod(send_period);
92 SetEnabled(is_enabled);
93 SetNbBuffering(nb_buffering);
94
95 getFrameworkManager()->UpdateSendData(this);
96
97 // ack pour la station sol
98 // period and enabled are already in persistent prop
99 SetVolatileXmlProp("period", send_period);
100 SetVolatileXmlProp("enabled", is_enabled);
101 SetVolatileXmlProp("nb_buf", nb_buffering);
102 SendXml();
103
104 getFrameworkManager()->UnBlockCom();
105 }
106
107 ExtraXmlEvent();
108}
109
110size_t SendData::SendSize(void) const { return pimpl_->send_size; }
111
112uint16_t SendData::SendPeriod(void) const { return pimpl_->send_period; }
113
114uint16_t SendData::NbBuffering(void) const { return pimpl_->nb_buffering; }
115
116bool SendData::IsEnabled(void) const { return pimpl_->is_enabled; }
117
118void SendData::SetEnabled(bool value) { pimpl_->is_enabled = value; }
119
120void SendData::SetSendSize(size_t value) {
121 pimpl_->send_size = value;
122
123 if (getUiCom() != NULL)
124 getUiCom()->UpdateDataToSendSize();
125}
126
127void SendData::SetSendPeriod(uint16_t value) { pimpl_->send_period = value; }
128
129void SendData::SetNbBuffering(uint16_t value) { pimpl_->nb_buffering = value; }
130
131} // end namespace core
132} // end namespace flair
Note: See TracBrowser for help on using the repository browser.