Show pressure for Brick PRS1 machines, Update Weight/BMI/Zombie Overview graphs when changed in daily view

This commit is contained in:
Mark Watkins 2011-12-11 01:24:45 +10:00
parent 8761a810c6
commit 186e806a8c
3 changed files with 85 additions and 18 deletions

View File

@ -486,6 +486,14 @@ bool PRS1Loader::ParseSummary(Machine *mach, qint32 sequence, quint32 timestamp,
duration=data[offset+0x12] | (data[0x13] << 8); duration=data[offset+0x12] | (data[0x13] << 8);
duration*=2; duration*=2;
session->really_set_last(qint64(timestamp+duration)*1000L); session->really_set_last(qint64(timestamp+duration)*1000L);
if (max>0) {
session->setMin(CPAP_Pressure,min);
session->setMax(CPAP_Pressure,max);
} else {
session->setWavg(CPAP_Pressure,min );
}
} else { } else {
// 0X28 & 0X29 is length on r5 // 0X28 & 0X29 is length on r5

View File

@ -143,8 +143,8 @@ Daily::Daily(QWidget *parent,gGraphView * shared, MainWindow *mw)
fg->AddLayer((new gFlagsLine(CPAP_FlowLimit,QColor("black"),"FL"))); fg->AddLayer((new gFlagsLine(CPAP_FlowLimit,QColor("black"),"FL")));
fg->AddLayer((new gFlagsLine(CPAP_RERA,QColor("gold"),"RE"))); fg->AddLayer((new gFlagsLine(CPAP_RERA,QColor("gold"),"RE")));
fg->AddLayer((new gFlagsLine(CPAP_VSnore,QColor("red"),"VS"))); fg->AddLayer((new gFlagsLine(CPAP_VSnore,QColor("red"),"VS")));
//fg->AddLayer(AddCPAP(new gFlagsLine(flags[8],QColor("dark green"),"U0E"))); //fg->AddLayer((new gFlagsLine(PRS1_0B,QColor("dark green"),"U0B")));
//fg->AddLayer(AddCPAP(new gFlagsLine(flags[10],QColor("red"),"VS2")); //fg->AddLayer((new gFlagsLine(CPAP_VSnore2,QColor("red"),"VS2")));
SF->setBlockZoom(true); SF->setBlockZoom(true);
SF->AddLayer(new gShadowArea()); SF->AddLayer(new gShadowArea());
SF->AddLayer(new gYSpacer(),LayerLeft,gYAxis::Margin); SF->AddLayer(new gYSpacer(),LayerLeft,gYAxis::Margin);
@ -907,9 +907,16 @@ void Daily::Load(QDate date)
sl.append("Starts"); sl.append("Starts");
sl.append("Notes"); sl.append("Notes");
ui->bookmarkTable->setHorizontalHeaderLabels(sl); ui->bookmarkTable->setHorizontalHeaderLabels(sl);
ui->ZombieMeter->blockSignals(true);
ui->weightSpinBox->blockSignals(true);
ui->ouncesSpinBox->blockSignals(true);
ui->weightSpinBox->setValue(0); ui->weightSpinBox->setValue(0);
ui->ouncesSpinBox->setValue(0); ui->ouncesSpinBox->setValue(0);
ui->ZombieMeter->setValue(5); ui->ZombieMeter->setValue(5);
ui->ouncesSpinBox->blockSignals(false);
ui->weightSpinBox->blockSignals(false);
ui->ZombieMeter->blockSignals(false);
ui->BMI->display(0); ui->BMI->display(0);
ui->BMI->setVisible(false); ui->BMI->setVisible(false);
ui->BMIlabel->setVisible(false); ui->BMIlabel->setVisible(false);
@ -925,7 +932,9 @@ void Daily::Load(QDate date)
double kg=journal->settings["Weight"].toDouble(&ok); double kg=journal->settings["Weight"].toDouble(&ok);
if (PROFILE["Units"].toString()=="metric") { if (PROFILE["Units"].toString()=="metric") {
ui->weightSpinBox->setDecimals(3); ui->weightSpinBox->setDecimals(3);
ui->weightSpinBox->blockSignals(true);
ui->weightSpinBox->setValue(kg); ui->weightSpinBox->setValue(kg);
ui->weightSpinBox->blockSignals(false);
ui->ouncesSpinBox->setVisible(false); ui->ouncesSpinBox->setVisible(false);
ui->weightSpinBox->setSuffix("Kg"); ui->weightSpinBox->setSuffix("Kg");
} else { } else {
@ -934,8 +943,12 @@ void Daily::Load(QDate date)
double oz; double oz;
double frac=modf(ounces,&oz); double frac=modf(ounces,&oz);
ounces=(int(ounces) % 16)+frac; ounces=(int(ounces) % 16)+frac;
ui->weightSpinBox->blockSignals(true);
ui->ouncesSpinBox->blockSignals(true);
ui->weightSpinBox->setValue(pounds); ui->weightSpinBox->setValue(pounds);
ui->ouncesSpinBox->setValue(ounces); ui->ouncesSpinBox->setValue(ounces);
ui->ouncesSpinBox->blockSignals(false);
ui->weightSpinBox->blockSignals(false);
ui->weightSpinBox->setSuffix("lb"); ui->weightSpinBox->setSuffix("lb");
ui->weightSpinBox->setDecimals(0); ui->weightSpinBox->setDecimals(0);
@ -951,8 +964,11 @@ void Daily::Load(QDate date)
} }
} }
if (journal->settings.contains("ZombieMeter")) if (journal->settings.contains("ZombieMeter")) {
ui->ZombieMeter->blockSignals(true);
ui->ZombieMeter->setValue(journal->settings["ZombieMeter"].toDouble(&ok)); ui->ZombieMeter->setValue(journal->settings["ZombieMeter"].toDouble(&ok));
ui->ZombieMeter->blockSignals(false);
}
if (journal->settings.contains("BookmarkStart")) { if (journal->settings.contains("BookmarkStart")) {
QVariantList start=journal->settings["BookmarkStart"].toList(); QVariantList start=journal->settings["BookmarkStart"].toList();
@ -1450,23 +1466,29 @@ void Daily::on_removeBookmarkButton_clicked()
BookmarksChanged=true; BookmarksChanged=true;
} }
} }
void Daily::on_ZombieMeter_valueChanged(int action)
void Daily::on_ZombieMeter_actionTriggered(int action)
{ {
Q_UNUSED(action); Q_UNUSED(action);
ZombieMeterMoved=true; ZombieMeterMoved=true;
Session *journal=GetJournalSession(previous_date);
if (!journal) {
journal=CreateJournalSession(previous_date);
}
journal->settings["ZombieMeter"]=ui->ZombieMeter->value();
journal->SetChanged(true);
gGraph *g;
if (mainwin->getOverview()) {
g=mainwin->getOverview()->graphView()->findGraph("Zombie");
if (g) g->setDay(NULL);
//mainwin->getOverview()->RedrawGraphs();
}
} }
//void Daily::on_EnergySlider_sliderMoved(int position) void Daily::on_ZombieMeter_actionTriggered(int action)
//{ {
// position=position; }
//Session *s=GetJournalSession(previous_date);
//if (!s)
// s=CreateJournalSession(previous_date);
//s->summary[JOURNAL_Energy]=position;
//s->SetChanged(true);
//}
void Daily::on_bookmarkTable_itemChanged(QTableWidgetItem *item) void Daily::on_bookmarkTable_itemChanged(QTableWidgetItem *item)
{ {
Q_UNUSED(item); Q_UNUSED(item);
@ -1476,30 +1498,64 @@ void Daily::on_weightSpinBox_valueChanged(double arg1)
{ {
bool ok; bool ok;
double height=PROFILE["Height"].toDouble(&ok)/100.0; double height=PROFILE["Height"].toDouble(&ok)/100.0;
Session *journal=GetJournalSession(previous_date);
if (!journal) {
journal=CreateJournalSession(previous_date);
}
double kg; double kg;
if (PROFILE["Units"].toString()=="metric") if (PROFILE["Units"].toString()=="metric")
kg=arg1; kg=arg1;
else { else {
kg=(arg1*pound_convert) + (ui->ouncesSpinBox->value()*ounce_convert); kg=(arg1*pound_convert) + (ui->ouncesSpinBox->value()*ounce_convert);
} }
journal->settings["Weight"]=kg;
gGraphView *gv=mainwin->getOverview()->graphView();
gGraph *g;
if (gv) {
g=gv->findGraph("Weight");
if (g) g->setDay(NULL);
}
if ((height>0) && (kg>0)) { if ((height>0) && (kg>0)) {
double bmi=kg/(height * height); double bmi=kg/(height * height);
ui->BMI->display(bmi); ui->BMI->display(bmi);
ui->BMI->setVisible(true); ui->BMI->setVisible(true);
//ui->BMI->setDigitCount(5); journal->settings["BMI"]=bmi;
//ui->BMI->setSmallDecimalPoint(true); if (gv) {
g=gv->findGraph("BMI");
if (g) g->setDay(NULL);
}
} }
journal->SetChanged(true);
} }
void Daily::on_ouncesSpinBox_valueChanged(int arg1) void Daily::on_ouncesSpinBox_valueChanged(int arg1)
{ {
bool ok; bool ok;
Session *journal=GetJournalSession(previous_date);
if (!journal) {
journal=CreateJournalSession(previous_date);
}
double height=PROFILE["Height"].toDouble(&ok)/100.0; double height=PROFILE["Height"].toDouble(&ok)/100.0;
double kg=(ui->weightSpinBox->value()*pound_convert) + (arg1*ounce_convert); double kg=(ui->weightSpinBox->value()*pound_convert) + (arg1*ounce_convert);
journal->settings["Weight"]=kg;
gGraph *g;
if (mainwin->getOverview()) {
g=mainwin->getOverview()->graphView()->findGraph("Weight");
if (g) g->setDay(NULL);
}
if ((height>0) && (kg>0)) { if ((height>0) && (kg>0)) {
double bmi=kg/(height * height); double bmi=kg/(height * height);
ui->BMI->display(bmi); ui->BMI->display(bmi);
ui->BMI->setVisible(true); ui->BMI->setVisible(true);
//ui->BMI->setDigitCount(5);
//ui->BMI->setSmallDecimalPoint(true); journal->settings["BMI"]=bmi;
if (mainwin->getOverview()) {
g=mainwin->getOverview()->graphView()->findGraph("BMI");
if (g) g->setDay(NULL);
}
} }
journal->SetChanged(true);
} }

View File

@ -89,6 +89,8 @@ private slots:
void on_ouncesSpinBox_valueChanged(int arg1); void on_ouncesSpinBox_valueChanged(int arg1);
void on_ZombieMeter_valueChanged(int value);
protected: protected:
private: private:
@ -130,3 +132,4 @@ private:
#endif // DAILY_H #endif // DAILY_H