2011-06-26 08:30:44 +00:00
|
|
|
/********************************************************************
|
|
|
|
SleepLib Day Class Header
|
|
|
|
Copyright (c)2011 Mark Watkins <jedimark@users.sourceforge.net>
|
|
|
|
License: GPL
|
|
|
|
*********************************************************************/
|
|
|
|
|
|
|
|
#ifndef DAY_H
|
|
|
|
#define DAY_H
|
|
|
|
|
2011-07-27 09:21:53 +00:00
|
|
|
#include "SleepLib/machine_common.h"
|
2011-06-26 08:30:44 +00:00
|
|
|
#include "SleepLib/machine.h"
|
2011-07-27 09:21:53 +00:00
|
|
|
#include "SleepLib/event.h"
|
2011-06-26 08:30:44 +00:00
|
|
|
#include "SleepLib/session.h"
|
|
|
|
|
|
|
|
class OneTypePerDay
|
|
|
|
{
|
|
|
|
};
|
|
|
|
|
|
|
|
class Machine;
|
|
|
|
class Session;
|
|
|
|
class Day
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Day(Machine *m);
|
|
|
|
~Day();
|
|
|
|
void AddSession(Session *s);
|
|
|
|
|
|
|
|
MachineType machine_type();
|
|
|
|
|
2011-07-31 20:24:43 +00:00
|
|
|
int count(ChannelID code);
|
|
|
|
EventDataType min(ChannelID code);
|
|
|
|
EventDataType max(ChannelID code);
|
2011-09-10 15:43:40 +00:00
|
|
|
EventDataType cph(ChannelID code);
|
|
|
|
EventDataType sph(ChannelID code);
|
2011-07-31 20:24:43 +00:00
|
|
|
EventDataType p90(ChannelID code);
|
|
|
|
EventDataType avg(ChannelID code);
|
|
|
|
EventDataType sum(ChannelID code);
|
|
|
|
EventDataType wavg(ChannelID code);
|
|
|
|
|
|
|
|
EventDataType percentile(ChannelID mc,double percent);
|
2011-06-26 08:30:44 +00:00
|
|
|
|
|
|
|
// Note, the following convert to doubles without considering the consequences fully.
|
2011-07-31 20:24:43 +00:00
|
|
|
EventDataType settings_avg(ChannelID code);
|
|
|
|
EventDataType settings_wavg(ChannelID code);
|
|
|
|
EventDataType settings_sum(ChannelID code);
|
|
|
|
EventDataType settings_min(ChannelID code);
|
|
|
|
EventDataType settings_max(ChannelID code);
|
2011-06-26 08:30:44 +00:00
|
|
|
|
2011-07-27 09:21:53 +00:00
|
|
|
qint64 first() { return d_first; }
|
|
|
|
qint64 last() { return d_last; }
|
2011-07-29 14:58:44 +00:00
|
|
|
void setFirst(qint64 val) { d_first=val; }
|
|
|
|
void setLast(qint64 val) { d_last=val; }
|
2011-07-31 20:24:43 +00:00
|
|
|
qint64 first(ChannelID code);
|
|
|
|
qint64 last(ChannelID code);
|
2011-07-27 09:21:53 +00:00
|
|
|
|
2011-06-26 08:30:44 +00:00
|
|
|
|
2011-07-02 14:35:50 +00:00
|
|
|
qint64 total_time(); // in milliseconds
|
2011-10-02 05:06:58 +00:00
|
|
|
EventDataType hours() { return double(total_time())/3600000.0; }
|
2011-06-26 08:30:44 +00:00
|
|
|
|
2011-07-27 09:21:53 +00:00
|
|
|
Session *operator [](int i) { return sessions[i]; }
|
2011-06-26 08:30:44 +00:00
|
|
|
|
2011-07-31 20:24:43 +00:00
|
|
|
QVector<Session *>::iterator begin() { return sessions.begin(); }
|
|
|
|
QVector<Session *>::iterator end() { return sessions.end(); }
|
2011-06-26 08:30:44 +00:00
|
|
|
|
2011-08-01 04:34:55 +00:00
|
|
|
int size() { return sessions.size(); }
|
2011-06-26 08:30:44 +00:00
|
|
|
Machine *machine;
|
|
|
|
|
|
|
|
void OpenEvents();
|
2011-07-31 20:24:43 +00:00
|
|
|
QVector<Session *> & getSessions() { return sessions; }
|
2011-08-07 11:37:56 +00:00
|
|
|
bool channelExists(ChannelID id);
|
2011-09-17 12:39:00 +00:00
|
|
|
bool channelHasData(ChannelID id);
|
2011-09-18 15:43:14 +00:00
|
|
|
bool settingExists(ChannelID id);
|
|
|
|
|
2011-06-26 08:30:44 +00:00
|
|
|
protected:
|
2011-07-31 20:24:43 +00:00
|
|
|
QVector<Session *> sessions;
|
2011-07-02 14:35:50 +00:00
|
|
|
qint64 d_first,d_last;
|
2011-06-26 08:30:44 +00:00
|
|
|
private:
|
|
|
|
bool d_firstsession;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
#endif // DAY_H
|