2
* Copyright (c) 2009 Sean C. Rhea (srhea@srhea.net)
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)
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
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
19
#ifndef _GC_RealtimeWindow_h
20
#define _GC_RealtimeWindow_h 1
24
#include "MainWindow.h"
25
#include "DeviceConfiguration.h"
26
#include "DeviceTypes.h"
28
#include "ErgFilePlot.h"
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
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
48
class RealtimeController;
52
class RealtimeWindow : public QWidget
58
RealtimeController *deviceController; // read from
59
RealtimeController *streamController; // send out to
61
RealtimeWindow(MainWindow *, TrainTool *, const QDir &);
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
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
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
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
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
92
// Handle config updates
93
void configUpdate(); // called when config changes
95
// When no config has been setup
101
// passed from MainWindow
104
TrainTool *trainTool;
106
QList<DeviceConfiguration> Devices;
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?
118
// for non-zero average calcs
119
int pwrcount, cadcount, hrcount, spdcount, lodcount, grdcount; // for NZ average calc
123
QFile *recordFile; // where we record!
124
ErgFile *ergFile; // workout file
131
uint session_elapsed_msec, lap_elapsed_msec;
132
QTime session_time, lap_time;
136
RealtimePlot *rtPlot;
137
ErgFilePlot *ergPlot;
139
QVBoxLayout *main_layout;
152
double avgPower, avgHeartRate, avgSpeed, avgCadence, avgLoad, avgGradient;
153
QLabel *avgpowerLabel,
159
QHBoxLayout *button_layout,
161
QGridLayout *timer_layout;
162
QVBoxLayout *controls_layout;
163
QCheckBox *recordSelector;
164
QComboBox *deviceSelector,
166
QPushButton *startButton,
170
QGridLayout *gridLayout;
173
QLCDNumber *powerLCD,
183
QLCDNumber *avgpowerLCD,
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
196
#endif // _GC_RealtimeWindow_h