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

« back to all changes in this revision

Viewing changes to src/RealtimeWindow.h

  • Committer: Package Import Robot
  • Author(s): KURASHIKI Satoru
  • Date: 2013-08-18 07:02:45 UTC
  • mfrom: (4.1.8 sid)
  • Revision ID: package-import@ubuntu.com-20130818070245-zgdvb47e1k3mtgil
Tags: 3.0-3
debian/control: remove needless dependency. (Closes: #719571)

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Copyright (c) 2009 Sean C. Rhea (srhea@srhea.net)
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
 
#ifndef _GC_RealtimeWindow_h
20
 
#define _GC_RealtimeWindow_h 1
21
 
 
22
 
#include <QtGui>
23
 
#include <QTimer>
24
 
#include "MainWindow.h"
25
 
#include "DeviceConfiguration.h"
26
 
#include "DeviceTypes.h"
27
 
#include "ErgFile.h"
28
 
#include "ErgFilePlot.h"
29
 
 
30
 
class TrainTool;
31
 
class TrainTabs;
32
 
 
33
 
// Status settings
34
 
#define RT_MODE_ERGO    0x0001        // load generation modes
35
 
#define RT_MODE_SPIN    0x0002        // spinscan like modes
36
 
#define RT_RUNNING      0x0100        // is running now
37
 
#define RT_PAUSED       0x0200        // is paused
38
 
#define RT_RECORDING    0x0400        // is recording to disk
39
 
#define RT_WORKOUT      0x0800        // is running a workout
40
 
#define RT_STREAMING    0x1000        // is streaming to a remote peer
41
 
 
42
 
#define REFRESHRATE    200 // screen refresh in milliseconds
43
 
#define STREAMRATE     200 // rate at which we stream updates to remote peer
44
 
#define SAMPLERATE     1000 // disk update in milliseconds
45
 
#define LOADRATE       1000 // rate at which load is adjusted
46
 
 
47
 
 
48
 
class RealtimeController;
49
 
class RealtimePlot;
50
 
class RealtimeData;
51
 
 
52
 
class RealtimeWindow : public QWidget
53
 
{
54
 
    Q_OBJECT
55
 
 
56
 
    public:
57
 
 
58
 
        RealtimeController *deviceController;   // read from
59
 
        RealtimeController *streamController;   // send out to
60
 
 
61
 
        RealtimeWindow(MainWindow *, TrainTool *, const QDir &);
62
 
 
63
 
        void updateData(RealtimeData &);      // to update telemetry by push devices
64
 
        void newLap();                      // start new Lap!
65
 
        void nextDisplayMode();     // show next display mode
66
 
        void setDeviceController();     // based upon selected device
67
 
        void setStreamController();     // based upon selected device
68
 
 
69
 
    public slots:
70
 
 
71
 
        void Start();       // when start button is pressed
72
 
        void Pause();       // when Paude is pressed
73
 
        void Stop(int status=0);        // when stop button is pressed
74
 
 
75
 
        void FFwd();        // jump forward when in a workout
76
 
        void Rewind();      // jump backwards when in a workout
77
 
        void FFwdLap();     // jump forward to next Lap marker
78
 
        void Higher();      // set load/gradient higher
79
 
        void Lower();       // set load/gradient higher
80
 
 
81
 
        void SelectDevice(int); // when combobox chooses device
82
 
        void SelectRecord();    // when checkbox chooses record mode
83
 
        void SelectStream(int);    // when remote server to stream to is selected
84
 
        void SelectWorkout();    // to select a Workout to use
85
 
 
86
 
        // Timed actions
87
 
        void guiUpdate();           // refreshes the telemetry
88
 
        void diskUpdate();          // writes to CSV file
89
 
        void streamUpdate();        // writes to remote Peer
90
 
        void loadUpdate();          // sets Load on CT like devices
91
 
 
92
 
        // Handle config updates
93
 
        void configUpdate();            // called when config changes
94
 
 
95
 
        // When no config has been setup
96
 
        void warnnoConfig();
97
 
 
98
 
    protected:
99
 
 
100
 
 
101
 
        // passed from MainWindow
102
 
        QDir home;
103
 
        MainWindow *main;
104
 
        TrainTool *trainTool;
105
 
 
106
 
        QList<DeviceConfiguration> Devices;
107
 
        bool useMetricUnits;
108
 
 
109
 
        // updated with a RealtimeData object either from
110
 
        // update() - from a push device (quarqd ANT+)
111
 
        // Device->getRealtimeData() - from a pull device (Computrainer)
112
 
        double displayPower, displayHeartRate, displayCadence,
113
 
               displayLoad, displayGradient, displaySpeed;
114
 
        double displayDistance, displayWorkoutDistance;
115
 
        int displayLap;            // user increment for Lap
116
 
        int displayWorkoutLap;     // which Lap in the workout are we at?
117
 
 
118
 
        // for non-zero average calcs
119
 
        int pwrcount, cadcount, hrcount, spdcount, lodcount, grdcount; // for NZ average calc
120
 
        int status;
121
 
        int displaymode;
122
 
 
123
 
        QFile *recordFile;      // where we record!
124
 
        ErgFile *ergFile;       // workout file
125
 
 
126
 
        long total_msecs,
127
 
             lap_msecs,
128
 
             load_msecs;
129
 
        QTime load_period;
130
 
 
131
 
        uint session_elapsed_msec, lap_elapsed_msec;
132
 
        QTime session_time, lap_time;
133
 
 
134
 
        // GUI WIDGETS
135
 
        // layout
136
 
        RealtimePlot *rtPlot;
137
 
        ErgFilePlot  *ergPlot;
138
 
 
139
 
        QVBoxLayout *main_layout;
140
 
 
141
 
        // labels
142
 
        QLabel *powerLabel,
143
 
                    *heartrateLabel,
144
 
                    *speedLabel,
145
 
                    *cadenceLabel,
146
 
                    *loadLabel,
147
 
                    *lapLabel,
148
 
                    *laptimeLabel,
149
 
                    *timeLabel,
150
 
                    *distanceLabel;
151
 
 
152
 
        double avgPower, avgHeartRate, avgSpeed, avgCadence, avgLoad, avgGradient;
153
 
        QLabel *avgpowerLabel,
154
 
                    *avgheartrateLabel,
155
 
                    *avgspeedLabel,
156
 
                    *avgcadenceLabel,
157
 
                    *avgloadLabel;
158
 
 
159
 
        QHBoxLayout *button_layout,
160
 
                    *option_layout;
161
 
        QGridLayout *timer_layout;
162
 
        QVBoxLayout *controls_layout;
163
 
        QCheckBox   *recordSelector;
164
 
        QComboBox   *deviceSelector,
165
 
                    *streamSelector;
166
 
        QPushButton *startButton,
167
 
                    *pauseButton,
168
 
                    *stopButton;
169
 
 
170
 
        QGridLayout *gridLayout;
171
 
 
172
 
        // the LCDs
173
 
        QLCDNumber *powerLCD,
174
 
                    *heartrateLCD,
175
 
                    *speedLCD,
176
 
                    *cadenceLCD,
177
 
                    *loadLCD,
178
 
                    *lapLCD,
179
 
                    *laptimeLCD,
180
 
                    *timeLCD,
181
 
                    *distanceLCD;
182
 
 
183
 
        QLCDNumber *avgpowerLCD,
184
 
                    *avgheartrateLCD,
185
 
                    *avgspeedLCD,
186
 
                    *avgcadenceLCD,
187
 
                    *avgloadLCD;
188
 
 
189
 
        QTimer      *gui_timer,     // refresh the gui
190
 
                    *stream_timer,  // send telemetry to server
191
 
                    *load_timer,    // change the load on the device
192
 
                    *disk_timer;    // write to .CSV file
193
 
 
194
 
};
195
 
 
196
 
#endif // _GC_RealtimeWindow_h
197