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

Last change on this file since 302 was 15, checked in by Bayard Gildas, 8 years ago

sources reformatted with flair-format-dir script

File size: 3.1 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,
32 uint16_t default_periodms, bool default_enabled)
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;
[2]41
[15]42 SetVolatileXmlProp("row", position->Row());
43 SetVolatileXmlProp("col", position->Col());
44 GetPersistentXmlProp("period", pimpl_->send_period);
45 SetPersistentXmlProp("period", pimpl_->send_period);
46 GetPersistentXmlProp("enabled", pimpl_->is_enabled);
47 SetPersistentXmlProp("enabled", pimpl_->is_enabled);
[2]48
[15]49 delete position;
[2]50
[15]51 if (getUiCom() != NULL) {
52 // register SendData for sending to ground station
53 getUiCom()->AddSendData(this);
54 // resume if necessary
55 getUiCom()->UpdateSendData(this);
56 }
[2]57}
58
59SendData::~SendData() {
[15]60 if (getUiCom() != NULL) {
61 // unregister SendData for sending to ground station
62 getUiCom()->RemoveSendData(this);
63 }
[2]64
[15]65 delete pimpl_;
[2]66}
67
68void SendData::XmlEvent(void) {
[15]69 uint16_t send_period;
70 bool is_enabled;
71 bool something_changed = false;
[2]72
[15]73 if (GetPersistentXmlProp("period", send_period) &&
74 GetPersistentXmlProp("enabled", is_enabled)) {
75 if (send_period != SendPeriod())
76 something_changed = true;
77 if (is_enabled != IsEnabled())
78 something_changed = true;
79 }
[2]80
[15]81 if (something_changed) {
82 getFrameworkManager()->BlockCom();
[2]83
[15]84 SetSendPeriod(send_period);
85 SetEnabled(is_enabled);
[2]86
[15]87 getFrameworkManager()->UpdateSendData(this);
[2]88
[15]89 // ack pour la station sol
90 // period and enabled are already in persistent prop
91 SetVolatileXmlProp("period", send_period);
92 SetVolatileXmlProp("enabled", is_enabled);
93 SendXml();
[2]94
[15]95 getFrameworkManager()->UnBlockCom();
96 }
[2]97
[15]98 ExtraXmlEvent();
[2]99}
100
[15]101size_t SendData::SendSize(void) const { return pimpl_->send_size; }
[2]102
[15]103uint16_t SendData::SendPeriod(void) const { return pimpl_->send_period; }
[2]104
[15]105bool SendData::IsEnabled(void) const { return pimpl_->is_enabled; }
[2]106
[15]107void SendData::SetEnabled(bool value) { pimpl_->is_enabled = value; }
[2]108
109void SendData::SetSendSize(size_t value) {
[15]110 pimpl_->send_size = value;
[2]111
[15]112 if (getUiCom() != NULL)
113 getUiCom()->UpdateDataToSendSize();
[2]114}
115
[15]116void SendData::SetSendPeriod(uint16_t value) { pimpl_->send_period = value; }
[2]117
118} // end namespace core
119} // end namespace flair
Note: See TracBrowser for help on using the repository browser.