~ubuntu-branches/ubuntu/saucy/goldencheetah/saucy

1.1.2 by KURASHIKI Satoru
Import upstream version 3.0
1
/*
2
 * Copyright (c) 2009 Mark Liversedge (liversedge@gmail.com)
3
 *
4
 * This program is free software; you can redistribute it and/or modify it
5
 * under the terms of the GNU General Public License as published by the Free
6
 * Software Foundation; either version 2 of the License, or (at your option)
7
 * any later version.
8
 *
9
 * This program is distributed in the hope that it will be useful, but WITHOUT
10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
12
 * more details.
13
 *
14
 * You should have received a copy of the GNU General Public License along
15
 * with this program; if not, write to the Free Software Foundation, Inc., 51
16
 * Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
17
 */
18
19
#include <QProgressDialog>
20
#include "ANTplusController.h"
21
#include "QuarqdClient.h"
22
#include "RealtimeData.h"
23
24
ANTplusController::ANTplusController(TrainTool *parent, DeviceConfiguration *dc) : RealtimeController(parent, dc)
25
{
26
    myANTplus = new QuarqdClient (parent, dc);
27
}
28
29
30
int
31
ANTplusController::start()
32
{
33
    myANTplus->start();
34
    return 0;
35
}
36
37
38
int
39
ANTplusController::restart()
40
{
41
    return myANTplus->restart();
42
}
43
44
45
int
46
ANTplusController::pause()
47
{
48
    return myANTplus->pause();
49
}
50
51
52
int
53
ANTplusController::stop()
54
{
55
    return myANTplus->stop();
56
}
57
58
59
bool
60
ANTplusController::discover(QString)
61
{
62
    return myANTplus->discover(QString);
63
}
64
65
66
bool ANTplusController::doesPush() { return false; }
67
bool ANTplusController::doesPull() { return true; }
68
bool ANTplusController::doesLoad() { return false; }
69
70
/*
71
 * gets called from the GUI to get updated telemetry.
72
 * so whilst we are at it we check button status too and
73
 * act accordingly.
74
 *
75
 */
76
void
77
ANTplusController::getRealtimeData(RealtimeData &rtData)
78
{
79
    if(!myANTplus->isRunning())
80
    {
81
        QMessageBox msgBox;
82
        msgBox.setText("Cannot Connect to Quarqd");
83
        msgBox.setIcon(QMessageBox::Critical);
84
        msgBox.exec();
85
        parent->Stop(1);
86
        return;
87
    }
88
    // get latest telemetry
89
    rtData = myANTplus->getRealtimeData();
90
    processRealtimeData(rtData);
91
}
92
93
void ANTplusController::pushRealtimeData(RealtimeData &) { } // update realtime data with current values