OP-1900 have path_progress updated correctly for leg_remaining and error_below end...
[librepilot.git] / ground / openpilotgcs / src / plugins / uploader / uploadergadgetconfiguration.cpp
blob75f3de00ec3d2b11bf3f15904b6aa8361f40e080
1 /**
2 ******************************************************************************
4 * @file uploadergadgetconfiguration.cpp
5 * @author The OpenPilot Team, http://www.openpilot.org Copyright (C) 2010.
6 * @addtogroup GCSPlugins GCS Plugins
7 * @{
8 * @addtogroup YModemUploader YModem Serial Uploader Plugin
9 * @{
10 * @brief The YModem protocol serial uploader plugin
11 *****************************************************************************/
13 * This program is free software; you can redistribute it and/or modify
14 * it under the terms of the GNU General Public License as published by
15 * the Free Software Foundation; either version 3 of the License, or
16 * (at your option) any later version.
18 * This program is distributed in the hope that it will be useful, but
19 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
20 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
21 * for more details.
23 * You should have received a copy of the GNU General Public License along
24 * with this program; if not, write to the Free Software Foundation, Inc.,
25 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
28 #include "uploadergadgetconfiguration.h"
29 #include <QtSerialPort/QSerialPort>
30 #include <QtSerialPort/QSerialPortInfo>
32 /**
33 * Loads a saved configuration or defaults if non exist.
36 UploaderGadgetConfiguration::UploaderGadgetConfiguration(QString classId, QSettings *qSettings, QObject *parent) :
37 IUAVGadgetConfiguration(classId, parent),
38 m_defaultPort("Unknown"),
39 m_defaultSpeed(QSerialPort::UnknownBaud),
40 m_defaultDataBits(QSerialPort::UnknownDataBits),
41 m_defaultFlow(QSerialPort::UnknownFlowControl),
42 m_defaultParity(QSerialPort::UnknownParity),
43 m_defaultStopBits(QSerialPort::UnknownStopBits),
44 m_defaultTimeOut(5000)
46 // if a saved configuration exists load it
47 if (qSettings != 0) {
48 QSerialPort::BaudRate speed;
49 QSerialPort::DataBits databits;
50 QSerialPort::FlowControl flow;
51 QSerialPort::Parity parity;
52 QSerialPort::StopBits stopbits;
54 int ispeed = qSettings->value("defaultSpeed").toInt();
55 int idatabits = qSettings->value("defaultDataBits").toInt();
56 int iflow = qSettings->value("defaultFlow").toInt();
57 int iparity = qSettings->value("defaultParity").toInt();
58 int istopbits = qSettings->value("defaultStopBits").toInt();
59 QString port = qSettings->value("defaultPort").toString();
61 databits = (QSerialPort::DataBits)idatabits;
62 flow = (QSerialPort::FlowControl)iflow;
63 parity = (QSerialPort::Parity)iparity;
64 stopbits = (QSerialPort::StopBits)istopbits;
65 speed = (QSerialPort::BaudRate)ispeed;
66 m_defaultPort = port;
67 m_defaultSpeed = speed;
68 m_defaultDataBits = databits;
69 m_defaultFlow = flow;
70 m_defaultParity = parity;
71 m_defaultStopBits = stopbits;
75 /**
76 * Clones a configuration.
79 IUAVGadgetConfiguration *UploaderGadgetConfiguration::clone()
81 UploaderGadgetConfiguration *m = new UploaderGadgetConfiguration(this->classId());
83 m->m_defaultSpeed = m_defaultSpeed;
84 m->m_defaultDataBits = m_defaultDataBits;
85 m->m_defaultFlow = m_defaultFlow;
86 m->m_defaultParity = m_defaultParity;
87 m->m_defaultStopBits = m_defaultStopBits;
88 m->m_defaultPort = m_defaultPort;
89 return m;
92 /**
93 * Saves a configuration.
96 void UploaderGadgetConfiguration::saveConfig(QSettings *qSettings) const
98 qSettings->setValue("defaultSpeed", m_defaultSpeed);
99 qSettings->setValue("defaultDataBits", m_defaultDataBits);
100 qSettings->setValue("defaultFlow", m_defaultFlow);
101 qSettings->setValue("defaultParity", m_defaultParity);
102 qSettings->setValue("defaultStopBits", m_defaultStopBits);
103 qSettings->setValue("defaultPort", m_defaultPort);