| 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 |
|
---|
| 25 | using namespace std;
|
---|
| 26 | using namespace flair::core;
|
---|
| 27 |
|
---|
| 28 | namespace flair
|
---|
| 29 | {
|
---|
| 30 | namespace gui
|
---|
| 31 | {
|
---|
| 32 |
|
---|
| 33 | SendData::SendData(const LayoutPosition* position,string name,string type,uint16_t default_periodms,bool default_enabled) :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 |
|
---|
| 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);
|
---|
| 48 |
|
---|
| 49 | delete position;
|
---|
| 50 |
|
---|
| 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 | }
|
---|
| 57 | }
|
---|
| 58 |
|
---|
| 59 | SendData::~SendData() {
|
---|
| 60 | if(getUiCom()!=NULL) {
|
---|
| 61 | //unregister SendData for sending to ground station
|
---|
| 62 | getUiCom()->RemoveSendData(this);
|
---|
| 63 | }
|
---|
| 64 |
|
---|
| 65 | delete pimpl_;
|
---|
| 66 | }
|
---|
| 67 |
|
---|
| 68 | void SendData::XmlEvent(void) {
|
---|
| 69 | uint16_t send_period;
|
---|
| 70 | bool is_enabled;
|
---|
| 71 | bool something_changed=false;
|
---|
| 72 |
|
---|
| 73 | if(GetPersistentXmlProp("period",send_period) && GetPersistentXmlProp("enabled",is_enabled)) {
|
---|
| 74 | if(send_period!=SendPeriod()) something_changed=true;
|
---|
| 75 | if(is_enabled!=IsEnabled()) something_changed=true;
|
---|
| 76 | }
|
---|
| 77 |
|
---|
| 78 | if(something_changed) {
|
---|
| 79 | getFrameworkManager()->BlockCom();
|
---|
| 80 |
|
---|
| 81 | SetSendPeriod(send_period);
|
---|
| 82 | SetEnabled(is_enabled);
|
---|
| 83 |
|
---|
| 84 | getFrameworkManager()->UpdateSendData(this);
|
---|
| 85 |
|
---|
| 86 | //ack pour la station sol
|
---|
| 87 | //period and enabled are already in persistent prop
|
---|
| 88 | SetVolatileXmlProp("period",send_period);
|
---|
| 89 | SetVolatileXmlProp("enabled",is_enabled);
|
---|
| 90 | SendXml();
|
---|
| 91 |
|
---|
| 92 | getFrameworkManager()->UnBlockCom();
|
---|
| 93 | }
|
---|
| 94 |
|
---|
| 95 | ExtraXmlEvent();
|
---|
| 96 | }
|
---|
| 97 |
|
---|
| 98 | size_t SendData::SendSize(void) const {
|
---|
| 99 | return pimpl_->send_size;
|
---|
| 100 | }
|
---|
| 101 |
|
---|
| 102 | uint16_t SendData::SendPeriod(void) const {
|
---|
| 103 | return pimpl_->send_period;
|
---|
| 104 | }
|
---|
| 105 |
|
---|
| 106 | bool SendData::IsEnabled(void) const {
|
---|
| 107 | return pimpl_->is_enabled;
|
---|
| 108 | }
|
---|
| 109 |
|
---|
| 110 | void SendData::SetEnabled(bool value) {
|
---|
| 111 | pimpl_->is_enabled=value;
|
---|
| 112 | }
|
---|
| 113 |
|
---|
| 114 | void SendData::SetSendSize(size_t value) {
|
---|
| 115 | pimpl_->send_size=value;
|
---|
| 116 |
|
---|
| 117 | if(getUiCom()!=NULL) getUiCom()->UpdateDataToSendSize();
|
---|
| 118 | }
|
---|
| 119 |
|
---|
| 120 | void SendData::SetSendPeriod(uint16_t value) {
|
---|
| 121 | pimpl_->send_period=value;
|
---|
| 122 | }
|
---|
| 123 |
|
---|
| 124 | } // end namespace core
|
---|
| 125 | } // end namespace flair
|
---|