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
RevLine 
[2]1// %flair:license{
[15]2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
[2]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
[15]28namespace flair {
29namespace gui {
[2]30
[15]31SendData::SendData(const LayoutPosition *position, string name, string type,
[437]32 uint16_t default_periodms, bool default_enabled, uint16_t default_nb_buffering)
[15]33 : Widget(position->getLayout(), name, type) {
34 pimpl_ = new SendData_impl();
[2]35
[15]36 pimpl_->send_size = 0;
[2]37
[15]38 // default refesh rate: (ms)
39 pimpl_->send_period = default_periodms;
40 pimpl_->is_enabled = default_enabled;
[437]41 pimpl_->nb_buffering = default_nb_buffering;
[2]42
[15]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);
[437]49 GetPersistentXmlProp("nb_buf", pimpl_->nb_buffering);
50 SetPersistentXmlProp("nb_buf", pimpl_->nb_buffering);
[2]51
[15]52 delete position;
[2]53
[15]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 }
[2]60}
61
62SendData::~SendData() {
[15]63 if (getUiCom() != NULL) {
64 // unregister SendData for sending to ground station
65 getUiCom()->RemoveSendData(this);
66 }
[2]67
[15]68 delete pimpl_;
[2]69}
70
71void SendData::XmlEvent(void) {
[437]72 uint16_t send_period,nb_buffering;
[15]73 bool is_enabled;
74 bool something_changed = false;
[2]75
[437]76 if (GetPersistentXmlProp("period", send_period) && GetPersistentXmlProp("enabled", is_enabled) && GetPersistentXmlProp("nb_buf", nb_buffering)) {
[15]77 if (send_period != SendPeriod())
78 something_changed = true;
79 if (is_enabled != IsEnabled())
80 something_changed = true;
81 }
[437]82
83 if (GetPersistentXmlProp("nb_buf", nb_buffering)) {
84 if (nb_buffering != NbBuffering())
85 something_changed = true;
86 }
[2]87
[15]88 if (something_changed) {
89 getFrameworkManager()->BlockCom();
[2]90
[15]91 SetSendPeriod(send_period);
92 SetEnabled(is_enabled);
[437]93 SetNbBuffering(nb_buffering);
[2]94
[15]95 getFrameworkManager()->UpdateSendData(this);
[2]96
[15]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);
[437]101 SetVolatileXmlProp("nb_buf", nb_buffering);
[15]102 SendXml();
[2]103
[15]104 getFrameworkManager()->UnBlockCom();
105 }
[2]106
[15]107 ExtraXmlEvent();
[2]108}
109
[15]110size_t SendData::SendSize(void) const { return pimpl_->send_size; }
[2]111
[15]112uint16_t SendData::SendPeriod(void) const { return pimpl_->send_period; }
[2]113
[437]114uint16_t SendData::NbBuffering(void) const { return pimpl_->nb_buffering; }
115
[15]116bool SendData::IsEnabled(void) const { return pimpl_->is_enabled; }
[2]117
[15]118void SendData::SetEnabled(bool value) { pimpl_->is_enabled = value; }
[2]119
120void SendData::SetSendSize(size_t value) {
[15]121 pimpl_->send_size = value;
[2]122
[15]123 if (getUiCom() != NULL)
124 getUiCom()->UpdateDataToSendSize();
[2]125}
126
[15]127void SendData::SetSendPeriod(uint16_t value) { pimpl_->send_period = value; }
[2]128
[437]129void SendData::SetNbBuffering(uint16_t value) { pimpl_->nb_buffering = value; }
130
[2]131} // end namespace core
132} // end namespace flair
Note: See TracBrowser for help on using the repository browser.