source: flair-src/trunk/tools/FlairGCS/src/DataRemote.cpp@ 129

Last change on this file since 129 was 67, checked in by Sanahuja Guillaume, 8 years ago

corrections bugs checkpoint map

File size: 2.6 KB
RevLine 
[10]1// %flair:license{
[15]2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
[10]4// %flair:license}
[9]5#include "DataRemote.h"
6#include <QMenu>
7#include <QInputDialog>
8#include <QtXml>
9#include "Manager.h"
10#include "ConnectionLayout.h"
11
[15]12DataRemote::DataRemote(QString name, QString type, XmlWidget *parent,
13 bool enabled, int period)
14 : XmlWidget(name, type, parent) {
15 auto_refresh = enabled;
16 is_logging = true;
17 receivesize = 0;
18 refresh_rate = (double)period / 1000.;
[9]19
[15]20 connectionLayout()->addDataRemote(this);
[9]21
[15]22 // pour ne pas faire de doublons qd on change la periode
23 SetIsExpandable(true);
[9]24}
25
[15]26DataRemote::~DataRemote() { connectionLayout()->removeDataRemote(this); }
[9]27
[15]28void DataRemote::appendmenu(QMenu *menu) {
29 menu->addSeparator();
[9]30
[15]31 b = menu->addAction("auto refresh");
32 b->setCheckable(true);
33 b->setChecked(auto_refresh);
[9]34
[15]35 c = menu->addAction(QString("set refresh rate (%1ms)")
36 .arg((uint16_t)(qRound(refresh_rate * 1000))));
37 c->setEnabled(auto_refresh);
38 menu->addSeparator();
[9]39
[15]40 d = menu->addAction("log");
41 d->setCheckable(true);
42 d->setChecked(is_logging);
[9]43}
44
[15]45QAction *DataRemote::execmenu(QWidget *parent, QMenu *menu, QPoint point) {
46 QAction *z;
[9]47
[15]48 z = menu->exec(point);
[9]49
[15]50 // auto_refresh=b->isChecked();
[9]51
[15]52 if (z == b) {
53 SendPeriod(RefreshRate_ms(), b->isChecked());
54 }
[9]55
[15]56 if (z == c) {
57 bool ok;
58 // uint16_t time = QInputDialog::getInt(this, QString("Set refresh rate
59 // (%1)").arg(title().text()),tr("Value (ms):"),
60 // (uint16_t)(qRound(refresh_rate*1000)), 1, 65535, 10, &ok);
61 uint16_t time = QInputDialog::getInt(
62 parent, "Set refresh rate ", "Value (ms):",
63 (uint16_t)(qRound(refresh_rate * 1000)), 1, 65535, 10, &ok);
64 if (ok == true && time != qRound(refresh_rate * 1000)) {
65 // refresh_rate=time/1000.;
66 SendPeriod(time, b->isChecked());
[9]67 }
[15]68 }
[9]69
[15]70 return z;
[9]71}
72
73uint16_t DataRemote::RefreshRate_ms(void) {
[15]74 return (uint16_t)(qRound(refresh_rate * 1000.));
[9]75}
76
[15]77bool DataRemote::IsEnabled(void) { return auto_refresh; }
[9]78
[15]79void DataRemote::SendPeriod(int period, bool auto_refresh) {
[67]80 RemoveAllAttributes();
81
[15]82 SetAttribute("period", period);
83 SetAttribute("enabled", auto_refresh);
[9]84
[15]85 connectionLayout()->XmlToSend(XmlDoc());
[9]86
[15]87 RemoveAttribute("period");
88 RemoveAttribute("enabled");
[9]89}
90
[15]91int DataRemote::ReceiveSize(void) { return receivesize; }
[9]92
93void DataRemote::XmlSetup(QDomElement dom) {
[15]94 refresh_rate = dom.attribute("period").toInt() / 1000.;
95 if (dom.attribute("enabled") == "1")
96 auto_refresh = true;
97 else
98 auto_refresh = false;
[9]99}
Note: See TracBrowser for help on using the repository browser.